resonance 1.0.1
Loading...
Searching...
No Matches
metscreen.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <map>
5#include <vector>
6
7#include "app/msgsink.h"
8#include "met/metrenderer.h"
9#include "os/hxstr.h"
10#include "rnd/asyncloader.h"
11#include "rnd/drawable.h"
12#include "rnd/object.h"
13#include "rnd/view.h"
14
15namespace Rnd {
16class Button;
17} // namespace Rnd
18
35
51
52class MetScreen;
53
66
73 explicit MetScreenEntry(MetScreen *pScreen, int nCategory = kDefaultCategory)
74 : mScreen(pScreen), mCategory(nCategory) {
75 }
76
78 static constexpr int kDefaultCategory = 0;
80 static constexpr int kUnsetCategory = 3;
81
84};
85
109
212class MetScreen : public MsgSink {
213public:
246 int nPriority,
247 const HxStr &name,
248 const HxStr &directory,
249 const HxStr &file);
250
267 virtual ~MetScreen();
268
281 static std::map<HxStr, MetContainerLoad *> &ContainerLoaderMap();
282
296 static std::map<HxStr, MetScreenEntry> &ScreenRegistry();
297
306 static MetScreen *FindScreenByName(const HxStr &name);
307
321 static MetScreen *FindEndScreen(MetRenderer *pRenderer, const HxStr &name);
322
335 static void CreateMainMenuScreens(MetRenderer *pRenderer);
336
348 static void DestroyAllScreens();
349
361 static void CreateStartupScreens(MetRenderer *pRenderer);
362
375 static void CreateFrontEndScreens(MetRenderer *pRenderer);
376
387
398
409
421 static void PollContainerLoads();
422
441 void DeliverCommand(const MetScreenCommand *pCommand);
442
456 void UpdateAnimationFrame(float flTime);
457
487 void UpdateFrame(float flTime);
488
500 virtual void PushNamedScreen(const HxStr &name);
501
510 virtual void EnterAndShow();
511
522 virtual void ActivateNamedPanel(const HxStr &name);
523
535 virtual void OnPanelActivated();
536
547 virtual void ExitScreenByName(const HxStr &name);
548
557 virtual void BeginExit();
558
572 virtual void OnUnusedHook();
573
587 virtual void OnKeyboardDismissed();
588
601 virtual void OnDrawPass();
602
615 virtual void OnDestroying();
616
627 virtual int PollContainerLoad();
628
652 virtual void OnMsgScreenDismissed(const HxStr &name, int nChoice);
653
669 virtual void OnMsgScreenShown(const HxStr &name);
670
687 virtual void SetShowing(int nShowing);
688
702 virtual void BeginContainerLoad(const HxStr &directory, const HxStr &file);
703
719 virtual void HandleCommand(const MetScreenCommand *pCommand);
720
736 virtual void PlaySlideSound(int nSelector);
737
749 virtual void PlayLeaveSound(int nSelector);
750
762 virtual void PlayHighSound(int nSelector);
763
776 virtual void PlayCycleLeftSound(int nSelector);
777
790 virtual void PlayCycleRightSound(int nSelector);
791
804 virtual void PlayErrorSound(int nSelector);
805
822 virtual void UpdateIdle(float flTime);
823
839 virtual void UpdateIdleAnimation(float flTime);
840
855 virtual void
856 StartRepeatingSound(float flStartTime, float flInterval, Rnd::Button *pButton, int nCycles);
857
872 virtual void UpdateRepeatingSound(float flTime);
873
885 virtual void OnRepeatingSoundFinished(Rnd::Button *pButton);
886
896 virtual void StartEnterAnimation(float flTime);
897
908 virtual void UpdateEnterAnimation(float flTime);
909
920 virtual void OnEnterFinished();
921
932 virtual void StartExitAnimation(float flTime);
933
944 virtual void UpdateExitAnimation(float flTime);
945
957 virtual void OnExitFinished();
958
968 virtual void Draw();
969
980 virtual void ResolveContainerViews();
981
982protected:
992 virtual void DispatchPriv(Message *pMsg);
993
994protected:
1006
1007protected:
1008 // End frame of the enter animation, read from mEnterAnim by the helper at 0x0038bd60. Not
1009 // written by the constructor. MetRemixTypeScreen's slot 5 reads it, which is why it is
1010 // protected.
1011 float mAnimEndFrame; // +0x04
1012
1013protected:
1014 // Time the enter animation started, or zero while no enter animation runs.
1015 // MetCreditsScreen::EnterAndShow() at 0x00214e70 clears it, which is why it is protected.
1016 float mEnterStartTime; // +0x08
1017
1018private:
1019 // Time the exit animation started, or zero while no exit animation runs.
1020 float mExitStartTime; // +0x0c
1021
1022protected:
1023 // The renderer this screen registers on. Protected because MetLoadFreqBaseScreen reads
1024 // MetRenderer::mAnimationFrame through it in slots 5, 19, and 39.
1026
1027public:
1036
1037protected:
1038 // How the screen is departing, for the exit hook to act on (0 for a back command and 2 for a
1039 // chosen button). Protected because MetLoadFreqBaseScreen writes 2 in its slot 30 and 0 in its
1040 // slot 19, and reads it in its slot 36 to choose between the gizmo panels and the three button
1041 // actions.
1042 int mExitChoice; // +0x18, starts at 2
1043
1044protected:
1045 // Set once the enter animation finishes and cleared when the exit animation starts.
1046 // DeliverCommand() ignores every command while it is clear. MetCreditsScreen::EnterAndShow()
1047 // at 0x00214e70 writes 1, and the member is protected for that write.
1048 int mAcceptsCommands; // +0x1c
1049
1050private:
1051 HxStr mScreenName; // +0x20
1052 HxStr mContainerFile; // +0x28, mContainerName with `.rnd` appended
1053
1054protected:
1055 // The view named `<screen>_EE.anim`. MetRemixTypeScreen's slot 5 swaps its animation, which
1056 // is why it is protected.
1058
1059private:
1060 Rnd::View *mBackAnim; // +0x34, the view `<screen>_BF.anim`
1061
1062protected:
1063 // Help text keys, one per button, for the screens to pass to MetHelpScreen::SetText().
1064 // Protected because MetMemCardLoadScreen, MetMemCardTypeScreen, MetRemixTypeScreen, and
1065 // MetRemixDelScreen each append one in their constructors.
1066 std::vector<HxStr> mHelpKeys; // +0x38
1067
1068private:
1069 // Neither read nor written outside construction and destruction.
1070 std::list<Rnd::Drawable *> mUnusedDrawables; // +0x44
1071
1072protected:
1073 // Set while the container views still need resolving, and cleared by slot 38. Read by
1074 // MetJukeboxBaseScreen::SetShowing(), which is why it is protected.
1075 int mViewsUnresolved; // +0x48, starts at 1
1076
1077public:
1087
1095
1096private:
1097 // Runs slot 26 on every frame rather than only while neither animation runs. The constructor
1098 // clears it and no writer of a set value is identified.
1099 int mIdleWhileAnimating; // +0x54
1100
1101public:
1112
1113protected:
1114 // Enables the navigation sounds in DeliverCommand(). Protected because the MetSaveRemixScreen
1115 // constructor clears it.
1116 int mPlaysCommandSounds; // +0x5c, starts at 1
1117 // Gates the drawable-list walk in SetShowing(). Cleared by the MetRemixLoadScreen and
1118 // MetRemixDelScreen constructors, which is why it is protected.
1119 int mShowsLoadedDrawables; // +0x60, starts at 1
1120
1121private:
1122 // The time of the next alternation step, or zero when none is running.
1123 float mRepeatNextTime; // +0x64
1124 // The button whose state slots 28 and 29 alternate through Rnd::Button::SetState().
1125 Rnd::Button *mRepeatButton; // +0x68
1126 int mRepeatStep; // +0x6c, the steps run, not written by the constructor
1127 int mRepeatSteps; // +0x70, the steps to run, not written by the constructor
1128 float mRepeatInterval; // +0x74, the step interval, not written by the constructor
1129 int mExitDone; // +0x78, set once the exit animation has passed its end
1130 int mEnterDone; // +0x7c, set once the enter animation has passed its end
1131 HxStr mContainerName; // +0x80, the container name without its suffix
1132 int mLoadPriority; // +0x88
1133};
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:41
Front-end renderer that owns the screen stack and drives every MetScreen.
Definition metrenderer.h:68
Base of every front-end screen.
Definition metscreen.h:212
void ResolveAnimationViews()
Resolves the two animation views from the screen name and records the enter animation's end frame.
int mAcceptsCommands
Definition metscreen.h:1048
virtual void HandleCommand(const MetScreenCommand *pCommand)
Act on a navigation command.
Rnd::View * mEnterAnim
Definition metscreen.h:1057
virtual void UpdateRepeatingSound(float flTime)
Advance the alternation that StartRepeatingSound() started.
static std::map< HxStr, MetContainerLoad * > & ContainerLoaderMap()
Shared table of container loads, interned under the container name.
virtual void UpdateExitAnimation(float flTime)
Drive the exit animation and hide the screen once it passes its end.
MetScreen(MetRenderer *pRenderer, int nPriority, const HxStr &name, const HxStr &directory, const HxStr &file)
Construct a screen and start its container load.
virtual void ResolveContainerViews()
Resolve the three views the container produced and hide the screen.
float mAnimEndFrame
Definition metscreen.h:1011
virtual void PlayErrorSound(int nSelector)
Play the sound that accompanies a rejected input.
virtual void OnDestroying()
Release what the screen acquired, ahead of the rest of destruction.
virtual void SetShowing(int nShowing)
Show or hide the view and every drawable the container loaded.
static void CreateMainMenuScreens(MetRenderer *pRenderer)
Create the main-menu screens.
Rnd::View * mView
The container's root view.
Definition metscreen.h:1035
static std::map< HxStr, MetScreenEntry > & ScreenRegistry()
Shared table of live screens, interned under the screen registry key.
int mEnterPending
Set when the screen was pushed before its container load finished.
Definition metscreen.h:1086
virtual void ExitScreenByName(const HxStr &name)
Start one named screen's exit animation.
virtual void StartRepeatingSound(float flStartTime, float flInterval, Rnd::Button *pButton, int nCycles)
Start alternating one button between its states 2 and 1.
static void CreateFrontEndScreens(MetRenderer *pRenderer)
Create every remaining front-end screen, once.
static void DestroyNonDefaultScreens()
Delete and unregister every screen outside category 0, then rewind the rndMetLocAndNet zone.
virtual void OnRepeatingSoundFinished(Rnd::Button *pButton)
Act on the alternation that StartRepeatingSound() started having finished.
static void DestroyCategory1Screens()
Delete and unregister every screen in category 1.
virtual void UpdateIdle(float flTime)
Advance whatever the screen updates once per frame while it is idle.
virtual void PlayCycleRightSound(int nSelector)
Play the sound that accompanies cycling a value to the right.
virtual void OnEnterFinished()
Act on the enter animation having finished.
virtual void UpdateIdleAnimation(float flTime)
Advance whatever the screen animates while it is neither entering nor exiting.
virtual void ActivateNamedPanel(const HxStr &name)
Make one named screen the renderer's active panel.
int mViewsUnresolved
Definition metscreen.h:1075
virtual void OnMsgScreenDismissed(const HxStr &name, int nChoice)
Act on the choice the user made in a message dialogue.
virtual void OnKeyboardDismissed()
Take control back after the keyboard screen has finished.
virtual void StartExitAnimation(float flTime)
Record the time the exit animation starts at.
virtual void PlayLeaveSound(int nSelector)
Play the sound that accompanies departing a screen.
virtual void BeginExit()
Start this screen's exit animation at the renderer's current time.
static void CreateStartupScreens(MetRenderer *pRenderer)
Create the four screens the front end needs before its containers have loaded.
static void DestroyAllScreens()
Delete every registered screen and release every container loader.
virtual void OnDrawPass()
Contribute to the renderer's draw pass.
static void DestroyCategory2Screens()
Delete and unregister every screen in category 2.
virtual void OnExitFinished()
Act on the exit animation having finished.
void DeliverCommand(const MetScreenCommand *pCommand)
Play the sound one navigation command calls for and then act on the command.
virtual void UpdateEnterAnimation(float flTime)
Drive the enter animation and finish it once it passes its end.
MetRenderer * mRenderer
Definition metscreen.h:1025
virtual void StartEnterAnimation(float flTime)
Rewind the enter animation and record the time it starts at.
std::vector< HxStr > mHelpKeys
Definition metscreen.h:1066
virtual void OnUnusedHook()
Do nothing.
virtual ~MetScreen()
Unregister from the renderer and release the container.
virtual int PollContainerLoad()
Advance this screen's container load and resolve its views once the load finishes.
static MetScreen * FindScreenByName(const HxStr &name)
Resolve one screen by its registry key.
virtual void PlayCycleLeftSound(int nSelector)
Play the sound that accompanies cycling a value to the left.
float mEnterStartTime
Definition metscreen.h:1016
virtual void DispatchPriv(Message *pMsg)
Act on a message.
virtual void PlayHighSound(int nSelector)
Play the sound that accompanies the emphasised selection.
int mPlaysCommandSounds
Definition metscreen.h:1116
static void PollContainerLoads()
Poll every container load that has not finished, and hide the drawables of each that does.
virtual void Draw()
Draw the view.
int mShowsLoadedDrawables
Definition metscreen.h:1119
virtual void OnPanelActivated()
Act on this screen having become the renderer's active panel.
float mRepeatScale
Scale on the input auto-repeat interval.
Definition metscreen.h:1111
static MetScreen * FindEndScreen(MetRenderer *pRenderer, const HxStr &name)
Resolve one end-of-game screen by its registry key, failing fatally when it is absent.
virtual void PushNamedScreen(const HxStr &name)
Bring one named screen onto the renderer's screen stack.
void UpdateFrame(float flTime)
Advance one screen by one frame.
int mActivatePending
Set when the screen was activated as a panel before its container load finished.
Definition metscreen.h:1094
virtual void BeginContainerLoad(const HxStr &directory, const HxStr &file)
Intern a container load under this screen's container name and enqueue it.
virtual void OnMsgScreenShown(const HxStr &name)
Act on a message dialogue becoming visible.
virtual void EnterAndShow()
Show this screen and start its enter animation.
virtual void PlaySlideSound(int nSelector)
Play the sound that accompanies sliding between screens.
int mExitChoice
Definition metscreen.h:1042
void UpdateAnimationFrame(float flTime)
Drive the frame of whichever animation is running and run the idle hook when none is.
Receiver of engine messages.
Definition msgsink.h:37
Request to load one renderer file in the background.
Definition asyncloader.h:29
Selectable widget, as one mesh and one text run plus a palette for each.
Definition button.h:39
Root of a loadable scene.
Definition view.h:47
MetScreenCommandCode
What a navigation command requests.
Definition metscreen.h:100
@ kMetScreenCommandRight
Definition metscreen.h:105
@ kMetScreenCommandBack
Definition metscreen.h:107
@ kMetScreenCommandNone
Definition metscreen.h:101
@ kMetScreenCommandLeft
Definition metscreen.h:104
@ kMetScreenCommandSelect
Definition metscreen.h:106
@ kMetScreenCommandPrevious
Definition metscreen.h:102
@ kMetScreenCommandNext
Definition metscreen.h:103
The rendering engine.
Definition animhelper.h:3
One shared container load, interned under the container name.
Definition metscreen.h:30
RndAsyncLoader * mLoader
Definition metscreen.h:31
int mEnqueuePending
Definition metscreen.h:33
int mFinished
Definition metscreen.h:32
One navigation command delivered to a screen.
Definition metscreen.h:46
int mPadIndex
Definition metscreen.h:48
int mCommand
Definition metscreen.h:47
int mButton
Definition metscreen.h:49
static constexpr int kUnsetCategory
The category a missing entry is created with.
Definition metscreen.h:80
MetScreen * mScreen
Definition metscreen.h:82
int mCategory
Definition metscreen.h:83
MetScreenEntry(MetScreen *pScreen, int nCategory=kDefaultCategory)
Record a screen in a category.
Definition metscreen.h:73
MetScreenEntry()
Record no screen, in category 3.
Definition metscreen.h:64
static constexpr int kDefaultCategory
The category every recovered registration stores.
Definition metscreen.h:78