uiscriptedwindow.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. class UIScriptedWindow
  2. {
  3. Widget m_WgtRoot;
  4. int m_Id;
  5. //---MOVE TO UIMANAGER WHEN FIXED
  6. static ref map<int, UIScriptedWindow> m_ActiveWindows;
  7. static void AddToActiveWindows( int id, UIScriptedWindow window )
  8. {
  9. if ( m_ActiveWindows == NULL )
  10. {
  11. m_ActiveWindows = new map<int, UIScriptedWindow>;
  12. }
  13. m_ActiveWindows.Insert( id, window );
  14. }
  15. static void RemoveFromActiveWindows( int id )
  16. {
  17. if ( m_ActiveWindows )
  18. {
  19. m_ActiveWindows.Remove( id );
  20. }
  21. }
  22. static UIScriptedWindow GetWindow( int id )
  23. {
  24. if ( m_ActiveWindows )
  25. {
  26. return m_ActiveWindows.Get( id );
  27. }
  28. return NULL;
  29. }
  30. static map<int, UIScriptedWindow> GetActiveWindows()
  31. {
  32. return m_ActiveWindows;
  33. }
  34. //---
  35. void UIScriptedWindow(int id)
  36. {
  37. m_Id = id;
  38. }
  39. void ~UIScriptedWindow()
  40. {
  41. GetWidgetRoot().Show(false);
  42. delete GetWidgetRoot();
  43. }
  44. Widget GetWidgetRoot()
  45. {
  46. return m_WgtRoot;
  47. }
  48. Widget Init()
  49. {
  50. }
  51. void ShowWindow()
  52. {
  53. GetWidgetRoot().Show( true );
  54. }
  55. void HideWindow()
  56. {
  57. GetWidgetRoot().Show( false );
  58. }
  59. void CloseWindow()
  60. {
  61. GetGame().GetUIManager().CloseWindow( m_Id );
  62. }
  63. //--- EVENTS
  64. bool OnClick(Widget w, int x, int y, int button)
  65. {
  66. return false;
  67. }
  68. bool OnModalResult(Widget w, int x, int y, int code, int result)
  69. {
  70. return false;
  71. }
  72. bool OnDoubleClick(Widget w, int x, int y, int button)
  73. {
  74. return false;
  75. }
  76. bool OnSelect(Widget w, int x, int y)
  77. {
  78. return false;
  79. }
  80. bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
  81. {
  82. return false;
  83. }
  84. bool OnFocus(Widget w, int x, int y)
  85. {
  86. return false;
  87. }
  88. bool OnFocusLost(Widget w, int x, int y)
  89. {
  90. return false;
  91. }
  92. bool OnMouseEnter(Widget w, int x, int y)
  93. {
  94. return false;
  95. }
  96. bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
  97. {
  98. return false;
  99. }
  100. bool OnMouseButtonDown(Widget w, int x, int y, int button)
  101. {
  102. return false;
  103. }
  104. bool OnMouseButtonUp(Widget w, int x, int y, int button)
  105. {
  106. return false;
  107. }
  108. bool OnMouseWheel(Widget w, int x, int y, int wheel)
  109. {
  110. return false;
  111. }
  112. bool OnController(Widget w, int control, int value)
  113. {
  114. return false;
  115. }
  116. bool OnKeyDown(Widget w, int x, int y, int key)
  117. {
  118. return false;
  119. }
  120. bool OnKeyUp(Widget w, int x, int y, int key)
  121. {
  122. return false;
  123. }
  124. bool OnKeyPress(Widget w, int x, int y, int key)
  125. {
  126. return false;
  127. }
  128. bool OnChange(Widget w, int x, int y, bool finished)
  129. {
  130. return false;
  131. }
  132. bool OnDrag(Widget w, int x, int y)
  133. {
  134. return false;
  135. }
  136. bool OnDragging(Widget w, int x, int y, Widget reciever)
  137. {
  138. return false;
  139. }
  140. bool OnDraggingOver(Widget w, int x, int y, Widget reciever)
  141. {
  142. return false;
  143. }
  144. bool OnDrop(Widget w, int x, int y, Widget reciever)
  145. {
  146. return false;
  147. }
  148. bool OnDropReceived(Widget w, int x, int y, Widget reciever)
  149. {
  150. return false;
  151. }
  152. bool OnEvent(EventType eventType, Widget target, int parameter0, int parameter1)
  153. {
  154. return false;
  155. }
  156. }