From 6e921e32582096471c25c39dac43984d31d9d068 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 15 Mar 2020 21:16:11 -0400 Subject: [PATCH 1/2] CPauseScreenBase: Mark colors as constexpr within UpdateSideTable() Same behavior, but allows eliding construction at runtime. --- Runtime/MP1/CPauseScreenBase.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Runtime/MP1/CPauseScreenBase.cpp b/Runtime/MP1/CPauseScreenBase.cpp index eb1b06278..023e215a2 100644 --- a/Runtime/MP1/CPauseScreenBase.cpp +++ b/Runtime/MP1/CPauseScreenBase.cpp @@ -252,11 +252,12 @@ void CPauseScreenBase::ChangeMode(EMode mode, bool playSfx) { } void CPauseScreenBase::UpdateSideTable(CGuiTableGroup* table) { - if (!table) + if (!table) { return; + } - zeus::CColor selColor = zeus::skWhite; - zeus::CColor deselColor = {1.f, 1.f, 1.f, 0.5f}; + constexpr zeus::CColor selColor = zeus::skWhite; + constexpr zeus::CColor deselColor = {1.f, 1.f, 1.f, 0.5f}; bool tableActive = true; if (table == x84_tablegroup_rightlog && x10_mode != EMode::RightTable) From 1a7ad1a7f6d14f78983b370b93c8605475464c77 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 15 Mar 2020 21:24:00 -0400 Subject: [PATCH 2/2] CPauseScreenBase: Make use of std::array in GetImagePaneName() We can make use of std::array here and also make the array constexpr. This can also be moved into the function in order to hide its scope. --- Runtime/MP1/CPauseScreenBase.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Runtime/MP1/CPauseScreenBase.cpp b/Runtime/MP1/CPauseScreenBase.cpp index 023e215a2..1f9e662c8 100644 --- a/Runtime/MP1/CPauseScreenBase.cpp +++ b/Runtime/MP1/CPauseScreenBase.cpp @@ -1,5 +1,7 @@ #include "Runtime/MP1/CPauseScreenBase.hpp" +#include + #include "Runtime/CGameState.hpp" #include "Runtime/GameGlobalObjects.hpp" #include "Runtime/Audio/CSfxManager.hpp" @@ -521,9 +523,13 @@ void CPauseScreenBase::OnWidgetScroll(CGuiWidget* widget, const boo::SScrollDelt } } -static const char* PaneSuffixes[] = {"0", "1", "2", "3", "01", "12", "23", "012", "123", "0123", - "4", "5", "6", "7", "45", "56", "67", "456", "567", "4567"}; +std::string CPauseScreenBase::GetImagePaneName(u32 i) { + static constexpr std::array PaneSuffixes{ + "0", "1", "2", "3", "01", "12", "23", "012", "123", "0123", + "4", "5", "6", "7", "45", "56", "67", "456", "567", "4567", + }; -std::string CPauseScreenBase::GetImagePaneName(u32 i) { return fmt::format(fmt("imagepane_pane{}"), PaneSuffixes[i]); } + return fmt::format(fmt("imagepane_pane{}"), PaneSuffixes[i]); +} } // namespace urde::MP1