NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_next.hpp
1#pragma once
2
3#include <game/bases/d_fader.hpp>
4#include <game/bases/d_cd_data.hpp>
5#include <lib/egg/core/eggHeap.h>
6
7/// @brief Manager for scene changes triggered by entrances.
8class dNext_c {
9public:
10 /// @brief The different types of scene changes.
11 /// @unofficial
13 NEXT_DIFFERENT_FILE, ///< The next entrance is in a different file.
14 NEXT_DIFFERENT_AREA, ///< The next entrance is in a different area of the same file.
15 NEXT_SAME_AREA ///< The next entrance is in the same area.
16 };
17
18 dNext_c(); ///< Constructs a new dNext_c.
19
20 void initialize(); ///< Resets the class to its initial state.
21 void execute(); ///< Checks for scene changes and executes them when necessary.
22
23 /// @brief Updates the saved entrance data for the next scene change if not already set.
24 /// @param fileIdx The file index of the entrance to set.
25 /// @param nextGoto The ID of the entrance to set.
26 /// @param faderType The type of fader to use for the scene change.
27 void setChangeSceneNextDat(u8 fileIdx, u8 nextGoto, dFader_c::fader_type_e faderType);
28
29 /// @brief Sets the entrance data for the next scene change.
30 /// @param fileIdx The file index of the entrance to set.
31 /// @param nextGoto The ID of the entrance to set.
32 void setOwnNextData(u8 fileIdx, u8 nextGoto);
33
34 /// @brief Returns whether the currently saved entrance is different from the given one.
35 /// @param fileIdx The file index of the entrance to compare to.
36 /// @param nextGoto The ID of the entrance to compare to.
37 /// @return Whether the currently saved entrance is different from the given one.
38 /// @unofficial
39 bool isNextDifferent(u8 fileIdx, u8 nextGoto);
40
41 /// @brief Search for a next entrance at the given coordinates in the given file.
42 /// @param fileIdx The file to search in.
43 /// @param x The x coordinate to search at.
44 /// @param y The y coordinate to search at.
45 /// @param foundNum Pointer to write the found next entrance's ID to.
46 /// @return Whether a next entrance was found at the given coordinates.
47 bool searchNextNum(u8 fileIdx, float x, float y, int *foundNum);
48
49 /// @brief Move to a new entrance in the same file.
50 /// @param destNextGoto The new entrance to go to.
51 /// @param faderType The type of fader to use for the scene change.
52 void simpleChangeScene(u8 destNextGoto, dFader_c::fader_type_e faderType);
53
54 /// @brief Move to a new entrance in any file.
55 /// @param destFile The file to go to.
56 /// @param destNextGoto The entrance in that file to go to.
57 /// @param faderType The type of fader to use for the scene change.
58 void simpleChangeScene(u8 destFile, u8 destNextGoto, dFader_c::fader_type_e faderType);
59
60 /// @brief Go to the next scene using the data in #mNextGotoData.
61 void changeScene();
62
63 static void createInstance(EGG::Heap *heap); ///< Creates a class instance on the given heap.
64 static void deleteInstance(); ///< Deletes the class instance.
65
66 sNextGotoData mNextGotoData; ///< The data for the entrance the player activated.
67 SceneChangeType_e mSceneChangeType; ///< The type of scene change to do when going to the next entrance.
68 bool mNextDataSet; ///< Whether the @ref mNextGotoData "entrance data" for the next scene change has been set.
69 bool mStartSceneChange; ///< Whether a scene change should be performed next time execute() is called.
70 bool mSceneChangeDone; ///< Whether the scene change has been performed.
71 u16 mMultiplayerDelay; ///< Number of frames to delay the scene change in multiplayer mode.
72 dFader_c::fader_type_e mFaderType; ///< The type of fader to use for the scene change.
73
74 static dNext_c *m_instance; ///< The singleton instance of this class.
75
76 // [Unofficial constants]
77 static const int smc_MULTIPLAYER_SCENE_CHANGE_DELAY = 180; ///< The number of frames to delay scene changes in multiplayer mode.
78};
bool isNextDifferent(u8 fileIdx, u8 nextGoto)
Returns whether the currently saved entrance is different from the given one.
Definition d_next.cpp:63
void changeScene()
Go to the next scene using the data in mNextGotoData.
Definition d_next.cpp:150
static dNext_c * m_instance
The singleton instance of this class.
Definition d_next.hpp:74
bool mStartSceneChange
Whether a scene change should be performed next time execute() is called.
Definition d_next.hpp:69
void simpleChangeScene(u8 destNextGoto, dFader_c::fader_type_e faderType)
Move to a new entrance in the same file.
Definition d_next.cpp:129
SceneChangeType_e
The different types of scene changes.
Definition d_next.hpp:12
@ NEXT_DIFFERENT_FILE
The next entrance is in a different file.
Definition d_next.hpp:13
@ NEXT_DIFFERENT_AREA
The next entrance is in a different area of the same file.
Definition d_next.hpp:14
@ NEXT_SAME_AREA
The next entrance is in the same area.
Definition d_next.hpp:15
void setOwnNextData(u8 fileIdx, u8 nextGoto)
Sets the entrance data for the next scene change.
Definition d_next.cpp:48
static void deleteInstance()
Deletes the class instance.
Definition d_next.cpp:23
SceneChangeType_e mSceneChangeType
The type of scene change to do when going to the next entrance.
Definition d_next.hpp:67
bool searchNextNum(u8 fileIdx, float x, float y, int *foundNum)
Search for a next entrance at the given coordinates in the given file.
Definition d_next.cpp:82
sNextGotoData mNextGotoData
The data for the entrance the player activated.
Definition d_next.hpp:66
void setChangeSceneNextDat(u8 fileIdx, u8 nextGoto, dFader_c::fader_type_e faderType)
Updates the saved entrance data for the next scene change if not already set.
Definition d_next.cpp:39
void execute()
Checks for scene changes and executes them when necessary.
Definition d_next.cpp:194
u16 mMultiplayerDelay
Number of frames to delay the scene change in multiplayer mode.
Definition d_next.hpp:71
bool mNextDataSet
Whether the entrance data for the next scene change has been set.
Definition d_next.hpp:68
bool mSceneChangeDone
Whether the scene change has been performed.
Definition d_next.hpp:70
dFader_c::fader_type_e mFaderType
The type of fader to use for the scene change.
Definition d_next.hpp:72
static const int smc_MULTIPLAYER_SCENE_CHANGE_DELAY
The number of frames to delay scene changes in multiplayer mode.
Definition d_next.hpp:77
void initialize()
Resets the class to its initial state.
Definition d_next.cpp:32
static void createInstance(EGG::Heap *heap)
Creates a class instance on the given heap.
Definition d_next.cpp:17
dNext_c()
Constructs a new dNext_c.
Definition d_next.cpp:13