dlgmplanhostoptions.cpp 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818
  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/dlgmplanhostoptions.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 6/21/02 11:40a $*
  29. * *
  30. * $Revision:: 81 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "dlgmplanhostoptions.h"
  36. #include "tabctrl.h"
  37. #include "gamedata.h"
  38. #include "netutil.h"
  39. #include "listctrl.h"
  40. #include "comboboxctrl.h"
  41. #include "gameinitmgr.h"
  42. #include "renegadedialogmgr.h"
  43. #include "gdcnc.h"
  44. #include "devoptions.h"
  45. #include "translatedb.h"
  46. #include "string_ids.h"
  47. #include "translatedb.h"
  48. #include "nicenum.h"
  49. #include "useroptions.h"
  50. #include "gamemode.h"
  51. #include "wolgmode.h"
  52. #include "campaign.h"
  53. #include "mpsettingsmgr.h"
  54. #include "specialbuilds.h"
  55. #include "dlgmpslaveservers.h"
  56. #include "wolgmode.h"
  57. #include "wolloginprofile.h"
  58. #include "dlgserversaveload.h"
  59. #include "modpackagemgr.h"
  60. #include "modpackage.h"
  61. #include "gamespyadmin.h"
  62. #include "specialbuilds.h"
  63. ////////////////////////////////////////////////////////////////
  64. //
  65. // MPLanHostOptionsMenuClass
  66. //
  67. ////////////////////////////////////////////////////////////////
  68. MPLanHostOptionsMenuClass::MPLanHostOptionsMenuClass (void) :
  69. MenuDialogClass (IDD_MP_LAN_HOST_OPTIONS),
  70. mStartTheGame (false),
  71. mClanID (0),
  72. MapCycleDialog (NULL)
  73. {
  74. return ;
  75. }
  76. MPLanHostOptionsMenuClass::~MPLanHostOptionsMenuClass (void)
  77. {
  78. WWDEBUG_SAY(("MPLanHostOptionsMenuClass: Destroyed\n"));
  79. REF_PTR_RELEASE (MapCycleDialog);
  80. return ;
  81. }
  82. ////////////////////////////////////////////////////////////////
  83. //
  84. // On_Init_Dialog
  85. //
  86. ////////////////////////////////////////////////////////////////
  87. void
  88. MPLanHostOptionsMenuClass::On_Init_Dialog (void)
  89. {
  90. #ifdef BETACLIENT
  91. Get_Dlg_Item(IDC_MENU_MP_LAN_START_BUTTON)->Enable(false);
  92. #endif // BETACLIENT
  93. WWASSERT(PTheGameData != NULL);
  94. WWASSERT(The_Game ()->Is_Cnc());
  95. Set_Dlg_Item_Text(IDC_GAME_TYPE_TITLE, TRANSLATE(IDS_MP_GAME_CNC));
  96. TabCtrlClass *tab_ctrl = (TabCtrlClass *)Get_Dlg_Item (IDC_TABCTRL);
  97. if (tab_ctrl != NULL) {
  98. //
  99. // Add the tabs to the control
  100. //
  101. TABCTRL_ADD_TAB (tab_ctrl, MPLanHostBasicOptionsTabClass);
  102. //
  103. // Add any mode-specific tabs to the control
  104. //
  105. if (The_Game ()->As_Cnc () != NULL) {
  106. TABCTRL_ADD_TAB (tab_ctrl, MPLanHostCnCOptionsTabClass);
  107. }
  108. TABCTRL_ADD_TAB (tab_ctrl, MPLanHostAdvancedOptionsTabClass);
  109. TABCTRL_ADD_TAB (tab_ctrl, MPLanHostVictoryOptionsTabClass);
  110. //
  111. // Keep a pointer around to the map cycle tab so we can
  112. // modify its contents as necessary
  113. //
  114. MapCycleDialog = new MPLanHostMapCycleOptionsTabClass;
  115. tab_ctrl->Add_Tab (MapCycleDialog);
  116. }
  117. MenuDialogClass::On_Init_Dialog ();
  118. return ;
  119. }
  120. ////////////////////////////////////////////////////////////////
  121. //
  122. // Enable_Mod_Selection
  123. //
  124. ////////////////////////////////////////////////////////////////
  125. void
  126. MPLanHostOptionsMenuClass::Enable_Mod_Selection (bool onoff)
  127. {
  128. if (MapCycleDialog == NULL) {
  129. return ;
  130. }
  131. MapCycleDialog->Enable_Mod_Selection (onoff);
  132. return ;
  133. }
  134. ////////////////////////////////////////////////////////////////
  135. //
  136. // On_Periodic
  137. //
  138. ////////////////////////////////////////////////////////////////
  139. void
  140. MPLanHostOptionsMenuClass::On_Periodic (void)
  141. {
  142. MenuDialogClass::On_Periodic();
  143. if (mStartTheGame) {
  144. WWASSERT(PTheGameData != NULL);
  145. Start_Game(The_Game());
  146. mStartTheGame = false;
  147. End_Dialog();
  148. }
  149. return ;
  150. }
  151. ////////////////////////////////////////////////////////////////
  152. //
  153. // On_Command
  154. //
  155. ////////////////////////////////////////////////////////////////
  156. void
  157. MPLanHostOptionsMenuClass::On_Command (int ctrl_id, int message_id, DWORD param)
  158. {
  159. switch (ctrl_id) {
  160. case IDC_MENU_MP_LAN_START_BUTTON:
  161. {
  162. //
  163. // Get a pointer to the tab ctrl
  164. //
  165. TabCtrlClass *tab_ctrl = (TabCtrlClass *)Get_Dlg_Item (IDC_TABCTRL);
  166. if (tab_ctrl != NULL) {
  167. //
  168. // Save the changes on each tab of the control
  169. //
  170. if (tab_ctrl->Apply_Changes_On_Tabs ()) {
  171. //
  172. // Are the settings valid?
  173. //
  174. WWASSERT(PTheGameData != NULL);
  175. WideStringClass outMsg;
  176. if (The_Game()->Is_Valid_Settings (outMsg, true)) {
  177. //
  178. // Save the settings
  179. //
  180. The_Game()->Save_To_Server_Config ();
  181. if (cUserOptions::Get_Bandwidth_Type() == BANDWIDTH_AUTO) {
  182. if (The_Game()->Get_Max_Players() > 2) {
  183. int available_bw = cUserOptions::BandwidthBps.Get();
  184. int required_bw = The_Game()->Get_Max_Players() * 64000;
  185. int set_bw = min(required_bw, available_bw);
  186. WWDEBUG_SAY(("MPLanHostOptionsMenuClass::On_Command - Setting BandwidthBps to %d\n", set_bw));
  187. cUserOptions::BandwidthBps.Set(set_bw);
  188. }
  189. }
  190. SlaveMaster.Startup_Slaves();
  191. GameModeClass* gameMode = GameModeManager::Find("WOL");
  192. if (gameMode && gameMode->Is_Active()) {
  193. WolGameModeClass* wolGame = static_cast<WolGameModeClass*>(gameMode);
  194. WWASSERT(wolGame);
  195. wolGame->SignalMe(*this);
  196. wolGame->Create_Game(The_Game());
  197. } else {
  198. Start_Game(The_Game());
  199. }
  200. } else {
  201. WideStringClass errorMsg(0, true);
  202. errorMsg.Format(L"%s\n\n%s", TRANSLATE(IDS_MENU_TEXT330), (const WCHAR*)outMsg);
  203. DlgMsgBox::DoDialog(TRANSLATE(IDS_MENU_TEXT329), errorMsg);
  204. }
  205. }
  206. }
  207. }
  208. break;
  209. case IDC_SAVELOAD_BUTTON:
  210. TabCtrlClass *tab_ctrl = (TabCtrlClass *)Get_Dlg_Item (IDC_TABCTRL);
  211. if (tab_ctrl != NULL) {
  212. //
  213. // Save the changes on each tab of the control back to the game data.
  214. //
  215. if (tab_ctrl->Apply_Changes_On_Tabs()) {
  216. End_Dialog();
  217. ServerSaveLoadMenuClass::Set_From_Slave_Config(false);
  218. START_DIALOG(ServerSaveLoadMenuClass);
  219. }
  220. }
  221. break;
  222. }
  223. MenuDialogClass::On_Command (ctrl_id, message_id, param);
  224. return ;
  225. }
  226. void MPLanHostOptionsMenuClass::ReceiveSignal(WolGameModeClass& gameMode)
  227. {
  228. if (gameMode.Channel_Create_OK()) {
  229. mStartTheGame = true;
  230. mClanID = 0;
  231. // If this is a clan game then get the current users clan.
  232. if (The_Game()->IsClanGame.Is_True()) {
  233. RefPtr<WWOnline::Session> wolSession = WWOnline::Session::GetInstance(false);
  234. if (wolSession.IsValid()) {
  235. RefPtr<WWOnline::UserData> user = wolSession->GetCurrentUser();
  236. if (user.IsValid()) {
  237. mClanID = user->GetSquadID();
  238. }
  239. }
  240. }
  241. }
  242. }
  243. void MPLanHostOptionsMenuClass::Start_Game(cGameData* theGame)
  244. {
  245. CampaignManager::Select_Backdrop_Number_By_MP_Type( theGame->Get_Game_Type() );
  246. GameInitMgrClass::Set_Is_Client_Required(theGame->IsDedicated.Is_False());
  247. GameInitMgrClass::Set_Is_Server_Required(true);
  248. int side = cNetInterface::Get_Side_Preference();
  249. GameInitMgrClass::Start_Game(theGame->Get_Map_Name(), side, mClanID);
  250. }
  251. ////////////////////////////////////////////////////////////////
  252. //
  253. // MPLanHostBasicOptionsTabClass
  254. //
  255. ////////////////////////////////////////////////////////////////
  256. MPLanHostBasicOptionsTabClass* MPLanHostBasicOptionsTabClass::_mInstance = NULL;
  257. int MPLanHostBasicOptionsTabClass::BandTestMaxPlayers = 0;
  258. MPLanHostBasicOptionsTabClass* MPLanHostBasicOptionsTabClass::Get_Instance(void)
  259. {
  260. if (_mInstance) {
  261. _mInstance->Add_Ref();
  262. return _mInstance;
  263. }
  264. return NULL;
  265. }
  266. MPLanHostBasicOptionsTabClass::MPLanHostBasicOptionsTabClass (void) :
  267. ChildDialogClass (IDD_MP_LAN_HOST_OPTIONS_BASIC_TAB)
  268. {
  269. assert(_mInstance == NULL);
  270. _mInstance = this;
  271. }
  272. MPLanHostBasicOptionsTabClass::~MPLanHostBasicOptionsTabClass (void)
  273. {
  274. _mInstance = NULL;
  275. }
  276. ////////////////////////////////////////////////////////////////
  277. //
  278. // On_Init_Dialog
  279. //
  280. ////////////////////////////////////////////////////////////////
  281. void
  282. MPLanHostBasicOptionsTabClass::On_Init_Dialog (void)
  283. {
  284. bool wolGame = GameModeManager::Find("WOL")->Is_Active();
  285. //
  286. // Fill in the game name
  287. //
  288. WWASSERT(PTheGameData != NULL);
  289. ((EditCtrlClass *)Get_Dlg_Item (IDC_GAME_NAME_EDIT))->Set_Text_Limit (25);
  290. Set_Dlg_Item_Text (IDC_GAME_NAME_EDIT, The_Game ()->Get_Game_Title ());
  291. //
  292. // Fill in the password control on the dialog
  293. //
  294. ((EditCtrlClass *)Get_Dlg_Item (IDC_PASSWORD_EDIT))->Set_Text_Limit (15);
  295. //Set_Dlg_Item_Text (IDC_PASSWORD_EDIT, The_Game ()->Get_Password ());
  296. /*
  297. if (cGameSpyAdmin::Is_Gamespy_Game()) {
  298. Get_Dlg_Item(IDC_PASSWORD_EDIT)->Enable(false);
  299. }
  300. */
  301. //
  302. // Fill in the max-players control on the dialog
  303. //
  304. if (wolGame || cGameSpyAdmin::Is_Gamespy_Game()) {
  305. BandTestMaxPlayers = (cUserOptions::BandwidthBps.Get() / 250000) * 4;
  306. if (BandTestMaxPlayers < 2) {
  307. if (cUserOptions::BandwidthBps.Get() > 100000) {
  308. BandTestMaxPlayers = 4;
  309. } else {
  310. BandTestMaxPlayers = 2;
  311. }
  312. }
  313. // Enable_Dlg_Item(IDC_NUM_PLAYERS_EDIT, false);
  314. int max_players = min(The_Game ()->Get_Max_Players (), BandTestMaxPlayers);
  315. Set_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT, min(max_players, NetworkObjectClass::MAX_CLIENT_COUNT-1));
  316. } else {
  317. Set_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT, min(The_Game ()->Get_Max_Players (), NetworkObjectClass::MAX_CLIENT_COUNT-1));
  318. }
  319. //
  320. // Configure the IP NIC Enumeration combobox
  321. //
  322. ComboBoxCtrlClass *nic_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_HOSTING_IP_COMBO);
  323. if (nic_combobox != NULL) {
  324. ULONG * nics = NULL;
  325. int nic_count = 0;
  326. ULONG preferred_nick;
  327. if (!cGameSpyAdmin::Get_Is_Server_Gamespy_Listed()) {
  328. nics = cNicEnum::Get_Nics();
  329. nic_count = cNicEnum::Get_Num_Nics();
  330. preferred_nick = cUserOptions::PreferredLanNic.Get();
  331. } else {
  332. nics = cNicEnum::Get_GameSpy_Nics();
  333. nic_count = cNicEnum::Get_Num_GameSpy_Nics();
  334. preferred_nick = cUserOptions::PreferredGameSpyNic.Get();
  335. }
  336. WWASSERT(nics != NULL);
  337. int current_index = -1;
  338. for (USHORT index = 0; index < nic_count; index++) {
  339. WideStringClass nic_string;
  340. nic_string.Convert_From(cNetUtil::Address_To_String(nics[index]));
  341. nic_combobox->Add_String( nic_string );
  342. if (nics[index] == preferred_nick) {
  343. current_index = index;
  344. }
  345. }
  346. //
  347. // Select the default entry in the radar_combobox
  348. //
  349. nic_combobox->Set_Curr_Sel ( current_index );
  350. Enable_Dlg_Item(IDC_HOSTING_IP_COMBO, !wolGame);
  351. }
  352. int sidePref = cNetInterface::Get_Side_Preference();
  353. if (wolGame) {
  354. RefPtr<WWOnline::Session> wolSession = WWOnline::Session::GetInstance(false);
  355. if (wolSession.IsValid()) {
  356. const RefPtr<WWOnline::LoginInfo>& login = wolSession->GetCurrentLogin();
  357. assert(login.IsValid());
  358. LoginProfile* profile = LoginProfile::Get(login->GetNickname());
  359. if (profile) {
  360. sidePref = profile->GetSidePreference();
  361. profile->Release_Ref();
  362. }
  363. }
  364. }
  365. InitSideChoiceCombo(sidePref);
  366. ChildDialogClass::On_Init_Dialog ();
  367. return ;
  368. }
  369. /******************************************************************************
  370. *
  371. * NAME
  372. * MPLanHostBasicOptionsTabClass::InitSideChoiceCombo
  373. *
  374. * DESCRIPTION
  375. *
  376. * INPUTS
  377. * NONE
  378. *
  379. * RESULT
  380. * NONE
  381. *
  382. ******************************************************************************/
  383. void MPLanHostBasicOptionsTabClass::InitSideChoiceCombo(int sidePref)
  384. {
  385. ComboBoxCtrlClass* combo = (ComboBoxCtrlClass*)Get_Dlg_Item(IDC_CHOOSESIDE_COMBO);
  386. if (combo) {
  387. //(gth) Renegade day 120 Patch: re-translate these strings each time!
  388. struct {const wchar_t* TeamName; int TeamID;} _teams[] = {
  389. {TRANSLATE (IDS_MENU_AUTO_TEAM), PLAYERTYPE_RENEGADE},
  390. {TRANSLATE (IDS_MENU_TEXT933), PLAYERTYPE_GDI},
  391. {TRANSLATE (IDS_MENU_TEXT934), PLAYERTYPE_NOD},
  392. {NULL, -1},
  393. };
  394. int index = 0;
  395. while (_teams[index].TeamName != NULL) {
  396. int item = combo->Add_String(_teams[index].TeamName);
  397. if (item >= 0) {
  398. combo->Set_Item_Data(item, (uint32)_teams[index].TeamID);
  399. }
  400. if (_teams[index].TeamID == sidePref) {
  401. combo->Set_Curr_Sel(index);
  402. }
  403. ++index;
  404. }
  405. if (combo->Get_Curr_Sel() == -1) {
  406. combo->Set_Curr_Sel(0);
  407. }
  408. }
  409. }
  410. ////////////////////////////////////////////////////////////////
  411. //
  412. // On_Apply
  413. //
  414. ////////////////////////////////////////////////////////////////
  415. bool
  416. MPLanHostBasicOptionsTabClass::On_Apply (void)
  417. {
  418. WideStringClass password = Get_Dlg_Item_Text (IDC_PASSWORD_EDIT);
  419. WWASSERT(PTheGameData != NULL);
  420. The_Game ()->IsPassworded.Set ((password.Get_Length () > 0));
  421. //
  422. // Pass our settings onto the game
  423. //
  424. The_Game ()->Set_Game_Title (Get_Dlg_Item_Text (IDC_GAME_NAME_EDIT));
  425. The_Game ()->Set_Password (password);
  426. // Has to be -1 since we use the last client as a reference for refreshing dirty bits.
  427. The_Game ()->Set_Max_Players (min(Get_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT), NetworkObjectClass::MAX_CLIENT_COUNT - 1));
  428. // Quickmatch games can not have passwords
  429. if (The_Game()->IsPassworded.Is_True()) {
  430. The_Game()->Set_QuickMatch_Server(false);
  431. }
  432. //
  433. // Read the IP NIC Enumeration combobox
  434. //
  435. if (!GameModeManager::Find("WOL")->Is_Active() && !cGameSpyAdmin::Get_Is_Server_Gamespy_Listed()) {
  436. ComboBoxCtrlClass *nic_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_HOSTING_IP_COMBO);
  437. if (nic_combobox != NULL) {
  438. int curr_sel = nic_combobox->Get_Curr_Sel ();
  439. WWASSERT(curr_sel < cNicEnum::Get_Num_Nics());
  440. if (curr_sel >= 0) {
  441. ULONG * nics = cNicEnum::Get_Nics();
  442. WWASSERT(nics != NULL);
  443. cUserOptions::PreferredLanNic.Set(nics[curr_sel]);
  444. The_Game()->Set_Ip_Address(nics[curr_sel]);
  445. }
  446. }
  447. } else if (!GameModeManager::Find("WOL")->Is_Active() && cGameSpyAdmin::Get_Is_Server_Gamespy_Listed()) {
  448. ComboBoxCtrlClass *nic_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_HOSTING_IP_COMBO);
  449. if (nic_combobox != NULL) {
  450. int curr_sel = nic_combobox->Get_Curr_Sel ();
  451. WWASSERT(curr_sel < cNicEnum::Get_Num_GameSpy_Nics());
  452. if (curr_sel >= 0) {
  453. ULONG * nics = cNicEnum::Get_GameSpy_Nics();
  454. WWASSERT(nics != NULL);
  455. cUserOptions::PreferredGameSpyNic.Set(nics[curr_sel]);
  456. The_Game()->Set_Ip_Address(nics[curr_sel]);
  457. }
  458. }
  459. } else if (!GameModeManager::Find("WOL")->Is_Active() && cGameSpyAdmin::Get_Is_Server_Gamespy_Listed()) {
  460. ComboBoxCtrlClass *nic_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_HOSTING_IP_COMBO);
  461. if (nic_combobox != NULL) {
  462. int curr_sel = nic_combobox->Get_Curr_Sel ();
  463. WWASSERT(curr_sel < cNicEnum::Get_Num_GameSpy_Nics());
  464. if (curr_sel >= 0) {
  465. ULONG * nics = cNicEnum::Get_GameSpy_Nics();
  466. WWASSERT(nics != NULL);
  467. cUserOptions::PreferredGameSpyNic.Set(nics[curr_sel]);
  468. The_Game()->Set_Ip_Address(nics[curr_sel]);
  469. }
  470. }
  471. }
  472. ComboBoxCtrlClass* combo = (ComboBoxCtrlClass*)Get_Dlg_Item(IDC_CHOOSESIDE_COMBO);
  473. if (combo) {
  474. int curSel = combo->Get_Curr_Sel();
  475. int side = combo->Get_Item_Data(curSel);
  476. cNetInterface::Set_Side_Preference(side);
  477. }
  478. return true;
  479. }
  480. ////////////////////////////////////////////////////////////////
  481. //
  482. // On_EditCtrl_Change
  483. //
  484. ////////////////////////////////////////////////////////////////
  485. void
  486. MPLanHostBasicOptionsTabClass::On_EditCtrl_Change (EditCtrlClass *edit, int ctrlID)
  487. {
  488. if (IDC_PASSWORD_EDIT == ctrlID) {
  489. //
  490. // Flag the game as passworded if the user enters text into the password edit.
  491. //
  492. const WCHAR* text = edit->Get_Text ();
  493. bool hasPassword = (text && (wcslen (text) > 0));
  494. SendSignal (hasPassword);
  495. } else if (ctrlID == IDC_NUM_PLAYERS_EDIT) {
  496. int max_players = min(BandTestMaxPlayers, NetworkObjectClass::MAX_CLIENT_COUNT-1);
  497. //
  498. // Check to ensure the player count is within bounds...
  499. //
  500. int player_count = Get_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT);
  501. if (player_count < 0 || player_count > NetworkObjectClass::MAX_CLIENT_COUNT-1) {
  502. player_count = min (player_count, NetworkObjectClass::MAX_CLIENT_COUNT-1);
  503. player_count = max (player_count, 0);
  504. Set_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT, player_count);
  505. }
  506. bool wol_game = GameModeManager::Find("WOL")->Is_Active();
  507. if ((wol_game || cGameSpyAdmin::Is_Gamespy_Game()) && player_count > max_players) {
  508. player_count = max_players;
  509. Set_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT, player_count);
  510. DlgMsgBox::DoDialog(IDS_MENU_TEXT329, IDS_MP_MAXPLAYER_WARNING, DlgMsgBox::Okay);
  511. }
  512. }
  513. return ;
  514. }
  515. ////////////////////////////////////////////////////////////////
  516. //
  517. // MPLanHostAdvancedOptionsTabClass
  518. //
  519. ////////////////////////////////////////////////////////////////
  520. MPLanHostAdvancedOptionsTabClass::MPLanHostAdvancedOptionsTabClass (void) :
  521. ChildDialogClass (IDD_MP_LAN_HOST_OPTIONS_ADVANCED_TAB)
  522. {
  523. return ;
  524. }
  525. ////////////////////////////////////////////////////////////////
  526. //
  527. // On_Init_Dialog
  528. //
  529. ////////////////////////////////////////////////////////////////
  530. void
  531. MPLanHostAdvancedOptionsTabClass::On_Init_Dialog (void)
  532. {
  533. MPLanHostBasicOptionsTabClass* basicTab = MPLanHostBasicOptionsTabClass::Get_Instance();
  534. if (basicTab) {
  535. basicTab->SignalMe(*this);
  536. basicTab->Release_Ref();
  537. }
  538. #ifdef FREEDEDICATEDSERVER
  539. WWASSERT(PTheGameData != NULL);
  540. The_Game ()->IsDedicated.Set(true);
  541. Enable_Dlg_Item (IDC_DEDICATED_SERVER_CHECK, false);
  542. #endif // FREEDEDICATEDSERVER
  543. // if (cGameSpyAdmin::Is_Gamespy_Game()) {
  544. // WWASSERT(PTheGameData != NULL);
  545. // The_Game ()->IsDedicated.Set(true);
  546. // Enable_Dlg_Item (IDC_DEDICATED_SERVER_CHECK, false);
  547. // }
  548. Check_Dlg_Button (IDC_DEDICATED_SERVER_CHECK, The_Game ()->IsDedicated.Is_True ());
  549. // Change teams is ON if team editing and changing team allowed is true
  550. bool canChangeTeams = The_Game()->Is_Editable_Teaming();
  551. mChangeTeams = canChangeTeams && The_Game()->IsTeamChangingAllowed.Is_True();
  552. Check_Dlg_Button(IDC_TEAM_CHANGE_CHECK, mChangeTeams);
  553. Enable_Dlg_Item(IDC_TEAM_CHANGE_CHECK, canChangeTeams);
  554. // Remix teams is ON if team change is FALSE and remix setting is true.
  555. mRemixTeams = The_Game()->IsTeamChangingAllowed.Is_False() && The_Game()->RemixTeams.Is_True();
  556. Check_Dlg_Button(IDC_REMIX_TEAMS_CHECK, mRemixTeams);
  557. Enable_Dlg_Item(IDC_REMIX_TEAMS_CHECK, The_Game()->IsTeamChangingAllowed.Is_False());
  558. //Check_Dlg_Button (IDC_TRUST_CLIENTS_CHECK, The_Game ()->IsClientTrusted.Is_True ());
  559. #ifdef MULTIPLAYERDEMO
  560. Enable_Dlg_Item(IDC_SERVER_RESTART_CHECK, false);
  561. Check_Dlg_Button (IDC_SERVER_RESTART_CHECK, false);
  562. #else
  563. Check_Dlg_Button (IDC_SERVER_RESTART_CHECK, The_Game ()->IsAutoRestart.Is_True ());
  564. #endif // MULTIPLAYERDEMO
  565. // Configure WOL settings
  566. mIsWOLGame = GameModeManager::Find("WOL")->Is_Active();
  567. mPassword = The_Game()->IsPassworded.Get();
  568. mLaddered = (mIsWOLGame && The_Game()->IsLaddered.Is_True());
  569. mClanGame = (mIsWOLGame && IsHostAClanMember() && The_Game()->IsClanGame.Is_True());
  570. mQuickmatch = (mIsWOLGame && !mPassword && The_Game()->Is_QuickMatch_Server());
  571. ConfigureWOLControls();
  572. if (The_Game()->IsDedicated.Is_False()) {// || (mIsWOLGame && strlen(MPSettingsMgrClass::Get_Auto_Login()) == 0)) {
  573. Check_Dlg_Button(IDC_SERVER_RESTART_CHECK, false);
  574. Enable_Dlg_Item(IDC_SERVER_RESTART_CHECK, false);
  575. }
  576. if (!GameModeManager::Find("WOL")->Is_Active()) {
  577. Enable_Dlg_Item(IDC_MENU_MP_LAN_SLAVE_SERVER_BUTTON, false);
  578. }
  579. //
  580. // Fill in the Motd control
  581. //
  582. Set_Dlg_Item_Text (IDC_MESSAGE_OF_THE_DAY_EDIT, The_Game ()->Get_Motd ());
  583. ChildDialogClass::On_Init_Dialog ();
  584. //
  585. // Don't allow the user to select a MOD package if the game is laddered
  586. //
  587. MPLanHostOptionsMenuClass *parent_dlg = static_cast<MPLanHostOptionsMenuClass *> (Get_Parent_Dialog ());
  588. if (parent_dlg != NULL) {
  589. parent_dlg->Enable_Mod_Selection (mLaddered == false);
  590. }
  591. return ;
  592. }
  593. ////////////////////////////////////////////////////////////////
  594. //
  595. // On_Apply
  596. //
  597. ////////////////////////////////////////////////////////////////
  598. bool
  599. MPLanHostAdvancedOptionsTabClass::On_Apply (void)
  600. {
  601. //
  602. // Pass our settings onto the game
  603. //
  604. WWASSERT(PTheGameData != NULL);
  605. The_Game()->IsDedicated.Set (Is_Dlg_Button_Checked (IDC_DEDICATED_SERVER_CHECK));
  606. The_Game()->IsAutoRestart.Set (Is_Dlg_Button_Checked (IDC_SERVER_RESTART_CHECK));
  607. The_Game()->IsTeamChangingAllowed.Set (Is_Dlg_Button_Checked (IDC_TEAM_CHANGE_CHECK));
  608. The_Game()->Set_QuickMatch_Server(Is_Dlg_Button_Checked(IDC_ALLOW_QUICKMATCH));
  609. The_Game()->IsLaddered.Set (Is_Dlg_Button_Checked (IDC_LADDERED_CHECK));
  610. The_Game()->IsClanGame.Set (Is_Dlg_Button_Checked (IDC_CLAN_GAME_CHECK));
  611. //The_Game()->IsClientTrusted.Set (Is_Dlg_Button_Checked (IDC_TRUST_CLIENTS_CHECK));
  612. The_Game()->RemixTeams.Set (Is_Dlg_Button_Checked (IDC_REMIX_TEAMS_CHECK));
  613. //
  614. // TSS022402
  615. // If laddering is on, silently turn off FF. Exploit concerns.
  616. // N.B. This is a hack. Leverages off the fact that
  617. // MPLanHostCnCOptionsTabClass::On_Apply is called first.
  618. //
  619. if (The_Game()->IsLaddered.Is_True()) {
  620. The_Game()->IsFriendlyFirePermitted.Set(false);
  621. }
  622. //
  623. // Save the message of the day (MOTD)
  624. //
  625. WideStringClass motd = Get_Dlg_Item_Text (IDC_MESSAGE_OF_THE_DAY_EDIT);
  626. if (motd.Get_Length() > MAX_MOTD_LENGTH) {
  627. motd.Peek_Buffer()[MAX_MOTD_LENGTH - 1] = 0;
  628. }
  629. The_Game ()->Set_Motd (motd);
  630. return true;
  631. }
  632. ////////////////////////////////////////////////////////////////
  633. //
  634. // On_Command
  635. //
  636. ////////////////////////////////////////////////////////////////
  637. void
  638. MPLanHostAdvancedOptionsTabClass::On_Command (int ctrl_id, int message_id, DWORD param)
  639. {
  640. bool restart_enabled = true;
  641. switch (ctrl_id) {
  642. case IDC_DEDICATED_SERVER_CHECK: {
  643. // Enable the restart button only if we have auto login
  644. if (Is_Dlg_Button_Checked(IDC_DEDICATED_SERVER_CHECK)) {
  645. restart_enabled = true;
  646. } else {
  647. restart_enabled = false;
  648. }
  649. #ifndef MULTIPLAYERDEMO
  650. if (restart_enabled) {
  651. Enable_Dlg_Item (IDC_SERVER_RESTART_CHECK, true);
  652. } else {
  653. Check_Dlg_Button(IDC_SERVER_RESTART_CHECK, false);
  654. Enable_Dlg_Item(IDC_SERVER_RESTART_CHECK, false);
  655. }
  656. #endif // MULTIPLAYERDEMO
  657. bool canClan = (IsHostAClanMember() && !mChangeTeams && !mRemixTeams);
  658. Enable_Dlg_Item(IDC_CLAN_GAME_CHECK, (mIsWOLGame && canClan));
  659. bool clanGame = (((param != 0) || canClan) ? mClanGame : false);
  660. Check_Dlg_Button(IDC_CLAN_GAME_CHECK, (mIsWOLGame && clanGame));
  661. }
  662. break;
  663. case IDC_SERVER_RESTART_CHECK: {
  664. if (Is_Dlg_Button_Checked(IDC_SERVER_RESTART_CHECK)) {
  665. if (GameModeManager::Find("WOL")->Is_Active() && strlen(MPSettingsMgrClass::Get_Auto_Login()) == 0) {
  666. DlgMsgBox::DoDialog (IDS_MENU_TEXT329, IDS_MENU_NEED_AUTO_LOGIN, DlgMsgBox::YesNo, this);
  667. Check_Dlg_Button(IDC_SERVER_RESTART_CHECK, false);
  668. }
  669. }
  670. }
  671. break;
  672. //
  673. // Bring up the slave server config dialog.
  674. //
  675. case IDC_MENU_MP_LAN_SLAVE_SERVER_BUTTON:
  676. if (WW3D::Is_Windowed()) {
  677. START_DIALOG(SlaveServerDialogClass);
  678. } else {
  679. DlgMsgBox::DoDialog(IDS_MENU_TEXT329, IDS_SLAVES_NEED_WINDOWED, DlgMsgBox::Okay);
  680. }
  681. break;
  682. case IDC_TEAM_CHANGE_CHECK:
  683. {
  684. mChangeTeams = (param != 0);
  685. // Change Team and Clans are mutually exclusive
  686. bool canClan = (!mChangeTeams && !Is_Dlg_Button_Checked(IDC_REMIX_TEAMS_CHECK) && !Is_Dlg_Button_Checked(IDC_ALLOW_QUICKMATCH));
  687. Enable_Dlg_Item(IDC_CLAN_GAME_CHECK, canClan);
  688. Check_Dlg_Button(IDC_CLAN_GAME_CHECK, canClan && mClanGame);
  689. // Change Team and laddered are mutually exclusive
  690. Enable_Dlg_Item(IDC_LADDERED_CHECK, !mChangeTeams);
  691. Check_Dlg_Button(IDC_LADDERED_CHECK, !mChangeTeams && mLaddered);
  692. }
  693. break;
  694. case IDC_REMIX_TEAMS_CHECK:
  695. {
  696. mRemixTeams = (param != 0);
  697. // Remix teams and clans are mutually exclusive
  698. bool canClan = (!mRemixTeams && !Is_Dlg_Button_Checked(IDC_TEAM_CHANGE_CHECK) && !Is_Dlg_Button_Checked(IDC_ALLOW_QUICKMATCH));
  699. Enable_Dlg_Item(IDC_CLAN_GAME_CHECK, canClan);
  700. Check_Dlg_Button(IDC_CLAN_GAME_CHECK, canClan && mClanGame);
  701. }
  702. break;
  703. // If clan is checked then quickmatch is not allowed.
  704. case IDC_CLAN_GAME_CHECK:
  705. mClanGame = (param != 0);
  706. ConfigureWOLControls();
  707. break;
  708. // If quickmatch is checked then laddered must be checked as well.
  709. case IDC_ALLOW_QUICKMATCH:
  710. mQuickmatch = (param != 0);
  711. ConfigureWOLControls();
  712. break;
  713. // If clan is checked then quickmatch is not allowed.
  714. case IDC_LADDERED_CHECK:
  715. {
  716. mLaddered = (param != 0);
  717. //
  718. // Don't allow the user to select a MOD package if the game is laddered
  719. //
  720. MPLanHostOptionsMenuClass *parent_dlg = static_cast<MPLanHostOptionsMenuClass *> (Get_Parent_Dialog ());
  721. if (parent_dlg != NULL) {
  722. parent_dlg->Enable_Mod_Selection (mLaddered == false);
  723. }
  724. // Laddered games and team changing is mutually exclusive
  725. bool canChangeTeam = (!mLaddered && !Is_Dlg_Button_Checked(IDC_CLAN_GAME_CHECK));
  726. Enable_Dlg_Item(IDC_TEAM_CHANGE_CHECK, canChangeTeam);
  727. Check_Dlg_Button(IDC_TEAM_CHANGE_CHECK, canChangeTeam && mChangeTeams);
  728. }
  729. break;
  730. }
  731. }
  732. void MPLanHostAdvancedOptionsTabClass::HandleNotification (DlgMsgBoxEvent &event)
  733. {
  734. //
  735. // We only use a message box for the auto login confirm.
  736. //
  737. if (event.Event() == DlgMsgBoxEvent::Yes) {
  738. //Enable_Dlg_Item (IDC_SERVER_RESTART_CHECK, true);
  739. Check_Dlg_Button(IDC_SERVER_RESTART_CHECK, true);
  740. const char* login = MPSettingsMgrClass::Get_Last_Login();
  741. MPSettingsMgrClass::Set_Auto_Login(login);
  742. }
  743. }
  744. void MPLanHostAdvancedOptionsTabClass::ReceiveSignal(bool& hasPassword)
  745. {
  746. if (mPassword != hasPassword) {
  747. mPassword = hasPassword;
  748. ConfigureWOLControls();
  749. }
  750. }
  751. void MPLanHostAdvancedOptionsTabClass::ConfigureWOLControls(void)
  752. {
  753. bool isDedicated = Is_Dlg_Button_Checked(IDC_DEDICATED_SERVER_CHECK);
  754. bool isQuickmatch = Is_Dlg_Button_Checked(IDC_ALLOW_QUICKMATCH);
  755. bool isTeamChange = Is_Dlg_Button_Checked(IDC_TEAM_CHANGE_CHECK);
  756. bool isTeamRemix = Is_Dlg_Button_Checked(IDC_REMIX_TEAMS_CHECK);
  757. bool isClanMember = IsHostAClanMember();
  758. //---------------------------------------------------------------------------
  759. // Clan games allowed if:
  760. // - WOL is active.
  761. // - Quickmatch is OFF
  762. // - Change team is OFF
  763. // - Remix team is OFF
  764. // - Host is member of a clan OR game is dedicated.
  765. //
  766. // Requirements if ON:
  767. // - Team Change must be OFF
  768. // - Team Remix must be OFF
  769. //---------------------------------------------------------------------------
  770. bool canClan = (mIsWOLGame && !isQuickmatch && !isTeamChange && !isTeamRemix && (isClanMember || isDedicated));
  771. Enable_Dlg_Item(IDC_CLAN_GAME_CHECK, canClan);
  772. bool clanned = (canClan && mClanGame);
  773. Check_Dlg_Button(IDC_CLAN_GAME_CHECK, clanned);
  774. //---------------------------------------------------------------------------
  775. // Quickmatch allowed if:
  776. // - WOL is active
  777. // - No password
  778. // - Clan is OFF
  779. //
  780. // Requirements if ON:
  781. // - Ladderd must be ON
  782. // - Clan must be OFF
  783. //---------------------------------------------------------------------------
  784. bool canQuickmatch = (mIsWOLGame && !mPassword && !clanned);
  785. Enable_Dlg_Item(IDC_ALLOW_QUICKMATCH, canQuickmatch);
  786. isQuickmatch = (canQuickmatch && mQuickmatch);
  787. Check_Dlg_Button(IDC_ALLOW_QUICKMATCH, isQuickmatch);
  788. //---------------------------------------------------------------------------
  789. // Ladder option available if WOL active and quickmatch is OFF
  790. //---------------------------------------------------------------------------
  791. bool canLadder = (mIsWOLGame && !isQuickmatch && !isTeamChange);
  792. Enable_Dlg_Item(IDC_LADDERED_CHECK, canLadder);
  793. bool laddered = ((canLadder && mLaddered) || isQuickmatch);
  794. Check_Dlg_Button(IDC_LADDERED_CHECK, laddered);
  795. //---------------------------------------------------------------------------
  796. // Team change not allowed with clan or laddered games.
  797. //---------------------------------------------------------------------------
  798. bool canChangeTeams = (!clanned && !laddered && The_Game()->Is_Editable_Teaming());
  799. Enable_Dlg_Item(IDC_TEAM_CHANGE_CHECK, canChangeTeams);
  800. bool changeTeams = (canChangeTeams && mChangeTeams);
  801. Check_Dlg_Button(IDC_TEAM_CHANGE_CHECK, changeTeams);
  802. //---------------------------------------------------------------------------
  803. // Remix teams not allowed with clan games
  804. //---------------------------------------------------------------------------
  805. bool remixTeams = (!clanned && mRemixTeams);
  806. Enable_Dlg_Item(IDC_REMIX_TEAMS_CHECK, !clanned);
  807. Check_Dlg_Button(IDC_REMIX_TEAMS_CHECK, remixTeams);
  808. //---------------------------------------------------------------------------
  809. // Double check availability of controls
  810. //---------------------------------------------------------------------------
  811. // Ladder is available only if change teams if off
  812. Enable_Dlg_Item(IDC_LADDERED_CHECK, !changeTeams && canLadder);
  813. Check_Dlg_Button(IDC_LADDERED_CHECK, !changeTeams && laddered);
  814. // Clan is available only if change team and remix team is off.
  815. canClan = (!changeTeams && !remixTeams && canClan);
  816. Enable_Dlg_Item(IDC_CLAN_GAME_CHECK, canClan);
  817. Check_Dlg_Button(IDC_CLAN_GAME_CHECK, canClan && clanned);
  818. }
  819. bool MPLanHostAdvancedOptionsTabClass::IsHostAClanMember(void) const
  820. {
  821. GameModeClass* gameMode = GameModeManager::Find("WOL");
  822. if (gameMode && gameMode->Is_Active()) {
  823. WolGameModeClass* wolGame = static_cast<WolGameModeClass*>(gameMode);
  824. WWASSERT(wolGame != NULL);
  825. RefPtr<WWOnline::UserData> host = wolGame->Get_WOL_User_Data(The_Game()->Get_Owner());
  826. if (host.IsValid()) {
  827. return (host->GetSquadID() != 0);
  828. }
  829. }
  830. return false;
  831. }
  832. ////////////////////////////////////////////////////////////////
  833. //
  834. // MPLanHostMapCycleOptionsTabClass
  835. //
  836. ////////////////////////////////////////////////////////////////
  837. MPLanHostMapCycleOptionsTabClass::MPLanHostMapCycleOptionsTabClass (void) :
  838. ChildDialogClass (IDD_MP_LAN_HOST_OPTIONS_MAP_TAB)
  839. {
  840. return ;
  841. }
  842. ////////////////////////////////////////////////////////////////
  843. //
  844. // List_Contains
  845. //
  846. ////////////////////////////////////////////////////////////////
  847. bool
  848. List_Contains(DynamicVectorClass<WideStringClass> & list, WideStringClass & item)
  849. {
  850. for (int index = 0; index < list.Count (); index ++) {
  851. if (list[index] == item) {
  852. return true;
  853. }
  854. }
  855. return false;
  856. }
  857. ////////////////////////////////////////////////////////////////
  858. //
  859. // On_Init_Dialog
  860. //
  861. ////////////////////////////////////////////////////////////////
  862. void
  863. MPLanHostMapCycleOptionsTabClass::On_Init_Dialog (void)
  864. {
  865. Build_Mod_Package_List ();
  866. //
  867. // Create the available maps list
  868. //
  869. ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_AVAILABLE_MAP_LIST_CTRL);
  870. if (list_ctrl != NULL) {
  871. list_ctrl->Add_Column (L"", 1.0F, Vector3 (1, 1, 1));
  872. }
  873. //
  874. // Create the map cycle list
  875. //
  876. list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_MAP_CYCLE_LIST_CTRL);
  877. if (list_ctrl != NULL) {
  878. list_ctrl->Add_Column (L"", 1.0F, Vector3 (1, 1, 1));
  879. }
  880. //
  881. // Build the map lists
  882. //
  883. Populate_Map_List_Ctrl ();
  884. //
  885. // Fill in the map time limit
  886. //
  887. WWASSERT(PTheGameData != NULL);
  888. ((EditCtrlClass *)Get_Dlg_Item (IDC_MAP_TIME_LIMIT_EDIT))->Set_Text_Limit (3);
  889. Set_Dlg_Item_Int (IDC_MAP_TIME_LIMIT_EDIT, The_Game ()->Get_Time_Limit_Minutes ());
  890. Check_Dlg_Button (IDC_LOOP_MAPS_CHECK, The_Game ()->Do_Maps_Loop ());
  891. ChildDialogClass::On_Init_Dialog ();
  892. return ;
  893. }
  894. ////////////////////////////////////////////////////////////////
  895. //
  896. // On_Apply
  897. //
  898. ////////////////////////////////////////////////////////////////
  899. bool
  900. MPLanHostMapCycleOptionsTabClass::On_Apply (void)
  901. {
  902. ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_MAP_CYCLE_LIST_CTRL);
  903. if (list_ctrl != NULL) {
  904. StringClass ascii_string;
  905. //
  906. // Convert the map name from wide-format to ascii-format
  907. //
  908. if (list_ctrl->Get_Entry_Count () > 0) {
  909. WideStringClass map_name (list_ctrl->Get_Entry_Text (0, 0));
  910. map_name.Convert_To (ascii_string);
  911. }
  912. //
  913. // Set the map name
  914. //
  915. WWASSERT(The_Game() != NULL);
  916. The_Game ()->Set_Map_Name (ascii_string);
  917. //
  918. // Configure the radar mode combobox
  919. //
  920. ComboBoxCtrlClass *combobox_ctrl = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_MOD_PACKAGE_COMBO);
  921. if (combobox_ctrl != NULL) {
  922. //
  923. // Lookup the currently selected mod package
  924. //
  925. int curr_sel = combobox_ctrl->Get_Curr_Sel ();
  926. if (curr_sel != -1) {
  927. const ModPackageClass *package = (const ModPackageClass *)combobox_ctrl->Get_Item_Data (curr_sel);
  928. if (package != NULL) {
  929. The_Game ()->Set_Mod_Name (package->Get_Package_Filename ());
  930. } else {
  931. The_Game ()->Set_Mod_Name ("");
  932. }
  933. } else {
  934. The_Game ()->Set_Mod_Name ("");
  935. }
  936. }
  937. //
  938. // Save the map cycle information
  939. //
  940. The_Game()->Clear_Map_Cycle();
  941. for (int i = 0; i < list_ctrl->Get_Entry_Count(); i++) {
  942. if (i < cGameData::MAX_MAPS) {
  943. WideStringClass map_name (list_ctrl->Get_Entry_Text (i, 0));
  944. map_name.Convert_To (ascii_string);
  945. The_Game()->Set_Map_Cycle(i, ascii_string);
  946. }
  947. }
  948. }
  949. //
  950. // Save the map time limit
  951. //
  952. WWASSERT(PTheGameData != NULL);
  953. The_Game ()->Set_Time_Limit_Minutes (Get_Dlg_Item_Int (IDC_MAP_TIME_LIMIT_EDIT));
  954. The_Game ()->Set_Do_Maps_Loop (Is_Dlg_Button_Checked (IDC_LOOP_MAPS_CHECK));
  955. return true;
  956. }
  957. ////////////////////////////////////////////////////////////////
  958. //
  959. // Enable_Mod_Selection
  960. //
  961. ////////////////////////////////////////////////////////////////
  962. void
  963. MPLanHostMapCycleOptionsTabClass::Enable_Mod_Selection (bool onoff)
  964. {
  965. ComboBoxCtrlClass *combobox_ctrl = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_MOD_PACKAGE_COMBO);
  966. if (combobox_ctrl == NULL) {
  967. return ;
  968. }
  969. //
  970. // Either enable or disable the mod selector as necessary
  971. //
  972. if (onoff) {
  973. Enable_Dlg_Item (IDC_MOD_PACKAGE_COMBO, true);
  974. } else {
  975. Enable_Dlg_Item (IDC_MOD_PACKAGE_COMBO, false);
  976. //
  977. // Ensure no mod package is selected and rebuild the map list if necessary
  978. //
  979. if (combobox_ctrl->Get_Curr_Sel () != 0) {
  980. combobox_ctrl->Set_Curr_Sel (0);
  981. Populate_Map_List_Ctrl ();
  982. }
  983. }
  984. return ;
  985. }
  986. ////////////////////////////////////////////////////////////////
  987. //
  988. // Build_Mod_Package_List
  989. //
  990. ////////////////////////////////////////////////////////////////
  991. void
  992. MPLanHostMapCycleOptionsTabClass::Build_Mod_Package_List (void)
  993. {
  994. //
  995. // Configure the radar mode combobox
  996. //
  997. ComboBoxCtrlClass *combobx_ctrl = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_MOD_PACKAGE_COMBO);
  998. if (combobx_ctrl == NULL) {
  999. return ;
  1000. }
  1001. ModPackageMgrClass::Reset_List ();
  1002. ModPackageMgrClass::Build_List ();
  1003. //
  1004. // Get the name of the default mod package
  1005. //
  1006. StringClass ansi_default_pkg = ModPackageMgrClass::Get_Current_Package ().Get_Name ();
  1007. WideStringClass default_pkg;
  1008. default_pkg.Convert_From (ansi_default_pkg);
  1009. //
  1010. // Add a default entry to the list
  1011. //
  1012. combobx_ctrl->Add_String (L"<None>");
  1013. //
  1014. // Loop over and add all the mod packages to the combobox
  1015. //
  1016. bool found = false;
  1017. int count = ModPackageMgrClass::Get_Package_Count ();
  1018. for (int index = 0; index < count; index ++) {
  1019. const ModPackageClass *package = ModPackageMgrClass::Get_Package (index);
  1020. if (package != NULL) {
  1021. //
  1022. // Add an entry for this mod package to the combobox
  1023. //
  1024. WideStringClass curr_name;
  1025. curr_name.Convert_From (package->Get_Name ());
  1026. int item_index = combobx_ctrl->Add_String (curr_name);
  1027. if (item_index != -1) {
  1028. combobx_ctrl->Set_Item_Data (item_index, (uint32)package);
  1029. //
  1030. // Is this the default entry? If so select it...
  1031. //
  1032. if (default_pkg.Compare_No_Case (curr_name) == 0) {
  1033. found = true;
  1034. combobx_ctrl->Set_Curr_Sel (item_index);
  1035. }
  1036. }
  1037. }
  1038. }
  1039. //
  1040. // Select the first entry by default
  1041. //
  1042. if (found == false) {
  1043. combobx_ctrl->Set_Curr_Sel (0);
  1044. }
  1045. return ;
  1046. }
  1047. ////////////////////////////////////////////////////////////////
  1048. //
  1049. // Add_Map
  1050. //
  1051. ////////////////////////////////////////////////////////////////
  1052. void
  1053. MPLanHostMapCycleOptionsTabClass::Add_Map (void)
  1054. {
  1055. ListCtrlClass *avail_list = (ListCtrlClass *)Get_Dlg_Item (IDC_AVAILABLE_MAP_LIST_CTRL);
  1056. ListCtrlClass *cycle_list = (ListCtrlClass *)Get_Dlg_Item (IDC_MAP_CYCLE_LIST_CTRL);
  1057. //
  1058. // Get the current selection, and add it to the cycle list
  1059. //
  1060. int curr_sel = avail_list->Get_Curr_Sel ();
  1061. if (curr_sel >= 0) {
  1062. cycle_list->Insert_Entry (0xFF, avail_list->Get_Entry_Text (curr_sel, 0));
  1063. avail_list->Delete_Entry (curr_sel);
  1064. }
  1065. return ;
  1066. }
  1067. ////////////////////////////////////////////////////////////////
  1068. //
  1069. // Remove_Map
  1070. //
  1071. ////////////////////////////////////////////////////////////////
  1072. void
  1073. MPLanHostMapCycleOptionsTabClass::Remove_Map (void)
  1074. {
  1075. ListCtrlClass *avail_list = (ListCtrlClass *)Get_Dlg_Item (IDC_AVAILABLE_MAP_LIST_CTRL);
  1076. ListCtrlClass *cycle_list = (ListCtrlClass *)Get_Dlg_Item (IDC_MAP_CYCLE_LIST_CTRL);
  1077. //
  1078. // Get the current selection
  1079. //
  1080. int curr_sel = cycle_list->Get_Curr_Sel ();
  1081. if (curr_sel >= 0) {
  1082. //
  1083. // Remove this entry from the list
  1084. //
  1085. avail_list->Insert_Entry (0xFF, cycle_list->Get_Entry_Text (curr_sel, 0));
  1086. cycle_list->Delete_Entry (curr_sel);
  1087. }
  1088. return ;
  1089. }
  1090. ////////////////////////////////////////////////////////////////
  1091. //
  1092. // On_Command
  1093. //
  1094. ////////////////////////////////////////////////////////////////
  1095. void
  1096. MPLanHostMapCycleOptionsTabClass::On_Command (int ctrl_id, int message_id, DWORD param)
  1097. {
  1098. switch (ctrl_id)
  1099. {
  1100. case IDC_ADD_MAP_BUTTON:
  1101. Add_Map ();
  1102. break;
  1103. case IDC_REMOVE_MAP_BUTTON:
  1104. Remove_Map ();
  1105. break;
  1106. }
  1107. ChildDialogClass::On_Command (ctrl_id, message_id, param);
  1108. return ;
  1109. }
  1110. ////////////////////////////////////////////////////////////////
  1111. //
  1112. // On_ListCtrl_DblClk
  1113. //
  1114. ////////////////////////////////////////////////////////////////
  1115. void
  1116. MPLanHostMapCycleOptionsTabClass::On_ListCtrl_DblClk
  1117. (
  1118. ListCtrlClass *list_ctrl,
  1119. int ctrl_id,
  1120. int item_index
  1121. )
  1122. {
  1123. switch (ctrl_id)
  1124. {
  1125. case IDC_AVAILABLE_MAP_LIST_CTRL:
  1126. Add_Map ();
  1127. break;
  1128. case IDC_MAP_CYCLE_LIST_CTRL:
  1129. Remove_Map ();
  1130. break;
  1131. }
  1132. return ;
  1133. }
  1134. ////////////////////////////////////////////////////////////////
  1135. //
  1136. // On_ComboBoxCtrl_Sel_Change
  1137. //
  1138. ////////////////////////////////////////////////////////////////
  1139. void
  1140. MPLanHostMapCycleOptionsTabClass::On_ComboBoxCtrl_Sel_Change
  1141. (
  1142. ComboBoxCtrlClass * combo_ctrl,
  1143. int ctrl_id,
  1144. int old_sel,
  1145. int new_sel
  1146. )
  1147. {
  1148. Populate_Map_List_Ctrl ();
  1149. return ;
  1150. }
  1151. ////////////////////////////////////////////////////////////////
  1152. //
  1153. // Populate_Map_List_Ctrl
  1154. //
  1155. ////////////////////////////////////////////////////////////////
  1156. void
  1157. MPLanHostMapCycleOptionsTabClass::Populate_Map_List_Ctrl (void)
  1158. {
  1159. ComboBoxCtrlClass *combobox_ctrl = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_MOD_PACKAGE_COMBO);
  1160. if (combobox_ctrl == NULL) {
  1161. return ;
  1162. }
  1163. //
  1164. // Lookup the currently selected mod package
  1165. //
  1166. int curr_sel = combobox_ctrl->Get_Curr_Sel ();
  1167. if (curr_sel != -1) {
  1168. const ModPackageClass *package = (const ModPackageClass *)combobox_ctrl->Get_Item_Data (curr_sel);
  1169. //
  1170. // Build a list of levels from the current mod package (or without a mod package)
  1171. //
  1172. Build_Map_List (package);
  1173. //
  1174. // Fill the list controls with map names
  1175. //
  1176. Fill_Map_Ctrls ();
  1177. }
  1178. return ;
  1179. }
  1180. ////////////////////////////////////////////////////////////////
  1181. //
  1182. // Fill_Map_Ctrls
  1183. //
  1184. ////////////////////////////////////////////////////////////////
  1185. void
  1186. MPLanHostMapCycleOptionsTabClass::Fill_Map_Ctrls (void)
  1187. {
  1188. //
  1189. // Build map cycle list from ini file.
  1190. // If map exists, add it to MapCycleList and remove it from MapList
  1191. //
  1192. MapCycleList.Delete_All();
  1193. for (int i = 0; i < cGameData::MAX_MAPS; i++)
  1194. {
  1195. //
  1196. // Get the map name as a wide character string
  1197. //
  1198. WWASSERT(PTheGameData != NULL);
  1199. StringClass ascii_map_name = The_Game ()->Get_Map_Cycle (i);
  1200. WideStringClass map_name;
  1201. map_name.Convert_From (ascii_map_name);
  1202. if (map_name.Get_Length () > 0 && List_Contains(MapList, map_name)) {
  1203. MapList.Delete (map_name);
  1204. MapCycleList.Add (map_name);
  1205. }
  1206. }
  1207. //
  1208. // Add the first map by default
  1209. //
  1210. if (MapCycleList.Count () == 0 && MapList.Count () > 0) {
  1211. MapCycleList.Add (MapList[0]);
  1212. MapList.Delete (0);
  1213. }
  1214. //
  1215. // Create the available maps list
  1216. //
  1217. ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_AVAILABLE_MAP_LIST_CTRL);
  1218. if (list_ctrl != NULL) {
  1219. //
  1220. // Start fresh
  1221. //
  1222. list_ctrl->Delete_All_Entries ();
  1223. //
  1224. // Add the map list into the list ctrl
  1225. //
  1226. for (int index = 0; index < MapList.Count (); index ++) {
  1227. list_ctrl->Insert_Entry (index, MapList[index]);
  1228. }
  1229. //
  1230. // Select the first entry by default
  1231. //
  1232. list_ctrl->Set_Curr_Sel (0);
  1233. }
  1234. //
  1235. // Create the map cycle list
  1236. //
  1237. list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_MAP_CYCLE_LIST_CTRL);
  1238. if (list_ctrl != NULL) {
  1239. //
  1240. // Start fresh
  1241. //
  1242. list_ctrl->Delete_All_Entries ();
  1243. //
  1244. // Add the map cycle list into the list ctrl
  1245. //
  1246. for (int index = 0; index < MapCycleList.Count (); index ++) {
  1247. list_ctrl->Insert_Entry (index, MapCycleList[index]);
  1248. }
  1249. //
  1250. // Select the first entry by default
  1251. //
  1252. list_ctrl->Set_Curr_Sel (0);
  1253. }
  1254. return ;
  1255. }
  1256. ////////////////////////////////////////////////////////////////
  1257. //
  1258. // Build_Map_List
  1259. //
  1260. ////////////////////////////////////////////////////////////////
  1261. void
  1262. MPLanHostMapCycleOptionsTabClass::Build_Map_List (const ModPackageClass *package)
  1263. {
  1264. if (package == NULL) {
  1265. Build_Map_List ();
  1266. } else {
  1267. //
  1268. // Generate a list of levels from the mod package
  1269. //
  1270. DynamicVectorClass<StringClass> map_list;
  1271. package->Build_Level_List (map_list);
  1272. //
  1273. // Copy the map list
  1274. //
  1275. MapList.Delete_All ();
  1276. for (int index = 0; index < map_list.Count (); index ++) {
  1277. WideStringClass wide_map_name;
  1278. wide_map_name.Convert_From (map_list[index]);
  1279. MapList.Add (wide_map_name);
  1280. }
  1281. }
  1282. return ;
  1283. }
  1284. ////////////////////////////////////////////////////////////////
  1285. //
  1286. // Build_Map_List
  1287. //
  1288. ////////////////////////////////////////////////////////////////
  1289. void
  1290. MPLanHostMapCycleOptionsTabClass::Build_Map_List (void)
  1291. {
  1292. MapList.Delete_All ();
  1293. WIN32_FIND_DATA find_info = { 0 };
  1294. BOOL keep_going = TRUE;
  1295. HANDLE file_find = NULL;
  1296. //
  1297. // Build a list of all the maps we know about
  1298. //
  1299. StringClass file_filter;
  1300. WWASSERT(The_Game() != NULL);
  1301. if (The_Game()->Is_Cnc()) {
  1302. file_filter.Format("data\\c&c_*.mix");
  1303. } else {
  1304. file_filter.Format("data\\mp_*.mix");
  1305. }
  1306. #ifdef WWDEBUG
  1307. if (cDevOptions::FilterLevelFiles.Is_False()) {
  1308. file_filter = "data\\*.mix";
  1309. }
  1310. #endif // WWDEBUG
  1311. for (file_find = ::FindFirstFile (file_filter, &find_info);
  1312. (file_find != INVALID_HANDLE_VALUE) && keep_going;
  1313. keep_going = ::FindNextFile (file_find, &find_info))
  1314. {
  1315. //
  1316. // Convert the string to a wide character format
  1317. //
  1318. WideStringClass map_name;
  1319. map_name.Convert_From (find_info.cFileName);
  1320. //
  1321. // Add this name to our list
  1322. //
  1323. MapList.Add (map_name);
  1324. }
  1325. if (file_find != INVALID_HANDLE_VALUE) {
  1326. ::FindClose (file_find);
  1327. }
  1328. return ;
  1329. }
  1330. ////////////////////////////////////////////////////////////////
  1331. //
  1332. // MPLanHostVictoryOptionsTabClass
  1333. //
  1334. ////////////////////////////////////////////////////////////////
  1335. MPLanHostVictoryOptionsTabClass::MPLanHostVictoryOptionsTabClass (void) :
  1336. ChildDialogClass (IDD_MP_LAN_HOST_OPTIONS_VICTORY_TAB)
  1337. {
  1338. return ;
  1339. }
  1340. ////////////////////////////////////////////////////////////////
  1341. //
  1342. // On_Init_Dialog
  1343. //
  1344. ////////////////////////////////////////////////////////////////
  1345. void
  1346. MPLanHostVictoryOptionsTabClass::On_Init_Dialog (void)
  1347. {
  1348. //
  1349. // Configure the score and life/kill limit controls
  1350. //
  1351. Update_Enable_State ();
  1352. //
  1353. // Set the check state of the CnC mode controls
  1354. //
  1355. WWASSERT(PTheGameData != NULL);
  1356. cGameDataCnc *cnc_mode = The_Game ()->As_Cnc ();
  1357. if (cnc_mode != NULL) {
  1358. Check_Dlg_Button (IDC_DESTROY_ALL_BUILDINGS_CHECK, cnc_mode->BaseDestructionEndsGame.Get());
  1359. Check_Dlg_Button (IDC_BEACON_CHECK, cnc_mode->BeaconPlacementEndsGame.Get());
  1360. Update_Enable_State();
  1361. } else {
  1362. Check_Dlg_Button (IDC_DESTROY_ALL_BUILDINGS_CHECK, false);
  1363. Check_Dlg_Button (IDC_BEACON_CHECK, false);
  1364. Enable_Dlg_Item (IDC_DESTROY_ALL_BUILDINGS_CHECK, false);
  1365. Enable_Dlg_Item (IDC_BEACON_CHECK, false);
  1366. }
  1367. ChildDialogClass::On_Init_Dialog ();
  1368. return ;
  1369. }
  1370. ////////////////////////////////////////////////////////////////
  1371. //
  1372. // On_Apply
  1373. //
  1374. ////////////////////////////////////////////////////////////////
  1375. bool
  1376. MPLanHostVictoryOptionsTabClass::On_Apply (void)
  1377. {
  1378. //
  1379. // Pass our settings onto the game
  1380. //
  1381. //
  1382. // Save any CnC mode specific data
  1383. //
  1384. WWASSERT(PTheGameData != NULL);
  1385. cGameDataCnc *cnc_mode = The_Game ()->As_Cnc ();
  1386. if (cnc_mode != NULL) {
  1387. //Check_Dlg_Button (IDC_DESTROY_ALL_BUILDINGS_CHECK, true);
  1388. //Check_Dlg_Button (IDC_BEACON_CHECK, true);
  1389. cnc_mode->BaseDestructionEndsGame.Set(Is_Dlg_Button_Checked(IDC_DESTROY_ALL_BUILDINGS_CHECK));
  1390. cnc_mode->BeaconPlacementEndsGame.Set(Is_Dlg_Button_Checked(IDC_BEACON_CHECK));
  1391. }
  1392. return true;
  1393. }
  1394. ////////////////////////////////////////////////////////////////
  1395. //
  1396. // Update_Enable_State
  1397. //
  1398. ////////////////////////////////////////////////////////////////
  1399. void
  1400. MPLanHostVictoryOptionsTabClass::Update_Enable_State (void)
  1401. {
  1402. /*
  1403. bool enable = Is_Dlg_Button_Checked (IDC_SCORE_LIMIT_CHECK);
  1404. Enable_Dlg_Item (IDC_SCORE_LIMIT_EDIT, enable);
  1405. enable = Is_Dlg_Button_Checked (IDC_KILL_LIMIT_CHECK);
  1406. Enable_Dlg_Item (IDC_KILL_LIMIT_EDIT, enable);
  1407. */
  1408. //
  1409. // Beacon option dependent on base destruction option
  1410. //
  1411. bool enable = Is_Dlg_Button_Checked (IDC_DESTROY_ALL_BUILDINGS_CHECK);
  1412. Enable_Dlg_Item (IDC_BEACON_CHECK, enable);
  1413. //
  1414. // Make sure to uncheck the beacon check if its disabled...
  1415. //
  1416. if (enable == false) {
  1417. Check_Dlg_Button (IDC_BEACON_CHECK, false);
  1418. }
  1419. return ;
  1420. }
  1421. ////////////////////////////////////////////////////////////////
  1422. //
  1423. // On_Command
  1424. //
  1425. ////////////////////////////////////////////////////////////////
  1426. void
  1427. MPLanHostVictoryOptionsTabClass::On_Command (int ctrl_id, int message_id, DWORD param)
  1428. {
  1429. /*
  1430. switch (ctrl_id)
  1431. {
  1432. case IDC_SCORE_LIMIT_CHECK:
  1433. case IDC_KILL_LIMIT_CHECK:
  1434. Update_Enable_State ();
  1435. break;
  1436. }
  1437. */
  1438. switch (ctrl_id)
  1439. {
  1440. case IDC_DESTROY_ALL_BUILDINGS_CHECK:
  1441. Update_Enable_State ();
  1442. break;
  1443. }
  1444. ChildDialogClass::On_Command (ctrl_id, message_id, param);
  1445. return ;
  1446. }
  1447. ////////////////////////////////////////////////////////////////
  1448. //
  1449. // On_Init_Dialog
  1450. //
  1451. ////////////////////////////////////////////////////////////////
  1452. void
  1453. MPLanHostCnCOptionsTabClass::On_Init_Dialog (void)
  1454. {
  1455. WWASSERT(PTheGameData != NULL);
  1456. cGameDataCnc *game_data = The_Game ()->As_Cnc ();
  1457. WWASSERT (game_data != NULL);
  1458. //
  1459. // Configure the edit control
  1460. //
  1461. EditCtrlClass * edit = (EditCtrlClass *)Get_Dlg_Item(IDC_STARTING_CREDITS_EDIT);
  1462. if (edit != NULL)
  1463. {
  1464. edit->Set_Text_Limit(5);
  1465. }
  1466. Set_Dlg_Item_Int (IDC_STARTING_CREDITS_EDIT, game_data->Get_Starting_Credits ());
  1467. //
  1468. // Configure the checkboxes
  1469. //
  1470. Check_Dlg_Button (IDC_CAN_REPAIR_BUILDINGS_CHECK, The_Game ()->CanRepairBuildings.Is_True ());
  1471. Check_Dlg_Button (IDC_DRIVER_IS_ALWAYS_GUNNER_CHECK, The_Game ()->DriverIsAlwaysGunner.Is_True ());
  1472. Check_Dlg_Button (IDC_SPAWN_WEAPONS_CHECK, The_Game ()->SpawnWeapons.Is_True ());
  1473. Check_Dlg_Button (IDC_ALLIED_FIRE_CHECK, The_Game ()->IsFriendlyFirePermitted.Is_True ());
  1474. Enable_Dlg_Item (IDC_ALLIED_FIRE_CHECK, The_Game ()->Is_Editable_Friendly_Fire ());
  1475. //
  1476. // Configure the radar mode combobox
  1477. //
  1478. ComboBoxCtrlClass *radar_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_RADAR_MODE_COMBO);
  1479. if (radar_combobox != NULL) {
  1480. //
  1481. // Fill the radar_combobox
  1482. //
  1483. radar_combobox->Add_String (TRANSLATION(IDS_MP_RADAR_MODE_NOBODY));
  1484. radar_combobox->Add_String (TRANSLATION(IDS_MP_RADAR_MODE_TEAMMATES));
  1485. radar_combobox->Add_String (TRANSLATION(IDS_MP_RADAR_MODE_ALL));
  1486. //
  1487. // Select the default entry in the radar_combobox
  1488. //
  1489. radar_combobox->Set_Curr_Sel (The_Game ()->Get_Radar_Mode ());
  1490. }
  1491. ChildDialogClass::On_Init_Dialog ();
  1492. return ;
  1493. }
  1494. ////////////////////////////////////////////////////////////////
  1495. //
  1496. // On_Apply
  1497. //
  1498. ////////////////////////////////////////////////////////////////
  1499. bool
  1500. MPLanHostCnCOptionsTabClass::On_Apply (void)
  1501. {
  1502. WWASSERT(PTheGameData != NULL);
  1503. cGameDataCnc *game_data = The_Game ()->As_Cnc ();
  1504. WWASSERT (game_data != NULL);
  1505. //
  1506. // Read the edit control
  1507. //
  1508. game_data->Set_Starting_Credits (Get_Dlg_Item_Int (IDC_STARTING_CREDITS_EDIT));
  1509. //
  1510. // Read the checkboxes
  1511. //
  1512. The_Game ()->CanRepairBuildings.Set (Is_Dlg_Button_Checked (IDC_CAN_REPAIR_BUILDINGS_CHECK));
  1513. The_Game ()->DriverIsAlwaysGunner.Set (Is_Dlg_Button_Checked (IDC_DRIVER_IS_ALWAYS_GUNNER_CHECK));
  1514. The_Game ()->SpawnWeapons.Set (Is_Dlg_Button_Checked (IDC_SPAWN_WEAPONS_CHECK));
  1515. The_Game ()->IsFriendlyFirePermitted.Set (Is_Dlg_Button_Checked (IDC_ALLIED_FIRE_CHECK));
  1516. //
  1517. // Read the radar mode combobox
  1518. //
  1519. ComboBoxCtrlClass *radar_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_RADAR_MODE_COMBO);
  1520. if (radar_combobox != NULL) {
  1521. The_Game ()->Set_Radar_Mode ((RadarModeEnum)radar_combobox->Get_Curr_Sel ());
  1522. }
  1523. return true;
  1524. }