2019-09-29 00:30:53 +00:00
|
|
|
#include "Runtime/MP1/CQuitGameScreen.hpp"
|
|
|
|
|
2020-04-12 14:59:03 +00:00
|
|
|
#include <array>
|
|
|
|
|
2019-09-29 00:30:53 +00:00
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/CSimplePool.hpp"
|
|
|
|
#include "Runtime/Audio/CSfxManager.hpp"
|
|
|
|
#include "Runtime/Camera/CCameraFilter.hpp"
|
|
|
|
#include "Runtime/Input/CFinalInput.hpp"
|
|
|
|
#include "Runtime/Graphics/CGraphics.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiFrame.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiTableGroup.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiTextPane.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiWidgetDrawParms.hpp"
|
|
|
|
#include "Runtime/GuiSys/CStringTable.hpp"
|
2016-12-30 06:37:01 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce::MP1 {
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-12 14:59:03 +00:00
|
|
|
constexpr std::array Titles{24, 25, 26, 27, 28};
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-12 14:59:03 +00:00
|
|
|
constexpr std::array DefaultSelections{1, 0, 1, 1, 0};
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-12 14:59:03 +00:00
|
|
|
constexpr std::array VerticalOffsets{0.f, 1.6f, 1.f, 0.f, 1.f};
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
void CQuitGameScreen::SetColors() {
|
|
|
|
x14_tablegroup_quitgame->SetColors(zeus::CColor{0.784313f, 0.784313f, 0.784313f, 1.f},
|
|
|
|
zeus::CColor{0.196078f, 0.196078f, 0.196078f, 1.f});
|
2016-12-30 06:37:01 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CQuitGameScreen::FinishedLoading() {
|
|
|
|
x10_loadedFrame = x4_frame.GetObj();
|
|
|
|
x10_loadedFrame->SetMaxAspect(1.33f);
|
|
|
|
|
|
|
|
x14_tablegroup_quitgame = static_cast<CGuiTableGroup*>(x10_loadedFrame->FindWidget("tablegroup_quitgame"));
|
|
|
|
x14_tablegroup_quitgame->SetVertical(false);
|
2019-08-14 07:45:28 +00:00
|
|
|
x14_tablegroup_quitgame->SetMenuAdvanceCallback([this](CGuiTableGroup* caller) { DoAdvance(caller); });
|
2018-12-08 05:30:43 +00:00
|
|
|
x14_tablegroup_quitgame->SetMenuSelectionChangeCallback(
|
2019-08-14 07:45:28 +00:00
|
|
|
[this](CGuiTableGroup* caller, int oldSel) { DoSelectionChange(caller, oldSel); });
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
static_cast<CGuiTextPane*>(x10_loadedFrame->FindWidget("textpane_title"))
|
|
|
|
->TextSupport()
|
2020-04-12 14:59:03 +00:00
|
|
|
.SetText(g_MainStringTable->GetString(Titles[size_t(x0_type)]));
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
static_cast<CGuiTextPane*>(x10_loadedFrame->FindWidget("textpane_yes"))
|
|
|
|
->TextSupport()
|
|
|
|
.SetText(g_MainStringTable->GetString(22));
|
|
|
|
static_cast<CGuiTextPane*>(x10_loadedFrame->FindWidget("textpane_no"))
|
|
|
|
->TextSupport()
|
|
|
|
.SetText(g_MainStringTable->GetString(23));
|
|
|
|
|
2020-04-12 14:59:03 +00:00
|
|
|
x14_tablegroup_quitgame->SetUserSelection(DefaultSelections[size_t(x0_type)]);
|
2019-01-23 07:52:19 +00:00
|
|
|
x14_tablegroup_quitgame->SetWorkersMouseActive(true);
|
2019-08-14 07:45:28 +00:00
|
|
|
x10_loadedFrame->SetMouseUpCallback([this](CGuiWidget* widget, bool cancel) { OnWidgetMouseUp(widget, cancel); });
|
2018-12-08 05:30:43 +00:00
|
|
|
SetColors();
|
2016-12-30 06:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-01-23 07:52:19 +00:00
|
|
|
void CQuitGameScreen::OnWidgetMouseUp(CGuiWidget* widget, bool cancel) {
|
|
|
|
if (!widget || cancel)
|
|
|
|
return;
|
|
|
|
DoAdvance(static_cast<CGuiTableGroup*>(widget->GetParent()));
|
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CQuitGameScreen::DoSelectionChange(CGuiTableGroup* caller, int oldSel) {
|
|
|
|
SetColors();
|
|
|
|
CSfxManager::SfxStart(SFXui_quit_change, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
2016-12-30 06:37:01 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CQuitGameScreen::DoAdvance(CGuiTableGroup* caller) {
|
|
|
|
if (caller->GetUserSelection() == 0) {
|
|
|
|
/* Yes */
|
|
|
|
CSfxManager::SfxStart(SFXui_advance, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
x18_action = EQuitAction::Yes;
|
|
|
|
} else {
|
|
|
|
/* No */
|
|
|
|
CSfxManager::SfxStart(SFXui_table_change_mode, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
x18_action = EQuitAction::No;
|
|
|
|
}
|
2016-12-30 06:37:01 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
EQuitAction CQuitGameScreen::Update(float dt) {
|
|
|
|
if (!x10_loadedFrame && x4_frame.IsLoaded())
|
|
|
|
FinishedLoading();
|
|
|
|
return x18_action;
|
2016-12-30 06:37:01 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CQuitGameScreen::Draw() {
|
2019-07-21 08:42:52 +00:00
|
|
|
SCOPED_GRAPHICS_DEBUG_GROUP("CQuitGameScreen::Draw", zeus::skPurple);
|
2020-04-12 14:59:03 +00:00
|
|
|
if (x0_type == EQuitType::QuitGame) {
|
2022-05-24 00:26:35 +00:00
|
|
|
CCameraFilterPass::DrawFilter(EFilterType::Blend, EFilterShape::Fullscreen, zeus::CColor{0.f, 0.5f}, nullptr, 1.f);
|
2020-04-12 14:59:03 +00:00
|
|
|
}
|
2016-12-30 06:37:01 +00:00
|
|
|
|
2020-04-12 14:59:03 +00:00
|
|
|
if (x10_loadedFrame) {
|
|
|
|
x10_loadedFrame->Draw(CGuiWidgetDrawParms{1.f, zeus::CVector3f{0.f, 0.f, VerticalOffsets[size_t(x0_type)]}});
|
|
|
|
}
|
2016-12-30 06:37:01 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CQuitGameScreen::ProcessUserInput(const CFinalInput& input) {
|
2020-04-12 14:59:03 +00:00
|
|
|
if (input.ControllerIdx() != 0) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-04-12 14:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!x10_loadedFrame) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-04-12 14:59:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
x10_loadedFrame->ProcessMouseInput(
|
|
|
|
input, CGuiWidgetDrawParms{1.f, zeus::CVector3f{0.f, 0.f, VerticalOffsets[size_t(x0_type)]}});
|
2018-12-08 05:30:43 +00:00
|
|
|
x10_loadedFrame->ProcessUserInput(input);
|
2022-02-22 05:53:57 +00:00
|
|
|
if ((input.PB() || input.PSpecialKey(aurora::SpecialKey::Esc)) && x0_type != EQuitType::ContinueFromLastSave) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x18_action = EQuitAction::No;
|
2020-04-12 14:59:03 +00:00
|
|
|
}
|
2016-12-30 06:37:01 +00:00
|
|
|
}
|
|
|
|
|
2022-05-24 00:26:35 +00:00
|
|
|
CQuitGameScreen::CQuitGameScreen(EQuitType tp) : x0_type(tp) { x4_frame = g_SimplePool->GetObj("FRME_QuitScreen"); }
|
2016-12-30 06:37:01 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce::MP1
|