NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_scene.cpp
1#include <dol/bases/d_scene.hpp>
2#include <dol/bases/d_audio.hpp>
3#include <dol/bases/d_actor.hpp>
4#include <dol/bases/d_effectmanager.hpp>
5#include <dol/bases/d_fader.hpp>
6#include <dol/bases/d_game_com.hpp>
7#include <dol/bases/d_reset.hpp>
8#include <dol/bases/d_s_restart_crsin.hpp>
9#include <dol/bases/d_s_stage.hpp>
10#include <dol/bases/d_WarningManager.hpp>
11#include <dol/mLib/m_fader.hpp>
12
14ProfileName dScene_c::m_nextScene = fProfile::INVALID;
15ProfileName dScene_c::m_nowScene = fProfile::INVALID;
16ProfileName dScene_c::m_oldScene = fProfile::INVALID;
18
21bool dScene_c::m_isAutoFadeIn = true;
22
23dScene_c::dScene_c() {
26
27 mpPhase = nullptr;
28 EffectManager_c::m_firstCalc = false;
29 dGameCom::clearGameStop();
30
31 dActor_c::mExecStopReq = 0;
32 dActor_c::mDrawStopReq = 0;
33 dActor_c::mExecStop = 0;
34 dActor_c::mDrawStop = 0;
35}
36
37dScene_c::~dScene_c() {
38 if (dWarningManager_c::m_WarningForbid > 0) {
39 dWarningManager_c::m_WarningForbid--;
40 }
41 dAudio::destroySceneSnd();
42}
43
46 return NOT_READY;
47 }
48
49 m_isAutoFadeIn = true;
50 return SUCCEEDED;
51}
52
54 if (status == SUCCESS) {
55 dReset::Manage_c::GetInstance()->SetSoftResetFinish();
56 dAudio::prepareSceneSnd();
57 fBase_c::createChild(fProfile::LASTACTOR, this, 0, fBase_c::OTHER);
58 }
59 dBase_c::postCreate(status);
60}
61
64 return NOT_READY;
65 }
66 return SUCCEEDED;
67}
68
70 if (status == SUCCESS) {
71 m_otherSceneFlg = false;
72 dReset::Manage_c::GetInstance()->PostDeleteScene();
73 }
74 dBase_c::postDelete(status);
75}
76
79 return NOT_READY;
80 }
81
82 if (mpPhase != nullptr && mpPhase->callMethod(this) != sPhase_c::DONE) {
83 // Phase not finished yet
84 return NOT_READY;
85 }
86
87 if (m_nextScene != fProfile::INVALID) {
88 // Prepare to go to next state
90 dFader_c::startFadeOut(m_fadeOutFrame); // Initiate fade out if not started yet
92 deleteRequest(); // Delete this scene if the fade has completed
93 }
94 return NOT_READY;
95 }
96
99 // We may run the execute and draw steps of this base and its children from now on
102 }
103 return NOT_READY;
104 }
105
107 // Begin fade in if needed, also initialize sound objects
108 dFader_c::startFadeIn(m_fadeInFrame);
109 dAudio::requestStartScene(m_nowScene);
110 }
111
112 return SUCCEEDED;
113}
114
116 if (status != NOT_READY) {
117 dReset::Manage_c::GetInstance()->SetSoftResetScene();
118 }
119 dBase_c::postExecute(status);
120}
121
123 if (dBase_c::preDraw() == NOT_READY) {
124 return NOT_READY;
125 }
126 return SUCCEEDED;
127}
128
130 dBase_c::postDraw(status);
131}
132
134 m_nextScene = fProfile::BOOT;
135 m_nowScene = fProfile::BOOT;
136 m_oldScene = fProfile::BOOT;
137 m_otherSceneFlg = false;
138 dAudio::setNextScene(fProfile::BOOT, 0);
139}
140
142 dScRestartCrsin_c::startTitle(0, true);
143}
144
146 if (m_otherSceneFlg || m_nextScene == fProfile::INVALID) {
147 return nullptr;
148 }
149
151 if (newScene != nullptr) {
154 m_nextScene = fProfile::INVALID;
155 m_otherSceneFlg = true;
156 return newScene;
157 }
158
159 return nullptr;
160}
161
162void dScene_c::setNextScene(ProfileName nextScene, unsigned long param, bool forceChange) {
163 if (m_nextScene != fProfile::INVALID) {
164 return;
165 }
166
168 bool isChangeDisallowed =
169 ((resetMng->mModeInit == dReset::Manage_c::SOFT_RESET) ||
170 (resetMng->mModeProc == dReset::Manage_c::SOFT_RESET)) ||
173
174 if (!isChangeDisallowed || forceChange) {
175 if (m_nowScene == fProfile::STAGE && nextScene != fProfile::STAGE) {
177 }
178 dAudio::setNextScene(nextScene, param);
179 m_nextScene = nextScene;
180 mPara = param;
181 }
182}
183
184void dScene_c::setFadeInFrame(unsigned short length) {
185 m_fadeInFrame = length;
186}
187
188void dScene_c::setFadeOutFrame(unsigned short length) {
189 m_fadeOutFrame = length;
190}
191
192void dScene_c::setFadeInOutFrame(unsigned short length) {
193 m_fadeInFrame = length;
194 m_fadeOutFrame = length;
195}
virtual int preDelete()
See fBase_c::preDelete.
Definition d_base.cpp:45
virtual void postExecute(fBase_c::MAIN_STATE_e status)
See fBase_c::postExecute.
Definition d_base.cpp:58
virtual void postDraw(fBase_c::MAIN_STATE_e status)
See fBase_c::postDraw.
Definition d_base.cpp:67
virtual void postCreate(fBase_c::MAIN_STATE_e status)
See fBase_c::postCreate.
Definition d_base.cpp:41
virtual int preDraw()
Code to be executed before draw.
Definition d_base.cpp:62
static dBase_c * createRoot(ProfileName profName, unsigned long param, u8 groupType)
See fBase_c::createRoot.
Definition d_base.cpp:91
virtual void postDelete(fBase_c::MAIN_STATE_e status)
See fBase_c::postDelete.
Definition d_base.cpp:49
virtual int preExecute()
Code to be executed before execute.
Definition d_base.cpp:53
virtual int preCreate()
See fBase_c::preCreate.
Definition d_base.cpp:37
System reset management class.
Definition d_reset.hpp:10
static dReset::Manage_c * GetInstance()
Gets a pointer to the instance of this class.
int mModeProc
The game's current running state. See Mode_e.
Definition d_reset.hpp:41
@ SAFETY_WAIT
The game is about to execute the hard reset procedure indicated in mExecMode.
Definition d_reset.hpp:20
@ SOFT_RESET
The game is being soft reset (from the Home Menu).
Definition d_reset.hpp:16
int mModeInit
The running state the game's about to switch to. See Mode_e.
Definition d_reset.hpp:45
static bool m_isCourseOut
Whether the game is transitioning from a stage scene to a non-stage scene.
Definition d_s_stage.hpp:6
virtual int preExecute()
Code to be executed before execute.
Definition d_scene.cpp:77
static void setFadeInFrame(unsigned short length)
Sets the duration of the next fade-in transition to length.
Definition d_scene.cpp:184
static void setStartScene()
Sets up the scene to be shown when the game boots up.
Definition d_scene.cpp:133
virtual void postExecute(fBase_c::MAIN_STATE_e status)
See dBase_c::postExecute.
Definition d_scene.cpp:115
virtual void postDelete(fBase_c::MAIN_STATE_e status)
See dBase_c::postDelete.
Definition d_scene.cpp:69
static dScene_c * createNextScene()
Creates and returns a root base for the next scene.
Definition d_scene.cpp:145
virtual int preDraw()
See dBase_c::preDraw.
Definition d_scene.cpp:122
static void setFadeOutFrame(unsigned short length)
Sets the duration of the next fade-out transition to length.
Definition d_scene.cpp:188
virtual void postDraw(fBase_c::MAIN_STATE_e status)
See dBase_c::postDraw.
Definition d_scene.cpp:129
static bool m_isAutoFadeIn
If a fade-in should automatically be performed on scene load.
Definition d_scene.hpp:62
virtual void postCreate(fBase_c::MAIN_STATE_e status)
Code to be executed after create.
Definition d_scene.cpp:53
sPhase_c * mpPhase
The phase to be completed before preExecute succeeds.
Definition d_scene.hpp:52
static ProfileName m_nextScene
The profile name of the next scene.
Definition d_scene.hpp:55
virtual int preDelete()
See dBase_c::preDelete.
Definition d_scene.cpp:62
static u16 m_fadeInFrame
The duration of the next fade-in.
Definition d_scene.hpp:60
static bool m_otherSceneFlg
Whether the next scene has already been created.
Definition d_scene.hpp:58
static void setResetScene()
Sets up the scene to be shown after a game reset.
Definition d_scene.cpp:141
static u32 mPara
The parameters for the next scene.
Definition d_scene.hpp:54
static ProfileName m_nowScene
The profile name of the current scene.
Definition d_scene.hpp:56
virtual int preCreate()
See dBase_c::preCreate.
Definition d_scene.cpp:44
static u16 m_fadeOutFrame
The duration of the next fade-out.
Definition d_scene.hpp:61
static void setFadeInOutFrame(unsigned short length)
Sets the duration of the next fade-in and fade-out transitions to length.
Definition d_scene.cpp:192
static void setNextScene(ProfileName nextScene, unsigned long param, bool forceChange)
Attempts to prepare the transition to a new state.
Definition d_scene.cpp:162
static ProfileName m_oldScene
The profile name of the previous scene.
Definition d_scene.hpp:57
MAIN_STATE_e
The possible operation results.
Definition f_base.hpp:135
@ SUCCESS
The operation was completed successfully.
Definition f_base.hpp:138
static fBase_c * createChild(ProfileName profName, fBase_c *parent, unsigned long param, u8 groupType)
Creates a child base under the given parent.
Definition f_base.cpp:511
void deleteRequest()
Requests deletion of the base.
Definition f_base.cpp:289
@ SCENE
The base is a scene.
Definition f_base.hpp:130
@ OTHER
The base is a generic process.
Definition f_base.hpp:129
bool checkChildProcessCreateState() const
Checks if the base has at least one child in the CREATING state.
Definition f_base.cpp:479
void clearProcControlFlag(u8 flag)
Clears a flag in mProcControl.
Definition f_base.hpp:189
void setProcControlFlag(u8 flag)
Sets a flag in mProcControl.
Definition f_base.hpp:187
@ ROOT_DISABLE_EXECUTE
Execution is disabled, and this is a root base.
Definition f_base.hpp:151
@ ROOT_DISABLE_DRAW
Drawing is disabled, and this is a root base.
Definition f_base.hpp:153
@ NOT_READY
The step could not completed at this time.
Definition f_base.hpp:144
@ SUCCEEDED
The step was completed successfully.
Definition f_base.hpp:145
bool isProcControlFlag(u8 flag) const
Checks if a flag is set in mProcControl.
Definition f_base.hpp:185
@ HIDDEN
The screen is completely unblocked.
@ OPAQUE
The screen is completely blacked out.
static bool isStatus(mFaderBase_c::EStatus status)
Checks if the current fader's status matches status .
Definition m_fader.hpp:12
@ DONE
The phase is done.
Definition s_Phase.hpp:12
METHOD_RESULT_e callMethod(void *thisPtr)
Executes the phase until the end is reached or a method returns METHOD_RESULT_e::WAIT.
Definition s_Phase.cpp:9
u16 ProfileName
The name of a profile. Value is a fProfile::PROFILE_NAME_e.
Definition f_profile.hpp:32