dlgcncserverinfo.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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/dlgcncserverinfo.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/15/02 8:19p $*
  29. * *
  30. * $Revision:: 4 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "dlgcncserverinfo.h"
  36. #include "gamedata.h"
  37. #include "resource.h"
  38. #include "listctrl.h"
  39. #include "imagectrl.h"
  40. #include "playertype.h"
  41. #include "combat.h"
  42. #include "playermanager.h"
  43. #include "player.h"
  44. #include "soldier.h"
  45. #include "gameinitmgr.h"
  46. #include "gamemode.h"
  47. #include "input.h"
  48. #include "healthbarctrl.h"
  49. #include "basecontroller.h"
  50. #include "building.h"
  51. #include "damage.h"
  52. #include "vehicle.h"
  53. #include "resource.h"
  54. #include "WOLGMode.h"
  55. #include <WWOnline\WOLUser.h>
  56. #include "translatedb.h"
  57. #include "string_ids.h"
  58. #include "mousemgr.h"
  59. #include "directinput.h"
  60. ////////////////////////////////////////////////////////////////
  61. // Local constants
  62. ////////////////////////////////////////////////////////////////
  63. enum
  64. {
  65. COL_OPTION,
  66. COL_VALUE,
  67. };
  68. ////////////////////////////////////////////////////////////////
  69. //
  70. // CNCServerInfoDialogClass
  71. //
  72. ////////////////////////////////////////////////////////////////
  73. CNCServerInfoDialogClass::CNCServerInfoDialogClass (void) :
  74. MenuDialogClass (IDD_CNC_SERVER_INFO)
  75. {
  76. return ;
  77. }
  78. ////////////////////////////////////////////////////////////////
  79. //
  80. // ~CNCServerInfoDialogClass
  81. //
  82. ////////////////////////////////////////////////////////////////
  83. CNCServerInfoDialogClass::~CNCServerInfoDialogClass (void)
  84. {
  85. GameInitMgrClass::Continue_Game ();
  86. return ;
  87. }
  88. ////////////////////////////////////////////////////////////////
  89. //
  90. // On_Init_Dialog
  91. //
  92. ////////////////////////////////////////////////////////////////
  93. void
  94. CNCServerInfoDialogClass::On_Init_Dialog (void)
  95. {
  96. MenuDialogClass::On_Init_Dialog ();
  97. MouseMgrClass::Show_Cursor (false);
  98. //
  99. // Get a pointer to the list control
  100. //
  101. ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_LIST_CTRL);
  102. if (list_ctrl != NULL) {
  103. //
  104. // Configure the columns
  105. //
  106. list_ctrl->Add_Column (TRANSLATE (IDS_MENU_SERVER_OPTION), 0.5F, Vector3 (1, 1, 1));
  107. list_ctrl->Add_Column (TRANSLATE (IDS_MENU_VALUE), 0.5F, Vector3 (1, 1, 1));
  108. //
  109. // Get the current description of the game
  110. //
  111. WideStringClass description;
  112. The_Game ()->Get_Description (description);
  113. const WCHAR *buffer = description.Peek_Buffer ();
  114. const WCHAR DELIMITER = L'\t';
  115. const WCHAR NEWLINE = L'\n';
  116. //
  117. // Fill the settings into the list control
  118. //
  119. WideStringClass string (100, true);
  120. int list_index = 0;
  121. int item_index = 0;
  122. int index = 0;
  123. while (buffer[index] != 0) {
  124. if (buffer[index] == DELIMITER) {
  125. //
  126. // Insert a new entry
  127. //
  128. item_index = list_ctrl->Insert_Entry (list_index ++, string);
  129. string.Get_Buffer (100)[0] = 0;
  130. } else if (buffer[index] == NEWLINE) {
  131. //
  132. // Fill in the setting value
  133. //
  134. item_index = list_ctrl->Set_Entry_Text (item_index, COL_VALUE, string);
  135. string.Get_Buffer (100)[0] = 0;
  136. } else {
  137. //
  138. // Simply add this character to the string
  139. //
  140. string += buffer[index];
  141. }
  142. index ++;
  143. }
  144. }
  145. //
  146. // Activate the menu game mode (if necessary)
  147. //
  148. GameModeClass *menu_game_mode = GameModeManager::Find ("Menu");
  149. if (menu_game_mode != NULL && menu_game_mode->Is_Active () == false) {
  150. menu_game_mode->Activate ();
  151. }
  152. return ;
  153. }
  154. ////////////////////////////////////////////////////////////////
  155. //
  156. // On_Frame_Update
  157. //
  158. ////////////////////////////////////////////////////////////////
  159. void
  160. CNCServerInfoDialogClass::On_Frame_Update (void)
  161. {
  162. //
  163. // End the dialog when the user releases the player list key
  164. //
  165. int dik_id = Input::Get_Primary_Key_For_Function (INPUT_FUNCTION_SERVER_INFO_TOGGLE);
  166. if ((DirectInput::Get_Keyboard_Button (dik_id) & DirectInput::DI_BUTTON_HELD) == 0) {
  167. End_Dialog ();
  168. }
  169. return ;
  170. }