home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / framework / Common.h < prev    next >
C/C++ Source or Header  |  2005-11-14  |  11KB  |  337 lines

  1.  
  2. #ifndef __COMMON_H__
  3. #define __COMMON_H__
  4.  
  5. /*
  6. ==============================================================
  7.  
  8.   Common
  9.  
  10. ==============================================================
  11. */
  12.  
  13.  
  14. // RAVEN BEGIN
  15. // mekberg: added more save types
  16. typedef enum {
  17.     ST_REGULAR,
  18.     ST_QUICK,
  19.     ST_AUTO,
  20.     ST_CHECKPOINT,
  21. } saveType_t;
  22. // RAVEN END
  23.  
  24. typedef enum {
  25.     EDITOR_NONE                    = 0,
  26.     EDITOR_RADIANT                = BIT(1),
  27.     EDITOR_GUI                    = BIT(2),
  28.     EDITOR_DEBUGGER                = BIT(3),
  29.     EDITOR_SCRIPT                = BIT(4),
  30.     EDITOR_LIGHT                = BIT(5),
  31.     EDITOR_SOUND                = BIT(6),
  32.     EDITOR_DECL                    = BIT(7),
  33.     EDITOR_AF                    = BIT(8),
  34.     EDITOR_PDA                    = BIT(9),
  35.     EDITOR_FX                    = BIT(10),
  36.     EDITOR_REVERB                = BIT(11),
  37.     EDITOR_PLAYBACKS            = BIT(12),
  38.     EDITOR_MODVIEW                = BIT(13),
  39.     EDITOR_LOGVIEW                = BIT(14),
  40.     EDITOR_ENTVIEW                = BIT(15),
  41.     EDITOR_MATERIAL                = BIT(16),
  42.  
  43.     // Just flags to prevent caching of unneeded assets
  44.     EDITOR_AAS                    = BIT(17),
  45.     EDITOR_RENDERBUMP            = BIT(18),
  46.     EDITOR_SPAWN_GUI            = BIT(19),
  47.  
  48.     // Specifies that a decl validation run is happening
  49.     EDITOR_DECL_VALIDATING        = BIT(20),
  50.  
  51.     EDITOR_ALL                    = -1
  52. };
  53. // RAVEN END
  54.  
  55. #define STRTABLE_ID                "#str_"
  56. #define STRTABLE_ID_LENGTH        5
  57.  
  58. extern idCVar        com_version;
  59. extern idCVar        com_skipRenderer;
  60. extern idCVar        com_asyncSound;
  61. extern idCVar        com_machineSpec;
  62. extern idCVar        com_purgeAll;
  63. extern idCVar        com_developer;
  64. extern idCVar        com_allowConsole;
  65. extern idCVar        com_speeds;
  66. extern idCVar        com_showFPS;
  67. extern idCVar        com_showMemoryUsage;
  68. extern idCVar        com_showAsyncStats;
  69. extern idCVar        com_showSoundDecoders;
  70. extern idCVar        com_makingBuild;
  71. extern idCVar        com_updateLoadSize;
  72. extern idCVar        com_videoRam;
  73.  
  74. // RAVEN BEGIN
  75. // ksergent: added bundler 
  76. extern idCVar        com_Bundler;
  77.  
  78. #ifndef _XENON
  79. // nrausch: generate rdf's for xenon load screens
  80. extern idCVar        com_MakeLoadScreens;
  81. #endif
  82.  
  83. // rjohnson: added quick load
  84. extern idCVar        com_QuickLoad;
  85. // rjohnson: added limits stuff
  86. extern idCVar        com_Limits;
  87. // jsinger: added build for binary lexer
  88. extern idCVar        com_BinaryWrite;
  89. extern idCVar        com_BinaryRead;
  90. // jsinger: added to support serialization/deserialization of binary decls
  91. #ifdef RV_BINARYDECLS
  92. extern idCVar        com_BinaryDeclRead;
  93. #endif
  94. // jsinger: added to support loading of all decls from a single file
  95. #ifdef RV_SINGLE_DECL_FILE
  96. extern idCVar        com_SingleDeclFile;
  97. extern idCVar        com_WriteSingleDeclFIle;
  98. #endif
  99. // jshepard: warning suppresion
  100. extern idCVar        com_uniqueWarnings;
  101. // amccarthy: show Mem_Alloc tag statistics
  102. extern idCVar        com_showMemAllocTags;
  103. #if defined(_XENON)
  104. // mwhitlock: changes for Xenon to enable us to use texture resources from .xpr bundles.
  105. extern idCVar        com_showXenTexCacheStats;
  106. extern idCVar        com_showXenHardwareTimers;
  107. // ksergent: show thread usage.
  108. extern idCVar        com_showXenThreadUsage;
  109. #endif // _XENON
  110. extern idCVar        sys_lang;
  111. // RAVEN END
  112.  
  113. extern int            time_gameFrame;            // game logic time
  114. extern int            time_gameDraw;            // game present time
  115. extern int            time_frontend;            // renderer frontend time
  116. extern int            time_backend;            // renderer backend time
  117. // RAVEN BEGIN
  118. extern int            time_waiting;            // game logic time
  119. // RAVEN END
  120.  
  121. extern int            com_frameTime;            // time for the current frame in milliseconds
  122. extern volatile int    com_ticNumber;            // 60 hz tics, incremented by async function
  123.  
  124. // RAVEN BEGIN
  125. // bdube: added timing dict
  126. extern bool            com_debugHudActive;        // The debug hud is active in the game
  127. // RAVEN END
  128.  
  129. #ifdef _WINDOWS
  130. const char            DMAP_MSGID[] = "DMAPOutput";
  131. const char            DMAP_DONE[] = "DMAPDone";
  132. #endif
  133.  
  134. // RAVEN BEGIN
  135. // bdube: forward declarations
  136. class idInterpreter;
  137. class idProgram;
  138.  
  139. // converted to a class so the idStr gets constructed
  140. class MemInfo {
  141. public:
  142.                     MemInfo( void );
  143.  
  144.     idStr            filebase;
  145.  
  146.     int                total;
  147.     int                assetTotals;
  148.  
  149.     // asset totals
  150.     int                imageAssetsTotal;
  151.     int                modelAssetsTotal;
  152.     int                soundAssetsTotal;
  153. // RAVEN BEGIN
  154.     int                collAssetsTotal;
  155.     int                animsAssetsTotal;
  156.     int                aasAssetsTotal;
  157.  
  158.     int                imageAssetsCount;
  159.     int                modelAssetsCount;
  160.     int                soundAssetsCount;
  161.     int                collAssetsCount;
  162.     int                animsAssetsCount;
  163.     int                aasAssetsCount;
  164. };
  165. // RAVEN END
  166.  
  167. class idCommon {
  168. public:
  169.     virtual                        ~idCommon( void ) {}
  170.  
  171.                                 // Initialize everything.
  172.                                 // if the OS allows, pass argc/argv directly (without executable name)
  173.                                 // otherwise pass the command line in a single string (without executable name)
  174.     virtual void                Init( int argc, const char **argv, const char *cmdline ) = 0;
  175.  
  176.                                 // Shuts down everything.
  177.     virtual void                Shutdown( void ) = 0;
  178.  
  179.                                 // Shuts down everything.
  180.     virtual void                Quit( void ) = 0;
  181.  
  182.                                 // Returns true if common initialization is complete.
  183.     virtual bool                IsInitialized( void ) const = 0;
  184.  
  185.                                 // Called repeatedly as the foreground thread for rendering and game logic.
  186.     virtual void                Frame( void ) = 0;
  187.  
  188.                                 // Called repeatedly by blocking function calls with GUI interactivity.
  189.     virtual void                GUIFrame( bool execCmd, bool network ) = 0;
  190.  
  191.                                 // Called 60 times a second from a background thread for sound mixing,
  192.                                 // and input generation. Not called until idCommon::Init() has completed.
  193.     virtual void                Async( void ) = 0;
  194.  
  195.                                 // Checks for and removes command line "+set var arg" constructs.
  196.                                 // If match is NULL, all set commands will be executed, otherwise
  197.                                 // only a set with the exact name.  Only used during startup.
  198.                                 // set once to clear the cvar from +set for early init code
  199.     virtual void                StartupVariable( const char *match, bool once ) = 0;
  200.  
  201. // RAVEN BEGIN
  202.     virtual    int                    GetUserCmdHz( void ) const = 0;
  203.  
  204.     virtual int                    GetUserCmdMSec( void ) const = 0;
  205.  
  206.                                 // Returns com_frameTime - which is 0 if a command is added to the command line
  207.     virtual int                    GetFrameTime( void ) const = 0;
  208.  
  209.                                 // returns if the game is processing the last frame when it processes multiple frames
  210.     virtual bool                IsRenderableGameFrame( void ) const = 0;
  211.  
  212.     virtual void                SetRenderableGameFrame( bool in ) = 0;
  213.  
  214.                                 // returns the last message from common->Error
  215.     virtual const char            *GetErrorMessage( void ) const = 0;
  216.  
  217.                                 // Initializes a tool with the given dictionary.
  218.     virtual void                InitTool( const int tool, const idDict *dict ) = 0;
  219.  
  220.                                 // Returns true if an editor has focus
  221.     virtual bool                IsToolActive( void ) const = 0;
  222.  
  223.                                 // Returns an interface to source control
  224.     virtual class rvISourceControl *GetSourceControl( void ) = 0;
  225. // RAVEN END
  226.  
  227. // RAVEN BEGIN
  228. // dluetscher: added the following method to initialize each of the memory heaps 
  229. #ifdef _RV_MEM_SYS_SUPPORT
  230.     virtual void                InitHeaps( void ) = 0;        // initializes each of the memory heaps for use
  231.     virtual void                ShutdownHeaps( void ) = 0;    // shuts down each of the memory heaps from further use
  232. #endif
  233. // RAVEN END
  234.  
  235.                                 // Activates or deactivates a tool.
  236.     virtual void                ActivateTool( bool active ) = 0;
  237.  
  238.                                 // Writes the user's configuration to a file
  239.     virtual void                WriteConfigToFile( const char *filename ) = 0;
  240.  
  241.                                 // Writes cvars with the given flags to a file.
  242.     virtual void                WriteFlaggedCVarsToFile( const char *filename, int flags, const char *setCmd ) = 0;
  243.  
  244. // RAVEN BEGIN
  245. // bdube: new exports
  246.                                 // Modview thinks in the middle of a game frame
  247.     virtual void                ModViewThink ( void ) = 0;    
  248.     
  249. // rjohnson: added option for guis to always think
  250.     virtual void                RunAlwaysThinkGUIs ( int time ) = 0;
  251.  
  252.                                 // Debbugger hook to check if a breakpoint has been hit
  253.     virtual void                DebuggerCheckBreakpoint ( idInterpreter* interpreter, idProgram* program, int instructionPointer ) = 0;
  254.  
  255. // scork: need to test if validating to catch some model errors that would stop the validation and convert to warnings...
  256.     virtual bool                DoingDeclValidation( void ) = 0;
  257. // scork: guess
  258.     virtual void                SetCrashReportAutoSendString( const char *psString ) = 0;
  259.  
  260.     virtual void                LoadToolsDLL( void ) = 0;
  261.     virtual void                UnloadToolsDLL( void ) = 0;
  262. // RAVEN END
  263.  
  264.                                 // Begins redirection of console output to the given buffer.
  265.     virtual void                BeginRedirect( char *buffer, int buffersize, void (*flush)( const char * ) ) = 0;
  266.  
  267.                                 // Stops redirection of console output.
  268.     virtual void                EndRedirect( void ) = 0;
  269.  
  270.                                 // Update the screen with every message printed.
  271.     virtual void                SetRefreshOnPrint( bool set ) = 0;
  272.  
  273.                                 // Prints message to the console, which may cause a screen update if com_refreshOnPrint is set.
  274.     virtual void                Printf( const char *fmt, ... )id_attribute((format(printf,2,3))) = 0;
  275.  
  276.                                 // Same as Printf, with a more usable API - Printf pipes to this.
  277.     virtual void                VPrintf( const char *fmt, va_list arg ) = 0;
  278.  
  279.                                 // Prints message that only shows up if the "developer" cvar is set,
  280.                                 // and NEVER forces a screen update, which could cause reentrancy problems.
  281.     virtual void                DPrintf( const char *fmt, ... ) id_attribute((format(printf,2,3))) = 0;
  282.  
  283.                                 // Prints WARNING %s message and adds the warning message to a queue for printing later on.
  284.     virtual void                Warning( const char *fmt, ... ) id_attribute((format(printf,2,3))) = 0;
  285.  
  286.                                 // Prints WARNING %s message in yellow that only shows up if the "developer" cvar is set.
  287.     virtual void                DWarning( const char *fmt, ...) id_attribute((format(printf,2,3))) = 0;
  288.  
  289.                                 // Prints all queued warnings.
  290.     virtual void                PrintWarnings( void ) = 0;
  291.  
  292.                                 // Removes all queued warnings.
  293.     virtual void                ClearWarnings( const char *reason ) = 0;
  294.  
  295.                                 // Issues a C++ throw. Normal errors just abort to the game loop,
  296.                                 // which is appropriate for media or dynamic logic errors.
  297.     virtual void                Error( const char *fmt, ... ) id_attribute((format(printf,2,3))) = 0;
  298.  
  299.                                 // Fatal errors quit all the way to a system dialog box, which is appropriate for
  300.                                 // static internal errors or cases where the system may be corrupted.
  301.     virtual void                FatalError( const char *fmt, ... ) id_attribute((format(printf,2,3))) = 0;
  302.  
  303. // RAVEN BEGIN
  304.                                 // Brings up notepad with the warnings generated while running the game
  305.     virtual void                DumpWarnings( void ) = 0;
  306.  
  307.                                 // Returns the localised string of the token, of the token if it does not begin with #str_
  308.     virtual const char *        GetLocalizedString( const char *token, int langIndex = -1 ) = 0;
  309.  
  310.                                 // Returns the localised string at position 'index'
  311.     virtual const idLangKeyValue * GetLocalizedString( int index, int langIndex = -1 ) = 0;
  312.  
  313.                                 // Returns the number of languages the game found
  314.     virtual int                    GetNumLanguages( void ) const = 0;
  315.  
  316.                                 // Returns the number of strings in the English langdict
  317.     virtual int                    GetNumLocalizedStrings( void ) const = 0;
  318.     
  319.                                 // Returns the name of the language
  320.     virtual const char *        GetLanguage( int index ) const = 0;
  321.  
  322.                                 // Returns whether the language has VO
  323.     virtual bool                LanguageHasVO( int index ) const = 0;
  324.  
  325.                                 // Returns key bound to the command
  326.     virtual const char *        KeysFromBinding( const char *bind ) = 0;
  327.  
  328. // mekberg: added
  329.     virtual int                    GetRModeForMachineSpec( int machineSpec ) const = 0;
  330.     virtual void                SetDesiredMachineSpec( int machineSpec ) = 0;
  331. // RAVEN END
  332. };
  333.  
  334. extern idCommon *                common;
  335.  
  336. #endif /* !__COMMON_H__ */
  337.