-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCAppStateManager.cpp
63 lines (54 loc) · 1.29 KB
/
CAppStateManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "CAppStateManager.h"
// Refer to your Other App States Here
#include "CAppStateIntro.h"
#include "CAppStateGame.h"
#include "CAppStateMenu.h"
CAppState* CAppStateManager::ActiveAppState = 0;
void CAppStateManager::OnEvent(SDL_Event* EventHolder)
{
if(ActiveAppState) ActiveAppState->OnEvent(EventHolder);
}
void CAppStateManager::OnLoop()
{
if(ActiveAppState) ActiveAppState->OnLoop();
}
void CAppStateManager::OnRender(SDL_Surface* Surf_Display)
{
if(ActiveAppState) ActiveAppState->OnRender(Surf_Display);
}
void CAppStateManager::SetActiveAppState(int AppStateID)
{
if(ActiveAppState) ActiveAppState->OnDeactivate();
// Also, add your App State Here so that the Manager can switch to it
switch(AppStateID)
{
case APPSTATE_NONE:
{
ActiveAppState = 0;
break;
}
case APPSTATE_INTRO:
{
ActiveAppState = CAppStateIntro::GetInstance();
break;
}
case APPSTATE_GAME:
{
ActiveAppState = CAppStateGame::GetInstance();
break;
}
case APPSTATE_MENU:
{
ActiveAppState = CAppStateMenu::GetInstance();
break;
}
default:
{
}
}
if(ActiveAppState) ActiveAppState->OnActivate();
}
CAppState* CAppStateManager::GetActiveAppState()
{
return ActiveAppState;
}