| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- /*
- ** 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/dlgmpwolmain.cpp $*
- * *
- * Author:: Patrick Smith *
- * *
- * $Modtime:: 1/11/02 8:57p $*
- * *
- * $Revision:: 46 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #include "dlgmpwolmain.h"
- #include "shortcutbarctrl.h"
- #include "renegadedialogmgr.h"
- #include "translatedb.h"
- #include "string_ids.h"
- #include "dialogmgr.h"
- #include "dlgmessagebox.h"
- #include "dlgdownload.h"
- #include "dlgquickmatch.h"
- #include "dlgmpwolgamelist.h"
- #include "mpsettingsmgr.h"
- #include "dlgsidebarhelp.h"
- #include "WOLLoginProfile.h"
- #include "bandwidthcheck.h"
- #include "autostart.h"
- ////////////////////////////////////////////////////////////////
- // Static member initialization
- ////////////////////////////////////////////////////////////////
- MPWolMainMenuClass * MPWolMainMenuClass::_TheInstance = NULL;
- ////////////////////////////////////////////////////////////////
- //
- // MPWolMainMenuClass
- //
- ////////////////////////////////////////////////////////////////
- MPWolMainMenuClass::MPWolMainMenuClass (void) :
- IsSidebarHelpPending (true),
- mPendingCmd(-1),
- MenuDialogClass (IDD_MP_WOL_MAIN)
- {
- _TheInstance = this;
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // ~MPWolMainMenuClass
- //
- ////////////////////////////////////////////////////////////////
- MPWolMainMenuClass::~MPWolMainMenuClass (void)
- {
- _TheInstance = NULL;
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Init_Dialog
- //
- ////////////////////////////////////////////////////////////////
- void
- MPWolMainMenuClass::On_Init_Dialog (void)
- {
- //
- // Configure the shortcut bar
- //
- ShortcutBarCtrlClass *bar = (ShortcutBarCtrlClass *)Get_Dlg_Item (IDC_SHORTCUT_BAR);
- if (bar != NULL) {
- bar->Add_Button(IDC_MP_SHORTCUT_BUDDIES, TRANSLATE(IDS_MP_SHORTCUT_BUDDIES));
- bar->Add_Button(IDC_MP_SHORTCUT_INTERNET_OPTIONS, TRANSLATE(IDS_INTERNET_OPTIONS));
- #ifdef QUICKMATCH_OPTIONS
- bar->Add_Button(IDC_MP_SHORTCUT_QUICKMATCH_OPTIONS, TRANSLATE(IDS_MENU_TEXT364));
- #endif
- bar->Add_Button(IDC_MP_SHORTCUT_NEWS, TRANSLATE(IDS_MP_SHORTCUT_NEWS));
- bar->Add_Button(IDC_MP_SHORTCUT_CLANS, TRANSLATE(IDS_MP_SHORTCUT_CLANS));
- bar->Add_Button(IDC_MP_SHORTCUT_RANKINGS, TRANSLATE(IDS_MP_SHORTCUT_RANKINGS));
- bar->Add_Button(IDC_MP_SHORTCUT_ACCOUNT, TRANSLATE(IDS_MP_SHORTCUT_ACCOUNT));
- bar->Add_Button(IDC_MP_SHORTCUT_NET_STATUS, TRANSLATE(IDS_MP_SHORTCUT_NET_STATUS));
- //
- // Force the bar to be displayed
- //
- if (MPSettingsMgrClass::Is_Sidebar_Help_Displayed ()) {
- bar->Display (true);
- }
- }
- MenuDialogClass::On_Init_Dialog ();
- bool wolValid = CheckWOLVersion();
- if (!wolValid) {
- DlgMsgBox::DoDialog(IDS_WOL_ERROR, IDS_WOL_WRONGVERSION);
- End_Dialog();
- }
- }
- // Check the version of the Westwood online component
- bool MPWolMainMenuClass::CheckWOLVersion(void)
- {
- RefPtr<WWOnline::Session> wolSession = WWOnline::Session::GetInstance(false);
- if (!wolSession.IsValid()) {
- return false;
- }
- // WOLAPI version 1.19.3 or better required.
- const LONG minVersion = MAKELONG(19,1);
- const LONG minBuild = MAKELONG(0,3);
- unsigned long wolVersion = 0;
- unsigned long wolBuild = 0;
- wolSession->GetChatObject()->GetVersion(&wolVersion);
- WideStringClass wolText(255, true);
- if (BandwidthCheckerClass::Get_Reported_Upstream_Bandwidth()) {
- WideStringClass conn(BandwidthCheckerClass::Get_Bandwidth_As_String(), true);
- wolText.Format(TRANSLATE(IDS_MENU_CONNECTION_SPEED_FORMAT), conn);
- }
- WideStringClass string(0, true);
- string.Format(L"WOLAPI V%u.%u", HIWORD(wolVersion), LOWORD(wolVersion));
- wolText += string;
- char buildString[32] = {0};
- LPCSTR value = (LPCSTR)(&buildString[0]);
- HRESULT hr = wolSession->GetChatObject()->GetAttributeValue("BuildNumber", &value);
- if (SUCCEEDED(hr)) {
- wolBuild = atol(buildString);
- string.Format(L".%u", HIWORD(wolBuild));
- wolText += string;
- }
- Set_Dlg_Item_Text(IDC_WOLAPI_VER, wolText);
- // Are we below the minimum version
- if (wolVersion < minVersion) {
- return false;
- }
- // If the version is the same then are we below the minimum build
- if ((wolVersion == minVersion) && (wolBuild < minBuild)) {
- return false;
- }
- return true;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Frame_Update
- //
- ////////////////////////////////////////////////////////////////
- void
- MPWolMainMenuClass::On_Frame_Update (void)
- {
- if (IsSidebarHelpPending) {
- IsSidebarHelpPending = false;
- //
- // Show the sidebar help (if necessary)
- //
- if (MPSettingsMgrClass::Is_Sidebar_Help_Displayed ()) {
- START_DIALOG (SidebarHelpDialogClass);
- }
- }
- MenuDialogClass::On_Frame_Update ();
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Command
- //
- ////////////////////////////////////////////////////////////////
- void
- MPWolMainMenuClass::On_Command (int ctrl_id, int message_id, DWORD param)
- {
- switch (ctrl_id)
- {
- case IDC_MP_WOL_QUICK_MATCH_BUTTON:
- case IDC_MP_WOL_ADVANCED_LISTINGS_BUTTON: // intentional fall through
- case IDC_MP_SHORTCUT_CHAT: // intentional fall through
- case IDC_MP_SHORTCUT_BUDDIES: // intentional fall through
- mPendingCmd = ctrl_id;
- WOLLogonMgr::Logon(this);
- return;
- break;
- }
- MenuDialogClass::On_Command (ctrl_id, message_id, param);
- return ;
- }
- void MPWolMainMenuClass::HandleNotification(WOLLogonAction& action)
- {
- if (WOLLOGON_SUCCESS == action) {
- switch (mPendingCmd) {
- case IDC_MP_WOL_ADVANCED_LISTINGS_BUTTON:
- MPWolGameListMenuClass::DoDialog();
- break;
- case IDC_MP_WOL_QUICK_MATCH_BUTTON:
- DlgQuickMatch::DoDialog();
- break;
- case -1:
- break;
- default:
- MenuDialogClass::On_Command(mPendingCmd, 0, 0);
- break;
- }
- } else if (WOLLOGON_PATCHREQUIRED == action) {
- // If a patch is required, ask the user if they want to download it now.
- DlgMsgBox::DoDialog(TRANSLATE(IDS_WOL_PATCHREQUIRED),
- TRANSLATE(IDS_WOL_DOWNLOADPROMPT), DlgMsgBox::YesNo, this);
- }
- mPendingCmd = -1;
- }
- void MPWolMainMenuClass::HandleNotification(DlgMsgBoxEvent& event)
- {
- if (DlgMsgBoxEvent::Yes == event.Event()) {
- RefPtr<WWOnline::Session> wolSession = WWOnline::Session::GetInstance(false);
- WWOnline::DownloadList& patchList = wolSession->GetPatchDownloadList();
- bool quiet = AutoRestart.Is_Active();
- DlgDownload::DoDialog(TRANSLATE(IDS_WOL_DOWNLOAD), patchList, quiet);
- }
- }
- ////////////////////////////////////////////////////////////////
- //
- // Display
- //
- ////////////////////////////////////////////////////////////////
- void
- MPWolMainMenuClass::Display (void)
- {
- //
- // Create the dialog if necessary, otherwise simply bring it to the front
- //
- if (_TheInstance == NULL) {
- START_DIALOG (MPWolMainMenuClass);
- } else {
- if (_TheInstance->Is_Active_Menu () == false) {
- DialogMgrClass::Rollback (_TheInstance);
- }
- }
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Activate
- //
- ////////////////////////////////////////////////////////////////
- void
- MPWolMainMenuClass::On_Activate(bool onoff)
- {
- MenuDialogClass::On_Activate(onoff);
- if (onoff) {
- Update_Login_Profile();
- WOLLogonMgr::Logoff();
- }
- }
- ////////////////////////////////////////////////////////////////
- //
- // On_Last_Menu_Ending
- //
- ////////////////////////////////////////////////////////////////
- void
- MPWolMainMenuClass::On_Last_Menu_Ending (void)
- {
- RenegadeDialogMgrClass::Goto_Location (RenegadeDialogMgrClass::LOC_MAIN_MENU);
- return ;
- }
- ////////////////////////////////////////////////////////////////
- //
- // Update_Login_Profile
- //
- ////////////////////////////////////////////////////////////////
- void
- MPWolMainMenuClass::Update_Login_Profile(void)
- {
- WideStringClass lastlogin(64, true);
- lastlogin = MPSettingsMgrClass::Get_Last_Login();
- LoginProfile* profile = LoginProfile::Get(lastlogin);
- ShowProfileRanking(this, profile);
-
- if (profile) {
- profile->Release_Ref();
- }
- }
|