dlgevaencyclopedia.cpp 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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/commando/dlgevaencyclopedia.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 12/02/01 10:45a $*
  29. * *
  30. * $Revision:: 26 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "dlgevaencyclopedia.h"
  36. #include "dialogresource.h"
  37. #include "tabctrl.h"
  38. #include "dlgevaobjectivestab.h"
  39. #include "dlgevamaptab.h"
  40. #include "dlgevadatatab.h"
  41. #include "dlgevacharacterstab.h"
  42. #include "dlgevaweaponstab.h"
  43. #include "dlgevavehiclestab.h"
  44. #include "dlgevabuildingstab.h"
  45. #include "cnetwork.h"
  46. #include "gamemode.h"
  47. #include "wolgmode.h"
  48. #include "dialogmgr.h"
  49. #include "gameinitmgr.h"
  50. #include "gametype.h"
  51. #include "suicideevent.h"
  52. #include "changeteamevent.h"
  53. #include "cstextobj.h"
  54. #include "wwaudio.h"
  55. #include "dlghelpscreen.h"
  56. #include "crandom.h"
  57. #include "slavemaster.h"
  58. #include "string_ids.h"
  59. #include "translatedb.h"
  60. ////////////////////////////////////////////////////////////////
  61. // Static member initialization
  62. ////////////////////////////////////////////////////////////////
  63. EVAEncyclopediaMenuClass * EVAEncyclopediaMenuClass::_TheInstance = NULL;
  64. int EVAEncyclopediaMenuClass::_NextTabIndex = -4;
  65. ////////////////////////////////////////////////////////////////
  66. //
  67. // EVAEncyclopediaMenuClass
  68. //
  69. ////////////////////////////////////////////////////////////////
  70. EVAEncyclopediaMenuClass::EVAEncyclopediaMenuClass (void) :
  71. MenuDialogClass (IDD_MENU_EVA_ENCYCLOPEDIA)
  72. {
  73. _TheInstance = this;
  74. return ;
  75. }
  76. ////////////////////////////////////////////////////////////////
  77. //
  78. // EVAEncyclopediaMenuClass
  79. //
  80. ////////////////////////////////////////////////////////////////
  81. EVAEncyclopediaMenuClass::~EVAEncyclopediaMenuClass (void)
  82. {
  83. _TheInstance = NULL;
  84. return ;
  85. }
  86. ////////////////////////////////////////////////////////////////
  87. //
  88. // On_Init_Dialog
  89. //
  90. ////////////////////////////////////////////////////////////////
  91. void
  92. EVAEncyclopediaMenuClass::On_Init_Dialog (void)
  93. {
  94. TabCtrlClass *tab_ctrl = (TabCtrlClass *)Get_Dlg_Item (IDC_GENERIC_TABCTRL);
  95. if (tab_ctrl != NULL) {
  96. //
  97. // Add the tabs to the control
  98. //
  99. TABCTRL_ADD_TAB (tab_ctrl, EvaObjectivesTabClass);
  100. TABCTRL_ADD_TAB (tab_ctrl, EvaMapTabClass);
  101. TABCTRL_ADD_TAB (tab_ctrl, EvaDataTabClass);
  102. TABCTRL_ADD_TAB (tab_ctrl, EvaCharactersTabClass);
  103. TABCTRL_ADD_TAB (tab_ctrl, EvaWeaponsTabClass);
  104. TABCTRL_ADD_TAB (tab_ctrl, EvaVehiclesTabClass);
  105. TABCTRL_ADD_TAB (tab_ctrl, EvaBuildingsTabClass);
  106. //
  107. // Determine which tab to show be default
  108. //
  109. int tab_index = _NextTabIndex;
  110. if (_NextTabIndex < 0) {
  111. tab_index = 0;
  112. }
  113. tab_ctrl->Set_Curr_Tab (tab_index);
  114. }
  115. //
  116. // Remove the save/load options for multiplay
  117. //
  118. if (!IS_MISSION) {
  119. Get_Dlg_Item (IDC_MENU_LOAD_SP_GAME_BUTTON)->Show (false);
  120. Get_Dlg_Item (IDC_MENU_LOAD_SP_GAME_BUTTON)->Enable (false);
  121. Get_Dlg_Item (IDC_MENU_SAVE_SP_GAME_BUTTON)->Show (false);
  122. Get_Dlg_Item (IDC_MENU_SAVE_SP_GAME_BUTTON)->Enable (false);
  123. }
  124. //
  125. // Enable or disable the suicide button
  126. //
  127. bool is_suicide_enabled =
  128. The_Game() != NULL &&
  129. !IS_MISSION &&
  130. cNetwork::I_Am_Client() &&
  131. GameModeManager::Find("Combat") != NULL &&
  132. GameModeManager::Find("Combat")->Is_Active();
  133. Get_Dlg_Item(IDC_OPTIONS_MULTIPLAY_SUICIDE)->Enable(is_suicide_enabled);
  134. Get_Dlg_Item(IDC_OPTIONS_MULTIPLAY_SUICIDE)->Show(is_suicide_enabled);
  135. //
  136. // Enable or disable the change teams button
  137. //
  138. bool is_team_change_enabled =
  139. The_Game() != NULL &&
  140. !IS_MISSION &&
  141. cNetwork::I_Am_Client() &&
  142. //The_Game()->Is_Team_Game() &&
  143. The_Game()->IsTeamChangingAllowed.Is_True() &&
  144. (!(GameModeManager::Find("WOL") != NULL && GameModeManager::Find("WOL")->Is_Active()) || The_Game()->IsLaddered.Is_False()) &&
  145. GameModeManager::Find("Combat") != NULL &&
  146. GameModeManager::Find("Combat")->Is_Active();
  147. Get_Dlg_Item(IDC_OPTIONS_MULTIPLAY_CHANGE_TEAMS)->Enable(is_team_change_enabled);
  148. Get_Dlg_Item(IDC_OPTIONS_MULTIPLAY_CHANGE_TEAMS)->Show(is_team_change_enabled);
  149. MenuDialogClass::On_Init_Dialog ();
  150. return ;
  151. }
  152. ////////////////////////////////////////////////////////////////
  153. //
  154. // On_Destroy
  155. //
  156. ////////////////////////////////////////////////////////////////
  157. void
  158. EVAEncyclopediaMenuClass::On_Destroy (void)
  159. {
  160. TabCtrlClass *tab_ctrl = (TabCtrlClass *)Get_Dlg_Item (IDC_GENERIC_TABCTRL);
  161. if (tab_ctrl == NULL) {
  162. return ;
  163. }
  164. //
  165. // Remember what tab the user left on...
  166. //
  167. if (_NextTabIndex >= 0) {
  168. _NextTabIndex = tab_ctrl->Get_Curr_Tab ();
  169. }
  170. MenuDialogClass::On_Destroy ();
  171. return ;
  172. }
  173. ////////////////////////////////////////////////////////////////
  174. //
  175. // On_Command
  176. //
  177. ////////////////////////////////////////////////////////////////
  178. void
  179. EVAEncyclopediaMenuClass::On_Command (int ctrl_id, int message_id, DWORD param)
  180. {
  181. bool allow_default_processing = true;
  182. switch (ctrl_id)
  183. {
  184. case IDC_HELP_BUTTON:
  185. START_DIALOG (HelpScreenDialogClass);
  186. break;
  187. case IDC_MENU_MAIN_MENU_BUTTON:
  188. Prompt_User ();
  189. allow_default_processing = false;
  190. break;
  191. case IDCANCEL:
  192. ctrl_id = IDC_MENU_BACK_BUTTON;
  193. case IDC_MENU_BACK_BUTTON:
  194. GameInitMgrClass::Continue_Game();
  195. break;
  196. }
  197. //
  198. // Allow the base class to process the message (if necessary)
  199. //
  200. if (allow_default_processing) {
  201. MenuDialogClass::On_Command (ctrl_id, message_id, param);
  202. }
  203. return ;
  204. }
  205. ////////////////////////////////////////////////////////////////
  206. //
  207. // Display
  208. //
  209. ////////////////////////////////////////////////////////////////
  210. void
  211. EVAEncyclopediaMenuClass::Display (TAB_ID tab_id)
  212. {
  213. //
  214. // Create the dialog if necessary, otherwise simply bring it to the front
  215. //
  216. if (_TheInstance == NULL) {
  217. if (tab_id != TAB_NONE) {
  218. _NextTabIndex = tab_id;
  219. }
  220. START_DIALOG (EVAEncyclopediaMenuClass);
  221. } else {
  222. if (_TheInstance->Is_Active_Menu () == false) {
  223. DialogMgrClass::Rollback (_TheInstance);
  224. }
  225. }
  226. return ;
  227. }
  228. ////////////////////////////////////////////////////////////////
  229. //
  230. // Prompt_User
  231. //
  232. ////////////////////////////////////////////////////////////////
  233. void
  234. EVAEncyclopediaMenuClass::Prompt_User (void)
  235. {
  236. //
  237. // Display the message box
  238. //
  239. DlgMsgBox::DoDialog (TRANSLATE (IDS_MENU_TEXT054), TRANSLATE (IDS_EXIT_GAME_VERIFICATION), DlgMsgBox::YesNo, this);
  240. return ;
  241. }
  242. ////////////////////////////////////////////////////////////////
  243. //
  244. // HandleNotification
  245. //
  246. ////////////////////////////////////////////////////////////////
  247. void
  248. EVAEncyclopediaMenuClass::HandleNotification (DlgMsgBoxEvent &event)
  249. {
  250. if (event.Event () == DlgMsgBoxEvent::Yes) {
  251. Exit_Game ();
  252. }
  253. return ;
  254. }
  255. ////////////////////////////////////////////////////////////////
  256. //
  257. // Exit_Game
  258. //
  259. ////////////////////////////////////////////////////////////////
  260. void
  261. EVAEncyclopediaMenuClass::Exit_Game (void)
  262. {
  263. bool stop = false;
  264. if (GameModeManager::Find("WOL")->Is_Active() || GameModeManager::Find("LAN")->Is_Active()) {
  265. if (cNetwork::I_Am_Server() && The_Game() && The_Game()->IsDedicated.Is_True() && SlaveMaster.Am_I_Slave()) {
  266. stop = true;
  267. }
  268. }
  269. //
  270. // Close the dialog
  271. //
  272. End_Dialog ();
  273. GameInitMgrClass::End_Game();
  274. //
  275. // Dedicated slave servers should just quit here.
  276. //
  277. if (stop) {
  278. extern void Stop_Main_Loop (int exitCode);
  279. Stop_Main_Loop (EXIT_SUCCESS);
  280. }
  281. GameInitMgrClass::Display_End_Game_Menu();
  282. return ;
  283. }