NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
s_StateStateMgr.hpp
1#pragma once
2#include <game/sLib/s_StateMgr.hpp>
3
5public:
6 virtual void changeToSubState(const sStateIDIf_c &newState) = 0;
7 virtual void returnState() = 0;
8 virtual bool isSubState() const = 0;
9 virtual const sStateIDIf_c *getMainStateID() const = 0;
10};
11
12template <class T, template <class, class> class Manager, class Method1, class Method2>
13class sStateStateMgr_c : public sStateStateMgrIf_c {
14public:
15 sStateStateMgr_c(T &owner, const sStateIDIf_c &initialState) :
16 mainMgr(owner, initialState),
17 subMgr(owner, initialState),
18 currentMgr(&mainMgr) {}
19
20 virtual void initializeState() { currentMgr->initializeState(); }
21 virtual void executeState() { currentMgr->executeState(); }
22 virtual void finalizeState() {
23 if (isSubState()) {
24 returnState();
25 } else {
26 currentMgr->finalizeState();
27 }
28 }
29
30 virtual bool isSubState() const { return currentMgr == &subMgr; }
31
32 virtual void returnState() {
33 if (isSubState()) {
34 currentMgr->finalizeState();
35 currentMgr = &mainMgr;
36 }
37 }
38
39 virtual const sStateIDIf_c *getOldStateID() const { return currentMgr->getOldStateID(); }
40
41 virtual void refreshState() { currentMgr->refreshState(); }
42
43 virtual void changeToSubState(const sStateIDIf_c &newState) {
44 currentMgr = &subMgr;
45 currentMgr->changeState(newState);
46 }
47
48 virtual void changeState(const sStateIDIf_c &newState) { currentMgr->changeState(newState); }
49 virtual sStateIf_c *getState() const { return currentMgr->getState(); }
50 virtual const sStateIDIf_c *getNewStateID() const { return currentMgr->getNewStateID(); }
51 virtual const sStateIDIf_c *getStateID() const { return currentMgr->getStateID(); }
52 virtual const sStateIDIf_c *getMainStateID() const { return mainMgr.getStateID(); }
53
54 Manager<T, Method1> mainMgr;
55 Manager<T, Method2> subMgr;
56 sStateMgrIf_c *currentMgr;
57};
The interface for state IDs.
The interface for a state holder.
The interface for state managers.
Definition s_StateMgr.hpp:7
virtual void changeState(const sStateIDIf_c &newStateID)=0
Transitions to a new state ID.
virtual void initializeState()
Initializes the current state.
virtual void changeState(const sStateIDIf_c &newState)
Transitions to a new state ID.
virtual void executeState()
Executes the current state.
virtual void finalizeState()
Prepares the current state for termination.
virtual const sStateIDIf_c * getOldStateID() const
Gets the previous state ID.
virtual sStateIf_c * getState() const
Gets the state holder.
virtual const sStateIDIf_c * getNewStateID() const
Gets the next state ID.
virtual const sStateIDIf_c * getStateID() const
Gets the current state ID.
virtual void refreshState()
Marks the current state to be executed again.