dlgmpwolquickmatchoptions.cpp 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. #ifdef QUICKMATCH_OPTIONS
  19. /***********************************************************************************************
  20. *** 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 ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Combat *
  24. * *
  25. * $Archive:: /Commando/Code/commando/dlgmpwolquickmatchoptions.cpp $*
  26. * *
  27. * Author:: Patrick Smith *
  28. * *
  29. * $Modtime:: 12/14/01 5:10p $*
  30. * *
  31. * $Revision:: 17 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #include "dlgmpwolquickmatchoptions.h"
  37. #include "dlgmpwolbuddies.h"
  38. #include "dlgmpwolchat.h"
  39. #include "renegadedialogmgr.h"
  40. #include "comboboxctrl.h"
  41. #include "sliderctrl.h"
  42. #include "shortcutbarctrl.h"
  43. #include "translatedb.h"
  44. #include "string_ids.h"
  45. #include "GameData.h"
  46. #include "MPSettingsMgr.h"
  47. ////////////////////////////////////////////////////////////////
  48. //
  49. // MPWolQuickMatchOptionsMenuClass
  50. //
  51. ////////////////////////////////////////////////////////////////
  52. MPWolQuickMatchOptionsMenuClass::MPWolQuickMatchOptionsMenuClass (void) :
  53. MenuDialogClass (IDD_MP_WOL_QUICKMATCH_OPTIONS)
  54. {
  55. return ;
  56. }
  57. ////////////////////////////////////////////////////////////////
  58. //
  59. // On_Init_Dialog
  60. //
  61. ////////////////////////////////////////////////////////////////
  62. void
  63. MPWolQuickMatchOptionsMenuClass::On_Init_Dialog (void)
  64. {
  65. WideStringClass entry_text;
  66. //
  67. // Configure the shortcut bar
  68. //
  69. ShortcutBarCtrlClass* bar = (ShortcutBarCtrlClass*)Get_Dlg_Item(IDC_SHORTCUT_BAR);
  70. if (bar) {
  71. bar->Add_Button(IDC_MP_SHORTCUT_BUDDIES, TRANSLATE(IDS_MP_SHORTCUT_BUDDIES));
  72. bar->Add_Button (IDC_MP_SHORTCUT_INTERNET_OPTIONS, TRANSLATE (IDS_INTERNET_OPTIONS));
  73. bar->Add_Button(IDC_MP_SHORTCUT_CHAT, TRANSLATE(IDS_MP_SHORTCUT_CHAT));
  74. bar->Add_Button(IDC_MP_SHORTCUT_NEWS, TRANSLATE(IDS_MP_SHORTCUT_NEWS));
  75. bar->Add_Button(IDC_MP_SHORTCUT_CLANS, TRANSLATE(IDS_MP_SHORTCUT_CLANS));
  76. bar->Add_Button(IDC_MP_SHORTCUT_RANKINGS, TRANSLATE(IDS_MP_SHORTCUT_RANKINGS));
  77. bar->Add_Button(IDC_MP_SHORTCUT_NET_STATUS, TRANSLATE(IDS_MP_SHORTCUT_NET_STATUS));
  78. }
  79. // Configure the sliders
  80. /*
  81. ((SliderCtrlClass*)Get_Dlg_Item(IDC_DM_SLIDER))->Set_Range(0, 10);
  82. const char* mode = cGameData::Get_Game_Type_Name(cGameData::GAME_TYPE_DEATHMATCH);
  83. int pref = MPSettingsMgrClass::Get_QuickMatch_Mode_Preference(mode);
  84. ((SliderCtrlClass*)Get_Dlg_Item(IDC_DM_SLIDER))->Set_Pos(pref);
  85. Update_Slider_Text(IDC_DM_SLIDER);
  86. ((SliderCtrlClass*)Get_Dlg_Item(IDC_TDM_SLIDER))->Set_Range(0, 10);
  87. mode = cGameData::Get_Game_Type_Name(cGameData::GAME_TYPE_TEAM_DEATHMATCH);
  88. pref = MPSettingsMgrClass::Get_QuickMatch_Mode_Preference(mode);
  89. ((SliderCtrlClass*)Get_Dlg_Item(IDC_TDM_SLIDER))->Set_Pos(pref);
  90. Update_Slider_Text(IDC_TDM_SLIDER);
  91. ((SliderCtrlClass*)Get_Dlg_Item(IDC_CNC_SLIDER))->Set_Range(0, 10);
  92. //const char * mode = cGameData::Get_Game_Type_Name(cGameData::GAME_TYPE_CNC);
  93. const char * mode = cGameDataCnc::Get_Game_Type_Name();
  94. int pref = MPSettingsMgrClass::Get_QuickMatch_Mode_Preference(mode);
  95. ((SliderCtrlClass*)Get_Dlg_Item(IDC_CNC_SLIDER))->Set_Pos(pref);
  96. Update_Slider_Text(IDC_CNC_SLIDER);
  97. */
  98. Check_Dlg_Button(IDC_REMEMBER_CHECK, false);
  99. MenuDialogClass::On_Init_Dialog();
  100. return ;
  101. }
  102. ////////////////////////////////////////////////////////////////
  103. //
  104. // On_Command
  105. //
  106. ////////////////////////////////////////////////////////////////
  107. void
  108. MPWolQuickMatchOptionsMenuClass::On_Command (int ctrl_id, int message_id, DWORD param)
  109. {
  110. if (ctrl_id == IDOK) {
  111. if (Save_Settings()) {
  112. End_Dialog();
  113. }
  114. }
  115. MenuDialogClass::On_Command (ctrl_id, message_id, param);
  116. return ;
  117. }
  118. ////////////////////////////////////////////////////////////////
  119. //
  120. // On_SliderCtrl_Pos_Changed
  121. //
  122. ////////////////////////////////////////////////////////////////
  123. void
  124. MPWolQuickMatchOptionsMenuClass::On_SliderCtrl_Pos_Changed
  125. (
  126. SliderCtrlClass * slider_ctrl,
  127. int ctrl_id,
  128. int new_pos
  129. )
  130. {
  131. Update_Slider_Text (ctrl_id);
  132. return ;
  133. }
  134. ////////////////////////////////////////////////////////////////
  135. //
  136. // Update_Slider_Text
  137. //
  138. ////////////////////////////////////////////////////////////////
  139. void
  140. MPWolQuickMatchOptionsMenuClass::Update_Slider_Text(int ctrl_id)
  141. {
  142. WideStringClass new_string;
  143. int new_pos = ((SliderCtrlClass*)Get_Dlg_Item(ctrl_id))->Get_Pos();
  144. // Determine which string to use for the given position
  145. if (new_pos <= 2) {
  146. new_string = TRANSLATE (IDS_MP_QM_UNDESIRABLE);
  147. } else if (new_pos <= 5) {
  148. new_string = TRANSLATE (IDS_MP_QM_DESIRABLE);
  149. } else if (new_pos <= 7) {
  150. new_string = TRANSLATE (IDS_MP_QM_VERY_DESIRABLE);
  151. } else {
  152. new_string = TRANSLATE (IDS_MP_QM_EXTREMELY_DESIRABLE);
  153. }
  154. // Now update the associated text
  155. switch (ctrl_id)
  156. {
  157. case IDC_DM_SLIDER:
  158. Set_Dlg_Item_Text (IDC_DM_STATIC, new_string);
  159. break;
  160. case IDC_TDM_SLIDER:
  161. Set_Dlg_Item_Text (IDC_TDM_STATIC, new_string);
  162. break;
  163. case IDC_CTF_SLIDER:
  164. Set_Dlg_Item_Text (IDC_CTF_STATIC, new_string);
  165. break;
  166. case IDC_CNC_SLIDER:
  167. Set_Dlg_Item_Text (IDC_CNC_STATIC, new_string);
  168. break;
  169. }
  170. return ;
  171. }
  172. bool MPWolQuickMatchOptionsMenuClass::Save_Settings(void)
  173. {
  174. int sum = 0;
  175. /*
  176. int pref = ((SliderCtrlClass*)Get_Dlg_Item(IDC_DM_SLIDER))->Get_Pos();
  177. const char* mode = cGameData::Get_Game_Type_Name(cGameData::GAME_TYPE_DEATHMATCH);
  178. MPSettingsMgrClass::Set_QuickMatch_Mode_Preference(mode, pref);
  179. sum += pref;
  180. pref = ((SliderCtrlClass*)Get_Dlg_Item(IDC_TDM_SLIDER))->Get_Pos();
  181. mode = cGameData::Get_Game_Type_Name(cGameData::GAME_TYPE_TEAM_DEATHMATCH);
  182. MPSettingsMgrClass::Set_QuickMatch_Mode_Preference(mode, pref);
  183. sum += pref;
  184. int pref = ((SliderCtrlClass*)Get_Dlg_Item(IDC_CNC_SLIDER))->Get_Pos();
  185. //const char * mode = cGameData::Get_Game_Type_Name(cGameData::GAME_TYPE_CNC);
  186. const char * mode = cGameDataCnc::Get_Game_Type_Name();
  187. MPSettingsMgrClass::Set_QuickMatch_Mode_Preference(mode, pref);
  188. sum += pref;
  189. */
  190. if (Is_Dlg_Button_Checked(IDC_REMEMBER_CHECK)) {
  191. MPSettingsMgrClass::Save_QuickMatch_Mode_Preferences();
  192. }
  193. if (sum == 0) {
  194. DlgMsgBox::DoDialog(TRANSLATE (IDS_MENU_INVALID_QM_SETTINGS_TITLE), TRANSLATE (IDS_MENU_INVALID_QM_SETTINGS));
  195. return false;
  196. }
  197. return true;
  198. }
  199. #endif // QUICKMATCH_OPTIONS