doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Common.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 __COMMON_H__
30 #define __COMMON_H__
31 
32 /*
33 ==============================================================
34 
35  Common
36 
37 ==============================================================
38 */
39 
40 typedef enum {
49  EDITOR_AF = BIT(8),
51  EDITOR_PDA = BIT(10),
52  EDITOR_AAS = BIT(11),
54 } toolFlag_t;
55 
56 #define STRTABLE_ID "#str_"
57 #define STRTABLE_ID_LENGTH 5
58 
59 extern idCVar com_version;
61 extern idCVar com_asyncInput;
62 extern idCVar com_asyncSound;
63 extern idCVar com_machineSpec;
64 extern idCVar com_purgeAll;
65 extern idCVar com_developer;
67 extern idCVar com_speeds;
68 extern idCVar com_showFPS;
72 extern idCVar com_makingBuild;
74 extern idCVar com_videoRam;
75 
76 extern int time_gameFrame; // game logic time
77 extern int time_gameDraw; // game present time
78 extern int time_frontend; // renderer frontend time
79 extern int time_backend; // renderer backend time
80 
81 extern int com_frameTime; // time for the current frame in milliseconds
82 extern volatile int com_ticNumber; // 60 hz tics, incremented by async function
83 extern int com_editors; // current active editor(s)
84 extern bool com_editorActive; // true if an editor has focus
85 
86 #ifdef _WIN32
87 const char DMAP_MSGID[] = "DMAPOutput";
88 const char DMAP_DONE[] = "DMAPDone";
89 extern HWND com_hwndMsg;
90 extern bool com_outputMsg;
91 #endif
92 
93 struct MemInfo_t {
95 
96  int total;
98 
99  // memory manager totals
101 
102  // subsystem totals
105 
106  // asset totals
110 };
111 
112 class idCommon {
113 public:
114  virtual ~idCommon( void ) {}
115 
116  // Initialize everything.
117  // if the OS allows, pass argc/argv directly (without executable name)
118  // otherwise pass the command line in a single string (without executable name)
119  virtual void Init( int argc, const char **argv, const char *cmdline ) = 0;
120 
121  // Shuts down everything.
122  virtual void Shutdown( void ) = 0;
123 
124  // Shuts down everything.
125  virtual void Quit( void ) = 0;
126 
127  // Returns true if common initialization is complete.
128  virtual bool IsInitialized( void ) const = 0;
129 
130  // Called repeatedly as the foreground thread for rendering and game logic.
131  virtual void Frame( void ) = 0;
132 
133  // Called repeatedly by blocking function calls with GUI interactivity.
134  virtual void GUIFrame( bool execCmd, bool network ) = 0;
135 
136  // Called 60 times a second from a background thread for sound mixing,
137  // and input generation. Not called until idCommon::Init() has completed.
138  virtual void Async( void ) = 0;
139 
140  // Checks for and removes command line "+set var arg" constructs.
141  // If match is NULL, all set commands will be executed, otherwise
142  // only a set with the exact name. Only used during startup.
143  // set once to clear the cvar from +set for early init code
144  virtual void StartupVariable( const char *match, bool once ) = 0;
145 
146  // Initializes a tool with the given dictionary.
147  virtual void InitTool( const toolFlag_t tool, const idDict *dict ) = 0;
148 
149  // Activates or deactivates a tool.
150  virtual void ActivateTool( bool active ) = 0;
151 
152  // Writes the user's configuration to a file
153  virtual void WriteConfigToFile( const char *filename ) = 0;
154 
155  // Writes cvars with the given flags to a file.
156  virtual void WriteFlaggedCVarsToFile( const char *filename, int flags, const char *setCmd ) = 0;
157 
158  // Begins redirection of console output to the given buffer.
159  virtual void BeginRedirect( char *buffer, int buffersize, void (*flush)( const char * ) ) = 0;
160 
161  // Stops redirection of console output.
162  virtual void EndRedirect( void ) = 0;
163 
164  // Update the screen with every message printed.
165  virtual void SetRefreshOnPrint( bool set ) = 0;
166 
167  // Prints message to the console, which may cause a screen update if com_refreshOnPrint is set.
168  virtual void Printf( const char *fmt, ... )id_attribute((format(printf,2,3))) = 0;
169 
170  // Same as Printf, with a more usable API - Printf pipes to this.
171  virtual void VPrintf( const char *fmt, va_list arg ) = 0;
172 
173  // Prints message that only shows up if the "developer" cvar is set,
174  // and NEVER forces a screen update, which could cause reentrancy problems.
175  virtual void DPrintf( const char *fmt, ... ) id_attribute((format(printf,2,3))) = 0;
176 
177  // Prints WARNING %s message and adds the warning message to a queue for printing later on.
178  virtual void Warning( const char *fmt, ... ) id_attribute((format(printf,2,3))) = 0;
179 
180  // Prints WARNING %s message in yellow that only shows up if the "developer" cvar is set.
181  virtual void DWarning( const char *fmt, ...) id_attribute((format(printf,2,3))) = 0;
182 
183  // Prints all queued warnings.
184  virtual void PrintWarnings( void ) = 0;
185 
186  // Removes all queued warnings.
187  virtual void ClearWarnings( const char *reason ) = 0;
188 
189  // Issues a C++ throw. Normal errors just abort to the game loop,
190  // which is appropriate for media or dynamic logic errors.
191  virtual void Error( const char *fmt, ... ) id_attribute((format(printf,2,3))) = 0;
192 
193  // Fatal errors quit all the way to a system dialog box, which is appropriate for
194  // static internal errors or cases where the system may be corrupted.
195  virtual void FatalError( const char *fmt, ... ) id_attribute((format(printf,2,3))) = 0;
196 
197  // Returns a pointer to the dictionary with language specific strings.
198  virtual const idLangDict * GetLanguageDict( void ) = 0;
199 
200  // Returns key bound to the command
201  virtual const char * KeysFromBinding( const char *bind ) = 0;
202 
203  // Returns the binding bound to the key
204  virtual const char * BindingFromKey( const char *key ) = 0;
205 
206  // Directly sample a button.
207  virtual int ButtonState( int key ) = 0;
208 
209  // Directly sample a keystate.
210  virtual int KeyState( int key ) = 0;
211 };
212 
213 extern idCommon * common;
214 
215 #endif /* !__COMMON_H__ */
volatile int com_ticNumber
Definition: Common.cpp:96
virtual void virtual void VPrintf(const char *fmt, va_list arg)=0
idCVar com_showSoundDecoders
int total
Definition: Common.h:96
int time_gameDraw
Definition: Common.cpp:90
virtual void InitTool(const toolFlag_t tool, const idDict *dict)=0
idCVar com_purgeAll
virtual ~idCommon(void)
Definition: Common.h:114
virtual const char * BindingFromKey(const char *key)=0
idCVar com_skipRenderer
virtual void virtual void virtual const idLangDict * GetLanguageDict(void)=0
int memoryManagerTotal
Definition: Common.h:100
GLenum GLsizei GLenum format
Definition: glext.h:2846
idCVar com_asyncInput
idCVar com_version
#define const
Definition: getdate.c:251
idCVar com_updateLoadSize
virtual int KeyState(int key)=0
#define BIT(num)
Definition: Lib.h:92
idCVar com_developer
idCVar com_showMemoryUsage
idCVar com_asyncSound
virtual void Async(void)=0
virtual void Frame(void)=0
int imageAssetsTotal
Definition: Common.h:107
int gameSubsystemTotal
Definition: Common.h:103
int assetTotals
Definition: Common.h:97
idCVar com_machineSpec
int com_frameTime
Definition: Common.cpp:94
virtual void GUIFrame(bool execCmd, bool network)=0
virtual void virtual void virtual void DWarning(const char *fmt,...) id_attribute((format(printf
int renderSubsystemTotal
Definition: Common.h:104
Definition: Dict.h:65
GLuint buffer
Definition: glext.h:3108
virtual void virtual void FatalError(const char *fmt,...) id_attribute((format(printf
virtual void virtual void virtual void virtual void PrintWarnings(void)=0
idCVar com_allowConsole
virtual void Printf(const char *fmt,...) id_attribute((format(printf
idStr filebase
Definition: Common.h:94
int modelAssetsTotal
Definition: Common.h:108
virtual int ButtonState(int key)=0
virtual void StartupVariable(const char *match, bool once)=0
int time_frontend
Definition: Common.cpp:91
idCVar com_makingBuild
int soundAssetsTotal
Definition: Common.h:109
virtual void WriteConfigToFile(const char *filename)=0
virtual const char * KeysFromBinding(const char *bind)=0
#define id_attribute(x)
Definition: sys_public.h:139
int time_gameFrame
Definition: Common.cpp:89
idCVar com_showAsyncStats
idCVar com_showFPS
virtual void WriteFlaggedCVarsToFile(const char *filename, int flags, const char *setCmd)=0
Definition: Str.h:116
toolFlag_t
Definition: Common.h:40
virtual void BeginRedirect(char *buffer, int buffersize, void(*flush)(const char *))=0
virtual void EndRedirect(void)=0
virtual void Quit(void)=0
int time_backend
Definition: Common.cpp:92
int com_editors
Definition: Common.cpp:97
virtual void ClearWarnings(const char *reason)=0
virtual void SetRefreshOnPrint(bool set)=0
virtual bool IsInitialized(void) const =0
virtual void DPrintf(const char *fmt,...) id_attribute((format(printf
virtual void Error(const char *fmt,...) id_attribute((format(printf
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
idCommon * common
Definition: Common.cpp:206
virtual void Init(int argc, const char **argv, const char *cmdline)=0
virtual void ActivateTool(bool active)=0
virtual void Shutdown(void)=0
idCVar com_speeds
bool com_editorActive
Definition: Common.cpp:98
idCVar com_videoRam