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 struct sysEvent_t; 33 struct backgroundDownload_t; 34 class idDemoFile; 35 class idRenderWorld; 36 class idSoundWorld; 37 class idUserInterface; 38 39 /* 40 =============================================================================== 41 42 The session is the glue that holds games together between levels. 43 44 =============================================================================== 45 */ 46 47 // needed by the gui system for the load game menu 48 typedef struct { 49 short health; 50 short heartRate; 51 short stamina; 52 short combat; 53 } logStats_t; 54 55 static const int MAX_LOGGED_STATS = 60 * 120; // log every half second 56 57 typedef enum { 58 MSG_OK, 59 MSG_ABORT, 60 MSG_OKCANCEL, 61 MSG_YESNO, 62 MSG_PROMPT, 63 MSG_CDKEY, 64 MSG_INFO, 65 MSG_WAIT 66 } msgBoxType_t; 67 68 typedef const char * (*HandleGuiCommand_t)( const char * ); 69 70 class idSession { 71 public: ~idSession()72 virtual ~idSession() {} 73 74 // Called in an orderly fashion at system startup, 75 // so commands, cvars, files, etc are all available. 76 virtual void Init() = 0; 77 78 // Shut down the session. 79 virtual void Shutdown() = 0; 80 81 // Called on errors and game exits. 82 virtual void Stop() = 0; 83 84 // Redraws the screen, handling games, guis, console, etc 85 // during normal once-a-frame updates, outOfSequence will be false, 86 // but when the screen is updated in a modal manner, as with utility 87 // output, the mouse cursor will be released if running windowed. 88 virtual void UpdateScreen( bool outOfSequence = true ) = 0; 89 90 // Called when console prints happen, allowing the loading screen 91 // to redraw if enough time has passed. 92 virtual void PacifierUpdate() = 0; 93 94 // Called every frame, possibly spinning in place if we are 95 // above maxFps, or we haven't advanced at least one demo frame. 96 // Returns the number of milliseconds since the last frame. 97 virtual void Frame() = 0; 98 99 // Returns true if a multiplayer game is running. 100 // CVars and commands are checked differently in multiplayer mode. 101 virtual bool IsMultiplayer() = 0; 102 103 // Processes the given event. 104 virtual bool ProcessEvent( const sysEvent_t *event ) = 0; 105 106 // Activates the main menu 107 virtual void StartMenu( bool playIntro = false ) = 0; 108 109 virtual void SetGUI( idUserInterface *gui, HandleGuiCommand_t handle ) = 0; 110 111 // Updates gui and dispatched events to it 112 virtual void GuiFrameEvents() = 0; 113 114 // fires up the optional GUI event, also returns them if you set wait to true 115 // if MSG_PROMPT and wait, returns the prompt string or NULL if aborted 116 // if MSG_CDKEY and want, returns the cd key or NULL if aborted 117 // network tells wether one should still run the network loop in a wait dialog 118 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; 119 virtual void StopBox( void ) = 0; 120 // monitor this download in a progress box to either abort or completion 121 virtual void DownloadProgressBox( backgroundDownload_t *bgl, const char *title, int progress_start = 0, int progress_end = 100 ) = 0; 122 123 virtual void SetPlayingSoundWorld() = 0; 124 125 // this is used by the sound system when an OnDemand sound is loaded, so the game action 126 // doesn't advance and get things out of sync 127 virtual void TimeHitch( int msec ) = 0; 128 129 // read and write the cd key data to files 130 // doesn't perform any validity checks 131 virtual void ReadCDKey( void ) = 0; 132 virtual void WriteCDKey( void ) = 0; 133 134 // returns NULL for if xp is true and xp key is not valid or not present 135 virtual const char *GetCDKey( bool xp ) = 0; 136 137 // check keys for validity when typed in by the user ( with checksum verification ) 138 // store the new set of keys if they are found valid 139 virtual bool CheckKey( const char *key, bool netConnect, bool offline_valid[ 2 ] ) = 0; 140 141 // verify the current set of keys for validity 142 // strict -> keys in state CDKEY_CHECKING state are not ok 143 virtual bool CDKeysAreValid( bool strict ) = 0; 144 // wipe the key on file if the network check finds it invalid 145 virtual void ClearCDKey( bool valid[ 2 ] ) = 0; 146 147 // configure gui variables for mainmenu.gui and cd key state 148 virtual void SetCDKeyGuiVars( void ) = 0; 149 150 virtual bool WaitingForGameAuth( void ) = 0; 151 152 // got reply from master about the keys. if !valid, auth_msg given 153 virtual void CDKeysAuthReply( bool valid, const char *auth_msg ) = 0; 154 155 virtual const char *GetCurrentMapName( void ) = 0; 156 157 virtual int GetSaveGameVersion( void ) = 0; 158 159 // The render world and sound world used for this session. 160 idRenderWorld * rw; 161 idSoundWorld * sw; 162 163 // The renderer and sound system will write changes to writeDemo. 164 // Demos can be recorded and played at the same time when splicing. 165 idDemoFile * readDemo; 166 idDemoFile * writeDemo; 167 int renderdemoVersion; 168 }; 169 170 extern idSession * session; 171 172 #endif /* !__SESSION_H__ */ 173