metaforce/Runtime/MP1/CFrontEndUI.cpp

1354 lines
44 KiB
C++
Raw Normal View History

2015-08-26 17:23:46 -07:00
#include "CFrontEndUI.hpp"
2016-09-16 13:18:03 -07:00
#include "CArchitectureMessage.hpp"
#include "CArchitectureQueue.hpp"
#include "CDvdFile.hpp"
#include "CSimplePool.hpp"
#include "GameGlobalObjects.hpp"
#include "MP1.hpp"
#include "CSlideShow.hpp"
2016-12-12 21:22:30 -08:00
#include "Audio/CSfxManager.hpp"
#include "Graphics/CMoviePlayer.hpp"
#include "CSaveUI.hpp"
2016-12-14 14:56:59 -08:00
#include "GuiSys/CGuiTextPane.hpp"
#include "GuiSys/CGuiFrame.hpp"
#include "GuiSys/CStringTable.hpp"
#include "GuiSys/CGuiTableGroup.hpp"
#include "GuiSys/CGuiModel.hpp"
2016-12-14 14:56:59 -08:00
#include "CGameState.hpp"
#include "CDependencyGroup.hpp"
#include "Audio/CAudioGroupSet.hpp"
2016-12-29 22:37:01 -08:00
#include "GuiSys/CGuiWidgetDrawParms.hpp"
2016-12-14 14:56:59 -08:00
#include "CNESEmulator.hpp"
2016-12-29 22:37:01 -08:00
#include "CQuitScreen.hpp"
2015-08-26 17:23:46 -07:00
2016-03-04 15:04:53 -08:00
namespace urde
2015-08-26 17:23:46 -07:00
{
namespace MP1
{
2016-12-14 14:56:59 -08:00
/* Music volume constants */
#define FE1_VOL 0.7421875f
#define FE2_VOL 0.7421875f
2016-12-12 21:22:30 -08:00
/* L/R Stereo transition cues */
static const u16 FETransitionBackSFX[3][2] =
{
{1090, 1097},
{1098, 1099},
{1100, 1101}
};
static const u16 FETransitionForwardSFX[3][2] =
{
{1102, 1103},
{1104, 1105},
{1106, 1107}
};
struct FEMovie
{
const char* path;
bool loop;
};
static const FEMovie FEMovies[] =
{
{"Video/00_first_start.thp", false},
{"Video/01_startloop.thp", true},
{"Video/02_start_fileselect_A.thp", false},
{"Video/03_fileselectloop.thp", true},
{"Video/04_fileselect_playgame_A.thp", false},
{"Video/06_fileselect_GBA.thp", false},
{"Video/07_GBAloop.thp", true},
{"Video/08_GBA_fileselect.thp", false},
{"Video/08_GBA_fileselect.thp", false},
};
2016-09-16 13:18:03 -07:00
SObjectTag g_DefaultWorldTag = {FOURCC('MLVL'), 0x158efe17};
2016-12-16 15:05:29 -08:00
void CFrontEndUI::PlayAdvanceSfx()
2016-12-14 14:56:59 -08:00
{
2016-12-16 15:05:29 -08:00
CSfxManager::SfxStart(1096, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
CSfxManager::SfxStart(1091, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
2016-12-16 15:05:29 -08:00
CFrontEndUI::SNewFileSelectFrame::SNewFileSelectFrame(CSaveUI* sui, u32 rnd)
: x0_rnd(rnd), x4_saveUI(sui)
{
2016-12-16 15:05:29 -08:00
x10_frme = g_SimplePool->GetObj("FRME_NewFileSelect");
}
void CFrontEndUI::SNewFileSelectFrame::FinishedLoading()
{
x20_tablegroup_fileselect = static_cast<CGuiTableGroup*>(x1c_loadedFrame->FindWidget("tablegroup_fileselect"));
x24_model_erase = static_cast<CGuiModel*>(x1c_loadedFrame->FindWidget("model_erase"));
xf8_model_erase_position = x24_model_erase->GetLocalPosition();
x28_textpane_erase = FindTextPanePair(x1c_loadedFrame, "textpane_erase");
2016-12-16 15:05:29 -08:00
x38_textpane_gba = FindTextPanePair(x1c_loadedFrame, "textpane_gba");
x30_textpane_cheats = FindTextPanePair(x1c_loadedFrame, "textpane_cheats");
x48_textpane_popupadvance = FindTextPanePair(x1c_loadedFrame, "textpane_popupadvance");
x50_textpane_popupcancel = FindTextPanePair(x1c_loadedFrame, "textpane_popupcancel");
x58_textpane_popupextra = FindTextPanePair(x1c_loadedFrame, "textpane_popupextra");
x40_tablegroup_popup = static_cast<CGuiTableGroup*>(x1c_loadedFrame->FindWidget("tablegroup_popup"));
x44_model_dash7 = static_cast<CGuiModel*>(x1c_loadedFrame->FindWidget("model_dash7"));
x60_textpane_cancel = static_cast<CGuiTextPane*>(x1c_loadedFrame->FindWidget("textpane_cancel"));
FindAndSetPairText(x1c_loadedFrame, "textpane_title", g_MainStringTable->GetString(97));
CGuiTextPane* proceed = static_cast<CGuiTextPane*>(x1c_loadedFrame->FindWidget("textpane_proceed"));
if (proceed)
proceed->TextSupport()->SetText(g_MainStringTable->GetString(85));
x40_tablegroup_popup->SetIsVisible(false);
x40_tablegroup_popup->SetIsActive(false);
x40_tablegroup_popup->SetD1(false);
CGuiWidget* worker = x40_tablegroup_popup->GetWorkerWidget(2);
worker->SetB627(false);
worker->SetVisibility(false, ETraversalMode::Children);
x20_tablegroup_fileselect->SetMenuAdvanceCallback(
2016-12-17 20:16:04 -08:00
std::bind(&SNewFileSelectFrame::DoFileMenuAdvance, this, std::placeholders::_1));
x20_tablegroup_fileselect->SetMenuSelectionChangeCallback(
2016-12-15 20:35:49 -08:00
std::bind(&SNewFileSelectFrame::DoSelectionChange, this, std::placeholders::_1));
x20_tablegroup_fileselect->SetMenuCancelCallback(
2016-12-17 20:16:04 -08:00
std::bind(&SNewFileSelectFrame::DoFileMenuCancel, this, std::placeholders::_1));
2016-12-14 14:56:59 -08:00
x40_tablegroup_popup->SetMenuAdvanceCallback(
2016-12-15 20:35:49 -08:00
std::bind(&SNewFileSelectFrame::DoPopupAdvance, this, std::placeholders::_1));
x40_tablegroup_popup->SetMenuSelectionChangeCallback(
2016-12-15 20:35:49 -08:00
std::bind(&SNewFileSelectFrame::DoSelectionChange, this, std::placeholders::_1));
x40_tablegroup_popup->SetMenuCancelCallback(
2016-12-15 20:35:49 -08:00
std::bind(&SNewFileSelectFrame::DoPopupCancel, this, std::placeholders::_1));
for (int i=0 ; i<3 ; ++i)
x64_fileSelections[i] = FindFileSelectOption(x1c_loadedFrame, i);
2016-12-29 22:37:01 -08:00
x104_rowPitch = (x64_fileSelections[1].x0_base->GetLocalPosition() -
x64_fileSelections[0].x0_base->GetLocalPosition()).z;
2016-12-14 14:56:59 -08:00
}
bool CFrontEndUI::SNewFileSelectFrame::PumpLoad()
{
if (x1c_loadedFrame)
return true;
if (x10_frme.IsLoaded())
{
if (x10_frme->GetIsFinishedLoading())
{
x1c_loadedFrame = x10_frme.GetObj();
FinishedLoading();
return true;
}
}
2016-12-14 14:56:59 -08:00
return false;
}
2016-12-15 20:35:49 -08:00
bool CFrontEndUI::SNewFileSelectFrame::IsTextDoneAnimating() const
{
if (x64_fileSelections[0].x28_ != 4)
return false;
if (x64_fileSelections[1].x28_ != 4)
return false;
if (x64_fileSelections[2].x28_ != 4)
return false;
2016-12-16 15:05:29 -08:00
if (!x28_textpane_erase.x0_panes[0]->GetTextSupport()->IsAnimationDone())
2016-12-15 20:35:49 -08:00
return false;
2016-12-16 15:05:29 -08:00
return x38_textpane_gba.x0_panes[0]->GetTextSupport()->IsAnimationDone();
2016-12-15 20:35:49 -08:00
}
2016-12-29 22:37:01 -08:00
CFrontEndUI::SNewFileSelectFrame::EAction
2016-12-15 20:35:49 -08:00
CFrontEndUI::SNewFileSelectFrame::ProcessUserInput(const CFinalInput& input)
{
2016-12-17 20:16:04 -08:00
if (x8_subMenu != ESubMenu::Two)
2016-12-15 20:35:49 -08:00
x4_saveUI->ProcessUserInput(input);
2016-12-17 20:16:04 -08:00
2016-12-15 20:35:49 -08:00
if (IsTextDoneAnimating())
x108_curTime = std::min(0.5f, x108_curTime + input.DeltaTime());
2016-12-17 20:16:04 -08:00
2016-12-15 20:35:49 -08:00
if (x108_curTime < 0.5f)
2016-12-29 22:37:01 -08:00
return xc_action;
2016-12-17 20:16:04 -08:00
2016-12-15 20:35:49 -08:00
if (x10c_inputEnable)
x1c_loadedFrame->ProcessUserInput(input);
2016-12-17 20:16:04 -08:00
2016-12-16 15:05:29 -08:00
if (x10d_needsExistingToggle)
2016-12-15 20:35:49 -08:00
{
if (x40_tablegroup_popup->GetIsActive())
2016-12-16 15:05:29 -08:00
DeactivateExistingGamePopup();
2016-12-15 20:35:49 -08:00
else
2016-12-16 15:05:29 -08:00
ActivateExistingGamePopup();
x10d_needsExistingToggle = false;
}
2016-12-17 20:16:04 -08:00
2016-12-16 15:05:29 -08:00
if (x10e_needsNewToggle)
{
if (x40_tablegroup_popup->GetIsActive())
DeactivateNewGamePopup();
else
ActivateNewGamePopup();
x10e_needsNewToggle = false;
2016-12-15 20:35:49 -08:00
}
2016-12-17 20:16:04 -08:00
2016-12-29 22:37:01 -08:00
return xc_action;
2016-12-15 20:35:49 -08:00
}
2016-12-17 20:16:04 -08:00
void CFrontEndUI::SNewFileSelectFrame::Draw() const
{
}
2016-12-15 20:35:49 -08:00
void CFrontEndUI::SNewFileSelectFrame::HandleActiveChange(CGuiTableGroup* active)
{
if (!active)
return;
2016-12-17 20:16:04 -08:00
2016-12-15 20:35:49 -08:00
active->SetColors(zeus::CColor::skWhite,
zeus::CColor{0.627450f, 0.627450f, 0.627450f, 0.784313f});
if (active == x20_tablegroup_fileselect)
x24_model_erase->SetLocalTransform(zeus::CTransform::Translate(
zeus::CVector3f{0.f, 0.f, active->GetUserSelection() * x104_rowPitch} + xf8_model_erase_position));
2016-12-17 20:16:04 -08:00
if (x8_subMenu == ESubMenu::Zero || x8_subMenu == ESubMenu::Three)
2016-12-15 20:35:49 -08:00
x24_model_erase->SetIsVisible(false);
else
x24_model_erase->SetIsVisible(true);
}
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SNewFileSelectFrame::DeactivateExistingGamePopup()
2016-12-15 20:35:49 -08:00
{
x40_tablegroup_popup->SetIsActive(false);
x40_tablegroup_popup->SetIsVisible(false);
x20_tablegroup_fileselect->SetIsActive(true);
2016-12-17 20:16:04 -08:00
2016-12-15 20:35:49 -08:00
HandleActiveChange(x20_tablegroup_fileselect);
2016-12-17 20:16:04 -08:00
2016-12-15 20:35:49 -08:00
x64_fileSelections[x20_tablegroup_fileselect->GetUserSelection()].
x0_base->SetColor(zeus::CColor::skWhite);
}
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SNewFileSelectFrame::ActivateExistingGamePopup()
2016-12-15 20:35:49 -08:00
{
x40_tablegroup_popup->SetIsActive(true);
x40_tablegroup_popup->SetIsVisible(true);
x40_tablegroup_popup->SetLocalTransform(
zeus::CTransform::Translate(0.f, 0.f, x20_tablegroup_fileselect->GetUserSelection() * x104_rowPitch) *
x40_tablegroup_popup->GetTransform());
x20_tablegroup_fileselect->SetIsActive(false);
2016-12-17 20:16:04 -08:00
x8_subMenu = ESubMenu::Two;
2016-12-15 20:35:49 -08:00
HandleActiveChange(x40_tablegroup_popup);
2016-12-17 20:16:04 -08:00
2016-12-16 15:05:29 -08:00
x48_textpane_popupadvance.SetPairText(g_MainStringTable->GetString(95));
x50_textpane_popupcancel.SetPairText(g_MainStringTable->GetString(38));
2016-12-17 20:16:04 -08:00
2016-12-15 20:35:49 -08:00
x64_fileSelections[x20_tablegroup_fileselect->GetUserSelection()].
x0_base->SetColor(zeus::CColor{1.f, 1.f, 1.f, 0.f});
x44_model_dash7->SetVisibility(false, ETraversalMode::Children);
}
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SNewFileSelectFrame::DeactivateNewGamePopup()
{
x40_tablegroup_popup->SetIsActive(false);
x40_tablegroup_popup->SetIsVisible(false);
x20_tablegroup_fileselect->SetIsActive(true);
2016-12-17 20:16:04 -08:00
2016-12-16 15:05:29 -08:00
CGuiWidget* worker = x40_tablegroup_popup->GetWorkerWidget(2);
worker->SetB627(false);
worker->SetVisibility(false, ETraversalMode::Children);
2016-12-17 20:16:04 -08:00
2016-12-16 15:05:29 -08:00
x44_model_dash7->SetVisibility(false, ETraversalMode::Children);
2016-12-17 20:16:04 -08:00
2016-12-16 15:05:29 -08:00
HandleActiveChange(x20_tablegroup_fileselect);
2016-12-17 20:16:04 -08:00
2016-12-16 15:05:29 -08:00
x64_fileSelections[x20_tablegroup_fileselect->GetUserSelection()].
x0_base->SetColor(zeus::CColor::skWhite);
x60_textpane_cancel->TextSupport()->SetText("");
}
void CFrontEndUI::SNewFileSelectFrame::ActivateNewGamePopup()
{
x40_tablegroup_popup->SetIsActive(true);
x40_tablegroup_popup->SetIsVisible(true);
x40_tablegroup_popup->SetUserSelection(0);
x40_tablegroup_popup->SetLocalTransform(
zeus::CTransform::Translate(0.f, 0.f, x20_tablegroup_fileselect->GetUserSelection() * x104_rowPitch) *
x40_tablegroup_popup->GetTransform());
x20_tablegroup_fileselect->SetIsActive(false);
2016-12-17 20:16:04 -08:00
x8_subMenu = ESubMenu::Three;
2016-12-16 15:05:29 -08:00
HandleActiveChange(x40_tablegroup_popup);
x64_fileSelections[x20_tablegroup_fileselect->GetUserSelection()].
x0_base->SetColor(zeus::CColor{1.f, 1.f, 1.f, 0.f});
2016-12-17 20:16:04 -08:00
2016-12-16 15:05:29 -08:00
PlayAdvanceSfx();
2016-12-17 20:16:04 -08:00
2016-12-20 13:51:50 -08:00
if (g_GameState->SystemOptions().GetPlayerHasHardMode())
2016-12-16 15:05:29 -08:00
{
x48_textpane_popupadvance.SetPairText(g_MainStringTable->GetString(102));
x50_textpane_popupcancel.SetPairText(g_MainStringTable->GetString(94));
x58_textpane_popupextra.SetPairText(g_MainStringTable->GetString(101));
CGuiWidget* worker = x40_tablegroup_popup->GetWorkerWidget(2);
worker->SetB627(true);
worker->SetVisibility(true, ETraversalMode::Children);
x44_model_dash7->SetVisibility(true, ETraversalMode::Children);
}
else
{
x48_textpane_popupadvance.SetPairText(g_MainStringTable->GetString(67));
x50_textpane_popupcancel.SetPairText(g_MainStringTable->GetString(94));
x44_model_dash7->SetVisibility(false, ETraversalMode::Children);
}
x60_textpane_cancel->TextSupport()->SetText(g_MainStringTable->GetString(82));
}
void CFrontEndUI::SNewFileSelectFrame::ResetFrame()
{
2016-12-17 20:16:04 -08:00
x8_subMenu = ESubMenu::Zero;
2016-12-16 15:05:29 -08:00
x38_textpane_gba.x0_panes[0]->SetB627(true);
x38_textpane_gba.x0_panes[0]->TextSupport()->SetFontColor(zeus::CColor::skWhite);
2016-12-17 20:16:04 -08:00
2016-12-16 15:05:29 -08:00
x30_textpane_cheats.x0_panes[0]->SetB627(true);
x30_textpane_cheats.x0_panes[0]->TextSupport()->SetFontColor(zeus::CColor::skWhite);
2016-12-17 20:16:04 -08:00
2016-12-16 15:05:29 -08:00
ClearFrameContents();
2016-12-17 20:16:04 -08:00
2016-12-16 15:05:29 -08:00
for (int i=2 ; i>=0 ; --i)
x20_tablegroup_fileselect->GetWorkerWidget(i)->SetB627(true);
x60_textpane_cancel->TextSupport()->SetText("");
}
void CFrontEndUI::SNewFileSelectFrame::ClearFrameContents()
{
x108_curTime = 0.f;
bool hasSave = false;
for (int i=0 ; i<3 ; ++i)
{
if (x4_saveUI->GetGameData(i))
hasSave = true;
2016-12-17 20:16:04 -08:00
SFileMenuOption& option = x64_fileSelections[i];
option.x2c_ = SFileMenuOption::ComputeRandom();
2016-12-16 15:05:29 -08:00
option.x28_ = -1;
for (int j=0 ; j<4 ; ++j)
option.x4_textpanes[j].SetPairText(L"");
}
StartTextAnimating(x28_textpane_erase.x0_panes[0], g_MainStringTable->GetString(38), 60.f);
StartTextAnimating(x38_textpane_gba.x0_panes[0], g_MainStringTable->GetString(37), 60.f);
StartTextAnimating(x30_textpane_cheats.x0_panes[0], g_MainStringTable->GetString(96), 60.f);
StartTextAnimating(x28_textpane_erase.x0_panes[1], g_MainStringTable->GetString(38), 60.f);
StartTextAnimating(x38_textpane_gba.x0_panes[1], g_MainStringTable->GetString(37), 60.f);
StartTextAnimating(x30_textpane_cheats.x0_panes[1], g_MainStringTable->GetString(96), 60.f);
if (hasSave)
{
x28_textpane_erase.x0_panes[0]->SetB627(true);
x28_textpane_erase.x0_panes[0]->TextSupport()->SetFontColor(zeus::CColor::skWhite);
}
else
{
x28_textpane_erase.x0_panes[0]->SetB627(false);
zeus::CColor color = zeus::CColor::skGrey;
color.a = 0.5f;
x28_textpane_erase.x0_panes[0]->TextSupport()->SetFontColor(color);
}
x20_tablegroup_fileselect->SetUserSelection(0);
CGuiTextPane* cheats = static_cast<CGuiTextPane*>(x20_tablegroup_fileselect->GetWorkerWidget(5));
if (CSlideShow::SlideShowGalleryFlags())
{
cheats->SetB627(true);
x30_textpane_cheats.x0_panes[0]->TextSupport()->SetFontColor(zeus::CColor::skWhite);
}
else
{
cheats->SetB627(false);
zeus::CColor color = zeus::CColor::skGrey;
color.a = 0.5f;
x30_textpane_cheats.x0_panes[0]->TextSupport()->SetFontColor(color);
}
HandleActiveChange(x20_tablegroup_fileselect);
}
void CFrontEndUI::SNewFileSelectFrame::SetupFrameContents()
2016-12-15 20:35:49 -08:00
{
2016-12-16 15:05:29 -08:00
for (int i=0 ; i<3 ; ++i)
{
2016-12-17 20:16:04 -08:00
SFileMenuOption& option = x64_fileSelections[i];
2016-12-16 15:05:29 -08:00
if (option.x28_ == 4)
continue;
SGuiTextPair* pair = (option.x28_ == -1) ? nullptr : &option.x4_textpanes[option.x28_];
if (pair)
{
//pair->x0_panes[0]->GetTextSupport()->GetNumCharsPrinted()
}
2016-12-15 20:35:49 -08:00
2016-12-16 15:05:29 -08:00
}
2016-12-15 20:35:49 -08:00
}
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SNewFileSelectFrame::DoPopupCancel(CGuiTableGroup* caller)
2016-12-15 20:35:49 -08:00
{
2016-12-17 20:16:04 -08:00
if (x8_subMenu == ESubMenu::Two)
2016-12-16 15:05:29 -08:00
{
CSfxManager::SfxStart(1094, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
2016-12-17 20:16:04 -08:00
x8_subMenu = ESubMenu::One;
2016-12-16 15:05:29 -08:00
x10d_needsExistingToggle = true;
}
else
{
CSfxManager::SfxStart(1094, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
2016-12-17 20:16:04 -08:00
x8_subMenu = ESubMenu::Zero;
2016-12-16 15:05:29 -08:00
x10e_needsNewToggle = true;
}
}
2016-12-15 20:35:49 -08:00
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SNewFileSelectFrame::DoPopupAdvance(CGuiTableGroup* caller)
{
2016-12-17 20:16:04 -08:00
if (x8_subMenu == ESubMenu::Two)
2016-12-16 15:05:29 -08:00
{
if (x40_tablegroup_popup->GetUserSelection() == 1)
{
x4_saveUI->EraseGame(x20_tablegroup_fileselect->GetUserSelection());
ResetFrame();
}
else
2016-12-17 20:16:04 -08:00
x8_subMenu = ESubMenu::One;
2016-12-16 15:05:29 -08:00
x10d_needsExistingToggle = true;
}
else
{
2016-12-20 13:51:50 -08:00
if (g_GameState->SystemOptions().GetPlayerHasHardMode())
2016-12-16 15:05:29 -08:00
{
if (x40_tablegroup_popup->GetUserSelection() == 1)
{
PlayAdvanceSfx();
2016-12-29 22:37:01 -08:00
xc_action = EAction::One;
2016-12-16 15:05:29 -08:00
return;
}
g_GameState->SetHardMode(x20_tablegroup_fileselect->GetUserSelection());
x4_saveUI->StartGame(x40_tablegroup_popup->GetUserSelection());
}
else
{
if (x40_tablegroup_popup->GetUserSelection() == 1)
{
PlayAdvanceSfx();
2016-12-29 22:37:01 -08:00
xc_action = EAction::One;
2016-12-16 15:05:29 -08:00
return;
}
x4_saveUI->StartGame(x40_tablegroup_popup->GetUserSelection());
}
}
2016-12-15 20:35:49 -08:00
}
2016-12-17 20:16:04 -08:00
void CFrontEndUI::SNewFileSelectFrame::DoFileMenuCancel(CGuiTableGroup* caller)
2016-12-15 20:35:49 -08:00
{
2016-12-17 20:16:04 -08:00
if (x8_subMenu == ESubMenu::One)
2016-12-16 15:05:29 -08:00
{
CSfxManager::SfxStart(1094, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
ResetFrame();
}
}
2016-12-15 20:35:49 -08:00
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SNewFileSelectFrame::DoSelectionChange(CGuiTableGroup* caller)
{
HandleActiveChange(caller);
CSfxManager::SfxStart(1093, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
2016-12-15 20:35:49 -08:00
}
2016-12-17 20:16:04 -08:00
void CFrontEndUI::SNewFileSelectFrame::DoFileMenuAdvance(CGuiTableGroup* caller)
{
}
2016-12-17 20:16:04 -08:00
CFrontEndUI::SFileMenuOption CFrontEndUI::SNewFileSelectFrame::FindFileSelectOption(CGuiFrame* frame, int idx)
{
2016-12-17 20:16:04 -08:00
SFileMenuOption ret;
2016-12-16 15:05:29 -08:00
ret.x0_base = frame->FindWidget(hecl::Format("basewidget_file%d", idx).c_str());
ret.x4_textpanes[0] = FindTextPanePair(frame, hecl::Format("textpane_filename%d", idx).c_str());
ret.x4_textpanes[1] = FindTextPanePair(frame, hecl::Format("textpane_world%d", idx).c_str());
ret.x4_textpanes[2] = FindTextPanePair(frame, hecl::Format("textpane_playtime%d", idx).c_str());
ret.x4_textpanes[3] = FindTextPanePair(frame, hecl::Format("textpane_date%d", idx).c_str());
return ret;
}
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SNewFileSelectFrame::StartTextAnimating(CGuiTextPane* text, const std::wstring& str, float chRate)
{
text->TextSupport()->SetText(str);
text->TextSupport()->SetTypeWriteEffectOptions(true, 0.1f, chRate);
}
CFrontEndUI::SGBASupportFrame::SGBASupportFrame()
{
x4_gbaSupport = std::make_unique<CGBASupport>();
xc_gbaScreen = g_SimplePool->GetObj("FRME_GBAScreen");
x18_gbaLink = g_SimplePool->GetObj("FRME_GBALink");
}
void CFrontEndUI::SGBASupportFrame::FinishedLoading()
{
2016-12-15 20:35:49 -08:00
x28_tablegroup_options = static_cast<CGuiTableGroup*>(x24_loadedFrame->FindWidget("tablegroup_options"));
x2c_tablegroup_fusionsuit = static_cast<CGuiTableGroup*>(x24_loadedFrame->FindWidget("tablegroup_fusionsuit"));
x30_textpane_instructions = FindTextPanePair(x24_loadedFrame, "textpane_instructions");
2016-12-17 20:16:04 -08:00
2016-12-15 20:35:49 -08:00
FindAndSetPairText(x24_loadedFrame, "textpane_nes", g_MainStringTable->GetString(66));
FindAndSetPairText(x24_loadedFrame, "textpane_fusionsuit", g_MainStringTable->GetString(63));
FindAndSetPairText(x24_loadedFrame, "textpane_fusionsuitno", g_MainStringTable->GetString(65));
FindAndSetPairText(x24_loadedFrame, "textpane_fusionsuityes", g_MainStringTable->GetString(64));
FindAndSetPairText(x24_loadedFrame, "textpane_title", g_MainStringTable->GetString(100));
2016-12-17 20:16:04 -08:00
2016-12-15 20:35:49 -08:00
static_cast<CGuiTextPane*>(x24_loadedFrame->FindWidget("textpane_proceed"))->
TextSupport()->SetText(g_MainStringTable->GetString(85));
static_cast<CGuiTextPane*>(x24_loadedFrame->FindWidget("textpane_cancel"))->
TextSupport()->SetText(g_MainStringTable->GetString(82));
2016-12-17 20:16:04 -08:00
2016-12-15 20:35:49 -08:00
x2c_tablegroup_fusionsuit->SetIsActive(false);
x2c_tablegroup_fusionsuit->SetIsVisible(false);
x2c_tablegroup_fusionsuit->SetD1(false);
2016-12-20 13:51:50 -08:00
x2c_tablegroup_fusionsuit->SetUserSelection(g_GameState->SystemOptions().GetPlayerHasFusion());
2016-12-15 20:35:49 -08:00
SetTableColors(x28_tablegroup_options);
SetTableColors(x2c_tablegroup_fusionsuit);
x28_tablegroup_options->SetMenuAdvanceCallback(
std::bind(&SGBASupportFrame::DoOptionsAdvance, this, std::placeholders::_1));
x28_tablegroup_options->SetMenuSelectionChangeCallback(
std::bind(&SGBASupportFrame::DoSelectionChange, this, std::placeholders::_1));
x28_tablegroup_options->SetMenuCancelCallback(
std::bind(&SGBASupportFrame::DoOptionsCancel, this, std::placeholders::_1));
x2c_tablegroup_fusionsuit->SetMenuSelectionChangeCallback(
std::bind(&SGBASupportFrame::DoSelectionChange, this, std::placeholders::_1));
}
bool CFrontEndUI::SGBASupportFrame::PumpLoad()
2016-12-15 20:35:49 -08:00
{
if (x24_loadedFrame)
return true;
if (!xc_gbaScreen.IsLoaded())
return false;
if (!x18_gbaLink.IsLoaded())
return false;
if (!x4_gbaSupport->IsReady())
return false;
if (!xc_gbaScreen->GetIsFinishedLoading())
return false;
x24_loadedFrame = xc_gbaScreen.GetObj();
FinishedLoading();
return true;
}
void CFrontEndUI::SGBASupportFrame::SetTableColors(CGuiTableGroup* tbgp) const
{
tbgp->SetColors(zeus::CColor::skWhite,
zeus::CColor{0.627450f, 0.627450f, 0.627450f, 0.784313f});
}
2016-12-29 22:37:01 -08:00
CFrontEndUI::SGBASupportFrame::EAction
CFrontEndUI::SGBASupportFrame::ProcessUserInput(const CFinalInput& input, CSaveUI* sui)
2016-12-15 20:35:49 -08:00
{
}
2016-12-17 20:16:04 -08:00
void CFrontEndUI::SGBASupportFrame::Draw() const
{
}
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SGBASupportFrame::DoOptionsCancel(CGuiTableGroup* caller)
2016-12-15 20:35:49 -08:00
{
}
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SGBASupportFrame::DoSelectionChange(CGuiTableGroup* caller)
2016-12-15 20:35:49 -08:00
{
}
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SGBASupportFrame::DoOptionsAdvance(CGuiTableGroup* caller)
{
}
2016-12-14 14:56:59 -08:00
void CFrontEndUI::SGuiTextPair::SetPairText(const std::wstring& str)
{
x0_panes[0]->TextSupport()->SetText(str);
x0_panes[1]->TextSupport()->SetText(str);
}
CFrontEndUI::SGuiTextPair CFrontEndUI::FindTextPanePair(CGuiFrame* frame, const char* name)
{
SGuiTextPair ret;
ret.x0_panes[0] = static_cast<CGuiTextPane*>(frame->FindWidget(name));
ret.x0_panes[1] = static_cast<CGuiTextPane*>(frame->FindWidget(hecl::Format("%sb", name).c_str()));
return ret;
}
void CFrontEndUI::FindAndSetPairText(CGuiFrame* frame, const char* name, const std::wstring& str)
{
CGuiTextPane* w1 = static_cast<CGuiTextPane*>(frame->FindWidget(name));
w1->TextSupport()->SetText(str);
CGuiTextPane* w2 = static_cast<CGuiTextPane*>(frame->FindWidget(hecl::Format("%sb", name).c_str()));
w2->TextSupport()->SetText(str);
}
2016-12-14 14:56:59 -08:00
void CFrontEndUI::SFrontEndFrame::FinishedLoading()
{
x18_tablegroup_mainmenu = static_cast<CGuiTableGroup*>(x14_loadedFrme->FindWidget("tablegroup_mainmenu"));
x1c_gbaPair = FindTextPanePair(x14_loadedFrme, "textpane_gba");
x1c_gbaPair.SetPairText(g_MainStringTable->GetString(37));
x24_cheatPair = FindTextPanePair(x14_loadedFrme, "textpane_cheats");
x24_cheatPair.SetPairText(g_MainStringTable->GetString(96));
2016-12-17 20:16:04 -08:00
2016-12-14 14:56:59 -08:00
FindAndSetPairText(x14_loadedFrme, "textpane_start", g_MainStringTable->GetString(67));
FindAndSetPairText(x14_loadedFrme, "textpane_options", g_MainStringTable->GetString(94));
FindAndSetPairText(x14_loadedFrme, "textpane_title", g_MainStringTable->GetString(98));
2016-12-17 20:16:04 -08:00
2016-12-14 14:56:59 -08:00
CGuiTextPane* proceed = static_cast<CGuiTextPane*>(x14_loadedFrme->FindWidget("textpane_proceed"));
if (proceed)
proceed->TextSupport()->SetText(g_MainStringTable->GetString(85));
x18_tablegroup_mainmenu->SetMenuAdvanceCallback(
2016-12-15 20:35:49 -08:00
std::bind(&SFrontEndFrame::DoAdvance, this, std::placeholders::_1));
2016-12-14 14:56:59 -08:00
x18_tablegroup_mainmenu->SetMenuSelectionChangeCallback(
2016-12-15 20:35:49 -08:00
std::bind(&SFrontEndFrame::DoSelectionChange, this, std::placeholders::_1));
2016-12-14 14:56:59 -08:00
x18_tablegroup_mainmenu->SetMenuCancelCallback(
2016-12-15 20:35:49 -08:00
std::bind(&SFrontEndFrame::DoCancel, this, std::placeholders::_1));
2016-12-14 14:56:59 -08:00
}
bool CFrontEndUI::SFrontEndFrame::PumpLoad()
{
if (x14_loadedFrme)
return true;
if (x8_frme.IsLoaded())
{
if (CGuiFrame* frme = x8_frme.GetObj())
{
if (frme->GetIsFinishedLoading())
{
x14_loadedFrme = frme;
FinishedLoading();
return true;
}
}
}
return false;
}
2016-12-29 22:37:01 -08:00
CFrontEndUI::SFrontEndFrame::EAction
CFrontEndUI::SFrontEndFrame::ProcessUserInput(const CFinalInput& input)
2016-12-14 14:56:59 -08:00
{
2016-12-29 22:37:01 -08:00
x4_action = EAction::Zero;
x14_loadedFrme->ProcessUserInput(input);
return x4_action;
2016-12-15 20:35:49 -08:00
}
2016-12-17 20:16:04 -08:00
void CFrontEndUI::SFrontEndFrame::Draw() const
{
2016-12-29 22:37:01 -08:00
x14_loadedFrme->Draw(CGuiWidgetDrawParms::Default);
2016-12-17 20:16:04 -08:00
}
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SFrontEndFrame::DoCancel(CGuiTableGroup* caller)
2016-12-15 20:35:49 -08:00
{
}
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SFrontEndFrame::DoSelectionChange(CGuiTableGroup* caller)
2016-12-15 20:35:49 -08:00
{
2016-12-14 14:56:59 -08:00
}
2016-12-16 15:05:29 -08:00
void CFrontEndUI::SFrontEndFrame::DoAdvance(CGuiTableGroup* caller)
2016-12-14 14:56:59 -08:00
{
}
CFrontEndUI::SFrontEndFrame::SFrontEndFrame(u32 rnd)
: x0_rnd(rnd)
{
x8_frme = g_SimplePool->GetObj("FRME_FrontEndPL");
}
2016-12-29 22:37:01 -08:00
CFrontEndUI::SNesEmulatorFrame::SNesEmulatorFrame()
2016-12-14 14:56:59 -08:00
{
x4_nesEmu = std::make_unique<CNESEmulator>();
const SObjectTag* deface = g_ResFactory->GetResourceIdByName("FONT_Deface14B");
CGuiTextProperties props(false, true, EJustification::Left,
EVerticalJustification::Center,
ETextDirection::Horizontal);
xc_textSupport = std::make_unique<CGuiTextSupport>(deface->id, props, zeus::CColor::skWhite,
zeus::CColor::skBlack, zeus::CColor::skWhite,
0, 0, g_SimplePool);
}
2016-12-29 22:37:01 -08:00
void CFrontEndUI::SNesEmulatorFrame::SetMode(EMode mode)
{
switch (mode)
{
case EMode::Emulator:
x8_quitScreen.reset();
break;
case EMode::QuitNESMetroid:
x8_quitScreen = std::make_unique<CQuitScreen>(EQuitType::QuitNESMetroid);
break;
case EMode::ContinuePlaying:
x8_quitScreen = std::make_unique<CQuitScreen>(EQuitType::ContinuePlaying);
break;
case EMode::SaveProgress:
x8_quitScreen = std::make_unique<CQuitScreen>(EQuitType::SaveProgress);
break;
default: break;
}
x0_mode = mode;
}
void CFrontEndUI::SNesEmulatorFrame::ProcessUserInput(const CFinalInput& input, CSaveUI* sui)
{
bool processInput = true;
if (sui && sui->GetUIType() != CSaveUI::EUIType::SaveProgress)
processInput = false;
if (sui)
sui->ProcessUserInput(input);
if (!processInput)
return;
switch (x0_mode)
{
case EMode::Emulator:
x4_nesEmu->ProcessUserInput(input, 4);
if (input.ControllerIdx() == 0 && input.PL())
SetMode(EMode::SaveProgress);
break;
case EMode::QuitNESMetroid:
case EMode::ContinuePlaying:
case EMode::SaveProgress:
x8_quitScreen->ProcessUserInput(input);
break;
default: break;
}
}
bool CFrontEndUI::SNesEmulatorFrame::DoUpdateWithSaveUI(float dt, CSaveUI* saveUi)
{
2016-12-29 22:37:01 -08:00
bool flag = (saveUi && saveUi->GetUIType() != CSaveUI::EUIType::SaveProgress) ? false : true;
x10_remTime = std::max(x10_remTime - dt, 0.f);
zeus::CColor geomCol(zeus::CColor::skWhite);
geomCol.a = std::min(x10_remTime, 1.f);
xc_textSupport->SetGeometryColor(geomCol);
if (xc_textSupport->GetIsTextSupportFinishedLoading())
{
}
return false;
}
2016-12-29 22:37:01 -08:00
void CFrontEndUI::SNesEmulatorFrame::Draw(CSaveUI* saveUi) const
2016-12-17 20:16:04 -08:00
{
}
2016-12-14 14:56:59 -08:00
CFrontEndUI::SOptionsFrontEndFrame::SOptionsFrontEndFrame()
{
x4_frme = g_SimplePool->GetObj("FRME_OptionsFrontEnd");
x10_pauseScreen = g_SimplePool->GetObj("STRG_PauseScreen");
}
2016-12-29 22:37:01 -08:00
bool CFrontEndUI::SOptionsFrontEndFrame::ProcessUserInput(const CFinalInput& input, CSaveUI* sui)
2016-12-17 20:16:04 -08:00
{
}
void CFrontEndUI::SOptionsFrontEndFrame::Draw() const
{
}
2016-09-16 13:18:03 -07:00
CFrontEndUI::CFrontEndUI(CArchitectureQueue& queue)
2016-08-05 16:48:53 -07:00
: CIOWin("FrontEndUI")
{
2016-12-12 21:22:30 -08:00
x18_rndA = std::min(rand() * 3 / RAND_MAX, 2);
x1c_rndB = std::min(rand() * 3 / RAND_MAX, 2);
2016-09-16 13:18:03 -07:00
x20_depsGroup = g_SimplePool->GetObj("FrontEnd_DGRP");
x38_pressStart = g_SimplePool->GetObj("TXTR_PressStart");
x44_frontendAudioGrp = g_SimplePool->GetObj("FrontEnd_AGSC");
g_Main->ResetGameState();
g_GameState->SetCurrentWorldId(g_DefaultWorldTag.id);
for (int i=0 ; CDvdFile::FileExists(GetAttractMovieFileName(i).c_str()) ; ++i)
++xc0_attractCount;
2016-08-05 16:48:53 -07:00
}
2015-08-26 17:23:46 -07:00
void CFrontEndUI::OnSliderSelectionChange(CGuiSliderGroup* grp, float)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::OnCheckBoxSelectionChange(CGuiTableGroup* grp)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::OnOptionSubMenuCancel(CGuiTableGroup* grp)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::OnOptionsMenuCancel(CGuiTableGroup* grp)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::OnNewGameMenuCancel(CGuiTableGroup* grp)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::OnFileMenuCancel(CGuiTableGroup* grp)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::OnGenericMenuSelectionChange(CGuiTableGroup* grp, int, int)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::OnOptionsMenuAdvance(CGuiTableGroup* grp)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::OnNewGameMenuAdvance(CGuiTableGroup* grp)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::OnFileMenuAdvance(CGuiTableGroup* grp)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::OnMainMenuAdvance(CGuiTableGroup* grp)
{}
2016-09-16 13:18:03 -07:00
void CFrontEndUI::StartSlideShow(CArchitectureQueue& queue)
{
queue.Push(MakeMsg::CreateCreateIOWin(EArchMsgTarget::IOWinManager, 12, 11, new CSlideShow()));
2016-09-16 13:18:03 -07:00
}
std::string CFrontEndUI::GetAttractMovieFileName(int idx)
{
return hecl::Format("Video/attract%d.thp", idx);
}
std::string CFrontEndUI::GetNextAttractMovieFileName()
{
2016-09-16 23:40:45 -07:00
std::string ret = GetAttractMovieFileName(xbc_nextAttract);
2016-09-16 13:18:03 -07:00
xbc_nextAttract = (xbc_nextAttract + 1) % xc0_attractCount;
2016-09-16 23:40:45 -07:00
return ret;
2016-09-16 13:18:03 -07:00
}
2015-08-26 17:23:46 -07:00
void CFrontEndUI::SetCurrentMovie(EMenuMovie movie)
2016-12-12 21:22:30 -08:00
{
if (xb8_curMovie == movie)
return;
StopAttractMovie();
if (xb8_curMovie != EMenuMovie::Stopped)
{
xcc_curMoviePtr->SetPlayMode(CMoviePlayer::EPlayMode::Stopped);
xcc_curMoviePtr->Rewind();
}
xb8_curMovie = movie;
if (xb8_curMovie != EMenuMovie::Stopped)
{
xcc_curMoviePtr = x70_menuMovies[int(xb8_curMovie)].get();
xcc_curMoviePtr->SetPlayMode(CMoviePlayer::EPlayMode::Playing);
}
else
xcc_curMoviePtr = nullptr;
}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::StopAttractMovie()
2016-12-12 21:22:30 -08:00
{
if (!xc4_attractMovie)
return;
xc4_attractMovie.reset();
xcc_curMoviePtr = nullptr;
}
2016-09-16 13:18:03 -07:00
2016-12-12 21:22:30 -08:00
void CFrontEndUI::StartAttractMovie()
{
if (xc4_attractMovie)
return;
SetCurrentMovie(EMenuMovie::Stopped);
xc4_attractMovie = std::make_unique<CMoviePlayer>(GetNextAttractMovieFileName().c_str(), 0.f, false, true);
xcc_curMoviePtr = xc4_attractMovie.get();
}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::UpdateMenuHighlights(CGuiTableGroup* grp)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::CompleteStateTransition()
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
bool CFrontEndUI::CanBuild(const SObjectTag& tag)
2016-09-16 13:18:03 -07:00
{
return false;
}
2015-08-26 17:23:46 -07:00
void CFrontEndUI::StartStateTransition(EScreen screen)
2016-12-12 21:22:30 -08:00
{
switch (x50_curScreen)
{
case EScreen::One:
if (screen != EScreen::Three)
break;
SetCurrentMovie(EMenuMovie::StartFileSelectA);
SetMovieSeconds(xcc_curMoviePtr->GetTotalSeconds());
break;
case EScreen::Three:
if (screen == EScreen::Five)
{
SetCurrentMovie(EMenuMovie::FileSelectPlayGameA);
SetMovieSeconds(xcc_curMoviePtr->GetTotalSeconds());
}
else if (screen == EScreen::Four)
{
SetCurrentMovie(EMenuMovie::FileSelectGBA);
SetMovieSeconds(xcc_curMoviePtr->GetTotalSeconds());
CSfxManager::SfxStart(1108, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
CSfxManager::SfxStart(1109, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
break;
case EScreen::Four:
if (screen == EScreen::Five)
{
SetCurrentMovie(EMenuMovie::GBAFileSelectB);
SetMovieSeconds(xcc_curMoviePtr->GetTotalSeconds());
}
else if (screen == EScreen::Three)
{
SetCurrentMovie(EMenuMovie::GBAFileSelectA);
SetMovieSeconds(xcc_curMoviePtr->GetTotalSeconds());
CSfxManager::SfxStart(1110, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
CSfxManager::SfxStart(1111, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
default: break;
}
switch (screen)
{
case EScreen::Zero:
case EScreen::One:
SetCurrentMovie(EMenuMovie::FirstStart);
SetMovieSeconds(xcc_curMoviePtr->GetTotalSeconds());
break;
case EScreen::Two:
StartAttractMovie();
SetMovieSecondsDeferred();
default: break;
}
x54_nextScreen = screen;
}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::HandleDebugMenuReturnValue(CGameDebug::EReturnValue val, CArchitectureQueue& queue)
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::Draw() const
2016-09-16 13:18:03 -07:00
{
2016-12-13 17:10:17 -08:00
//printf("DRAW\n");
2016-12-17 20:16:04 -08:00
if (x14_phase < EPhase::Four)
return;
2016-12-29 22:37:01 -08:00
if (xec_emuFrme)
xec_emuFrme->Draw(xdc_saveUI.get());
2016-12-17 20:16:04 -08:00
else
{
//g_Renderer->SetDepthReadWrite(false, false);
g_Renderer->SetViewportOrtho(false, -4096.f, 4096.f);
if (xcc_curMoviePtr && xcc_curMoviePtr->GetIsFullyCached())
{
auto vidDimensions = xcc_curMoviePtr->GetVideoDimensions();
float aspectRatio = vidDimensions.first / float(vidDimensions.second);
float verticalOff = (CGraphics::g_ViewportResolution.x / aspectRatio - CGraphics::g_ViewportResolution.y) * 0.5f;
xcc_curMoviePtr->SetFrame(zeus::CVector3f(0.f, -verticalOff, 0.f),
zeus::CVector3f(CGraphics::g_ViewportResolution.x, verticalOff, 0.f),
zeus::CVector3f(0.f, CGraphics::g_ViewportResolution.y + verticalOff, 0.f),
zeus::CVector3f(CGraphics::g_ViewportResolution.x, CGraphics::g_ViewportResolution.y + verticalOff, 0.f));
2016-12-17 20:16:04 -08:00
xcc_curMoviePtr->DrawFrame();
}
if (x50_curScreen == EScreen::Three && x54_nextScreen == EScreen::Three)
{
if (xf0_optionsFrme)
xf0_optionsFrme->Draw();
else if (xe0_newFileSel)
xe0_newFileSel->Draw();
else
xe8_frontendFrme->Draw();
}
else if (x50_curScreen == EScreen::Four && x54_nextScreen == EScreen::Four)
xe4_gbaSupportFrme->Draw();
if (x64_pressStartAlpha > 0.f && x38_pressStart.IsLoaded() && m_pressStartQuad)
{
float nativeRatio = CGraphics::g_ViewportResolution.x / 640.f;
float hOffset = x38_pressStart->GetWidth() / 2.f * nativeRatio;
float vOffset = x38_pressStart->GetHeight() / 2.f * nativeRatio;
zeus::CRectangle rect(CGraphics::g_ViewportResolutionHalf.x - hOffset, 72.f * nativeRatio - vOffset,
x38_pressStart->GetWidth() * nativeRatio, x38_pressStart->GetHeight() * nativeRatio);
zeus::CColor color = zeus::CColor::skWhite;
color.a = x64_pressStartAlpha;
const_cast<CTexturedQuadFilterAlpha&>(*m_pressStartQuad).draw(color, 1.f, rect);
}
if (xc0_attractCount > 0)
{
if (((x50_curScreen == EScreen::One && x54_nextScreen == EScreen::One) ||
x54_nextScreen == EScreen::Two) && x58_movieSeconds < 1.f)
{
zeus::CColor color = zeus::CColor::skBlack;
color.a = 1.f - x58_movieSeconds;
const_cast<CColoredQuadFilter&>(m_fadeToBlack).draw(color);
}
}
if (xd0_)
{
if (x54_nextScreen == EScreen::One && x50_curScreen == EScreen::Zero)
{
zeus::CColor color = zeus::CColor::skBlack;
color.a = zeus::clamp(0.f, 1.f - x58_movieSeconds, 1.f);
const_cast<CColoredQuadFilter&>(m_fadeToBlack).draw(color);
}
else if (x54_nextScreen == EScreen::One && x50_curScreen == EScreen::One)
{
zeus::CColor color = zeus::CColor::skBlack;
color.a = 1.f - zeus::clamp(0.f, 30.f - x58_movieSeconds, 1.f);
const_cast<CColoredQuadFilter&>(m_fadeToBlack).draw(color);
}
}
if (xdc_saveUI)
{
if ((IsSaveUIConditional() && !xdc_saveUI->IsDrawConditional()) ||
((x50_curScreen == EScreen::Three && x54_nextScreen == EScreen::Three) ||
(x50_curScreen == EScreen::Four && x54_nextScreen == EScreen::Four)))
xdc_saveUI->Draw();
}
}
2016-09-16 13:18:03 -07:00
}
2015-08-26 17:23:46 -07:00
void CFrontEndUI::UpdateMovies(float dt)
2016-12-12 21:22:30 -08:00
{
if (xcc_curMoviePtr && x5c_movieSecondsNeeded)
{
x5c_movieSecondsNeeded = false;
x58_movieSeconds = xcc_curMoviePtr->GetTotalSeconds();
}
for (auto& movie : x70_menuMovies)
if (movie)
movie->Update(dt);
if (xc4_attractMovie)
xc4_attractMovie->Update(dt);
}
2016-12-14 14:56:59 -08:00
void CFrontEndUI::FinishedLoadingDepsGroup()
{
2016-12-17 20:16:04 -08:00
const CDependencyGroup* dgrp = x20_depsGroup.GetObj();
x2c_deps.reserve(dgrp->GetObjectTagVector().size());
for (const SObjectTag& tag : dgrp->GetObjectTagVector())
x2c_deps.push_back(g_SimplePool->GetObj(tag));
x44_frontendAudioGrp.Lock();
2016-12-14 14:56:59 -08:00
}
bool CFrontEndUI::PumpLoad()
{
2016-12-17 20:16:04 -08:00
for (CToken& tok : x2c_deps)
if (!tok.IsLoaded())
return false;
if (!x44_frontendAudioGrp.IsLoaded())
return false;
/* Ready to construct texture quads */
m_pressStartQuad.emplace(CCameraFilterPass::EFilterType::Blend, x38_pressStart);
return true;
2016-12-14 14:56:59 -08:00
}
2016-12-12 21:22:30 -08:00
bool CFrontEndUI::PumpMovieLoad()
{
if (xd1_moviesLoaded)
return true;
for (int i=0 ; i<9 ; ++i)
{
if (!x70_menuMovies[i])
{
2016-12-14 14:56:59 -08:00
const FEMovie& movie = FEMovies[i];
x70_menuMovies[i] = std::make_unique<CMoviePlayer>(movie.path, 0.05f, movie.loop, false);
2016-12-12 21:22:30 -08:00
x70_menuMovies[i]->SetPlayMode(CMoviePlayer::EPlayMode::Stopped);
return false;
}
}
xd1_moviesLoaded = true;
return true;
}
2016-09-16 13:18:03 -07:00
void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue& queue)
{
2016-12-29 22:37:01 -08:00
if (static_cast<CMain*>(g_Main)->GetBardBusy())
return;
if (input.ControllerIdx() > 1)
return;
if (xec_emuFrme)
{
xec_emuFrme->ProcessUserInput(input, xdc_saveUI.get());
return;
}
if (x14_phase != EPhase::Four || input.ControllerIdx() != 0)
return;
if (x50_curScreen != x54_nextScreen)
{
if (x54_nextScreen == EScreen::Two && (input.PStart() || input.PA()))
{
SetMovieSeconds(std::min(1.f, x58_movieSeconds));
PlayAdvanceSfx();
return;
}
if (input.PA() || input.PStart())
{
if (x50_curScreen == EScreen::Zero && x54_nextScreen == EScreen::One &&
x58_movieSeconds > 1.f)
{
xd0_ = true;
SetMovieSeconds(1.f);
return;
}
}
}
else
{
if (x50_curScreen == EScreen::One)
{
if (input.PStart() || input.PA())
{
if (x58_movieSeconds < 30.f - g_tweakGame->GetPressStartDelay())
{
CSfxManager::SfxStart(FETransitionBackSFX[x18_rndA][0], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
CSfxManager::SfxStart(FETransitionBackSFX[x18_rndA][1], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
StartStateTransition(EScreen::Three);
return;
}
}
}
else if (x50_curScreen == EScreen::Three && x54_nextScreen == EScreen::Three)
{
if (xf0_optionsFrme)
{
if (xf0_optionsFrme->ProcessUserInput(input, xdc_saveUI.get()))
return;
xf0_optionsFrme.reset();
return;
}
else if (xe0_newFileSel)
{
switch (xe0_newFileSel->ProcessUserInput(input))
{
case SNewFileSelectFrame::EAction::Two:
StartStateTransition(EScreen::Four);
return;
case SNewFileSelectFrame::EAction::One:
xf0_optionsFrme = std::make_unique<SOptionsFrontEndFrame>();
return;
case SNewFileSelectFrame::EAction::Three:
xd2_ = true;
StartSlideShow(queue);
return;
default: return;
}
}
else
{
switch (xe8_frontendFrme->ProcessUserInput(input))
{
case SFrontEndFrame::EAction::Two:
StartStateTransition(EScreen::Four);
return;
case SFrontEndFrame::EAction::Three:
xf0_optionsFrme = std::make_unique<SOptionsFrontEndFrame>();
return;
case SFrontEndFrame::EAction::One:
TransitionToFive();
return;
case SFrontEndFrame::EAction::Four:
xd2_ = true;
StartSlideShow(queue);
return;
default: return;
}
}
}
else if (x50_curScreen == EScreen::Four && x54_nextScreen == EScreen::Four)
{
switch (xe4_gbaSupportFrme->ProcessUserInput(input, xdc_saveUI.get()))
{
case SGBASupportFrame::EAction::One:
StartStateTransition(EScreen::Three);
return;
case SGBASupportFrame::EAction::Two:
xf4_curAudio->StopMixing();
xec_emuFrme = std::make_unique<SNesEmulatorFrame>();
if (xdc_saveUI)
xdc_saveUI->SetInGame(true);
return;
default: return;
}
}
}
2016-09-16 13:18:03 -07:00
}
2016-12-12 21:22:30 -08:00
void CFrontEndUI::TransitionToFive()
{
if (x14_phase >= EPhase::Five)
2016-12-12 21:22:30 -08:00
return;
const u16* sfx = FETransitionForwardSFX[x1c_rndB];
CSfxManager::SfxStart(sfx[0], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
CSfxManager::SfxStart(sfx[1], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
x14_phase = EPhase::Five;
2016-12-12 21:22:30 -08:00
StartStateTransition(EScreen::Five);
}
2016-12-14 14:56:59 -08:00
void CFrontEndUI::UpdateMusicVolume()
2016-09-16 13:18:03 -07:00
{
2016-12-14 14:56:59 -08:00
float volMul = (xf4_curAudio == xd4_audio1.get()) ? FE1_VOL : FE2_VOL;
if (xf4_curAudio)
{
float vol = volMul * x68_musicVol * (g_GameState->GameOptions().GetMusicVolume() / 127.f);
xf4_curAudio->SetVolume(vol);
}
}
2016-12-12 21:22:30 -08:00
2016-12-14 14:56:59 -08:00
CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
{
2016-12-12 21:22:30 -08:00
if (xdc_saveUI && x50_curScreen >= EScreen::Three)
{
switch (xdc_saveUI->Update(dt))
{
case EMessageReturn::Exit:
TransitionToFive();
break;
case EMessageReturn::RemoveIOWinAndExit:
case EMessageReturn::RemoveIOWin:
xe0_newFileSel.reset();
xdc_saveUI.reset();
default: break;
}
}
2016-12-14 14:56:59 -08:00
UpdateMusicVolume();
switch (x14_phase)
2016-12-14 14:56:59 -08:00
{
case EPhase::Zero:
2016-12-14 14:56:59 -08:00
if (!x20_depsGroup.IsLoaded())
return EMessageReturn::Exit;
FinishedLoadingDepsGroup();
x20_depsGroup.Unlock();
x14_phase = EPhase::One;
2016-12-14 14:56:59 -08:00
case EPhase::One:
2016-12-14 14:56:59 -08:00
if (PumpLoad())
{
xe0_newFileSel = std::make_unique<SNewFileSelectFrame>(xdc_saveUI.get(), x1c_rndB);
xe4_gbaSupportFrme = std::make_unique<SGBASupportFrame>();
2016-12-14 14:56:59 -08:00
xe8_frontendFrme = std::make_unique<SFrontEndFrame>(x1c_rndB);
x38_pressStart.GetObj();
CAudioSys::AddAudioGroup(x44_frontendAudioGrp->GetAudioGroupData());
xd4_audio1 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_1.rsf", 416480, 1973664);
xd8_audio2 = std::make_unique<CStaticAudioPlayer>("Audio/frontend_2.rsf", 273556, 1636980);
x14_phase = EPhase::Two;
2016-12-14 14:56:59 -08:00
}
if (x14_phase == EPhase::One)
2016-12-14 14:56:59 -08:00
return EMessageReturn::Exit;
case EPhase::Two:
2016-12-14 14:56:59 -08:00
if (!xd4_audio1->IsReady() || !xd8_audio2->IsReady() ||
!xe0_newFileSel->PumpLoad() || !xe4_gbaSupportFrme->PumpLoad() ||
2016-12-14 14:56:59 -08:00
!xe8_frontendFrme->PumpLoad() || !xdc_saveUI->PumpLoad())
return EMessageReturn::Exit;
xf4_curAudio = xd4_audio1.get();
xf4_curAudio->StartMixing();
x14_phase = EPhase::Three;
2016-12-14 14:56:59 -08:00
case EPhase::Three:
2016-12-14 14:56:59 -08:00
{
bool moviesReady = true;
if (PumpMovieLoad())
{
UpdateMovies(dt);
for (int i=0 ; i<9 ; ++i)
{
if (!x70_menuMovies[i]->GetIsFullyCached())
{
moviesReady = false;
break;
}
}
}
else
moviesReady = false;
if (moviesReady)
{
x14_phase = EPhase::Four;
2016-12-14 14:56:59 -08:00
StartStateTransition(EScreen::One);
}
else
return EMessageReturn::Exit;
}
case EPhase::Four:
case EPhase::Five:
2016-12-29 22:37:01 -08:00
if (xec_emuFrme)
2016-12-14 14:56:59 -08:00
{
2016-12-29 22:37:01 -08:00
if (xec_emuFrme->DoUpdateWithSaveUI(dt, xdc_saveUI.get()))
{
2016-12-29 22:37:01 -08:00
xec_emuFrme.reset();
xf4_curAudio->StartMixing();
}
break;
2016-12-14 14:56:59 -08:00
}
}
2016-12-12 21:22:30 -08:00
2016-09-16 13:18:03 -07:00
return EMessageReturn::Exit;
}
2015-08-26 17:23:46 -07:00
CIOWin::EMessageReturn CFrontEndUI::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue)
2016-09-16 13:18:03 -07:00
{
switch (msg.GetType())
{
case EArchMsgType::UserInput:
{
const CArchMsgParmUserInput& input = MakeMsg::GetParmUserInput(msg);
ProcessUserInput(input.x4_parm, queue);
break;
}
case EArchMsgType::TimerTick:
{
float dt = MakeMsg::GetParmTimerTick(msg).x4_parm;
return Update(dt, queue);
}
case EArchMsgType::QuitGameplay:
{
x14_phase = EPhase::Six;
2016-09-16 13:18:03 -07:00
break;
}
default: break;
}
return EMessageReturn::Normal;
}
2015-08-26 17:23:46 -07:00
void CFrontEndUI::StartGame()
{}
2016-09-16 13:18:03 -07:00
2015-08-26 17:23:46 -07:00
void CFrontEndUI::InitializeFrame()
{}
}
}