doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UserInterface.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 __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 
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 ) = 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( void ) = 0;
110 
111  virtual void SetCursor( float x, float y ) = 0;
112  virtual float CursorX() = 0;
113  virtual float CursorY() = 0;
114 };
115 
116 
118 public:
119  virtual ~idUserInterfaceManager( void ) {};
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  // Sets the size for 640x480 adjustment.
127  virtual void SetSize( float width, float height ) = 0;
128 
129  virtual void BeginLevelLoad() = 0;
130  virtual void EndLevelLoad() = 0;
131 
132  // Reloads changed guis, or all guis.
133  virtual void Reload( bool all ) = 0;
134 
135  // lists all guis
136  virtual void ListGuis() const = 0;
137 
138  // Returns true if gui exists.
139  virtual bool CheckGui( const char *qpath ) const = 0;
140 
141  // Allocates a new gui.
142  virtual idUserInterface * Alloc( void ) const = 0;
143 
144  // De-allocates a gui.. ONLY USE FOR PRECACHING
145  virtual void DeAlloc( idUserInterface *gui ) = 0;
146 
147  // Returns NULL if gui by that name does not exist.
148  virtual idUserInterface * FindGui( const char *qpath, bool autoLoad = false, bool needUnique = false, bool forceUnique = false ) = 0;
149 
150  // Returns NULL if gui by that name does not exist.
151  virtual idUserInterface * FindDemoGui( const char *qpath ) = 0;
152 
153  // Allocates a new GUI list handler
154  virtual idListGUI * AllocListGUI( void ) const = 0;
155 
156  // De-allocates a list gui
157  virtual void FreeListGUI( idListGUI *listgui ) = 0;
158 };
159 
161 
162 #endif /* !__USERINTERFACE_H__ */
virtual void DeAlloc(idUserInterface *gui)=0
GLsizei const GLfloat * value
Definition: glext.h:3614
virtual void StateChanged(int time, bool redraw=false)=0
virtual void WritePrecacheCommands(idFile *f)=0
virtual void SetStateString(const char *varName, const char *value)=0
virtual void SetUniqued(bool b)=0
GLenum GLint GLint y
Definition: glext.h:2849
virtual void Init()=0
virtual idUserInterface * FindDemoGui(const char *qpath)=0
virtual idUserInterface * Alloc(void) const =0
virtual void HandleNamedEvent(const char *eventName)=0
virtual void SetKeyBindingNames(void)=0
virtual void SetStateInt(const char *varName, const int value)=0
virtual void SetSize(float width, float height)=0
GLenum GLint x
Definition: glext.h:2849
virtual const char * Comment() const =0
virtual const char * HandleEvent(const sysEvent_t *event, int time, bool *updateVisuals=NULL)=0
virtual bool IsInteractive() const =0
virtual void SetStateBool(const char *varName, const bool value)=0
virtual float CursorX()=0
virtual idUserInterface * FindGui(const char *qpath, bool autoLoad=false, bool needUnique=false, bool forceUnique=false)=0
virtual int GetStateInt(const char *varName, const char *defaultString="0") const =0
virtual void SetStateFloat(const char *varName, const float value)=0
Definition: File.h:50
virtual void DeleteStateVar(const char *varName)=0
virtual float CursorY()=0
virtual const char * GetStateString(const char *varName, const char *defaultString="") const =0
virtual bool ReadFromSaveGame(idFile *savefile)=0
virtual void Shutdown()=0
virtual void SetCursor(float x, float y)=0
virtual idListGUI * AllocListGUI(void) const =0
Definition: Dict.h:65
#define NULL
Definition: Lib.h:88
virtual bool InitFromFile(const char *qpath, bool rebuild=true, bool cache=true)=0
virtual void Redraw(int time)=0
virtual const char * Name() const =0
virtual void ListGuis() const =0
virtual void FreeListGUI(idListGUI *listgui)=0
virtual const char * Activate(bool activate, int time)=0
GLenum GLsizei width
Definition: glext.h:2846
virtual bool CheckGui(const char *qpath) const =0
virtual const idDict & State() const =0
virtual void BeginLevelLoad()=0
GLenum GLsizei GLsizei height
Definition: glext.h:2856
GLubyte GLubyte b
Definition: glext.h:4662
virtual bool GetStateBool(const char *varName, const char *defaultString="0") const =0
idUserInterfaceManager * uiManager
virtual float GetStateFloat(const char *varName, const char *defaultString="0") const =0
virtual void Reload(bool all)=0
virtual ~idUserInterface()
Definition: UserInterface.h:47
tuple f
Definition: idal.py:89
virtual void Touch(const char *name)=0
virtual bool IsUniqued() const =0
virtual bool WriteToSaveGame(idFile *savefile) const =0
const GLcharARB * name
Definition: glext.h:3629
virtual void WriteToDemoFile(class idDemoFile *f)=0
virtual void ReadFromDemoFile(class idDemoFile *f)=0
virtual ~idUserInterfaceManager(void)
virtual void DrawCursor()=0
virtual void Trigger(int time)=0
virtual void EndLevelLoad()=0