menudialog.cpp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/wwui/menudialog.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/02/02 11:10a $*
  29. * *
  30. * $Revision:: 11 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "menudialog.h"
  36. #include "menubackdrop.h"
  37. #include "render2d.h"
  38. #include "stylemgr.h"
  39. #include "dialogmgr.h"
  40. #include "childdialog.h"
  41. #include "dialogcontrol.h"
  42. ////////////////////////////////////////////////////////////////
  43. // Static member initialization
  44. ////////////////////////////////////////////////////////////////
  45. MenuDialogClass * MenuDialogClass::ActiveMenu = NULL;
  46. MenuBackDropClass * MenuDialogClass::BackDrop = NULL;
  47. DynamicVectorClass<MenuDialogClass *> MenuDialogClass::MenuStack;
  48. ////////////////////////////////////////////////////////////////
  49. //
  50. // MenuDialogClass
  51. //
  52. ////////////////////////////////////////////////////////////////
  53. MenuDialogClass::MenuDialogClass (int res_id) :
  54. DialogBaseClass (res_id)
  55. {
  56. //
  57. // Add ourselves to the global stack of menus
  58. //
  59. MenuStack.Add (this);
  60. return ;
  61. }
  62. ////////////////////////////////////////////////////////////////
  63. //
  64. // ~MenuDialogClass
  65. //
  66. ////////////////////////////////////////////////////////////////
  67. MenuDialogClass::~MenuDialogClass (void)
  68. {
  69. if (ActiveMenu == this) {
  70. ActiveMenu = NULL;
  71. }
  72. //
  73. // Remove ourselves from the stack
  74. //
  75. int index = MenuStack.ID (this);
  76. if (index != -1) {
  77. MenuStack.Delete (index);
  78. }
  79. return ;
  80. }
  81. ////////////////////////////////////////////////////////////////
  82. //
  83. // Initialize
  84. //
  85. ////////////////////////////////////////////////////////////////
  86. void
  87. MenuDialogClass::Initialize (void)
  88. {
  89. BackDrop = new MenuBackDropClass;
  90. return ;
  91. }
  92. ////////////////////////////////////////////////////////////////
  93. //
  94. // Shutdown
  95. //
  96. ////////////////////////////////////////////////////////////////
  97. void
  98. MenuDialogClass::Shutdown (void)
  99. {
  100. if (BackDrop != NULL) {
  101. delete BackDrop;
  102. BackDrop = NULL;
  103. }
  104. return ;
  105. }
  106. ////////////////////////////////////////////////////////////////
  107. //
  108. // Render
  109. //
  110. ////////////////////////////////////////////////////////////////
  111. void
  112. MenuDialogClass::Render (void)
  113. {
  114. //
  115. // Don't render if we aren't the active menu
  116. //
  117. if (ActiveMenu == this || DialogMgrClass::Peek_Transitioning_Dialog () == this) {
  118. //
  119. // Render the background scene first
  120. //
  121. BackDrop->Render ();
  122. //
  123. // Now, let the dialog subsystem render the controls and
  124. // such...
  125. //
  126. DialogBaseClass::Render ();
  127. }
  128. return ;
  129. }
  130. ////////////////////////////////////////////////////////////////
  131. //
  132. // On_Init_Dialog
  133. //
  134. ////////////////////////////////////////////////////////////////
  135. /*void
  136. MenuDialogClass::On_Init_Dialog (void)
  137. {
  138. DialogBaseClass::Set_Default_Focus ();
  139. return ;
  140. }*/
  141. ////////////////////////////////////////////////////////////////
  142. //
  143. // Start_Dialog
  144. //
  145. ////////////////////////////////////////////////////////////////
  146. void
  147. MenuDialogClass::Start_Dialog (void)
  148. {
  149. //
  150. // As a menu dialog we use the whole screen
  151. //
  152. Rect = Render2DClass::Get_Screen_Resolution ();
  153. DialogBaseClass::Start_Dialog ();
  154. return ;
  155. }
  156. ////////////////////////////////////////////////////////////////
  157. //
  158. // On_Activate
  159. //
  160. ////////////////////////////////////////////////////////////////
  161. void
  162. MenuDialogClass::On_Activate (bool onoff)
  163. {
  164. if (onoff) {
  165. //
  166. // Notify the old menu
  167. //
  168. if (ActiveMenu != NULL) {
  169. ActiveMenu->On_Menu_Activate (false);
  170. }
  171. //
  172. // Switch to active state
  173. //
  174. ActiveMenu = this;
  175. On_Menu_Activate (true);
  176. }
  177. DialogBaseClass::On_Activate (onoff);
  178. return ;
  179. }
  180. ////////////////////////////////////////////////////////////////
  181. //
  182. // On_Menu_Activate
  183. //
  184. ////////////////////////////////////////////////////////////////
  185. void
  186. MenuDialogClass::On_Menu_Activate (bool onoff)
  187. {
  188. return ;
  189. }
  190. ////////////////////////////////////////////////////////////////
  191. //
  192. // End_Dialog
  193. //
  194. ////////////////////////////////////////////////////////////////
  195. void
  196. MenuDialogClass::End_Dialog (void)
  197. {
  198. //
  199. // Is this the last menu? If so, send a notification
  200. //
  201. if (DialogMgrClass::Is_Flushing_Dialogs () == false) {
  202. if (MenuStack.Count () == 1) {
  203. On_Last_Menu_Ending ();
  204. } else {
  205. //
  206. // Play the sound effect
  207. //
  208. StyleMgrClass::Play_Sound (StyleMgrClass::EVENT_MENU_BACK);
  209. }
  210. }
  211. DialogBaseClass::End_Dialog ();
  212. return ;
  213. }
  214. ////////////////////////////////////////////////////////////////
  215. //
  216. // Replace_BackDrop
  217. //
  218. ////////////////////////////////////////////////////////////////
  219. MenuBackDropClass *
  220. MenuDialogClass::Replace_BackDrop (MenuBackDropClass *backdrop)
  221. {
  222. MenuBackDropClass *retval = BackDrop;
  223. BackDrop = backdrop;
  224. return retval;
  225. }