metaforce/Runtime/MP1/CQuitGameScreen.cpp

121 lines
3.3 KiB
C++
Raw Normal View History

2017-02-12 03:17:18 +00:00
#include "CQuitGameScreen.hpp"
2016-12-30 06:37:01 +00:00
#include "Input/CFinalInput.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
#include "GuiSys/CGuiFrame.hpp"
#include "GuiSys/CGuiTableGroup.hpp"
#include "GuiSys/CGuiTextPane.hpp"
#include "GuiSys/CStringTable.hpp"
#include "GuiSys/CGuiWidgetDrawParms.hpp"
#include "Audio/CSfxManager.hpp"
namespace urde
{
namespace MP1
{
static const int Titles[] =
{
24, 25, 26, 27, 28
};
static const int DefaultSelections[] =
{
1, 0, 1, 1, 0
};
static const float VerticalOffsets[] =
{
0.f, 1.6f, 1.f, 0.f, 1.f
};
2017-02-12 03:17:18 +00:00
void CQuitGameScreen::SetColors()
2016-12-30 06:37:01 +00:00
{
x14_tablegroup_quitgame->SetColors(zeus::CColor{0.784313f, 0.784313f, 0.784313f, 1.f},
zeus::CColor{0.196078f, 0.196078f, 0.196078f, 1.f});
}
2017-02-12 03:17:18 +00:00
void CQuitGameScreen::FinishedLoading()
2016-12-30 06:37:01 +00:00
{
x10_loadedFrame = x4_frame.GetObj();
x14_tablegroup_quitgame = static_cast<CGuiTableGroup*>(
x10_loadedFrame->FindWidget("tablegroup_quitgame"));
x14_tablegroup_quitgame->SetMenuAdvanceCallback(
2017-02-12 03:17:18 +00:00
std::bind(&CQuitGameScreen::DoAdvance, this, std::placeholders::_1));
2016-12-30 06:37:01 +00:00
x14_tablegroup_quitgame->SetMenuSelectionChangeCallback(
2017-02-12 03:17:18 +00:00
std::bind(&CQuitGameScreen::DoSelectionChange, this, std::placeholders::_1, std::placeholders::_2));
2016-12-30 06:37:01 +00:00
2017-05-31 21:26:50 +00:00
static_cast<CGuiTextPane*>(x10_loadedFrame->FindWidget("textpane_title"))->TextSupport().
2016-12-30 06:37:01 +00:00
SetText(g_MainStringTable->GetString(Titles[int(x0_type)]));
2017-05-31 21:26:50 +00:00
static_cast<CGuiTextPane*>(x10_loadedFrame->FindWidget("textpane_yes"))->TextSupport().
2016-12-30 06:37:01 +00:00
SetText(g_MainStringTable->GetString(22));
2017-05-31 21:26:50 +00:00
static_cast<CGuiTextPane*>(x10_loadedFrame->FindWidget("textpane_no"))->TextSupport().
2016-12-30 06:37:01 +00:00
SetText(g_MainStringTable->GetString(23));
x14_tablegroup_quitgame->SetUserSelection(DefaultSelections[int(x0_type)]);
SetColors();
}
2017-02-12 03:17:18 +00:00
void CQuitGameScreen::DoSelectionChange(CGuiTableGroup* caller, int userSel)
2016-12-30 06:37:01 +00:00
{
SetColors();
CSfxManager::SfxStart(1424, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
2017-02-12 03:17:18 +00:00
void CQuitGameScreen::DoAdvance(CGuiTableGroup* caller)
2016-12-30 06:37:01 +00:00
{
if (caller->GetUserSelection() == 0)
{
/* Yes */
CSfxManager::SfxStart(1432, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
x18_action = EQuitAction::Yes;
}
else
{
/* No */
CSfxManager::SfxStart(1431, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
x18_action = EQuitAction::No;
}
}
2017-02-12 03:17:18 +00:00
EQuitAction CQuitGameScreen::Update(float dt)
2016-12-30 06:37:01 +00:00
{
if (!x10_loadedFrame && x4_frame.IsLoaded())
FinishedLoading();
return x18_action;
}
2017-02-12 03:17:18 +00:00
void CQuitGameScreen::Draw()
2016-12-30 06:37:01 +00:00
{
if (x0_type == EQuitType::QuitGame)
m_blackScreen->draw(zeus::CColor::skBlack);
if (x10_loadedFrame)
x10_loadedFrame->Draw(CGuiWidgetDrawParms{1.f,
zeus::CVector3f{0.f, 0.f, VerticalOffsets[int(x0_type)]}});
}
2017-02-12 03:17:18 +00:00
void CQuitGameScreen::ProcessUserInput(const CFinalInput& input)
2016-12-30 06:37:01 +00:00
{
if (input.ControllerIdx() != 0)
return;
if (!x10_loadedFrame)
return;
x10_loadedFrame->ProcessUserInput(input);
if (input.PB() && x0_type != EQuitType::ContinueFromLastSave)
x18_action = EQuitAction::No;
}
2017-02-12 03:17:18 +00:00
CQuitGameScreen::CQuitGameScreen(EQuitType tp)
2016-12-30 06:37:01 +00:00
: x0_type(tp)
{
x4_frame = g_SimplePool->GetObj("FRME_QuitScreen");
if (tp == EQuitType::QuitGame)
2017-06-01 05:34:24 +00:00
m_blackScreen.emplace(EFilterType::Blend);
2016-12-30 06:37:01 +00:00
}
}
}