UserInterface.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 __USERINTERFACE_H__
  21. #define __USERINTERFACE_H__
  22. /*
  23. ===============================================================================
  24. Draws an interactive 2D surface.
  25. Used for all user interaction with the game.
  26. ===============================================================================
  27. */
  28. class idFile;
  29. class idDemoFile;
  30. class idUserInterface {
  31. public:
  32. virtual ~idUserInterface() {};
  33. // Returns the name of the gui.
  34. virtual const char * Name() const = 0;
  35. // Returns a comment on the gui.
  36. virtual const char * Comment() const = 0;
  37. // Returns true if the gui is interactive.
  38. virtual bool IsInteractive() const = 0;
  39. virtual bool IsUniqued() const = 0;
  40. virtual void SetUniqued( bool b ) = 0;
  41. // returns false if it failed to load
  42. virtual bool InitFromFile( const char *qpath, bool rebuild = true, bool cache = true ) = 0;
  43. // handles an event, can return an action string, the caller interprets
  44. // any return and acts accordingly
  45. virtual const char * HandleEvent( const sysEvent_t *event, int time, bool *updateVisuals = NULL ) = 0;
  46. // handles a named event
  47. virtual void HandleNamedEvent( const char *eventName ) = 0;
  48. // repaints the ui
  49. virtual void Redraw( int time ) = 0;
  50. // repaints the cursor
  51. virtual void DrawCursor() = 0;
  52. // Provides read access to the idDict that holds this gui's state.
  53. virtual const idDict & State() const = 0;
  54. // Removes a gui state variable
  55. virtual void DeleteStateVar( const char *varName ) = 0;
  56. // Sets a gui state variable.
  57. virtual void SetStateString( const char *varName, const char *value ) = 0;
  58. virtual void SetStateBool( const char *varName, const bool value ) = 0;
  59. virtual void SetStateInt( const char *varName, const int value ) = 0;
  60. virtual void SetStateFloat( const char *varName, const float value ) = 0;
  61. // Gets a gui state variable
  62. virtual const char* GetStateString( const char *varName, const char* defaultString = "" ) const = 0;
  63. virtual bool GetStateBool( const char *varName, const char* defaultString = "0" ) const = 0;
  64. virtual int GetStateInt( const char *varName, const char* defaultString = "0" ) const = 0;
  65. virtual float GetStateFloat( const char *varName, const char* defaultString = "0" ) const = 0;
  66. // The state has changed and the gui needs to update from the state idDict.
  67. virtual void StateChanged( int time, bool redraw = false ) = 0;
  68. // Activated the gui.
  69. virtual const char * Activate( bool activate, int time ) = 0;
  70. // Triggers the gui and runs the onTrigger scripts.
  71. virtual void Trigger( int time ) = 0;
  72. virtual void ReadFromDemoFile( class idDemoFile *f ) = 0;
  73. virtual void WriteToDemoFile( class idDemoFile *f ) = 0;
  74. virtual bool WriteToSaveGame( idFile *savefile ) const = 0;
  75. virtual bool ReadFromSaveGame( idFile *savefile ) = 0;
  76. virtual void SetKeyBindingNames( void ) = 0;
  77. virtual void SetCursor( float x, float y ) = 0;
  78. virtual float CursorX() = 0;
  79. virtual float CursorY() = 0;
  80. };
  81. class idUserInterfaceManager {
  82. public:
  83. virtual ~idUserInterfaceManager( void ) {};
  84. virtual void Init() = 0;
  85. virtual void Shutdown() = 0;
  86. virtual void Touch( const char *name ) = 0;
  87. virtual void WritePrecacheCommands( idFile *f ) = 0;
  88. // Sets the size for 640x480 adjustment.
  89. virtual void SetSize( float width, float height ) = 0;
  90. virtual void BeginLevelLoad() = 0;
  91. virtual void EndLevelLoad() = 0;
  92. // Reloads changed guis, or all guis.
  93. virtual void Reload( bool all ) = 0;
  94. // lists all guis
  95. virtual void ListGuis() const = 0;
  96. // Returns true if gui exists.
  97. virtual bool CheckGui( const char *qpath ) const = 0;
  98. // Allocates a new gui.
  99. virtual idUserInterface * Alloc( void ) const = 0;
  100. // De-allocates a gui.. ONLY USE FOR PRECACHING
  101. virtual void DeAlloc( idUserInterface *gui ) = 0;
  102. // Returns NULL if gui by that name does not exist.
  103. virtual idUserInterface * FindGui( const char *qpath, bool autoLoad = false, bool needUnique = false, bool forceUnique = false ) = 0;
  104. // Returns NULL if gui by that name does not exist.
  105. virtual idUserInterface * FindDemoGui( const char *qpath ) = 0;
  106. // Allocates a new GUI list handler
  107. virtual idListGUI * AllocListGUI( void ) const = 0;
  108. // De-allocates a list gui
  109. virtual void FreeListGUI( idListGUI *listgui ) = 0;
  110. };
  111. extern idUserInterfaceManager * uiManager;
  112. #endif /* !__USERINTERFACE_H__ */