| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** 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 ***
- ***********************************************************************************************
- * *
- * Project Name : Combat *
- * *
- * $Archive:: /Commando/Code/Commando/dlgmplanhostoptions.cpp $*
- * *
- * Author:: Patrick Smith *
- * *
- * $Modtime:: 6/21/02 11:40a $*
- * *
- * $Revision:: 81 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "dlgmplanhostoptions.h"
- #include "tabctrl.h"
- #include "gamedata.h"
- #include "netutil.h"
- #include "listctrl.h"
- #include "comboboxctrl.h"
- #include "gameinitmgr.h"
- #include "renegadedialogmgr.h"
- #include "gdcnc.h"
- #include "devoptions.h"
- #include "translatedb.h"
- #include "string_ids.h"
- #include "translatedb.h"
- #include "nicenum.h"
- #include "useroptions.h"
- #include "gamemode.h"
- #include "wolgmode.h"
- #include "campaign.h"
- #include "mpsettingsmgr.h"
- #include "specialbuilds.h"
- #include "dlgmpslaveservers.h"
- #include "wolgmode.h"
- #include "wolloginprofile.h"
- #include "dlgserversaveload.h"
- #include "modpackagemgr.h"
- #include "modpackage.h"
- #include "gamespyadmin.h"
- #include "specialbuilds.h"
- ////////////////////////////////////////////////////////////////
- //
- // MPLanHostOptionsMenuClass
- //
- ////////////////////////////////////////////////////////////////
- MPLanHostOptionsMenuClass::MPLanHostOptionsMenuClass (void) :
- MenuDialogClass (IDD_MP_LAN_HOST_OPTIONS),
- mStartTheGame (false),
- mClanID (0),
- MapCycleDialog (NULL)
- {
- return ;
- }
- MPLanHostOptionsMenuClass::~MPLanHostOptionsMenuClass (void)
- {
- WWDEBUG_SAY(("MPLanHostOptionsMenuClass: Destroyed\n"));
- REF_PTR_RELEASE (MapCycleDialog);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Init_Dialog
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostOptionsMenuClass::On_Init_Dialog (void)
- {
- #ifdef BETACLIENT
- Get_Dlg_Item(IDC_MENU_MP_LAN_START_BUTTON)->Enable(false);
- #endif // BETACLIENT
- WWASSERT(PTheGameData != NULL);
- WWASSERT(The_Game ()->Is_Cnc());
- Set_Dlg_Item_Text(IDC_GAME_TYPE_TITLE, TRANSLATE(IDS_MP_GAME_CNC));
- TabCtrlClass *tab_ctrl = (TabCtrlClass *)Get_Dlg_Item (IDC_TABCTRL);
- if (tab_ctrl != NULL) {
- //
- // Add the tabs to the control
- //
- TABCTRL_ADD_TAB (tab_ctrl, MPLanHostBasicOptionsTabClass);
- //
- // Add any mode-specific tabs to the control
- //
- if (The_Game ()->As_Cnc () != NULL) {
- TABCTRL_ADD_TAB (tab_ctrl, MPLanHostCnCOptionsTabClass);
- }
- TABCTRL_ADD_TAB (tab_ctrl, MPLanHostAdvancedOptionsTabClass);
- TABCTRL_ADD_TAB (tab_ctrl, MPLanHostVictoryOptionsTabClass);
-
- //
- // Keep a pointer around to the map cycle tab so we can
- // modify its contents as necessary
- //
- MapCycleDialog = new MPLanHostMapCycleOptionsTabClass;
- tab_ctrl->Add_Tab (MapCycleDialog);
- }
- MenuDialogClass::On_Init_Dialog ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Enable_Mod_Selection
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostOptionsMenuClass::Enable_Mod_Selection (bool onoff)
- {
- if (MapCycleDialog == NULL) {
- return ;
- }
- MapCycleDialog->Enable_Mod_Selection (onoff);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Periodic
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostOptionsMenuClass::On_Periodic (void)
- {
- MenuDialogClass::On_Periodic();
- if (mStartTheGame) {
- WWASSERT(PTheGameData != NULL);
- Start_Game(The_Game());
- mStartTheGame = false;
- End_Dialog();
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Command
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostOptionsMenuClass::On_Command (int ctrl_id, int message_id, DWORD param)
- {
- switch (ctrl_id) {
- case IDC_MENU_MP_LAN_START_BUTTON:
- {
- //
- // Get a pointer to the tab ctrl
- //
- TabCtrlClass *tab_ctrl = (TabCtrlClass *)Get_Dlg_Item (IDC_TABCTRL);
- if (tab_ctrl != NULL) {
- //
- // Save the changes on each tab of the control
- //
- if (tab_ctrl->Apply_Changes_On_Tabs ()) {
- //
- // Are the settings valid?
- //
- WWASSERT(PTheGameData != NULL);
- WideStringClass outMsg;
- if (The_Game()->Is_Valid_Settings (outMsg, true)) {
- //
- // Save the settings
- //
- The_Game()->Save_To_Server_Config ();
- if (cUserOptions::Get_Bandwidth_Type() == BANDWIDTH_AUTO) {
- if (The_Game()->Get_Max_Players() > 2) {
- int available_bw = cUserOptions::BandwidthBps.Get();
- int required_bw = The_Game()->Get_Max_Players() * 64000;
- int set_bw = min(required_bw, available_bw);
- WWDEBUG_SAY(("MPLanHostOptionsMenuClass::On_Command - Setting BandwidthBps to %d\n", set_bw));
- cUserOptions::BandwidthBps.Set(set_bw);
- }
- }
- SlaveMaster.Startup_Slaves();
- GameModeClass* gameMode = GameModeManager::Find("WOL");
- if (gameMode && gameMode->Is_Active()) {
- WolGameModeClass* wolGame = static_cast<WolGameModeClass*>(gameMode);
- WWASSERT(wolGame);
- wolGame->SignalMe(*this);
- wolGame->Create_Game(The_Game());
- } else {
- Start_Game(The_Game());
- }
- } else {
- WideStringClass errorMsg(0, true);
- errorMsg.Format(L"%s\n\n%s", TRANSLATE(IDS_MENU_TEXT330), (const WCHAR*)outMsg);
- DlgMsgBox::DoDialog(TRANSLATE(IDS_MENU_TEXT329), errorMsg);
- }
- }
- }
- }
- break;
- case IDC_SAVELOAD_BUTTON:
- TabCtrlClass *tab_ctrl = (TabCtrlClass *)Get_Dlg_Item (IDC_TABCTRL);
- if (tab_ctrl != NULL) {
- //
- // Save the changes on each tab of the control back to the game data.
- //
- if (tab_ctrl->Apply_Changes_On_Tabs()) {
- End_Dialog();
- ServerSaveLoadMenuClass::Set_From_Slave_Config(false);
- START_DIALOG(ServerSaveLoadMenuClass);
- }
- }
- break;
- }
- MenuDialogClass::On_Command (ctrl_id, message_id, param);
- return ;
- }
- void MPLanHostOptionsMenuClass::ReceiveSignal(WolGameModeClass& gameMode)
- {
- if (gameMode.Channel_Create_OK()) {
- mStartTheGame = true;
- mClanID = 0;
- // If this is a clan game then get the current users clan.
- if (The_Game()->IsClanGame.Is_True()) {
- RefPtr<WWOnline::Session> wolSession = WWOnline::Session::GetInstance(false);
- if (wolSession.IsValid()) {
- RefPtr<WWOnline::UserData> user = wolSession->GetCurrentUser();
- if (user.IsValid()) {
- mClanID = user->GetSquadID();
- }
- }
- }
- }
- }
- void MPLanHostOptionsMenuClass::Start_Game(cGameData* theGame)
- {
- CampaignManager::Select_Backdrop_Number_By_MP_Type( theGame->Get_Game_Type() );
- GameInitMgrClass::Set_Is_Client_Required(theGame->IsDedicated.Is_False());
- GameInitMgrClass::Set_Is_Server_Required(true);
- int side = cNetInterface::Get_Side_Preference();
- GameInitMgrClass::Start_Game(theGame->Get_Map_Name(), side, mClanID);
- }
- ////////////////////////////////////////////////////////////////
- //
- // MPLanHostBasicOptionsTabClass
- //
- ////////////////////////////////////////////////////////////////
- MPLanHostBasicOptionsTabClass* MPLanHostBasicOptionsTabClass::_mInstance = NULL;
- int MPLanHostBasicOptionsTabClass::BandTestMaxPlayers = 0;
- MPLanHostBasicOptionsTabClass* MPLanHostBasicOptionsTabClass::Get_Instance(void)
- {
- if (_mInstance) {
- _mInstance->Add_Ref();
- return _mInstance;
- }
- return NULL;
- }
- MPLanHostBasicOptionsTabClass::MPLanHostBasicOptionsTabClass (void) :
- ChildDialogClass (IDD_MP_LAN_HOST_OPTIONS_BASIC_TAB)
- {
- assert(_mInstance == NULL);
- _mInstance = this;
- }
- MPLanHostBasicOptionsTabClass::~MPLanHostBasicOptionsTabClass (void)
- {
- _mInstance = NULL;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Init_Dialog
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostBasicOptionsTabClass::On_Init_Dialog (void)
- {
- bool wolGame = GameModeManager::Find("WOL")->Is_Active();
- //
- // Fill in the game name
- //
- WWASSERT(PTheGameData != NULL);
- ((EditCtrlClass *)Get_Dlg_Item (IDC_GAME_NAME_EDIT))->Set_Text_Limit (25);
- Set_Dlg_Item_Text (IDC_GAME_NAME_EDIT, The_Game ()->Get_Game_Title ());
- //
- // Fill in the password control on the dialog
- //
- ((EditCtrlClass *)Get_Dlg_Item (IDC_PASSWORD_EDIT))->Set_Text_Limit (15);
- //Set_Dlg_Item_Text (IDC_PASSWORD_EDIT, The_Game ()->Get_Password ());
- /*
- if (cGameSpyAdmin::Is_Gamespy_Game()) {
- Get_Dlg_Item(IDC_PASSWORD_EDIT)->Enable(false);
- }
- */
- //
- // Fill in the max-players control on the dialog
- //
- if (wolGame || cGameSpyAdmin::Is_Gamespy_Game()) {
- BandTestMaxPlayers = (cUserOptions::BandwidthBps.Get() / 250000) * 4;
- if (BandTestMaxPlayers < 2) {
- if (cUserOptions::BandwidthBps.Get() > 100000) {
- BandTestMaxPlayers = 4;
- } else {
- BandTestMaxPlayers = 2;
- }
- }
- // Enable_Dlg_Item(IDC_NUM_PLAYERS_EDIT, false);
- int max_players = min(The_Game ()->Get_Max_Players (), BandTestMaxPlayers);
- Set_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT, min(max_players, NetworkObjectClass::MAX_CLIENT_COUNT-1));
- } else {
- Set_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT, min(The_Game ()->Get_Max_Players (), NetworkObjectClass::MAX_CLIENT_COUNT-1));
- }
- //
- // Configure the IP NIC Enumeration combobox
- //
- ComboBoxCtrlClass *nic_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_HOSTING_IP_COMBO);
- if (nic_combobox != NULL) {
- ULONG * nics = NULL;
- int nic_count = 0;
- ULONG preferred_nick;
- if (!cGameSpyAdmin::Get_Is_Server_Gamespy_Listed()) {
- nics = cNicEnum::Get_Nics();
- nic_count = cNicEnum::Get_Num_Nics();
- preferred_nick = cUserOptions::PreferredLanNic.Get();
- } else {
- nics = cNicEnum::Get_GameSpy_Nics();
- nic_count = cNicEnum::Get_Num_GameSpy_Nics();
- preferred_nick = cUserOptions::PreferredGameSpyNic.Get();
- }
- WWASSERT(nics != NULL);
- int current_index = -1;
- for (USHORT index = 0; index < nic_count; index++) {
- WideStringClass nic_string;
- nic_string.Convert_From(cNetUtil::Address_To_String(nics[index]));
- nic_combobox->Add_String( nic_string );
- if (nics[index] == preferred_nick) {
- current_index = index;
- }
- }
- //
- // Select the default entry in the radar_combobox
- //
- nic_combobox->Set_Curr_Sel ( current_index );
- Enable_Dlg_Item(IDC_HOSTING_IP_COMBO, !wolGame);
- }
- int sidePref = cNetInterface::Get_Side_Preference();
- if (wolGame) {
- RefPtr<WWOnline::Session> wolSession = WWOnline::Session::GetInstance(false);
- if (wolSession.IsValid()) {
- const RefPtr<WWOnline::LoginInfo>& login = wolSession->GetCurrentLogin();
- assert(login.IsValid());
- LoginProfile* profile = LoginProfile::Get(login->GetNickname());
- if (profile) {
- sidePref = profile->GetSidePreference();
- profile->Release_Ref();
- }
- }
- }
- InitSideChoiceCombo(sidePref);
- ChildDialogClass::On_Init_Dialog ();
- return ;
- }
- /******************************************************************************
- *
- * NAME
- * MPLanHostBasicOptionsTabClass::InitSideChoiceCombo
- *
- * DESCRIPTION
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void MPLanHostBasicOptionsTabClass::InitSideChoiceCombo(int sidePref)
- {
- ComboBoxCtrlClass* combo = (ComboBoxCtrlClass*)Get_Dlg_Item(IDC_CHOOSESIDE_COMBO);
- if (combo) {
- //(gth) Renegade day 120 Patch: re-translate these strings each time!
- struct {const wchar_t* TeamName; int TeamID;} _teams[] = {
- {TRANSLATE (IDS_MENU_AUTO_TEAM), PLAYERTYPE_RENEGADE},
- {TRANSLATE (IDS_MENU_TEXT933), PLAYERTYPE_GDI},
- {TRANSLATE (IDS_MENU_TEXT934), PLAYERTYPE_NOD},
- {NULL, -1},
- };
- int index = 0;
- while (_teams[index].TeamName != NULL) {
- int item = combo->Add_String(_teams[index].TeamName);
- if (item >= 0) {
- combo->Set_Item_Data(item, (uint32)_teams[index].TeamID);
- }
- if (_teams[index].TeamID == sidePref) {
- combo->Set_Curr_Sel(index);
- }
- ++index;
- }
- if (combo->Get_Curr_Sel() == -1) {
- combo->Set_Curr_Sel(0);
- }
- }
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Apply
- //
- ////////////////////////////////////////////////////////////////
- bool
- MPLanHostBasicOptionsTabClass::On_Apply (void)
- {
- WideStringClass password = Get_Dlg_Item_Text (IDC_PASSWORD_EDIT);
- WWASSERT(PTheGameData != NULL);
- The_Game ()->IsPassworded.Set ((password.Get_Length () > 0));
- //
- // Pass our settings onto the game
- //
- The_Game ()->Set_Game_Title (Get_Dlg_Item_Text (IDC_GAME_NAME_EDIT));
- The_Game ()->Set_Password (password);
- // Has to be -1 since we use the last client as a reference for refreshing dirty bits.
- The_Game ()->Set_Max_Players (min(Get_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT), NetworkObjectClass::MAX_CLIENT_COUNT - 1));
- // Quickmatch games can not have passwords
- if (The_Game()->IsPassworded.Is_True()) {
- The_Game()->Set_QuickMatch_Server(false);
- }
- //
- // Read the IP NIC Enumeration combobox
- //
- if (!GameModeManager::Find("WOL")->Is_Active() && !cGameSpyAdmin::Get_Is_Server_Gamespy_Listed()) {
- ComboBoxCtrlClass *nic_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_HOSTING_IP_COMBO);
- if (nic_combobox != NULL) {
- int curr_sel = nic_combobox->Get_Curr_Sel ();
- WWASSERT(curr_sel < cNicEnum::Get_Num_Nics());
- if (curr_sel >= 0) {
- ULONG * nics = cNicEnum::Get_Nics();
- WWASSERT(nics != NULL);
- cUserOptions::PreferredLanNic.Set(nics[curr_sel]);
- The_Game()->Set_Ip_Address(nics[curr_sel]);
- }
- }
- } else if (!GameModeManager::Find("WOL")->Is_Active() && cGameSpyAdmin::Get_Is_Server_Gamespy_Listed()) {
- ComboBoxCtrlClass *nic_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_HOSTING_IP_COMBO);
- if (nic_combobox != NULL) {
- int curr_sel = nic_combobox->Get_Curr_Sel ();
- WWASSERT(curr_sel < cNicEnum::Get_Num_GameSpy_Nics());
- if (curr_sel >= 0) {
- ULONG * nics = cNicEnum::Get_GameSpy_Nics();
- WWASSERT(nics != NULL);
- cUserOptions::PreferredGameSpyNic.Set(nics[curr_sel]);
- The_Game()->Set_Ip_Address(nics[curr_sel]);
- }
- }
- } else if (!GameModeManager::Find("WOL")->Is_Active() && cGameSpyAdmin::Get_Is_Server_Gamespy_Listed()) {
- ComboBoxCtrlClass *nic_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_HOSTING_IP_COMBO);
- if (nic_combobox != NULL) {
- int curr_sel = nic_combobox->Get_Curr_Sel ();
- WWASSERT(curr_sel < cNicEnum::Get_Num_GameSpy_Nics());
- if (curr_sel >= 0) {
- ULONG * nics = cNicEnum::Get_GameSpy_Nics();
- WWASSERT(nics != NULL);
- cUserOptions::PreferredGameSpyNic.Set(nics[curr_sel]);
- The_Game()->Set_Ip_Address(nics[curr_sel]);
- }
- }
- }
- ComboBoxCtrlClass* combo = (ComboBoxCtrlClass*)Get_Dlg_Item(IDC_CHOOSESIDE_COMBO);
- if (combo) {
- int curSel = combo->Get_Curr_Sel();
- int side = combo->Get_Item_Data(curSel);
- cNetInterface::Set_Side_Preference(side);
- }
- return true;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_EditCtrl_Change
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostBasicOptionsTabClass::On_EditCtrl_Change (EditCtrlClass *edit, int ctrlID)
- {
- if (IDC_PASSWORD_EDIT == ctrlID) {
- //
- // Flag the game as passworded if the user enters text into the password edit.
- //
- const WCHAR* text = edit->Get_Text ();
- bool hasPassword = (text && (wcslen (text) > 0));
- SendSignal (hasPassword);
- } else if (ctrlID == IDC_NUM_PLAYERS_EDIT) {
- int max_players = min(BandTestMaxPlayers, NetworkObjectClass::MAX_CLIENT_COUNT-1);
- //
- // Check to ensure the player count is within bounds...
- //
- int player_count = Get_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT);
- if (player_count < 0 || player_count > NetworkObjectClass::MAX_CLIENT_COUNT-1) {
- player_count = min (player_count, NetworkObjectClass::MAX_CLIENT_COUNT-1);
- player_count = max (player_count, 0);
- Set_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT, player_count);
- }
- bool wol_game = GameModeManager::Find("WOL")->Is_Active();
- if ((wol_game || cGameSpyAdmin::Is_Gamespy_Game()) && player_count > max_players) {
- player_count = max_players;
- Set_Dlg_Item_Int (IDC_NUM_PLAYERS_EDIT, player_count);
- DlgMsgBox::DoDialog(IDS_MENU_TEXT329, IDS_MP_MAXPLAYER_WARNING, DlgMsgBox::Okay);
- }
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // MPLanHostAdvancedOptionsTabClass
- //
- ////////////////////////////////////////////////////////////////
- MPLanHostAdvancedOptionsTabClass::MPLanHostAdvancedOptionsTabClass (void) :
- ChildDialogClass (IDD_MP_LAN_HOST_OPTIONS_ADVANCED_TAB)
- {
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Init_Dialog
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostAdvancedOptionsTabClass::On_Init_Dialog (void)
- {
- MPLanHostBasicOptionsTabClass* basicTab = MPLanHostBasicOptionsTabClass::Get_Instance();
- if (basicTab) {
- basicTab->SignalMe(*this);
- basicTab->Release_Ref();
- }
- #ifdef FREEDEDICATEDSERVER
- WWASSERT(PTheGameData != NULL);
- The_Game ()->IsDedicated.Set(true);
- Enable_Dlg_Item (IDC_DEDICATED_SERVER_CHECK, false);
- #endif // FREEDEDICATEDSERVER
- // if (cGameSpyAdmin::Is_Gamespy_Game()) {
- // WWASSERT(PTheGameData != NULL);
- // The_Game ()->IsDedicated.Set(true);
- // Enable_Dlg_Item (IDC_DEDICATED_SERVER_CHECK, false);
- // }
- Check_Dlg_Button (IDC_DEDICATED_SERVER_CHECK, The_Game ()->IsDedicated.Is_True ());
- // Change teams is ON if team editing and changing team allowed is true
- bool canChangeTeams = The_Game()->Is_Editable_Teaming();
- mChangeTeams = canChangeTeams && The_Game()->IsTeamChangingAllowed.Is_True();
- Check_Dlg_Button(IDC_TEAM_CHANGE_CHECK, mChangeTeams);
- Enable_Dlg_Item(IDC_TEAM_CHANGE_CHECK, canChangeTeams);
- // Remix teams is ON if team change is FALSE and remix setting is true.
- mRemixTeams = The_Game()->IsTeamChangingAllowed.Is_False() && The_Game()->RemixTeams.Is_True();
- Check_Dlg_Button(IDC_REMIX_TEAMS_CHECK, mRemixTeams);
- Enable_Dlg_Item(IDC_REMIX_TEAMS_CHECK, The_Game()->IsTeamChangingAllowed.Is_False());
- //Check_Dlg_Button (IDC_TRUST_CLIENTS_CHECK, The_Game ()->IsClientTrusted.Is_True ());
- #ifdef MULTIPLAYERDEMO
- Enable_Dlg_Item(IDC_SERVER_RESTART_CHECK, false);
- Check_Dlg_Button (IDC_SERVER_RESTART_CHECK, false);
- #else
- Check_Dlg_Button (IDC_SERVER_RESTART_CHECK, The_Game ()->IsAutoRestart.Is_True ());
- #endif // MULTIPLAYERDEMO
- // Configure WOL settings
- mIsWOLGame = GameModeManager::Find("WOL")->Is_Active();
- mPassword = The_Game()->IsPassworded.Get();
- mLaddered = (mIsWOLGame && The_Game()->IsLaddered.Is_True());
- mClanGame = (mIsWOLGame && IsHostAClanMember() && The_Game()->IsClanGame.Is_True());
- mQuickmatch = (mIsWOLGame && !mPassword && The_Game()->Is_QuickMatch_Server());
- ConfigureWOLControls();
- if (The_Game()->IsDedicated.Is_False()) {// || (mIsWOLGame && strlen(MPSettingsMgrClass::Get_Auto_Login()) == 0)) {
- Check_Dlg_Button(IDC_SERVER_RESTART_CHECK, false);
- Enable_Dlg_Item(IDC_SERVER_RESTART_CHECK, false);
- }
- if (!GameModeManager::Find("WOL")->Is_Active()) {
- Enable_Dlg_Item(IDC_MENU_MP_LAN_SLAVE_SERVER_BUTTON, false);
- }
- //
- // Fill in the Motd control
- //
- Set_Dlg_Item_Text (IDC_MESSAGE_OF_THE_DAY_EDIT, The_Game ()->Get_Motd ());
- ChildDialogClass::On_Init_Dialog ();
- //
- // Don't allow the user to select a MOD package if the game is laddered
- //
- MPLanHostOptionsMenuClass *parent_dlg = static_cast<MPLanHostOptionsMenuClass *> (Get_Parent_Dialog ());
- if (parent_dlg != NULL) {
- parent_dlg->Enable_Mod_Selection (mLaddered == false);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Apply
- //
- ////////////////////////////////////////////////////////////////
- bool
- MPLanHostAdvancedOptionsTabClass::On_Apply (void)
- {
- //
- // Pass our settings onto the game
- //
- WWASSERT(PTheGameData != NULL);
- The_Game()->IsDedicated.Set (Is_Dlg_Button_Checked (IDC_DEDICATED_SERVER_CHECK));
- The_Game()->IsAutoRestart.Set (Is_Dlg_Button_Checked (IDC_SERVER_RESTART_CHECK));
- The_Game()->IsTeamChangingAllowed.Set (Is_Dlg_Button_Checked (IDC_TEAM_CHANGE_CHECK));
- The_Game()->Set_QuickMatch_Server(Is_Dlg_Button_Checked(IDC_ALLOW_QUICKMATCH));
- The_Game()->IsLaddered.Set (Is_Dlg_Button_Checked (IDC_LADDERED_CHECK));
- The_Game()->IsClanGame.Set (Is_Dlg_Button_Checked (IDC_CLAN_GAME_CHECK));
- //The_Game()->IsClientTrusted.Set (Is_Dlg_Button_Checked (IDC_TRUST_CLIENTS_CHECK));
- The_Game()->RemixTeams.Set (Is_Dlg_Button_Checked (IDC_REMIX_TEAMS_CHECK));
- //
- // TSS022402
- // If laddering is on, silently turn off FF. Exploit concerns.
- // N.B. This is a hack. Leverages off the fact that
- // MPLanHostCnCOptionsTabClass::On_Apply is called first.
- //
- if (The_Game()->IsLaddered.Is_True()) {
- The_Game()->IsFriendlyFirePermitted.Set(false);
- }
- //
- // Save the message of the day (MOTD)
- //
- WideStringClass motd = Get_Dlg_Item_Text (IDC_MESSAGE_OF_THE_DAY_EDIT);
- if (motd.Get_Length() > MAX_MOTD_LENGTH) {
- motd.Peek_Buffer()[MAX_MOTD_LENGTH - 1] = 0;
- }
- The_Game ()->Set_Motd (motd);
- return true;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Command
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostAdvancedOptionsTabClass::On_Command (int ctrl_id, int message_id, DWORD param)
- {
- bool restart_enabled = true;
- switch (ctrl_id) {
- case IDC_DEDICATED_SERVER_CHECK: {
- // Enable the restart button only if we have auto login
- if (Is_Dlg_Button_Checked(IDC_DEDICATED_SERVER_CHECK)) {
- restart_enabled = true;
- } else {
- restart_enabled = false;
- }
- #ifndef MULTIPLAYERDEMO
- if (restart_enabled) {
- Enable_Dlg_Item (IDC_SERVER_RESTART_CHECK, true);
- } else {
- Check_Dlg_Button(IDC_SERVER_RESTART_CHECK, false);
- Enable_Dlg_Item(IDC_SERVER_RESTART_CHECK, false);
- }
- #endif // MULTIPLAYERDEMO
- bool canClan = (IsHostAClanMember() && !mChangeTeams && !mRemixTeams);
- Enable_Dlg_Item(IDC_CLAN_GAME_CHECK, (mIsWOLGame && canClan));
- bool clanGame = (((param != 0) || canClan) ? mClanGame : false);
- Check_Dlg_Button(IDC_CLAN_GAME_CHECK, (mIsWOLGame && clanGame));
- }
- break;
- case IDC_SERVER_RESTART_CHECK: {
- if (Is_Dlg_Button_Checked(IDC_SERVER_RESTART_CHECK)) {
- if (GameModeManager::Find("WOL")->Is_Active() && strlen(MPSettingsMgrClass::Get_Auto_Login()) == 0) {
- DlgMsgBox::DoDialog (IDS_MENU_TEXT329, IDS_MENU_NEED_AUTO_LOGIN, DlgMsgBox::YesNo, this);
- Check_Dlg_Button(IDC_SERVER_RESTART_CHECK, false);
- }
- }
- }
- break;
- //
- // Bring up the slave server config dialog.
- //
- case IDC_MENU_MP_LAN_SLAVE_SERVER_BUTTON:
- if (WW3D::Is_Windowed()) {
- START_DIALOG(SlaveServerDialogClass);
- } else {
- DlgMsgBox::DoDialog(IDS_MENU_TEXT329, IDS_SLAVES_NEED_WINDOWED, DlgMsgBox::Okay);
- }
- break;
- case IDC_TEAM_CHANGE_CHECK:
- {
- mChangeTeams = (param != 0);
- // Change Team and Clans are mutually exclusive
- bool canClan = (!mChangeTeams && !Is_Dlg_Button_Checked(IDC_REMIX_TEAMS_CHECK) && !Is_Dlg_Button_Checked(IDC_ALLOW_QUICKMATCH));
- Enable_Dlg_Item(IDC_CLAN_GAME_CHECK, canClan);
- Check_Dlg_Button(IDC_CLAN_GAME_CHECK, canClan && mClanGame);
- // Change Team and laddered are mutually exclusive
- Enable_Dlg_Item(IDC_LADDERED_CHECK, !mChangeTeams);
- Check_Dlg_Button(IDC_LADDERED_CHECK, !mChangeTeams && mLaddered);
- }
- break;
- case IDC_REMIX_TEAMS_CHECK:
- {
- mRemixTeams = (param != 0);
- // Remix teams and clans are mutually exclusive
- bool canClan = (!mRemixTeams && !Is_Dlg_Button_Checked(IDC_TEAM_CHANGE_CHECK) && !Is_Dlg_Button_Checked(IDC_ALLOW_QUICKMATCH));
- Enable_Dlg_Item(IDC_CLAN_GAME_CHECK, canClan);
- Check_Dlg_Button(IDC_CLAN_GAME_CHECK, canClan && mClanGame);
- }
- break;
- // If clan is checked then quickmatch is not allowed.
- case IDC_CLAN_GAME_CHECK:
- mClanGame = (param != 0);
- ConfigureWOLControls();
- break;
- // If quickmatch is checked then laddered must be checked as well.
- case IDC_ALLOW_QUICKMATCH:
- mQuickmatch = (param != 0);
- ConfigureWOLControls();
- break;
- // If clan is checked then quickmatch is not allowed.
- case IDC_LADDERED_CHECK:
- {
- mLaddered = (param != 0);
- //
- // Don't allow the user to select a MOD package if the game is laddered
- //
- MPLanHostOptionsMenuClass *parent_dlg = static_cast<MPLanHostOptionsMenuClass *> (Get_Parent_Dialog ());
- if (parent_dlg != NULL) {
- parent_dlg->Enable_Mod_Selection (mLaddered == false);
- }
- // Laddered games and team changing is mutually exclusive
- bool canChangeTeam = (!mLaddered && !Is_Dlg_Button_Checked(IDC_CLAN_GAME_CHECK));
- Enable_Dlg_Item(IDC_TEAM_CHANGE_CHECK, canChangeTeam);
- Check_Dlg_Button(IDC_TEAM_CHANGE_CHECK, canChangeTeam && mChangeTeams);
- }
- break;
- }
- }
- void MPLanHostAdvancedOptionsTabClass::HandleNotification (DlgMsgBoxEvent &event)
- {
- //
- // We only use a message box for the auto login confirm.
- //
- if (event.Event() == DlgMsgBoxEvent::Yes) {
- //Enable_Dlg_Item (IDC_SERVER_RESTART_CHECK, true);
- Check_Dlg_Button(IDC_SERVER_RESTART_CHECK, true);
- const char* login = MPSettingsMgrClass::Get_Last_Login();
- MPSettingsMgrClass::Set_Auto_Login(login);
- }
- }
- void MPLanHostAdvancedOptionsTabClass::ReceiveSignal(bool& hasPassword)
- {
- if (mPassword != hasPassword) {
- mPassword = hasPassword;
- ConfigureWOLControls();
- }
- }
- void MPLanHostAdvancedOptionsTabClass::ConfigureWOLControls(void)
- {
- bool isDedicated = Is_Dlg_Button_Checked(IDC_DEDICATED_SERVER_CHECK);
- bool isQuickmatch = Is_Dlg_Button_Checked(IDC_ALLOW_QUICKMATCH);
- bool isTeamChange = Is_Dlg_Button_Checked(IDC_TEAM_CHANGE_CHECK);
- bool isTeamRemix = Is_Dlg_Button_Checked(IDC_REMIX_TEAMS_CHECK);
- bool isClanMember = IsHostAClanMember();
- //---------------------------------------------------------------------------
- // Clan games allowed if:
- // - WOL is active.
- // - Quickmatch is OFF
- // - Change team is OFF
- // - Remix team is OFF
- // - Host is member of a clan OR game is dedicated.
- //
- // Requirements if ON:
- // - Team Change must be OFF
- // - Team Remix must be OFF
- //---------------------------------------------------------------------------
- bool canClan = (mIsWOLGame && !isQuickmatch && !isTeamChange && !isTeamRemix && (isClanMember || isDedicated));
- Enable_Dlg_Item(IDC_CLAN_GAME_CHECK, canClan);
- bool clanned = (canClan && mClanGame);
- Check_Dlg_Button(IDC_CLAN_GAME_CHECK, clanned);
- //---------------------------------------------------------------------------
- // Quickmatch allowed if:
- // - WOL is active
- // - No password
- // - Clan is OFF
- //
- // Requirements if ON:
- // - Ladderd must be ON
- // - Clan must be OFF
- //---------------------------------------------------------------------------
- bool canQuickmatch = (mIsWOLGame && !mPassword && !clanned);
- Enable_Dlg_Item(IDC_ALLOW_QUICKMATCH, canQuickmatch);
- isQuickmatch = (canQuickmatch && mQuickmatch);
- Check_Dlg_Button(IDC_ALLOW_QUICKMATCH, isQuickmatch);
- //---------------------------------------------------------------------------
- // Ladder option available if WOL active and quickmatch is OFF
- //---------------------------------------------------------------------------
- bool canLadder = (mIsWOLGame && !isQuickmatch && !isTeamChange);
- Enable_Dlg_Item(IDC_LADDERED_CHECK, canLadder);
- bool laddered = ((canLadder && mLaddered) || isQuickmatch);
- Check_Dlg_Button(IDC_LADDERED_CHECK, laddered);
- //---------------------------------------------------------------------------
- // Team change not allowed with clan or laddered games.
- //---------------------------------------------------------------------------
- bool canChangeTeams = (!clanned && !laddered && The_Game()->Is_Editable_Teaming());
- Enable_Dlg_Item(IDC_TEAM_CHANGE_CHECK, canChangeTeams);
- bool changeTeams = (canChangeTeams && mChangeTeams);
- Check_Dlg_Button(IDC_TEAM_CHANGE_CHECK, changeTeams);
- //---------------------------------------------------------------------------
- // Remix teams not allowed with clan games
- //---------------------------------------------------------------------------
- bool remixTeams = (!clanned && mRemixTeams);
- Enable_Dlg_Item(IDC_REMIX_TEAMS_CHECK, !clanned);
- Check_Dlg_Button(IDC_REMIX_TEAMS_CHECK, remixTeams);
- //---------------------------------------------------------------------------
- // Double check availability of controls
- //---------------------------------------------------------------------------
- // Ladder is available only if change teams if off
- Enable_Dlg_Item(IDC_LADDERED_CHECK, !changeTeams && canLadder);
- Check_Dlg_Button(IDC_LADDERED_CHECK, !changeTeams && laddered);
- // Clan is available only if change team and remix team is off.
- canClan = (!changeTeams && !remixTeams && canClan);
- Enable_Dlg_Item(IDC_CLAN_GAME_CHECK, canClan);
- Check_Dlg_Button(IDC_CLAN_GAME_CHECK, canClan && clanned);
- }
- bool MPLanHostAdvancedOptionsTabClass::IsHostAClanMember(void) const
- {
- GameModeClass* gameMode = GameModeManager::Find("WOL");
- if (gameMode && gameMode->Is_Active()) {
- WolGameModeClass* wolGame = static_cast<WolGameModeClass*>(gameMode);
- WWASSERT(wolGame != NULL);
- RefPtr<WWOnline::UserData> host = wolGame->Get_WOL_User_Data(The_Game()->Get_Owner());
- if (host.IsValid()) {
- return (host->GetSquadID() != 0);
- }
- }
- return false;
- }
- ////////////////////////////////////////////////////////////////
- //
- // MPLanHostMapCycleOptionsTabClass
- //
- ////////////////////////////////////////////////////////////////
- MPLanHostMapCycleOptionsTabClass::MPLanHostMapCycleOptionsTabClass (void) :
- ChildDialogClass (IDD_MP_LAN_HOST_OPTIONS_MAP_TAB)
- {
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // List_Contains
- //
- ////////////////////////////////////////////////////////////////
- bool
- List_Contains(DynamicVectorClass<WideStringClass> & list, WideStringClass & item)
- {
- for (int index = 0; index < list.Count (); index ++) {
- if (list[index] == item) {
- return true;
- }
- }
- return false;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Init_Dialog
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::On_Init_Dialog (void)
- {
- Build_Mod_Package_List ();
- //
- // Create the available maps list
- //
- ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_AVAILABLE_MAP_LIST_CTRL);
- if (list_ctrl != NULL) {
- list_ctrl->Add_Column (L"", 1.0F, Vector3 (1, 1, 1));
- }
- //
- // Create the map cycle list
- //
- list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_MAP_CYCLE_LIST_CTRL);
- if (list_ctrl != NULL) {
- list_ctrl->Add_Column (L"", 1.0F, Vector3 (1, 1, 1));
- }
- //
- // Build the map lists
- //
- Populate_Map_List_Ctrl ();
- //
- // Fill in the map time limit
- //
- WWASSERT(PTheGameData != NULL);
- ((EditCtrlClass *)Get_Dlg_Item (IDC_MAP_TIME_LIMIT_EDIT))->Set_Text_Limit (3);
- Set_Dlg_Item_Int (IDC_MAP_TIME_LIMIT_EDIT, The_Game ()->Get_Time_Limit_Minutes ());
- Check_Dlg_Button (IDC_LOOP_MAPS_CHECK, The_Game ()->Do_Maps_Loop ());
- ChildDialogClass::On_Init_Dialog ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Apply
- //
- ////////////////////////////////////////////////////////////////
- bool
- MPLanHostMapCycleOptionsTabClass::On_Apply (void)
- {
- ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_MAP_CYCLE_LIST_CTRL);
- if (list_ctrl != NULL) {
- StringClass ascii_string;
- //
- // Convert the map name from wide-format to ascii-format
- //
- if (list_ctrl->Get_Entry_Count () > 0) {
- WideStringClass map_name (list_ctrl->Get_Entry_Text (0, 0));
- map_name.Convert_To (ascii_string);
- }
- //
- // Set the map name
- //
- WWASSERT(The_Game() != NULL);
- The_Game ()->Set_Map_Name (ascii_string);
- //
- // Configure the radar mode combobox
- //
- ComboBoxCtrlClass *combobox_ctrl = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_MOD_PACKAGE_COMBO);
- if (combobox_ctrl != NULL) {
- //
- // Lookup the currently selected mod package
- //
- int curr_sel = combobox_ctrl->Get_Curr_Sel ();
- if (curr_sel != -1) {
- const ModPackageClass *package = (const ModPackageClass *)combobox_ctrl->Get_Item_Data (curr_sel);
- if (package != NULL) {
- The_Game ()->Set_Mod_Name (package->Get_Package_Filename ());
- } else {
- The_Game ()->Set_Mod_Name ("");
- }
- } else {
- The_Game ()->Set_Mod_Name ("");
- }
- }
- //
- // Save the map cycle information
- //
- The_Game()->Clear_Map_Cycle();
- for (int i = 0; i < list_ctrl->Get_Entry_Count(); i++) {
- if (i < cGameData::MAX_MAPS) {
- WideStringClass map_name (list_ctrl->Get_Entry_Text (i, 0));
- map_name.Convert_To (ascii_string);
- The_Game()->Set_Map_Cycle(i, ascii_string);
- }
- }
- }
- //
- // Save the map time limit
- //
- WWASSERT(PTheGameData != NULL);
- The_Game ()->Set_Time_Limit_Minutes (Get_Dlg_Item_Int (IDC_MAP_TIME_LIMIT_EDIT));
- The_Game ()->Set_Do_Maps_Loop (Is_Dlg_Button_Checked (IDC_LOOP_MAPS_CHECK));
- return true;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Enable_Mod_Selection
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::Enable_Mod_Selection (bool onoff)
- {
- ComboBoxCtrlClass *combobox_ctrl = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_MOD_PACKAGE_COMBO);
- if (combobox_ctrl == NULL) {
- return ;
- }
- //
- // Either enable or disable the mod selector as necessary
- //
- if (onoff) {
- Enable_Dlg_Item (IDC_MOD_PACKAGE_COMBO, true);
- } else {
- Enable_Dlg_Item (IDC_MOD_PACKAGE_COMBO, false);
-
- //
- // Ensure no mod package is selected and rebuild the map list if necessary
- //
- if (combobox_ctrl->Get_Curr_Sel () != 0) {
- combobox_ctrl->Set_Curr_Sel (0);
- Populate_Map_List_Ctrl ();
- }
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Build_Mod_Package_List
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::Build_Mod_Package_List (void)
- {
- //
- // Configure the radar mode combobox
- //
- ComboBoxCtrlClass *combobx_ctrl = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_MOD_PACKAGE_COMBO);
- if (combobx_ctrl == NULL) {
- return ;
- }
- ModPackageMgrClass::Reset_List ();
- ModPackageMgrClass::Build_List ();
- //
- // Get the name of the default mod package
- //
- StringClass ansi_default_pkg = ModPackageMgrClass::Get_Current_Package ().Get_Name ();
- WideStringClass default_pkg;
- default_pkg.Convert_From (ansi_default_pkg);
- //
- // Add a default entry to the list
- //
- combobx_ctrl->Add_String (L"<None>");
- //
- // Loop over and add all the mod packages to the combobox
- //
- bool found = false;
- int count = ModPackageMgrClass::Get_Package_Count ();
- for (int index = 0; index < count; index ++) {
- const ModPackageClass *package = ModPackageMgrClass::Get_Package (index);
- if (package != NULL) {
- //
- // Add an entry for this mod package to the combobox
- //
- WideStringClass curr_name;
- curr_name.Convert_From (package->Get_Name ());
- int item_index = combobx_ctrl->Add_String (curr_name);
- if (item_index != -1) {
- combobx_ctrl->Set_Item_Data (item_index, (uint32)package);
- //
- // Is this the default entry? If so select it...
- //
- if (default_pkg.Compare_No_Case (curr_name) == 0) {
- found = true;
- combobx_ctrl->Set_Curr_Sel (item_index);
- }
- }
- }
- }
- //
- // Select the first entry by default
- //
- if (found == false) {
- combobx_ctrl->Set_Curr_Sel (0);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Add_Map
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::Add_Map (void)
- {
- ListCtrlClass *avail_list = (ListCtrlClass *)Get_Dlg_Item (IDC_AVAILABLE_MAP_LIST_CTRL);
- ListCtrlClass *cycle_list = (ListCtrlClass *)Get_Dlg_Item (IDC_MAP_CYCLE_LIST_CTRL);
- //
- // Get the current selection, and add it to the cycle list
- //
- int curr_sel = avail_list->Get_Curr_Sel ();
- if (curr_sel >= 0) {
- cycle_list->Insert_Entry (0xFF, avail_list->Get_Entry_Text (curr_sel, 0));
- avail_list->Delete_Entry (curr_sel);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Remove_Map
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::Remove_Map (void)
- {
- ListCtrlClass *avail_list = (ListCtrlClass *)Get_Dlg_Item (IDC_AVAILABLE_MAP_LIST_CTRL);
- ListCtrlClass *cycle_list = (ListCtrlClass *)Get_Dlg_Item (IDC_MAP_CYCLE_LIST_CTRL);
- //
- // Get the current selection
- //
- int curr_sel = cycle_list->Get_Curr_Sel ();
- if (curr_sel >= 0) {
- //
- // Remove this entry from the list
- //
- avail_list->Insert_Entry (0xFF, cycle_list->Get_Entry_Text (curr_sel, 0));
- cycle_list->Delete_Entry (curr_sel);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Command
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::On_Command (int ctrl_id, int message_id, DWORD param)
- {
- switch (ctrl_id)
- {
- case IDC_ADD_MAP_BUTTON:
- Add_Map ();
- break;
- case IDC_REMOVE_MAP_BUTTON:
- Remove_Map ();
- break;
- }
- ChildDialogClass::On_Command (ctrl_id, message_id, param);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_ListCtrl_DblClk
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::On_ListCtrl_DblClk
- (
- ListCtrlClass *list_ctrl,
- int ctrl_id,
- int item_index
- )
- {
- switch (ctrl_id)
- {
- case IDC_AVAILABLE_MAP_LIST_CTRL:
- Add_Map ();
- break;
- case IDC_MAP_CYCLE_LIST_CTRL:
- Remove_Map ();
- break;
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_ComboBoxCtrl_Sel_Change
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::On_ComboBoxCtrl_Sel_Change
- (
- ComboBoxCtrlClass * combo_ctrl,
- int ctrl_id,
- int old_sel,
- int new_sel
- )
- {
- Populate_Map_List_Ctrl ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Populate_Map_List_Ctrl
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::Populate_Map_List_Ctrl (void)
- {
- ComboBoxCtrlClass *combobox_ctrl = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_MOD_PACKAGE_COMBO);
- if (combobox_ctrl == NULL) {
- return ;
- }
- //
- // Lookup the currently selected mod package
- //
- int curr_sel = combobox_ctrl->Get_Curr_Sel ();
- if (curr_sel != -1) {
- const ModPackageClass *package = (const ModPackageClass *)combobox_ctrl->Get_Item_Data (curr_sel);
- //
- // Build a list of levels from the current mod package (or without a mod package)
- //
- Build_Map_List (package);
- //
- // Fill the list controls with map names
- //
- Fill_Map_Ctrls ();
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Fill_Map_Ctrls
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::Fill_Map_Ctrls (void)
- {
- //
- // Build map cycle list from ini file.
- // If map exists, add it to MapCycleList and remove it from MapList
- //
- MapCycleList.Delete_All();
- for (int i = 0; i < cGameData::MAX_MAPS; i++)
- {
- //
- // Get the map name as a wide character string
- //
- WWASSERT(PTheGameData != NULL);
- StringClass ascii_map_name = The_Game ()->Get_Map_Cycle (i);
- WideStringClass map_name;
- map_name.Convert_From (ascii_map_name);
- if (map_name.Get_Length () > 0 && List_Contains(MapList, map_name)) {
- MapList.Delete (map_name);
- MapCycleList.Add (map_name);
- }
- }
- //
- // Add the first map by default
- //
- if (MapCycleList.Count () == 0 && MapList.Count () > 0) {
- MapCycleList.Add (MapList[0]);
- MapList.Delete (0);
- }
- //
- // Create the available maps list
- //
- ListCtrlClass *list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_AVAILABLE_MAP_LIST_CTRL);
- if (list_ctrl != NULL) {
- //
- // Start fresh
- //
- list_ctrl->Delete_All_Entries ();
- //
- // Add the map list into the list ctrl
- //
- for (int index = 0; index < MapList.Count (); index ++) {
- list_ctrl->Insert_Entry (index, MapList[index]);
- }
- //
- // Select the first entry by default
- //
- list_ctrl->Set_Curr_Sel (0);
- }
- //
- // Create the map cycle list
- //
- list_ctrl = (ListCtrlClass *)Get_Dlg_Item (IDC_MAP_CYCLE_LIST_CTRL);
- if (list_ctrl != NULL) {
- //
- // Start fresh
- //
- list_ctrl->Delete_All_Entries ();
- //
- // Add the map cycle list into the list ctrl
- //
- for (int index = 0; index < MapCycleList.Count (); index ++) {
- list_ctrl->Insert_Entry (index, MapCycleList[index]);
- }
- //
- // Select the first entry by default
- //
- list_ctrl->Set_Curr_Sel (0);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Build_Map_List
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::Build_Map_List (const ModPackageClass *package)
- {
- if (package == NULL) {
- Build_Map_List ();
- } else {
- //
- // Generate a list of levels from the mod package
- //
- DynamicVectorClass<StringClass> map_list;
- package->Build_Level_List (map_list);
- //
- // Copy the map list
- //
- MapList.Delete_All ();
- for (int index = 0; index < map_list.Count (); index ++) {
- WideStringClass wide_map_name;
- wide_map_name.Convert_From (map_list[index]);
- MapList.Add (wide_map_name);
- }
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Build_Map_List
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostMapCycleOptionsTabClass::Build_Map_List (void)
- {
- MapList.Delete_All ();
- WIN32_FIND_DATA find_info = { 0 };
- BOOL keep_going = TRUE;
- HANDLE file_find = NULL;
- //
- // Build a list of all the maps we know about
- //
- StringClass file_filter;
- WWASSERT(The_Game() != NULL);
- if (The_Game()->Is_Cnc()) {
- file_filter.Format("data\\c&c_*.mix");
- } else {
- file_filter.Format("data\\mp_*.mix");
- }
- #ifdef WWDEBUG
- if (cDevOptions::FilterLevelFiles.Is_False()) {
- file_filter = "data\\*.mix";
- }
- #endif // WWDEBUG
- for (file_find = ::FindFirstFile (file_filter, &find_info);
- (file_find != INVALID_HANDLE_VALUE) && keep_going;
- keep_going = ::FindNextFile (file_find, &find_info))
- {
- //
- // Convert the string to a wide character format
- //
- WideStringClass map_name;
- map_name.Convert_From (find_info.cFileName);
- //
- // Add this name to our list
- //
- MapList.Add (map_name);
- }
- if (file_find != INVALID_HANDLE_VALUE) {
- ::FindClose (file_find);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // MPLanHostVictoryOptionsTabClass
- //
- ////////////////////////////////////////////////////////////////
- MPLanHostVictoryOptionsTabClass::MPLanHostVictoryOptionsTabClass (void) :
- ChildDialogClass (IDD_MP_LAN_HOST_OPTIONS_VICTORY_TAB)
- {
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Init_Dialog
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostVictoryOptionsTabClass::On_Init_Dialog (void)
- {
- //
- // Configure the score and life/kill limit controls
- //
- Update_Enable_State ();
- //
- // Set the check state of the CnC mode controls
- //
- WWASSERT(PTheGameData != NULL);
- cGameDataCnc *cnc_mode = The_Game ()->As_Cnc ();
- if (cnc_mode != NULL) {
- Check_Dlg_Button (IDC_DESTROY_ALL_BUILDINGS_CHECK, cnc_mode->BaseDestructionEndsGame.Get());
- Check_Dlg_Button (IDC_BEACON_CHECK, cnc_mode->BeaconPlacementEndsGame.Get());
- Update_Enable_State();
- } else {
- Check_Dlg_Button (IDC_DESTROY_ALL_BUILDINGS_CHECK, false);
- Check_Dlg_Button (IDC_BEACON_CHECK, false);
- Enable_Dlg_Item (IDC_DESTROY_ALL_BUILDINGS_CHECK, false);
- Enable_Dlg_Item (IDC_BEACON_CHECK, false);
- }
- ChildDialogClass::On_Init_Dialog ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Apply
- //
- ////////////////////////////////////////////////////////////////
- bool
- MPLanHostVictoryOptionsTabClass::On_Apply (void)
- {
- //
- // Pass our settings onto the game
- //
- //
- // Save any CnC mode specific data
- //
- WWASSERT(PTheGameData != NULL);
- cGameDataCnc *cnc_mode = The_Game ()->As_Cnc ();
- if (cnc_mode != NULL) {
- //Check_Dlg_Button (IDC_DESTROY_ALL_BUILDINGS_CHECK, true);
- //Check_Dlg_Button (IDC_BEACON_CHECK, true);
- cnc_mode->BaseDestructionEndsGame.Set(Is_Dlg_Button_Checked(IDC_DESTROY_ALL_BUILDINGS_CHECK));
- cnc_mode->BeaconPlacementEndsGame.Set(Is_Dlg_Button_Checked(IDC_BEACON_CHECK));
- }
- return true;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Update_Enable_State
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostVictoryOptionsTabClass::Update_Enable_State (void)
- {
- /*
- bool enable = Is_Dlg_Button_Checked (IDC_SCORE_LIMIT_CHECK);
- Enable_Dlg_Item (IDC_SCORE_LIMIT_EDIT, enable);
- enable = Is_Dlg_Button_Checked (IDC_KILL_LIMIT_CHECK);
- Enable_Dlg_Item (IDC_KILL_LIMIT_EDIT, enable);
- */
- //
- // Beacon option dependent on base destruction option
- //
- bool enable = Is_Dlg_Button_Checked (IDC_DESTROY_ALL_BUILDINGS_CHECK);
- Enable_Dlg_Item (IDC_BEACON_CHECK, enable);
- //
- // Make sure to uncheck the beacon check if its disabled...
- //
- if (enable == false) {
- Check_Dlg_Button (IDC_BEACON_CHECK, false);
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Command
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostVictoryOptionsTabClass::On_Command (int ctrl_id, int message_id, DWORD param)
- {
- /*
- switch (ctrl_id)
- {
- case IDC_SCORE_LIMIT_CHECK:
- case IDC_KILL_LIMIT_CHECK:
- Update_Enable_State ();
- break;
- }
- */
- switch (ctrl_id)
- {
- case IDC_DESTROY_ALL_BUILDINGS_CHECK:
- Update_Enable_State ();
- break;
- }
- ChildDialogClass::On_Command (ctrl_id, message_id, param);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Init_Dialog
- //
- ////////////////////////////////////////////////////////////////
- void
- MPLanHostCnCOptionsTabClass::On_Init_Dialog (void)
- {
- WWASSERT(PTheGameData != NULL);
- cGameDataCnc *game_data = The_Game ()->As_Cnc ();
- WWASSERT (game_data != NULL);
- //
- // Configure the edit control
- //
- EditCtrlClass * edit = (EditCtrlClass *)Get_Dlg_Item(IDC_STARTING_CREDITS_EDIT);
- if (edit != NULL)
- {
- edit->Set_Text_Limit(5);
- }
- Set_Dlg_Item_Int (IDC_STARTING_CREDITS_EDIT, game_data->Get_Starting_Credits ());
- //
- // Configure the checkboxes
- //
- Check_Dlg_Button (IDC_CAN_REPAIR_BUILDINGS_CHECK, The_Game ()->CanRepairBuildings.Is_True ());
- Check_Dlg_Button (IDC_DRIVER_IS_ALWAYS_GUNNER_CHECK, The_Game ()->DriverIsAlwaysGunner.Is_True ());
- Check_Dlg_Button (IDC_SPAWN_WEAPONS_CHECK, The_Game ()->SpawnWeapons.Is_True ());
- Check_Dlg_Button (IDC_ALLIED_FIRE_CHECK, The_Game ()->IsFriendlyFirePermitted.Is_True ());
- Enable_Dlg_Item (IDC_ALLIED_FIRE_CHECK, The_Game ()->Is_Editable_Friendly_Fire ());
- //
- // Configure the radar mode combobox
- //
- ComboBoxCtrlClass *radar_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_RADAR_MODE_COMBO);
- if (radar_combobox != NULL) {
- //
- // Fill the radar_combobox
- //
- radar_combobox->Add_String (TRANSLATION(IDS_MP_RADAR_MODE_NOBODY));
- radar_combobox->Add_String (TRANSLATION(IDS_MP_RADAR_MODE_TEAMMATES));
- radar_combobox->Add_String (TRANSLATION(IDS_MP_RADAR_MODE_ALL));
- //
- // Select the default entry in the radar_combobox
- //
- radar_combobox->Set_Curr_Sel (The_Game ()->Get_Radar_Mode ());
- }
- ChildDialogClass::On_Init_Dialog ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Apply
- //
- ////////////////////////////////////////////////////////////////
- bool
- MPLanHostCnCOptionsTabClass::On_Apply (void)
- {
- WWASSERT(PTheGameData != NULL);
- cGameDataCnc *game_data = The_Game ()->As_Cnc ();
- WWASSERT (game_data != NULL);
- //
- // Read the edit control
- //
- game_data->Set_Starting_Credits (Get_Dlg_Item_Int (IDC_STARTING_CREDITS_EDIT));
- //
- // Read the checkboxes
- //
- The_Game ()->CanRepairBuildings.Set (Is_Dlg_Button_Checked (IDC_CAN_REPAIR_BUILDINGS_CHECK));
- The_Game ()->DriverIsAlwaysGunner.Set (Is_Dlg_Button_Checked (IDC_DRIVER_IS_ALWAYS_GUNNER_CHECK));
- The_Game ()->SpawnWeapons.Set (Is_Dlg_Button_Checked (IDC_SPAWN_WEAPONS_CHECK));
- The_Game ()->IsFriendlyFirePermitted.Set (Is_Dlg_Button_Checked (IDC_ALLIED_FIRE_CHECK));
- //
- // Read the radar mode combobox
- //
- ComboBoxCtrlClass *radar_combobox = (ComboBoxCtrlClass *)Get_Dlg_Item (IDC_RADAR_MODE_COMBO);
- if (radar_combobox != NULL) {
- The_Game ()->Set_Radar_Mode ((RadarModeEnum)radar_combobox->Get_Curr_Sel ());
- }
- return true;
- }
|