UserInterfaceLocal.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition 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 BFG Edition 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 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. 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.
  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. class idWindow;
  21. class idUserInterfaceLocal : public idUserInterface {
  22. friend class idUserInterfaceManagerLocal;
  23. public:
  24. idUserInterfaceLocal();
  25. virtual ~idUserInterfaceLocal();
  26. virtual const char * Name() const;
  27. virtual const char * Comment() const;
  28. virtual bool IsInteractive() const;
  29. virtual bool InitFromFile( const char *qpath, bool rebuild = true, bool cache = true );
  30. virtual const char * HandleEvent( const sysEvent_t *event, int time, bool *updateVisuals );
  31. virtual void HandleNamedEvent( const char* namedEvent );
  32. virtual void Redraw( int time, bool hud );
  33. virtual void DrawCursor();
  34. virtual const idDict & State() const;
  35. virtual void DeleteStateVar( const char *varName );
  36. virtual void SetStateString( const char *varName, const char *value );
  37. virtual void SetStateBool( const char *varName, const bool value );
  38. virtual void SetStateInt( const char *varName, const int value );
  39. virtual void SetStateFloat( const char *varName, const float value );
  40. // Gets a gui state variable
  41. virtual const char* GetStateString( const char *varName, const char* defaultString = "" ) const;
  42. virtual bool GetStateBool( const char *varName, const char* defaultString = "0" ) const;
  43. virtual int GetStateInt( const char *varName, const char* defaultString = "0" ) const;
  44. virtual float GetStateFloat( const char *varName, const char* defaultString = "0" ) const;
  45. virtual void StateChanged( int time, bool redraw );
  46. virtual const char * Activate( bool activate, int time );
  47. virtual void Trigger( int time );
  48. virtual void ReadFromDemoFile( class idDemoFile *f );
  49. virtual void WriteToDemoFile( class idDemoFile *f );
  50. virtual bool WriteToSaveGame( idFile *savefile ) const;
  51. virtual bool ReadFromSaveGame( idFile * savefile );
  52. virtual void SetKeyBindingNames();
  53. virtual bool IsUniqued() const { return uniqued; };
  54. virtual void SetUniqued( bool b ) { uniqued = b; };
  55. virtual void SetCursor( float x, float y );
  56. virtual float CursorX() { return cursorX; }
  57. virtual float CursorY() { return cursorY; }
  58. size_t Size();
  59. idDict * GetStateDict() { return &state; }
  60. const char * GetSourceFile() const { return source; }
  61. ID_TIME_T GetTimeStamp() const { return timeStamp; }
  62. idWindow * GetDesktop() const { return desktop; }
  63. void SetBindHandler( idWindow *win ) { bindHandler = win; }
  64. bool Active() const { return active; }
  65. int GetTime() const { return time; }
  66. void SetTime( int _time ) { time = _time; }
  67. void ClearRefs() { refs = 0; }
  68. void AddRef() { refs++; }
  69. int GetRefs() { return refs; }
  70. void RecurseSetKeyBindingNames( idWindow *window );
  71. idStr &GetPendingCmd() { return pendingCmd; };
  72. idStr &GetReturnCmd() { return returnCmd; };
  73. private:
  74. bool active;
  75. bool loading;
  76. bool interactive;
  77. bool uniqued;
  78. idDict state;
  79. idWindow * desktop;
  80. idWindow * bindHandler;
  81. idStr source;
  82. idStr activateStr;
  83. idStr pendingCmd;
  84. idStr returnCmd;
  85. ID_TIME_T timeStamp;
  86. float cursorX;
  87. float cursorY;
  88. int time;
  89. int refs;
  90. };
  91. class idUserInterfaceManagerLocal : public idUserInterfaceManager {
  92. friend class idUserInterfaceLocal;
  93. public:
  94. virtual void Init();
  95. virtual void Shutdown();
  96. virtual void SetDrawingDC();
  97. virtual void Touch( const char *name );
  98. virtual void WritePrecacheCommands( idFile *f );
  99. virtual void SetSize( float width, float height );
  100. virtual void BeginLevelLoad();
  101. virtual void EndLevelLoad( const char *mapName );
  102. virtual void Preload( const char *mapName );
  103. virtual void Reload( bool all );
  104. virtual void ListGuis() const;
  105. virtual bool CheckGui( const char *qpath ) const;
  106. virtual idUserInterface * Alloc() const;
  107. virtual void DeAlloc( idUserInterface *gui );
  108. virtual idUserInterface * FindGui( const char *qpath, bool autoLoad = false, bool needInteractive = false, bool forceUnique = false );
  109. virtual idUserInterface * FindDemoGui( const char *qpath );
  110. virtual idListGUI * AllocListGUI() const;
  111. virtual void FreeListGUI( idListGUI *listgui );
  112. idTokenParser & GetBinaryParser() { return mapParser; }
  113. private:
  114. idRectangle screenRect;
  115. idDeviceContext dcOld;
  116. idDeviceContextOptimized dcOptimized;
  117. idList<idUserInterfaceLocal*> guis;
  118. idList<idUserInterfaceLocal*> demoGuis;
  119. idTokenParser mapParser;
  120. };
  121. // These used to be in every window, but they all pointed at the same one in idUserInterfaceManagerLocal.
  122. // Made a global so it can be switched out dynamically to test optimized versions.
  123. extern idDeviceContext *dc;