2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/MP1/CSlideShow.hpp"
|
|
|
|
|
2020-05-12 23:53:16 +00:00
|
|
|
#include <algorithm>
|
2016-09-16 20:18:03 +00:00
|
|
|
|
2021-05-24 05:06:51 +00:00
|
|
|
#include "Runtime/CArchitectureMessage.hpp"
|
|
|
|
#include "Runtime/CGameState.hpp"
|
|
|
|
#include "Runtime/CSimplePool.hpp"
|
2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2020-05-12 23:53:16 +00:00
|
|
|
namespace {
|
|
|
|
bool AreAllDepsLoaded(const std::vector<TLockedToken<CDependencyGroup>>& deps) {
|
|
|
|
return std::all_of(deps.cbegin(), deps.cend(), [](const auto& dep) { return dep.IsLoaded(); });
|
|
|
|
}
|
|
|
|
} // Anonymous namespace
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-21 07:22:41 +00:00
|
|
|
CSlideShow::CSlideShow() : CIOWin("SlideShow"), x130_(g_tweakSlideShow->GetX54()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
const SObjectTag* font = g_ResFactory->GetResourceIdByName(g_tweakSlideShow->GetFont());
|
|
|
|
if (font) {
|
|
|
|
CGuiTextProperties propsA(false, true, EJustification::Center, EVerticalJustification::Bottom);
|
|
|
|
xc4_textA = std::make_unique<CGuiTextSupport>(font->id, propsA, g_tweakSlideShow->GetFontColor(),
|
2019-02-24 07:15:54 +00:00
|
|
|
g_tweakSlideShow->GetOutlineColor(), zeus::skWhite, 640, 480,
|
2018-12-08 05:30:43 +00:00
|
|
|
g_SimplePool, CGuiWidget::EGuiModelDrawFlags::Alpha);
|
|
|
|
|
|
|
|
CGuiTextProperties propsB(false, true, EJustification::Right, EVerticalJustification::Bottom);
|
|
|
|
xc8_textB = std::make_unique<CGuiTextSupport>(font->id, propsB, g_tweakSlideShow->GetFontColor(),
|
2019-02-24 07:15:54 +00:00
|
|
|
g_tweakSlideShow->GetOutlineColor(), zeus::skWhite, 640, 480,
|
2018-12-08 05:30:43 +00:00
|
|
|
g_SimplePool, CGuiWidget::EGuiModelDrawFlags::Alpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
xf8_stickTextures.reserve(18);
|
|
|
|
x108_buttonTextures.reserve(8);
|
2022-02-19 13:04:45 +00:00
|
|
|
SObjectTag txtrTag(FOURCC('TXTR'), CAssetId());
|
2020-09-18 20:47:59 +00:00
|
|
|
for (const auto& lStickId : g_tweakPlayerRes->x24_lStick) {
|
2019-09-30 22:02:03 +00:00
|
|
|
txtrTag.id = lStickId;
|
2019-09-30 22:07:31 +00:00
|
|
|
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2020-09-18 20:47:59 +00:00
|
|
|
for (const auto& cStickId : g_tweakPlayerRes->x4c_cStick) {
|
2019-09-30 22:02:03 +00:00
|
|
|
txtrTag.id = cStickId;
|
2019-09-30 22:07:31 +00:00
|
|
|
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2020-09-18 20:47:59 +00:00
|
|
|
for (const auto& lTriggerId : g_tweakPlayerRes->x74_lTrigger) {
|
2019-09-30 22:02:03 +00:00
|
|
|
txtrTag.id = lTriggerId;
|
2019-09-30 22:07:31 +00:00
|
|
|
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2020-09-18 20:47:59 +00:00
|
|
|
for (const auto& rTriggerId : g_tweakPlayerRes->x80_rTrigger) {
|
2019-09-30 22:02:03 +00:00
|
|
|
txtrTag.id = rTriggerId;
|
2019-09-30 22:07:31 +00:00
|
|
|
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2020-09-18 20:47:59 +00:00
|
|
|
for (const auto& bButtonId : g_tweakPlayerRes->xa4_bButton) {
|
2019-09-30 22:02:03 +00:00
|
|
|
txtrTag.id = bButtonId;
|
2019-09-30 22:07:31 +00:00
|
|
|
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2020-09-18 20:47:59 +00:00
|
|
|
for (const auto& yButtonId : g_tweakPlayerRes->xbc_yButton) {
|
2019-09-30 22:02:03 +00:00
|
|
|
txtrTag.id = yButtonId;
|
2019-09-30 22:07:31 +00:00
|
|
|
xf8_stickTextures.emplace_back(g_SimplePool->GetObj(txtrTag));
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-09-25 01:58:20 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CSlideShow::LoadTXTRDep(std::string_view name) {
|
|
|
|
const SObjectTag* dgrpTag = g_ResFactory->GetResourceIdByName(name);
|
|
|
|
if (dgrpTag && dgrpTag->type == FOURCC('DGRP')) {
|
2019-09-30 22:07:31 +00:00
|
|
|
x18_galleryTXTRDeps.emplace_back(g_SimplePool->GetObj(*dgrpTag));
|
2016-09-25 01:58:20 +00:00
|
|
|
return true;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
return false;
|
2016-09-16 20:18:03 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CIOWin::EMessageReturn CSlideShow::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) {
|
|
|
|
switch (msg.GetType()) {
|
|
|
|
case EArchMsgType::TimerTick: {
|
|
|
|
if (x134_29_)
|
|
|
|
return EMessageReturn::RemoveIOWinAndExit;
|
|
|
|
|
|
|
|
// float dt = MakeMsg::GetParmTimerTick(msg).x4_parm;
|
|
|
|
|
|
|
|
switch (x14_phase) {
|
|
|
|
case Phase::Zero: {
|
|
|
|
// if (!g_resLoader->AreAllPaksLoaded())
|
|
|
|
//{
|
|
|
|
// g_resLoader->AsyncIdlePakLoading();
|
|
|
|
// return EMessageReturn::Exit;
|
|
|
|
//}
|
|
|
|
x14_phase = Phase::One;
|
2019-02-18 05:47:46 +00:00
|
|
|
[[fallthrough]];
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
case Phase::One: {
|
|
|
|
if (x18_galleryTXTRDeps.empty()) {
|
|
|
|
x18_galleryTXTRDeps.reserve(5);
|
|
|
|
for (int i = 1; true; ++i) {
|
2020-04-11 22:51:39 +00:00
|
|
|
std::string depResName = fmt::format(FMT_STRING("Gallery{:02d}_DGRP"), i);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!LoadTXTRDep(depResName))
|
|
|
|
break;
|
2016-09-25 01:58:20 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
LoadTXTRDep("GalleryAssets_DGRP");
|
|
|
|
}
|
|
|
|
if (!AreAllDepsLoaded(x18_galleryTXTRDeps))
|
|
|
|
return EMessageReturn::Exit;
|
2016-09-25 01:58:20 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x14_phase = Phase::Three;
|
2019-02-18 05:47:46 +00:00
|
|
|
[[fallthrough]];
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
case Phase::Two:
|
2019-02-18 05:47:46 +00:00
|
|
|
case Phase::Three:
|
2018-12-08 05:30:43 +00:00
|
|
|
case Phase::Four:
|
|
|
|
case Phase::Five:
|
2019-02-18 05:47:46 +00:00
|
|
|
break;
|
2018-12-08 05:30:43 +00:00
|
|
|
default:
|
|
|
|
break;
|
2016-09-25 01:58:20 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EArchMsgType::UserInput:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EMessageReturn::Exit;
|
2016-09-16 20:18:03 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 01:55:58 +00:00
|
|
|
void CSlideShow::SSlideData::Draw() {
|
2022-05-24 00:26:35 +00:00
|
|
|
// TODO
|
|
|
|
// if (!IsLoaded()) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// const zeus::CRectangle rect;
|
|
|
|
// m_texQuad->draw(x30_mulColor, 1.f, rect);
|
|
|
|
//
|
|
|
|
// const zeus::CVector2f centeredOffset((x28_canvasSize.x() - m_texQuad->GetTex()->GetWidth()) * 0.5f,
|
|
|
|
// (x28_canvasSize.y() - m_texQuad->GetTex()->GetHeight()) * 0.5f);
|
2016-09-16 23:43:33 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 01:55:58 +00:00
|
|
|
void CSlideShow::Draw() {
|
2019-07-21 08:42:52 +00:00
|
|
|
SCOPED_GRAPHICS_DEBUG_GROUP("CSlideShow::Draw", zeus::skGreen);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x14_phase == Phase::Five) {
|
|
|
|
x5c_slideA.Draw();
|
|
|
|
x90_slideB.Draw();
|
|
|
|
}
|
2016-09-16 20:18:03 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
u32 CSlideShow::SlideShowGalleryFlags() {
|
|
|
|
u32 ret = 0;
|
|
|
|
if (!g_GameState)
|
2016-12-16 23:05:29 +00:00
|
|
|
return ret;
|
2018-12-08 05:30:43 +00:00
|
|
|
if (g_GameState->SystemOptions().GetLogScanPercent() >= 50)
|
|
|
|
ret |= 1;
|
|
|
|
if (g_GameState->SystemOptions().GetLogScanPercent() == 100)
|
|
|
|
ret |= 2;
|
|
|
|
if (g_GameState->SystemOptions().GetPlayerBeatHardMode())
|
|
|
|
ret |= 4;
|
|
|
|
if (g_GameState->SystemOptions().GetAllItemsCollected())
|
|
|
|
ret |= 8;
|
|
|
|
return ret;
|
2016-12-16 23:05:29 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|