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>
This commit is contained in:
bors[bot] 2020-01-23 20:54:49 +00:00 committed by GitHub
commit 8ab8834ccb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 5 deletions

View file

@ -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;

View file

@ -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},

View file

@ -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},
@ -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},