UserInterface.h (6441B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition 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 BFG Edition 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 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition 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 BFG Edition 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 __USERINTERFACE_H__ 30 #define __USERINTERFACE_H__ 31 32 /* 33 =============================================================================== 34 35 Draws an interactive 2D surface. 36 Used for all user interaction with the game. 37 38 =============================================================================== 39 */ 40 41 class idFile; 42 class idDemoFile; 43 44 45 class idUserInterface { 46 public: 47 virtual ~idUserInterface() {}; 48 49 // Returns the name of the gui. 50 virtual const char * Name() const = 0; 51 52 // Returns a comment on the gui. 53 virtual const char * Comment() const = 0; 54 55 // Returns true if the gui is interactive. 56 virtual bool IsInteractive() const = 0; 57 58 virtual bool IsUniqued() const = 0; 59 60 virtual void SetUniqued( bool b ) = 0; 61 // returns false if it failed to load 62 virtual bool InitFromFile( const char *qpath, bool rebuild = true, bool cache = true ) = 0; 63 64 // handles an event, can return an action string, the caller interprets 65 // any return and acts accordingly 66 virtual const char * HandleEvent( const sysEvent_t *event, int time, bool *updateVisuals = NULL ) = 0; 67 68 // handles a named event 69 virtual void HandleNamedEvent( const char *eventName ) = 0; 70 71 // repaints the ui 72 virtual void Redraw( int time, bool hud = false ) = 0; 73 74 // repaints the cursor 75 virtual void DrawCursor() = 0; 76 77 // Provides read access to the idDict that holds this gui's state. 78 virtual const idDict & State() const = 0; 79 80 // Removes a gui state variable 81 virtual void DeleteStateVar( const char *varName ) = 0; 82 83 // Sets a gui state variable. 84 virtual void SetStateString( const char *varName, const char *value ) = 0; 85 virtual void SetStateBool( const char *varName, const bool value ) = 0; 86 virtual void SetStateInt( const char *varName, const int value ) = 0; 87 virtual void SetStateFloat( const char *varName, const float value ) = 0; 88 89 // Gets a gui state variable 90 virtual const char* GetStateString( const char *varName, const char* defaultString = "" ) const = 0; 91 virtual bool GetStateBool( const char *varName, const char* defaultString = "0" ) const = 0; 92 virtual int GetStateInt( const char *varName, const char* defaultString = "0" ) const = 0; 93 virtual float GetStateFloat( const char *varName, const char* defaultString = "0" ) const = 0; 94 95 // The state has changed and the gui needs to update from the state idDict. 96 virtual void StateChanged( int time, bool redraw = false ) = 0; 97 98 // Activated the gui. 99 virtual const char * Activate( bool activate, int time ) = 0; 100 101 // Triggers the gui and runs the onTrigger scripts. 102 virtual void Trigger( int time ) = 0; 103 104 virtual void ReadFromDemoFile( class idDemoFile *f ) = 0; 105 virtual void WriteToDemoFile( class idDemoFile *f ) = 0; 106 107 virtual bool WriteToSaveGame( idFile * savefile ) const = 0; 108 virtual bool ReadFromSaveGame( idFile * savefile ) = 0; 109 virtual void SetKeyBindingNames() = 0; 110 111 virtual void SetCursor( float x, float y ) = 0; 112 virtual float CursorX() = 0; 113 virtual float CursorY() = 0; 114 }; 115 116 117 class idUserInterfaceManager { 118 public: 119 virtual ~idUserInterfaceManager() {}; 120 121 virtual void Init() = 0; 122 virtual void Shutdown() = 0; 123 virtual void Touch( const char *name ) = 0; 124 virtual void WritePrecacheCommands( idFile *f ) = 0; 125 126 // use either the optimized or legacy implementation for 127 // testing, based on the g_useNewGuiCode cvar 128 virtual void SetDrawingDC() = 0; 129 130 // Sets the size for 640x480 adjustment. 131 virtual void SetSize( float width, float height ) = 0; 132 133 virtual void BeginLevelLoad() = 0; 134 virtual void EndLevelLoad( const char *mapName ) = 0; 135 virtual void Preload( const char *mapName ) = 0; 136 137 // Reloads changed guis, or all guis. 138 virtual void Reload( bool all ) = 0; 139 140 // lists all guis 141 virtual void ListGuis() const = 0; 142 143 // Returns true if gui exists. 144 virtual bool CheckGui( const char *qpath ) const = 0; 145 146 // Allocates a new gui. 147 virtual idUserInterface * Alloc() const = 0; 148 149 // De-allocates a gui.. ONLY USE FOR PRECACHING 150 virtual void DeAlloc( idUserInterface *gui ) = 0; 151 152 // Returns NULL if gui by that name does not exist. 153 virtual idUserInterface * FindGui( const char *qpath, bool autoLoad = false, bool needUnique = false, bool forceUnique = false ) = 0; 154 155 // Returns NULL if gui by that name does not exist. 156 virtual idUserInterface * FindDemoGui( const char *qpath ) = 0; 157 158 // Allocates a new GUI list handler 159 virtual idListGUI * AllocListGUI() const = 0; 160 161 // De-allocates a list gui 162 virtual void FreeListGUI( idListGUI *listgui ) = 0; 163 }; 164 165 extern idUserInterfaceManager * uiManager; 166 167 #endif /* !__USERINTERFACE_H__ */