2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/MP1/COptionsScreen.hpp"
|
|
|
|
|
2020-04-16 06:57:04 +00:00
|
|
|
#include "Runtime/IMain.hpp"
|
2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/CArchitectureQueue.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiSliderGroup.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiTableGroup.hpp"
|
|
|
|
#include "Runtime/GuiSys/CGuiTextPane.hpp"
|
|
|
|
#include "Runtime/Input/RumbleFxTable.hpp"
|
2017-05-02 04:00:38 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce::MP1 {
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
COptionsScreen::COptionsScreen(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg)
|
2020-04-21 07:22:41 +00:00
|
|
|
: CPauseScreenBase(mgr, frame, pauseStrg), x1a0_gameCube{std::make_unique<CGameCubeDoll>()} {}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
COptionsScreen::~COptionsScreen() { CSfxManager::SfxStop(x1a4_sliderSfx); }
|
|
|
|
|
|
|
|
void COptionsScreen::UpdateOptionView() {
|
|
|
|
ResetOptionWidgetVisibility();
|
|
|
|
|
|
|
|
const std::pair<int, const SGameOption*>& category = GameOptionsRegistry[x70_tablegroup_leftlog->GetUserSelection()];
|
|
|
|
if (category.first == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
float zOff = x38_highlightPitch * x1c_rightSel;
|
|
|
|
const SGameOption& opt = category.second[x1c_rightSel];
|
|
|
|
switch (opt.type) {
|
|
|
|
case EOptionType::Float:
|
|
|
|
x18c_slidergroup_slider->SetIsActive(true);
|
|
|
|
x18c_slidergroup_slider->SetVisibility(true, ETraversalMode::Children);
|
|
|
|
x18c_slidergroup_slider->SetMinVal(opt.minVal);
|
|
|
|
x18c_slidergroup_slider->SetMaxVal(opt.maxVal);
|
|
|
|
x18c_slidergroup_slider->SetIncrement(opt.increment);
|
|
|
|
x18c_slidergroup_slider->SetCurVal(CGameOptions::GetOption(opt.option));
|
|
|
|
x18c_slidergroup_slider->SetLocalPosition(x3c_sliderStart + zeus::CVector3f(0.f, 0.f, zOff));
|
|
|
|
break;
|
|
|
|
case EOptionType::DoubleEnum:
|
|
|
|
x190_tablegroup_double->SetUserSelection(CGameOptions::GetOption(opt.option));
|
|
|
|
x190_tablegroup_double->SetIsVisible(true);
|
|
|
|
x190_tablegroup_double->SetIsActive(true);
|
2019-01-22 04:23:51 +00:00
|
|
|
x190_tablegroup_double->SetWorkersMouseActive(true);
|
2018-12-08 05:30:43 +00:00
|
|
|
UpdateSideTable(x190_tablegroup_double);
|
|
|
|
x190_tablegroup_double->SetLocalPosition(x48_tableDoubleStart + zeus::CVector3f(0.f, 0.f, zOff));
|
|
|
|
break;
|
|
|
|
case EOptionType::TripleEnum:
|
|
|
|
x194_tablegroup_triple->SetUserSelection(CGameOptions::GetOption(opt.option));
|
|
|
|
x194_tablegroup_triple->SetIsVisible(true);
|
|
|
|
x194_tablegroup_triple->SetIsActive(true);
|
2019-01-22 04:23:51 +00:00
|
|
|
x194_tablegroup_triple->SetWorkersMouseActive(true);
|
2018-12-08 05:30:43 +00:00
|
|
|
UpdateSideTable(x194_tablegroup_triple);
|
|
|
|
x194_tablegroup_triple->SetLocalPosition(x54_tableTripleStart + zeus::CVector3f(0.f, 0.f, zOff));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-01-22 04:23:51 +00:00
|
|
|
|
|
|
|
x174_textpane_body->SetMouseActive(false);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void COptionsScreen::ResetOptionWidgetVisibility() {
|
|
|
|
x18c_slidergroup_slider->SetIsActive(false);
|
|
|
|
x18c_slidergroup_slider->SetVisibility(false, ETraversalMode::Children);
|
|
|
|
x190_tablegroup_double->SetIsVisible(false);
|
|
|
|
x190_tablegroup_double->SetIsActive(false);
|
2019-01-22 04:23:51 +00:00
|
|
|
x190_tablegroup_double->SetWorkersMouseActive(false);
|
2018-12-08 05:30:43 +00:00
|
|
|
x194_tablegroup_triple->SetIsActive(false);
|
|
|
|
x194_tablegroup_triple->SetIsVisible(false);
|
2019-01-22 04:23:51 +00:00
|
|
|
x194_tablegroup_triple->SetWorkersMouseActive(false);
|
|
|
|
x174_textpane_body->SetMouseActive(true);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void COptionsScreen::OnSliderChanged(CGuiSliderGroup* caller, float val) {
|
|
|
|
if (x10_mode != EMode::RightTable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
EGameOption opt = GameOptionsRegistry[x70_tablegroup_leftlog->GetUserSelection()].second[x1c_rightSel].option;
|
|
|
|
CGameOptions::SetOption(opt, caller->GetGurVal());
|
|
|
|
}
|
|
|
|
|
|
|
|
void COptionsScreen::OnEnumChanged(CGuiTableGroup* caller, int oldSel) {
|
|
|
|
if (x10_mode != EMode::RightTable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
EGameOption opt = GameOptionsRegistry[x70_tablegroup_leftlog->GetUserSelection()].second[x1c_rightSel].option;
|
|
|
|
CGameOptions::SetOption(opt, caller->GetUserSelection());
|
|
|
|
|
|
|
|
if (opt == EGameOption::Rumble && caller->GetUserSelection() > 0) {
|
|
|
|
x1a8_rumble.HardStopAll();
|
2022-03-20 04:19:43 +00:00
|
|
|
x1a8_rumble.Rumble(RumbleFxTable[size_t(ERumbleFxId::PlayerBump)], 1.f, ERumblePriority::One, EIOPort::Player1);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CPauseScreenBase::UpdateSideTable(caller);
|
|
|
|
CSfxManager::SfxStart(SFXui_option_enum_change, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool COptionsScreen::InputDisabled() const { return x19c_quitGame.operator bool(); }
|
|
|
|
|
|
|
|
void COptionsScreen::Update(float dt, CRandom16& rand, CArchitectureQueue& archQueue) {
|
|
|
|
x1a8_rumble.Update(dt);
|
|
|
|
CPauseScreenBase::Update(dt, rand, archQueue);
|
|
|
|
|
|
|
|
if (x1a4_sliderSfx.operator bool() != (x18c_slidergroup_slider->GetState() != CGuiSliderGroup::EState::None)) {
|
|
|
|
if (x18c_slidergroup_slider->GetState() != CGuiSliderGroup::EState::None) {
|
|
|
|
x1a4_sliderSfx =
|
|
|
|
CSfxManager::SfxStart(SFXui_options_slider_change_lp, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
} else {
|
|
|
|
CSfxManager::SfxStop(x1a4_sliderSfx);
|
|
|
|
x1a4_sliderSfx.reset();
|
2017-05-12 19:54:35 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-05-12 19:54:35 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x2a0_24_inOptionBody)
|
|
|
|
x29c_optionAlpha = std::min(x29c_optionAlpha + 4.f * dt, 1.f);
|
|
|
|
else
|
|
|
|
x29c_optionAlpha = std::max(x29c_optionAlpha - 4.f * dt, 0.f);
|
2017-05-12 19:54:35 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (std::fabs(x29c_optionAlpha) < 0.00001f) {
|
|
|
|
ResetOptionWidgetVisibility();
|
|
|
|
x174_textpane_body->SetIsVisible(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CColor color = g_tweakGuiColors->GetPauseItemAmberColor();
|
|
|
|
color.a() = x29c_optionAlpha;
|
|
|
|
x18c_slidergroup_slider->SetColor(color);
|
|
|
|
x190_tablegroup_double->SetColor(color);
|
|
|
|
x194_tablegroup_triple->SetColor(color);
|
|
|
|
|
|
|
|
if (x19c_quitGame) {
|
|
|
|
EQuitAction action = x19c_quitGame->Update(dt);
|
|
|
|
if (action == EQuitAction::Yes) {
|
|
|
|
archQueue.Push(MakeMsg::CreateQuitGameplay(EArchMsgTarget::Game));
|
|
|
|
CSfxManager::SetChannel(CSfxManager::ESfxChannels::Default);
|
|
|
|
CSfxManager::SfxStart(SFXui_options_quit_accept, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
} else if (action == EQuitAction::No) {
|
|
|
|
CSfxManager::SfxStart(SFXui_options_quit_reject, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
|
|
|
x19c_quitGame.reset();
|
2017-05-12 19:54:35 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-05-12 19:54:35 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x1a0_gameCube->Update(dt);
|
2017-05-12 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void COptionsScreen::Touch() {
|
|
|
|
CPauseScreenBase::Touch();
|
|
|
|
x1a0_gameCube->Touch();
|
2017-05-12 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void COptionsScreen::ProcessControllerInput(const CFinalInput& input) {
|
|
|
|
if (!x19c_quitGame) {
|
2019-01-23 07:52:19 +00:00
|
|
|
bool leftClicked = m_leftClicked;
|
|
|
|
bool rightClicked = m_rightClicked;
|
2019-01-21 04:10:34 +00:00
|
|
|
CPauseScreenBase::ProcessMouseInput(input, 0.f);
|
2018-12-08 05:30:43 +00:00
|
|
|
CPauseScreenBase::ProcessControllerInput(input);
|
2019-01-23 07:52:19 +00:00
|
|
|
CGameOptions::TryRestoreDefaults(input, x70_tablegroup_leftlog->GetUserSelection(), x1c_rightSel, false,
|
|
|
|
rightClicked);
|
2020-04-16 06:57:04 +00:00
|
|
|
if (x70_tablegroup_leftlog->GetUserSelection() == 4 &&
|
2022-07-29 20:16:55 +00:00
|
|
|
(input.PA() || leftClicked || input.PSpecialKey(ESpecialKey::Enter)))
|
2018-12-08 05:30:43 +00:00
|
|
|
x19c_quitGame = std::make_unique<CQuitGameScreen>(EQuitType::QuitGame);
|
|
|
|
} else {
|
2019-01-23 07:52:19 +00:00
|
|
|
CPauseScreenBase::ResetMouseState();
|
2018-12-08 05:30:43 +00:00
|
|
|
x19c_quitGame->ProcessUserInput(input);
|
|
|
|
}
|
2017-05-12 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void COptionsScreen::Draw(float transInterp, float totalAlpha, float yOff) {
|
2019-07-21 08:42:52 +00:00
|
|
|
SCOPED_GRAPHICS_DEBUG_GROUP("COptionsScreen::Draw", zeus::skPurple);
|
2018-12-08 05:30:43 +00:00
|
|
|
CPauseScreenBase::Draw(transInterp, totalAlpha, yOff);
|
|
|
|
x1a0_gameCube->Draw(transInterp * (1.f - x29c_optionAlpha));
|
|
|
|
if (x19c_quitGame) {
|
|
|
|
CGraphics::SetDepthRange(DEPTH_NEAR, 0.001f);
|
|
|
|
x19c_quitGame->Draw();
|
|
|
|
CGraphics::SetDepthRange(DEPTH_NEAR, DEPTH_FAR);
|
|
|
|
}
|
2017-05-02 04:00:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool COptionsScreen::VReady() const { return true; }
|
2017-05-02 04:00:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void COptionsScreen::VActivate() {
|
2020-04-16 06:57:04 +00:00
|
|
|
for (int i = 0; i < 5; ++i) {
|
2020-04-16 10:25:59 +00:00
|
|
|
if (g_Main->IsUSA() && !g_Main->IsTrilogy()) {
|
2020-04-16 06:57:04 +00:00
|
|
|
xa8_textpane_categories[i]->TextSupport().SetText(xc_pauseStrg.GetString(i + 16));
|
|
|
|
} else {
|
|
|
|
xa8_textpane_categories[i]->TextSupport().SetText(xc_pauseStrg.GetString(i + 18));
|
|
|
|
}
|
|
|
|
}
|
2017-05-12 19:54:35 +00:00
|
|
|
|
2020-04-16 10:25:59 +00:00
|
|
|
x178_textpane_title->TextSupport().SetText(
|
|
|
|
xc_pauseStrg.GetString((g_Main->IsUSA() && !g_Main->IsTrilogy()) ? 15 : 17));
|
2017-05-12 19:54:35 +00:00
|
|
|
|
2018-01-05 03:02:30 +00:00
|
|
|
#if 0
|
|
|
|
for (int i=5 ; i<5 ; ++i)
|
2017-05-12 19:54:35 +00:00
|
|
|
x70_tablegroup_leftlog->GetWorkerWidget(i)->SetIsSelectable(false);
|
2018-01-05 03:02:30 +00:00
|
|
|
#endif
|
2017-05-12 19:54:35 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x174_textpane_body->TextSupport().SetJustification(EJustification::Center);
|
|
|
|
x174_textpane_body->TextSupport().SetVerticalJustification(EVerticalJustification::Bottom);
|
|
|
|
|
2020-04-16 10:25:59 +00:00
|
|
|
int stringOffset = (g_Main->IsUSA() && !g_Main->IsTrilogy()) ? 0 : 3;
|
2018-12-08 05:30:43 +00:00
|
|
|
static_cast<CGuiTextPane*>(x190_tablegroup_double->GetWorkerWidget(0))
|
|
|
|
->TextSupport()
|
2020-04-16 06:57:04 +00:00
|
|
|
.SetText(xc_pauseStrg.GetString(95 + stringOffset));
|
2018-12-08 05:30:43 +00:00
|
|
|
static_cast<CGuiTextPane*>(x190_tablegroup_double->GetWorkerWidget(1))
|
|
|
|
->TextSupport()
|
2020-04-16 06:57:04 +00:00
|
|
|
.SetText(xc_pauseStrg.GetString(94 + stringOffset));
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
static_cast<CGuiTextPane*>(x194_tablegroup_triple->GetWorkerWidget(0))
|
|
|
|
->TextSupport()
|
2020-04-16 06:57:04 +00:00
|
|
|
.SetText(xc_pauseStrg.GetString(96 + stringOffset));
|
2018-12-08 05:30:43 +00:00
|
|
|
static_cast<CGuiTextPane*>(x194_tablegroup_triple->GetWorkerWidget(1))
|
|
|
|
->TextSupport()
|
2020-04-16 06:57:04 +00:00
|
|
|
.SetText(xc_pauseStrg.GetString(97 + stringOffset));
|
2018-12-08 05:30:43 +00:00
|
|
|
static_cast<CGuiTextPane*>(x194_tablegroup_triple->GetWorkerWidget(2))
|
|
|
|
->TextSupport()
|
2020-04-16 06:57:04 +00:00
|
|
|
.SetText(xc_pauseStrg.GetString(98 + stringOffset));
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
x18c_slidergroup_slider->SetSelectionChangedCallback(
|
2019-08-14 07:45:28 +00:00
|
|
|
[this](CGuiSliderGroup* caller, float value) { OnSliderChanged(caller, value); });
|
2018-12-08 05:30:43 +00:00
|
|
|
x190_tablegroup_double->SetMenuSelectionChangeCallback(
|
2019-08-14 07:45:28 +00:00
|
|
|
[this](CGuiTableGroup* caller, int oldSel) { OnEnumChanged(caller, oldSel); });
|
2018-12-08 05:30:43 +00:00
|
|
|
x194_tablegroup_triple->SetMenuSelectionChangeCallback(
|
2019-08-14 07:45:28 +00:00
|
|
|
[this](CGuiTableGroup* caller, int oldSel) { OnEnumChanged(caller, oldSel); });
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void COptionsScreen::RightTableSelectionChanged(int oldSel, int newSel) { UpdateOptionView(); }
|
|
|
|
|
|
|
|
void COptionsScreen::ChangedMode(EMode oldMode) {
|
|
|
|
if (x10_mode == EMode::RightTable) {
|
|
|
|
x174_textpane_body->SetIsVisible(true);
|
2017-05-12 19:54:35 +00:00
|
|
|
UpdateOptionView();
|
2018-12-08 05:30:43 +00:00
|
|
|
x2a0_24_inOptionBody = true;
|
|
|
|
} else {
|
|
|
|
x2a0_24_inOptionBody = false;
|
|
|
|
}
|
2017-05-12 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void COptionsScreen::UpdateRightTable() {
|
|
|
|
CPauseScreenBase::UpdateRightTable();
|
2020-04-16 06:57:04 +00:00
|
|
|
const std::pair<int, const SGameOption*>& category =
|
2020-04-16 10:25:59 +00:00
|
|
|
(g_Main->IsUSA() && !g_Main->IsTrilogy()) ? GameOptionsRegistry[x70_tablegroup_leftlog->GetUserSelection()]
|
|
|
|
: GameOptionsRegistryNew[x70_tablegroup_leftlog->GetUserSelection()];
|
2018-12-08 05:30:43 +00:00
|
|
|
for (int i = 0; i < 5; ++i) {
|
2020-04-16 06:57:04 +00:00
|
|
|
if (i < category.first) {
|
2018-12-08 05:30:43 +00:00
|
|
|
xd8_textpane_titles[i]->TextSupport().SetText(xc_pauseStrg.GetString(category.second[i].stringId));
|
2020-04-16 06:57:04 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
xd8_textpane_titles[i]->TextSupport().SetText(u"");
|
2020-04-16 06:57:04 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-05-12 19:54:35 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool COptionsScreen::ShouldLeftTableAdvance() const { return x70_tablegroup_leftlog->GetUserSelection() != 4; }
|
2017-05-12 19:54:35 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool COptionsScreen::ShouldRightTableAdvance() const { return false; }
|
2017-05-02 04:00:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
u32 COptionsScreen::GetRightTableCount() const {
|
|
|
|
return GameOptionsRegistry[x70_tablegroup_leftlog->GetUserSelection()].first;
|
2017-05-02 04:00:38 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce::MP1
|