Session.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. 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.
  17. 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.
  18. ===========================================================================
  19. */
  20. #ifndef __SESSION_H__
  21. #define __SESSION_H__
  22. /*
  23. ===============================================================================
  24. The session is the glue that holds games together between levels.
  25. ===============================================================================
  26. */
  27. // needed by the gui system for the load game menu
  28. typedef struct {
  29. short health;
  30. short heartRate;
  31. short stamina;
  32. short combat;
  33. } logStats_t;
  34. static const int MAX_LOGGED_STATS = 60 * 120; // log every half second
  35. typedef enum {
  36. MSG_OK,
  37. MSG_ABORT,
  38. MSG_OKCANCEL,
  39. MSG_YESNO,
  40. MSG_PROMPT,
  41. MSG_CDKEY,
  42. MSG_INFO,
  43. MSG_WAIT
  44. } msgBoxType_t;
  45. typedef const char * (*HandleGuiCommand_t)( const char * );
  46. class idSession {
  47. public:
  48. virtual ~idSession() {}
  49. // Called in an orderly fashion at system startup,
  50. // so commands, cvars, files, etc are all available.
  51. virtual void Init() = 0;
  52. // Shut down the session.
  53. virtual void Shutdown() = 0;
  54. // Called on errors and game exits.
  55. virtual void Stop() = 0;
  56. // Redraws the screen, handling games, guis, console, etc
  57. // during normal once-a-frame updates, outOfSequence will be false,
  58. // but when the screen is updated in a modal manner, as with utility
  59. // output, the mouse cursor will be released if running windowed.
  60. virtual void UpdateScreen( bool outOfSequence = true ) = 0;
  61. // Called when console prints happen, allowing the loading screen
  62. // to redraw if enough time has passed.
  63. virtual void PacifierUpdate() = 0;
  64. // Called every frame, possibly spinning in place if we are
  65. // above maxFps, or we haven't advanced at least one demo frame.
  66. // Returns the number of milliseconds since the last frame.
  67. virtual void Frame() = 0;
  68. // Returns true if a multiplayer game is running.
  69. // CVars and commands are checked differently in multiplayer mode.
  70. virtual bool IsMultiplayer() = 0;
  71. // Processes the given event.
  72. virtual bool ProcessEvent( const sysEvent_t *event ) = 0;
  73. // Activates the main menu
  74. virtual void StartMenu( bool playIntro = false ) = 0;
  75. virtual void SetGUI( idUserInterface *gui, HandleGuiCommand_t handle ) = 0;
  76. // Updates gui and dispatched events to it
  77. virtual void GuiFrameEvents() = 0;
  78. // fires up the optional GUI event, also returns them if you set wait to true
  79. // if MSG_PROMPT and wait, returns the prompt string or NULL if aborted
  80. // if MSG_CDKEY and want, returns the cd key or NULL if aborted
  81. // network tells wether one should still run the network loop in a wait dialog
  82. 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;
  83. virtual void StopBox( void ) = 0;
  84. // monitor this download in a progress box to either abort or completion
  85. virtual void DownloadProgressBox( backgroundDownload_t *bgl, const char *title, int progress_start = 0, int progress_end = 100 ) = 0;
  86. virtual void SetPlayingSoundWorld() = 0;
  87. // this is used by the sound system when an OnDemand sound is loaded, so the game action
  88. // doesn't advance and get things out of sync
  89. virtual void TimeHitch( int msec ) = 0;
  90. // read and write the cd key data to files
  91. // doesn't perform any validity checks
  92. virtual void ReadCDKey( void ) = 0;
  93. virtual void WriteCDKey( void ) = 0;
  94. // returns NULL for if xp is true and xp key is not valid or not present
  95. virtual const char *GetCDKey( bool xp ) = 0;
  96. // check keys for validity when typed in by the user ( with checksum verification )
  97. // store the new set of keys if they are found valid
  98. virtual bool CheckKey( const char *key, bool netConnect, bool offline_valid[ 2 ] ) = 0;
  99. // verify the current set of keys for validity
  100. // strict -> keys in state CDKEY_CHECKING state are not ok
  101. virtual bool CDKeysAreValid( bool strict ) = 0;
  102. // wipe the key on file if the network check finds it invalid
  103. virtual void ClearCDKey( bool valid[ 2 ] ) = 0;
  104. // configure gui variables for mainmenu.gui and cd key state
  105. virtual void SetCDKeyGuiVars( void ) = 0;
  106. virtual bool WaitingForGameAuth( void ) = 0;
  107. // got reply from master about the keys. if !valid, auth_msg given
  108. virtual void CDKeysAuthReply( bool valid, const char *auth_msg ) = 0;
  109. virtual const char *GetCurrentMapName( void ) = 0;
  110. virtual int GetSaveGameVersion( void ) = 0;
  111. // The render world and sound world used for this session.
  112. idRenderWorld * rw;
  113. idSoundWorld * sw;
  114. // The renderer and sound system will write changes to writeDemo.
  115. // Demos can be recorded and played at the same time when splicing.
  116. idDemoFile * readDemo;
  117. idDemoFile * writeDemo;
  118. int renderdemoVersion;
  119. };
  120. extern idSession * session;
  121. #endif /* !__SESSION_H__ */