blob: 6a0f83affe0bd8517b6302764392b19949b14a4b (
plain) (
blame)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
//=============================================================================
// Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved.
//
// Component: GameFlow
//
// Description: The GameFlow Controller orchestrates the overall game execution.
//
// History: + Stolen and cleaned up from Penthouse -- Darwin Chau
//
//=============================================================================
#ifndef GAMEFLOW_H
#define GAMEFLOW_H
//========================================
// System Includes
//========================================
#include <vector>
#include <stack>
#include <radtime.hpp> // IRadTimerCallback
//========================================
// Project Includes
//========================================
#include <contexts/contextenum.h>
#include <memory/stlallocators.h>
//========================================
// Forward References
//========================================
class Context;
//=============================================================================
//
// Synopsis: The game "loop"
//
//=============================================================================
class GameFlow : public IRadTimerCallback
{
public:
// Static Methods (for creating and getting an instance of the game)
static GameFlow* CreateInstance();
static GameFlow* GetInstance();
static void DestroyInstance();
// Functions to change the context.
void PushContext( ContextEnum context );
void PopContext();
void SetContext( ContextEnum context );
// Implement IRadTimerCallback interface.
// This member is called whenever the timer expires.
void OnTimerDone( unsigned int elapsedtime, void* pUserData );
ContextEnum GetCurrentContext() const { return mCurrentContext; }
ContextEnum GetNextContext() const { return mNextContext; }
Context* GetContext( ContextEnum which ) const { return mpContexts[which]; }
/*
bool GetQuickStartLoading( void ) const { return mQuickStartLoading; }
void SetQuickStartLoading( bool IsQuickStartLoading ) { mQuickStartLoading = IsQuickStartLoading; }
*/
private:
// Declared but not defined to prevent copying and assignment.
GameFlow( const GameFlow& );
GameFlow& operator=( const GameFlow& );
// Constructor - these are private to prevent anybody else from
// creating me.
GameFlow();
virtual ~GameFlow();
// This member is called when the gameflow is being initialized.
void Initialize();
// The one and only GameFlow instance.
static GameFlow* spInstance;
// Timer for gameflow updates.
IRadTimer* mpITimer;
// Contexts
ContextEnum mCurrentContext;
ContextEnum mNextContext;
typedef std::vector< ContextEnum, s2alloc<ContextEnum> > ContextEnumSequence;
typedef std::stack< ContextEnum, ContextEnumSequence > ContextStack;
ContextStack mContextStack;
Context* mpContexts[NUM_CONTEXTS];
bool mQuickStartLoading : 1;
};
//
// A little syntactic sugar for getting at this singleton.
//
inline GameFlow* GetGameFlow() { return( GameFlow::GetInstance() ); }
#endif
|