New editor feature: Show if tele and switch numbers are used already

This commit is contained in:
def 2014-05-17 17:19:48 +02:00
parent 54609b3fab
commit 0a49301eea
3 changed files with 51 additions and 8 deletions

View file

@ -2237,7 +2237,7 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar)
}
int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *pNewVal)
int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *pNewVal, vec4 color)
{
int Change = -1;
@ -2258,7 +2258,7 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
Shifter.VSplitRight(10.0f, &Shifter, &Inc);
Shifter.VSplitLeft(10.0f, &Dec, &Shifter);
str_format(aBuf, sizeof(aBuf),"%d", pProps[i].m_Value);
RenderTools()->DrawUIRect(&Shifter, vec4(1,1,1,0.5f), 0, 0.0f);
RenderTools()->DrawUIRect(&Shifter, color, 0, 0.0f);
UI()->DoLabel(&Shifter, aBuf, 10.0f, 0, -1);
if(DoButton_ButtonDec(&pIDs[i], 0, 0, &Dec, 0, "Decrease"))

View file

@ -689,7 +689,7 @@ public:
CLayer *GetSelectedLayer(int Index);
CLayerGroup *GetSelectedGroup();
int DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal);
int DoProperties(CUIRect *pToolbox, CProperty *pProps, int *pIDs, int *pNewVal, vec4 color = vec4(1,1,1,0.5f));
int m_Mode;
int m_Dialog;

View file

@ -1035,10 +1035,32 @@ int CEditor::PopupTele(CEditor *pEditor, CUIRect View)
static int s_aIds[NUM_PROPS] = {0};
int NewVal = 0;
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
static vec4 s_color = vec4(1,1,1,0.5f);
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal, s_color);
if(Prop == PROP_TELE)
pEditor->m_TeleNumber = clamp(NewVal, 0, 255);
{
NewVal = clamp(NewVal, 0, 255);
CLayerTele *gl = pEditor->m_Map.m_pTeleLayer;
for(int y = 0; y < gl->m_Height; ++y)
{
for(int x = 0; x < gl->m_Width; ++x)
{
if(gl->m_pTeleTile[y*gl->m_Width+x].m_Number == NewVal)
{
s_color = vec4(1,0.5f,0.5f,0.5f);
goto done;
}
}
}
s_color = vec4(0.5f,1,0.5f,0.5f);
done:
pEditor->m_TeleNumber = NewVal;
}
return 0;
}
@ -1097,12 +1119,33 @@ int CEditor::PopupSwitch(CEditor *pEditor, CUIRect View)
static int s_aIds[NUM_PROPS] = {0};
int NewVal = 0;
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal);
static vec4 s_color = vec4(1,1,1,0.5f);
int Prop = pEditor->DoProperties(&View, aProps, s_aIds, &NewVal, s_color);
if(Prop == PROP_SwitchNumber)
pEditor->m_SwitchNum = clamp(NewVal, 0, 255);
{
NewVal = clamp(NewVal, 0, 255);
CLayerSwitch *gl = pEditor->m_Map.m_pSwitchLayer;
for(int y = 0; y < gl->m_Height; ++y)
{
for(int x = 0; x < gl->m_Width; ++x)
{
if(gl->m_pSwitchTile[y*gl->m_Width+x].m_Number == NewVal)
{
s_color = vec4(1,0.5f,0.5f,0.5f);
goto done;
}
}
}
s_color = vec4(0.5f,1,0.5f,0.5f);
done:
pEditor->m_SwitchNum = NewVal;
}
if(Prop == PROP_SwitchDelay)
pEditor->m_SwitchDelay = clamp(NewVal, 0, 255);
pEditor->m_SwitchDelay = clamp(NewVal, 0, 255);
return 0;
}