diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 0b070e301..879626b89 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -306,20 +306,20 @@ CUi::EPopupMenuFunctionResult CEditor::PopupMenuSettings(void *pContext, CUIRect static int s_ButtonOff = 0; static int s_ButtonDec = 0; static int s_ButtonHex = 0; - if(pEditor->DoButton_Ex(&s_ButtonOff, "Off", pEditor->m_ShowTileInfo == SHOW_TILE_OFF, &Off, 0, "Do not show tile information", IGraphics::CORNER_L)) + CQuickAction *pAction = &pEditor->m_QuickActionShowInfoOff; + if(pEditor->DoButton_Ex(&s_ButtonOff, pAction->LabelShort(), pAction->Active(), &Off, 0, pAction->Description(), IGraphics::CORNER_L)) { - pEditor->m_ShowTileInfo = SHOW_TILE_OFF; - pEditor->m_ShowEnvelopePreview = SHOWENV_NONE; + pAction->Call(); } - if(pEditor->DoButton_Ex(&s_ButtonDec, "Dec", pEditor->m_ShowTileInfo == SHOW_TILE_DECIMAL, &Dec, 0, "[ctrl+i] Show tile information", IGraphics::CORNER_NONE)) + pAction = &pEditor->m_QuickActionShowInfoDec; + if(pEditor->DoButton_Ex(&s_ButtonDec, pAction->LabelShort(), pAction->Active(), &Dec, 0, pAction->Description(), IGraphics::CORNER_NONE)) { - pEditor->m_ShowTileInfo = SHOW_TILE_DECIMAL; - pEditor->m_ShowEnvelopePreview = SHOWENV_NONE; + pAction->Call(); } - if(pEditor->DoButton_Ex(&s_ButtonHex, "Hex", pEditor->m_ShowTileInfo == SHOW_TILE_HEXADECIMAL, &Hex, 0, "[ctrl+shift+i] Show tile information in hexadecimal", IGraphics::CORNER_R)) + pAction = &pEditor->m_QuickActionShowInfoHex; + if(pEditor->DoButton_Ex(&s_ButtonHex, pAction->LabelShort(), pAction->Active(), &Hex, 0, pAction->Description(), IGraphics::CORNER_R)) { - pEditor->m_ShowTileInfo = SHOW_TILE_HEXADECIMAL; - pEditor->m_ShowEnvelopePreview = SHOWENV_NONE; + pAction->Call(); } } diff --git a/src/game/editor/quick_action.h b/src/game/editor/quick_action.h index 05efca84e..124713643 100644 --- a/src/game/editor/quick_action.h +++ b/src/game/editor/quick_action.h @@ -52,6 +52,17 @@ public: int Color() { return m_pfnColorCallback(); } const char *Label() const { return m_pLabel; } + + // skips to the part of the label after the first colon + // useful for buttons that only show the state + const char *LabelShort() const + { + const char *pShort = str_find(m_pLabel, ": "); + if(!pShort) + return m_pLabel; + return pShort + 2; + } + const char *Description() const { return m_pDescription; } }; diff --git a/src/game/editor/quick_actions.h b/src/game/editor/quick_actions.h index d89dee77f..2e4f7b8dd 100644 --- a/src/game/editor/quick_actions.h +++ b/src/game/editor/quick_actions.h @@ -71,6 +71,39 @@ REGISTER_QUICK_ACTION( ALWAYS_FALSE, DEFAULT_BTN, "Pick mapres image for currently selected layer") +REGISTER_QUICK_ACTION( + ShowInfoOff, + "Show Info: Off", + [&]() { + m_ShowTileInfo = SHOW_TILE_OFF; + m_ShowEnvelopePreview = SHOWENV_NONE; + }, + ALWAYS_FALSE, + [&]() -> bool { return m_ShowTileInfo == SHOW_TILE_OFF; }, + DEFAULT_BTN, + "Do not show tile information") +REGISTER_QUICK_ACTION( + ShowInfoDec, + "Show Info: Dec", + [&]() { + m_ShowTileInfo = SHOW_TILE_DECIMAL; + m_ShowEnvelopePreview = SHOWENV_NONE; + }, + ALWAYS_FALSE, + [&]() -> bool { return m_ShowTileInfo == SHOW_TILE_DECIMAL; }, + DEFAULT_BTN, + "[ctrl+i] Show tile information") +REGISTER_QUICK_ACTION( + ShowInfoHex, + "Show Info: Hex", + [&]() { + m_ShowTileInfo = SHOW_TILE_HEXADECIMAL; + m_ShowEnvelopePreview = SHOWENV_NONE; + }, + ALWAYS_FALSE, + [&]() -> bool { return m_ShowTileInfo == SHOW_TILE_HEXADECIMAL; }, + DEFAULT_BTN, + "[ctrl+shift+i] Show tile information in hexadecimal") #undef ALWAYS_FALSE #undef DEFAULT_BTN