dlgcncreference.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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 : commando *
  23. * *
  24. * $Archive:: /Commando/Code/commando/dlgcncreference.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 2/24/02 2:06p $*
  29. * *
  30. * $Revision:: 14 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "dlgcncreference.h"
  36. #include "resource.h"
  37. #include "dialogresource.h"
  38. #include "gamedata.h"
  39. #include "cnetwork.h"
  40. #include "gamemode.h"
  41. #include "gametype.h"
  42. #include "dialogcontrol.h"
  43. #include "dlghelpscreen.h"
  44. #include "gameinitmgr.h"
  45. #include "suicideevent.h"
  46. #include "changeteamevent.h"
  47. #include "cstextobj.h"
  48. #include "wwaudio.h"
  49. #include "dialogmgr.h"
  50. #include "menubackdrop.h"
  51. #include "input.h"
  52. #include "string_ids.h"
  53. #include "translatedb.h"
  54. #include "useroptions.h"
  55. #include "gamespyadmin.h"
  56. #include "dialogtests.h"
  57. #include "dialogmgr.h"
  58. #include "specialbuilds.h"
  59. ////////////////////////////////////////////////////////////////
  60. // Static member initialization
  61. ////////////////////////////////////////////////////////////////
  62. CnCReferenceMenuClass * CnCReferenceMenuClass::_TheInstance = NULL;
  63. DWORD CnCReferenceMenuClass::LastSuicideTimeMs = 0;
  64. DWORD CnCReferenceMenuClass::LastChangeTeamTimeMs = 0;
  65. ////////////////////////////////////////////////////////////////
  66. //
  67. // CnCReferenceMenuClass
  68. //
  69. ////////////////////////////////////////////////////////////////
  70. CnCReferenceMenuClass::CnCReferenceMenuClass (void) :
  71. OldBackdrop (NULL),
  72. Timer (0.5F),
  73. MenuDialogClass (IDD_MENU_CNC_REFERENCE)
  74. {
  75. _TheInstance = this;
  76. return ;
  77. }
  78. ////////////////////////////////////////////////////////////////
  79. //
  80. // CnCReferenceMenuClass
  81. //
  82. ////////////////////////////////////////////////////////////////
  83. CnCReferenceMenuClass::~CnCReferenceMenuClass (void)
  84. {
  85. _TheInstance = NULL;
  86. return ;
  87. }
  88. ////////////////////////////////////////////////////////////////
  89. //
  90. // On_Init_Dialog
  91. //
  92. ////////////////////////////////////////////////////////////////
  93. void
  94. CnCReferenceMenuClass::On_Init_Dialog (void)
  95. {
  96. Get_Dlg_Item (IDC_OPTIONS_MULTIPLAY_SUICIDE)->Enable (false);
  97. Get_Dlg_Item (IDC_OPTIONS_MULTIPLAY_SUICIDE)->Show (false);
  98. Get_Dlg_Item (IDC_OPTIONS_MULTIPLAY_CHANGE_TEAMS)->Enable (false);
  99. Get_Dlg_Item (IDC_OPTIONS_MULTIPLAY_CHANGE_TEAMS)->Show (false);
  100. //
  101. // Make the text on the dialog "white"
  102. //
  103. Get_Dlg_Item (IDC_STATIC_TEXT_01)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  104. Get_Dlg_Item (IDC_STATIC_TEXT_02)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  105. Get_Dlg_Item (IDC_STATIC_TEXT_03)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  106. Get_Dlg_Item (IDC_STATIC_TEXT_04)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  107. Get_Dlg_Item (IDC_STATIC_TEXT_05)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  108. Get_Dlg_Item (IDC_STATIC_TEXT_06)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  109. Get_Dlg_Item (IDC_STATIC_TEXT_07)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  110. Get_Dlg_Item (IDC_STATIC_TEXT_08)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  111. Get_Dlg_Item (IDC_STATIC_TEXT_09)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  112. Get_Dlg_Item (IDC_STATIC_TEXT_10)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  113. Get_Dlg_Item (IDC_STATIC_TEXT_11)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  114. Get_Dlg_Item (IDC_STATIC_TEXT_12)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  115. Get_Dlg_Item (IDC_STATIC_TEXT_13)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  116. Get_Dlg_Item (IDC_STATIC_TEXT_14)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  117. Get_Dlg_Item (IDC_STATIC_TEXT_15)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  118. Get_Dlg_Item (IDC_STATIC_TEXT_16)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  119. Get_Dlg_Item (IDC_STATIC_TEXT_17)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  120. Get_Dlg_Item (IDC_STATIC_TEXT_18)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  121. Get_Dlg_Item (IDC_STATIC_TEXT_19)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  122. Get_Dlg_Item (IDC_STATIC_TEXT_20)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  123. Get_Dlg_Item (IDC_KEY_NAME_01)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  124. Get_Dlg_Item (IDC_KEY_NAME_02)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  125. Get_Dlg_Item (IDC_KEY_NAME_03)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  126. Get_Dlg_Item (IDC_KEY_NAME_04)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  127. Get_Dlg_Item (IDC_KEY_NAME_05)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  128. Get_Dlg_Item (IDC_KEY_NAME_06)->Set_Text_Color (Vector3 (1.0F, 1.0F, 1.0F));
  129. //
  130. // Now, fill in the names of the mapped keys for these functions
  131. //
  132. WideStringClass name;
  133. Input::Get_Translated_Key_Name (Input::Get_Primary_Key_For_Function (INPUT_FUNCTION_TEAM_INFO_TOGGLE), name);
  134. Set_Dlg_Item_Text (IDC_KEY_NAME_01, name);
  135. Input::Get_Translated_Key_Name (Input::Get_Primary_Key_For_Function (INPUT_FUNCTION_BATTLE_INFO_TOGGLE), name);
  136. Set_Dlg_Item_Text (IDC_KEY_NAME_02, name);
  137. Input::Get_Translated_Key_Name (Input::Get_Primary_Key_For_Function (INPUT_FUNCTION_ACTION), name);
  138. Set_Dlg_Item_Text (IDC_KEY_NAME_03, name);
  139. Input::Get_Translated_Key_Name (Input::Get_Primary_Key_For_Function (INPUT_FUNCTION_EVA_MISSION_OBJECTIVES_TOGGLE), name);
  140. Set_Dlg_Item_Text (IDC_KEY_NAME_04, name);
  141. Input::Get_Translated_Key_Name (Input::Get_Primary_Key_For_Function (INPUT_FUNCTION_BEGIN_PUBLIC_MESSAGE), name);
  142. Set_Dlg_Item_Text (IDC_KEY_NAME_05, name);
  143. Input::Get_Translated_Key_Name (Input::Get_Primary_Key_For_Function (INPUT_FUNCTION_BEGIN_TEAM_MESSAGE), name);
  144. Set_Dlg_Item_Text (IDC_KEY_NAME_06, name);
  145. Timer = 0.5F;
  146. MenuDialogClass::On_Init_Dialog ();
  147. return ;
  148. }
  149. ////////////////////////////////////////////////////////////////
  150. //
  151. // On_Destroy
  152. //
  153. ////////////////////////////////////////////////////////////////
  154. void
  155. CnCReferenceMenuClass::On_Destroy (void)
  156. {
  157. //
  158. // Restore the old backdrop
  159. //
  160. if (OldBackdrop != NULL) {
  161. OldBackdrop = Replace_BackDrop (OldBackdrop);
  162. if (OldBackdrop != NULL) {
  163. delete OldBackdrop;
  164. OldBackdrop = NULL;
  165. }
  166. }
  167. MenuDialogClass::On_Destroy ();
  168. return ;
  169. }
  170. ////////////////////////////////////////////////////////////////
  171. //
  172. // On_Command
  173. //
  174. ////////////////////////////////////////////////////////////////
  175. void
  176. CnCReferenceMenuClass::On_Command (int ctrl_id, int message_id, DWORD param)
  177. {
  178. bool allow_default_processing = true;
  179. switch (ctrl_id)
  180. {
  181. case IDC_HELP_BUTTON:
  182. START_DIALOG (HelpScreenDialogClass);
  183. break;
  184. case IDC_MENU_MAIN_MENU_BUTTON:
  185. {
  186. Prompt_User ();
  187. allow_default_processing = false;
  188. break;
  189. }
  190. case IDC_OPTIONS_MULTIPLAY_SUICIDE:
  191. {
  192. cSuicideEvent * p_suicide = new cSuicideEvent;
  193. p_suicide->Init();
  194. //
  195. // Play a custom SFX for feedback
  196. //
  197. WWASSERT(WWAudioClass::Get_Instance() != NULL);
  198. WWAudioClass::Get_Instance()->Create_Instant_Sound("Committed_Suicide", Matrix3D(1));
  199. GameInitMgrClass::Continue_Game();
  200. End_Dialog();
  201. LastSuicideTimeMs = TIMEGETTIME();
  202. break;
  203. }
  204. case IDC_OPTIONS_MULTIPLAY_CHANGE_TEAMS:
  205. {
  206. cChangeTeamEvent * p_event = new cChangeTeamEvent;
  207. p_event->Init();
  208. //
  209. // Play a custom SFX for feedback
  210. //
  211. WWASSERT(WWAudioClass::Get_Instance() != NULL);
  212. WWAudioClass::Get_Instance()->Create_Instant_Sound("Changed_Team", Matrix3D(1));
  213. GameInitMgrClass::Continue_Game();
  214. End_Dialog();
  215. LastChangeTeamTimeMs = TIMEGETTIME();
  216. break;
  217. }
  218. case IDCANCEL:
  219. ctrl_id = IDC_MENU_BACK_BUTTON;
  220. case IDC_MENU_BACK_BUTTON:
  221. if (Timer <= 0.0F) {
  222. GameInitMgrClass::Continue_Game();
  223. } else {
  224. allow_default_processing = false;
  225. }
  226. break;
  227. }
  228. //
  229. // Allow the base class to process the message (if necessary)
  230. //
  231. if (allow_default_processing) {
  232. MenuDialogClass::On_Command (ctrl_id, message_id, param);
  233. }
  234. return ;
  235. }
  236. ////////////////////////////////////////////////////////////////
  237. //
  238. // Display
  239. //
  240. ////////////////////////////////////////////////////////////////
  241. void
  242. CnCReferenceMenuClass::Display (void)
  243. {
  244. //
  245. // Create the dialog if necessary, otherwise simply bring it to the front
  246. //
  247. if (_TheInstance == NULL) {
  248. //
  249. // Create the dialog
  250. //
  251. START_DIALOG (CnCReferenceMenuClass);
  252. } else {
  253. if (_TheInstance->Is_Active_Menu () == false) {
  254. DialogMgrClass::Rollback (_TheInstance);
  255. }
  256. }
  257. return ;
  258. }
  259. ////////////////////////////////////////////////////////////////
  260. //
  261. // On_Menu_Activate
  262. //
  263. ////////////////////////////////////////////////////////////////
  264. void
  265. CnCReferenceMenuClass::On_Menu_Activate (bool onoff)
  266. {
  267. if (onoff) {
  268. //
  269. // Replace the backdrop
  270. //
  271. MenuBackDropClass *new_backdrop = new MenuBackDropClass;
  272. new_backdrop->Set_Model ("IF_LVL80LOAD");
  273. new_backdrop->Set_Animation ("IF_LVL80LOAD.IF_LVL80LOAD");
  274. OldBackdrop = Replace_BackDrop (new_backdrop);
  275. } else {
  276. //
  277. // Restore the old backdrop
  278. //
  279. if (OldBackdrop != NULL) {
  280. OldBackdrop = Replace_BackDrop (OldBackdrop);
  281. if (OldBackdrop != NULL) {
  282. delete OldBackdrop;
  283. OldBackdrop = NULL;
  284. }
  285. }
  286. }
  287. return ;
  288. }
  289. ////////////////////////////////////////////////////////////////
  290. //
  291. // On_Frame_Update
  292. //
  293. ////////////////////////////////////////////////////////////////
  294. void
  295. CnCReferenceMenuClass::On_Frame_Update (void)
  296. {
  297. DWORD time_now_ms = TIMEGETTIME();
  298. //
  299. // Enable or disable the suicide button
  300. //
  301. bool is_suicide_enabled =
  302. The_Game() != NULL &&
  303. !IS_MISSION &&
  304. cNetwork::I_Am_Client();// &&
  305. //GameModeManager::Find("Combat") != NULL &&
  306. //GameModeManager::Find("Combat")->Is_Active();
  307. bool can_suicide_now = (time_now_ms - LastSuicideTimeMs >= ACTION_TIMEOUT_MS);
  308. Get_Dlg_Item(IDC_OPTIONS_MULTIPLAY_SUICIDE)->Enable (can_suicide_now);
  309. Get_Dlg_Item(IDC_OPTIONS_MULTIPLAY_SUICIDE)->Show (is_suicide_enabled);
  310. //
  311. // Enable or disable the change teams button
  312. //
  313. bool is_team_change_enabled =
  314. The_Game() != NULL &&
  315. !IS_MISSION &&
  316. cNetwork::I_Am_Client() &&
  317. The_Game()->IsTeamChangingAllowed.Is_True() &&
  318. (!(GameModeManager::Find("WOL") != NULL && GameModeManager::Find("WOL")->Is_Active()) || The_Game()->IsLaddered.Is_False());// &&
  319. //GameModeManager::Find("Combat") != NULL &&
  320. //GameModeManager::Find("Combat")->Is_Active();
  321. bool can_change_teams_now = (time_now_ms - LastChangeTeamTimeMs >= ACTION_TIMEOUT_MS);
  322. Get_Dlg_Item (IDC_OPTIONS_MULTIPLAY_CHANGE_TEAMS)->Enable (can_change_teams_now);
  323. Get_Dlg_Item (IDC_OPTIONS_MULTIPLAY_CHANGE_TEAMS)->Show (is_team_change_enabled);
  324. //
  325. // Decrement the "delay on this screen" timer...
  326. //
  327. if (Timer > 0) {
  328. Timer -= TimeManager::Get_Frame_Seconds ();
  329. }
  330. //
  331. // Call the base class
  332. //
  333. MenuDialogClass::On_Frame_Update();
  334. return ;
  335. }
  336. ////////////////////////////////////////////////////////////////
  337. //
  338. // Prompt_User
  339. //
  340. ////////////////////////////////////////////////////////////////
  341. void
  342. CnCReferenceMenuClass::Prompt_User (void)
  343. {
  344. //
  345. // Display the message box
  346. //
  347. if (cUserOptions::SkipIngameQuitConfirmDialog.Is_True()) {
  348. Exit_Game ();
  349. } else {
  350. DlgMsgBox::DoDialog (TRANSLATE (IDS_MENU_TEXT054), TRANSLATE (IDS_EXIT_GAME_VERIFICATION), DlgMsgBox::YesNo, this);
  351. }
  352. return ;
  353. }
  354. ////////////////////////////////////////////////////////////////
  355. //
  356. // HandleNotification
  357. //
  358. ////////////////////////////////////////////////////////////////
  359. void
  360. CnCReferenceMenuClass::HandleNotification (DlgMsgBoxEvent &event)
  361. {
  362. if (event.Event () == DlgMsgBoxEvent::Yes) {
  363. Exit_Game ();
  364. }
  365. return ;
  366. }
  367. ////////////////////////////////////////////////////////////////
  368. //
  369. // Exit_Game
  370. //
  371. ////////////////////////////////////////////////////////////////
  372. void
  373. CnCReferenceMenuClass::Exit_Game (void)
  374. {
  375. //
  376. // Close the dialog
  377. //
  378. End_Dialog ();
  379. GameInitMgrClass::End_Game ();
  380. //GameInitMgrClass::Display_End_Game_Menu ();
  381. if (cGameSpyAdmin::Get_Is_Launched_From_Gamespy()) {
  382. #ifdef MULTIPLAYERDEMO
  383. DialogMgrClass::Flush_Dialogs ();
  384. START_DIALOG (SplashOutroMenuDialogClass);
  385. #else
  386. extern void Stop_Main_Loop (int);
  387. Stop_Main_Loop(EXIT_SUCCESS);
  388. #endif // MULTIPLAYERDEMO
  389. } else {
  390. GameInitMgrClass::Display_End_Game_Menu ();
  391. }
  392. return ;
  393. }
  394. /*
  395. bool is_suicide_enabled =
  396. The_Game() != NULL &&
  397. !IS_MISSION &&
  398. cNetwork::I_Am_Client() &&
  399. GameModeManager::Find("Combat") != NULL &&
  400. GameModeManager::Find("Combat")->Is_Active();
  401. //Get_Dlg_Item (IDC_OPTIONS_MULTIPLAY_SUICIDE)->Enable (is_suicide_enabled);
  402. //Get_Dlg_Item (IDC_OPTIONS_MULTIPLAY_SUICIDE)->Show (is_suicide_enabled);
  403. //
  404. // Enable or disable the change teams button
  405. //
  406. bool is_team_change_enabled =
  407. The_Game() != NULL &&
  408. !IS_MISSION &&
  409. cNetwork::I_Am_Client() &&
  410. The_Game()->IsTeamChangingAllowed.Is_True() &&
  411. (!(GameModeManager::Find("WOL") != NULL && GameModeManager::Find("WOL")->Is_Active()) || The_Game()->IsLaddered.Is_False()) &&
  412. GameModeManager::Find("Combat") != NULL &&
  413. GameModeManager::Find("Combat")->Is_Active();
  414. Get_Dlg_Item (IDC_OPTIONS_MULTIPLAY_CHANGE_TEAMS)->Enable (is_team_change_enabled);
  415. Get_Dlg_Item (IDC_OPTIONS_MULTIPLAY_CHANGE_TEAMS)->Show (is_team_change_enabled);
  416. */
  417. /*
  418. if (cGameSpyAdmin::Get_Is_Launched_From_Gamespy()) {
  419. extern void Stop_Main_Loop (int);
  420. Stop_Main_Loop(EXIT_SUCCESS);
  421. }
  422. /**/