some minor cleanups and new asserts

This commit is contained in:
Gered 2013-04-02 12:14:09 -04:00
parent 6de773f270
commit c18ed56011
9 changed files with 52 additions and 23 deletions

View file

@ -11,13 +11,14 @@ GameState::GameState(GameApp *gameApp, StateManager *stateManager)
: EventListenerEx(gameApp->GetEventManager())
{
STACK_TRACE;
ASSERT(gameApp != NULL);
ASSERT(stateManager != NULL);
m_gameApp = gameApp;
m_stateManager = stateManager;
m_effectManager = new EffectManager();
ASSERT(m_effectManager != NULL);
m_processManager = new ProcessManager(this);
ASSERT(m_processManager != NULL);
m_isFinished = FALSE;
m_returnValue = 0;

View file

@ -43,18 +43,18 @@ public:
template<class T> T* As();
template<class T> const T* As() const;
GameApp* GetGameApp() const { return m_gameApp; }
ProcessManager* GetProcessManager() const { return m_processManager; }
EffectManager* GetEffectManager() const { return m_effectManager; }
GameApp* GetGameApp() const { return m_gameApp; }
ProcessManager* GetProcessManager() const { return m_processManager; }
EffectManager* GetEffectManager() const { return m_effectManager; }
BOOL IsTransitioning() const;
BOOL IsTopState() const;
BOOL IsFinished() const { return m_isFinished; }
BOOL HasReturnValue() const { return m_hasReturnValue; }
uint32_t GetReturnValue() const { return m_returnValue; }
BOOL IsFinished() const { return m_isFinished; }
BOOL HasReturnValue() const { return m_hasReturnValue; }
uint32_t GetReturnValue() const { return m_returnValue; }
protected:
StateManager* GetStateManager() const { return m_stateManager; }
StateManager* GetStateManager() const { return m_stateManager; }
void SetFinished();
void SetFinished(uint32_t returnValue);

View file

@ -4,7 +4,7 @@
#include "gwengamestateuicontroller.h"
GwenGameState::GwenGameState(GameApp *gameApp, StateManager *stateManager)
: GameState(gameApp, stateManager)
: GameState(gameApp, stateManager)
{
STACK_TRACE;
m_gwenController = NULL;

View file

@ -19,7 +19,7 @@ public:
static GAMESTATE_TYPE typeName = "GwenGameState";
return typeName;
}
GAMESTATE_TYPE GetTypeOf() const { return GetType(); }
GAMESTATE_TYPE GetTypeOf() const { return GetType(); }
GwenGameState(GameApp *gameApp, StateManager *stateManager);
virtual ~GwenGameState();

View file

@ -14,6 +14,8 @@
GwenGameStateUIController::GwenGameStateUIController(GwenGameState *gameState)
{
STACK_TRACE;
ASSERT(gameState != NULL);
m_gameState = gameState;
m_canvas = NULL;
m_inputProcessor = NULL;

View file

@ -58,13 +58,13 @@ protected:
Gwen::Controls::Canvas* InitializeGwen(const stl::string &skinFilename, const stl::string &fontFilename, uint8_t fontSize);
void ResizeAndScaleCanvas();
GwenGameState* GetGameState() const { return m_gameState; }
Gwen::Controls::Canvas* GetCanvas() const { return m_canvas; }
GwenGameState* GetGameState() const { return m_gameState; }
Gwen::Controls::Canvas* GetCanvas() const { return m_canvas; }
void EnableGwenInput(BOOL enable);
float GetAlpha() const { return m_alpha; }
float GetScale() const { return m_scale; }
float GetAlpha() const { return m_alpha; }
float GetScale() const { return m_scale; }
void SetAlpha(float alpha);
void SetScale(float scale);

View file

@ -21,7 +21,7 @@ struct StateInfo
BOOL isInactive;
BOOL isBeingPopped;
const stl::string& GetDescriptor() const { return m_descriptor; }
const stl::string& GetDescriptor() const { return m_descriptor; }
private:
void SetDescriptor();

View file

@ -13,6 +13,7 @@
StateManager::StateManager(GameApp *gameApp)
{
STACK_TRACE;
ASSERT(gameApp != NULL);
m_gameApp = gameApp;
m_stateReturnValue = 0;
m_hasStateReturnValue = FALSE;

View file

@ -43,15 +43,15 @@ public:
void OnUpdate(float delta);
BOOL IsTransitioning() const;
BOOL IsEmpty() const { return (m_states.empty() && m_pushQueue.empty() && m_swapQueue.empty()); }
BOOL IsTop(const GameState *state) const { return GetTop()->gameState == state; }
BOOL IsTransitioning(const GameState *state) const { return GetStateInfoFor(state)->isTransitioning; }
BOOL IsEmpty() const;
BOOL IsTop(const GameState *state) const;
BOOL IsTransitioning(const GameState *state) const;
GameState* GetTopState() const { return GetTop()->gameState; }
GameState* GetTopNonOverlayState() const { return GetTopNonOverlay()->gameState; }
GameState* GetTopState() const;
GameState* GetTopNonOverlayState() const;
uint32_t GetLastReturnValue() const { return m_stateReturnValue; }
BOOL HasLastReturnValue() const { return m_hasStateReturnValue; }
uint32_t GetLastReturnValue() const { return m_stateReturnValue; }
BOOL HasLastReturnValue() const { return m_hasStateReturnValue; }
private:
void QueueForPush(StateInfo *newStateInfo);
@ -151,6 +151,31 @@ T* StateManager::SwapTopNonOverlayWith(const stl::string &name)
return newState;
}
inline BOOL StateManager::IsEmpty() const
{
return (m_states.empty() && m_pushQueue.empty() && m_swapQueue.empty());
}
inline BOOL StateManager::IsTop(const GameState *state) const
{
return GetTop()->gameState == state;
}
inline BOOL StateManager::IsTransitioning(const GameState *state) const
{
return GetStateInfoFor(state)->isTransitioning;
}
inline GameState* StateManager::GetTopState() const
{
return GetTop()->gameState;
}
inline GameState* StateManager::GetTopNonOverlayState() const
{
return GetTopNonOverlay()->gameState;
}
inline StateInfo* StateManager::GetTop() const
{
if (m_states.empty())