doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Session.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __SESSION_H__
30 #define __SESSION_H__
31 
32 /*
33 ===============================================================================
34 
35  The session is the glue that holds games together between levels.
36 
37 ===============================================================================
38 */
39 
40 // needed by the gui system for the load game menu
41 typedef struct {
42  short health;
43  short heartRate;
44  short stamina;
45  short combat;
46 } logStats_t;
47 
48 static const int MAX_LOGGED_STATS = 60 * 120; // log every half second
49 
50 typedef enum {
59 } msgBoxType_t;
60 
61 typedef const char * (*HandleGuiCommand_t)( const char * );
62 
63 class idSession {
64 public:
65  virtual ~idSession() {}
66 
67  // Called in an orderly fashion at system startup,
68  // so commands, cvars, files, etc are all available.
69  virtual void Init() = 0;
70 
71  // Shut down the session.
72  virtual void Shutdown() = 0;
73 
74  // Called on errors and game exits.
75  virtual void Stop() = 0;
76 
77  // Redraws the screen, handling games, guis, console, etc
78  // during normal once-a-frame updates, outOfSequence will be false,
79  // but when the screen is updated in a modal manner, as with utility
80  // output, the mouse cursor will be released if running windowed.
81  virtual void UpdateScreen( bool outOfSequence = true ) = 0;
82 
83  // Called when console prints happen, allowing the loading screen
84  // to redraw if enough time has passed.
85  virtual void PacifierUpdate() = 0;
86 
87  // Called every frame, possibly spinning in place if we are
88  // above maxFps, or we haven't advanced at least one demo frame.
89  // Returns the number of milliseconds since the last frame.
90  virtual void Frame() = 0;
91 
92  // Returns true if a multiplayer game is running.
93  // CVars and commands are checked differently in multiplayer mode.
94  virtual bool IsMultiplayer() = 0;
95 
96  // Processes the given event.
97  virtual bool ProcessEvent( const sysEvent_t *event ) = 0;
98 
99  // Activates the main menu
100  virtual void StartMenu( bool playIntro = false ) = 0;
101 
102  virtual void SetGUI( idUserInterface *gui, HandleGuiCommand_t handle ) = 0;
103 
104  // Updates gui and dispatched events to it
105  virtual void GuiFrameEvents() = 0;
106 
107  // fires up the optional GUI event, also returns them if you set wait to true
108  // if MSG_PROMPT and wait, returns the prompt string or NULL if aborted
109  // if MSG_CDKEY and want, returns the cd key or NULL if aborted
110  // network tells wether one should still run the network loop in a wait dialog
111  virtual const char *MessageBox( msgBoxType_t type, const char *message, const char *title = NULL, bool wait = false, const char *fire_yes = NULL, const char *fire_no = NULL, bool network = false ) = 0;
112  virtual void StopBox( void ) = 0;
113  // monitor this download in a progress box to either abort or completion
114  virtual void DownloadProgressBox( backgroundDownload_t *bgl, const char *title, int progress_start = 0, int progress_end = 100 ) = 0;
115 
116  virtual void SetPlayingSoundWorld() = 0;
117 
118  // this is used by the sound system when an OnDemand sound is loaded, so the game action
119  // doesn't advance and get things out of sync
120  virtual void TimeHitch( int msec ) = 0;
121 
122  // read and write the cd key data to files
123  // doesn't perform any validity checks
124  virtual void ReadCDKey( void ) = 0;
125  virtual void WriteCDKey( void ) = 0;
126 
127  // returns NULL for if xp is true and xp key is not valid or not present
128  virtual const char *GetCDKey( bool xp ) = 0;
129 
130  // check keys for validity when typed in by the user ( with checksum verification )
131  // store the new set of keys if they are found valid
132  virtual bool CheckKey( const char *key, bool netConnect, bool offline_valid[ 2 ] ) = 0;
133 
134  // verify the current set of keys for validity
135  // strict -> keys in state CDKEY_CHECKING state are not ok
136  virtual bool CDKeysAreValid( bool strict ) = 0;
137  // wipe the key on file if the network check finds it invalid
138  virtual void ClearCDKey( bool valid[ 2 ] ) = 0;
139 
140  // configure gui variables for mainmenu.gui and cd key state
141  virtual void SetCDKeyGuiVars( void ) = 0;
142 
143  virtual bool WaitingForGameAuth( void ) = 0;
144 
145  // got reply from master about the keys. if !valid, auth_msg given
146  virtual void CDKeysAuthReply( bool valid, const char *auth_msg ) = 0;
147 
148  virtual const char *GetCurrentMapName( void ) = 0;
149 
150  virtual int GetSaveGameVersion( void ) = 0;
151 
152  // The render world and sound world used for this session.
155 
156  // The renderer and sound system will write changes to writeDemo.
157  // Demos can be recorded and played at the same time when splicing.
161 };
162 
163 extern idSession * session;
164 
165 #endif /* !__SESSION_H__ */
short heartRate
Definition: Session.h:43
virtual void Init()=0
idDemoFile * readDemo
Definition: Session.h:158
short stamina
Definition: Session.h:44
int renderdemoVersion
Definition: Session.h:160
virtual void CDKeysAuthReply(bool valid, const char *auth_msg)=0
idSoundWorld * sw
Definition: Session.h:154
virtual void GuiFrameEvents()=0
virtual ~idSession()
Definition: Session.h:65
virtual const char * MessageBox(msgBoxType_t type, const char *message, const char *title=NULL, bool wait=false, const char *fire_yes=NULL, const char *fire_no=NULL, bool network=false)=0
virtual void ClearCDKey(bool valid[2])=0
idSession * session
Definition: Session.cpp:48
virtual int GetSaveGameVersion(void)=0
short combat
Definition: Session.h:45
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
virtual bool CDKeysAreValid(bool strict)=0
virtual bool IsMultiplayer()=0
virtual void StartMenu(bool playIntro=false)=0
virtual bool ProcessEvent(const sysEvent_t *event)=0
idDemoFile * writeDemo
Definition: Session.h:159
virtual void WriteCDKey(void)=0
idRenderWorld * rw
Definition: Session.h:153
virtual void SetPlayingSoundWorld()=0
#define NULL
Definition: Lib.h:88
virtual void DownloadProgressBox(backgroundDownload_t *bgl, const char *title, int progress_start=0, int progress_end=100)=0
virtual void ReadCDKey(void)=0
virtual void Stop()=0
virtual void StopBox(void)=0
Definition: Session.h:51
virtual const char * GetCurrentMapName(void)=0
virtual void UpdateScreen(bool outOfSequence=true)=0
virtual const char * GetCDKey(bool xp)=0
msgBoxType_t
Definition: Session.h:50
virtual bool CheckKey(const char *key, bool netConnect, bool offline_valid[2])=0
virtual void PacifierUpdate()=0
virtual void Shutdown()=0
const char *(* HandleGuiCommand_t)(const char *)
Definition: Session.h:61
virtual void SetCDKeyGuiVars(void)=0
short health
Definition: Session.h:42
virtual void TimeHitch(int msec)=0
virtual void SetGUI(idUserInterface *gui, HandleGuiCommand_t handle)=0
virtual bool WaitingForGameAuth(void)=0
virtual void Frame()=0