add binding for tele/switch/speedup/tune button

This commit is contained in:
Andrii 2020-05-15 22:53:26 +03:00 committed by heinrich5991
parent d3df450715
commit 0f1af41911
3 changed files with 23 additions and 10 deletions

View file

@ -31,6 +31,7 @@
#include "auto_map.h"
#include "editor.h"
static const char *VANILLA_IMAGES[] = {
"bg_cloud1",
"bg_cloud2",
@ -1333,9 +1334,8 @@ void CEditor::DoToolbar(CUIRect ToolBar)
// do tele/tune/switch/speedup button
{
int (*pPopupFunc)(CEditor *peditor, CUIRect View, void *pContext) = NULL;
const char *aButtonName = "Modifier";
const char *aButtonName = 0;
float Height = 0.0f;
int Checked = -1;
CLayerTiles *pS = (CLayerTiles *)GetSelectedLayerType(0, LAYERTYPE_TILES);
if(pS)
{
@ -1344,43 +1344,45 @@ void CEditor::DoToolbar(CUIRect ToolBar)
aButtonName = "Switch";
pPopupFunc = PopupSwitch;
Height = 36;
Checked = 0;
}
else if(pS == m_Map.m_pSpeedupLayer)
{
aButtonName = "Speedup";
pPopupFunc = PopupSpeedup;
Height = 53;
Checked = 0;
}
else if(pS == m_Map.m_pTuneLayer)
{
aButtonName = "Tune";
pPopupFunc = PopupTune;
Height = 23;
Checked = 0;
}
else if(pS == m_Map.m_pTeleLayer)
{
aButtonName = "Tele";
pPopupFunc = PopupTele;
Height = 23;
Checked = 0;
}
if(Checked == 0)
if(aButtonName != 0)
{
static char aBuf[64];
str_format(aBuf, sizeof(aBuf), "[ctrl+a] %s", aButtonName);
TB_Bottom.VSplitLeft(60.0f, &Button, &TB_Bottom);
static int s_ModifierButton = 0;
if(DoButton_Ex(&s_ModifierButton, aButtonName, Checked, &Button, 0, aButtonName, CUI::CORNER_ALL))
if(DoButton_Ex(&s_ModifierButton, aButtonName, 0, &Button, 0, aBuf, CUI::CORNER_ALL)
|| (ctrlPressed && Input()->KeyPress(KEY_A)))
{
static int s_ModifierPopupID = 0;
UiInvokePopupMenu(&s_ModifierPopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, Height, pPopupFunc);
if(!UiPopupExists(&s_ModifierPopupID))
{
UiInvokePopupMenu(&s_ModifierPopupID, 0, Button.x, Button.y + Button.h, 120, Height, pPopupFunc);
}
}
TB_Bottom.VSplitLeft(5.0f, 0, &TB_Bottom);
}
}
}
}

View file

@ -956,6 +956,7 @@ public:
void UiInvokePopupMenu(void *pID, int Flags, float X, float Y, float W, float H, int (*pfnFunc)(CEditor *pEditor, CUIRect Rect, void *pContext), void *pExtra=0);
void UiDoPopupMenu();
bool UiPopupExists(void *pID);
int UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, int Current, int Min, int Max, int Step, float Scale, const char *pToolTip, bool IsDegree=false, bool IsHex=false, int corners=CUI::CORNER_ALL, ColorRGBA* Color=0);

View file

@ -98,6 +98,16 @@ void CEditor::UiDoPopupMenu()
}
}
bool CEditor::UiPopupExists(void *pid)
{
for(int i = 0; i < g_UiNumPopups; i++)
{
if(s_UiPopups[i].m_pId == pid)
return true;
}
return false;
}
int CEditor::PopupGroup(CEditor *pEditor, CUIRect View, void *pContext)
{