summaryrefslogtreecommitdiffstats
path: root/game/code/contexts/pausecontext.h
blob: 780c07ec94790deb6ca1f395ccfaea12e4ccb280 (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
//=============================================================================
// Copyright (C) 2002 Radical Entertainment Ltd.  All rights reserved.
//
// File:        PauseContext.h
//
// Description: 
//
// History:     + Created -- Tony Chu
//
//=============================================================================

#ifndef PAUSECONTEXT_H
#define PAUSECONTEXT_H

//========================================
// System Includes
//========================================

//========================================
// Project Includes
//========================================
#include <contexts/context.h>   // is-a Context
#include <input/controller.h>

//========================================
// Forward References
//========================================

//=============================================================================
//
// Synopsis:    
//
//=============================================================================
class PauseContext : public Context
{
    public:

        // Static Methods for accessing this singleton.
        static PauseContext* GetInstance();

        bool IsWaitingForContextSwitch() { return m_waitingForContextSwitch; }
        void SetWaitingForContextSwitch( bool tf ) { m_waitingForContextSwitch = tf; }

    protected:

        virtual void OnStart( ContextEnum previousContext );
        virtual void OnStop( ContextEnum nextContext );
        virtual void OnUpdate( unsigned int elapsedTime );
        
        virtual void OnSuspend();
        virtual void OnResume();

        virtual void OnHandleEvent( EventEnum id, void* pEventData );

    private:

        // constructor and destructor are protected to force singleton implementation
        PauseContext();
        virtual ~PauseContext();

        // Declared but not defined to prevent copying and assignment.
        PauseContext( const PauseContext& );
        PauseContext& operator=( const PauseContext& );

        // Pointer to the one and only instance of this singleton.
        static PauseContext* spInstance;

        Input::ActiveState mOldState;
        bool m_quitGamePending : 1;
        bool m_waitingForContextSwitch;        
};

// A little syntactic sugar for getting at this singleton.
inline PauseContext* GetPauseContext() { return( PauseContext::GetInstance() ); }


#endif // PAUSECONTEXT_H