GuiScript.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. #ifndef __GUISCRIPT_H
  21. #define __GUISCRIPT_H
  22. #include "Window.h"
  23. #include "Winvar.h"
  24. struct idGSWinVar {
  25. idGSWinVar() {
  26. var = NULL;
  27. own = false;
  28. }
  29. idWinVar* var;
  30. bool own;
  31. };
  32. class idGuiScriptList;
  33. class idGuiScript {
  34. friend class idGuiScriptList;
  35. friend class idWindow;
  36. public:
  37. idGuiScript();
  38. ~idGuiScript();
  39. bool Parse(idTokenParser *src);
  40. void Execute(idWindow *win) {
  41. if (handler) {
  42. handler(win, &parms);
  43. }
  44. }
  45. void FixupParms(idWindow *win);
  46. size_t Size() {
  47. int sz = sizeof(*this);
  48. for (int i = 0; i < parms.Num(); i++) {
  49. sz += parms[i].var->Size();
  50. }
  51. return sz;
  52. }
  53. void WriteToSaveGame( idFile *savefile );
  54. void ReadFromSaveGame( idFile *savefile );
  55. protected:
  56. int conditionReg;
  57. idGuiScriptList *ifList;
  58. idGuiScriptList *elseList;
  59. idList<idGSWinVar, TAG_OLD_UI> parms;
  60. void (*handler) (idWindow *window, idList<idGSWinVar, TAG_OLD_UI> *src);
  61. };
  62. class idGuiScriptList {
  63. idList<idGuiScript*, TAG_OLD_UI> list;
  64. public:
  65. idGuiScriptList() { list.SetGranularity( 4 ); };
  66. ~idGuiScriptList() { list.DeleteContents(true); };
  67. void Execute(idWindow *win);
  68. void Append(idGuiScript* gs) {
  69. list.Append(gs);
  70. }
  71. size_t Size() {
  72. int sz = sizeof(*this);
  73. for (int i = 0; i < list.Num(); i++) {
  74. sz += list[i]->Size();
  75. }
  76. return sz;
  77. }
  78. void FixupParms(idWindow *win);
  79. void ReadFromDemoFile( class idDemoFile *f ) {};
  80. void WriteToDemoFile( class idDemoFile *f ) {};
  81. void WriteToSaveGame( idFile *savefile );
  82. void ReadFromSaveGame( idFile *savefile );
  83. };
  84. #endif // __GUISCRIPT_H