Skip to content

Commit

Permalink
Merge #2048
Browse files Browse the repository at this point in the history
2048: Display envelope name in popups r=12pm a=Learath2

A dropdown would've worked better, but we don't have one

Co-authored-by: Learath <learath2@gmail.com>
  • Loading branch information
bors[bot] and Learath2 committed Jan 23, 2020
2 parents 5c4fd72 + e567fde commit 8ab8834
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
47 changes: 47 additions & 0 deletions src/game/editor/editor.cpp
Expand Up @@ -3247,6 +3247,53 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
Change = i;
}
}
else if(pProps[i].m_Type == PROPTYPE_ENVELOPE)
{
CUIRect Inc, Dec;
char aBuf[64];
float FontSize = 10.0f;
int CurValue = pProps[i].m_Value;

Shifter.VSplitRight(10.0f, &Shifter, &Inc);
Shifter.VSplitLeft(10.0f, &Dec, &Shifter);

if(CurValue <= 0)
str_copy(aBuf, "None", sizeof(aBuf));
else
{
if(m_Map.m_lEnvelopes[CurValue - 1]->m_aName[0])
str_format(aBuf, sizeof(aBuf), "%d: %s", CurValue, m_Map.m_lEnvelopes[CurValue - 1]->m_aName);
else
str_format(aBuf, sizeof(aBuf), "%d", CurValue);

while(TextRender()->TextWidth(0, FontSize, aBuf, -1) > Shifter.w)
{
if(FontSize > 6.0f)
{
FontSize--;
}
else
{
aBuf[str_length(aBuf) - 4] = '\0';
str_append(aBuf, "...", sizeof(aBuf));
}
}
}

RenderTools()->DrawUIRect(&Shifter, Color, 0, 5.0f);
UI()->DoLabel(&Shifter, aBuf, FontSize, 0, -1);

if(DoButton_ButtonDec((char *) &pIDs[i] +1, 0, 0, &Dec, 0, "Previous Envelope"))
{
*pNewVal = pProps[i].m_Value-1;
Change = i;
}
if(DoButton_ButtonInc(((char *)&pIDs[i])+2, 0, 0, &Inc, 0, "Next Envelope"))
{
*pNewVal = pProps[i].m_Value+1;
Change = i;
}
}
}

return Change;
Expand Down
2 changes: 1 addition & 1 deletion src/game/editor/layer_tiles.cpp
Expand Up @@ -861,7 +861,7 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox)
{"Shift by", m_pEditor->m_ShiftBy, PROPTYPE_INT_SCROLL, 1, 100000},
{"Image", m_Image, PROPTYPE_IMAGE, 0, 0},
{"Color", Color, PROPTYPE_COLOR, 0, 0},
{"Color Env", m_ColorEnv+1, PROPTYPE_INT_STEP, 0, m_pEditor->m_Map.m_lEnvelopes.size()+1},
{"Color Env", m_ColorEnv+1, PROPTYPE_ENVELOPE, 0, 0},
{"Color TO", m_ColorEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Auto Rule", m_AutoMapperConfig, PROPTYPE_AUTOMAPPER, m_Image, 0},
{"Seed", m_Seed, PROPTYPE_INT_SCROLL, 0, 1000000000},
Expand Down
8 changes: 4 additions & 4 deletions src/game/editor/popups.cpp
Expand Up @@ -570,9 +570,9 @@ int CEditor::PopupQuad(CEditor *pEditor, CUIRect View)
CProperty aProps[] = {
{"Pos X", pCurrentQuad->m_aPoints[4].x/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Pos Y", pCurrentQuad->m_aPoints[4].y/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Pos. Env", pCurrentQuad->m_PosEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1},
{"Pos. Env", pCurrentQuad->m_PosEnv+1, PROPTYPE_ENVELOPE, 0, 0},
{"Pos. TO", pCurrentQuad->m_PosEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Color Env", pCurrentQuad->m_ColorEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1},
{"Color Env", pCurrentQuad->m_ColorEnv+1, PROPTYPE_ENVELOPE, 0, 0},
{"Color TO", pCurrentQuad->m_ColorEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000},

{0},
Expand Down Expand Up @@ -712,9 +712,9 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
{"Pan", pSource->m_Pan, PROPTYPE_BOOL, 0, 1},
{"Delay", pSource->m_TimeDelay, PROPTYPE_INT_SCROLL, 0, 1000000},
{"Falloff", pSource->m_Falloff, PROPTYPE_INT_SCROLL, 0, 255},
{"Pos. Env", pSource->m_PosEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1},
{"Pos. Env", pSource->m_PosEnv+1, PROPTYPE_ENVELOPE, 0, 0},
{"Pos. TO", pSource->m_PosEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000},
{"Sound Env", pSource->m_SoundEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1},
{"Sound Env", pSource->m_SoundEnv+1, PROPTYPE_ENVELOPE, 0, 0},
{"Sound. TO", pSource->m_PosEnvOffset, PROPTYPE_INT_SCROLL, -1000000, 1000000},

{0},
Expand Down

0 comments on commit 8ab8834

Please sign in to comment.