2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-07-07 12:45:53 +00:00

CQuitGameScreen: Make use of std::array where applicable

Same behavior, but more strongly typed and without any implicit array to
pointer decay.
This commit is contained in:
Lioncash 2020-04-12 10:59:03 -04:00
parent eba3270c14
commit f1aca12e6b

View File

@ -1,5 +1,7 @@
#include "Runtime/MP1/CQuitGameScreen.hpp" #include "Runtime/MP1/CQuitGameScreen.hpp"
#include <array>
#include "Runtime/GameGlobalObjects.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/CSimplePool.hpp" #include "Runtime/CSimplePool.hpp"
#include "Runtime/Audio/CSfxManager.hpp" #include "Runtime/Audio/CSfxManager.hpp"
@ -14,11 +16,11 @@
namespace urde::MP1 { namespace urde::MP1 {
static const int Titles[] = {24, 25, 26, 27, 28}; constexpr std::array Titles{24, 25, 26, 27, 28};
static const int DefaultSelections[] = {1, 0, 1, 1, 0}; constexpr std::array DefaultSelections{1, 0, 1, 1, 0};
static const float VerticalOffsets[] = {0.f, 1.6f, 1.f, 0.f, 1.f}; constexpr std::array VerticalOffsets{0.f, 1.6f, 1.f, 0.f, 1.f};
void CQuitGameScreen::SetColors() { void CQuitGameScreen::SetColors() {
x14_tablegroup_quitgame->SetColors(zeus::CColor{0.784313f, 0.784313f, 0.784313f, 1.f}, x14_tablegroup_quitgame->SetColors(zeus::CColor{0.784313f, 0.784313f, 0.784313f, 1.f},
@ -37,7 +39,7 @@ void CQuitGameScreen::FinishedLoading() {
static_cast<CGuiTextPane*>(x10_loadedFrame->FindWidget("textpane_title")) static_cast<CGuiTextPane*>(x10_loadedFrame->FindWidget("textpane_title"))
->TextSupport() ->TextSupport()
.SetText(g_MainStringTable->GetString(Titles[int(x0_type)])); .SetText(g_MainStringTable->GetString(Titles[size_t(x0_type)]));
static_cast<CGuiTextPane*>(x10_loadedFrame->FindWidget("textpane_yes")) static_cast<CGuiTextPane*>(x10_loadedFrame->FindWidget("textpane_yes"))
->TextSupport() ->TextSupport()
@ -46,7 +48,7 @@ void CQuitGameScreen::FinishedLoading() {
->TextSupport() ->TextSupport()
.SetText(g_MainStringTable->GetString(23)); .SetText(g_MainStringTable->GetString(23));
x14_tablegroup_quitgame->SetUserSelection(DefaultSelections[int(x0_type)]); x14_tablegroup_quitgame->SetUserSelection(DefaultSelections[size_t(x0_type)]);
x14_tablegroup_quitgame->SetWorkersMouseActive(true); x14_tablegroup_quitgame->SetWorkersMouseActive(true);
x10_loadedFrame->SetMouseUpCallback([this](CGuiWidget* widget, bool cancel) { OnWidgetMouseUp(widget, cancel); }); x10_loadedFrame->SetMouseUpCallback([this](CGuiWidget* widget, bool cancel) { OnWidgetMouseUp(widget, cancel); });
SetColors(); SetColors();
@ -83,24 +85,31 @@ EQuitAction CQuitGameScreen::Update(float dt) {
void CQuitGameScreen::Draw() { void CQuitGameScreen::Draw() {
SCOPED_GRAPHICS_DEBUG_GROUP("CQuitGameScreen::Draw", zeus::skPurple); SCOPED_GRAPHICS_DEBUG_GROUP("CQuitGameScreen::Draw", zeus::skPurple);
if (x0_type == EQuitType::QuitGame) if (x0_type == EQuitType::QuitGame) {
m_blackScreen->draw(zeus::CColor(0.f, 0.5f)); m_blackScreen->draw(zeus::CColor(0.f, 0.5f));
}
if (x10_loadedFrame) if (x10_loadedFrame) {
x10_loadedFrame->Draw(CGuiWidgetDrawParms{1.f, zeus::CVector3f{0.f, 0.f, VerticalOffsets[int(x0_type)]}}); x10_loadedFrame->Draw(CGuiWidgetDrawParms{1.f, zeus::CVector3f{0.f, 0.f, VerticalOffsets[size_t(x0_type)]}});
}
} }
void CQuitGameScreen::ProcessUserInput(const CFinalInput& input) { void CQuitGameScreen::ProcessUserInput(const CFinalInput& input) {
if (input.ControllerIdx() != 0) if (input.ControllerIdx() != 0) {
return; return;
if (!x10_loadedFrame) }
if (!x10_loadedFrame) {
return; return;
x10_loadedFrame->ProcessMouseInput(input, }
CGuiWidgetDrawParms{1.f, zeus::CVector3f{0.f, 0.f, VerticalOffsets[int(x0_type)]}});
x10_loadedFrame->ProcessMouseInput(
input, CGuiWidgetDrawParms{1.f, zeus::CVector3f{0.f, 0.f, VerticalOffsets[size_t(x0_type)]}});
x10_loadedFrame->ProcessUserInput(input); x10_loadedFrame->ProcessUserInput(input);
if ((input.PB() || input.PSpecialKey(boo::ESpecialKey::Esc)) && x0_type != EQuitType::ContinueFromLastSave) if ((input.PB() || input.PSpecialKey(boo::ESpecialKey::Esc)) && x0_type != EQuitType::ContinueFromLastSave) {
x18_action = EQuitAction::No; x18_action = EQuitAction::No;
} }
}
CQuitGameScreen::CQuitGameScreen(EQuitType tp) : x0_type(tp) { CQuitGameScreen::CQuitGameScreen(EQuitType tp) : x0_type(tp) {
x4_frame = g_SimplePool->GetObj("FRME_QuitScreen"); x4_frame = g_SimplePool->GetObj("FRME_QuitScreen");