mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 05:58:19 +00:00
Merge pull request #8858 from ChillerDragon/pr_action_info
Add quick actions for Show Info Off/Dec/Hex
This commit is contained in:
commit
50b0af1614
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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; }
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue