From 72194d28e71f4682b4feae1b73bfbac008e52814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 22 Sep 2022 18:02:07 +0200 Subject: [PATCH] Replace magic numbers with enum `EShowEnvelope` --- src/game/editor/editor.cpp | 20 ++++++++++---------- src/game/editor/editor.h | 11 +++++++++-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index ddec451f6..cabf1b598 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -913,7 +913,7 @@ void CEditor::DoToolbar(CUIRect ToolBar) (Input()->KeyPress(KEY_I) && ModPressed)) { m_ShowTileInfo = !m_ShowTileInfo; - m_ShowEnvelopePreview = 0; + m_ShowEnvelopePreview = SHOWENV_NONE; } TB_Top.VSplitLeft(5.0f, nullptr, &TB_Top); @@ -2093,7 +2093,7 @@ void CEditor::DoQuadEnvelopes(const std::vector &vQuads, IGraphics::CText mem_zero(apEnvelope, sizeof(CEnvelope *) * Num); // NOLINT(bugprone-sizeof-expression) for(size_t i = 0; i < Num; i++) { - if((m_ShowEnvelopePreview == 1 && vQuads[i].m_PosEnv == m_SelectedEnvelope) || m_ShowEnvelopePreview == 2) + if((m_ShowEnvelopePreview == SHOWENV_SELECTED && vQuads[i].m_PosEnv == m_SelectedEnvelope) || m_ShowEnvelopePreview == SHOWENV_ALL) if(vQuads[i].m_PosEnv >= 0 && vQuads[i].m_PosEnv < (int)m_Map.m_vpEnvelopes.size()) apEnvelope[i] = m_Map.m_vpEnvelopes[vQuads[i].m_PosEnv]; } @@ -2787,8 +2787,8 @@ void CEditor::DoMapEditor(CUIRect View) { CLayerQuads *pLayer = (CLayerQuads *)apEditLayers[k]; - if(!m_ShowEnvelopePreview) - m_ShowEnvelopePreview = 2; + if(m_ShowEnvelopePreview == SHOWENV_NONE) + m_ShowEnvelopePreview = SHOWENV_ALL; if(m_QuadKnifeActive) DoQuadKnife(m_vSelectedQuads[m_SelectedQuadIndex]); @@ -2988,7 +2988,7 @@ void CEditor::DoMapEditor(CUIRect View) } } - if(!m_ShowPicker && m_ShowTileInfo && m_ShowEnvelopePreview != 0 && GetSelectedLayer(0) && GetSelectedLayer(0)->m_Type == LAYERTYPE_QUADS) + if(!m_ShowPicker && m_ShowTileInfo && m_ShowEnvelopePreview != SHOWENV_NONE && GetSelectedLayer(0) && GetSelectedLayer(0)->m_Type == LAYERTYPE_QUADS) { GetSelectedGroup()->MapScreen(); @@ -2998,7 +2998,7 @@ void CEditor::DoMapEditor(CUIRect View) Texture = m_Map.m_vpImages[pLayer->m_Image]->m_Texture; DoQuadEnvelopes(pLayer->m_vQuads, Texture); - m_ShowEnvelopePreview = 0; + m_ShowEnvelopePreview = SHOWENV_NONE; } UI()->MapScreen(); @@ -5052,7 +5052,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) m_Map.m_Modified = true; } - m_ShowEnvelopePreview = 1; + m_ShowEnvelopePreview = SHOWENV_SELECTED; m_pTooltip = "Press right mouse button to create a new point"; } } @@ -5237,7 +5237,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) } m_SelectedQuadEnvelope = m_SelectedEnvelope; - m_ShowEnvelopePreview = 1; + m_ShowEnvelopePreview = SHOWENV_SELECTED; m_SelectedEnvelopePoint = i; m_Map.m_Modified = true; } @@ -5272,7 +5272,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) m_Map.m_Modified = true; } - m_ShowEnvelopePreview = 1; + m_ShowEnvelopePreview = SHOWENV_SELECTED; ColorMod = 100.0f; Graphics()->SetColor(1, 0.75f, 0.75f, 1); m_pTooltip = "Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point as well. Right click to delete."; @@ -6035,7 +6035,7 @@ void CEditor::Reset(bool CreateDefault) m_Map.m_Modified = false; - m_ShowEnvelopePreview = 0; + m_ShowEnvelopePreview = SHOWENV_NONE; m_ShiftBy = 1; m_Map.m_Modified = false; diff --git a/src/game/editor/editor.h b/src/game/editor/editor.h index a1dbd2698..83a9c267a 100644 --- a/src/game/editor/editor.h +++ b/src/game/editor/editor.h @@ -810,7 +810,7 @@ public: m_ShowEnvelopeEditor = 0; m_ShowServerSettingsEditor = false; - m_ShowEnvelopePreview = 0; + m_ShowEnvelopePreview = SHOWENV_NONE; m_SelectedQuadEnvelope = -1; m_SelectedEnvelopePoint = -1; @@ -994,7 +994,14 @@ public: float m_AnimateSpeed; int m_ShowEnvelopeEditor; - int m_ShowEnvelopePreview; //Values: 0-Off|1-Selected Envelope|2-All + + enum EShowEnvelope + { + SHOWENV_NONE = 0, + SHOWENV_SELECTED, + SHOWENV_ALL + }; + EShowEnvelope m_ShowEnvelopePreview; bool m_ShowServerSettingsEditor; bool m_ShowPicker;