-
-
Save Wolfolo/1824b5e2e80906f6bb439dde7dc7fb68 to your computer and use it in GitHub Desktop.
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
// [...] | |
Globals *_globals; | |
// [...] | |
class Globals { // <-- class type redefinition error | |
public: | |
/* Public accessors */ | |
bool IsGameMode(GameMode mode) | |
{ | |
return game_mode == mode; | |
} | |
void SetGameMode(GameMode mode) | |
{ | |
game_mode = mode; | |
} | |
void BackupGameMode() | |
{ | |
backup_game_mode = game_mode; | |
} | |
void RestoreGameMode() | |
{ | |
game_mode = backup_game_mode; | |
} | |
GameMode GetGameMode() | |
{ | |
return game_mode; | |
} | |
GameMode GetOldGameMode() | |
{ | |
return backup_game_mode; | |
} | |
private: | |
GameMode game_mode; ///< Current game mode | |
GameMode backup_game_mode; ///< Backup game mode, used for brief game changes. | |
}; |
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
// [...] | |
class Globals { | |
public: | |
static Globals *GetInstance() | |
{ | |
if (!instance) { | |
instance = new Globals(); | |
} | |
return instance; | |
} | |
/* Public accessors */ | |
virtual bool IsGameMode(GameMode mode); | |
virtual void SetGameMode(GameMode mode); | |
virtual void BackupGameMode(); | |
virtual void RestoreGameMode(); | |
virtual GameMode GetGameMode(); | |
virtual GameMode GetOldGameMode(); | |
private: | |
static Globals *instance; | |
Globals() {} | |
Globals(Globals const&); | |
Globals &operator=(const Globals&); | |
}; | |
extern Globals *_globals; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment