forked from CraftyBoss/SuperMarioOdysseyOnline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
348 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include "al/factory/Factory.h" | ||
#include "server/hns/HideAndSeekConfigMenu.hpp" | ||
#include "server/gamemode/GameModeConfigMenu.hpp" | ||
|
||
typedef GameModeConfigMenu* (*createMenu)(const char* name); | ||
|
||
template <class T> | ||
GameModeConfigMenu* createGameModeConfigMenu(const char* name) { | ||
return new T(); | ||
}; | ||
|
||
__attribute((used)) constexpr al::NameToCreator<createMenu> menuTable[] = { | ||
{"HideAndSeek", &createGameModeConfigMenu<HideAndSeekConfigMenu>}, | ||
}; | ||
|
||
class GameModeConfigMenuFactory : public al::Factory<createMenu> { | ||
public: | ||
GameModeConfigMenuFactory(const char* fName) { | ||
this->factoryName = fName; | ||
this->actorTable = menuTable; | ||
this->factoryCount = sizeof(menuTable) / sizeof(menuTable[0]); | ||
}; | ||
|
||
constexpr static const char* getMenuName(int idx); | ||
constexpr static int getMenuCount(); | ||
}; | ||
|
||
constexpr const char* GameModeConfigMenuFactory::getMenuName(int idx) { | ||
if (idx >= 0 && idx < sizeof(menuTable) / sizeof(menuTable[0])) | ||
return menuTable[idx].creatorName; | ||
return nullptr; | ||
} | ||
|
||
constexpr int GameModeConfigMenuFactory::getMenuCount() { | ||
return sizeof(menuTable) / sizeof(menuTable[0]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,11 @@ | ||
#pragma once | ||
|
||
#include "server/gamemode/GameModeBase.hpp" | ||
#include <heap/seadHeap.h> | ||
|
||
// base struct containing info about the current gamemode | ||
struct GameModeInfoBase { | ||
GameMode mMode; | ||
}; | ||
|
||
template<class T> | ||
T *createModeInfo() { | ||
// using sequence heap to create mode info should allow for mode info to persist between scenes | ||
sead::Heap* seqHeap = sead::HeapMgr::instance()->findHeapByName("SequenceHeap", 0); | ||
|
||
if (seqHeap) { | ||
return new (seqHeap) T(); | ||
} else { | ||
// if failed to get sequence heap, fall back to current heap (will return null if current heap is also null) | ||
return new T(); | ||
} | ||
} | ||
#include "server/gamemode/GameModeManager.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#pragma once | ||
|
||
#include <heap/seadDisposer.h> | ||
#include <heap/seadHeap.h> | ||
#include <container/seadSafeArray.h> | ||
#include "server/gamemode/GameModeBase.hpp" | ||
#include "server/gamemode/GameModeInfoBase.hpp" | ||
|
||
class GameModeManager { | ||
SEAD_SINGLETON_DISPOSER(GameModeManager) | ||
GameModeManager(); | ||
~GameModeManager(); | ||
|
||
public: | ||
void setMode(GameMode mode); | ||
void initScene(const GameModeInitInfo& info); | ||
void begin(); | ||
void end(); | ||
void update(); | ||
|
||
GameMode getGameMode() const { return mCurMode; } | ||
template<class T> T* getMode() const { return static_cast<T*>(mCurModeBase); } | ||
template<class T> T* getInfo() const { return static_cast<T*>(mModeInfo); } | ||
void setInfo(GameModeInfoBase* info) { | ||
mModeInfo = info; | ||
} | ||
|
||
template<class T> | ||
T* createModeInfo(); | ||
|
||
sead::Heap* getHeap() { return mHeap; } | ||
void toggleActive(); | ||
void setActive(bool active) { mActive = active; } | ||
void setPaused(bool paused); | ||
bool isMode(GameMode mode) const { return mCurMode == mode; } | ||
bool isActive() const { return mActive; } | ||
bool isModeAndActive(GameMode mode) const { return isMode(mode) && isActive(); } | ||
bool isPaused() const { return mPaused; } | ||
private: | ||
sead::Heap* mHeap = nullptr; | ||
|
||
bool mActive = false; | ||
bool mPaused = false; | ||
bool mWasSceneTrans = false; | ||
bool mWasSetMode = false; | ||
GameMode mCurMode = GameMode::NONE; | ||
GameModeBase* mCurModeBase = nullptr; | ||
GameModeInfoBase *mModeInfo = nullptr; | ||
GameModeInitInfo *mLastInitInfo = nullptr; | ||
}; | ||
|
||
template<class T> | ||
T* GameModeManager::createModeInfo() { | ||
sead::ScopedCurrentHeapSetter heapSetter(mHeap); | ||
|
||
T* info = new T(); | ||
mModeInfo = info; | ||
return info; | ||
} |
2 changes: 1 addition & 1 deletion
2
include/server/HideAndSeekConfigMenu.hpp → include/server/hns/HideAndSeekConfigMenu.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.