2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 09:07:43 +00:00

CFrontEndUI work

This commit is contained in:
Jack Andersen
2016-12-12 19:22:30 -10:00
parent 67e55749e0
commit 2d961af921
9 changed files with 333 additions and 36 deletions

View File

@@ -6,17 +6,57 @@
#include "GameGlobalObjects.hpp"
#include "MP1.hpp"
#include "CSlideShow.hpp"
#include "Audio/CSfxManager.hpp"
#include "Graphics/CMoviePlayer.hpp"
#include "GuiSys/CSaveUI.hpp"
namespace urde
{
namespace MP1
{
/* 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},
};
SObjectTag g_DefaultWorldTag = {FOURCC('MLVL'), 0x158efe17};
CFrontEndUI::CFrontEndUI(CArchitectureQueue& queue)
: CIOWin("FrontEndUI")
{
x18_rndA = std::min(rand() * 3 / RAND_MAX, 2);
x1c_rndB = std::min(rand() * 3 / RAND_MAX, 2);
x20_depsGroup = g_SimplePool->GetObj("FrontEnd_DGRP");
x38_pressStart = g_SimplePool->GetObj("TXTR_PressStart");
x44_frontendAudioGrp = g_SimplePool->GetObj("FrontEnd_AGSC");
@@ -79,13 +119,44 @@ std::string CFrontEndUI::GetNextAttractMovieFileName()
}
void CFrontEndUI::SetCurrentMovie(EMenuMovie movie)
{}
{
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;
}
void CFrontEndUI::StopAttractMovie()
{}
{
if (!xc4_attractMovie)
return;
xc4_attractMovie.reset();
xcc_curMoviePtr = nullptr;
}
void CFrontEndUI::StartAttractMovie(int idx)
{}
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();
}
void CFrontEndUI::UpdateMenuHighlights(CGuiTableGroup* grp)
{}
@@ -99,7 +170,60 @@ bool CFrontEndUI::CanBuild(const SObjectTag& tag)
}
void CFrontEndUI::StartStateTransition(EScreen screen)
{}
{
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;
}
void CFrontEndUI::HandleDebugMenuReturnValue(CGameDebug::EReturnValue val, CArchitectureQueue& queue)
{}
@@ -110,15 +234,75 @@ void CFrontEndUI::Draw() const
}
void CFrontEndUI::UpdateMovies(float dt)
{}
{
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);
}
bool CFrontEndUI::PumpMovieLoad()
{
if (xd1_moviesLoaded)
return true;
for (int i=0 ; i<9 ; ++i)
{
if (!x70_menuMovies[i])
{
x70_menuMovies[i] = std::make_unique<CMoviePlayer>(FEMovies[i].path, 0.05f, FEMovies[i].loop, false);
x70_menuMovies[i]->SetPlayMode(CMoviePlayer::EPlayMode::Stopped);
return false;
}
}
xd1_moviesLoaded = true;
return true;
}
void CFrontEndUI::ProcessUserInput(const CFinalInput& input, CArchitectureQueue& queue)
{
}
void CFrontEndUI::TransitionToFive()
{
if (x14_screen >= EScreen::Five)
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_screen = EScreen::Five;
StartStateTransition(EScreen::Five);
}
CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
{
printf("UPDATE\n");
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;
}
}
return EMessageReturn::Exit;
}
@@ -139,7 +323,7 @@ CIOWin::EMessageReturn CFrontEndUI::OnMessage(const CArchitectureMessage& msg, C
}
case EArchMsgType::QuitGameplay:
{
x14_phase = Phase::Six;
x14_screen = EScreen::Six;
break;
}
default: break;