doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Window.cpp
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 #include "../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "DeviceContext.h"
33 #include "Window.h"
34 #include "UserInterfaceLocal.h"
35 #include "EditWindow.h"
36 #include "ChoiceWindow.h"
37 #include "SliderWindow.h"
38 #include "BindWindow.h"
39 #include "ListWindow.h"
40 #include "RenderWindow.h"
41 #include "MarkerWindow.h"
42 #include "FieldWindow.h"
43 
44 #include "GameSSDWindow.h"
45 #include "GameBearShootWindow.h"
46 #include "GameBustOutWindow.h"
47 
48 //
49 // gui editor is more integrated into the window now
50 #include "../tools/guied/GEWindowWrapper.h"
51 
52 bool idWindow::registerIsTemporary[MAX_EXPRESSION_REGISTERS]; // statics to assist during parsing
53 //float idWindow::shaderRegisters[MAX_EXPRESSION_REGISTERS];
54 //wexpOp_t idWindow::shaderOps[MAX_EXPRESSION_OPS];
55 
56 idCVar idWindow::gui_debug( "gui_debug", "0", CVAR_GUI | CVAR_BOOL, "" );
57 idCVar idWindow::gui_edit( "gui_edit", "0", CVAR_GUI | CVAR_BOOL, "" );
58 
59 extern idCVar r_skipGuiShaders; // 1 = don't render any gui elements on surfaces
60 
61 // made RegisterVars a member of idWindow
63  { "forecolor", idRegister::VEC4 },
64  { "hovercolor", idRegister::VEC4 },
65  { "backcolor", idRegister::VEC4 },
66  { "bordercolor", idRegister::VEC4 },
67  { "rect", idRegister::RECTANGLE },
68  { "matcolor", idRegister::VEC4 },
69  { "scale", idRegister::VEC2 },
70  { "translate", idRegister::VEC2 },
71  { "rotate", idRegister::FLOAT },
72  { "textscale", idRegister::FLOAT },
73  { "visible", idRegister::BOOL },
74  { "noevents", idRegister::BOOL },
75  { "text", idRegister::STRING },
76  { "background", idRegister::STRING },
77  { "runscript", idRegister::STRING },
78  { "varbackground", idRegister::STRING },
79  { "cvar", idRegister::STRING },
80  { "choices", idRegister::STRING },
81  { "choiceVar", idRegister::STRING },
82  { "bind", idRegister::STRING },
83  { "modelRotate", idRegister::VEC4 },
84  { "modelOrigin", idRegister::VEC4 },
85  { "lightOrigin", idRegister::VEC4 },
86  { "lightColor", idRegister::VEC4 },
87  { "viewOffset", idRegister::VEC4 },
88  { "hideCursor", idRegister::BOOL}
89 };
90 
91 const int idWindow::NumRegisterVars = sizeof(RegisterVars) / sizeof(idRegEntry);
92 
93 const char *idWindow::ScriptNames[] = {
94  "onMouseEnter",
95  "onMouseExit",
96  "onAction",
97  "onActivate",
98  "onDeactivate",
99  "onESC",
100  "onEvent",
101  "onTrigger",
102  "onActionRelease",
103  "onEnter",
104  "onEnterRelease"
105 };
106 
107 /*
108 ================
109 idWindow::CommonInit
110 ================
111 */
113  childID = 0;
114  flags = 0;
115  lastTimeRun = 0;
116  origin.Zero();
117  fontNum = 0;
118  timeLine = -1;
119  xOffset = yOffset = 0.0;
120  cursor = 0;
121  forceAspectWidth = 640;
122  forceAspectHeight = 480;
123  matScalex = 1;
124  matScaley = 1;
125  borderSize = 0;
126  noTime = false;
127  visible = true;
128  textAlign = 0;
129  textAlignx = 0;
130  textAligny = 0;
131  noEvents = false;
132  rotate = 0;
133  shear.Zero();
134  textScale = 0.35f;
135  backColor.Zero();
136  foreColor = idVec4(1, 1, 1, 1);
137  hoverColor = idVec4(1, 1, 1, 1);
138  matColor = idVec4(1, 1, 1, 1);
139  borderColor.Zero();
140  background = NULL;
141  backGroundName = "";
142  focusedChild = NULL;
143  captureChild = NULL;
144  overChild = NULL;
145  parent = NULL;
146  saveOps = NULL;
147  saveRegs = NULL;
148  timeLine = -1;
149  textShadow = 0;
150  hover = false;
151 
152  for (int i = 0; i < SCRIPT_COUNT; i++) {
153  scripts[i] = NULL;
154  }
155 
156  hideCursor = false;
157 }
158 
159 /*
160 ================
161 idWindow::Size
162 ================
163 */
164 size_t idWindow::Size() {
165  int c = children.Num();
166  int sz = 0;
167  for (int i = 0; i < c; i++) {
168  sz += children[i]->Size();
169  }
170  sz += sizeof(*this) + Allocated();
171  return sz;
172 }
173 
174 /*
175 ================
176 idWindow::Allocated
177 ================
178 */
180  int i, c;
181  int sz = name.Allocated();
182  sz += text.Size();
183  sz += backGroundName.Size();
184 
185  c = definedVars.Num();
186  for (i = 0; i < c; i++) {
187  sz += definedVars[i]->Size();
188  }
189 
190  for (i = 0; i < SCRIPT_COUNT; i++) {
191  if (scripts[i]) {
192  sz += scripts[i]->Size();
193  }
194  }
195  c = timeLineEvents.Num();
196  for (i = 0; i < c; i++) {
197  sz += timeLineEvents[i]->Size();
198  }
199 
200  c = namedEvents.Num();
201  for (i = 0; i < c; i++) {
202  sz += namedEvents[i]->Size();
203  }
204 
205  c = drawWindows.Num();
206  for (i = 0; i < c; i++) {
207  if (drawWindows[i].simp) {
208  sz += drawWindows[i].simp->Size();
209  }
210  }
211 
212  return sz;
213 }
214 
215 /*
216 ================
217 idWindow::idWindow
218 ================
219 */
221  dc = NULL;
222  gui = ui;
223  CommonInit();
224 }
225 
226 /*
227 ================
228 idWindow::idWindow
229 ================
230 */
232  dc = d;
233  gui = ui;
234  CommonInit();
235 }
236 
237 /*
238 ================
239 idWindow::CleanUp
240 ================
241 */
243  int i, c = drawWindows.Num();
244  for (i = 0; i < c; i++) {
245  delete drawWindows[i].simp;
246  }
247 
248  // ensure the register list gets cleaned up
249  regList.Reset ( );
250 
251  // Cleanup the named events
253 
254  drawWindows.Clear();
255  children.DeleteContents(true);
258  for (i = 0; i < SCRIPT_COUNT; i++) {
259  delete scripts[i];
260  }
261  CommonInit();
262 }
263 
264 /*
265 ================
266 idWindow::~idWindow
267 ================
268 */
270  CleanUp();
271 }
272 
273 /*
274 ================
275 idWindow::Move
276 ================
277 */
278 void idWindow::Move(float x, float y) {
279  idRectangle rct = rect;
280  rct.x = x;
281  rct.y = y;
282  idRegister *reg = RegList()->FindReg("rect");
283  if (reg) {
284  reg->Enable(false);
285  }
286  rect = rct;
287 }
288 
289 /*
290 ================
291 idWindow::SetFont
292 ================
293 */
295  dc->SetFont(fontNum);
296 }
297 
298 /*
299 ================
300 idWindow::GetMaxCharHeight
301 ================
302 */
304  SetFont();
305  return dc->MaxCharHeight(textScale);
306 }
307 
308 /*
309 ================
310 idWindow::GetMaxCharWidth
311 ================
312 */
314  SetFont();
315  return dc->MaxCharWidth(textScale);
316 }
317 
318 /*
319 ================
320 idWindow::Draw
321 ================
322 */
323 void idWindow::Draw( int time, float x, float y ) {
324  if ( text.Length() == 0 ) {
325  return;
326  }
327  if ( textShadow ) {
328  idStr shadowText = text;
329  idRectangle shadowRect = textRect;
330 
331  shadowText.RemoveColors();
332  shadowRect.x += textShadow;
333  shadowRect.y += textShadow;
334 
335  dc->DrawText( shadowText, textScale, textAlign, colorBlack, shadowRect, !( flags & WIN_NOWRAP ), -1 );
336  }
338 
339  if ( gui_edit.GetBool() ) {
340  dc->EnableClipping( false );
341  dc->DrawText( va( "x: %i y: %i", ( int )rect.x(), ( int )rect.y() ), 0.25, 0, dc->colorWhite, idRectangle( rect.x(), rect.y() - 15, 100, 20 ), false );
342  dc->DrawText( va( "w: %i h: %i", ( int )rect.w(), ( int )rect.h() ), 0.25, 0, dc->colorWhite, idRectangle( rect.x() + rect.w(), rect.w() + rect.h() + 5, 100, 20 ), false );
343  dc->EnableClipping( true );
344  }
345 
346 }
347 
348 /*
349 ================
350 idWindow::BringToTop
351 ================
352 */
354 
355  if (w && !(w->flags & WIN_MODAL)) {
356  return;
357  }
358 
359  int c = children.Num();
360  for (int i = 0; i < c; i++) {
361  if (children[i] == w) {
362  // this is it move from i - 1 to 0 to i to 1 then shove this one into 0
363  for (int j = i+1; j < c; j++) {
364  children[j-1] = children[j];
365  }
366  children[c-1] = w;
367  break;
368  }
369  }
370 }
371 
372 /*
373 ================
374 idWindow::Size
375 ================
376 */
377 void idWindow::Size(float x, float y, float w, float h) {
378  idRectangle rct = rect;
379  rct.x = x;
380  rct.y = y;
381  rct.w = w;
382  rct.h = h;
383  rect = rct;
384  CalcClientRect(0,0);
385 }
386 
387 /*
388 ================
389 idWindow::MouseEnter
390 ================
391 */
393 
394  if (noEvents) {
395  return;
396  }
397 
399 }
400 
401 /*
402 ================
403 idWindow::MouseExit
404 ================
405 */
407 
408  if (noEvents) {
409  return;
410  }
411 
413 }
414 
415 
416 /*
417 ================
418 idWindow::RouteMouseCoords
419 ================
420 */
421 const char *idWindow::RouteMouseCoords(float xd, float yd) {
422  idStr str;
423  if (GetCaptureChild()) {
424  //FIXME: unkludge this whole mechanism
425  return GetCaptureChild()->RouteMouseCoords(xd, yd);
426  }
427 
428  if (xd == -2000 || yd == -2000) {
429  return "";
430  }
431 
432  int c = children.Num();
433  while (c > 0) {
434  idWindow *child = children[--c];
435  if (child->visible && !child->noEvents && child->Contains(child->drawRect, gui->CursorX(), gui->CursorY())) {
436 
437  dc->SetCursor(child->cursor);
438  child->hover = true;
439 
440  if (overChild != child) {
441  if (overChild) {
442  overChild->MouseExit();
443  str = overChild->cmd;
444  if (str.Length()) {
445  gui->GetDesktop()->AddCommand(str);
446  overChild->cmd = "";
447  }
448  }
449  overChild = child;
451  str = overChild->cmd;
452  if (str.Length()) {
453  gui->GetDesktop()->AddCommand(str);
454  overChild->cmd = "";
455  }
456  } else {
457  if (!(child->flags & WIN_HOLDCAPTURE)) {
458  child->RouteMouseCoords(xd, yd);
459  }
460  }
461  return "";
462  }
463  }
464  if (overChild) {
465  overChild->MouseExit();
466  str = overChild->cmd;
467  if (str.Length()) {
468  gui->GetDesktop()->AddCommand(str);
469  overChild->cmd = "";
470  }
471  overChild = NULL;
472  }
473  return "";
474 }
475 
476 /*
477 ================
478 idWindow::Activate
479 ================
480 */
481 void idWindow::Activate( bool activate, idStr &act ) {
482 
483  int n = (activate) ? ON_ACTIVATE : ON_DEACTIVATE;
484 
485  // make sure win vars are updated before activation
486  UpdateWinVars ( );
487 
488  RunScript(n);
489  int c = children.Num();
490  for (int i = 0; i < c; i++) {
491  children[i]->Activate( activate, act );
492  }
493 
494  if ( act.Length() ) {
495  act += " ; ";
496  }
497 }
498 
499 /*
500 ================
501 idWindow::Trigger
502 ================
503 */
506  int c = children.Num();
507  for ( int i = 0; i < c; i++ ) {
508  children[i]->Trigger();
509  }
510  StateChanged( true );
511 }
512 
513 /*
514 ================
515 idWindow::StateChanged
516 ================
517 */
518 void idWindow::StateChanged( bool redraw ) {
519 
520  UpdateWinVars();
521 
522  if (expressionRegisters.Num() && ops.Num()) {
523  EvalRegs();
524  }
525 
526  int c = drawWindows.Num();
527  for ( int i = 0; i < c; i++ ) {
528  if ( drawWindows[i].win ) {
529  drawWindows[i].win->StateChanged( redraw );
530  } else {
531  drawWindows[i].simp->StateChanged( redraw );
532  }
533  }
534 
535  if ( redraw ) {
536  if ( flags & WIN_DESKTOP ) {
537  Redraw( 0.0f, 0.0f );
538  }
539  if ( background && background->CinematicLength() ) {
541  }
542  }
543 }
544 
545 /*
546 ================
547 idWindow::SetCapture
548 ================
549 */
551  // only one child can have the focus
552 
553  idWindow *last = NULL;
554  int c = children.Num();
555  for (int i = 0; i < c; i++) {
556  if ( children[i]->flags & WIN_CAPTURE ) {
557  last = children[i];
558  //last->flags &= ~WIN_CAPTURE;
559  last->LoseCapture();
560  break;
561  }
562  }
563 
564  w->flags |= WIN_CAPTURE;
565  w->GainCapture();
567  return last;
568 }
569 
570 /*
571 ================
572 idWindow::AddUpdateVar
573 ================
574 */
576  updateVars.AddUnique(var);
577 }
578 
579 /*
580 ================
581 idWindow::UpdateWinVars
582 ================
583 */
585  int c = updateVars.Num();
586  for (int i = 0; i < c; i++) {
587  updateVars[i]->Update();
588  }
589 }
590 
591 /*
592 ================
593 idWindow::RunTimeEvents
594 ================
595 */
597 
598  if ( time - lastTimeRun < USERCMD_MSEC ) {
599  //common->Printf("Skipping gui time events at %i\n", time);
600  return false;
601  }
602 
603  lastTimeRun = time;
604 
605  UpdateWinVars();
606 
607  if (expressionRegisters.Num() && ops.Num()) {
608  EvalRegs();
609  }
610 
611  if ( flags & WIN_INTRANSITION ) {
612  Transition();
613  }
614 
615  Time();
616 
617  // renamed ON_EVENT to ON_FRAME
619 
620  int c = children.Num();
621  for (int i = 0; i < c; i++) {
622  children[i]->RunTimeEvents(time);
623  }
624 
625  return true;
626 }
627 
628 /*
629 ================
630 idWindow::RunNamedEvent
631 ================
632 */
633 void idWindow::RunNamedEvent ( const char* eventName )
634 {
635  int i;
636  int c;
637 
638  // Find and run the event
639  c = namedEvents.Num( );
640  for ( i = 0; i < c; i ++ ) {
641  if ( namedEvents[i]->mName.Icmp( eventName ) ) {
642  continue;
643  }
644 
645  UpdateWinVars();
646 
647  // Make sure we got all the current values for stuff
648  if (expressionRegisters.Num() && ops.Num()) {
649  EvalRegs(-1, true);
650  }
651 
652  RunScriptList( namedEvents[i]->mEvent );
653 
654  break;
655  }
656 
657  // Run the event in all the children as well
658  c = children.Num();
659  for ( i = 0; i < c; i++ ) {
660  children[i]->RunNamedEvent ( eventName );
661  }
662 }
663 
664 /*
665 ================
666 idWindow::Contains
667 ================
668 */
669 bool idWindow::Contains(const idRectangle &sr, float x, float y) {
670  idRectangle r = sr;
671  r.x += actualX - drawRect.x;
672  r.y += actualY - drawRect.y;
673  return r.Contains(x, y);
674 }
675 
676 /*
677 ================
678 idWindow::Contains
679 ================
680 */
681 bool idWindow::Contains(float x, float y) {
683  r.x = actualX;
684  r.y = actualY;
685  return r.Contains(x, y);
686 }
687 
688 /*
689 ================
690 idWindow::AddCommand
691 ================
692 */
693 void idWindow::AddCommand(const char *_cmd) {
694  idStr str = cmd;
695  if (str.Length()) {
696  str += " ; ";
697  str += _cmd;
698  } else {
699  str = _cmd;
700  }
701  cmd = str;
702 }
703 
704 /*
705 ================
706 idWindow::HandleEvent
707 ================
708 */
709 const char *idWindow::HandleEvent(const sysEvent_t *event, bool *updateVisuals) {
710  static bool actionDownRun;
711  static bool actionUpRun;
712 
713  cmd = "";
714 
715  if ( flags & WIN_DESKTOP ) {
716  actionDownRun = false;
717  actionUpRun = false;
718  if (expressionRegisters.Num() && ops.Num()) {
719  EvalRegs();
720  }
722  CalcRects(0,0);
724  }
725 
726  if (visible && !noEvents) {
727 
728  if (event->evType == SE_KEY) {
729  EvalRegs(-1, true);
730  if (updateVisuals) {
731  *updateVisuals = true;
732  }
733 
734  if (event->evValue == K_MOUSE1) {
735 
736  if (!event->evValue2 && GetCaptureChild()) {
739  return "";
740  }
741 
742  int c = children.Num();
743  while (--c >= 0) {
744  if (children[c]->visible && children[c]->Contains(children[c]->drawRect, gui->CursorX(), gui->CursorY()) && !(children[c]->noEvents)) {
745  idWindow *child = children[c];
746  if (event->evValue2) {
747  BringToTop(child);
748  SetFocus(child);
749  if (child->flags & WIN_HOLDCAPTURE) {
750  SetCapture(child);
751  }
752  }
753  if (child->Contains(child->clientRect, gui->CursorX(), gui->CursorY())) {
754  //if ((gui_edit.GetBool() && (child->flags & WIN_SELECTED)) || (!gui_edit.GetBool() && (child->flags & WIN_MOVABLE))) {
755  // SetCapture(child);
756  //}
757  SetFocus(child);
758  const char *childRet = child->HandleEvent(event, updateVisuals);
759  if (childRet && *childRet) {
760  return childRet;
761  }
762  if (child->flags & WIN_MODAL) {
763  return "";
764  }
765  } else {
766  if (event->evValue2) {
767  SetFocus(child);
768  bool capture = true;
769  if (capture && ((child->flags & WIN_MOVABLE) || gui_edit.GetBool())) {
770  SetCapture(child);
771  }
772  return "";
773  } else {
774  }
775  }
776  }
777  }
778  if (event->evValue2 && !actionDownRun) {
779  actionDownRun = RunScript( ON_ACTION );
780  } else if (!actionUpRun) {
781  actionUpRun = RunScript( ON_ACTIONRELEASE );
782  }
783  } else if (event->evValue == K_MOUSE2) {
784 
785  if (!event->evValue2 && GetCaptureChild()) {
788  return "";
789  }
790 
791  int c = children.Num();
792  while (--c >= 0) {
793  if (children[c]->visible && children[c]->Contains(children[c]->drawRect, gui->CursorX(), gui->CursorY()) && !(children[c]->noEvents)) {
794  idWindow *child = children[c];
795  if (event->evValue2) {
796  BringToTop(child);
797  SetFocus(child);
798  }
799  if (child->Contains(child->clientRect,gui->CursorX(), gui->CursorY()) || GetCaptureChild() == child) {
800  if ((gui_edit.GetBool() && (child->flags & WIN_SELECTED)) || (!gui_edit.GetBool() && (child->flags & WIN_MOVABLE))) {
801  SetCapture(child);
802  }
803  const char *childRet = child->HandleEvent(event, updateVisuals);
804  if (childRet && *childRet) {
805  return childRet;
806  }
807  if (child->flags & WIN_MODAL) {
808  return "";
809  }
810  }
811  }
812  }
813  } else if (event->evValue == K_MOUSE3) {
814  if (gui_edit.GetBool()) {
815  int c = children.Num();
816  for (int i = 0; i < c; i++) {
817  if (children[i]->drawRect.Contains(gui->CursorX(), gui->CursorY())) {
818  if (event->evValue2) {
819  children[i]->flags ^= WIN_SELECTED;
820  if (children[i]->flags & WIN_SELECTED) {
821  flags &= ~WIN_SELECTED;
822  return "childsel";
823  }
824  }
825  }
826  }
827  }
828  } else if (event->evValue == K_TAB && event->evValue2) {
829  if (GetFocusedChild()) {
830  const char *childRet = GetFocusedChild()->HandleEvent(event, updateVisuals);
831  if (childRet && *childRet) {
832  return childRet;
833  }
834 
835  // If the window didn't handle the tab, then move the focus to the next window
836  // or the previous window if shift is held down
837 
838  int direction = 1;
839  if ( idKeyInput::IsDown( K_SHIFT ) ) {
840  direction = -1;
841  }
842 
843  idWindow *currentFocus = GetFocusedChild();
844  idWindow *child = GetFocusedChild();
845  idWindow *parent = child->GetParent();
846  while ( parent ) {
847  bool foundFocus = false;
848  bool recurse = false;
849  int index = 0;
850  if ( child ) {
851  index = parent->GetChildIndex( child ) + direction;
852  } else if ( direction < 0 ) {
853  index = parent->GetChildCount() - 1;
854  }
855  while ( index < parent->GetChildCount() && index >= 0) {
856  idWindow *testWindow = parent->GetChild( index );
857  if ( testWindow == currentFocus ) {
858  // we managed to wrap around and get back to our starting window
859  foundFocus = true;
860  break;
861  }
862  if ( testWindow && !testWindow->noEvents && testWindow->visible ) {
863  if ( testWindow->flags & WIN_CANFOCUS ) {
864  SetFocus( testWindow );
865  foundFocus = true;
866  break;
867  } else if ( testWindow->GetChildCount() > 0 ) {
868  parent = testWindow;
869  child = NULL;
870  recurse = true;
871  break;
872  }
873  }
874  index += direction;
875  }
876  if ( foundFocus ) {
877  // We found a child to focus on
878  break;
879  } else if ( recurse ) {
880  // We found a child with children
881  continue;
882  } else {
883  // We didn't find anything, so go back up to our parent
884  child = parent;
885  parent = child->GetParent();
886  if ( parent == gui->GetDesktop() ) {
887  // We got back to the desktop, so wrap around but don't actually go to the desktop
888  parent = NULL;
889  child = NULL;
890  }
891  }
892  }
893  }
894  } else if (event->evValue == K_ESCAPE && event->evValue2) {
895  if (GetFocusedChild()) {
896  const char *childRet = GetFocusedChild()->HandleEvent(event, updateVisuals);
897  if (childRet && *childRet) {
898  return childRet;
899  }
900  }
901  RunScript( ON_ESC );
902  } else if (event->evValue == K_ENTER ) {
903  if (GetFocusedChild()) {
904  const char *childRet = GetFocusedChild()->HandleEvent(event, updateVisuals);
905  if (childRet && *childRet) {
906  return childRet;
907  }
908  }
909  if ( flags & WIN_WANTENTER ) {
910  if ( event->evValue2 ) {
911  RunScript( ON_ACTION );
912  } else {
914  }
915  }
916  } else {
917  if (GetFocusedChild()) {
918  const char *childRet = GetFocusedChild()->HandleEvent(event, updateVisuals);
919  if (childRet && *childRet) {
920  return childRet;
921  }
922  }
923  }
924 
925  } else if (event->evType == SE_MOUSE) {
926  if (updateVisuals) {
927  *updateVisuals = true;
928  }
929  const char *mouseRet = RouteMouseCoords(event->evValue, event->evValue2);
930  if (mouseRet && *mouseRet) {
931  return mouseRet;
932  }
933  } else if (event->evType == SE_NONE) {
934  } else if (event->evType == SE_CHAR) {
935  if (GetFocusedChild()) {
936  const char *childRet = GetFocusedChild()->HandleEvent(event, updateVisuals);
937  if (childRet && *childRet) {
938  return childRet;
939  }
940  }
941  }
942  }
943 
944  gui->GetReturnCmd() = cmd;
945  if ( gui->GetPendingCmd().Length() ) {
946  gui->GetReturnCmd() += " ; ";
948  gui->GetPendingCmd().Clear();
949  }
950  cmd = "";
951  return gui->GetReturnCmd();
952 }
953 
954 /*
955 ================
956 idWindow::DebugDraw
957 ================
958 */
959 void idWindow::DebugDraw(int time, float x, float y) {
960  static char buff[16384];
961  if (dc) {
962  dc->EnableClipping(false);
963  if (gui_debug.GetInteger() == 1) {
965  } else if (gui_debug.GetInteger() == 2) {
966  char out[1024];
967  idStr str;
968  str = text.c_str();
969 
970  if (str.Length()) {
971  sprintf(buff, "%s\n", str.c_str());
972  }
973 
974  sprintf(out, "Rect: %0.1f, %0.1f, %0.1f, %0.1f\n", rect.x(), rect.y(), rect.w(), rect.h());
975  strcat(buff, out);
976  sprintf(out, "Draw Rect: %0.1f, %0.1f, %0.1f, %0.1f\n", drawRect.x, drawRect.y, drawRect.w, drawRect.h);
977  strcat(buff, out);
978  sprintf(out, "Client Rect: %0.1f, %0.1f, %0.1f, %0.1f\n", clientRect.x, clientRect.y, clientRect.w, clientRect.h);
979  strcat(buff, out);
980  sprintf(out, "Cursor: %0.1f : %0.1f\n", gui->CursorX(), gui->CursorY());
981  strcat(buff, out);
982 
983 
984  //idRectangle tempRect = textRect;
985  //tempRect.x += offsetX;
986  //drawRect.y += offsetY;
987  dc->DrawText(buff, textScale, textAlign, foreColor, textRect, true);
988  }
989  dc->EnableClipping(true);
990  }
991 }
992 
993 /*
994 ================
995 idWindow::Transition
996 ================
997 */
999  int i, c = transitions.Num();
1000  bool clear = true;
1001 
1002  for ( i = 0; i < c; i++ ) {
1004  idWinRectangle *r = NULL;
1005  idWinVec4 *v4 = dynamic_cast<idWinVec4*>(data->data);
1006  idWinFloat* val = NULL;
1007  if (v4 == NULL) {
1008  r = dynamic_cast<idWinRectangle*>(data->data);
1009  if ( !r ) {
1010  val = dynamic_cast<idWinFloat*>(data->data);
1011  }
1012  }
1013  if ( data->interp.IsDone( gui->GetTime() ) && data->data) {
1014  if (v4) {
1015  *v4 = data->interp.GetEndValue();
1016  } else if ( val ) {
1017  *val = data->interp.GetEndValue()[0];
1018  } else {
1019  *r = data->interp.GetEndValue();
1020  }
1021  } else {
1022  clear = false;
1023  if (data->data) {
1024  if (v4) {
1025  *v4 = data->interp.GetCurrentValue( gui->GetTime() );
1026  } else if ( val ) {
1027  *val = data->interp.GetCurrentValue( gui->GetTime() )[0];
1028  } else {
1029  *r = data->interp.GetCurrentValue( gui->GetTime() );
1030  }
1031  } else {
1032  common->Warning("Invalid transitional data for window %s in gui %s", GetName(), gui->GetSourceFile());
1033  }
1034  }
1035  }
1036 
1037  if ( clear ) {
1038  transitions.SetNum( 0, false );
1039  flags &= ~WIN_INTRANSITION;
1040  }
1041 }
1042 
1043 /*
1044 ================
1045 idWindow::Time
1046 ================
1047 */
1049 
1050  if ( noTime ) {
1051  return;
1052  }
1053 
1054  if ( timeLine == -1 ) {
1055  timeLine = gui->GetTime();
1056  }
1057 
1058  cmd = "";
1059 
1060  int c = timeLineEvents.Num();
1061  if ( c > 0 ) {
1062  for (int i = 0; i < c; i++) {
1063  if ( timeLineEvents[i]->pending && gui->GetTime() - timeLine >= timeLineEvents[i]->time ) {
1064  timeLineEvents[i]->pending = false;
1065  RunScriptList( timeLineEvents[i]->event );
1066  }
1067  }
1068  }
1069  if ( gui->Active() ) {
1070  gui->GetPendingCmd() += cmd;
1071  }
1072 }
1073 
1074 /*
1075 ================
1076 idWindow::EvalRegs
1077 ================
1078 */
1079 float idWindow::EvalRegs(int test, bool force) {
1080  static float regs[MAX_EXPRESSION_REGISTERS];
1081  static idWindow *lastEval = NULL;
1082 
1083  if (!force && test >= 0 && test < MAX_EXPRESSION_REGISTERS && lastEval == this) {
1084  return regs[test];
1085  }
1086 
1087  lastEval = this;
1088 
1089  if (expressionRegisters.Num()) {
1090  regList.SetToRegs(regs);
1091  EvaluateRegisters(regs);
1092  regList.GetFromRegs(regs);
1093  }
1094 
1095  if (test >= 0 && test < MAX_EXPRESSION_REGISTERS) {
1096  return regs[test];
1097  }
1098 
1099  return 0.0;
1100 }
1101 
1102 /*
1103 ================
1104 idWindow::DrawBackground
1105 ================
1106 */
1107 void idWindow::DrawBackground(const idRectangle &drawRect) {
1108  if ( backColor.w() ) {
1109  dc->DrawFilledRect(drawRect.x, drawRect.y, drawRect.w, drawRect.h, backColor);
1110  }
1111 
1112  if ( background && matColor.w() ) {
1113  float scalex, scaley;
1114  if ( flags & WIN_NATURALMAT ) {
1115  scalex = drawRect.w / background->GetImageWidth();
1116  scaley = drawRect.h / background->GetImageHeight();
1117  } else {
1118  scalex = matScalex;
1119  scaley = matScaley;
1120  }
1121  dc->DrawMaterial(drawRect.x, drawRect.y, drawRect.w, drawRect.h, background, matColor, scalex, scaley);
1122  }
1123 }
1124 
1125 /*
1126 ================
1127 idWindow::DrawBorderAndCaption
1128 ================
1129 */
1131  if ( flags & WIN_BORDER && borderSize && borderColor.w() ) {
1132  dc->DrawRect(drawRect.x, drawRect.y, drawRect.w, drawRect.h, borderSize, borderColor);
1133  }
1134 }
1135 
1136 /*
1137 ================
1138 idWindow::SetupTransforms
1139 ================
1140 */
1141 void idWindow::SetupTransforms(float x, float y) {
1142  static idMat3 trans;
1143  static idVec3 org;
1144 
1145  trans.Identity();
1146  org.Set( origin.x + x, origin.y + y, 0 );
1147 
1148  if ( rotate ) {
1149  static idRotation rot;
1150  static idVec3 vec(0, 0, 1);
1151  rot.Set( org, vec, rotate );
1152  trans = rot.ToMat3();
1153  }
1154 
1155  if ( shear.x || shear.y ) {
1156  static idMat3 smat;
1157  smat.Identity();
1158  smat[0][1] = shear.x;
1159  smat[1][0] = shear.y;
1160  trans *= smat;
1161  }
1162 
1163  if ( !trans.IsIdentity() ) {
1164  dc->SetTransformInfo( org, trans );
1165  }
1166 }
1167 
1168 /*
1169 ================
1170 idWindow::CalcRects
1171 ================
1172 */
1173 void idWindow::CalcRects(float x, float y) {
1174  CalcClientRect(0, 0);
1175  drawRect.Offset(x, y);
1176  clientRect.Offset(x, y);
1177  actualX = drawRect.x;
1178  actualY = drawRect.y;
1179  int c = drawWindows.Num();
1180  for (int i = 0; i < c; i++) {
1181  if (drawWindows[i].win) {
1182  drawWindows[i].win->CalcRects(clientRect.x + xOffset, clientRect.y + yOffset);
1183  }
1184  }
1185  drawRect.Offset(-x, -y);
1186  clientRect.Offset(-x, -y);
1187 }
1188 
1189 /*
1190 ================
1191 idWindow::Redraw
1192 ================
1193 */
1194 void idWindow::Redraw(float x, float y) {
1195  idStr str;
1196 
1197  if (r_skipGuiShaders.GetInteger() == 1 || dc == NULL ) {
1198  return;
1199  }
1200 
1201  int time = gui->GetTime();
1202 
1203  if ( flags & WIN_DESKTOP && r_skipGuiShaders.GetInteger() != 3 ) {
1204  RunTimeEvents( time );
1205  }
1206 
1207  if ( r_skipGuiShaders.GetInteger() == 2 ) {
1208  return;
1209  }
1210 
1211  if ( flags & WIN_SHOWTIME ) {
1212  dc->DrawText(va(" %0.1f seconds\n%s", (float)(time - timeLine) / 1000, gui->State().GetString("name")), 0.35f, 0, dc->colorWhite, idRectangle(100, 0, 80, 80), false);
1213  }
1214 
1215  if ( flags & WIN_SHOWCOORDS ) {
1216  dc->EnableClipping(false);
1217  sprintf(str, "x: %i y: %i cursorx: %i cursory: %i", (int)rect.x(), (int)rect.y(), (int)gui->CursorX(), (int)gui->CursorY());
1218  dc->DrawText(str, 0.25f, 0, dc->colorWhite, idRectangle(0, 0, 100, 20), false);
1219  dc->EnableClipping(true);
1220  }
1221 
1222  if (!visible) {
1223  return;
1224  }
1225 
1226  CalcClientRect(0, 0);
1227 
1228  SetFont();
1229  //if (flags & WIN_DESKTOP) {
1230  // see if this window forces a new aspect ratio
1232  //}
1233 
1234  //FIXME: go to screen coord tracking
1235  drawRect.Offset(x, y);
1236  clientRect.Offset(x, y);
1237  textRect.Offset(x, y);
1238  actualX = drawRect.x;
1239  actualY = drawRect.y;
1240 
1241  idVec3 oldOrg;
1242  idMat3 oldTrans;
1243 
1244  dc->GetTransformInfo( oldOrg, oldTrans );
1245 
1246  SetupTransforms(x, y);
1249 
1250  if ( !( flags & WIN_NOCLIP) ) {
1252  }
1253 
1254  if ( r_skipGuiShaders.GetInteger() < 5 ) {
1255  Draw(time, x, y);
1256  }
1257 
1258  if ( gui_debug.GetInteger() ) {
1259  DebugDraw(time, x, y);
1260  }
1261 
1262  int c = drawWindows.Num();
1263  for ( int i = 0; i < c; i++ ) {
1264  if ( drawWindows[i].win ) {
1265  drawWindows[i].win->Redraw( clientRect.x + xOffset, clientRect.y + yOffset );
1266  } else {
1267  drawWindows[i].simp->Redraw( clientRect.x + xOffset, clientRect.y + yOffset );
1268  }
1269  }
1270 
1271  // Put transforms back to what they were before the children were processed
1272  dc->SetTransformInfo(oldOrg, oldTrans);
1273 
1274  if ( ! ( flags & WIN_NOCLIP ) ) {
1275  dc->PopClipRect();
1276  }
1277 
1278  if (gui_edit.GetBool() || (flags & WIN_DESKTOP && !( flags & WIN_NOCURSOR ) && !hideCursor && (gui->Active() || ( flags & WIN_MENUGUI ) ))) {
1280  gui->DrawCursor();
1281  }
1282 
1283  if (gui_debug.GetInteger() && flags & WIN_DESKTOP) {
1284  dc->EnableClipping(false);
1285  sprintf(str, "x: %1.f y: %1.f", gui->CursorX(), gui->CursorY());
1286  dc->DrawText(str, 0.25, 0, dc->colorWhite, idRectangle(0, 0, 100, 20), false);
1287  dc->DrawText(gui->GetSourceFile(), 0.25, 0, dc->colorWhite, idRectangle(0, 20, 300, 20), false);
1288  dc->EnableClipping(true);
1289  }
1290 
1291  drawRect.Offset(-x, -y);
1292  clientRect.Offset(-x, -y);
1293  textRect.Offset(-x, -y);
1294 }
1295 
1296 /*
1297 ================
1298 idWindow::SetDC
1299 ================
1300 */
1302  dc = d;
1303  //if (flags & WIN_DESKTOP) {
1305  //}
1306  int c = children.Num();
1307  for (int i = 0; i < c; i++) {
1308  children[i]->SetDC(d);
1309  }
1310 }
1311 
1312 /*
1313 ================
1314 idWindow::ArchiveToDictionary
1315 ================
1316 */
1317 void idWindow::ArchiveToDictionary(idDict *dict, bool useNames) {
1318  //FIXME: rewrite without state
1319  int c = children.Num();
1320  for (int i = 0; i < c; i++) {
1321  children[i]->ArchiveToDictionary(dict);
1322  }
1323 }
1324 
1325 /*
1326 ================
1327 idWindow::InitFromDictionary
1328 ================
1329 */
1330 void idWindow::InitFromDictionary(idDict *dict, bool byName) {
1331  //FIXME: rewrite without state
1332  int c = children.Num();
1333  for (int i = 0; i < c; i++) {
1334  children[i]->InitFromDictionary(dict);
1335  }
1336 }
1337 
1338 /*
1339 ================
1340 idWindow::CalcClientRect
1341 ================
1342 */
1343 void idWindow::CalcClientRect(float xofs, float yofs) {
1344  drawRect = rect;
1345 
1346  if ( flags & WIN_INVERTRECT ) {
1347  drawRect.x = rect.x() - rect.w();
1348  drawRect.y = rect.y() - rect.h();
1349  }
1350 
1351  if (flags & (WIN_HCENTER | WIN_VCENTER) && parent) {
1352  // in this case treat xofs and yofs as absolute top left coords
1353  // and ignore the original positioning
1354  if (flags & WIN_HCENTER) {
1355  drawRect.x = (parent->rect.w() - rect.w()) / 2;
1356  } else {
1357  drawRect.y = (parent->rect.h() - rect.h()) / 2;
1358  }
1359  }
1360 
1361  drawRect.x += xofs;
1362  drawRect.y += yofs;
1363 
1364  clientRect = drawRect;
1365  if (rect.h() > 0.0 && rect.w() > 0.0) {
1366 
1367  if (flags & WIN_BORDER && borderSize != 0.0) {
1368  clientRect.x += borderSize;
1369  clientRect.y += borderSize;
1370  clientRect.w -= borderSize;
1371  clientRect.h -= borderSize;
1372  }
1373 
1374  textRect = clientRect;
1375  textRect.x += 2.0;
1376  textRect.w -= 2.0;
1377  textRect.y += 2.0;
1378  textRect.h -= 2.0;
1379 
1380  textRect.x += textAlignx;
1381  textRect.y += textAligny;
1382 
1383  }
1384  origin.Set( rect.x() + (rect.w() / 2 ), rect.y() + ( rect.h() / 2 ) );
1385 
1386 }
1387 
1388 /*
1389 ================
1390 idWindow::SetupBackground
1391 ================
1392 */
1394  if (backGroundName.Length()) {
1396  background->SetImageClassifications( 1 ); // just for resource tracking
1399  }
1400  }
1402 }
1403 
1404 /*
1405 ================
1406 idWindow::SetupFromState
1407 ================
1408 */
1410  idStr str;
1411  background = NULL;
1412 
1413  SetupBackground();
1414 
1415  if (borderSize) {
1416  flags |= WIN_BORDER;
1417  }
1418 
1419  if (regList.FindReg("rotate") || regList.FindReg("shear")) {
1420  flags |= WIN_TRANSFORM;
1421  }
1422 
1423  CalcClientRect(0,0);
1424  if ( scripts[ ON_ACTION ] ) {
1426  flags |= WIN_CANFOCUS;
1427  }
1428 }
1429 
1430 /*
1431 ================
1432 idWindow::Moved
1433 ================
1434 */
1436 }
1437 
1438 /*
1439 ================
1440 idWindow::Sized
1441 ================
1442 */
1444 }
1445 
1446 /*
1447 ================
1448 idWindow::GainFocus
1449 ================
1450 */
1452 }
1453 
1454 /*
1455 ================
1456 idWindow::LoseFocus
1457 ================
1458 */
1460 }
1461 
1462 /*
1463 ================
1464 idWindow::GainCapture
1465 ================
1466 */
1468 }
1469 
1470 /*
1471 ================
1472 idWindow::LoseCapture
1473 ================
1474 */
1476  flags &= ~WIN_CAPTURE;
1477 }
1478 
1479 /*
1480 ================
1481 idWindow::SetFlag
1482 ================
1483 */
1484 void idWindow::SetFlag(unsigned int f) {
1485  flags |= f;
1486 }
1487 
1488 /*
1489 ================
1490 idWindow::ClearFlag
1491 ================
1492 */
1493 void idWindow::ClearFlag(unsigned int f) {
1494  flags &= ~f;
1495 }
1496 
1497 
1498 /*
1499 ================
1500 idWindow::SetParent
1501 ================
1502 */
1504  parent = w;
1505 }
1506 
1507 /*
1508 ================
1509 idWindow::GetCaptureChild
1510 ================
1511 */
1513  if (flags & WIN_DESKTOP) {
1514  return gui->GetDesktop()->captureChild;
1515  }
1516  return NULL;
1517 }
1518 
1519 /*
1520 ================
1521 idWindow::GetFocusedChild
1522 ================
1523 */
1525  if (flags & WIN_DESKTOP) {
1526  return gui->GetDesktop()->focusedChild;
1527  }
1528  return NULL;
1529 }
1530 
1531 
1532 /*
1533 ================
1534 idWindow::SetFocus
1535 ================
1536 */
1538  // only one child can have the focus
1539  idWindow *lastFocus = NULL;
1540  if (w->flags & WIN_CANFOCUS) {
1541  lastFocus = gui->GetDesktop()->focusedChild;
1542  if ( lastFocus ) {
1543  lastFocus->flags &= ~WIN_FOCUS;
1544  lastFocus->LoseFocus();
1545  }
1546 
1547  // call on lose focus
1548  if ( scripts && lastFocus ) {
1549  // calling this broke all sorts of guis
1550  // lastFocus->RunScript(ON_MOUSEEXIT);
1551  }
1552  // call on gain focus
1553  if ( scripts && w ) {
1554  // calling this broke all sorts of guis
1555  // w->RunScript(ON_MOUSEENTER);
1556  }
1557 
1558  w->flags |= WIN_FOCUS;
1559  w->GainFocus();
1560  gui->GetDesktop()->focusedChild = w;
1561  }
1562 
1563  return lastFocus;
1564 }
1565 
1566 /*
1567 ================
1568 idWindow::ParseScript
1569 ================
1570 */
1571 bool idWindow::ParseScript(idParser *src, idGuiScriptList &list, int *timeParm, bool elseBlock ) {
1572 
1573  bool ifElseBlock = false;
1574 
1575  idToken token;
1576 
1577  // scripts start with { ( unless parm is true ) and have ; separated command lists.. commands are command,
1578  // arg.. basically we want everything between the { } as it will be interpreted at
1579  // run time
1580 
1581  if ( elseBlock ) {
1582  src->ReadToken ( &token );
1583 
1584  if ( !token.Icmp ( "if" ) ) {
1585  ifElseBlock = true;
1586  }
1587 
1588  src->UnreadToken ( &token );
1589 
1590  if ( !ifElseBlock && !src->ExpectTokenString( "{" ) ) {
1591  return false;
1592  }
1593  }
1594  else if ( !src->ExpectTokenString( "{" ) ) {
1595  return false;
1596  }
1597 
1598  int nest = 0;
1599 
1600  while (1) {
1601  if ( !src->ReadToken(&token) ) {
1602  src->Error( "Unexpected end of file" );
1603  return false;
1604  }
1605 
1606  if ( token == "{" ) {
1607  nest++;
1608  }
1609 
1610  if ( token == "}" ) {
1611  if (nest-- <= 0) {
1612  return true;
1613  }
1614  }
1615 
1616  idGuiScript *gs = new idGuiScript();
1617  if (token.Icmp("if") == 0) {
1618  gs->conditionReg = ParseExpression(src);
1619  gs->ifList = new idGuiScriptList();
1620  ParseScript(src, *gs->ifList, NULL);
1621  if (src->ReadToken(&token)) {
1622  if (token == "else") {
1623  gs->elseList = new idGuiScriptList();
1624  // pass true to indicate we are parsing an else condition
1625  ParseScript(src, *gs->elseList, NULL, true );
1626  } else {
1627  src->UnreadToken(&token);
1628  }
1629  }
1630 
1631  list.Append(gs);
1632 
1633  // if we are parsing an else if then return out so
1634  // the initial "if" parser can handle the rest of the tokens
1635  if ( ifElseBlock ) {
1636  return true;
1637  }
1638  continue;
1639  } else {
1640  src->UnreadToken(&token);
1641  }
1642 
1643  // empty { } is not allowed
1644  if ( token == "{" ) {
1645  src->Error ( "Unexpected {" );
1646  delete gs;
1647  return false;
1648  }
1649 
1650  gs->Parse(src);
1651  list.Append(gs);
1652  }
1653 
1654 }
1655 
1656 /*
1657 ================
1658 idWindow::SaveExpressionParseState
1659 ================
1660 */
1662  saveTemps = (bool*)Mem_Alloc(MAX_EXPRESSION_REGISTERS * sizeof(bool));
1663  memcpy(saveTemps, registerIsTemporary, MAX_EXPRESSION_REGISTERS * sizeof(bool));
1664 }
1665 
1666 /*
1667 ================
1668 idWindow::RestoreExpressionParseState
1669 ================
1670 */
1672  memcpy(registerIsTemporary, saveTemps, MAX_EXPRESSION_REGISTERS * sizeof(bool));
1674 }
1675 
1676 /*
1677 ================
1678 idWindow::ParseScriptEntry
1679 ================
1680 */
1682  for (int i = 0; i < SCRIPT_COUNT; i++) {
1683  if (idStr::Icmp(name, ScriptNames[i]) == 0) {
1684  delete scripts[i];
1685  scripts[i] = new idGuiScriptList;
1686  return ParseScript(src, *scripts[i]);
1687  }
1688  }
1689  return false;
1690 }
1691 
1692 /*
1693 ================
1694 idWindow::DisableRegister
1695 ================
1696 */
1697 void idWindow::DisableRegister(const char *_name) {
1698  idRegister *reg = RegList()->FindReg(_name);
1699  if (reg) {
1700  reg->Enable(false);
1701  }
1702 }
1703 
1704 /*
1705 ================
1706 idWindow::PostParse
1707 ================
1708 */
1710 }
1711 
1712 /*
1713 ================
1714 idWindow::GetWinVarOffset
1715 ================
1716 */
1718  int ret = -1;
1719 
1720  if ( wv == &rect ) {
1721  ret = (int)&( ( idWindow * ) 0 )->rect;
1722  }
1723 
1724  if ( wv == &backColor ) {
1725  ret = (int)&( ( idWindow * ) 0 )->backColor;
1726  }
1727 
1728  if ( wv == &matColor ) {
1729  ret = (int)&( ( idWindow * ) 0 )->matColor;
1730  }
1731 
1732  if ( wv == &foreColor ) {
1733  ret = (int)&( ( idWindow * ) 0 )->foreColor;
1734  }
1735 
1736  if ( wv == &hoverColor ) {
1737  ret = (int)&( ( idWindow * ) 0 )->hoverColor;
1738  }
1739 
1740  if ( wv == &borderColor ) {
1741  ret = (int)&( ( idWindow * ) 0 )->borderColor;
1742  }
1743 
1744  if ( wv == &textScale ) {
1745  ret = (int)&( ( idWindow * ) 0 )->textScale;
1746  }
1747 
1748  if ( wv == &rotate ) {
1749  ret = (int)&( ( idWindow * ) 0 )->rotate;
1750  }
1751 
1752  if ( ret != -1 ) {
1753  owner->win = this;
1754  return ret;
1755  }
1756 
1757  for ( int i = 0; i < drawWindows.Num(); i++ ) {
1758  if ( drawWindows[i].win ) {
1759  ret = drawWindows[i].win->GetWinVarOffset( wv, owner );
1760  } else {
1761  ret = drawWindows[i].simp->GetWinVarOffset( wv, owner );
1762  }
1763  if ( ret != -1 ) {
1764  break;
1765  }
1766  }
1767 
1768  return ret;
1769 }
1770 
1771 /*
1772 ================
1773 idWindow::GetWinVarByName
1774 ================
1775 */
1776 idWinVar *idWindow::GetWinVarByName(const char *_name, bool fixup, drawWin_t** owner) {
1777  idWinVar *retVar = NULL;
1778 
1779  if ( owner ) {
1780  *owner = NULL;
1781  }
1782 
1783  if (idStr::Icmp(_name, "notime") == 0) {
1784  retVar = &noTime;
1785  }
1786  if (idStr::Icmp(_name, "background") == 0) {
1787  retVar = &backGroundName;
1788  }
1789  if (idStr::Icmp(_name, "visible") == 0) {
1790  retVar = &visible;
1791  }
1792  if (idStr::Icmp(_name, "rect") == 0) {
1793  retVar = &rect;
1794  }
1795  if (idStr::Icmp(_name, "backColor") == 0) {
1796  retVar = &backColor;
1797  }
1798  if (idStr::Icmp(_name, "matColor") == 0) {
1799  retVar = &matColor;
1800  }
1801  if (idStr::Icmp(_name, "foreColor") == 0) {
1802  retVar = &foreColor;
1803  }
1804  if (idStr::Icmp(_name, "hoverColor") == 0) {
1805  retVar = &hoverColor;
1806  }
1807  if (idStr::Icmp(_name, "borderColor") == 0) {
1808  retVar = &borderColor;
1809  }
1810  if (idStr::Icmp(_name, "textScale") == 0) {
1811  retVar = &textScale;
1812  }
1813  if (idStr::Icmp(_name, "rotate") == 0) {
1814  retVar = &rotate;
1815  }
1816  if (idStr::Icmp(_name, "noEvents") == 0) {
1817  retVar = &noEvents;
1818  }
1819  if (idStr::Icmp(_name, "text") == 0) {
1820  retVar = &text;
1821  }
1822  if (idStr::Icmp(_name, "backGroundName") == 0) {
1823  retVar = &backGroundName;
1824  }
1825  if (idStr::Icmp(_name, "hidecursor") == 0) {
1826  retVar = &hideCursor;
1827  }
1828 
1829  idStr key = _name;
1830  bool guiVar = (key.Find(VAR_GUIPREFIX) >= 0);
1831  int c = definedVars.Num();
1832  for (int i = 0; i < c; i++) {
1833  if (idStr::Icmp(_name, (guiVar) ? va("%s",definedVars[i]->GetName()) : definedVars[i]->GetName()) == 0) {
1834  retVar = definedVars[i];
1835  break;
1836  }
1837  }
1838 
1839  if (retVar) {
1840  if (fixup && *_name != '$') {
1841  DisableRegister(_name);
1842  }
1843 
1844  if ( owner && parent ) {
1845  *owner = parent->FindChildByName ( name );
1846  }
1847 
1848  return retVar;
1849  }
1850 
1851  int len = key.Length();
1852  if ( len > 5 && guiVar ) {
1853  idWinVar *var = new idWinStr;
1854  var->Init(_name, this);
1855  definedVars.Append(var);
1856  return var;
1857  } else if (fixup) {
1858  int n = key.Find("::");
1859  if (n > 0) {
1860  idStr winName = key.Left(n);
1861  idStr var = key.Right(key.Length() - n - 2);
1862  drawWin_t *win = GetGui()->GetDesktop()->FindChildByName(winName);
1863  if (win) {
1864  if (win->win) {
1865  return win->win->GetWinVarByName(var, false, owner);
1866  } else {
1867  if ( owner ) {
1868  *owner = win;
1869  }
1870  return win->simp->GetWinVarByName(var);
1871  }
1872  }
1873  }
1874  }
1875  return NULL;
1876 }
1877 
1878 /*
1879 ================
1880 idWindow::ParseString
1881 ================
1882 */
1884  idToken tok;
1885  if (src->ReadToken(&tok)) {
1886  out = tok;
1887  }
1888 }
1889 
1890 /*
1891 ================
1892 idWindow::ParseVec4
1893 ================
1894 */
1896  idToken tok;
1897  src->ReadToken(&tok);
1898  out.x = atof(tok);
1899  src->ExpectTokenString(",");
1900  src->ReadToken(&tok);
1901  out.y = atof(tok);
1902  src->ExpectTokenString(",");
1903  src->ReadToken(&tok);
1904  out.z = atof(tok);
1905  src->ExpectTokenString(",");
1906  src->ReadToken(&tok);
1907  out.w = atof(tok);
1908 }
1909 
1910 /*
1911 ================
1912 idWindow::ParseInternalVar
1913 ================
1914 */
1915 bool idWindow::ParseInternalVar(const char *_name, idParser *src) {
1916 
1917  if (idStr::Icmp(_name, "showtime") == 0) {
1918  if ( src->ParseBool() ) {
1919  flags |= WIN_SHOWTIME;
1920  }
1921  return true;
1922  }
1923  if (idStr::Icmp(_name, "showcoords") == 0) {
1924  if ( src->ParseBool() ) {
1925  flags |= WIN_SHOWCOORDS;
1926  }
1927  return true;
1928  }
1929  if (idStr::Icmp(_name, "forceaspectwidth") == 0) {
1930  forceAspectWidth = src->ParseFloat();
1931  return true;
1932  }
1933  if (idStr::Icmp(_name, "forceaspectheight") == 0) {
1934  forceAspectHeight = src->ParseFloat();
1935  return true;
1936  }
1937  if (idStr::Icmp(_name, "matscalex") == 0) {
1938  matScalex = src->ParseFloat();
1939  return true;
1940  }
1941  if (idStr::Icmp(_name, "matscaley") == 0) {
1942  matScaley = src->ParseFloat();
1943  return true;
1944  }
1945  if (idStr::Icmp(_name, "bordersize") == 0) {
1946  borderSize = src->ParseFloat();
1947  return true;
1948  }
1949  if (idStr::Icmp(_name, "nowrap") == 0) {
1950  if ( src->ParseBool() ) {
1951  flags |= WIN_NOWRAP;
1952  }
1953  return true;
1954  }
1955  if (idStr::Icmp(_name, "shadow") == 0) {
1956  textShadow = src->ParseInt();
1957  return true;
1958  }
1959  if (idStr::Icmp(_name, "textalign") == 0) {
1960  textAlign = src->ParseInt();
1961  return true;
1962  }
1963  if (idStr::Icmp(_name, "textalignx") == 0) {
1964  textAlignx = src->ParseFloat();
1965  return true;
1966  }
1967  if (idStr::Icmp(_name, "textaligny") == 0) {
1968  textAligny = src->ParseFloat();
1969  return true;
1970  }
1971  if (idStr::Icmp(_name, "shear") == 0) {
1972  shear.x = src->ParseFloat();
1973  idToken tok;
1974  src->ReadToken( &tok );
1975  if ( tok.Icmp( "," ) ) {
1976  src->Error( "Expected comma in shear definiation" );
1977  return false;
1978  }
1979  shear.y = src->ParseFloat();
1980  return true;
1981  }
1982  if (idStr::Icmp(_name, "wantenter") == 0) {
1983  if ( src->ParseBool() ) {
1984  flags |= WIN_WANTENTER;
1985  }
1986  return true;
1987  }
1988  if (idStr::Icmp(_name, "naturalmatscale") == 0) {
1989  if ( src->ParseBool() ) {
1990  flags |= WIN_NATURALMAT;
1991  }
1992  return true;
1993  }
1994  if (idStr::Icmp(_name, "noclip") == 0) {
1995  if ( src->ParseBool() ) {
1996  flags |= WIN_NOCLIP;
1997  }
1998  return true;
1999  }
2000  if (idStr::Icmp(_name, "nocursor") == 0) {
2001  if ( src->ParseBool() ) {
2002  flags |= WIN_NOCURSOR;
2003  }
2004  return true;
2005  }
2006  if (idStr::Icmp(_name, "menugui") == 0) {
2007  if ( src->ParseBool() ) {
2008  flags |= WIN_MENUGUI;
2009  }
2010  return true;
2011  }
2012  if (idStr::Icmp(_name, "modal") == 0) {
2013  if ( src->ParseBool() ) {
2014  flags |= WIN_MODAL;
2015  }
2016  return true;
2017  }
2018  if (idStr::Icmp(_name, "invertrect") == 0) {
2019  if ( src->ParseBool() ) {
2020  flags |= WIN_INVERTRECT;
2021  }
2022  return true;
2023  }
2024  if (idStr::Icmp(_name, "name") == 0) {
2025  ParseString(src, name);
2026  return true;
2027  }
2028  if (idStr::Icmp(_name, "play") == 0) {
2029  common->Warning( "play encountered during gui parse.. see Robert\n" );
2030  idStr playStr;
2031  ParseString(src, playStr);
2032  return true;
2033  }
2034  if (idStr::Icmp(_name, "comment") == 0) {
2035  ParseString(src, comment);
2036  return true;
2037  }
2038  if ( idStr::Icmp( _name, "font" ) == 0 ) {
2039  idStr fontStr;
2040  ParseString( src, fontStr );
2041  fontNum = dc->FindFont( fontStr );
2042  return true;
2043  }
2044  return false;
2045 }
2046 
2047 /*
2048 ================
2049 idWindow::ParseRegEntry
2050 ================
2051 */
2053  idStr work;
2054  work = name;
2055  work.ToLower();
2056 
2057  idWinVar *var = GetWinVarByName(work, NULL);
2058  if ( var ) {
2059  for (int i = 0; i < NumRegisterVars; i++) {
2060  if (idStr::Icmp(work, RegisterVars[i].name) == 0) {
2061  regList.AddReg(work, RegisterVars[i].type, src, this, var);
2062  return true;
2063  }
2064  }
2065  }
2066 
2067  // not predefined so just read the next token and add it to the state
2068  idToken tok;
2069  idVec4 v;
2070  idWinInt *vari;
2071  idWinFloat *varf;
2072  idWinStr *vars;
2073  if (src->ReadToken(&tok)) {
2074  if (var) {
2075  var->Set(tok);
2076  return true;
2077  }
2078  switch (tok.type) {
2079  case TT_NUMBER :
2080  if (tok.subtype & TT_INTEGER) {
2081  vari = new idWinInt();
2082  *vari = atoi(tok);
2083  vari->SetName(work);
2084  definedVars.Append(vari);
2085  } else if (tok.subtype & TT_FLOAT) {
2086  varf = new idWinFloat();
2087  *varf = atof(tok);
2088  varf->SetName(work);
2089  definedVars.Append(varf);
2090  } else {
2091  vars = new idWinStr();
2092  *vars = tok;
2093  vars->SetName(work);
2094  definedVars.Append(vars);
2095  }
2096  break;
2097  default :
2098  vars = new idWinStr();
2099  *vars = tok;
2100  vars->SetName(work);
2101  definedVars.Append(vars);
2102  break;
2103  }
2104  }
2105 
2106  return true;
2107 }
2108 
2109 /*
2110 ================
2111 idWindow::SetInitialState
2112 ================
2113 */
2114 void idWindow::SetInitialState(const char *_name) {
2115  name = _name;
2116  matScalex = 1.0;
2117  matScaley = 1.0;
2118  forceAspectWidth = 640.0;
2119  forceAspectHeight = 480.0;
2120  noTime = false;
2121  visible = true;
2122  flags = 0;
2123 }
2124 
2125 /*
2126 ================
2127 idWindow::Parse
2128 ================
2129 */
2130 bool idWindow::Parse( idParser *src, bool rebuild) {
2131  idToken token, token2, token3, token4, token5, token6, token7;
2132  idStr work;
2133 
2134  if (rebuild) {
2135  CleanUp();
2136  }
2137 
2138  drawWin_t dwt;
2139 
2141  transitions.Clear();
2142 
2143  namedEvents.DeleteContents( true );
2144 
2145  src->ExpectTokenType( TT_NAME, 0, &token );
2146 
2147  SetInitialState(token);
2148 
2149  src->ExpectTokenString( "{" );
2150  src->ExpectAnyToken( &token );
2151 
2152  bool ret = true;
2153 
2154  // attach a window wrapper to the window if the gui editor is running
2155 #ifdef ID_ALLOW_TOOLS
2156  if ( com_editors & EDITOR_GUI ) {
2158  }
2159 #endif
2160 
2161  while( token != "}" ) {
2162  // track what was parsed so we can maintain it for the guieditor
2163  src->SetMarker ( );
2164 
2165  if ( token == "windowDef" || token == "animationDef" ) {
2166  if (token == "animationDef") {
2167  visible = false;
2168  rect = idRectangle(0,0,0,0);
2169  }
2170  src->ExpectTokenType( TT_NAME, 0, &token );
2171  token2 = token;
2172  src->UnreadToken(&token);
2173  drawWin_t *dw = FindChildByName(token2.c_str());
2174  if (dw && dw->win) {
2176  dw->win->Parse(src, rebuild);
2178  } else {
2179  idWindow *win = new idWindow(dc, gui);
2181  win->Parse(src, rebuild);
2183  win->SetParent(this);
2184  dwt.simp = NULL;
2185  dwt.win = NULL;
2186  if (win->IsSimple()) {
2187  idSimpleWindow *simple = new idSimpleWindow(win);
2188  dwt.simp = simple;
2189  drawWindows.Append(dwt);
2190  delete win;
2191  } else {
2192  AddChild(win);
2193  SetFocus(win,false);
2194  dwt.win = win;
2195  drawWindows.Append(dwt);
2196  }
2197  }
2198  }
2199  else if ( token == "editDef" ) {
2200  idEditWindow *win = new idEditWindow(dc, gui);
2202  win->Parse(src, rebuild);
2204  AddChild(win);
2205  win->SetParent(this);
2206  dwt.simp = NULL;
2207  dwt.win = win;
2208  drawWindows.Append(dwt);
2209  }
2210  else if ( token == "choiceDef" ) {
2213  win->Parse(src, rebuild);
2215  AddChild(win);
2216  win->SetParent(this);
2217  dwt.simp = NULL;
2218  dwt.win = win;
2219  drawWindows.Append(dwt);
2220  }
2221  else if ( token == "sliderDef" ) {
2224  win->Parse(src, rebuild);
2226  AddChild(win);
2227  win->SetParent(this);
2228  dwt.simp = NULL;
2229  dwt.win = win;
2230  drawWindows.Append(dwt);
2231  }
2232  else if ( token == "markerDef" ) {
2235  win->Parse(src, rebuild);
2237  AddChild(win);
2238  win->SetParent(this);
2239  dwt.simp = NULL;
2240  dwt.win = win;
2241  drawWindows.Append(dwt);
2242  }
2243  else if ( token == "bindDef" ) {
2244  idBindWindow *win = new idBindWindow(dc, gui);
2246  win->Parse(src, rebuild);
2248  AddChild(win);
2249  win->SetParent(this);
2250  dwt.simp = NULL;
2251  dwt.win = win;
2252  drawWindows.Append(dwt);
2253  }
2254  else if ( token == "listDef" ) {
2255  idListWindow *win = new idListWindow(dc, gui);
2257  win->Parse(src, rebuild);
2259  AddChild(win);
2260  win->SetParent(this);
2261  dwt.simp = NULL;
2262  dwt.win = win;
2263  drawWindows.Append(dwt);
2264  }
2265  else if ( token == "fieldDef" ) {
2268  win->Parse(src, rebuild);
2270  AddChild(win);
2271  win->SetParent(this);
2272  dwt.simp = NULL;
2273  dwt.win = win;
2274  drawWindows.Append(dwt);
2275  }
2276  else if ( token == "renderDef" ) {
2279  win->Parse(src, rebuild);
2281  AddChild(win);
2282  win->SetParent(this);
2283  dwt.simp = NULL;
2284  dwt.win = win;
2285  drawWindows.Append(dwt);
2286  }
2287  else if ( token == "gameSSDDef" ) {
2290  win->Parse(src, rebuild);
2292  AddChild(win);
2293  win->SetParent(this);
2294  dwt.simp = NULL;
2295  dwt.win = win;
2296  drawWindows.Append(dwt);
2297  }
2298  else if ( token == "gameBearShootDef" ) {
2301  win->Parse(src, rebuild);
2303  AddChild(win);
2304  win->SetParent(this);
2305  dwt.simp = NULL;
2306  dwt.win = win;
2307  drawWindows.Append(dwt);
2308  }
2309  else if ( token == "gameBustOutDef" ) {
2312  win->Parse(src, rebuild);
2314  AddChild(win);
2315  win->SetParent(this);
2316  dwt.simp = NULL;
2317  dwt.win = win;
2318  drawWindows.Append(dwt);
2319  }
2320 //
2321 // added new onEvent
2322  else if ( token == "onNamedEvent" ) {
2323  // Read the event name
2324  if ( !src->ReadToken(&token) ) {
2325  src->Error( "Expected event name" );
2326  return false;
2327  }
2328 
2329  rvNamedEvent* ev = new rvNamedEvent ( token );
2330 
2331  src->SetMarker ( );
2332 
2333  if ( !ParseScript ( src, *ev->mEvent ) ) {
2334  ret = false;
2335  break;
2336  }
2337 
2338  // If we are in the gui editor then add the internal var to the
2339  // the wrapper
2340 #ifdef ID_ALLOW_TOOLS
2341  if ( com_editors & EDITOR_GUI ) {
2342  idStr str;
2343  idStr out;
2344 
2345  // Grab the string from the last marker
2346  src->GetStringFromMarker ( str, false );
2347 
2348  // Parse it one more time to knock unwanted tabs out
2349  idLexer src2( str, str.Length(), "", src->GetFlags() );
2350  src2.ParseBracedSectionExact ( out, 1);
2351 
2352  // Save the script
2353  rvGEWindowWrapper::GetWrapper ( this )->GetScriptDict().Set ( va("onEvent %s", token.c_str()), out );
2354  }
2355 #endif
2356  namedEvents.Append(ev);
2357  }
2358  else if ( token == "onTime" ) {
2359  idTimeLineEvent *ev = new idTimeLineEvent;
2360 
2361  if ( !src->ReadToken(&token) ) {
2362  src->Error( "Unexpected end of file" );
2363  return false;
2364  }
2365  ev->time = atoi(token.c_str());
2366 
2367  // reset the mark since we dont want it to include the time
2368  src->SetMarker ( );
2369 
2370  if (!ParseScript(src, *ev->event, &ev->time)) {
2371  ret = false;
2372  break;
2373  }
2374 
2375  // add the script to the wrappers script list
2376  // If we are in the gui editor then add the internal var to the
2377  // the wrapper
2378 #ifdef ID_ALLOW_TOOLS
2379  if ( com_editors & EDITOR_GUI ) {
2380  idStr str;
2381  idStr out;
2382 
2383  // Grab the string from the last marker
2384  src->GetStringFromMarker ( str, false );
2385 
2386  // Parse it one more time to knock unwanted tabs out
2387  idLexer src2( str, str.Length(), "", src->GetFlags() );
2388  src2.ParseBracedSectionExact ( out, 1);
2389 
2390  // Save the script
2391  rvGEWindowWrapper::GetWrapper ( this )->GetScriptDict().Set ( va("onTime %d", ev->time), out );
2392  }
2393 #endif
2394  // this is a timeline event
2395  ev->pending = true;
2396  timeLineEvents.Append(ev);
2397  }
2398  else if ( token == "definefloat" ) {
2399  src->ReadToken(&token);
2400  work = token;
2401  work.ToLower();
2402  idWinFloat *varf = new idWinFloat();
2403  varf->SetName(work);
2404  definedVars.Append(varf);
2405 
2406  // add the float to the editors wrapper dict
2407  // Set the marker after the float name
2408  src->SetMarker ( );
2409 
2410  // Read in the float
2411  regList.AddReg(work, idRegister::FLOAT, src, this, varf);
2412 
2413  // If we are in the gui editor then add the float to the defines
2414 #ifdef ID_ALLOW_TOOLS
2415  if ( com_editors & EDITOR_GUI ) {
2416  idStr str;
2417 
2418  // Grab the string from the last marker and save it in the wrapper
2419  src->GetStringFromMarker ( str, true );
2420  rvGEWindowWrapper::GetWrapper ( this )->GetVariableDict().Set ( va("definefloat\t\"%s\"",token.c_str()), str );
2421  }
2422 #endif
2423  }
2424  else if ( token == "definevec4" ) {
2425  src->ReadToken(&token);
2426  work = token;
2427  work.ToLower();
2428  idWinVec4 *var = new idWinVec4();
2429  var->SetName(work);
2430 
2431  // set the marker so we can determine what was parsed
2432  // set the marker after the vec4 name
2433  src->SetMarker ( );
2434 
2435  // FIXME: how about we add the var to the desktop instead of this window so it won't get deleted
2436  // when this window is destoyed which even happens during parsing with simple windows ?
2437  //definedVars.Append(var);
2438  gui->GetDesktop()->definedVars.Append( var );
2439  gui->GetDesktop()->regList.AddReg( work, idRegister::VEC4, src, gui->GetDesktop(), var );
2440 
2441  // store the original vec4 for the editor
2442  // If we are in the gui editor then add the float to the defines
2443 #ifdef ID_ALLOW_TOOLS
2444  if ( com_editors & EDITOR_GUI ) {
2445  idStr str;
2446 
2447  // Grab the string from the last marker and save it in the wrapper
2448  src->GetStringFromMarker ( str, true );
2449  rvGEWindowWrapper::GetWrapper ( this )->GetVariableDict().Set ( va("definevec4\t\"%s\"",token.c_str()), str );
2450  }
2451 #endif
2452  }
2453  else if ( token == "float" ) {
2454  src->ReadToken(&token);
2455  work = token;
2456  work.ToLower();
2457  idWinFloat *varf = new idWinFloat();
2458  varf->SetName(work);
2459  definedVars.Append(varf);
2460 
2461  // add the float to the editors wrapper dict
2462  // set the marker to after the float name
2463  src->SetMarker ( );
2464 
2465  // Parse the float
2466  regList.AddReg(work, idRegister::FLOAT, src, this, varf);
2467 
2468  // If we are in the gui editor then add the float to the defines
2469 #ifdef ID_ALLOW_TOOLS
2470  if ( com_editors & EDITOR_GUI ) {
2471  idStr str;
2472 
2473  // Grab the string from the last marker and save it in the wrapper
2474  src->GetStringFromMarker ( str, true );
2475  rvGEWindowWrapper::GetWrapper ( this )->GetVariableDict().Set ( va("float\t\"%s\"",token.c_str()), str );
2476  }
2477 #endif
2478  }
2479  else if (ParseScriptEntry(token, src)) {
2480  // add the script to the wrappers script list
2481  // If we are in the gui editor then add the internal var to the
2482  // the wrapper
2483 #ifdef ID_ALLOW_TOOLS
2484  if ( com_editors & EDITOR_GUI ) {
2485  idStr str;
2486  idStr out;
2487 
2488  // Grab the string from the last marker
2489  src->GetStringFromMarker ( str, false );
2490 
2491  // Parse it one more time to knock unwanted tabs out
2492  idLexer src2( str, str.Length(), "", src->GetFlags() );
2493  src2.ParseBracedSectionExact ( out, 1);
2494 
2495  // Save the script
2496  rvGEWindowWrapper::GetWrapper ( this )->GetScriptDict().Set ( token, out );
2497  }
2498 #endif
2499  } else if (ParseInternalVar(token, src)) {
2500  // gui editor support
2501  // If we are in the gui editor then add the internal var to the
2502  // the wrapper
2503 #ifdef ID_ALLOW_TOOLS
2504  if ( com_editors & EDITOR_GUI ) {
2505  idStr str;
2506  src->GetStringFromMarker ( str );
2507  rvGEWindowWrapper::GetWrapper ( this )->SetStateKey ( token, str, false );
2508  }
2509 #endif
2510  }
2511  else {
2512  ParseRegEntry(token, src);
2513  // hook into the main window parsing for the gui editor
2514  // If we are in the gui editor then add the internal var to the
2515  // the wrapper
2516 #ifdef ID_ALLOW_TOOLS
2517  if ( com_editors & EDITOR_GUI ) {
2518  idStr str;
2519  src->GetStringFromMarker ( str );
2520  rvGEWindowWrapper::GetWrapper ( this )->SetStateKey ( token, str, false );
2521  }
2522 #endif
2523  }
2524  if ( !src->ReadToken( &token ) ) {
2525  src->Error( "Unexpected end of file" );
2526  ret = false;
2527  break;
2528  }
2529  }
2530 
2531  if (ret) {
2532  EvalRegs(-1, true);
2533  }
2534 
2535  SetupFromState();
2536  PostParse();
2537 
2538  // hook into the main window parsing for the gui editor
2539  // If we are in the gui editor then add the internal var to the
2540  // the wrapper
2541 #ifdef ID_ALLOW_TOOLS
2542  if ( com_editors & EDITOR_GUI ) {
2543  rvGEWindowWrapper::GetWrapper ( this )->Finish ( );
2544  }
2545 #endif
2546 
2547  return ret;
2548 }
2549 
2550 /*
2551 ================
2552 idWindow::FindSimpleWinByName
2553 ================
2554 */
2556  int c = drawWindows.Num();
2557  for (int i = 0; i < c; i++) {
2558  if (drawWindows[i].simp == NULL) {
2559  continue;
2560  }
2561  if ( idStr::Icmp(drawWindows[i].simp->name, _name) == 0 ) {
2562  return drawWindows[i].simp;
2563  }
2564  }
2565  return NULL;
2566 }
2567 
2568 /*
2569 ================
2570 idWindow::FindChildByName
2571 ================
2572 */
2574  static drawWin_t dw;
2575  if (idStr::Icmp(name,_name) == 0) {
2576  dw.simp = NULL;
2577  dw.win = this;
2578  return &dw;
2579  }
2580  int c = drawWindows.Num();
2581  for (int i = 0; i < c; i++) {
2582  if (drawWindows[i].win) {
2583  if (idStr::Icmp(drawWindows[i].win->name, _name) == 0) {
2584  return &drawWindows[i];
2585  }
2586  drawWin_t *win = drawWindows[i].win->FindChildByName(_name);
2587  if (win) {
2588  return win;
2589  }
2590  } else {
2591  if (idStr::Icmp(drawWindows[i].simp->name, _name) == 0) {
2592  return &drawWindows[i];
2593  }
2594  }
2595  }
2596  return NULL;
2597 }
2598 
2599 /*
2600 ================
2601 idWindow::GetStrPtrByName
2602 ================
2603 */
2604 idStr* idWindow::GetStrPtrByName(const char *_name) {
2605  return NULL;
2606 }
2607 
2608 /*
2609 ================
2610 idWindow::AddTransition
2611 ================
2612 */
2613 void idWindow::AddTransition(idWinVar *dest, idVec4 from, idVec4 to, int time, float accelTime, float decelTime) {
2615  data.data = dest;
2616  data.interp.Init(gui->GetTime(), accelTime * time, decelTime * time, time, from, to);
2617  transitions.Append(data);
2618 }
2619 
2620 
2621 /*
2622 ================
2623 idWindow::StartTransition
2624 ================
2625 */
2628 }
2629 
2630 /*
2631 ================
2632 idWindow::ResetCinematics
2633 ================
2634 */
2636  if ( background ) {
2638  }
2639 }
2640 
2641 /*
2642 ================
2643 idWindow::ResetTime
2644 ================
2645 */
2647 
2648  timeLine = gui->GetTime() - t;
2649 
2650  int i, c = timeLineEvents.Num();
2651  for ( i = 0; i < c; i++ ) {
2652  if ( timeLineEvents[i]->time >= t ) {
2653  timeLineEvents[i]->pending = true;
2654  }
2655  }
2656 
2657  noTime = false;
2658 
2659  c = transitions.Num();
2660  for ( i = 0; i < c; i++ ) {
2662  if ( data->interp.IsDone( gui->GetTime() ) && data->data ) {
2663  transitions.RemoveIndex( i );
2664  i--;
2665  c--;
2666  }
2667  }
2668 
2669 }
2670 
2671 
2672 /*
2673 ================
2674 idWindow::RunScriptList
2675 ================
2676 */
2678  if (src == NULL) {
2679  return false;
2680  }
2681  src->Execute(this);
2682  return true;
2683 }
2684 
2685 /*
2686 ================
2687 idWindow::RunScript
2688 ================
2689 */
2691  if (n >= ON_MOUSEENTER && n < SCRIPT_COUNT) {
2692  return RunScriptList(scripts[n]);
2693  }
2694  return false;
2695 }
2696 
2697 /*
2698 ================
2699 idWindow::ExpressionConstant
2700 ================
2701 */
2703  int i;
2704 
2705  for ( i = WEXP_REG_NUM_PREDEFINED ; i < expressionRegisters.Num() ; i++ ) {
2706  if ( !registerIsTemporary[i] && expressionRegisters[i] == f ) {
2707  return i;
2708  }
2709  }
2710  if ( expressionRegisters.Num() == MAX_EXPRESSION_REGISTERS ) {
2711  common->Warning( "expressionConstant: gui %s hit MAX_EXPRESSION_REGISTERS", gui->GetSourceFile() );
2712  return 0;
2713  }
2714 
2715  int c = expressionRegisters.Num();
2716  if (i > c) {
2717  while (i > c) {
2718  expressionRegisters.Append(-9999999);
2719  i--;
2720  }
2721  }
2722 
2723  i = expressionRegisters.Append(f);
2724  registerIsTemporary[i] = false;
2725  return i;
2726 }
2727 
2728 /*
2729 ================
2730 idWindow::ExpressionTemporary
2731 ================
2732 */
2734  if ( expressionRegisters.Num() == MAX_EXPRESSION_REGISTERS ) {
2735  common->Warning( "expressionTemporary: gui %s hit MAX_EXPRESSION_REGISTERS", gui->GetSourceFile());
2736  return 0;
2737  }
2738  int i = expressionRegisters.Num();
2739  registerIsTemporary[i] = true;
2740  i = expressionRegisters.Append(0);
2741  return i;
2742 }
2743 
2744 /*
2745 ================
2746 idWindow::ExpressionOp
2747 ================
2748 */
2750  if ( ops.Num() == MAX_EXPRESSION_OPS ) {
2751  common->Warning( "expressionOp: gui %s hit MAX_EXPRESSION_OPS", gui->GetSourceFile());
2752  return &ops[0];
2753  }
2754  wexpOp_t wop;
2755  memset(&wop, 0, sizeof(wexpOp_t));
2756  int i = ops.Append(wop);
2757  return &ops[i];
2758 }
2759 
2760 /*
2761 ================
2762 idWindow::EmitOp
2763 ================
2764 */
2765 
2766 int idWindow::EmitOp( int a, int b, wexpOpType_t opType, wexpOp_t **opp ) {
2767  wexpOp_t *op;
2768 /*
2769  // optimize away identity operations
2770  if ( opType == WOP_TYPE_ADD ) {
2771  if ( !registerIsTemporary[a] && shaderRegisters[a] == 0 ) {
2772  return b;
2773  }
2774  if ( !registerIsTemporary[b] && shaderRegisters[b] == 0 ) {
2775  return a;
2776  }
2777  if ( !registerIsTemporary[a] && !registerIsTemporary[b] ) {
2778  return ExpressionConstant( shaderRegisters[a] + shaderRegisters[b] );
2779  }
2780  }
2781  if ( opType == WOP_TYPE_MULTIPLY ) {
2782  if ( !registerIsTemporary[a] && shaderRegisters[a] == 1 ) {
2783  return b;
2784  }
2785  if ( !registerIsTemporary[a] && shaderRegisters[a] == 0 ) {
2786  return a;
2787  }
2788  if ( !registerIsTemporary[b] && shaderRegisters[b] == 1 ) {
2789  return a;
2790  }
2791  if ( !registerIsTemporary[b] && shaderRegisters[b] == 0 ) {
2792  return b;
2793  }
2794  if ( !registerIsTemporary[a] && !registerIsTemporary[b] ) {
2795  return ExpressionConstant( shaderRegisters[a] * shaderRegisters[b] );
2796  }
2797  }
2798 */
2799  op = ExpressionOp();
2800 
2801  op->opType = opType;
2802  op->a = a;
2803  op->b = b;
2804  op->c = ExpressionTemporary();
2805 
2806  if (opp) {
2807  *opp = op;
2808  }
2809  return op->c;
2810 }
2811 
2812 /*
2813 ================
2814 idWindow::ParseEmitOp
2815 ================
2816 */
2817 int idWindow::ParseEmitOp( idParser *src, int a, wexpOpType_t opType, int priority, wexpOp_t **opp ) {
2818  int b = ParseExpressionPriority( src, priority );
2819  return EmitOp( a, b, opType, opp );
2820 }
2821 
2822 
2823 /*
2824 ================
2825 idWindow::ParseTerm
2826 
2827 Returns a register index
2828 =================
2829 */
2830 int idWindow::ParseTerm( idParser *src, idWinVar *var, int component ) {
2831  idToken token;
2832  int a, b;
2833 
2834  src->ReadToken( &token );
2835 
2836  if ( token == "(" ) {
2837  a = ParseExpression( src );
2838  src->ExpectTokenString(")");
2839  return a;
2840  }
2841 
2842  if ( !token.Icmp( "time" ) ) {
2843  return WEXP_REG_TIME;
2844  }
2845 
2846  // parse negative numbers
2847  if ( token == "-" ) {
2848  src->ReadToken( &token );
2849  if ( token.type == TT_NUMBER || token == "." ) {
2850  return ExpressionConstant( -(float) token.GetFloatValue() );
2851  }
2852  src->Warning( "Bad negative number '%s'", token.c_str() );
2853  return 0;
2854  }
2855 
2856  if ( token.type == TT_NUMBER || token == "." || token == "-" ) {
2857  return ExpressionConstant( (float) token.GetFloatValue() );
2858  }
2859 
2860  // see if it is a table name
2861  const idDeclTable *table = static_cast<const idDeclTable *>( declManager->FindType( DECL_TABLE, token.c_str(), false ) );
2862  if ( table ) {
2863  a = table->Index();
2864  // parse a table expression
2865  src->ExpectTokenString("[");
2866  b = ParseExpression(src);
2867  src->ExpectTokenString("]");
2868  return EmitOp( a, b, WOP_TYPE_TABLE );
2869  }
2870 
2871  if (var == NULL) {
2872  var = GetWinVarByName(token, true);
2873  }
2874  if (var) {
2875  a = (int)var;
2876  //assert(dynamic_cast<idWinVec4*>(var));
2877  var->Init(token, this);
2878  b = component;
2879  if (dynamic_cast<idWinVec4*>(var)) {
2880  if (src->ReadToken(&token)) {
2881  if (token == "[") {
2882  b = ParseExpression(src);
2883  src->ExpectTokenString("]");
2884  } else {
2885  src->UnreadToken(&token);
2886  }
2887  }
2888  return EmitOp(a, b, WOP_TYPE_VAR);
2889  } else if (dynamic_cast<idWinFloat*>(var)) {
2890  return EmitOp(a, b, WOP_TYPE_VARF);
2891  } else if (dynamic_cast<idWinInt*>(var)) {
2892  return EmitOp(a, b, WOP_TYPE_VARI);
2893  } else if (dynamic_cast<idWinBool*>(var)) {
2894  return EmitOp(a, b, WOP_TYPE_VARB);
2895  } else if (dynamic_cast<idWinStr*>(var)) {
2896  return EmitOp(a, b, WOP_TYPE_VARS);
2897  } else {
2898  src->Warning("Var expression not vec4, float or int '%s'", token.c_str());
2899  }
2900  return 0;
2901  } else {
2902  // ugly but used for post parsing to fixup named vars
2903  char *p = new char[token.Length()+1];
2904  strcpy(p, token);
2905  a = (int)p;
2906  b = -2;
2907  return EmitOp(a, b, WOP_TYPE_VAR);
2908  }
2909 
2910 }
2911 
2912 /*
2913 =================
2914 idWindow::ParseExpressionPriority
2915 
2916 Returns a register index
2917 =================
2918 */
2919 #define TOP_PRIORITY 4
2920 int idWindow::ParseExpressionPriority( idParser *src, int priority, idWinVar *var, int component ) {
2921  idToken token;
2922  int a;
2923 
2924  if ( priority == 0 ) {
2925  return ParseTerm( src, var, component );
2926  }
2927 
2928  a = ParseExpressionPriority( src, priority - 1, var, component );
2929 
2930  if ( !src->ReadToken( &token ) ) {
2931  // we won't get EOF in a real file, but we can
2932  // when parsing from generated strings
2933  return a;
2934  }
2935 
2936  if ( priority == 1 && token == "*" ) {
2937  return ParseEmitOp( src, a, WOP_TYPE_MULTIPLY, priority );
2938  }
2939  if ( priority == 1 && token == "/" ) {
2940  return ParseEmitOp( src, a, WOP_TYPE_DIVIDE, priority );
2941  }
2942  if ( priority == 1 && token == "%" ) { // implied truncate both to integer
2943  return ParseEmitOp( src, a, WOP_TYPE_MOD, priority );
2944  }
2945  if ( priority == 2 && token == "+" ) {
2946  return ParseEmitOp( src, a, WOP_TYPE_ADD, priority );
2947  }
2948  if ( priority == 2 && token == "-" ) {
2949  return ParseEmitOp( src, a, WOP_TYPE_SUBTRACT, priority );
2950  }
2951  if ( priority == 3 && token == ">" ) {
2952  return ParseEmitOp( src, a, WOP_TYPE_GT, priority );
2953  }
2954  if ( priority == 3 && token == ">=" ) {
2955  return ParseEmitOp( src, a, WOP_TYPE_GE, priority );
2956  }
2957  if ( priority == 3 && token == "<" ) {
2958  return ParseEmitOp( src, a, WOP_TYPE_LT, priority );
2959  }
2960  if ( priority == 3 && token == "<=" ) {
2961  return ParseEmitOp( src, a, WOP_TYPE_LE, priority );
2962  }
2963  if ( priority == 3 && token == "==" ) {
2964  return ParseEmitOp( src, a, WOP_TYPE_EQ, priority );
2965  }
2966  if ( priority == 3 && token == "!=" ) {
2967  return ParseEmitOp( src, a, WOP_TYPE_NE, priority );
2968  }
2969  if ( priority == 4 && token == "&&" ) {
2970  return ParseEmitOp( src, a, WOP_TYPE_AND, priority );
2971  }
2972  if ( priority == 4 && token == "||" ) {
2973  return ParseEmitOp( src, a, WOP_TYPE_OR, priority );
2974  }
2975  if ( priority == 4 && token == "?" ) {
2976  wexpOp_t *oop = NULL;
2977  int o = ParseEmitOp( src, a, WOP_TYPE_COND, priority, &oop );
2978  if ( !src->ReadToken( &token ) ) {
2979  return o;
2980  }
2981  if (token == ":") {
2982  a = ParseExpressionPriority( src, priority - 1, var );
2983  oop->d = a;
2984  }
2985  return o;
2986  }
2987 
2988  // assume that anything else terminates the expression
2989  // not too robust error checking...
2990 
2991  src->UnreadToken( &token );
2992 
2993  return a;
2994 }
2995 
2996 /*
2997 ================
2998 idWindow::ParseExpression
2999 
3000 Returns a register index
3001 ================
3002 */
3003 int idWindow::ParseExpression(idParser *src, idWinVar *var, int component) {
3004  return ParseExpressionPriority( src, TOP_PRIORITY, var );
3005 }
3006 
3007 /*
3008 ================
3009 idWindow::ParseBracedExpression
3010 ================
3011 */
3013  src->ExpectTokenString("{");
3014  ParseExpression(src);
3015  src->ExpectTokenString("}");
3016 }
3017 
3018 /*
3019 ===============
3020 idWindow::EvaluateRegisters
3021 
3022 Parameters are taken from the localSpace and the renderView,
3023 then all expressions are evaluated, leaving the shader registers
3024 set to their apropriate values.
3025 ===============
3026 */
3027 void idWindow::EvaluateRegisters(float *registers) {
3028  int i, b;
3029  wexpOp_t *op;
3030  idVec4 v;
3031 
3032  int erc = expressionRegisters.Num();
3033  int oc = ops.Num();
3034  // copy the constants
3035  for ( i = WEXP_REG_NUM_PREDEFINED ; i < erc ; i++ ) {
3036  registers[i] = expressionRegisters[i];
3037  }
3038 
3039  // copy the local and global parameters
3040  registers[WEXP_REG_TIME] = gui->GetTime();
3041 
3042  for ( i = 0 ; i < oc ; i++ ) {
3043  op = &ops[i];
3044  if (op->b == -2) {
3045  continue;
3046  }
3047  switch( op->opType ) {
3048  case WOP_TYPE_ADD:
3049  registers[op->c] = registers[op->a] + registers[op->b];
3050  break;
3051  case WOP_TYPE_SUBTRACT:
3052  registers[op->c] = registers[op->a] - registers[op->b];
3053  break;
3054  case WOP_TYPE_MULTIPLY:
3055  registers[op->c] = registers[op->a] * registers[op->b];
3056  break;
3057  case WOP_TYPE_DIVIDE:
3058  if ( registers[op->b] == 0.0f ) {
3059  common->Warning( "Divide by zero in window '%s' in %s", GetName(), gui->GetSourceFile() );
3060  registers[op->c] = registers[op->a];
3061  } else {
3062  registers[op->c] = registers[op->a] / registers[op->b];
3063  }
3064  break;
3065  case WOP_TYPE_MOD:
3066  b = (int)registers[op->b];
3067  b = b != 0 ? b : 1;
3068  registers[op->c] = (int)registers[op->a] % b;
3069  break;
3070  case WOP_TYPE_TABLE:
3071  {
3072  const idDeclTable *table = static_cast<const idDeclTable *>( declManager->DeclByIndex( DECL_TABLE, op->a ) );
3073  registers[op->c] = table->TableLookup( registers[op->b] );
3074  }
3075  break;
3076  case WOP_TYPE_GT:
3077  registers[op->c] = registers[ op->a ] > registers[op->b];
3078  break;
3079  case WOP_TYPE_GE:
3080  registers[op->c] = registers[ op->a ] >= registers[op->b];
3081  break;
3082  case WOP_TYPE_LT:
3083  registers[op->c] = registers[ op->a ] < registers[op->b];
3084  break;
3085  case WOP_TYPE_LE:
3086  registers[op->c] = registers[ op->a ] <= registers[op->b];
3087  break;
3088  case WOP_TYPE_EQ:
3089  registers[op->c] = registers[ op->a ] == registers[op->b];
3090  break;
3091  case WOP_TYPE_NE:
3092  registers[op->c] = registers[ op->a ] != registers[op->b];
3093  break;
3094  case WOP_TYPE_COND:
3095  registers[op->c] = (registers[ op->a ]) ? registers[op->b] : registers[op->d];
3096  break;
3097  case WOP_TYPE_AND:
3098  registers[op->c] = registers[ op->a ] && registers[op->b];
3099  break;
3100  case WOP_TYPE_OR:
3101  registers[op->c] = registers[ op->a ] || registers[op->b];
3102  break;
3103  case WOP_TYPE_VAR:
3104  if ( !op->a ) {
3105  registers[op->c] = 0.0f;
3106  break;
3107  }
3108  if ( op->b >= 0 && registers[op->b] >= 0 && registers[op->b] < 4 ) {
3109  // grabs vector components
3110  idWinVec4 *var = (idWinVec4 *)( op->a );
3111  registers[op->c] = ((idVec4&)var)[registers[op->b]];
3112  } else {
3113  registers[op->c] = ((idWinVar*)(op->a))->x();
3114  }
3115  break;
3116  case WOP_TYPE_VARS:
3117  if (op->a) {
3118  idWinStr *var = (idWinStr*)(op->a);
3119  registers[op->c] = atof(var->c_str());
3120  } else {
3121  registers[op->c] = 0;
3122  }
3123  break;
3124  case WOP_TYPE_VARF:
3125  if (op->a) {
3126  idWinFloat *var = (idWinFloat*)(op->a);
3127  registers[op->c] = *var;
3128  } else {
3129  registers[op->c] = 0;
3130  }
3131  break;
3132  case WOP_TYPE_VARI:
3133  if (op->a) {
3134  idWinInt *var = (idWinInt*)(op->a);
3135  registers[op->c] = *var;
3136  } else {
3137  registers[op->c] = 0;
3138  }
3139  break;
3140  case WOP_TYPE_VARB:
3141  if (op->a) {
3142  idWinBool *var = (idWinBool*)(op->a);
3143  registers[op->c] = *var;
3144  } else {
3145  registers[op->c] = 0;
3146  }
3147  break;
3148  default:
3149  common->FatalError( "R_EvaluateExpression: bad opcode" );
3150  }
3151  }
3152 
3153 }
3154 
3155 /*
3156 ================
3157 idWindow::ReadFromDemoFile
3158 ================
3159 */
3160 void idWindow::ReadFromDemoFile( class idDemoFile *f, bool rebuild ) {
3161 
3162  // should never hit unless we re-enable WRITE_GUIS
3163 #ifndef WRITE_GUIS
3164  assert( false );
3165 #else
3166 
3167  if (rebuild) {
3168  CommonInit();
3169  }
3170 
3171  f->SetLog(true, "window1");
3173  f->SetLog(true, backGroundName);
3174  if ( backGroundName[0] ) {
3176  } else {
3177  background = NULL;
3178  }
3179  f->ReadUnsignedChar( cursor );
3180  f->ReadUnsignedInt( flags );
3181  f->ReadInt( timeLine );
3182  f->ReadInt( lastTimeRun );
3183  idRectangle rct = rect;
3184  f->ReadFloat( rct.x );
3185  f->ReadFloat( rct.y );
3186  f->ReadFloat( rct.w );
3187  f->ReadFloat( rct.h );
3188  f->ReadFloat( drawRect.x );
3189  f->ReadFloat( drawRect.y );
3190  f->ReadFloat( drawRect.w );
3191  f->ReadFloat( drawRect.h );
3192  f->ReadFloat( clientRect.x );
3193  f->ReadFloat( clientRect.y );
3194  f->ReadFloat( clientRect.w );
3195  f->ReadFloat( clientRect.h );
3196  f->ReadFloat( textRect.x );
3197  f->ReadFloat( textRect.y );
3198  f->ReadFloat( textRect.w );
3199  f->ReadFloat( textRect.h );
3200  f->ReadFloat( xOffset);
3201  f->ReadFloat( yOffset);
3202  int i, c;
3203 
3204  idStr work;
3205  if (rebuild) {
3206  f->SetLog(true, (work + "-scripts"));
3207  for (i = 0; i < SCRIPT_COUNT; i++) {
3208  bool b;
3209  f->ReadBool( b );
3210  if (b) {
3211  delete scripts[i];
3212  scripts[i] = new idGuiScriptList;
3213  scripts[i]->ReadFromDemoFile(f);
3214  }
3215  }
3216 
3217  f->SetLog(true, (work + "-timelines"));
3218  f->ReadInt( c );
3219  for (i = 0; i < c; i++) {
3220  idTimeLineEvent *tl = new idTimeLineEvent;
3221  f->ReadInt( tl->time );
3222  f->ReadBool( tl->pending );
3223  tl->event->ReadFromDemoFile(f);
3224  if (rebuild) {
3225  timeLineEvents.Append(tl);
3226  } else {
3227  assert(i < timeLineEvents.Num());
3228  timeLineEvents[i]->time = tl->time;
3229  timeLineEvents[i]->pending = tl->pending;
3230  }
3231  }
3232  }
3233 
3234  f->SetLog(true, (work + "-transitions"));
3235  f->ReadInt( c );
3236  for (i = 0; i < c; i++) {
3237  idTransitionData td;
3238  td.data = NULL;
3239  f->ReadInt ( td.offset );
3240 
3241  float startTime, accelTime, linearTime, decelTime;
3242  idVec4 startValue, endValue;
3243  f->ReadFloat( startTime );
3244  f->ReadFloat( accelTime );
3245  f->ReadFloat( linearTime );
3246  f->ReadFloat( decelTime );
3247  f->ReadVec4( startValue );
3248  f->ReadVec4( endValue );
3249  td.interp.Init( startTime, accelTime, decelTime, accelTime + linearTime + decelTime, startValue, endValue );
3250 
3251  // read this for correct data padding with the win32 savegames
3252  // the extrapolate is correctly initialized through the above Init call
3253  int extrapolationType;
3254  float duration;
3255  idVec4 baseSpeed, speed;
3256  float currentTime;
3257  idVec4 currentValue;
3258  f->ReadInt( extrapolationType );
3259  f->ReadFloat( startTime );
3260  f->ReadFloat( duration );
3261  f->ReadVec4( startValue );
3262  f->ReadVec4( baseSpeed );
3263  f->ReadVec4( speed );
3264  f->ReadFloat( currentTime );
3265  f->ReadVec4( currentValue );
3266 
3267  transitions.Append(td);
3268  }
3269 
3270  f->SetLog(true, (work + "-regstuff"));
3271  if (rebuild) {
3272  f->ReadInt( c );
3273  for (i = 0; i < c; i++) {
3274  wexpOp_t w;
3275  f->ReadInt( (int&)w.opType );
3276  f->ReadInt( w.a );
3277  f->ReadInt( w.b );
3278  f->ReadInt( w.c );
3279  f->ReadInt( w.d );
3280  ops.Append(w);
3281  }
3282 
3283  f->ReadInt( c );
3284  for (i = 0; i < c; i++) {
3285  float ff;
3286  f->ReadFloat( ff );
3288  }
3289 
3291 
3292  }
3293  f->SetLog(true, (work + "-children"));
3294  f->ReadInt( c );
3295  for (i = 0; i < c; i++) {
3296  if (rebuild) {
3297  idWindow *win = new idWindow(dc, gui);
3298  win->ReadFromDemoFile(f);
3299  AddChild(win);
3300  } else {
3301  for (int j = 0; j < c; j++) {
3302  if (children[j]->childID == i) {
3303  children[j]->ReadFromDemoFile(f,rebuild);
3304  break;
3305  } else {
3306  continue;
3307  }
3308  }
3309  }
3310  }
3311 #endif /* WRITE_GUIS */
3312 }
3313 
3314 /*
3315 ================
3316 idWindow::WriteToDemoFile
3317 ================
3318 */
3320  // should never hit unless we re-enable WRITE_GUIS
3321 #ifndef WRITE_GUIS
3322  assert( false );
3323 #else
3324 
3325  f->SetLog(true, "window");
3327  f->SetLog(true, backGroundName);
3328  f->WriteUnsignedChar( cursor );
3329  f->WriteUnsignedInt( flags );
3330  f->WriteInt( timeLine );
3331  f->WriteInt( lastTimeRun );
3332  idRectangle rct = rect;
3333  f->WriteFloat( rct.x );
3334  f->WriteFloat( rct.y );
3335  f->WriteFloat( rct.w );
3336  f->WriteFloat( rct.h );
3337  f->WriteFloat( drawRect.x );
3338  f->WriteFloat( drawRect.y );
3339  f->WriteFloat( drawRect.w );
3340  f->WriteFloat( drawRect.h );
3341  f->WriteFloat( clientRect.x );
3342  f->WriteFloat( clientRect.y );
3343  f->WriteFloat( clientRect.w );
3344  f->WriteFloat( clientRect.h );
3345  f->WriteFloat( textRect.x );
3346  f->WriteFloat( textRect.y );
3347  f->WriteFloat( textRect.w );
3348  f->WriteFloat( textRect.h );
3349  f->WriteFloat( xOffset );
3350  f->WriteFloat( yOffset );
3351  idStr work;
3352  f->SetLog(true, work);
3353 
3354  int i, c;
3355 
3356  f->SetLog(true, (work + "-transitions"));
3357  c = transitions.Num();
3358  f->WriteInt( c );
3359  for (i = 0; i < c; i++) {
3360  f->WriteInt( 0 );
3361  f->WriteInt( transitions[i].offset );
3362 
3363  f->WriteFloat( transitions[i].interp.GetStartTime() );
3364  f->WriteFloat( transitions[i].interp.GetAccelTime() );
3365  f->WriteFloat( transitions[i].interp.GetLinearTime() );
3366  f->WriteFloat( transitions[i].interp.GetDecelTime() );
3367  f->WriteVec4( transitions[i].interp.GetStartValue() );
3368  f->WriteVec4( transitions[i].interp.GetEndValue() );
3369 
3370  // write to keep win32 render demo format compatiblity - we don't actually read them back anymore
3371  f->WriteInt( transitions[i].interp.GetExtrapolate()->GetExtrapolationType() );
3372  f->WriteFloat( transitions[i].interp.GetExtrapolate()->GetStartTime() );
3373  f->WriteFloat( transitions[i].interp.GetExtrapolate()->GetDuration() );
3374  f->WriteVec4( transitions[i].interp.GetExtrapolate()->GetStartValue() );
3375  f->WriteVec4( transitions[i].interp.GetExtrapolate()->GetBaseSpeed() );
3376  f->WriteVec4( transitions[i].interp.GetExtrapolate()->GetSpeed() );
3377  f->WriteFloat( transitions[i].interp.GetExtrapolate()->GetCurrentTime() );
3378  f->WriteVec4( transitions[i].interp.GetExtrapolate()->GetCurrentValue() );
3379  }
3380 
3381  f->SetLog(true, (work + "-regstuff"));
3382 
3383  f->SetLog(true, (work + "-children"));
3384  c = children.Num();
3385  f->WriteInt( c );
3386  for (i = 0; i < c; i++) {
3387  for (int j = 0; j < c; j++) {
3388  if (children[j]->childID == i) {
3389  children[j]->WriteToDemoFile(f);
3390  break;
3391  } else {
3392  continue;
3393  }
3394  }
3395  }
3396 #endif /* WRITE_GUIS */
3397 }
3398 
3399 /*
3400 ===============
3401 idWindow::WriteString
3402 ===============
3403 */
3404 void idWindow::WriteSaveGameString( const char *string, idFile *savefile ) {
3405  int len = strlen( string );
3406 
3407  savefile->Write( &len, sizeof( len ) );
3408  savefile->Write( string, len );
3409 }
3410 
3411 /*
3412 ===============
3413 idWindow::WriteSaveGameTransition
3414 ===============
3415 */
3417  drawWin_t dw, *fdw;
3418  idStr winName("");
3419  dw.simp = NULL;
3420  dw.win = NULL;
3421  int offset = gui->GetDesktop()->GetWinVarOffset( trans.data, &dw );
3422  if ( dw.win || dw.simp ) {
3423  winName = ( dw.win ) ? dw.win->GetName() : dw.simp->name.c_str();
3424  }
3425  fdw = gui->GetDesktop()->FindChildByName( winName );
3426  if ( offset != -1 && fdw && ( fdw->win || fdw->simp ) ) {
3427  savefile->Write( &offset, sizeof( offset ) );
3428  WriteSaveGameString( winName, savefile );
3429  savefile->Write( &trans.interp, sizeof( trans.interp ) );
3430  } else {
3431  offset = -1;
3432  savefile->Write( &offset, sizeof( offset ) );
3433  }
3434 }
3435 
3436 /*
3437 ===============
3438 idWindow::ReadSaveGameTransition
3439 ===============
3440 */
3442  int offset;
3443 
3444  savefile->Read( &offset, sizeof( offset ) );
3445  if ( offset != -1 ) {
3446  idStr winName;
3447  ReadSaveGameString( winName, savefile );
3448  savefile->Read( &trans.interp, sizeof( trans.interp ) );
3449  trans.data = NULL;
3450  trans.offset = offset;
3451  if ( winName.Length() ) {
3452  idWinStr *strVar = new idWinStr();
3453  strVar->Set( winName );
3454  trans.data = dynamic_cast< idWinVar* >( strVar );
3455  }
3456  }
3457 }
3458 
3459 /*
3460 ===============
3461 idWindow::WriteToSaveGame
3462 ===============
3463 */
3465  int i;
3466 
3467  WriteSaveGameString( cmd, savefile );
3468 
3469  savefile->Write( &actualX, sizeof( actualX ) );
3470  savefile->Write( &actualY, sizeof( actualY ) );
3471  savefile->Write( &childID, sizeof( childID ) );
3472  savefile->Write( &flags, sizeof( flags ) );
3473  savefile->Write( &lastTimeRun, sizeof( lastTimeRun ) );
3474  savefile->Write( &drawRect, sizeof( drawRect ) );
3475  savefile->Write( &clientRect, sizeof( clientRect ) );
3476  savefile->Write( &origin, sizeof( origin ) );
3477  savefile->Write( &fontNum, sizeof( fontNum ) );
3478  savefile->Write( &timeLine, sizeof( timeLine ) );
3479  savefile->Write( &xOffset, sizeof( xOffset ) );
3480  savefile->Write( &yOffset, sizeof( yOffset ) );
3481  savefile->Write( &cursor, sizeof( cursor ) );
3482  savefile->Write( &forceAspectWidth, sizeof( forceAspectWidth ) );
3483  savefile->Write( &forceAspectHeight, sizeof( forceAspectHeight ) );
3484  savefile->Write( &matScalex, sizeof( matScalex ) );
3485  savefile->Write( &matScaley, sizeof( matScaley ) );
3486  savefile->Write( &borderSize, sizeof( borderSize ) );
3487  savefile->Write( &textAlign, sizeof( textAlign ) );
3488  savefile->Write( &textAlignx, sizeof( textAlignx ) );
3489  savefile->Write( &textAligny, sizeof( textAligny ) );
3490  savefile->Write( &textShadow, sizeof( textShadow ) );
3491  savefile->Write( &shear, sizeof( shear ) );
3492 
3493  WriteSaveGameString( name, savefile );
3494  WriteSaveGameString( comment, savefile );
3495 
3496  // WinVars
3497  noTime.WriteToSaveGame( savefile );
3498  visible.WriteToSaveGame( savefile );
3499  rect.WriteToSaveGame( savefile );
3500  backColor.WriteToSaveGame( savefile );
3501  matColor.WriteToSaveGame( savefile );
3502  foreColor.WriteToSaveGame( savefile );
3503  hoverColor.WriteToSaveGame( savefile );
3504  borderColor.WriteToSaveGame( savefile );
3505  textScale.WriteToSaveGame( savefile );
3506  noEvents.WriteToSaveGame( savefile );
3507  rotate.WriteToSaveGame( savefile );
3508  text.WriteToSaveGame( savefile );
3509  backGroundName.WriteToSaveGame( savefile );
3510  hideCursor.WriteToSaveGame(savefile);
3511 
3512  // Defined Vars
3513  for ( i = 0; i < definedVars.Num(); i++ ) {
3514  definedVars[i]->WriteToSaveGame( savefile );
3515  }
3516 
3517  savefile->Write( &textRect, sizeof( textRect ) );
3518 
3519  // Window pointers saved as the child ID of the window
3520  int winID;
3521 
3522  winID = focusedChild ? focusedChild->childID : -1 ;
3523  savefile->Write( &winID, sizeof( winID ) );
3524 
3525  winID = captureChild ? captureChild->childID : -1 ;
3526  savefile->Write( &winID, sizeof( winID ) );
3527 
3528  winID = overChild ? overChild->childID : -1 ;
3529  savefile->Write( &winID, sizeof( winID ) );
3530 
3531 
3532  // Scripts
3533  for ( i = 0; i < SCRIPT_COUNT; i++ ) {
3534  if ( scripts[i] ) {
3535  scripts[i]->WriteToSaveGame( savefile );
3536  }
3537  }
3538 
3539  // TimeLine Events
3540  for ( i = 0; i < timeLineEvents.Num(); i++ ) {
3541  if ( timeLineEvents[i] ) {
3542  savefile->Write( &timeLineEvents[i]->pending, sizeof( timeLineEvents[i]->pending ) );
3543  savefile->Write( &timeLineEvents[i]->time, sizeof( timeLineEvents[i]->time ) );
3544  if ( timeLineEvents[i]->event ) {
3545  timeLineEvents[i]->event->WriteToSaveGame( savefile );
3546  }
3547  }
3548  }
3549 
3550  // Transitions
3551  int num = transitions.Num();
3552 
3553  savefile->Write( &num, sizeof( num ) );
3554  for ( i = 0; i < transitions.Num(); i++ ) {
3555  WriteSaveGameTransition( transitions[ i ], savefile );
3556  }
3557 
3558 
3559  // Named Events
3560  for ( i = 0; i < namedEvents.Num(); i++ ) {
3561  if ( namedEvents[i] ) {
3562  WriteSaveGameString( namedEvents[i]->mName, savefile );
3563  if ( namedEvents[i]->mEvent ) {
3564  namedEvents[i]->mEvent->WriteToSaveGame( savefile );
3565  }
3566  }
3567  }
3568 
3569  // regList
3570  regList.WriteToSaveGame( savefile );
3571 
3572 
3573  // Save children
3574  for ( i = 0; i < drawWindows.Num(); i++ ) {
3576 
3577  if ( window.simp ) {
3578  window.simp->WriteToSaveGame( savefile );
3579  } else if ( window.win ) {
3580  window.win->WriteToSaveGame( savefile );
3581  }
3582  }
3583 }
3584 
3585 /*
3586 ===============
3587 idWindow::ReadSaveGameString
3588 ===============
3589 */
3590 void idWindow::ReadSaveGameString( idStr &string, idFile *savefile ) {
3591  int len;
3592 
3593  savefile->Read( &len, sizeof( len ) );
3594  if ( len < 0 ) {
3595  common->Warning( "idWindow::ReadSaveGameString: invalid length" );
3596  }
3597 
3598  string.Fill( ' ', len );
3599  savefile->Read( &string[0], len );
3600 }
3601 
3602 /*
3603 ===============
3604 idWindow::ReadFromSaveGame
3605 ===============
3606 */
3608  int i;
3609 
3610  transitions.Clear();
3611 
3612  ReadSaveGameString( cmd, savefile );
3613 
3614  savefile->Read( &actualX, sizeof( actualX ) );
3615  savefile->Read( &actualY, sizeof( actualY ) );
3616  savefile->Read( &childID, sizeof( childID ) );
3617  savefile->Read( &flags, sizeof( flags ) );
3618  savefile->Read( &lastTimeRun, sizeof( lastTimeRun ) );
3619  savefile->Read( &drawRect, sizeof( drawRect ) );
3620  savefile->Read( &clientRect, sizeof( clientRect ) );
3621  savefile->Read( &origin, sizeof( origin ) );
3622  savefile->Read( &fontNum, sizeof( fontNum ) );
3623  savefile->Read( &timeLine, sizeof( timeLine ) );
3624  savefile->Read( &xOffset, sizeof( xOffset ) );
3625  savefile->Read( &yOffset, sizeof( yOffset ) );
3626  savefile->Read( &cursor, sizeof( cursor ) );
3627  savefile->Read( &forceAspectWidth, sizeof( forceAspectWidth ) );
3628  savefile->Read( &forceAspectHeight, sizeof( forceAspectHeight ) );
3629  savefile->Read( &matScalex, sizeof( matScalex ) );
3630  savefile->Read( &matScaley, sizeof( matScaley ) );
3631  savefile->Read( &borderSize, sizeof( borderSize ) );
3632  savefile->Read( &textAlign, sizeof( textAlign ) );
3633  savefile->Read( &textAlignx, sizeof( textAlignx ) );
3634  savefile->Read( &textAligny, sizeof( textAligny ) );
3635  savefile->Read( &textShadow, sizeof( textShadow ) );
3636  savefile->Read( &shear, sizeof( shear ) );
3637 
3638  ReadSaveGameString( name, savefile );
3639  ReadSaveGameString( comment, savefile );
3640 
3641  // WinVars
3642  noTime.ReadFromSaveGame( savefile );
3643  visible.ReadFromSaveGame( savefile );
3644  rect.ReadFromSaveGame( savefile );
3645  backColor.ReadFromSaveGame( savefile );
3646  matColor.ReadFromSaveGame( savefile );
3647  foreColor.ReadFromSaveGame( savefile );
3648  hoverColor.ReadFromSaveGame( savefile );
3649  borderColor.ReadFromSaveGame( savefile );
3650  textScale.ReadFromSaveGame( savefile );
3651  noEvents.ReadFromSaveGame( savefile );
3652  rotate.ReadFromSaveGame( savefile );
3653  text.ReadFromSaveGame( savefile );
3654  backGroundName.ReadFromSaveGame( savefile );
3655 
3656  if ( session->GetSaveGameVersion() >= 17 ) {
3657  hideCursor.ReadFromSaveGame(savefile);
3658  } else {
3659  hideCursor = false;
3660  }
3661 
3662  // Defined Vars
3663  for ( i = 0; i < definedVars.Num(); i++ ) {
3664  definedVars[i]->ReadFromSaveGame( savefile );
3665  }
3666 
3667  savefile->Read( &textRect, sizeof( textRect ) );
3668 
3669  // Window pointers saved as the child ID of the window
3670  int winID = -1;
3671 
3672  savefile->Read( &winID, sizeof( winID ) );
3673  for ( i = 0; i < children.Num(); i++ ) {
3674  if ( children[i]->childID == winID ) {
3675  focusedChild = children[i];
3676  }
3677  }
3678  savefile->Read( &winID, sizeof( winID ) );
3679  for ( i = 0; i < children.Num(); i++ ) {
3680  if ( children[i]->childID == winID ) {
3681  captureChild = children[i];
3682  }
3683  }
3684  savefile->Read( &winID, sizeof( winID ) );
3685  for ( i = 0; i < children.Num(); i++ ) {
3686  if ( children[i]->childID == winID ) {
3687  overChild = children[i];
3688  }
3689  }
3690 
3691  // Scripts
3692  for ( i = 0; i < SCRIPT_COUNT; i++ ) {
3693  if ( scripts[i] ) {
3694  scripts[i]->ReadFromSaveGame( savefile );
3695  }
3696  }
3697 
3698  // TimeLine Events
3699  for ( i = 0; i < timeLineEvents.Num(); i++ ) {
3700  if ( timeLineEvents[i] ) {
3701  savefile->Read( &timeLineEvents[i]->pending, sizeof( timeLineEvents[i]->pending ) );
3702  savefile->Read( &timeLineEvents[i]->time, sizeof( timeLineEvents[i]->time ) );
3703  if ( timeLineEvents[i]->event ) {
3704  timeLineEvents[i]->event->ReadFromSaveGame( savefile );
3705  }
3706  }
3707  }
3708 
3709 
3710  // Transitions
3711  int num;
3712  savefile->Read( &num, sizeof( num ) );
3713  for ( i = 0; i < num; i++ ) {
3714  idTransitionData trans;
3715  trans.data = NULL;
3716  ReadSaveGameTransition( trans, savefile );
3717  if ( trans.data ) {
3718  transitions.Append( trans );
3719  }
3720  }
3721 
3722 
3723  // Named Events
3724  for ( i = 0; i < namedEvents.Num(); i++ ) {
3725  if ( namedEvents[i] ) {
3726  ReadSaveGameString( namedEvents[i]->mName, savefile );
3727  if ( namedEvents[i]->mEvent ) {
3728  namedEvents[i]->mEvent->ReadFromSaveGame( savefile );
3729  }
3730  }
3731  }
3732 
3733  // regList
3734  regList.ReadFromSaveGame( savefile );
3735 
3736  // Read children
3737  for ( i = 0; i < drawWindows.Num(); i++ ) {
3739 
3740  if ( window.simp ) {
3741  window.simp->ReadFromSaveGame( savefile );
3742  } else if ( window.win ) {
3743  window.win->ReadFromSaveGame( savefile );
3744  }
3745  }
3746 
3747  if ( flags & WIN_DESKTOP ) {
3748  FixupTransitions();
3749  }
3750 }
3751 
3752 /*
3753 ===============
3754 idWindow::NumTransitions
3755 ===============
3756 */
3758  int c = transitions.Num();
3759  for ( int i = 0; i < children.Num(); i++ ) {
3760  c += children[i]->NumTransitions();
3761  }
3762  return c;
3763 }
3764 
3765 
3766 /*
3767 ===============
3768 idWindow::FixupTransitions
3769 ===============
3770 */
3772  int i, c = transitions.Num();
3773  for ( i = 0; i < c; i++ ) {
3774  drawWin_t *dw = gui->GetDesktop()->FindChildByName( ( ( idWinStr* )transitions[i].data )->c_str() );
3775  delete transitions[i].data;
3776  transitions[i].data = NULL;
3777  if ( dw && ( dw->win || dw->simp ) ){
3778  if ( dw->win ) {
3779  if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->rect ) {
3780  transitions[i].data = &dw->win->rect;
3781  } else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->backColor ) {
3782  transitions[i].data = &dw->win->backColor;
3783  } else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->matColor ) {
3784  transitions[i].data = &dw->win->matColor;
3785  } else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->foreColor ) {
3786  transitions[i].data = &dw->win->foreColor;
3787  } else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->borderColor ) {
3788  transitions[i].data = &dw->win->borderColor;
3789  } else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->textScale ) {
3790  transitions[i].data = &dw->win->textScale;
3791  } else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->rotate ) {
3792  transitions[i].data = &dw->win->rotate;
3793  }
3794  } else {
3795  if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->rect ) {
3796  transitions[i].data = &dw->simp->rect;
3797  } else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->backColor ) {
3798  transitions[i].data = &dw->simp->backColor;
3799  } else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->matColor ) {
3800  transitions[i].data = &dw->simp->matColor;
3801  } else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->foreColor ) {
3802  transitions[i].data = &dw->simp->foreColor;
3803  } else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->borderColor ) {
3804  transitions[i].data = &dw->simp->borderColor;
3805  } else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->textScale ) {
3806  transitions[i].data = &dw->simp->textScale;
3807  } else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->rotate ) {
3808  transitions[i].data = &dw->simp->rotate;
3809  }
3810  }
3811  }
3812  if ( transitions[i].data == NULL ) {
3813  transitions.RemoveIndex( i );
3814  i--;
3815  c--;
3816  }
3817  }
3818  for ( c = 0; c < children.Num(); c++ ) {
3819  children[c]->FixupTransitions();
3820  }
3821 }
3822 
3823 
3824 /*
3825 ===============
3826 idWindow::AddChild
3827 ===============
3828 */
3830  win->childID = children.Append(win);
3831 }
3832 
3833 /*
3834 ================
3835 idWindow::FixupParms
3836 ================
3837 */
3839  int i;
3840  int c = children.Num();
3841  for (i = 0; i < c; i++) {
3842  children[i]->FixupParms();
3843  }
3844  for (i = 0; i < SCRIPT_COUNT; i++) {
3845  if (scripts[i]) {
3846  scripts[i]->FixupParms(this);
3847  }
3848  }
3849 
3850  c = timeLineEvents.Num();
3851  for (i = 0; i < c; i++) {
3852  timeLineEvents[i]->event->FixupParms(this);
3853  }
3854 
3855  c = namedEvents.Num();
3856  for (i = 0; i < c; i++) {
3857  namedEvents[i]->mEvent->FixupParms(this);
3858  }
3859 
3860  c = ops.Num();
3861  for (i = 0; i < c; i++) {
3862  if (ops[i].b == -2) {
3863  // need to fix this up
3864  const char *p = (const char*)(ops[i].a);
3865  idWinVar *var = GetWinVarByName(p, true);
3866  delete []p;
3867  ops[i].a = (int)var;
3868  ops[i].b = -1;
3869  }
3870  }
3871 
3872 
3873  if (flags & WIN_DESKTOP) {
3874  CalcRects(0,0);
3875  }
3876 
3877 }
3878 
3879 /*
3880 ================
3881 idWindow::IsSimple
3882 ================
3883 */
3885 
3886  // dont do simple windows when in gui editor
3887  if ( com_editors & EDITOR_GUI ) {
3888  return false;
3889  }
3890 
3891  if (ops.Num()) {
3892  return false;
3893  }
3894  if (flags & (WIN_HCENTER | WIN_VCENTER)) {
3895  return false;
3896  }
3897  if (children.Num() || drawWindows.Num()) {
3898  return false;
3899  }
3900  for (int i = 0; i < SCRIPT_COUNT; i++) {
3901  if (scripts[i]) {
3902  return false;
3903  }
3904  }
3905  if (timeLineEvents.Num()) {
3906  return false;
3907  }
3908 
3909  if ( namedEvents.Num() ) {
3910  return false;
3911  }
3912 
3913  return true;
3914 }
3915 
3916 /*
3917 ================
3918 idWindow::ContainsStateVars
3919 ================
3920 */
3922  if ( updateVars.Num() ) {
3923  return true;
3924  }
3925  int c = children.Num();
3926  for (int i = 0; i < c; i++) {
3927  if ( children[i]->ContainsStateVars() ) {
3928  return true;
3929  }
3930  }
3931  return false;
3932 }
3933 
3934 /*
3935 ================
3936 idWindow::Interactive
3937 ================
3938 */
3940  if ( scripts[ ON_ACTION ] ) {
3941  return true;
3942  }
3943  int c = children.Num();
3944  for (int i = 0; i < c; i++) {
3945  if (children[i]->Interactive()) {
3946  return true;
3947  }
3948  }
3949  return false;
3950 }
3951 
3952 /*
3953 ================
3954 idWindow::SetChildWinVarVal
3955 ================
3956 */
3957 void idWindow::SetChildWinVarVal(const char *name, const char *var, const char *val) {
3958  drawWin_t *dw = FindChildByName(name);
3959  idWinVar *wv = NULL;
3960  if (dw && dw->simp) {
3961  wv = dw->simp->GetWinVarByName(var);
3962  } else if (dw && dw->win) {
3963  wv = dw->win->GetWinVarByName(var);
3964  }
3965  if (wv) {
3966  wv->Set(val);
3967  wv->SetEval(false);
3968  }
3969 }
3970 
3971 
3972 /*
3973 ================
3974 idWindow::FindChildByPoint
3975 
3976 Finds the window under the given point
3977 ================
3978 */
3979 idWindow* idWindow::FindChildByPoint ( float x, float y, idWindow** below ) {
3980  int c = children.Num();
3981 
3982  // If we are looking for a window below this one then
3983  // the next window should be good, but this one wasnt it
3984  if ( *below == this ) {
3985  *below = NULL;
3986  return NULL;
3987  }
3988 
3989  if ( !Contains ( drawRect, x, y ) ) {
3990  return NULL;
3991  }
3992 
3993  for (int i = c - 1; i >= 0 ; i-- ) {
3994  idWindow* found = children[i]->FindChildByPoint ( x, y, below );
3995  if ( found ) {
3996  if ( *below ) {
3997  continue;
3998  }
3999 
4000  return found;
4001  }
4002  }
4003 
4004  return this;
4005 }
4006 
4007 /*
4008 ================
4009 idWindow::FindChildByPoint
4010 ================
4011 */
4013 {
4014  return FindChildByPoint ( x, y, &below );
4015 }
4016 
4017 /*
4018 ================
4019 idWindow::GetChildCount
4020 
4021 Returns the number of children
4022 ================
4023 */
4025 {
4026  return drawWindows.Num ( );
4027 }
4028 
4029 /*
4030 ================
4031 idWindow::GetChild
4032 
4033 Returns the child window at the given index
4034 ================
4035 */
4037 {
4038  return drawWindows[index].win;
4039 }
4040 
4041 /*
4042 ================
4043 idWindow::GetChildIndex
4044 
4045 Returns the index of the given child window
4046 ================
4047 */
4049  int find;
4050  for ( find = 0; find < drawWindows.Num(); find ++ ) {
4051  if ( drawWindows[find].win == window ) {
4052  return find;
4053  }
4054  }
4055  return -1;
4056 }
4057 
4058 /*
4059 ================
4060 idWindow::RemoveChild
4061 
4062 Removes the child from the list of children. Note that the child window being
4063 removed must still be deallocated by the caller
4064 ================
4065 */
4067  int find;
4068 
4069  // Remove the child window
4070  children.Remove ( win );
4071 
4072  for ( find = 0; find < drawWindows.Num(); find ++ )
4073  {
4074  if ( drawWindows[find].win == win )
4075  {
4076  drawWindows.RemoveIndex ( find );
4077  break;
4078  }
4079  }
4080 }
4081 
4082 /*
4083 ================
4084 idWindow::InsertChild
4085 
4086 Inserts the given window as a child into the given location in the zorder.
4087 ================
4088 */
4090 {
4091  AddChild ( win );
4092 
4093  win->parent = this;
4094 
4095  drawWin_t dwt;
4096  dwt.simp = NULL;
4097  dwt.win = win;
4098 
4099  // If not inserting before anything then just add it at the end
4100  if ( before ) {
4101  int index;
4102  index = GetChildIndex ( before );
4103  if ( index != -1 ) {
4104  drawWindows.Insert ( dwt, index );
4105  return true;
4106  }
4107  }
4108 
4109  drawWindows.Append ( dwt );
4110  return true;
4111 }
4112 
4113 /*
4114 ================
4115 idWindow::ScreenToClient
4116 ================
4117 */
4119  int x;
4120  int y;
4121  idWindow* p;
4122 
4123  for ( p = this, x = 0, y = 0; p; p = p->parent ) {
4124  x += p->rect.x();
4125  y += p->rect.y();
4126  }
4127 
4128  r->x -= x;
4129  r->y -= y;
4130 }
4131 
4132 /*
4133 ================
4134 idWindow::ClientToScreen
4135 ================
4136 */
4138  int x;
4139  int y;
4140  idWindow* p;
4141 
4142  for ( p = this, x = 0, y = 0; p; p = p->parent ) {
4143  x += p->rect.x();
4144  y += p->rect.y();
4145  }
4146 
4147  r->x += x;
4148  r->y += y;
4149 }
4150 
4151 /*
4152 ================
4153 idWindow::SetDefaults
4154 
4155 Set the window do a default window with no text, no background and
4156 default colors, etc..
4157 ================
4158 */
4159 void idWindow::SetDefaults ( void ) {
4160  forceAspectWidth = 640.0f;
4161  forceAspectHeight = 480.0f;
4162  matScalex = 1;
4163  matScaley = 1;
4164  borderSize = 0;
4165  noTime = false;
4166  visible = true;
4167  textAlign = 0;
4168  textAlignx = 0;
4169  textAligny = 0;
4170  noEvents = false;
4171  rotate = 0;
4172  shear.Zero();
4173  textScale = 0.35f;
4174  backColor.Zero();
4175  foreColor = idVec4(1, 1, 1, 1);
4176  hoverColor = idVec4(1, 1, 1, 1);
4177  matColor = idVec4(1, 1, 1, 1);
4178  borderColor.Zero();
4179  text = "";
4180 
4181  background = NULL;
4182  backGroundName = "";
4183 }
4184 
4185 /*
4186 ================
4187 idWindow::UpdateFromDictionary
4188 
4189 The editor only has a dictionary to work with so the easiest way to push the
4190 values of the dictionary onto the window is for the window to interpret the
4191 dictionary as if were a file being parsed.
4192 ================
4193 */
4195  const idKeyValue* kv;
4196  int i;
4197 
4198  SetDefaults ( );
4199 
4200  // Clear all registers since they will get recreated
4201  regList.Reset ( );
4203  ops.Clear ( );
4204 
4205  for ( i = 0; i < dict.GetNumKeyVals(); i ++ ) {
4206  kv = dict.GetKeyVal ( i );
4207 
4208  // Special case name
4209  if ( !kv->GetKey().Icmp ( "name" ) ) {
4210  name = kv->GetValue();
4211  continue;
4212  }
4213 
4214  idParser src( kv->GetValue().c_str(), kv->GetValue().Length(), "",
4216  if ( !ParseInternalVar ( kv->GetKey(), &src ) ) {
4217  // Kill the old register since the parse reg entry will add a new one
4218  if ( !ParseRegEntry ( kv->GetKey(), &src ) ) {
4219  continue;
4220  }
4221  }
4222  }
4223 
4224  EvalRegs(-1, true);
4225 
4226  SetupFromState();
4227  PostParse();
4228 
4229  return true;
4230 }
static bool IsDown(int keyNum)
Definition: KeyInput.cpp:271
void SetTransformInfo(const idVec3 &origin, const idMat3 &mat)
static idCVar gui_edit
Definition: Window.h:430
virtual int ReadUnsignedChar(unsigned char &value)
Definition: File.cpp:364
idList< float > expressionRegisters
Definition: Window.h:441
void Error(const char *str,...) const id_attribute((format(printf
Definition: Parser.cpp:318
void UpdateWinVars()
Definition: Window.cpp:584
virtual int WriteUnsignedChar(const unsigned char value)
Definition: File.cpp:517
idList< idTimeLineEvent * > timeLineEvents
Definition: Window.h:435
void ReadFromDemoFile(idDemoFile *f)
Definition: RegExp.cpp:348
void ResetTime(int time)
Definition: Window.cpp:2646
float GetMaxCharHeight()
Definition: Window.cpp:303
int type
Definition: Token.h:77
virtual void Set(const char *val)=0
idWinBool noTime
Definition: Window.h:396
virtual int virtual int ReadInt(int &value)
Definition: File.cpp:311
idWinFloat textScale
Definition: Window.h:405
virtual void Sized()
Definition: Window.cpp:1443
assert(prefInfo.fullscreenBtn)
int Length()
Definition: Winvar.h:192
int ExpressionConstant(float f)
Definition: Window.cpp:2702
bool ParseScript(idParser *src, idGuiScriptList &list, int *timeParm=NULL, bool allowIf=false)
Definition: Window.cpp:1571
void UnreadToken(idToken *token)
Definition: Parser.cpp:2745
const type & GetEndValue(void) const
Definition: Interpolate.h:149
idMat3 mat3_identity(idVec3(1, 0, 0), idVec3(0, 1, 0), idVec3(0, 0, 1))
virtual void WriteToSaveGame(idFile *savefile)
Definition: Winvar.h:228
void ToLower(void)
Definition: Str.h:817
bool UpdateFromDictionary(idDict &dict)
Definition: Window.cpp:4194
bool Contains(float x, float y)
Definition: Window.cpp:681
virtual void ReadFromSaveGame(idFile *savefile)
virtual int ReadVec4(idVec4 &vec)
Definition: File.cpp:435
void ScreenToClient(idRectangle *rect)
Definition: Window.cpp:4118
const int WIN_NOWRAP
Definition: Window.h:54
signed char textShadow
Definition: Window.h:391
float y
Definition: Vector.h:811
float y
Definition: Vector.h:55
virtual void MouseExit()
Definition: Window.cpp:406
const char * GetName()
Definition: Window.h:247
void ResetCinematicTime(int time) const
Definition: Material.cpp:2575
const GLdouble * v
Definition: glext.h:2936
idGuiScriptList * event
Definition: Window.h:129
const idStr & GetKey(void) const
Definition: Dict.h:52
idRegisterList regList
Definition: Window.h:446
void SetNum(int newnum, bool resize=true)
Definition: List.h:289
int GetWinVarOffset(idWinVar *wv, drawWin_t *dw)
Definition: Window.cpp:1717
virtual void StateChanged(bool redraw)
Definition: Window.cpp:518
void Offset(float x, float y)
Definition: Rectangle.h:44
const int WIN_TRANSFORM
Definition: Window.h:52
#define TT_NAME
Definition: Token.h:44
unsigned int flags
Definition: Window.h:371
int EmitOp(int a, int b, wexpOpType_t opType, wexpOp_t **opp=NULL)
Definition: Window.cpp:2766
int Length(void) const
Definition: Str.h:702
void RestoreExpressionParseState()
Definition: Window.cpp:1671
virtual void ArchiveToDictionary(idDict *dict, bool useNames=true)
Definition: Window.cpp:1317
idStr comment
Definition: Window.h:388
idWinBool noEvents
Definition: Window.h:398
virtual bool ParseInternalVar(const char *name, idParser *src)
Definition: Window.cpp:1915
idList< idWindow * > children
Definition: Window.h:417
bool IsSimple()
Definition: Window.cpp:3884
const int WIN_VCENTER
Definition: Window.h:47
const int WIN_MOVABLE
Definition: Window.h:43
virtual void ReadFromSaveGame(idFile *savefile)
Definition: Winvar.h:467
void GetFromRegs(float *registers)
Definition: RegExp.cpp:299
void UpdateCinematic(int time) const
Definition: Material.cpp:2548
drawWin_t * FindChildByName(const char *name)
Definition: Window.cpp:2573
void Set(const float x, const float y, const float z)
Definition: Vector.h:409
idWindow(idUserInterfaceLocal *gui)
Definition: Window.cpp:220
void BringToTop(idWindow *w)
Definition: Window.cpp:353
#define TT_INTEGER
Definition: Token.h:48
void DisableRegister(const char *_name)
Definition: Window.cpp:1697
void AddCommand(const char *cmd)
Definition: Window.cpp:693
virtual ~idWindow()
Definition: Window.cpp:269
GLenum GLint GLint y
Definition: glext.h:2849
idList< drawWin_t > drawWindows
Definition: Window.h:418
idWinVec4 matColor
Definition: Window.h:401
idList< float > * saveRegs
Definition: Window.h:444
GLenum GLsizei n
Definition: glext.h:3705
virtual void WriteToSaveGame(idFile *savefile)
float z
Definition: Vector.h:812
bool ContainsStateVars()
Definition: Window.cpp:3921
case const int
Definition: Callbacks.cpp:52
signed char textAlign
Definition: Window.h:394
const int WIN_SELECTED
Definition: Window.h:51
void ClientToScreen(idRectangle *rect)
Definition: Window.cpp:4137
float xOffset
Definition: Window.h:378
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:2846
int subtype
Definition: Token.h:78
void FixupParms(idWindow *win)
Definition: GuiScript.cpp:587
const int WIN_FOCUS
Definition: Window.h:44
wexpOpType_t
Definition: Window.h:79
int lastTimeRun
Definition: Window.h:372
float w() const
Definition: Winvar.h:420
void ParseString(idParser *src, idStr &out)
Definition: Window.cpp:1883
float GetFloatValue(void)
Definition: Token.h:138
void SetFont()
Definition: Window.cpp:294
Definition: Vector.h:316
virtual int GetSaveGameVersion(void)=0
void Enable(bool b)
Definition: RegExp.h:53
virtual void WriteToSaveGame(idFile *savefile)
Definition: Window.cpp:3464
static idVec4 colorWhite
idWinFloat rotate
Definition: Window.h:406
idRegisterList * RegList()
Definition: Window.h:305
virtual void WriteToSaveGame(idFile *savefile)
Definition: Winvar.h:622
void ParseVec4(idParser *src, idVec4 &out)
Definition: Window.cpp:1895
const char * Left(int len, idStr &result) const
Definition: Str.h:892
virtual void GainCapture()
Definition: Window.cpp:1467
const int WIN_MENUGUI
Definition: Window.h:59
int GetImageHeight(void) const
Definition: Material.cpp:2526
int c
Definition: Window.h:109
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
int ExpectTokenString(const char *string)
Definition: Parser.cpp:2402
Definition: Token.h:71
void PushClipRect(float x, float y, float w, float h)
int d
Definition: Window.h:109
idDeviceContext * dc
Definition: Window.h:425
void FixupParms()
Definition: Window.cpp:3838
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
idWinVec4 borderColor
Definition: SimpleWindow.h:88
const int WIN_SHOWTIME
Definition: Window.h:62
GLuint src
Definition: glext.h:5390
GLenum GLsizei len
Definition: glext.h:3472
void Set(const char *key, const char *value)
Definition: Dict.cpp:275
float y() const
Definition: Winvar.h:417
virtual int WriteVec4(const idVec4 &vec)
Definition: File.cpp:581
void Identity(void)
Definition: Matrix.h:591
const idMaterial * background
Definition: Window.h:414
idWinRectangle rect
Definition: SimpleWindow.h:84
GLenum GLint x
Definition: glext.h:2849
int i
Definition: process.py:33
idGuiScriptList * scripts[SCRIPT_COUNT]
Definition: Window.h:432
virtual void Trigger()
Definition: Window.cpp:504
GLintptr offset
Definition: glext.h:3113
void SetFont(int num)
GLuint GLuint num
Definition: glext.h:5390
int test(char *url)
Definition: lib500.c:3
void DebugDraw(int time, float x, float y)
Definition: Window.cpp:959
void SetDC(idDeviceContext *d)
Definition: Window.cpp:1301
int Icmp(const char *text) const
Definition: Str.h:667
void AddReg(const char *name, int type, idParser *src, idWindow *win, idWinVar *var)
Definition: RegExp.cpp:249
const int WIN_CAPTURE
Definition: Window.h:45
float forceAspectWidth
Definition: Window.h:380
int FindFont(const char *name)
virtual void WriteToSaveGame(idFile *savefile)
Definition: Winvar.h:137
virtual void MouseEnter()
Definition: Window.cpp:392
#define TT_NUMBER
Definition: Token.h:43
idWindow * overChild
Definition: Window.h:422
virtual void LoseCapture()
Definition: Window.cpp:1475
void Zero(void)
Definition: Vector.h:119
idWindow * win
Definition: SimpleWindow.h:37
int timeLine
Definition: Window.h:377
idWinVec4 foreColor
Definition: SimpleWindow.h:87
int ParseExpressionPriority(idParser *src, int priority, idWinVar *var=NULL, int component=0)
Definition: Window.cpp:2920
unsigned char cursor
Definition: Window.h:393
virtual void WriteToDemoFile(class idDemoFile *f)
Definition: Window.cpp:3319
float borderSize
Definition: Window.h:384
bool pending
Definition: Window.h:130
void ReadFromSaveGame(idFile *savefile)
Definition: RegExp.cpp:395
int com_editors
Definition: Common.cpp:97
void CalcRects(float x, float y)
Definition: Window.cpp:1173
Definition: File.h:50
int ReadToken(idToken *token)
Definition: Parser.cpp:2338
void SetParent(idWindow *w)
Definition: Window.cpp:1503
virtual void Draw(int time, float x, float y)
Definition: Window.cpp:323
idWindow * FindChildByPoint(float x, float y, idWindow *below=NULL)
Definition: Window.cpp:4012
const int USERCMD_MSEC
Definition: UsercmdGen.h:41
virtual void WriteToSaveGame(idFile *savefile)
Definition: Winvar.h:355
idRectangle clientRect
Definition: Window.h:374
Definition: Lexer.h:137
bool ParseBool(void)
Definition: Parser.cpp:2797
idWindow * focusedChild
Definition: Window.h:420
virtual size_t Size()
Definition: Winvar.h:222
idList< idWinVar * > updateVars
Definition: Window.h:411
idWinFloat rotate
Definition: SimpleWindow.h:90
void AddUpdateVar(idWinVar *var)
Definition: Window.cpp:575
idWinBool visible
Definition: Window.h:397
#define TOP_PRIORITY
Definition: Window.cpp:2919
int GetFlags(void) const
Definition: Parser.cpp:3004
idStr * GetStrPtrByName(const char *_name)
Definition: Window.cpp:2604
idRectangle drawRect
Definition: Window.h:373
int Index(void) const
Definition: DeclManager.h:165
void Init(const float startTime, const float accelTime, const float decelTime, const float duration, const type &startValue, const type &endValue)
Definition: Interpolate.h:182
void GetStringFromMarker(idStr &out, bool clean=false)
Definition: Parser.cpp:2929
int conditionReg
Definition: GuiScript.h:72
void Time()
Definition: Window.cpp:1048
virtual void Activate(bool activate, idStr &act)
Definition: Window.cpp:481
virtual void ReadFromSaveGame(idFile *savefile)
Definition: Winvar.h:626
int MaxCharWidth(float scale)
float matScalex
Definition: Window.h:382
idGuiScriptList * mEvent
Definition: Window.h:155
virtual void DrawBackground(const idRectangle &drawRect)
Definition: Window.cpp:1107
virtual int WriteInt(const int value)
Definition: File.cpp:468
virtual void PostParse()
Definition: Window.cpp:1709
void WriteToSaveGame(idFile *savefile)
Definition: GuiScript.cpp:606
bool RunTimeEvents(int time)
Definition: Window.cpp:596
void Zero()
Definition: Winvar.h:611
idWindow * parent
Definition: Window.h:416
int ParseInt(void)
Definition: Parser.cpp:2775
int DrawText(const char *text, float textScale, int textAlign, idVec4 color, idRectangle rectDraw, bool wrap, int cursor=-1, bool calcOnly=false, idList< int > *breaks=NULL, int limit=0)
GLuint index
Definition: glext.h:3476
idRegister * FindReg(const char *name)
Definition: RegExp.cpp:323
const GLubyte * c
Definition: glext.h:4677
const char * GetString(const char *key, const char *defaultString="") const
Definition: Dict.h:240
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:3454
Definition: Vector.h:808
virtual void WriteToSaveGame(idFile *savefile)
Definition: Winvar.h:810
idDict & GetScriptDict(void)
virtual void InitFromDictionary(idDict *dict, bool byName=true)
Definition: Window.cpp:1330
idVec3 vec3_origin(0.0f, 0.0f, 0.0f)
virtual void DrawCursor()
const int WIN_MODAL
Definition: Window.h:48
idWinVec4 matColor
Definition: SimpleWindow.h:86
void Reset()
Definition: RegExp.cpp:338
virtual void Init(const char *_name, idWindow *win)=0
Definition: Winvar.cpp:53
float y
Definition: Rectangle.h:37
const int WIN_WANTENTER
Definition: Window.h:63
idWinVec4 backColor
Definition: SimpleWindow.h:85
idCommon * common
Definition: Common.cpp:206
void DrawFilledRect(float x, float y, float width, float height, const idVec4 &color)
idList< wexpOp_t > ops
Definition: Window.h:440
bool * saveTemps
Definition: Window.h:433
Definition: Dict.h:65
#define NULL
Definition: Lib.h:88
idSimpleWindow * FindSimpleWinByName(const char *_name)
Definition: Window.cpp:2555
int b
Definition: Window.h:109
virtual const idDecl * FindType(declType_t type, const char *name, bool makeDefault=true)=0
bool IsIdentity(const float epsilon=MATRIX_EPSILON) const
Definition: Matrix.h:595
float actualY
Definition: Window.h:369
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:2853
int evValue2
Definition: sys_public.h:218
int GetInteger(void) const
Definition: CVarSystem.h:143
idGuiScriptList * ifList
Definition: GuiScript.h:73
void ReadFromDemoFile(class idDemoFile *f)
Definition: GuiScript.h:98
virtual float CursorY()
float EvalRegs(int test=-1, bool force=false)
Definition: Window.cpp:1079
float w() const
Definition: Winvar.h:588
void GetTransformInfo(idVec3 &origin, idMat3 &mat)
bool IsDone(float time) const
Definition: Interpolate.h:141
idDict & GetVariableDict(void)
unsigned char fontNum
Definition: Window.h:392
float forceAspectHeight
Definition: Window.h:381
size_t Size(void) const
Definition: List.h:242
const int WIN_NATURALMAT
Definition: Window.h:57
const char * GetSourceFile(void) const
virtual void virtual void FatalError(const char *fmt,...) id_attribute((format(printf
idWinVec4 foreColor
Definition: Window.h:402
virtual int Read(void *buffer, int len)
Definition: File.cpp:179
idWindow * SetCapture(idWindow *w)
Definition: Window.cpp:550
const int WIN_CANFOCUS
Definition: Window.h:50
void SetMaterialPtr(const idMaterial **m)
Definition: Winvar.h:806
float w
Definition: Vector.h:813
virtual bool Parse(idParser *src, bool rebuild=true)
Definition: Window.cpp:2130
static const char * ScriptNames[SCRIPT_COUNT]
Definition: Window.h:199
float x
Definition: Vector.h:54
float matScaley
Definition: Window.h:383
void EnableClipping(bool b)
Definition: DeviceContext.h:90
Definition: KeyInput.h:47
float x() const
Definition: Winvar.h:414
void SetName(const char *_name)
Definition: Winvar.h:53
void void Warning(const char *str,...) const id_attribute((format(printf
Definition: Parser.cpp:335
idList< wexpOp_t > * saveOps
Definition: Window.h:442
size_t Size()
Definition: GuiScript.h:90
virtual const char * RouteMouseCoords(float xd, float yd)
Definition: Window.cpp:421
const idStr & GetValue(void) const
Definition: Dict.h:53
float ParseFloat(void)
Definition: Parser.cpp:2812
float GetMaxCharWidth()
Definition: Window.cpp:313
void DeleteContents(bool clear)
Definition: List.h:207
void Mem_Free(void *ptr)
Definition: Heap.cpp:1087
void DrawBorderAndCaption(const idRectangle &drawRect)
Definition: Window.cpp:1130
virtual size_t Allocated()
Definition: Window.cpp:179
void Clear(void)
Definition: Str.h:724
virtual void ReadFromSaveGame(idFile *savefile)
Definition: Winvar.h:141
const char * Right(int len, idStr &result) const
Definition: Str.h:896
idWindow * GetCaptureChild()
Definition: Window.cpp:1512
int Find(const char c, int start=0, int end=-1) const
Definition: Str.h:874
static const idRegEntry RegisterVars[]
Definition: Window.h:201
int NumTransitions()
Definition: Window.cpp:3757
idStr & RemoveColors(void)
Definition: Str.h:849
void SetupTransforms(float x, float y)
Definition: Window.cpp:1141
virtual const idDict & State() const
void Move(float x, float y)
Definition: Window.cpp:278
int MaxCharHeight(float scale)
static idCVar gui_debug
Definition: Window.h:429
GLubyte GLubyte GLubyte a
Definition: glext.h:4662
idWindow * GetDesktop() const
void SaveExpressionParseState()
Definition: Window.cpp:1661
idList< idTransitionData > transitions
Definition: Window.h:436
int ExpectAnyToken(idToken *token)
Definition: Parser.cpp:2476
int CinematicLength(void) const
Definition: Material.cpp:2536
void ReadSaveGameString(idStr &string, idFile *savefile)
Definition: Window.cpp:3590
idWinVar * GetWinVarByName(const char *_name)
void WriteSaveGameString(const char *string, idFile *savefile)
Definition: Window.cpp:3404
const int WIN_SHOWCOORDS
Definition: Window.h:61
idWinStr text
Definition: Window.h:407
const int WIN_INTRANSITION
Definition: Window.h:49
virtual int ReadBool(bool &value)
Definition: File.cpp:384
sysEventType_t evType
Definition: sys_public.h:216
void Set(const idVec3 &rotationOrigin, const idVec3 &rotationVec, const float rotationAngle)
Definition: Rotation.h:108
void RemoveChild(idWindow *win)
Definition: Window.cpp:4066
idStr cmd
Definition: Window.h:316
virtual void ReadFromSaveGame(idFile *savefile)
Definition: Winvar.h:819
virtual void RunNamedEvent(const char *eventName)
Definition: Window.cpp:633
idWinRectangle rect
Definition: Window.h:399
float x
Definition: Rectangle.h:36
virtual int ReadUnsignedInt(unsigned int &value)
Definition: File.cpp:322
idDeclManager * declManager
void SetInitialState(const char *_name)
Definition: Window.cpp:2114
void ParseBracedExpression(idParser *src)
Definition: Window.cpp:3012
void Transition()
Definition: Window.cpp:998
virtual size_t Size()
Definition: Winvar.h:801
GLubyte GLubyte b
Definition: glext.h:4662
const int WIN_HCENTER
Definition: Window.h:46
void CommonInit()
Definition: Window.cpp:112
idVec2 shear
Definition: Window.h:389
void ResetCinematics()
Definition: Window.cpp:2635
idWindow * SetFocus(idWindow *w, bool scripts=true)
Definition: Window.cpp:1537
virtual void ReadFromSaveGame(idFile *savefile)
Definition: Winvar.h:237
void WriteToSaveGame(idFile *savefile)
Definition: RegExp.cpp:379
bool ParseRegEntry(const char *name, idParser *src)
Definition: Window.cpp:2052
void SetToRegs(float *registers)
Definition: RegExp.cpp:311
idWinVec4 borderColor
Definition: Window.h:404
prefInfo window
bool RunScriptList(idGuiScriptList *src)
Definition: Window.cpp:2677
bool Interactive()
Definition: Window.cpp:3939
int ParseExpression(idParser *src, idWinVar *var=NULL, int component=0)
Definition: Window.cpp:3003
void Execute(idWindow *win)
Definition: GuiScript.cpp:410
idGuiScriptList * elseList
Definition: GuiScript.h:74
int Insert(const type &obj, int index=0)
Definition: List.h:679
void ClearFlag(unsigned int f)
Definition: Window.cpp:1493
float textAlignx
Definition: Window.h:385
int ExpressionTemporary()
Definition: Window.cpp:2733
int Append(const type &obj)
Definition: List.h:646
GLdouble GLdouble GLdouble r
Definition: glext.h:2951
void SetChildWinVarVal(const char *name, const char *var, const char *val)
Definition: Window.cpp:3957
idWinBool hideCursor
Definition: Window.h:448
static rvGEWindowWrapper * GetWrapper(idWindow *window)
Definition: Matrix.h:333
int Length()
Definition: Winvar.h:763
int a
Definition: Window.h:109
float textAligny
Definition: Window.h:386
int AddUnique(const type &obj)
Definition: List.h:742
idUserInterfaceLocal * gui
Definition: Window.h:427
bool GetBool(void) const
Definition: CVarSystem.h:142
virtual const idDecl * DeclByIndex(declType_t type, int index, bool forceParse=true)=0
idWinVec4 backColor
Definition: Window.h:400
tuple f
Definition: idal.py:89
virtual int WriteUnsignedInt(const unsigned int value)
Definition: File.cpp:478
idUserInterfaceLocal * GetGui()
Definition: Window.h:225
static bool registerIsTemporary[MAX_EXPRESSION_REGISTERS]
Definition: Window.h:438
const idMat3 & ToMat3(void) const
Definition: Rotation.cpp:60
int Num(void) const
Definition: List.h:265
bool RemoveIndex(int index)
Definition: List.h:849
const int WIN_INVERTRECT
Definition: Window.h:56
virtual int WriteFloat(const float value)
Definition: File.cpp:526
bool Contains(float xt, float yt)
Definition: Rectangle.h:48
const GLcharARB * name
Definition: glext.h:3629
void FixupTransitions()
Definition: Window.cpp:3771
idWindow * GetChild(int index)
Definition: Window.cpp:4036
virtual int Write(const void *buffer, int len)
Definition: File.cpp:189
void SetLog(bool b, const char *p)
Definition: DemoFile.cpp:130
Definition: Str.h:116
idWinFloat textScale
Definition: SimpleWindow.h:89
int GetImageWidth(void) const
Definition: Material.cpp:2516
int GetChildCount(void)
Definition: Window.cpp:4024
wexpOpType_t opType
Definition: Window.h:108
virtual void Redraw(float x, float y)
Definition: Window.cpp:1194
bool Parse(idParser *src)
Definition: GuiScript.cpp:345
const int WIN_NOCURSOR
Definition: Window.h:58
void SetMarker(void)
Definition: Parser.cpp:2918
float w
Definition: Rectangle.h:38
Window win
Definition: glimp.cpp:46
virtual const char * c_str() const
Definition: Winvar.h:204
void ReadSaveGameTransition(idTransitionData &trans, idFile *savefile)
Definition: Window.cpp:3441
const char * c_str(void) const
Definition: Str.h:487
bool InsertChild(idWindow *win, idWindow *before)
Definition: Window.cpp:4089
void SetCursor(int n)
void SetDefaults(void)
Definition: Window.cpp:4159
idList< rvNamedEvent * > namedEvents
Definition: Window.h:443
bool ParseScriptEntry(const char *name, idParser *src)
Definition: Window.cpp:1681
Definition: Window.h:112
size_t Size()
Definition: Window.cpp:164
bool TestMaterialFlag(const int flag) const
Definition: Material.h:494
idInterpolateAccelDecelLinear< idVec4 > interp
Definition: Window.h:161
void SetSort(float s) const
Definition: Material.h:513
idStr name
Definition: Window.h:387
const idKeyValue * GetKeyVal(int index) const
Definition: Dict.h:294
void CleanUp()
Definition: Window.cpp:242
virtual void ReadFromDemoFile(class idDemoFile *f, bool rebuild=true)
Definition: Window.cpp:3160
friend class idSimpleWindow
Definition: Window.h:341
const char * ReadHashString()
Definition: DemoFile.cpp:212
float h
Definition: Rectangle.h:39
GLuint interp
Definition: glext.h:5284
void SetImageClassifications(int tag) const
Definition: Material.cpp:2644
void StartTransition()
Definition: Window.cpp:2626
void Set(const float x, const float y)
Definition: Vector.h:114
bool RunScript(int n)
Definition: Window.cpp:2690
wexpOp_t * ExpressionOp()
Definition: Window.cpp:2749
void * Mem_Alloc(const int size)
Definition: Heap.cpp:1067
void EvaluateRegisters(float *registers)
Definition: Window.cpp:3027
const int WIN_BORDER
Definition: Window.h:41
void SetStateKey(const char *key, const char *value, bool update=true)
GLint j
Definition: qgl.h:264
idSimpleWindow * simp
Definition: SimpleWindow.h:38
bool hover
Definition: Window.h:423
virtual int ReadFloat(float &value)
Definition: File.cpp:373
void AddChild(idWindow *win)
Definition: Window.cpp:3829
idSession * session
Definition: Session.cpp:48
if(!ValidDisplayID(prefInfo.prefDisplayID)) prefInfo.prefDisplayID
float yOffset
Definition: Window.h:379
#define TT_FLOAT
Definition: Token.h:55
virtual void Moved()
Definition: Window.cpp:1435
virtual void LoseFocus()
Definition: Window.cpp:1459
char * va(const char *fmt,...)
Definition: Str.cpp:1568
const int WIN_NOCLIP
Definition: Window.h:55
static const int NumRegisterVars
Definition: Window.h:202
virtual const char * HandleEvent(const sysEvent_t *event, bool *updateVisuals)
Definition: Window.cpp:709
const int WIN_HOLDCAPTURE
Definition: Window.h:53
virtual void Set(const char *val)
Definition: Winvar.h:208
void SetSize(float width, float height)
GLfloat GLfloat p
Definition: glext.h:4674
const int WIN_DESKTOP
Definition: Window.h:65
void SetFlag(unsigned int f)
Definition: Window.cpp:1484
idList< idWinVar * > definedVars
Definition: Window.h:410
idWinVar * data
Definition: Window.h:159
idWinBackground backGroundName
Definition: Window.h:408
float x
Definition: Vector.h:810
void DrawMaterial(float x, float y, float w, float h, const idMaterial *mat, const idVec4 &color, float scalex=1.0, float scaley=1.0)
virtual void ReadFromSaveGame(idFile *savefile)
Definition: Winvar.h:359
idVec4 colorBlack
Definition: Lib.cpp:115
void SetupBackground()
Definition: Window.cpp:1393
int GetNumKeyVals(void) const
Definition: Dict.h:290
const char * ParseBracedSectionExact(idStr &out, int tabs=-1)
Definition: Lexer.cpp:1376
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
idCVar r_skipGuiShaders
int GetChildIndex(idWindow *window)
Definition: Window.cpp:4048
virtual float CursorX()
virtual idWinVar * GetWinVarByName(const char *_name, bool winLookup=false, drawWin_t **owner=NULL)
Definition: Window.cpp:1776
void SetEval(bool b)
Definition: Winvar.h:82
int sprintf(idStr &string, const char *fmt,...)
Definition: Str.cpp:1528
void ReadFromSaveGame(idFile *savefile)
Definition: GuiScript.cpp:619
type GetCurrentValue(float time) const
Definition: Interpolate.h:252
bool Remove(const type &obj)
Definition: List.h:878
void Append(idGuiScript *gs)
Definition: GuiScript.h:87
idWindow * GetParent()
Definition: Window.h:224
virtual void ReadFromSaveGame(idFile *savefile)
Definition: Window.cpp:3607
void DrawRect(float x, float y, float width, float height, float size, const idVec4 &color)
virtual void WriteToSaveGame(idFile *savefile)
Definition: Winvar.h:463
idWindow * GetFocusedChild()
Definition: Window.cpp:1524
idRectangle textRect
Definition: Window.h:413
int childID
Definition: Window.h:370
virtual void GainFocus()
Definition: Window.cpp:1451
idWinVec4 hoverColor
Definition: Window.h:403
int ExpectTokenType(int type, int subtype, idToken *token)
Definition: Parser.cpp:2422
float h() const
Definition: Winvar.h:423
void SetupFromState()
Definition: Window.cpp:1409
void CalcClientRect(float xofs, float yofs)
Definition: Window.cpp:1343
static idVec4 colorRed
idVec2 origin
Definition: Window.h:375
GLdouble GLdouble t
Definition: glext.h:2943
void AddTransition(idWinVar *dest, idVec4 from, idVec4 to, int time, float accelTime, float decelTime)
Definition: Window.cpp:2613
friend class rvGEWindowWrapper
Definition: Window.h:336
void Clear(void)
Definition: List.h:184
idWindow * captureChild
Definition: Window.h:421
void WriteHashString(const char *str)
Definition: DemoFile.cpp:248
float actualX
Definition: Window.h:368
float TableLookup(float index) const
Definition: DeclTable.cpp:38
int ParseTerm(idParser *src, idWinVar *var=NULL, int component=0)
Definition: Window.cpp:2830
int ParseEmitOp(idParser *src, int a, wexpOpType_t opType, int priority, wexpOp_t **opp=NULL)
Definition: Window.cpp:2817
void WriteSaveGameTransition(idTransitionData &trans, idFile *savefile)
Definition: Window.cpp:3416