From 2abe4fbcfbe92b6b37a6f85919a9e3a3484349b8 Mon Sep 17 00:00:00 2001 From: Learath Date: Thu, 23 Jan 2020 20:26:06 +0100 Subject: [PATCH 1/3] Display envelope name --- src/game/editor/editor.cpp | 33 ++++++++++++++++++++++++++++++--- src/game/editor/layer_tiles.cpp | 2 +- src/game/editor/popups.cpp | 8 ++++---- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 11ef90eda..765f1e0da 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1536,7 +1536,7 @@ void CEditor::DoSoundSource(CSoundSource *pSource, int Index) m_Map.m_UndoModified++; static int s_SourcePopupID = 0; - UiInvokePopupMenu(&s_SourcePopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 200, PopupSource); + UiInvokePopupMenu(&s_SourcePopupID, 0, UI()->MouseX(), UI()->MouseY(), 180, 200, PopupSource); m_LockMouse = false; } s_Operation = OP_NONE; @@ -1741,7 +1741,7 @@ void CEditor::DoQuad(CQuad *q, int Index) m_SelectedQuadIndex = FindSelectedQuadIndex(Index); static int s_QuadPopupID = 0; - UiInvokePopupMenu(&s_QuadPopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 180, PopupQuad); + UiInvokePopupMenu(&s_QuadPopupID, 0, UI()->MouseX(), UI()->MouseY(), 160, 180, PopupQuad); m_LockMouse = false; } s_Operation = OP_NONE; @@ -3247,6 +3247,33 @@ 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]; + int Cur = pProps[i].m_Value; + + Shifter.VSplitRight(10.0f, &Shifter, &Inc); + Shifter.VSplitLeft(10.0f, &Dec, &Shifter); + + //TODO: Truncate this properly + int FieldLength = Shifter.w / 7.5f; + str_format(aBuf, sizeof(aBuf),"%.*s", FieldLength, Cur > 0 ? m_Map.m_lEnvelopes[Cur - 1]->m_aName : "None"); + + RenderTools()->DrawUIRect(&Shifter, Color, 0, 5.0f); + UI()->DoLabel(&Shifter, aBuf, 10, 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; @@ -3437,7 +3464,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect View) } static int s_LayerPopupID = 0; if(Result == 2) - UiInvokePopupMenu(&s_LayerPopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 300, PopupLayer); + UiInvokePopupMenu(&s_LayerPopupID, 0, UI()->MouseX(), UI()->MouseY(), 180, 300, PopupLayer); } LayerCur += 14.0f; diff --git a/src/game/editor/layer_tiles.cpp b/src/game/editor/layer_tiles.cpp index df24a7d47..30f834ee1 100644 --- a/src/game/editor/layer_tiles.cpp +++ b/src/game/editor/layer_tiles.cpp @@ -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}, diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index 5d8c2f2c1..2f15f6add 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -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}, From a2eee9a8dbfedbda3f1832c0599ce2db41f64b1a Mon Sep 17 00:00:00 2001 From: Learath Date: Thu, 23 Jan 2020 20:48:42 +0100 Subject: [PATCH 2/3] Truncate properly --- src/game/editor/editor.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 765f1e0da..061423d0a 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -3251,17 +3251,32 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int * { CUIRect Inc, Dec; char aBuf[64]; - int Cur = pProps[i].m_Value; + float FontSize = 10.0f; Shifter.VSplitRight(10.0f, &Shifter, &Inc); Shifter.VSplitLeft(10.0f, &Dec, &Shifter); - //TODO: Truncate this properly - int FieldLength = Shifter.w / 7.5f; - str_format(aBuf, sizeof(aBuf),"%.*s", FieldLength, Cur > 0 ? m_Map.m_lEnvelopes[Cur - 1]->m_aName : "None"); + if(pProps[i].m_Value <= 0) + str_copy(aBuf, "None", sizeof(aBuf)); + else + { + str_format(aBuf, sizeof(aBuf), "%s", m_Map.m_lEnvelopes[pProps[i].m_Value - 1]->m_aName); + 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, 10, 0, -1); + UI()->DoLabel(&Shifter, aBuf, FontSize, 0, -1); if(DoButton_ButtonDec((char *) &pIDs[i] +1, 0, 0, &Dec, 0, "Previous Envelope")) { From e567fde9d70e3ab37c9136b8eee60ae1b406e5dd Mon Sep 17 00:00:00 2001 From: Learath Date: Thu, 23 Jan 2020 21:24:48 +0100 Subject: [PATCH 3/3] Names aren't unique, thinner popup --- src/game/editor/editor.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 061423d0a..9c9df8e58 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -1536,7 +1536,7 @@ void CEditor::DoSoundSource(CSoundSource *pSource, int Index) m_Map.m_UndoModified++; static int s_SourcePopupID = 0; - UiInvokePopupMenu(&s_SourcePopupID, 0, UI()->MouseX(), UI()->MouseY(), 180, 200, PopupSource); + UiInvokePopupMenu(&s_SourcePopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 200, PopupSource); m_LockMouse = false; } s_Operation = OP_NONE; @@ -1741,7 +1741,7 @@ void CEditor::DoQuad(CQuad *q, int Index) m_SelectedQuadIndex = FindSelectedQuadIndex(Index); static int s_QuadPopupID = 0; - UiInvokePopupMenu(&s_QuadPopupID, 0, UI()->MouseX(), UI()->MouseY(), 160, 180, PopupQuad); + UiInvokePopupMenu(&s_QuadPopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 180, PopupQuad); m_LockMouse = false; } s_Operation = OP_NONE; @@ -3252,15 +3252,20 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int * 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(pProps[i].m_Value <= 0) + if(CurValue <= 0) str_copy(aBuf, "None", sizeof(aBuf)); else { - str_format(aBuf, sizeof(aBuf), "%s", m_Map.m_lEnvelopes[pProps[i].m_Value - 1]->m_aName); + 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) @@ -3479,7 +3484,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect View) } static int s_LayerPopupID = 0; if(Result == 2) - UiInvokePopupMenu(&s_LayerPopupID, 0, UI()->MouseX(), UI()->MouseY(), 180, 300, PopupLayer); + UiInvokePopupMenu(&s_LayerPopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 300, PopupLayer); } LayerCur += 14.0f;