gamemenu.cpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Commando/gamemenu.cpp $*
  25. * *
  26. * $Author:: Bhayes $*
  27. * *
  28. * $Modtime:: 2/08/02 12:16p $*
  29. * *
  30. * $Revision:: 191 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "gamemenu.h"
  36. #include "scene.h"
  37. #include "camera.h"
  38. #include "ww3d.h"
  39. #include "debug.h"
  40. #include "assets.h"
  41. #include "font3d.h"
  42. #include "render2d.h"
  43. #include "saveloadstatus.h"
  44. #include "cnetwork.h"
  45. #include "netinterface.h"
  46. #include "langmode.h"
  47. #include "wolgmode.h"
  48. #include "miscutil.h"
  49. #include "_globals.h"
  50. #include "player.h"
  51. #include "gamedata.h"
  52. #include "useroptions.h"
  53. #include "devoptions.h"
  54. #include "playertype.h"
  55. #include "singlepl.h"
  56. #include "translatedb.h"
  57. #include "string_ids.h"
  58. #include "playermanager.h"
  59. #include "teammanager.h"
  60. #include "thread.h"
  61. #include "textdisplay.h"
  62. #include "msgloop.h"
  63. #include "texture.h"
  64. #include "combatgmode.h"
  65. #include "font3d.h"
  66. #include "wwprofile.h"
  67. #include "wwmemlog.h"
  68. #include "physlist.h"
  69. #include "pscene.h"
  70. #include "dazzle.h"
  71. #include "decophys.h"
  72. #include "wwaudio.h"
  73. #include "audiblesound.h"
  74. #include "gametype.h"
  75. #include "dx8wrapper.h"
  76. #include "dx8renderer.h"
  77. #include "rect.h"
  78. #include "dialogmgr.h"
  79. #include "renegadedialogmgr.h"
  80. #include "textureloader.h"
  81. #include "input.h"
  82. #include "menudialog.h"
  83. #include "popupdialog.h"
  84. #include "resource.h"
  85. #include "gameinitmgr.h"
  86. #include "menubackdrop.h"
  87. #include "dlgmainmenu.h"
  88. #include "ccamera.h"
  89. bool g_is_loading = false;
  90. ////////////////////////////////////////////////////////////////////
  91. //
  92. // MenuGameModeClass2
  93. //
  94. ////////////////////////////////////////////////////////////////////
  95. MenuGameModeClass2::MenuGameModeClass2 (void) :
  96. MenuMusic (NULL)
  97. {
  98. return ;
  99. }
  100. ////////////////////////////////////////////////////////////////////
  101. //
  102. // Init
  103. //
  104. ////////////////////////////////////////////////////////////////////
  105. void
  106. MenuGameModeClass2::Init (void)
  107. {
  108. const char *MENU_MUSIC_FILENAME = "menu.mp3";
  109. //
  110. // Create the background music
  111. //
  112. MenuMusic = WWAudioClass::Get_Instance ()->Create_Sound_Effect (MENU_MUSIC_FILENAME);
  113. if (MenuMusic != NULL) {
  114. MenuMusic->Set_Type (AudibleSoundClass::TYPE_MUSIC);
  115. MenuMusic->Set_Priority (1.0F);
  116. MenuMusic->Set_Loop_Count (0);
  117. MenuMusic->Set_Volume (1.0F);
  118. }
  119. if (MenuDialogClass::Get_BackDrop () && MenuDialogClass::Get_BackDrop ()->Peek_Model () == NULL) {
  120. MenuDialogClass::Get_BackDrop ()->Set_Model ("IF_BACK01");
  121. MenuDialogClass::Get_BackDrop ()->Set_Animation ("IF_BACK01.IF_BACK01");
  122. }
  123. return ;
  124. }
  125. ////////////////////////////////////////////////////////////////////
  126. //
  127. // Shutdown
  128. //
  129. ////////////////////////////////////////////////////////////////////
  130. void
  131. MenuGameModeClass2::Shutdown (void)
  132. {
  133. if (MenuMusic != NULL) {
  134. MenuMusic->Stop ();
  135. REF_PTR_RELEASE (MenuMusic);
  136. }
  137. return ;
  138. }
  139. ////////////////////////////////////////////////////////////////////
  140. //
  141. // Think
  142. //
  143. ////////////////////////////////////////////////////////////////////
  144. void
  145. MenuGameModeClass2::Think (void)
  146. {
  147. if (MenuMusic != NULL) {
  148. //
  149. // Start playing the music where necessary and stop the music
  150. // where necessary
  151. //
  152. if (Is_Active () && MenuMusic->Is_Playing () == false) {
  153. if (IS_SOLOPLAY || GameInitMgrClass::Is_Game_In_Progress () == false) {
  154. MenuMusic->Stop ();
  155. MenuMusic->Play ();
  156. }
  157. } else if (Is_Active () == false && MenuMusic->Is_Playing ()) {
  158. MenuMusic->Stop ();
  159. }
  160. }
  161. if (Is_Active () && DialogMgrClass::Get_Dialog_Count () == 0) {
  162. Deactivate ();
  163. }
  164. return ;
  165. }
  166. ////////////////////////////////////////////////////////////////////
  167. //
  168. // Think
  169. //
  170. ////////////////////////////////////////////////////////////////////
  171. void
  172. MenuGameModeClass2::Render (void)
  173. {
  174. return ;
  175. }
  176. ////////////////////////////////////////////////////////////////////
  177. //
  178. // Activate
  179. //
  180. ////////////////////////////////////////////////////////////////////
  181. void
  182. MenuGameModeClass2::Activate (void)
  183. {
  184. WWMEMLOG(MEM_GAMEDATA);
  185. GameModeClass::Activate();
  186. //
  187. // Pause game sounds and activate menu sounds
  188. //
  189. if (IS_SOLOPLAY && WWAudioClass::Get_Instance () != NULL) {
  190. WWAudioClass::Get_Instance ()->Set_Active_Sound_Page (WWAudioClass::PAGE_SECONDARY);
  191. }
  192. if (COMBAT_CAMERA != NULL) {
  193. COMBAT_CAMERA->Set_Snap_Shot_Mode (false);
  194. }
  195. return ;
  196. }
  197. ////////////////////////////////////////////////////////////////////
  198. //
  199. // Deactivate
  200. //
  201. ////////////////////////////////////////////////////////////////////
  202. void
  203. MenuGameModeClass2::Deactivate (void)
  204. {
  205. WWMEMLOG(MEM_GAMEDATA);
  206. //
  207. // Resume game sounds as necessary
  208. //
  209. if (WWAudioClass::Get_Instance () != NULL) {
  210. WWAudioClass::Get_Instance ()->Flush_Playlist (WWAudioClass::PAGE_SECONDARY);
  211. WWAudioClass::Get_Instance ()->Set_Active_Sound_Page (WWAudioClass::PAGE_PRIMARY);
  212. }
  213. DialogMgrClass::Flush_Dialogs ();
  214. GameModeClass::Deactivate();
  215. return ;
  216. }