diff --git a/Generals/Code/GameEngine/GameEngine.dsp b/Generals/Code/GameEngine/GameEngine.dsp index fa30157b068..c01e1827107 100644 --- a/Generals/Code/GameEngine/GameEngine.dsp +++ b/Generals/Code/GameEngine/GameEngine.dsp @@ -1904,58 +1904,6 @@ SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\SkirmishGameOptionsMenu.cpp SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\SkirmishMapSelectMenu.cpp # End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLBuddyOverlay.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLCustomScoreScreen.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLGameSetupMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLLadderScreen.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLLobbyMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLLocaleSelectPopup.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLLoginMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLMapSelectMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLMessageWindow.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLQMScoreScreen.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLQuickMatchMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLStatusMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLWelcomeMenu.cpp -# End Source File # End Group # Begin Source File @@ -4348,6 +4296,7 @@ SOURCE=.\Include\GameClient\WinInstanceData.h # End Group # Begin Group "GameNetwork.H" +# PROP Default_Filter "" # Begin Group "GameSpyLibs.H" # PROP Default_Filter "" diff --git a/Generals/Code/GameEngine/Include/GameClient/GUICallbacks.h b/Generals/Code/GameEngine/Include/GameClient/GUICallbacks.h index 07e3ded5e01..58d7598e347 100644 --- a/Generals/Code/GameEngine/Include/GameClient/GUICallbacks.h +++ b/Generals/Code/GameEngine/Include/GameClient/GUICallbacks.h @@ -164,105 +164,6 @@ extern void DifficultySelectInit( WindowLayout *layout, void *userData ); extern WindowMsgHandledType DifficultySelectSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); extern WindowMsgHandledType DifficultySelectInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -//================================================================================================= -// WOL UI // -//================================================================================================= -// WOL Ladder Screen --------------------------------------------------------------------------------- -extern void WOLLadderScreenInit( WindowLayout *layout, void *userData ); -extern void WOLLadderScreenUpdate( WindowLayout *layout, void *userData ); -extern void WOLLadderScreenShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLLadderScreenSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLLadderScreenInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Login Menu --------------------------------------------------------------------------------- -extern void WOLLoginMenuInit( WindowLayout *layout, void *userData ); -extern void WOLLoginMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLLoginMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLLoginMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLLoginMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Locale Select Popup --------------------------------------------------------------------------------- -extern void WOLLocaleSelectInit( WindowLayout *layout, void *userData ); -extern void WOLLocaleSelectUpdate( WindowLayout *layout, void *userData ); -extern void WOLLocaleSelectShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLLocaleSelectSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLLocaleSelectInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Message Window ------------------------------------------------------------------------------ -extern void WOLMessageWindowInit( WindowLayout *layout, void *userData ); -extern void WOLMessageWindowUpdate( WindowLayout *layout, void *userData ); -extern void WOLMessageWindowShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLMessageWindowSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLMessageWindowInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Quick Match Menu ---------------------------------------------------------------------------- -extern void WOLQuickMatchMenuInit( WindowLayout *layout, void *userData ); -extern void WOLQuickMatchMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLQuickMatchMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLQuickMatchMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLQuickMatchMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Welcome Menu -------------------------------------------------------------------------------- -extern void WOLWelcomeMenuInit( WindowLayout *layout, void *userData ); -extern void WOLWelcomeMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLWelcomeMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLWelcomeMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLWelcomeMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Welcome Menu -------------------------------------------------------------------------------- -extern void WOLStatusMenuInit( WindowLayout *layout, void *userData ); -extern void WOLStatusMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLStatusMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLStatusMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLStatusMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Quickmatch Score Screen -------------------------------------------------------------------------------- -extern void WOLQMScoreScreenInit( WindowLayout *layout, void *userData ); -extern void WOLQMScoreScreenUpdate( WindowLayout *layout, void *userData ); -extern void WOLQMScoreScreenShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLQMScoreScreenSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLQMScoreScreenInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Lobby Menu --------------------------------------------------------------------------------- -extern void WOLLobbyMenuInit( WindowLayout *layout, void *userData ); -extern void WOLLobbyMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLLobbyMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLLobbyMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLLobbyMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Game Setup Menu --------------------------------------------------------------------------------- -extern void WOLGameSetupMenuInit( WindowLayout *layout, void *userData ); -extern void WOLGameSetupMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLGameSetupMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLGameSetupMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Custom Score Screen -------------------------------------------------------------------------------- -extern void WOLCustomScoreScreenInit( WindowLayout *layout, void *userData ); -extern void WOLCustomScoreScreenUpdate( WindowLayout *layout, void *userData ); -extern void WOLCustomScoreScreenShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLCustomScoreScreenSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLCustomScoreScreenInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Map Select Overlay --------------------------------------------------------------------------------- -extern void WOLMapSelectMenuInit( WindowLayout *layout, void *userData ); -extern void WOLMapSelectMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLMapSelectMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLMapSelectMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLMapSelectMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Buddy Overlay --------------------------------------------------------------------------------- -extern void WOLBuddyOverlayInit( WindowLayout *layout, void *userData ); -extern void WOLBuddyOverlayUpdate( WindowLayout *layout, void *userData ); -extern void WOLBuddyOverlayShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLBuddyOverlaySystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLBuddyOverlayInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Buddy Overlay Right Click menu callbacks -------------------------------------------------------------- -extern void WOLBuddyOverlayRCMenuInit( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLBuddyOverlayRCMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - // GameSpy Player Info Overlay --------------------------------------------------------------------------------- extern void GameSpyPlayerInfoOverlayInit( WindowLayout *layout, void *userData ); extern void GameSpyPlayerInfoOverlayUpdate( WindowLayout *layout, void *userData ); diff --git a/Generals/Code/GameEngine/Source/Common/System/FunctionLexicon.cpp b/Generals/Code/GameEngine/Source/Common/System/FunctionLexicon.cpp index 341f1d2edfc..7dca14a838e 100644 --- a/Generals/Code/GameEngine/Source/Common/System/FunctionLexicon.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/FunctionLexicon.cpp @@ -43,7 +43,6 @@ extern WindowMsgHandledType PopupLadderSelectInput( GameWindow *window, Unsigned extern WindowMsgHandledType PopupBuddyNotificationSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -// WOL Buddy Overlay Right Click menu callbacks -------------------------------------------------------------- extern void RCGameDetailsMenuInit( WindowLayout *layout, void *userData ); extern WindowMsgHandledType RCGameDetailsMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); @@ -111,22 +110,8 @@ static FunctionLexicon::TableEntry gameWinSystemTable[] = { NAMEKEY_INVALID, "PopupBuddyNotificationSystem", PopupBuddyNotificationSystem }, { NAMEKEY_INVALID, "PopupReplaySystem", PopupReplaySystem }, { NAMEKEY_INVALID, "KeyboardOptionsMenuSystem", KeyboardOptionsMenuSystem }, - { NAMEKEY_INVALID, "WOLLadderScreenSystem", WOLLadderScreenSystem }, - { NAMEKEY_INVALID, "WOLLoginMenuSystem", WOLLoginMenuSystem }, - { NAMEKEY_INVALID, "WOLLocaleSelectSystem", WOLLocaleSelectSystem }, - { NAMEKEY_INVALID, "WOLLobbyMenuSystem", WOLLobbyMenuSystem }, - { NAMEKEY_INVALID, "WOLGameSetupMenuSystem", WOLGameSetupMenuSystem }, - { NAMEKEY_INVALID, "WOLMapSelectMenuSystem", WOLMapSelectMenuSystem }, - { NAMEKEY_INVALID, "WOLBuddyOverlaySystem", WOLBuddyOverlaySystem }, - { NAMEKEY_INVALID, "WOLBuddyOverlayRCMenuSystem", WOLBuddyOverlayRCMenuSystem }, { NAMEKEY_INVALID, "RCGameDetailsMenuSystem", RCGameDetailsMenuSystem }, { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlaySystem",GameSpyPlayerInfoOverlaySystem }, - { NAMEKEY_INVALID, "WOLMessageWindowSystem", WOLMessageWindowSystem }, - { NAMEKEY_INVALID, "WOLQuickMatchMenuSystem", WOLQuickMatchMenuSystem }, - { NAMEKEY_INVALID, "WOLWelcomeMenuSystem", WOLWelcomeMenuSystem }, - { NAMEKEY_INVALID, "WOLStatusMenuSystem", WOLStatusMenuSystem }, - { NAMEKEY_INVALID, "WOLQMScoreScreenSystem", WOLQMScoreScreenSystem }, - { NAMEKEY_INVALID, "WOLCustomScoreScreenSystem", WOLCustomScoreScreenSystem }, { NAMEKEY_INVALID, "NetworkDirectConnectSystem", NetworkDirectConnectSystem }, { NAMEKEY_INVALID, "PopupHostGameSystem", PopupHostGameSystem }, { NAMEKEY_INVALID, "PopupJoinGameSystem", PopupJoinGameSystem }, @@ -183,20 +168,7 @@ static FunctionLexicon::TableEntry gameWinInputTable[] = { NAMEKEY_INVALID, "LanMapSelectMenuInput", LanMapSelectMenuInput }, { NAMEKEY_INVALID, "SkirmishGameOptionsMenuInput", SkirmishGameOptionsMenuInput }, { NAMEKEY_INVALID, "SkirmishMapSelectMenuInput", SkirmishMapSelectMenuInput }, - { NAMEKEY_INVALID, "WOLLadderScreenInput", WOLLadderScreenInput }, - { NAMEKEY_INVALID, "WOLLoginMenuInput", WOLLoginMenuInput }, - { NAMEKEY_INVALID, "WOLLocaleSelectInput", WOLLocaleSelectInput }, - { NAMEKEY_INVALID, "WOLLobbyMenuInput", WOLLobbyMenuInput }, - { NAMEKEY_INVALID, "WOLGameSetupMenuInput", WOLGameSetupMenuInput }, - { NAMEKEY_INVALID, "WOLMapSelectMenuInput", WOLMapSelectMenuInput }, - { NAMEKEY_INVALID, "WOLBuddyOverlayInput", WOLBuddyOverlayInput }, { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayInput", GameSpyPlayerInfoOverlayInput }, - { NAMEKEY_INVALID, "WOLMessageWindowInput", WOLMessageWindowInput }, - { NAMEKEY_INVALID, "WOLQuickMatchMenuInput", WOLQuickMatchMenuInput }, - { NAMEKEY_INVALID, "WOLWelcomeMenuInput", WOLWelcomeMenuInput }, - { NAMEKEY_INVALID, "WOLStatusMenuInput", WOLStatusMenuInput }, - { NAMEKEY_INVALID, "WOLQMScoreScreenInput", WOLQMScoreScreenInput }, - { NAMEKEY_INVALID, "WOLCustomScoreScreenInput", WOLCustomScoreScreenInput }, { NAMEKEY_INVALID, "NetworkDirectConnectInput", NetworkDirectConnectInput }, { NAMEKEY_INVALID, "PopupHostGameInput", PopupHostGameInput }, { NAMEKEY_INVALID, "PopupJoinGameInput", PopupJoinGameInput }, @@ -227,7 +199,6 @@ static FunctionLexicon::TableEntry gameWinInputTable[] = static FunctionLexicon::TableEntry gameWinTooltipTable[] = { - { NAMEKEY_INVALID, "GameWinDefaultTooltip", GameWinDefaultTooltip }, { NAMEKEY_INVALID, NULL, NULL } @@ -254,22 +225,8 @@ static FunctionLexicon::TableEntry winLayoutInitTable[] = { NAMEKEY_INVALID, "LanMapSelectMenuInit", LanMapSelectMenuInit }, { NAMEKEY_INVALID, "SkirmishGameOptionsMenuInit", SkirmishGameOptionsMenuInit }, { NAMEKEY_INVALID, "SkirmishMapSelectMenuInit", SkirmishMapSelectMenuInit }, - { NAMEKEY_INVALID, "WOLLadderScreenInit", WOLLadderScreenInit }, - { NAMEKEY_INVALID, "WOLLoginMenuInit", WOLLoginMenuInit }, - { NAMEKEY_INVALID, "WOLLocaleSelectInit", WOLLocaleSelectInit }, - { NAMEKEY_INVALID, "WOLLobbyMenuInit", WOLLobbyMenuInit }, - { NAMEKEY_INVALID, "WOLGameSetupMenuInit", WOLGameSetupMenuInit }, - { NAMEKEY_INVALID, "WOLMapSelectMenuInit", WOLMapSelectMenuInit }, - { NAMEKEY_INVALID, "WOLBuddyOverlayInit", WOLBuddyOverlayInit }, - { NAMEKEY_INVALID, "WOLBuddyOverlayRCMenuInit", WOLBuddyOverlayRCMenuInit }, { NAMEKEY_INVALID, "RCGameDetailsMenuInit", RCGameDetailsMenuInit }, { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayInit", GameSpyPlayerInfoOverlayInit }, - { NAMEKEY_INVALID, "WOLMessageWindowInit", WOLMessageWindowInit }, - { NAMEKEY_INVALID, "WOLQuickMatchMenuInit", WOLQuickMatchMenuInit }, - { NAMEKEY_INVALID, "WOLWelcomeMenuInit", WOLWelcomeMenuInit }, - { NAMEKEY_INVALID, "WOLStatusMenuInit", WOLStatusMenuInit }, - { NAMEKEY_INVALID, "WOLQMScoreScreenInit", WOLQMScoreScreenInit }, - { NAMEKEY_INVALID, "WOLCustomScoreScreenInit", WOLCustomScoreScreenInit }, { NAMEKEY_INVALID, "NetworkDirectConnectInit", NetworkDirectConnectInit }, { NAMEKEY_INVALID, "PopupHostGameInit", PopupHostGameInit }, { NAMEKEY_INVALID, "PopupJoinGameInit", PopupJoinGameInit }, @@ -302,20 +259,7 @@ static FunctionLexicon::TableEntry winLayoutUpdateTable[] = { NAMEKEY_INVALID, "LanMapSelectMenuUpdate", LanMapSelectMenuUpdate }, { NAMEKEY_INVALID, "SkirmishGameOptionsMenuUpdate", SkirmishGameOptionsMenuUpdate }, { NAMEKEY_INVALID, "SkirmishMapSelectMenuUpdate", SkirmishMapSelectMenuUpdate }, - { NAMEKEY_INVALID, "WOLLadderScreenUpdate", WOLLadderScreenUpdate }, - { NAMEKEY_INVALID, "WOLLoginMenuUpdate", WOLLoginMenuUpdate }, - { NAMEKEY_INVALID, "WOLLocaleSelectUpdate", WOLLocaleSelectUpdate }, - { NAMEKEY_INVALID, "WOLLobbyMenuUpdate", WOLLobbyMenuUpdate }, - { NAMEKEY_INVALID, "WOLGameSetupMenuUpdate", WOLGameSetupMenuUpdate }, - { NAMEKEY_INVALID, "WOLMapSelectMenuUpdate", WOLMapSelectMenuUpdate }, - { NAMEKEY_INVALID, "WOLBuddyOverlayUpdate", WOLBuddyOverlayUpdate }, { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayUpdate",GameSpyPlayerInfoOverlayUpdate }, - { NAMEKEY_INVALID, "WOLMessageWindowUpdate", WOLMessageWindowUpdate }, - { NAMEKEY_INVALID, "WOLQuickMatchMenuUpdate", WOLQuickMatchMenuUpdate }, - { NAMEKEY_INVALID, "WOLWelcomeMenuUpdate", WOLWelcomeMenuUpdate }, - { NAMEKEY_INVALID, "WOLStatusMenuUpdate", WOLStatusMenuUpdate }, - { NAMEKEY_INVALID, "WOLQMScoreScreenUpdate", WOLQMScoreScreenUpdate }, - { NAMEKEY_INVALID, "WOLCustomScoreScreenUpdate", WOLCustomScoreScreenUpdate }, { NAMEKEY_INVALID, "NetworkDirectConnectUpdate", NetworkDirectConnectUpdate }, { NAMEKEY_INVALID, "ScoreScreenUpdate", ScoreScreenUpdate }, { NAMEKEY_INVALID, "DownloadMenuUpdate", DownloadMenuUpdate }, @@ -342,20 +286,7 @@ static FunctionLexicon::TableEntry winLayoutShutdownTable[] = { NAMEKEY_INVALID, "LanMapSelectMenuShutdown", LanMapSelectMenuShutdown }, { NAMEKEY_INVALID, "SkirmishGameOptionsMenuShutdown",SkirmishGameOptionsMenuShutdown }, { NAMEKEY_INVALID, "SkirmishMapSelectMenuShutdown", SkirmishMapSelectMenuShutdown }, - { NAMEKEY_INVALID, "WOLLadderScreenShutdown", WOLLadderScreenShutdown }, - { NAMEKEY_INVALID, "WOLLoginMenuShutdown", WOLLoginMenuShutdown }, - { NAMEKEY_INVALID, "WOLLocaleSelectShutdown", WOLLocaleSelectShutdown }, - { NAMEKEY_INVALID, "WOLLobbyMenuShutdown", WOLLobbyMenuShutdown }, - { NAMEKEY_INVALID, "WOLGameSetupMenuShutdown", WOLGameSetupMenuShutdown }, - { NAMEKEY_INVALID, "WOLMapSelectMenuShutdown", WOLMapSelectMenuShutdown }, - { NAMEKEY_INVALID, "WOLBuddyOverlayShutdown", WOLBuddyOverlayShutdown }, { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayShutdown",GameSpyPlayerInfoOverlayShutdown }, - { NAMEKEY_INVALID, "WOLMessageWindowShutdown", WOLMessageWindowShutdown }, - { NAMEKEY_INVALID, "WOLQuickMatchMenuShutdown", WOLQuickMatchMenuShutdown }, - { NAMEKEY_INVALID, "WOLWelcomeMenuShutdown", WOLWelcomeMenuShutdown }, - { NAMEKEY_INVALID, "WOLStatusMenuShutdown", WOLStatusMenuShutdown }, - { NAMEKEY_INVALID, "WOLQMScoreScreenShutdown", WOLQMScoreScreenShutdown }, - { NAMEKEY_INVALID, "WOLCustomScoreScreenShutdown", WOLCustomScoreScreenShutdown }, { NAMEKEY_INVALID, "NetworkDirectConnectShutdown", NetworkDirectConnectShutdown }, { NAMEKEY_INVALID, "ScoreScreenShutdown", ScoreScreenShutdown }, { NAMEKEY_INVALID, "DownloadMenuShutdown", DownloadMenuShutdown }, diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp deleted file mode 100644 index 55db148badc..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp +++ /dev/null @@ -1,1453 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLBuddyOverlay.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/AudioEventRTS.h" -#include "Common/PlayerList.h" -#include "Common/Player.h" -#include "GameClient/GameText.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetPushButton.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GadgetRadioButton.h" -#include "GameClient/Display.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/BuddyDefs.h" -#include "GameNetwork/GameSpy/BuddyThread.h" -#include "GameNetwork/GameSpy/LobbyUtils.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" -#include "GameNetwork/GameSpy/ThreadUtils.h" - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentID = NAMEKEY_INVALID; -static NameKeyType buttonHideID = NAMEKEY_INVALID; -static NameKeyType buttonAddBuddyID = NAMEKEY_INVALID; -static NameKeyType buttonDeleteBuddyID = NAMEKEY_INVALID; -static NameKeyType textEntryID = NAMEKEY_INVALID; -static NameKeyType listboxBuddyID = NAMEKEY_INVALID; -static NameKeyType listboxChatID = NAMEKEY_INVALID; -static NameKeyType buttonAcceptBuddyID = NAMEKEY_INVALID; -static NameKeyType buttonDenyBuddyID = NAMEKEY_INVALID; -static NameKeyType radioButtonBuddiesID = NAMEKEY_INVALID; -static NameKeyType radioButtonIgnoreID = NAMEKEY_INVALID; -static NameKeyType parentBuddiesID = NAMEKEY_INVALID; -static NameKeyType parentIgnoreID = NAMEKEY_INVALID; -static NameKeyType listboxIgnoreID = NAMEKEY_INVALID; -static NameKeyType buttonNotificationID = NAMEKEY_INVALID; - - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parent = NULL; -static GameWindow *buttonHide = NULL; -static GameWindow *buttonAddBuddy = NULL; -static GameWindow *buttonDeleteBuddy = NULL; -static GameWindow *textEntry = NULL; -static GameWindow *listboxBuddy = NULL; -static GameWindow *listboxChat = NULL; -static GameWindow *buttonAcceptBuddy = NULL; -static GameWindow *buttonDenyBuddy = NULL; -static GameWindow *radioButtonBuddies = NULL; -static GameWindow *radioButtonIgnore = NULL; -static GameWindow *parentBuddies = NULL; -static GameWindow *parentIgnore = NULL; -static GameWindow *listboxIgnore = NULL; - -static Bool isOverlayActive = false; -void insertChat( BuddyMessage msg ); -// RightClick pointers --------------------------------------------------------------------- -static GameWindow *rcMenu = NULL; -static WindowLayout *noticeLayout = NULL; -static UnsignedInt noticeExpires = 0; -enum { NOTIFICATION_EXPIRES = 3000 }; - -void setUnignoreText( WindowLayout *layout, AsciiString nick, GPProfile id); -void refreshIgnoreList( void ); -void showNotificationBox( AsciiString nick, UnicodeString message); -void deleteNotificationBox( void ); -static Bool lastNotificationWasStatus = FALSE; -static Int numOnlineInNotification = 0; - -class BuddyControls -{ -public: - BuddyControls(void ); - GameWindow *listboxChat; - NameKeyType listboxChatID; - - GameWindow *listboxBuddies; - NameKeyType listboxBuddiesID; - - GameWindow *textEntryEdit; - NameKeyType textEntryEditID; - Bool isInit; -}; - -static BuddyControls buddyControls; -BuddyControls::BuddyControls( void ) -{ - listboxChat = NULL; - listboxChatID = NAMEKEY_INVALID; - listboxBuddies = NULL; - listboxBuddiesID = NAMEKEY_INVALID; - textEntryEdit = NULL; - textEntryEditID = NAMEKEY_INVALID; - isInit = FALSE; -} -// At this point I don't give a damn about how good this way is. I'm doing it anyway. -enum -{ - BUDDY_RESETALL_CRAP = -1, - BUDDY_WINDOW_BUDDIES = 0, - BUDDY_WINDOW_DIPLOMACY, - BUDDY_WINDOW_WELCOME_SCREEN, -}; - -void InitBuddyControls(Int type) -{ - if(!TheGameSpyInfo) - { - buddyControls.textEntryEditID = NAMEKEY_INVALID; - buddyControls.textEntryEdit = NULL; - buddyControls.listboxBuddiesID = NAMEKEY_INVALID; - buddyControls.listboxChatID = NAMEKEY_INVALID; - buddyControls.listboxBuddies = NULL; - buddyControls.listboxChat = NULL; - buddyControls.isInit = FALSE; - return; - } - switch (type) { - case BUDDY_RESETALL_CRAP: - buddyControls.textEntryEditID = NAMEKEY_INVALID; - buddyControls.textEntryEdit = NULL; - buddyControls.listboxBuddiesID = NAMEKEY_INVALID; - buddyControls.listboxChatID = NAMEKEY_INVALID; - buddyControls.listboxBuddies = NULL; - buddyControls.listboxChat = NULL; - buddyControls.isInit = FALSE; - break; - case BUDDY_WINDOW_BUDDIES: - buddyControls.textEntryEditID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:TextEntryChat" ) ); - buddyControls.textEntryEdit = TheWindowManager->winGetWindowFromId(NULL, buddyControls.textEntryEditID); - buddyControls.listboxBuddiesID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ListboxBuddies" ) ); - buddyControls.listboxChatID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ListboxBuddyChat" ) ); - buddyControls.listboxBuddies = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxBuddiesID ); - buddyControls.listboxChat = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxChatID); - GadgetTextEntrySetText(buddyControls.textEntryEdit, UnicodeString.TheEmptyString); - buddyControls.isInit = TRUE; - break; - case BUDDY_WINDOW_DIPLOMACY: - buddyControls.textEntryEditID = TheNameKeyGenerator->nameToKey( AsciiString( "Diplomacy.wnd:TextEntryChat" ) ); - buddyControls.textEntryEdit = TheWindowManager->winGetWindowFromId(NULL, buddyControls.textEntryEditID); - buddyControls.listboxBuddiesID = TheNameKeyGenerator->nameToKey( AsciiString( "Diplomacy.wnd:ListboxBuddies" ) ); - buddyControls.listboxChatID = TheNameKeyGenerator->nameToKey( AsciiString( "Diplomacy.wnd:ListboxBuddyChat" ) ); - buddyControls.listboxBuddies = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxBuddiesID ); - buddyControls.listboxChat = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxChatID); - GadgetTextEntrySetText(buddyControls.textEntryEdit, UnicodeString.TheEmptyString); - buddyControls.isInit = TRUE; - break; - case BUDDY_WINDOW_WELCOME_SCREEN: - break; - default: - DEBUG_ASSERTCRASH(FALSE, ("Well, you really shouldn't have gotten here, if you really care about GUI Bugs, search for this string, you you don't care, call chris (who probably doesn't care either")); - } - -} - -WindowMsgHandledType BuddyControlSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2) -{ - if(!TheGameSpyInfo || TheGameSpyInfo->getLocalProfileID() == 0 || !buddyControls.isInit) - { - return MSG_IGNORED; - } - - switch( msg ) - { - case GLM_RIGHT_CLICKED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if( controlID == buddyControls.listboxBuddiesID ) - { - RightClickStruct *rc = (RightClickStruct *)mData2; - WindowLayout *rcLayout; - if(rc->pos < 0) - break; - - GPProfile profileID = (GPProfile)GadgetListBoxGetItemData(control, rc->pos, 0); - RCItemType itemType = (RCItemType)(Int)GadgetListBoxGetItemData(control, rc->pos, 1); - UnicodeString nick = GadgetListBoxGetText(control, rc->pos); - - GadgetListBoxSetSelected(control, rc->pos); - if (itemType == ITEM_BUDDY) - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCBuddiesMenu.wnd")); - else if (itemType == ITEM_REQUEST) - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCBuddyRequestMenu.wnd")); - else - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCNonBuddiesMenu.wnd")); - rcMenu = rcLayout->getFirstWindow(); - rcMenu->winGetLayout()->runInit(); - rcMenu->winBringToTop(); - rcMenu->winHide(FALSE); - - - ICoord2D rcSize, rcPos; - rcMenu->winGetSize(&rcSize.x, &rcSize.y); - rcPos.x = rc->mouseX; - rcPos.y = rc->mouseY; - if(rc->mouseX + rcSize.x > TheDisplay->getWidth()) - rcPos.x = TheDisplay->getWidth() - rcSize.x; - if(rc->mouseY + rcSize.y > TheDisplay->getHeight()) - rcPos.y = TheDisplay->getHeight() - rcSize.y; - rcMenu->winSetPosition(rcPos.x, rcPos.y); - - - GameSpyRCMenuData *rcData = NEW GameSpyRCMenuData; - rcData->m_id = profileID; - rcData->m_nick.translate(nick); - rcData->m_itemType = itemType; - setUnignoreText(rcLayout, rcData->m_nick, rcData->m_id); - rcMenu->winSetUserData((void *)rcData); - TheWindowManager->winSetLoneWindow(rcMenu); - } - else - return MSG_IGNORED; - break; - } - case GEM_EDIT_DONE: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if(controlID != buddyControls.textEntryEditID) - return MSG_IGNORED; - - // see if someone's selected - Int selected = -1; - GadgetListBoxGetSelected(buddyControls.listboxBuddies, &selected); - if (selected >= 0) - { - GPProfile selectedProfile = (GPProfile)GadgetListBoxGetItemData(buddyControls.listboxBuddies, selected); - BuddyInfoMap *m = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator recipIt = m->find(selectedProfile); - if (recipIt == m->end()) - break; - - DEBUG_LOG(("Trying to send a buddy message to %d.\n", selectedProfile)); - if (TheGameSpyGame && TheGameSpyGame->isInGame() && TheGameSpyGame->isGameInProgress() && - !ThePlayerList->getLocalPlayer()->isPlayerActive()) - { - DEBUG_LOG(("I'm dead - gotta look for cheats.\n")); - for (Int i=0; igetGameSpySlot(i)->getProfileID())); - if (TheGameSpyGame->getGameSpySlot(i)->getProfileID() == selectedProfile) - { - // can't send to someone in our game if we're dead/observing. security breach and all that. no seances for you. - if (buddyControls.listboxChat) - { - GadgetListBoxAddEntryText( buddyControls.listboxChat, TheGameText->fetch("Buddy:CantTalkToIngameBuddy"), - GameSpyColor[GSCOLOR_DEFAULT], -1, -1 ); - } - return MSG_HANDLED; - } - } - } - - // read the user's input and clear the entry box - UnicodeString txtInput; - txtInput.set(GadgetTextEntryGetText( buddyControls.textEntryEdit )); - GadgetTextEntrySetText(buddyControls.textEntryEdit, UnicodeString::TheEmptyString); - txtInput.trim(); - if (!txtInput.isEmpty()) - { - // Send the message - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_MESSAGE; - wcsncpy(req.arg.message.text, txtInput.str(), MAX_BUDDY_CHAT_LEN); - req.arg.message.text[MAX_BUDDY_CHAT_LEN-1] = 0; - req.arg.message.recipient = selectedProfile; - TheGameSpyBuddyMessageQueue->addRequest(req); - - // save message for future incarnations of the buddy window - BuddyMessageList *messages = TheGameSpyInfo->getBuddyMessages(); - BuddyMessage message; - message.m_timestamp = time(NULL); - message.m_senderID = TheGameSpyInfo->getLocalProfileID(); - message.m_senderNick = TheGameSpyInfo->getLocalBaseName(); - message.m_recipientID = selectedProfile; - message.m_recipientNick = recipIt->second.m_name; - message.m_message = UnicodeString(req.arg.message.text); - messages->push_back(message); - - // put message on screen - insertChat(message); - } - } - else - { - // nobody selected. Prompt the user. - if (buddyControls.listboxChat) - { - GadgetListBoxAddEntryText( buddyControls.listboxChat, TheGameText->fetch("Buddy:SelectBuddyToChat"), - GameSpyColor[GSCOLOR_DEFAULT], -1, -1 ); - } - } - break; - } - default: - return MSG_IGNORED; - } - return MSG_HANDLED; -} - - -static void insertChat( BuddyMessage msg ) -{ - if (buddyControls.listboxChat) - { - BuddyInfoMap *m = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator senderIt = m->find(msg.m_senderID); - BuddyInfoMap::iterator recipientIt = m->find(msg.m_recipientID); - Bool localSender = (msg.m_senderID == TheGameSpyInfo->getLocalProfileID()); - UnicodeString s; - //UnicodeString timeStr = UnicodeString(_wctime( (const time_t *)&msg.m_timestamp )); - UnicodeString timeStr; - if (localSender /*&& recipientIt != m->end()*/) - { - s.format(L"[%hs -> %hs] %s", TheGameSpyInfo->getLocalBaseName().str(), msg.m_recipientNick.str(), msg.m_message.str()); - Int index = GadgetListBoxAddEntryText( buddyControls.listboxChat, s, GameSpyColor[GSCOLOR_PLAYER_SELF], -1, -1 ); - GadgetListBoxAddEntryText( buddyControls.listboxChat, timeStr, GameSpyColor[GSCOLOR_PLAYER_SELF], index, 1); - } - else if (!localSender /*&& senderIt != m->end()*/) - { - if (!msg.m_senderID) - { - s = msg.m_message; - Int index = GadgetListBoxAddEntryText( buddyControls.listboxChat, s, GameSpyColor[GSCOLOR_DEFAULT], -1, -1 ); - GadgetListBoxAddEntryText( buddyControls.listboxChat, timeStr, GameSpyColor[GSCOLOR_DEFAULT], index, 1); - } - else - { - s.format(L"[%hs] %s", msg.m_senderNick.str(), msg.m_message.str()); - Int index = GadgetListBoxAddEntryText( buddyControls.listboxChat, s, GameSpyColor[GSCOLOR_PLAYER_BUDDY], -1, -1 ); - GadgetListBoxAddEntryText( buddyControls.listboxChat, timeStr, GameSpyColor[GSCOLOR_PLAYER_BUDDY], index, 1); - } - } - } -} - -void updateBuddyInfo( void ) -{ - if (!TheGameSpyBuddyMessageQueue->isConnected()) - { - GadgetListBoxReset(buddyControls.listboxBuddies); - return; - } - - if (!buddyControls.isInit) - return; - - int selected; - GPProfile selectedProfile = 0; - int visiblePos = GadgetListBoxGetTopVisibleEntry(buddyControls.listboxBuddies); - - GadgetListBoxGetSelected(buddyControls.listboxBuddies, &selected); - if (selected >= 0) - selectedProfile = (GPProfile)GadgetListBoxGetItemData(buddyControls.listboxBuddies, selected); - - selected = -1; - GadgetListBoxReset(buddyControls.listboxBuddies); - - // Add buddies - BuddyInfoMap *buddies = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator bIt; - for (bIt = buddies->begin(); bIt != buddies->end(); ++bIt) - { - BuddyInfo info = bIt->second; - GPProfile profileID = bIt->first; - - // insert name into box - UnicodeString formatStr; - formatStr.translate(info.m_name.str());//, info.m_status, info.m_statusString.str(), info.m_locationString.str()); - Color nameColor = (TheGameSpyInfo->isSavedIgnored(profileID)) ? - GameSpyColor[GSCOLOR_PLAYER_IGNORED] : GameSpyColor[GSCOLOR_PLAYER_BUDDY]; - int index = GadgetListBoxAddEntryText(buddyControls.listboxBuddies, formatStr, nameColor, -1, -1); - - // insert status into box - AsciiString marker; - marker.format("Buddy:%ls", info.m_statusString.str()); - if (!info.m_statusString.compareNoCase(L"Offline") || - !info.m_statusString.compareNoCase(L"Online") || - !info.m_statusString.compareNoCase(L"Matching")) - { - formatStr = TheGameText->fetch(marker); - } - else if (!info.m_statusString.compareNoCase(L"Staging") || - !info.m_statusString.compareNoCase(L"Loading") || - !info.m_statusString.compareNoCase(L"Playing")) - { - formatStr.format(TheGameText->fetch(marker), info.m_locationString.str()); - } - else if (!info.m_statusString.compareNoCase(L"Chatting")) - { - UnicodeString roomName; - GroupRoomMap::iterator gIt = TheGameSpyInfo->getGroupRoomList()->find( _wtoi(info.m_locationString.str()) ); - if (gIt != TheGameSpyInfo->getGroupRoomList()->end()) - { - AsciiString s; - s.format("GUI:%s", gIt->second.m_name.str()); - roomName = TheGameText->fetch(s); - } - formatStr.format(TheGameText->fetch(marker), roomName.str()); - } - else - { - formatStr = info.m_statusString; - } - GadgetListBoxAddEntryText(buddyControls.listboxBuddies, formatStr, GameSpyColor[GSCOLOR_DEFAULT], index, 1); - GadgetListBoxSetItemData(buddyControls.listboxBuddies, (void *)(profileID), index, 0 ); - GadgetListBoxSetItemData(buddyControls.listboxBuddies, (void *)(ITEM_BUDDY), index, 1 ); - - if (profileID == selectedProfile) - selected = index; - } - - // add requests - buddies = TheGameSpyInfo->getBuddyRequestMap(); - for (bIt = buddies->begin(); bIt != buddies->end(); ++bIt) - { - BuddyInfo info = bIt->second; - GPProfile profileID = bIt->first; - - // insert name into box - UnicodeString formatStr; - formatStr.translate(info.m_name.str()); - int index = GadgetListBoxAddEntryText(buddyControls.listboxBuddies, formatStr, GameSpyColor[GSCOLOR_DEFAULT], -1, -1); - GadgetListBoxSetItemData(buddyControls.listboxBuddies, (void *)(profileID), index, 0 ); - - // insert status into box - formatStr = TheGameText->fetch("GUI:BuddyAddReq"); - GadgetListBoxAddEntryText(buddyControls.listboxBuddies, formatStr, GameSpyColor[GSCOLOR_DEFAULT], index, 1); - GadgetListBoxSetItemData(buddyControls.listboxBuddies, (void *)(ITEM_REQUEST), index, 1 ); - - if (profileID == selectedProfile) - selected = index; - } - - - // select the same guy - if (selected >= 0) - { - GadgetListBoxSetSelected(buddyControls.listboxBuddies, selected); - } - - // view the same spot - GadgetListBoxSetTopVisibleEntry(buddyControls.listboxBuddies, visiblePos); -} - -void HandleBuddyResponses( void ) -{ - if (TheGameSpyBuddyMessageQueue) - { - BuddyResponse resp; - if (TheGameSpyBuddyMessageQueue->getResponse( resp )) - { - switch (resp.buddyResponseType) - { - case BuddyResponse::BUDDYRESPONSE_LOGIN: - { - deleteNotificationBox(); - } - break; - case BuddyResponse::BUDDYRESPONSE_DISCONNECT: - { - lastNotificationWasStatus = FALSE; - numOnlineInNotification = 0; - showNotificationBox(AsciiString::TheEmptyString, TheGameText->fetch("Buddy:MessageDisconnected")); - } - break; - case BuddyResponse::BUDDYRESPONSE_MESSAGE: - { - if ( !wcscmp(resp.arg.message.text, L"I have authorized your request to add me to your list") ) - break; - - if (TheGameSpyInfo->isSavedIgnored(resp.profile)) - { - //DEBUG_CRASH(("Player is ignored!\n")); - break; // no buddy messages from ignored people - } - - // save message for future incarnations of the buddy window - BuddyMessageList *messages = TheGameSpyInfo->getBuddyMessages(); - BuddyMessage message; - message.m_timestamp = resp.arg.message.date; - message.m_senderID = resp.profile; - message.m_recipientID = TheGameSpyInfo->getLocalProfileID(); - message.m_recipientNick = TheGameSpyInfo->getLocalBaseName(); - message.m_message = resp.arg.message.text; - // insert status into box - BuddyInfoMap *m = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator senderIt = m->find(message.m_senderID); - AsciiString nick; - if (senderIt != m->end()) - nick = senderIt->second.m_name.str(); - else - nick = resp.arg.message.nick; - message.m_senderNick = nick; - messages->push_back(message); - - DEBUG_LOG(("Inserting buddy chat from '%s'/'%s'\n", nick.str(), resp.arg.message.nick)); - - // put message on screen - insertChat(message); - - // play audio notification - AudioEventRTS buddyMsgAudio("GUIMessageReceived"); - if( TheAudio ) - { - TheAudio->addAudioEvent( &buddyMsgAudio ); - } // end if - - UnicodeString snippet = message.m_message; - while (snippet.getLength() > 11) - { - snippet.removeLastChar(); - } - UnicodeString s; - s.format(TheGameText->fetch("Buddy:MessageNotification"), nick.str(), snippet.str()); - lastNotificationWasStatus = FALSE; - numOnlineInNotification = 0; - showNotificationBox(AsciiString::TheEmptyString, s); - } - break; - case BuddyResponse::BUDDYRESPONSE_REQUEST: - { - // save request for future incarnations of the buddy window - BuddyInfoMap *m = TheGameSpyInfo->getBuddyRequestMap(); - BuddyInfo info; - info.m_countryCode = resp.arg.request.countrycode; - info.m_email = resp.arg.request.email; - info.m_name = resp.arg.request.nick; - info.m_id = resp.profile; - info.m_status = (GPEnum)0; - info.m_statusString = resp.arg.request.text; - (*m)[resp.profile] = info; - - // TODO: put request on screen - updateBuddyInfo(); - // insert status into box - lastNotificationWasStatus = FALSE; - numOnlineInNotification = 0; - showNotificationBox(info.m_name, TheGameText->fetch("Buddy:AddNotification")); - } - break; - case BuddyResponse::BUDDYRESPONSE_STATUS: - { - BuddyInfoMap *m = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::const_iterator bit = m->find(resp.profile); - Bool seenPreviously = FALSE; - GPEnum oldStatus = GP_OFFLINE; - GPEnum newStatus = resp.arg.status.status; - if (bit != m->end()) - { - seenPreviously = TRUE; - oldStatus = (*m)[resp.profile].m_status; - } - BuddyInfo info; - info.m_countryCode = resp.arg.status.countrycode; - info.m_email = resp.arg.status.email; - info.m_name = resp.arg.status.nick; - info.m_id = resp.profile; - info.m_status = newStatus; - info.m_statusString = UnicodeString(MultiByteToWideCharSingleLine(resp.arg.status.statusString).c_str()); - info.m_locationString = UnicodeString(MultiByteToWideCharSingleLine(resp.arg.status.location).c_str()); - (*m)[resp.profile] = info; - - updateBuddyInfo(); - PopulateLobbyPlayerListbox(); - RefreshGameListBoxes(); - if ( (newStatus == GP_OFFLINE && seenPreviously) || - (newStatus == GP_ONLINE && (oldStatus == GP_OFFLINE || !seenPreviously)) ) - //if (!info.m_statusString.compareNoCase(L"Offline") || - //!info.m_statusString.compareNoCase(L"Online")) - { - // insert status into box - AsciiString marker; - marker.format("Buddy:%lsNotification", info.m_statusString.str()); - - lastNotificationWasStatus = TRUE; - if (newStatus != GP_OFFLINE) - ++numOnlineInNotification; - - showNotificationBox(info.m_name, TheGameText->fetch(marker)); - } - else if( newStatus == GP_RECV_GAME_INVITE && !seenPreviously) - { - lastNotificationWasStatus = TRUE; - if (newStatus != GP_OFFLINE) - ++numOnlineInNotification; - - showNotificationBox(info.m_name, TheGameText->fetch("Buddy:OnlineNotification")); - } - } - break; - } - } - } - else - { - DEBUG_CRASH(("No buddy message queue!\n")); - } - if(noticeLayout && timeGetTime() > noticeExpires) - { - deleteNotificationBox(); - } -} - -void showNotificationBox( AsciiString nick, UnicodeString message) -{ -// if(!GameSpyIsOverlayOpen(GSOVERLAY_BUDDY)) -// return; - if( !noticeLayout ) - noticeLayout = TheWindowManager->winCreateLayout( "Menus/PopupBuddyListNotification.wnd" ); - noticeLayout->hide( FALSE ); - if (buttonNotificationID == NAMEKEY_INVALID) - { - buttonNotificationID = TheNameKeyGenerator->nameToKey("PopupBuddyListNotification.wnd:ButtonNotification"); - } - GameWindow *win = TheWindowManager->winGetWindowFromId(NULL,buttonNotificationID); - if(!win) - { - deleteNotificationBox(); - return; - } - - if (lastNotificationWasStatus && numOnlineInNotification > 1) - { - message = TheGameText->fetch("Buddy:MultipleOnlineNotification"); - } - - if (nick.isNotEmpty()) - message.format(message, nick.str()); - GadgetButtonSetText(win, message); - //GadgetStaticTextSetText(win, message); - noticeExpires = timeGetTime() + NOTIFICATION_EXPIRES; - noticeLayout->bringForward(); - - AudioEventRTS buttonClick("GUICommunicatorIncoming"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } // end if - -} - -void deleteNotificationBox( void ) -{ - lastNotificationWasStatus = FALSE; - numOnlineInNotification = 0; - if(noticeLayout) - { - noticeLayout->destroyWindows(); - noticeLayout->deleteInstance(); - noticeLayout = NULL; - } -} - -void PopulateOldBuddyMessages(void) -{ - // show previous messages - BuddyMessageList *messages = TheGameSpyInfo->getBuddyMessages(); - for (BuddyMessageList::iterator mIt = messages->begin(); mIt != messages->end(); ++mIt) - { - BuddyMessage message = *mIt; - insertChat(message); - } -} - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Buddy Overlay */ -//------------------------------------------------------------------------------------------------- -void WOLBuddyOverlayInit( WindowLayout *layout, void *userData ) -{ - parentID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:BuddyMenuParent" ) ); - buttonHideID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ButtonHide" ) ); - buttonAddBuddyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ButtonAdd" ) ); - buttonDeleteBuddyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ButtonDelete" ) ); - //textEntryID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:TextEntryChat" ) ); - //listboxBuddyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ListboxBuddies" ) ); - //listboxChatID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ListboxBuddyChat" ) ); - buttonAcceptBuddyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ButtonYes" ) ); - buttonDenyBuddyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ButtonNo" ) ); - radioButtonBuddiesID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:RadioButtonBuddies" ) ); - radioButtonIgnoreID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:RadioButtonIgnore" ) ); - parentBuddiesID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:BuddiesParent" ) ); - parentIgnoreID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:IgnoreParent" ) ); - listboxIgnoreID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ListboxIgnore" ) ); - - - parent = TheWindowManager->winGetWindowFromId( NULL, parentID ); - buttonHide = TheWindowManager->winGetWindowFromId( parent, buttonHideID); - buttonAddBuddy = TheWindowManager->winGetWindowFromId( parent, buttonAddBuddyID); - buttonDeleteBuddy = TheWindowManager->winGetWindowFromId( parent, buttonDeleteBuddyID); - // textEntry = TheWindowManager->winGetWindowFromId( parent, textEntryID); - //listboxBuddy = TheWindowManager->winGetWindowFromId( parent, listboxBuddyID); - //listboxChat = TheWindowManager->winGetWindowFromId( parent, listboxChatID); - buttonAcceptBuddy = TheWindowManager->winGetWindowFromId( parent, buttonAcceptBuddyID); - buttonDenyBuddy = TheWindowManager->winGetWindowFromId( parent, buttonDenyBuddyID); - radioButtonBuddies = TheWindowManager->winGetWindowFromId( parent, radioButtonBuddiesID); - radioButtonIgnore = TheWindowManager->winGetWindowFromId( parent, radioButtonIgnoreID); - parentBuddies = TheWindowManager->winGetWindowFromId( parent, parentBuddiesID); - parentIgnore = TheWindowManager->winGetWindowFromId( parent, parentIgnoreID); - listboxIgnore = TheWindowManager->winGetWindowFromId( parent, listboxIgnoreID); - - InitBuddyControls(BUDDY_WINDOW_BUDDIES); - - GadgetRadioSetSelection(radioButtonBuddies,FALSE); - parentBuddies->winHide(FALSE); - parentIgnore->winHide(TRUE); - - //GadgetTextEntrySetText(textEntry, UnicodeString.TheEmptyString); - - PopulateOldBuddyMessages(); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parent ); - - isOverlayActive = true; - updateBuddyInfo(); - -} // WOLBuddyOverlayInit - -//------------------------------------------------------------------------------------------------- -/** WOL Buddy Overlay shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLBuddyOverlayShutdown( WindowLayout *layout, void *userData ) -{ - listboxIgnore = NULL; - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - //TheShell->shutdownComplete( layout ); - - isOverlayActive = false; - - InitBuddyControls(BUDDY_RESETALL_CRAP); - -} // WOLBuddyOverlayShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Buddy Overlay update method */ -//------------------------------------------------------------------------------------------------- -void WOLBuddyOverlayUpdate( WindowLayout * layout, void *userData) -{ - if (!TheGameSpyBuddyMessageQueue || !TheGameSpyBuddyMessageQueue->isConnected()) - GameSpyCloseOverlay(GSOVERLAY_BUDDY); -}// WOLBuddyOverlayUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Buddy Overlay input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLBuddyOverlayInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonHide, buttonHideID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLBuddyOverlayInput - -//------------------------------------------------------------------------------------------------- -/** WOL Buddy Overlay window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLBuddyOverlaySystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - if(BuddyControlSystem(window, msg, mData1, mData2) == MSG_HANDLED) - { - return MSG_HANDLED; - } - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - case GLM_RIGHT_CLICKED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if( controlID == listboxIgnoreID ) - { - RightClickStruct *rc = (RightClickStruct *)mData2; - WindowLayout *rcLayout; - if(rc->pos < 0) - break; - - Bool isBuddy = false, isRequest = false; - GPProfile profileID = (GPProfile)GadgetListBoxGetItemData(control, rc->pos); - UnicodeString nick = GadgetListBoxGetText(control, rc->pos); - BuddyInfoMap *buddies = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator bIt; - bIt = buddies->find(profileID); - if (bIt != buddies->end()) - { - isBuddy = true; - } - else - { - buddies = TheGameSpyInfo->getBuddyRequestMap(); - bIt = buddies->find(profileID); - if (bIt != buddies->end()) - { - isRequest = true; - } - else - { - // neither buddy nor request - //break; - } - } - - GadgetListBoxSetSelected(control, rc->pos); - if (isBuddy) - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCBuddiesMenu.wnd")); - else if (isRequest) - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCBuddyRequestMenu.wnd")); - else - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCNonBuddiesMenu.wnd")); - rcMenu = rcLayout->getFirstWindow(); - rcMenu->winGetLayout()->runInit(); - rcMenu->winBringToTop(); - rcMenu->winHide(FALSE); - - - - rcMenu->winSetPosition(rc->mouseX, rc->mouseY); - GameSpyRCMenuData *rcData = NEW GameSpyRCMenuData; - rcData->m_id = profileID; - rcData->m_nick.translate(nick); - rcData->m_itemType = (isBuddy)?ITEM_BUDDY:((isRequest)?ITEM_REQUEST:ITEM_NONBUDDY); - setUnignoreText(rcLayout, rcData->m_nick, rcData->m_id); - rcMenu->winSetUserData((void *)rcData); - TheWindowManager->winSetLoneWindow(rcMenu); - } - break; - } - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if (controlID == buttonHideID) - { - GameSpyCloseOverlay( GSOVERLAY_BUDDY ); - } - else if (controlID == radioButtonBuddiesID) - { - parentBuddies->winHide(FALSE); - parentIgnore->winHide(TRUE); - } - else if (controlID == radioButtonIgnoreID) - { - parentBuddies->winHide(TRUE); - parentIgnore->winHide(FALSE); - refreshIgnoreList(); - } - else if (controlID == buttonAddBuddyID) - { - /* - UnicodeString uName = GadgetTextEntryGetText(textEntry); - AsciiString aName; - aName.translate(uName); - if (!aName.isEmpty()) - { - TheWOLBuddyList->requestBuddyAdd(aName); - } - GadgetTextEntrySetText(textEntry, UnicodeString::TheEmptyString); - */ - } - else if (controlID == buttonDeleteBuddyID) - { - /* - int selected; - AsciiString selectedName = AsciiString::TheEmptyString; - - GadgetListBoxGetSelected(listbox, &selected); - if (selected >= 0) - selectedName = TheNameKeyGenerator->keyToName((NameKeyType)(int)GadgetListBoxGetItemData(listbox, selected)); - - if (!selectedName.isEmpty()) - { - TheWOLBuddyList->requestBuddyDelete(selectedName); - } - */ - } - break; - }// case GBM_SELECTED: - case GLM_DOUBLE_CLICKED: - { - /* - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if( controlID == listboxBuddyID ) - { - int rowSelected = mData2; - - if (rowSelected >= 0) - { - UnicodeString buddyName; - GameWindow *listboxWindow = TheWindowManager->winGetWindowFromId( parent, listboxBuddyID ); - - // get text of buddy name - buddyName = GadgetListBoxGetText( listboxWindow, rowSelected,0 ); - GPProfile buddyID = (GPProfile)GadgetListBoxGetItemData( listboxWindow, rowSelected, 0 ); - - Int index = -1; - gpGetBuddyIndex(TheGPConnection, buddyID, &index); - if (index >= 0) - { - GPBuddyStatus status; - gpGetBuddyStatus(TheGPConnection, rowSelected, &status); - - UnicodeString string; - string.format(L"To join %s in %hs:", buddyName.str(), status.locationString); - GameSpyAddText(string, GSCOLOR_DEFAULT); - - if (status.status == GP_CHATTING) - { - AsciiString location = status.locationString; - AsciiString val; - location.nextToken(&val, "/"); - location.nextToken(&val, "/"); - location.nextToken(&val, "/"); - - string.format(L" ???"); - if (!val.isEmpty()) - { - Int groupRoom = atoi(val.str()); - if (TheGameSpyChat->getCurrentGroupRoomID() == groupRoom) - { - // already there - string.format(L" nothing"); - GameSpyAddText(string, GSCOLOR_DEFAULT); - } - else - { - GroupRoomMap *rooms = TheGameSpyChat->getGroupRooms(); - if (rooms) - { - Bool needToJoin = true; - GroupRoomMap::iterator it = rooms->find(groupRoom); - if (it != rooms->end()) - { - // he's in a different room - if (TheGameSpyChat->getCurrentGroupRoomID()) - { - string.format(L" leave group room"); - GameSpyAddText(string, GSCOLOR_DEFAULT); - - TheGameSpyChat->leaveRoom(GroupRoom); - } - else if (TheGameSpyGame->isInGame()) - { - if (TheGameSpyGame->isGameInProgress()) - { - string.format(L" can't leave game in progress"); - GameSpyAddText(string, GSCOLOR_DEFAULT); - needToJoin = false; - } - else - { - string.format(L" leave game setup"); - GameSpyAddText(string, GSCOLOR_DEFAULT); - - TheGameSpyChat->leaveRoom(StagingRoom); - TheGameSpyGame->leaveGame(); - } - } - if (needToJoin) - { - string.format(L" join lobby %d", groupRoom); - TheGameSpyChat->joinGroupRoom(groupRoom); - GameSpyAddText(string, GSCOLOR_DEFAULT); - } - } - } - } - } - } - } - else - { - DEBUG_CRASH(("No buddy associated with that ProfileID")); - GameSpyUpdateBuddyOverlay(); - } - } - } - */ - break; - } - - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLBuddyOverlaySystem - -WindowMsgHandledType PopupBuddyNotificationSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - case GWM_CREATE: - { - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if (controlID == buttonNotificationID) - { - GameSpyOpenOverlay( GSOVERLAY_BUDDY ); - } - break; - } - - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// PopupBuddyNotificationSystem - -/* -static NameKeyType buttonAcceptBuddyID = NAMEKEY_INVALID; -static NameKeyType buttonDenyBuddyID = NAMEKEY_INVALID; -*/ -static NameKeyType buttonAddID = NAMEKEY_INVALID; -static NameKeyType buttonDeleteID = NAMEKEY_INVALID; -static NameKeyType buttonPlayID = NAMEKEY_INVALID; -static NameKeyType buttonIgnoreID = NAMEKEY_INVALID; -static NameKeyType buttonStatsID = NAMEKEY_INVALID; -// Window Pointers ------------------------------------------------------------------------ -//static GameWindow *rCparent = NULL; - - -//------------------------------------------------------------------------------------------------- -/** WOL Buddy Overlay Right Click menu callbacks */ -//------------------------------------------------------------------------------------------------- -void WOLBuddyOverlayRCMenuInit( WindowLayout *layout, void *userData ) -{ - AsciiString controlName; - controlName.format("%s:ButtonAdd",layout->getFilename().str()+6); - buttonAddID = TheNameKeyGenerator->nameToKey( controlName ); - controlName.format("%s:ButtonDelete",layout->getFilename().str()+6); - buttonDeleteID = TheNameKeyGenerator->nameToKey( controlName ); - controlName.format("%s:ButtonPlay",layout->getFilename().str()+6); - buttonPlayID = TheNameKeyGenerator->nameToKey( controlName ); - controlName.format("%s:ButtonIgnore",layout->getFilename().str()+6); - buttonIgnoreID = TheNameKeyGenerator->nameToKey( controlName ); - controlName.format("%s:ButtonStats",layout->getFilename().str()+6); - buttonStatsID = TheNameKeyGenerator->nameToKey( controlName ); -} -static void closeRightClickMenu(GameWindow *win) -{ - - if(win) - { - WindowLayout *winLay = win->winGetLayout(); - if(!winLay) - return; - winLay->destroyWindows(); - winLay->deleteInstance(); - winLay = NULL; - - } -} - -void RequestBuddyAdd(Int profileID, AsciiString nick) -{ - // request to add a buddy - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_ADDBUDDY; - req.arg.addbuddy.id = profileID; - UnicodeString buddyAddstr; - buddyAddstr = TheGameText->fetch("GUI:BuddyAddReq"); - wcsncpy(req.arg.addbuddy.text, buddyAddstr.str(), MAX_BUDDY_CHAT_LEN); - req.arg.addbuddy.text[MAX_BUDDY_CHAT_LEN-1] = 0; - TheGameSpyBuddyMessageQueue->addRequest(req); - - UnicodeString s; - Bool exists = TRUE; - s.format(TheGameText->fetch("Buddy:InviteSent", &exists)); - if (!exists) - { - // no string yet. don't display. - return; - } - - // save message for future incarnations of the buddy window - BuddyMessageList *messages = TheGameSpyInfo->getBuddyMessages(); - BuddyMessage message; - message.m_timestamp = time(NULL); - message.m_senderID = 0; - message.m_senderNick = ""; - message.m_recipientID = TheGameSpyInfo->getLocalProfileID(); - message.m_recipientNick = TheGameSpyInfo->getLocalBaseName(); - message.m_message.format(TheGameText->fetch("Buddy:InviteSentToPlayer"), nick.str()); - - // insert status into box - messages->push_back(message); - - DEBUG_LOG(("Inserting buddy add request\n")); - - // put message on screen - insertChat(message); - - // play audio notification - AudioEventRTS buddyMsgAudio("GUIMessageReceived"); - if( TheAudio ) - { - TheAudio->addAudioEvent( &buddyMsgAudio ); - } // end if - - lastNotificationWasStatus = FALSE; - numOnlineInNotification = 0; - showNotificationBox(AsciiString::TheEmptyString, s); -} - -WindowMsgHandledType WOLBuddyOverlayRCMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ) -{ - - switch( msg ) - { - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - rcMenu = NULL; - break; - } // case GWM_DESTROY: - - case GGM_CLOSE: - { - closeRightClickMenu(window); - //rcMenu = NULL; - break; - } - - - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - GameSpyRCMenuData *rcData = (GameSpyRCMenuData*)window->winGetUserData(); - if(!rcData) - break; - DEBUG_ASSERTCRASH(rcData, ("WOLBuddyOverlayRCMenuSystem GBM_SELECTED:: we're attempting to read the GameSpyRCMenuData from the window, but the data's not there")); - GPProfile profileID = rcData->m_id; - AsciiString nick = rcData->m_nick; - - Bool isBuddy = false, isRequest = false; - Bool isGameSpyUser = profileID > 0; - if (rcData->m_itemType == ITEM_BUDDY) - isBuddy = TRUE; - else if (rcData->m_itemType == ITEM_REQUEST) - isRequest = TRUE; - - if(rcData) - { - delete rcData; - rcData = NULL; - } - window->winSetUserData(NULL); - //DEBUG_ASSERTCRASH(profileID > 0, ("Bad profile ID in user data!")); - - if( controlID == buttonAddID ) - { - if(!isGameSpyUser) - break; - DEBUG_LOG(("ButtonAdd was pushed\n")); - if (isRequest) - { - // ok the request - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_OKADD; - req.arg.profile.id = profileID; - TheGameSpyBuddyMessageQueue->addRequest(req); - - BuddyInfoMap *m = TheGameSpyInfo->getBuddyRequestMap(); - m->erase( profileID ); - - // DONT CHECK IN UNTIL MATT HAS REVIEWED - // if the profile ID is not from a buddy and we're okaying his request, then - // request to add him to our list automatically CLH 2-18-03 - if(!TheGameSpyInfo->isBuddy(profileID)) - { - RequestBuddyAdd(profileID, nick); - } - updateBuddyInfo(); - - } - else if (!isBuddy) - { - RequestBuddyAdd(profileID, nick); - } - } - else if( controlID == buttonDeleteID ) - { - if(!isGameSpyUser) - break; - if (isBuddy) - { - // delete the buddy - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_DELBUDDY; - req.arg.profile.id = profileID; - TheGameSpyBuddyMessageQueue->addRequest(req); - } - else - { - // delete the request - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_DENYADD; - req.arg.profile.id = profileID; - TheGameSpyBuddyMessageQueue->addRequest(req); - BuddyInfoMap *m = TheGameSpyInfo->getBuddyRequestMap(); - m->erase( profileID ); - } - BuddyInfoMap *buddies = (isBuddy)?TheGameSpyInfo->getBuddyMap():TheGameSpyInfo->getBuddyRequestMap(); - buddies->erase(profileID); - updateBuddyInfo(); - DEBUG_LOG(("ButtonDelete was pushed\n")); - PopulateLobbyPlayerListbox(); - } - else if( controlID == buttonPlayID ) - { - DEBUG_LOG(("buttonPlayID was pushed\n")); - } - else if( controlID == buttonIgnoreID ) - { - DEBUG_LOG(("%s is isGameSpyUser %d", nick.str(), isGameSpyUser)); - if( isGameSpyUser ) - { - if(TheGameSpyInfo->isSavedIgnored(profileID)) - { - TheGameSpyInfo->removeFromSavedIgnoreList(profileID); - } - else - { - TheGameSpyInfo->addToSavedIgnoreList(profileID, nick); - } - } - else - { - if(TheGameSpyInfo->isIgnored(nick)) - { - TheGameSpyInfo->removeFromIgnoreList(nick); - } - else - { - TheGameSpyInfo->addToIgnoreList(nick); - } - } - updateBuddyInfo(); - refreshIgnoreList(); - // repopulate our player listboxes now - PopulateLobbyPlayerListbox(); - } - else if( controlID == buttonStatsID ) - { - DEBUG_LOG(("buttonStatsID was pushed\n")); - GameSpyCloseOverlay(GSOVERLAY_PLAYERINFO); - SetLookAtPlayer(profileID,nick ); - GameSpyOpenOverlay(GSOVERLAY_PLAYERINFO); - PSRequest req; - req.requestType = PSRequest::PSREQUEST_READPLAYERSTATS; - req.player.id = profileID; - TheGameSpyPSMessageQueue->addRequest(req); - } - closeRightClickMenu(window); - break; - } - default: - return MSG_IGNORED; - - }//Switch - return MSG_HANDLED; -} - - -void setUnignoreText( WindowLayout *layout, AsciiString nick, GPProfile id) -{ - AsciiString controlName; - controlName.format("%s:ButtonIgnore",layout->getFilename().str()+6); - NameKeyType ID = TheNameKeyGenerator->nameToKey( controlName ); - GameWindow *win = TheWindowManager->winGetWindowFromId(layout->getFirstWindow(), ID); - if(win) - { - if(TheGameSpyInfo->isSavedIgnored(id) || TheGameSpyInfo->isIgnored(nick)) - GadgetButtonSetText(win, TheGameText->fetch("GUI:Unignore")); - } -} - -void refreshIgnoreList( void ) -{ - - - SavedIgnoreMap tempMap; - tempMap = TheGameSpyInfo->returnSavedIgnoreList(); - SavedIgnoreMap::iterator it = tempMap.begin(); - GadgetListBoxReset(listboxIgnore); - while(it != tempMap.end()) - { - UnicodeString name; - name.translate(it->second); - Int pos = GadgetListBoxAddEntryText(listboxIgnore, name, GameMakeColor(255,100,100,255),-1); - GadgetListBoxSetItemData(listboxIgnore, (void *)it->first,pos ); - ++it; - } - IgnoreList tempList; - tempList = TheGameSpyInfo->returnIgnoreList(); - IgnoreList::iterator iListIt = tempList.begin(); - while( iListIt != tempList.end()) - { - AsciiString aName = *iListIt; - UnicodeString name; - name.translate(aName); - Int pos = GadgetListBoxAddEntryText(listboxIgnore, name, GameMakeColor(255,100,100,255),-1); - GadgetListBoxSetItemData(listboxIgnore, 0,pos ); - ++iListIt; - } - -// -// GPProfile profileID = 0; -// PlayerInfoMap::iterator it = TheGameSpyInfo->getPlayerInfoMap()->find(aName); -// if (it != TheGameSpyInfo->getPlayerInfoMap()->end()) -// profileID = it->second.m_profileID; - -} diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLCustomScoreScreen.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLCustomScoreScreen.cpp deleted file mode 100644 index d0bfe524d77..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLCustomScoreScreen.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLCustomScoreScreen.cpp -// Author: Matt Campbell, December 2001 -// Description: Custom match score screen -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Lib/BaseType.h" -#include "Common/GameEngine.h" -#include "Common/NameKeyGenerator.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -#include "Common/GlobalData.h" -//#include "GameNetwork/WOL.h" -//#include "GameNetwork/WOLmenus.h" - - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLCustomScoreID = NAMEKEY_INVALID; -static NameKeyType buttonDisconnectID = NAMEKEY_INVALID; -static NameKeyType buttonLobbyID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLCustomScore = NULL; -static GameWindow *buttonDisconnect = NULL; -static GameWindow *buttonLobby = NULL; - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Status Menu */ -//------------------------------------------------------------------------------------------------- -void WOLCustomScoreScreenInit( WindowLayout *layout, void *userData ) -{ - parentWOLCustomScoreID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLCustomScoreScreen.wnd:WOLCustomScoreScreenParent" ) ); - buttonDisconnectID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLCustomScoreScreen.wnd:ButtonDisconnect" ) ); - buttonLobbyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLCustomScoreScreen.wnd:ButtonLobby" ) ); - parentWOLCustomScore = TheWindowManager->winGetWindowFromId( NULL, parentWOLCustomScoreID ); - buttonDisconnect = TheWindowManager->winGetWindowFromId( NULL, buttonDisconnectID); - buttonLobby = TheWindowManager->winGetWindowFromId( NULL, buttonLobbyID); - - /* - if (WOL::TheWOL->getState() == WOL::WOLAPI_FATAL_ERROR) - { - // We can get to the score screen even though we've been disconnected. Just hide - // any buttons that lead back into WOL. - buttonLobby->winHide( TRUE ); - } - */ - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLCustomScore ); -} // WOLCustomScoreScreenInit - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLCustomScoreScreenShutdown( WindowLayout *layout, void *userData ) -{ - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); -} // WOLCustomScoreScreenShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLCustomScoreScreenUpdate( WindowLayout * layout, void *userData) -{ - /* - if (WOL::TheWOL) - WOL::TheWOL->update(); - */ -}// WOLCustomScoreScreenUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLCustomScoreScreenInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonDisconnect, buttonDisconnectID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLCustomScoreScreenInput - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLCustomScoreScreenSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're given the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - /* - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == buttonDisconnectID ) - { - if (WOL::TheWOL->setState( WOL::WOLAPI_FATAL_ERROR )) - { - WOL::TheWOL->addCommand( WOL::WOLCOMMAND_RESET ); // don't display an error, log out, or anything - } - - } //if ( controlID == buttonDisconnect ) - else if ( controlID == buttonLobbyID ) - { - if (WOL::TheWOL->getState() != WOL::WOLAPI_FATAL_ERROR) - { - WOL::TheWOL->setScreen(WOL::WOLAPI_MENU_CUSTOMLOBBY); - WOL::TheWOL->setGameMode(WOL::WOLTYPE_CUSTOM); - WOL::TheWOL->setState( WOL::WOLAPI_LOBBY ); - WOL::TheWOL->addCommand( WOL::WOLCOMMAND_REFRESH_CHANNELS ); - } - else - { - } - } //if ( controlID == buttonDisconnect ) - */ - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLCustomScoreScreenSystem diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp deleted file mode 100644 index 81329e4f53a..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp +++ /dev/null @@ -1,2689 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLGameSetupMenu.cpp -// Author: Matt Campbell, December 2001 -// Description: WOL Game Options Menu -/////////////////////////////////////////////////////////////////////////////////////// - -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "Common/GameState.h" -#include "GameClient/GameText.h" -#include "Common/MultiplayerSettings.h" -#include "Common/PlayerTemplate.h" -#include "Common/CustomMatchPreferences.h" -#include "GameClient/AnimateWindowManager.h" -#include "GameClient/InGameUI.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Mouse.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetComboBox.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GadgetPushButton.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/MapUtil.h" -#include "GameClient/EstablishConnectionsMenu.h" -#include "GameClient/GameWindowTransitions.h" - -#include "GameNetwork/GameSpy/BuddyDefs.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameNetwork/NAT.h" -#include "GameNetwork/GUIUtil.h" -#include "GameNetwork/GameSpy/GSConfig.h" - -void WOLDisplaySlotList( void ); - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -extern std::list TheLobbyQueuedUTMs; -extern void MapSelectorTooltip(GameWindow *window, WinInstanceData *instData, UnsignedInt mouse); - - -#if defined(_DEBUG) || defined(_INTERNAL) -extern Bool g_debugSlots; -void slotListDebugLog(const char *fmt, ...) -{ - static char buf[1024]; - va_list va; - va_start( va, fmt ); - _vsnprintf(buf, 1024, fmt, va ); - va_end( va ); - buf[1023] = 0; - - DEBUG_LOG(("%s", buf)); - if (g_debugSlots) - { - UnicodeString msg; - msg.translate(buf); - TheGameSpyInfo->addText(msg, GameSpyColor[GSCOLOR_DEFAULT], NULL); - } -} -#define SLOTLIST_DEBUG_LOG(x) slotListDebugLog x -#else -#define SLOTLIST_DEBUG_LOG(x) DEBUG_LOG(x) -#endif - -void SendStatsToOtherPlayers(const GameInfo *game) -{ - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "STATS/"; - AsciiString fullStr; - PSPlayerStats fullStats = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID()); - PSPlayerStats subStats; - subStats.id = fullStats.id; - subStats.wins = fullStats.wins; - subStats.losses = fullStats.losses; - subStats.discons = fullStats.discons; - subStats.desyncs = fullStats.desyncs; - subStats.games = fullStats.games; - subStats.locale = fullStats.locale; - subStats.gamesAsRandom = fullStats.gamesAsRandom; - GetAdditionalDisconnectsFromUserFile(&subStats); - fullStr.format("%d %s", TheGameSpyInfo->getLocalProfileID(), TheGameSpyPSMessageQueue->formatPlayerKVPairs( subStats )); - req.options = fullStr.str(); - - Int localIndex = game->getLocalSlotNum(); - for (Int i=0; igetConstSlot(i); - if (slot->isHuman() && i != localIndex) - { - AsciiString hostName; - hostName.translate(slot->getName()); - req.nick = hostName.str(); - DEBUG_LOG(("SendStatsToOtherPlayers() - sending to '%s', data of\n\t'%s'\n", hostName.str(), req.options.c_str())); - TheGameSpyPeerMessageQueue->addRequest(req); - } - } -} - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -static Bool isShuttingDown = false; -static Bool buttonPushed = false; -static char *nextScreen = NULL; -static Bool raiseMessageBoxes = false; -static Bool launchGameNext = FALSE; - -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLGameSetupID = NAMEKEY_INVALID; - -static NameKeyType comboBoxPlayerID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType staticTextPlayerID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType buttonAcceptID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType comboBoxColorID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType comboBoxPlayerTemplateID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType comboBoxTeamID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; -//static NameKeyType buttonStartPositionID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, -// NAMEKEY_INVALID,NAMEKEY_INVALID, -// NAMEKEY_INVALID,NAMEKEY_INVALID, -// NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType buttonMapStartPositionID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; -static NameKeyType genericPingWindowID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType textEntryChatID = NAMEKEY_INVALID; -static NameKeyType textEntryMapDisplayID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; -static NameKeyType buttonStartID = NAMEKEY_INVALID; -static NameKeyType buttonEmoteID = NAMEKEY_INVALID; -static NameKeyType buttonSelectMapID = NAMEKEY_INVALID; -static NameKeyType windowMapID = NAMEKEY_INVALID; - -static NameKeyType windowMapSelectMapID = NAMEKEY_INVALID; -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLGameSetup = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *buttonStart = NULL; -static GameWindow *buttonSelectMap = NULL; -static GameWindow *buttonEmote = NULL; -static GameWindow *textEntryChat = NULL; -static GameWindow *textEntryMapDisplay = NULL; -static GameWindow *windowMap = NULL; - -static GameWindow *comboBoxPlayer[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; -static GameWindow *staticTextPlayer[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; -static GameWindow *buttonAccept[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -static GameWindow *comboBoxColor[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -static GameWindow *comboBoxPlayerTemplate[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -static GameWindow *comboBoxTeam[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -//static GameWindow *buttonStartPosition[MAX_SLOTS] = {NULL,NULL,NULL,NULL, -// NULL,NULL,NULL,NULL }; -// -static GameWindow *buttonMapStartPosition[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -static GameWindow *genericPingWindow[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -static const Image *pingImages[3] = { NULL, NULL, NULL }; - -WindowLayout *WOLMapSelectLayout = NULL; - -void PopBackToLobby( void ) -{ - // delete TheNAT, its no good for us anymore. - delete TheNAT; - TheNAT = NULL; - - if (TheGameSpyInfo) // this can be blown away by a disconnect on the map transfer screen - { - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - } - - DEBUG_LOG(("PopBackToLobby() - parentWOLGameSetup is %X\n", parentWOLGameSetup)); - if (parentWOLGameSetup) - { - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - } -} - -void updateMapStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[], Bool onLoadScreen = FALSE ); -void positionStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[], GameWindow *mapWindow); -void positionStartSpots(AsciiString mapName, GameWindow *buttonMapStartPositions[], GameWindow *mapWindow); -void WOLPositionStartSpots( void ) -{ - GameWindow *win = windowMap; - - if (WOLMapSelectLayout != NULL) { - win = TheWindowManager->winGetWindowFromId(NULL, windowMapSelectMapID); - - // get the controls. - NameKeyType listboxMapID = TheNameKeyGenerator->nameToKey( AsciiString("WOLMapSelectMenu.wnd:ListboxMap") ); - GameWindow *listboxMap = TheWindowManager->winGetWindowFromId( NULL, listboxMapID ); - - if (listboxMap != NULL) { - Int selected; - UnicodeString map; - - // get the selected index - GadgetListBoxGetSelected( listboxMap, &selected ); - - if( selected != -1 ) - { - - // get text of the map to load - map = GadgetListBoxGetText( listboxMap, selected, 0 ); - - - // set the map name in the global data map name - AsciiString asciiMap; - const char *mapFname = (const char *)GadgetListBoxGetItemData( listboxMap, selected ); - DEBUG_ASSERTCRASH(mapFname, ("No map item data")); - if (mapFname) { - asciiMap = mapFname; - } else { - asciiMap.translate( map ); - } - - positionStartSpots(asciiMap, buttonMapStartPosition, win); - } - } - - } else { - DEBUG_ASSERTCRASH(win != NULL, ("no map preview window")); - positionStartSpots( TheGameSpyInfo->getCurrentStagingRoom(), buttonMapStartPosition, win); - } -} -static void savePlayerInfo( void ) -{ - if (TheGameSpyGame) - { - Int slotNum = TheGameSpyGame->getLocalSlotNum(); - if (slotNum >= 0) - { - GameSpyGameSlot *slot = TheGameSpyGame->getGameSpySlot(slotNum); - if (slot) - { - // save off some prefs - CustomMatchPreferences pref; - pref.setPreferredColor(slot->getColor()); - pref.setPreferredFaction(slot->getPlayerTemplate()); - if (TheGameSpyGame->amIHost()) - { - pref.setPreferredMap(TheGameSpyGame->getMap()); - } - pref.write(); - } - } - } -} - -// Tooltips ------------------------------------------------------------------------------- - -static void playerTooltip(GameWindow *window, - WinInstanceData *instData, - UnsignedInt mouse) -{ - Int slotIdx = -1; - for (Int i=0; isetCursorTooltip( UnicodeString::TheEmptyString, -1, NULL, 1.5f ); - return; - } - - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (!game) - { - TheMouse->setCursorTooltip( UnicodeString::TheEmptyString, -1, NULL, 1.5f ); - return; - } - - GameSpyGameSlot *slot = game->getGameSpySlot(slotIdx); - if (!slot || !slot->isHuman()) - { - TheMouse->setCursorTooltip( UnicodeString::TheEmptyString, -1, NULL, 1.5f ); - return; - } - - // for tooltip, we want: - // * player name - // * ping - // * locale - // * win/loss history - // * discons/desyncs as one var - // * favorite army - // in that order. got it? good. - - UnicodeString uName = slot->getName(); - - AsciiString aName; - aName.translate(uName); - PlayerInfoMap::iterator pmIt = TheGameSpyInfo->getPlayerInfoMap()->find(aName); - if (pmIt == TheGameSpyInfo->getPlayerInfoMap()->end()) - { - TheMouse->setCursorTooltip( uName, -1, NULL, 1.5f ); - return; - } - Int profileID = pmIt->second.m_profileID; - - PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(profileID); - if (stats.id == 0) - { - TheMouse->setCursorTooltip( uName, -1, NULL, 1.5f ); - return; - } - - Bool isLocalPlayer = slot == game->getGameSpySlot(game->getLocalSlotNum()); - - AsciiString localeIdentifier; - localeIdentifier.format("WOL:Locale%2.2d", stats.locale); - UnicodeString playerInfo; - Int totalWins = 0, totalLosses = 0, totalDiscons = 0; - PerGeneralMap::iterator it; - - for (it = stats.wins.begin(); it != stats.wins.end(); ++it) - { - totalWins += it->second; - } - for (it = stats.losses.begin(); it != stats.losses.end(); ++it) - { - totalLosses += it->second; - } - for (it = stats.discons.begin(); it != stats.discons.end(); ++it) - { - totalDiscons += it->second; - } - for (it = stats.desyncs.begin(); it != stats.desyncs.end(); ++it) - { - totalDiscons += it->second; - } - UnicodeString favoriteSide; - Int numGames = 0; - Int favorite = 0; - for(it = stats.games.begin(); it != stats.games.end(); ++it) - { - if(it->second >= numGames) - { - numGames = it->second; - favorite = it->first; - } - } - if(numGames == 0) - favoriteSide = TheGameText->fetch("GUI:None"); - else if( stats.gamesAsRandom >= numGames ) - favoriteSide = TheGameText->fetch("GUI:Random"); - else - { - const PlayerTemplate *fac = ThePlayerTemplateStore->getNthPlayerTemplate(favorite); - if (fac) - { - AsciiString side; - side.format("SIDE:%s", fac->getSide().str()); - - favoriteSide = TheGameText->fetch(side); - } - } - - playerInfo.format(TheGameText->fetch("TOOLTIP:StagingPlayerInfo"), - TheGameText->fetch(localeIdentifier).str(), - slot->getPingAsInt(), - totalWins, totalLosses, totalDiscons, - favoriteSide.str()); - - UnicodeString tooltip = UnicodeString::TheEmptyString; - if (isLocalPlayer) - { - tooltip.format(TheGameText->fetch("TOOLTIP:LocalPlayer"), uName.str()); - } - else - { - // not us - if (TheGameSpyInfo->getBuddyMap()->find(profileID) != TheGameSpyInfo->getBuddyMap()->end()) - { - // buddy - tooltip.format(TheGameText->fetch("TOOLTIP:BuddyPlayer"), uName.str()); - } - else - { - if (profileID) - { - // non-buddy profiled player - tooltip.format(TheGameText->fetch("TOOLTIP:ProfiledPlayer"), uName.str()); - } - else - { - // non-profiled player - tooltip.format(TheGameText->fetch("TOOLTIP:GenericPlayer"), uName.str()); - } - } - } - - tooltip.concat(playerInfo); - - TheMouse->setCursorTooltip( tooltip, -1, NULL, 1.5f ); // the text and width are the only params used. the others are the default values. -} - -void gameAcceptTooltip(GameWindow *window, WinInstanceData *instData, UnsignedInt mouse) -{ - Int x, y; - x = LOLONGTOSHORT(mouse); - y = HILONGTOSHORT(mouse); - - Int winPosX, winPosY, winWidth, winHeight; - - window->winGetScreenPosition(&winPosX, &winPosY); - - window->winGetSize(&winWidth, &winHeight); - - if ((x > winPosX && x < (winPosX + winWidth)) && (y > winPosY && y < (winPosY + winHeight))) - { - TheMouse->setCursorTooltip(TheGameText->fetch("TOOLTIP:GameAcceptance"), -1, NULL); - } -} - -void pingTooltip(GameWindow *window, WinInstanceData *instData, UnsignedInt mouse) -{ - Int x, y; - x = LOLONGTOSHORT(mouse); - y = HILONGTOSHORT(mouse); - - - Int winPosX, winPosY, winWidth, winHeight; - - window->winGetScreenPosition(&winPosX, &winPosY); - - window->winGetSize(&winWidth, &winHeight); - - if ((x > winPosX && x < (winPosX + winWidth)) && (y > winPosY && y < (winPosY + winHeight))) - { - TheMouse->setCursorTooltip(TheGameText->fetch("TOOLTIP:ConnectionSpeed"), -1, NULL); - } -} - -//external declarations of the Gadgets the callbacks can use -GameWindow *listboxGameSetupChat = NULL; -NameKeyType listboxGameSetupChatID = NAMEKEY_INVALID; - -static void handleColorSelection(int index) -{ - GameWindow *combo = comboBoxColor[index]; - Int color, selIndex; - GadgetComboBoxGetSelectedPos(combo, &selIndex); - color = (Int)GadgetComboBoxGetItemData(combo, selIndex); - - GameInfo *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - - if (myGame) - { - GameSlot * slot = myGame->getSlot(index); - if (color == slot->getColor()) - return; - - if (color >= -1 && color < TheMultiplayerSettings->getNumColors()) - { - Bool colorAvailable = TRUE; - if(color != -1 ) - { - for(Int i=0; i getSlot(i); - if(color == checkSlot->getColor() && slot != checkSlot) - { - colorAvailable = FALSE; - break; - } - } - } - if(!colorAvailable) - return; - } - - slot->setColor(color); - - if (TheGameSpyInfo->amIHost()) - { - // send around a new slotlist - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - else - { - // request the color from the host - if (!slot->isPlayer(TheGameSpyInfo->getLocalName())) - return; - - AsciiString options; - options.format("Color=%d", color); - AsciiString hostName; - hostName.translate(myGame->getSlot(0)->getName()); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "REQ/"; - req.nick = hostName.str(); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - } - } -} - -static void handlePlayerTemplateSelection(int index) -{ - GameWindow *combo = comboBoxPlayerTemplate[index]; - Int playerTemplate, selIndex; - GadgetComboBoxGetSelectedPos(combo, &selIndex); - playerTemplate = (Int)GadgetComboBoxGetItemData(combo, selIndex); - GameInfo *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - - if (myGame) - { - GameSlot * slot = myGame->getSlot(index); - if (playerTemplate == slot->getPlayerTemplate()) - return; - - Int oldTemplate = slot->getPlayerTemplate(); - slot->setPlayerTemplate(playerTemplate); - - if (oldTemplate == PLAYERTEMPLATE_OBSERVER) - { - // was observer, so populate color & team with all, and enable - GadgetComboBoxSetSelectedPos(comboBoxColor[index], 0); - GadgetComboBoxSetSelectedPos(comboBoxTeam[index], 0); - slot->setStartPos(-1); - } - else if (playerTemplate == PLAYERTEMPLATE_OBSERVER) - { - // is becoming observer, so populate color & team with random only, and disable - GadgetComboBoxSetSelectedPos(comboBoxColor[index], 0); - GadgetComboBoxSetSelectedPos(comboBoxTeam[index], 0); - slot->setStartPos(-1); - } - - - if (TheGameSpyInfo->amIHost()) - { - // send around a new slotlist - myGame->resetAccepted(); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - else - { - // request the playerTemplate from the host - AsciiString options; - options.format("PlayerTemplate=%d", playerTemplate); - AsciiString hostName; - hostName.translate(myGame->getSlot(0)->getName()); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "REQ/"; - req.nick = hostName.str(); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - } - } -} - - -static void handleStartPositionSelection(Int player, int startPos) -{ - GameSpyStagingRoom *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - - if (myGame) - { - GameSpyGameSlot * slot = myGame->getGameSpySlot(player); - if (!slot) - return; - - if (startPos == slot->getStartPos()) - return; - Bool skip = FALSE; - if (startPos < 0) - { - skip = TRUE; - } - - if(!skip) - { - Bool isAvailable = TRUE; - for(Int i = 0; i < MAX_SLOTS; ++i) - { - if(i != player && myGame->getSlot(i)->getStartPos() == startPos) - { - isAvailable = FALSE; - break; - } - } - if( !isAvailable ) - return; - } - slot->setStartPos(startPos); - - if (myGame->amIHost()) - { - // send around a new slotlist - myGame->resetAccepted(); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - else - { - // request the color from the host - if (AreSlotListUpdatesEnabled()) - { - // request the playerTemplate from the host - AsciiString options; - options.format("StartPos=%d", slot->getStartPos()); - AsciiString hostName; - hostName.translate(myGame->getSlot(0)->getName()); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "REQ/"; - req.nick = hostName.str(); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - - } - } - } -} - - - -static void handleTeamSelection(int index) -{ - GameWindow *combo = comboBoxTeam[index]; - Int team, selIndex; - GadgetComboBoxGetSelectedPos(combo, &selIndex); - team = (Int)GadgetComboBoxGetItemData(combo, selIndex); - GameInfo *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - - if (myGame) - { - GameSlot * slot = myGame->getSlot(index); - if (team == slot->getTeamNumber()) - return; - - slot->setTeamNumber(team); - - if (TheGameSpyInfo->amIHost()) - { - // send around a new slotlist - myGame->resetAccepted(); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - else - { - // request the team from the host - AsciiString options; - options.format("Team=%d", team); - AsciiString hostName; - hostName.translate(myGame->getSlot(0)->getName()); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "REQ/"; - req.nick = hostName.str(); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - } - } -} - - -static void StartPressed(void) -{ - Bool isReady = TRUE; - Bool allHaveMap = TRUE; - Int playerCount = 0; - Int humanCount = 0; - GameSpyStagingRoom *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - if (!myGame) - return; - - // see if everyone's accepted and count the number of players in the game - UnicodeString mapDisplayName; - const MapMetaData *mapData = TheMapCache->findMap( myGame->getMap() ); - Bool willTransfer = TRUE; - if (mapData) - { - mapDisplayName.format(L"%ls", mapData->m_displayName.str()); - willTransfer = !mapData->m_isOfficial; - } - else - { - mapDisplayName.format(L"%hs", myGame->getMap().str()); - willTransfer = WouldMapTransfer(myGame->getMap()); - } - for( int i = 0; i < MAX_SLOTS; i++ ) - { - if ((myGame->getSlot(i)->isAccepted() == FALSE) && (myGame->getSlot(i)->isHuman() == TRUE)) - { - isReady = FALSE; - if (!myGame->getSlot(i)->hasMap() && !willTransfer) - { - UnicodeString msg; - msg.format(TheGameText->fetch("GUI:PlayerNoMap"), myGame->getSlot(i)->getName().str(), mapDisplayName.str()); - TheGameSpyInfo->addText(msg, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - allHaveMap = FALSE; - } - } - if(myGame->getSlot(i)->isOccupied() && myGame->getSlot(i)->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - if (myGame->getSlot(i)->isHuman()) - humanCount++; - playerCount++; - } - } - - // Check for too many players - const MapMetaData *md = TheMapCache->findMap( myGame->getMap() ); - if (!md || md->m_numPlayers < playerCount) - { - if (myGame->amIHost()) - { - UnicodeString text; - text.format(TheGameText->fetch("LAN:TooManyPlayers"), (md)?md->m_numPlayers:0); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - return; - } - - // Check for observer + AI players - if (TheGlobalData->m_netMinPlayers && !humanCount) - { - if (myGame->amIHost()) - { - UnicodeString text = TheGameText->fetch("GUI:NeedHumanPlayers"); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - return; - } - - // Check for too few players - if (playerCount < TheGlobalData->m_netMinPlayers) - { - if (myGame->amIHost()) - { - UnicodeString text; - text.format(TheGameText->fetch("LAN:NeedMorePlayers"),playerCount); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - return; - } - - // Check for too few teams - int numRandom = 0; - std::set teams; - for (i=0; igetSlot(i); - if (slot && slot->isOccupied() && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - if (slot->getTeamNumber() >= 0) - { - teams.insert(slot->getTeamNumber()); - } - else - { - ++numRandom; - } - } - } - if (numRandom + teams.size() < TheGlobalData->m_netMinPlayers) - { - if (myGame->amIHost()) - { - UnicodeString text; - text.format(TheGameText->fetch("LAN:NeedMoreTeams")); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - return; - } - - if (numRandom + teams.size() < 2) - { - UnicodeString text; - text.format(TheGameText->fetch("GUI:SandboxMode")); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - - if(isReady) - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STARTGAME; - TheGameSpyPeerMessageQueue->addRequest(req); - - SendStatsToOtherPlayers(myGame); - - // we've started, there's no going back - // i.e. disable the back button. - buttonBack->winEnable(FALSE); - GameWindow *buttonBuddy = TheWindowManager->winGetWindowFromId(NULL, NAMEKEY("GameSpyGameOptionsMenu.wnd:ButtonCommunicator")); - if (buttonBuddy) - buttonBuddy->winEnable(FALSE); - GameSpyCloseOverlay(GSOVERLAY_BUDDY); - - *TheGameSpyGame = *myGame; - TheGameSpyGame->startGame(0); - } - else if (allHaveMap) - { - TheGameSpyInfo->addText(TheGameText->fetch("GUI:NotifiedStartIntent"), GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMROOM; - req.UTM.isStagingRoom = TRUE; - req.id = "HWS/"; - req.options = "true"; - TheGameSpyPeerMessageQueue->addRequest(req); - } - -}//void StartPressed(void) - -//------------------------------------------------------------------------------------------------- -/** Update options on screen */ -//------------------------------------------------------------------------------------------------- -void WOLDisplayGameOptions( void ) -{ - GameSpyStagingRoom *theGame = TheGameSpyInfo->getCurrentStagingRoom(); - if (!parentWOLGameSetup || !theGame) - return; - - const GameSlot *localSlot = NULL; - if (theGame->getLocalSlotNum() >= 0) - localSlot = theGame->getConstSlot(theGame->getLocalSlotNum()); - - const MapMetaData *md = TheMapCache->findMap(TheGameSpyInfo->getCurrentStagingRoom()->getMap()); - if (md && localSlot && localSlot->hasMap()) - { - GadgetStaticTextSetText(textEntryMapDisplay, md->m_displayName); - } - else - { - AsciiString s = TheGameSpyInfo->getCurrentStagingRoom()->getMap(); - if (s.reverseFind('\\')) - { - s = s.reverseFind('\\') + 1; - } - UnicodeString mapDisplay; - mapDisplay.translate(s); - GadgetStaticTextSetText(textEntryMapDisplay, mapDisplay); - } - WOLPositionStartSpots(); - updateMapStartSpots(TheGameSpyInfo->getCurrentStagingRoom(), buttonMapStartPosition); -} - -// ----------------------------------------------------------------------------------------- -// The Bad munkee slot list displaying function -//------------------------------------------------------------------------------------------------- -void WOLDisplaySlotList( void ) -{ - if (!parentWOLGameSetup || !TheGameSpyInfo->getCurrentStagingRoom()) - return; - - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (!game->isInGame()) - return; - - DEBUG_ASSERTCRASH(!game->getConstSlot(0)->isOpen(), ("Open host!")); - - UpdateSlotList( game, comboBoxPlayer, comboBoxColor, - comboBoxPlayerTemplate, comboBoxTeam, buttonAccept, buttonStart, buttonMapStartPosition ); - - WOLDisplayGameOptions(); - - for (Int i=0; igetGameSpySlot(i); - if (slot && slot->isHuman()) - { - if (i == game->getLocalSlotNum()) - { - // set up my own ping... - slot->setPingString(TheGameSpyInfo->getPingString()); - } - - if (genericPingWindow[i]) - { - genericPingWindow[i]->winHide(FALSE); - Int ping = slot->getPingAsInt(); - if (ping < TheGameSpyConfig->getPingCutoffGood()) - { - genericPingWindow[i]->winSetEnabledImage(0, pingImages[0]); - } - else if (ping < TheGameSpyConfig->getPingCutoffBad()) - { - genericPingWindow[i]->winSetEnabledImage(0, pingImages[1]); - } - else - { - genericPingWindow[i]->winSetEnabledImage(0, pingImages[2]); - } - } - } - else - { - if (genericPingWindow[i]) - genericPingWindow[i]->winHide(TRUE); - } - } -} - -//------------------------------------------------------------------------------------------------- -/** Initialize the Gadgets Options Menu */ -//------------------------------------------------------------------------------------------------- -void InitWOLGameGadgets( void ) -{ - GameSpyStagingRoom *theGameInfo = TheGameSpyInfo->getCurrentStagingRoom(); - pingImages[0] = TheMappedImageCollection->findImageByName("Ping03"); - pingImages[1] = TheMappedImageCollection->findImageByName("Ping02"); - pingImages[2] = TheMappedImageCollection->findImageByName("Ping01"); - DEBUG_ASSERTCRASH(pingImages[0], ("Can't find ping image!")); - DEBUG_ASSERTCRASH(pingImages[1], ("Can't find ping image!")); - DEBUG_ASSERTCRASH(pingImages[2], ("Can't find ping image!")); - - //Initialize the gadget IDs - parentWOLGameSetupID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:GameSpyGameOptionsMenuParent" ) ); - buttonBackID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:ButtonBack" ) ); - buttonStartID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:ButtonStart" ) ); - textEntryChatID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:TextEntryChat" ) ); - textEntryMapDisplayID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:TextEntryMapDisplay" ) ); - listboxGameSetupChatID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:ListboxChatWindowGameSpyGameSetup" ) ); - buttonEmoteID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:ButtonEmote" ) ); - buttonSelectMapID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:ButtonSelectMap" ) ); - windowMapID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:MapWindow" ) ); - windowMapSelectMapID = TheNameKeyGenerator->nameToKey(AsciiString("WOLMapSelectMenu.wnd:WinMapPreview")); - - NameKeyType staticTextTitleID = NAMEKEY("GameSpyGameOptionsMenu.wnd:StaticTextGameName"); - - // Initialize the pointers to our gadgets - parentWOLGameSetup = TheWindowManager->winGetWindowFromId( NULL, parentWOLGameSetupID ); - buttonEmote = TheWindowManager->winGetWindowFromId( parentWOLGameSetup,buttonEmoteID ); - buttonSelectMap = TheWindowManager->winGetWindowFromId( parentWOLGameSetup,buttonSelectMapID ); - buttonStart = TheWindowManager->winGetWindowFromId( parentWOLGameSetup,buttonStartID ); - buttonBack = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, buttonBackID); - listboxGameSetupChat = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, listboxGameSetupChatID ); - textEntryChat = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, textEntryChatID ); - textEntryMapDisplay = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, textEntryMapDisplayID ); - windowMap = TheWindowManager->winGetWindowFromId( parentWOLGameSetup,windowMapID ); - DEBUG_ASSERTCRASH(windowMap, ("Could not find the parentWOLGameSetup.wnd:MapWindow" )); - - //Added By Sadullah Nader - //Tooltip Function set - windowMap->winSetTooltipFunc(MapSelectorTooltip); - // - - GameWindow *staticTextTitle = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, staticTextTitleID ); - if (staticTextTitle) - { - GadgetStaticTextSetText(staticTextTitle, TheGameSpyGame->getGameName()); - } - - if (!theGameInfo) - { - DEBUG_CRASH(("No staging room!")); - return; - } - - for (Int i = 0; i < MAX_SLOTS; i++) - { - AsciiString tmpString; - tmpString.format("GameSpyGameOptionsMenu.wnd:ComboBoxPlayer%d", i); - comboBoxPlayerID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - comboBoxPlayer[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, comboBoxPlayerID[i] ); - GadgetComboBoxReset(comboBoxPlayer[i]); - comboBoxPlayer[i]->winSetTooltipFunc(playerTooltip); - - tmpString.format("GameSpyGameOptionsMenu.wnd:StaticTextPlayer%d", i); - staticTextPlayerID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - staticTextPlayer[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, staticTextPlayerID[i] ); - staticTextPlayer[i]->winSetTooltipFunc(playerTooltip); - if (TheGameSpyInfo->amIHost()) - staticTextPlayer[i]->winHide(TRUE); - - if(i==0 && TheGameSpyInfo->amIHost()) - { - UnicodeString uName; - uName.translate(TheGameSpyInfo->getLocalName()); - GadgetComboBoxAddEntry(comboBoxPlayer[i],uName,GameSpyColor[GSCOLOR_PLAYER_OWNER]); - GadgetComboBoxSetSelectedPos(comboBoxPlayer[0],0); - } - else - { - GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:Open"),GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:Closed"),GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:EasyAI"),GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:MediumAI"),GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:HardAI"),GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - GadgetComboBoxSetSelectedPos(comboBoxPlayer[i],0); - } - - tmpString.format("GameSpyGameOptionsMenu.wnd:ComboBoxColor%d", i); - comboBoxColorID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - comboBoxColor[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, comboBoxColorID[i] ); - DEBUG_ASSERTCRASH(comboBoxColor[i], ("Could not find the comboBoxColor[%d]",i )); - PopulateColorComboBox(i, comboBoxColor, theGameInfo); - GadgetComboBoxSetSelectedPos(comboBoxColor[i], 0); - - tmpString.format("GameSpyGameOptionsMenu.wnd:ComboBoxPlayerTemplate%d", i); - comboBoxPlayerTemplateID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - comboBoxPlayerTemplate[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, comboBoxPlayerTemplateID[i] ); - DEBUG_ASSERTCRASH(comboBoxPlayerTemplate[i], ("Could not find the comboBoxPlayerTemplate[%d]",i )); - PopulatePlayerTemplateComboBox(i, comboBoxPlayerTemplate, theGameInfo, theGameInfo->getAllowObservers()); - - tmpString.format("GameSpyGameOptionsMenu.wnd:ComboBoxTeam%d", i); - comboBoxTeamID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - comboBoxTeam[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, comboBoxTeamID[i] ); - DEBUG_ASSERTCRASH(comboBoxTeam[i], ("Could not find the comboBoxTeam[%d]",i )); - PopulateTeamComboBox(i, comboBoxTeam, theGameInfo); - - tmpString.format("GameSpyGameOptionsMenu.wnd:ButtonAccept%d", i); - buttonAcceptID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - buttonAccept[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, buttonAcceptID[i] ); - DEBUG_ASSERTCRASH(buttonAccept[i], ("Could not find the buttonAccept[%d]",i )); - buttonAccept[i]->winSetTooltipFunc(gameAcceptTooltip); - - tmpString.format("GameSpyGameOptionsMenu.wnd:GenericPing%d", i); - genericPingWindowID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - genericPingWindow[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, genericPingWindowID[i] ); - DEBUG_ASSERTCRASH(genericPingWindow[i], ("Could not find the genericPingWindow[%d]",i )); - genericPingWindow[i]->winSetTooltipFunc(pingTooltip); - -// tmpString.format("GameSpyGameOptionsMenu.wnd:ButtonStartPosition%d", i); -// buttonStartPositionID[i] = TheNameKeyGenerator->nameToKey( tmpString ); -// buttonStartPosition[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, buttonStartPositionID[i] ); -// DEBUG_ASSERTCRASH(buttonStartPosition[i], ("Could not find the ButtonStartPosition[%d]",i )); - - tmpString.format("GameSpyGameOptionsMenu.wnd:ButtonMapStartPosition%d", i); - buttonMapStartPositionID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - buttonMapStartPosition[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, buttonMapStartPositionID[i] ); - DEBUG_ASSERTCRASH(buttonMapStartPosition[i], ("Could not find the ButtonMapStartPosition[%d]",i )); - -// if (buttonStartPosition[i]) -// buttonStartPosition[i]->winHide(TRUE); - - if(i !=0 && buttonAccept[i]) - buttonAccept[i]->winHide(TRUE); - } - - if( buttonAccept[0] ) - buttonAccept[0]->winEnable(TRUE); - - if (buttonBack != NULL) - { - buttonBack->winEnable(TRUE); - } - //GadgetButtonSetEnabledColor(buttonAccept[0], GameSpyColor[GSCOLOR_ACCEPT_TRUE]); -} - -void DeinitWOLGameGadgets( void ) -{ - parentWOLGameSetup = NULL; - buttonEmote = NULL; - buttonSelectMap = NULL; - buttonStart = NULL; - buttonBack = NULL; - listboxGameSetupChat = NULL; - textEntryChat = NULL; - textEntryMapDisplay = NULL; - windowMap = NULL; -// GameWindow *staticTextTitle = NULL; - for (Int i = 0; i < MAX_SLOTS; i++) - { - comboBoxPlayer[i] = NULL; - staticTextPlayer[i] = NULL; - comboBoxColor[i] = NULL; - comboBoxPlayerTemplate[i] = NULL; - comboBoxTeam[i] = NULL; - buttonAccept[i] = NULL; -// buttonStartPosition[i] = NULL; - buttonMapStartPosition[i] = NULL; - genericPingWindow[i] = NULL; - } -} - -static Bool initDone = false; -UnsignedInt lastSlotlistTime = 0; -UnsignedInt enterTime = 0; -Bool initialAcceptEnable = FALSE; -//------------------------------------------------------------------------------------------------- -/** Initialize the Lan Game Options Menu */ -//------------------------------------------------------------------------------------------------- -void WOLGameSetupMenuInit( WindowLayout *layout, void *userData ) -{ - if (TheGameSpyGame && TheGameSpyGame->isGameInProgress()) - { - TheGameSpyGame->setGameInProgress(FALSE); - - // check if we were disconnected - Int disconReason; - if (TheGameSpyInfo->isDisconnectedAfterGameStart(&disconReason)) - { - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", disconReason); - UnicodeString title, body; - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheGameSpyInfo->reset(); - DEBUG_LOG(("WOLGameSetupMenuInit() - game was in progress, and we were disconnected, so pop immediate back to main menu\n")); - TheShell->popImmediate(); - return; - } - - // If we init while the game is in progress, we are really returning to the menu - // after the game. So, we pop the menu and go back to the lobby. Whee! - DEBUG_LOG(("WOLGameSetupMenuInit() - game was in progress, so pop immediate back to lobby\n")); - TheShell->popImmediate(); - if (TheGameSpyPeerMessageQueue && TheGameSpyPeerMessageQueue->isConnected()) - { - DEBUG_LOG(("We're still connected, so pushing back on the lobby\n")); - TheShell->push("Menus/WOLCustomLobby.wnd", TRUE); - } - return; - } - TheGameSpyInfo->setCurrentGroupRoom(0); - - if (TheNAT != NULL) { - delete TheNAT; - TheNAT = NULL; - } - - nextScreen = NULL; - buttonPushed = false; - isShuttingDown = false; - launchGameNext = FALSE; - - //initialize the gadgets - EnableSlotListUpdates(FALSE); - InitWOLGameGadgets(); - EnableSlotListUpdates(TRUE); - TheGameSpyInfo->registerTextWindow(listboxGameSetupChat); - - //The dialog needs to react differently depending on whether it's the host or not. - TheMapCache->updateCache(); - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - GameSpyGameSlot *hostSlot = game->getGameSpySlot(0); - hostSlot->setAccept(); - if (TheGameSpyInfo->amIHost()) - { - OptionPreferences natPref; - CustomMatchPreferences customPref; - hostSlot->setColor( customPref.getPreferredColor() ); - hostSlot->setPlayerTemplate( customPref.getPreferredFaction() ); - hostSlot->setNATBehavior((FirewallHelperClass::FirewallBehaviorType)natPref.getFirewallBehavior()); - hostSlot->setPingString(TheGameSpyInfo->getPingString()); - game->setMap(customPref.getPreferredMap()); - - for (Int i=1; igetGameSpySlot(i); - slot->setState( SLOT_OPEN ); - } - - AsciiString lowerMap = customPref.getPreferredMap(); - lowerMap.toLower(); - std::map::iterator it = TheMapCache->find(lowerMap); - if (it != TheMapCache->end()) - { - hostSlot->setMapAvailability(TRUE); - game->setMapCRC( it->second.m_CRC ); - game->setMapSize( it->second.m_filesize ); - - game->adjustSlotsForMap(); // BGC- adjust the slots for the new map. - } - - - WOLDisplaySlotList(); - WOLDisplayGameOptions(); - } - else - { - OptionPreferences natPref; - CustomMatchPreferences customPref; - AsciiString options; - PeerRequest req; - UnicodeString uName = hostSlot->getName(); - AsciiString aName; - aName.translate(uName); - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "REQ/"; - req.nick = aName.str(); - options.format("PlayerTemplate=%d", customPref.getPreferredFaction()); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - options.format("Color=%d", customPref.getPreferredColor()); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - options.format("NAT=%d", natPref.getFirewallBehavior()); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - options.format("Ping=%s", TheGameSpyInfo->getPingString().str()); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - - game->setMapCRC( game->getMapCRC() ); // force a recheck - game->setMapSize( game->getMapSize() ); // of if we have the map - - for (Int i = 0; i < MAX_SLOTS; ++i) - { - //I'm a client, disable the controls I can't touch. - comboBoxPlayer[i]->winEnable(FALSE); - - comboBoxColor[i]->winEnable(FALSE); - comboBoxPlayerTemplate[i]->winEnable(FALSE); - comboBoxTeam[i]->winEnable(FALSE); -// buttonStartPosition[i]->winEnable(FALSE); - buttonMapStartPosition[i]->winEnable(FALSE); - - } - buttonStart->winSetText(TheGameText->fetch("GUI:Accept")); - buttonStart->winEnable( FALSE ); - buttonSelectMap->winEnable( FALSE ); - initialAcceptEnable = FALSE; - } - - // Show the Menu - layout->hide( FALSE ); - - // Make sure the text fields are clear - GadgetListBoxReset( listboxGameSetupChat ); - GadgetTextEntrySetText(textEntryChat, UnicodeString::TheEmptyString); - - initDone = true; - TheGameSpyInfo->setGameOptions(); - //TheShell->registerWithAnimateManager(parentWOLGameSetup, WIN_ANIMATION_SLIDE_TOP, TRUE); - WOLPositionStartSpots(); - - lastSlotlistTime = 0; - enterTime = timeGetTime(); - - // Set Keyboard to chat entry - TheWindowManager->winSetFocus( textEntryChat ); - raiseMessageBoxes = true; - TheTransitionHandler->setGroup("GameSpyGameOptionsMenuFade"); -}// void WOLGameSetupMenuInit( WindowLayout *layout, void *userData ) - -//------------------------------------------------------------------------------------------------- -/** This is called when a shutdown is complete for this menu */ -//------------------------------------------------------------------------------------------------- -static void shutdownComplete( WindowLayout *layout ) -{ - - isShuttingDown = false; - - // hide the layout - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout, (nextScreen != NULL) ); - - if (nextScreen != NULL) - { - if (!TheGameSpyPeerMessageQueue || !TheGameSpyPeerMessageQueue->isConnected()) - { - DEBUG_LOG(("GameSetup shutdownComplete() - skipping push because we're disconnected\n")); - } - else - { - TheShell->push(nextScreen); - } - } - - /* - if (launchGameNext) - { - TheGameSpyGame->launchGame(); - TheGameSpyInfo->leaveStagingRoom(); - } - */ - - nextScreen = NULL; - -} // end if - -//------------------------------------------------------------------------------------------------- -/** GameSpy Game Options menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLGameSetupMenuShutdown( WindowLayout *layout, void *userData ) -{ - TheGameSpyInfo->unregisterTextWindow(listboxGameSetupChat); - - if( WOLMapSelectLayout ) - { - WOLMapSelectLayout->destroyWindows(); - WOLMapSelectLayout->deleteInstance(); - WOLMapSelectLayout = NULL; - } - parentWOLGameSetup = NULL; - EnableSlotListUpdates(FALSE); - DeinitWOLGameGadgets(); - if (TheEstablishConnectionsMenu != NULL) - { - TheEstablishConnectionsMenu->endMenu(); - } - initDone = false; - - isShuttingDown = true; - - // if we are shutting down for an immediate pop, skip the animations - Bool popImmediate = *(Bool *)userData; - if( popImmediate ) - { - - shutdownComplete( layout ); - return; - - } //end if - - TheShell->reverseAnimatewindow(); - - RaiseGSMessageBox(); - TheTransitionHandler->reverse("GameSpyGameOptionsMenuFade"); -} // void WOLGameSetupMenuShutdown( WindowLayout *layout, void *userData ) - -static void fillPlayerInfo(const PeerResponse *resp, PlayerInfo *info) -{ - info->m_name = resp->nick.c_str(); - info->m_profileID = resp->player.profileID; - info->m_flags = resp->player.flags; - info->m_wins = resp->player.wins; - info->m_losses = resp->player.losses; - info->m_locale = resp->locale.c_str(); - info->m_rankPoints= resp->player.rankPoints; - info->m_side = resp->player.side; - info->m_preorder = resp->player.preorder; -} - -//------------------------------------------------------------------------------------------------- -/** Lan Game Options menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData) -{ - // We'll only be successful if we've requested to - if(isShuttingDown && TheShell->isAnimFinished() && TheTransitionHandler->isFinished()) - { - shutdownComplete(layout); - return; - } - - if (raiseMessageBoxes) - { - RaiseGSMessageBox(); - raiseMessageBoxes = false; - } - - if (TheShell->isAnimFinished() && !buttonPushed && TheGameSpyPeerMessageQueue) - { - HandleBuddyResponses(); - HandlePersistentStorageResponses(); - - if (TheGameSpyGame && TheGameSpyGame->isGameInProgress()) - { - if (TheGameSpyInfo->isDisconnectedAfterGameStart(NULL)) - { - return; // already been disconnected, so don't worry. - } - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - PeerResponse resp; - while (allowedMessages-- && !sawImportantMessage && TheGameSpyPeerMessageQueue->getResponse( resp )) - { - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - - // check for scorescreen - NameKeyType listboxChatWindowScoreScreenID = NAMEKEY("ScoreScreen.wnd:ListboxChatWindowScoreScreen"); - GameWindow *listboxChatWindowScoreScreen = TheWindowManager->winGetWindowFromId( NULL, listboxChatWindowScoreScreenID ); - if (listboxChatWindowScoreScreen) - { - GadgetListBoxAddEntryText(listboxChatWindowScoreScreen, TheGameText->fetch(disconMunkee), - GameSpyColor[GSCOLOR_DEFAULT], -1); - } - else - { - // still ingame - TheInGameUI->message(disconMunkee); - } - TheGameSpyInfo->markAsDisconnectedAfterGameStart(resp.discon.reason); - } - } - } - - return; // if we're in game, all we care about is if we've been disconnected from the chat server - } - - Bool isHosting = TheGameSpyInfo->amIHost(); // only while in game setup screen - isHosting = isHosting || (TheGameSpyGame && TheGameSpyGame->isInGame() && TheGameSpyGame->amIHost()); // while in game - if (!isHosting && !lastSlotlistTime && timeGetTime() > enterTime + 10000) - { - // don't do this if we're disconnected - if (TheGameSpyPeerMessageQueue->isConnected()) - { - // haven't seen ourselves - buttonPushed = true; - DEBUG_LOG(("Haven't seen ourselves in slotlist\n")); - if (TheGameSpyGame) - TheGameSpyGame->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - GSMessageBoxOk(TheGameText->fetch("GUI:HostLeftTitle"), TheGameText->fetch("GUI:HostLeft")); - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - } - return; - } - - if (TheNAT != NULL) { - NATStateType NATState = TheNAT->update(); - if (NATState == NATSTATE_DONE) - { - //launchGameNext = TRUE; - //TheShell->pop(); - TheGameSpyGame->launchGame(); - if (TheGameSpyInfo) // this can be blown away by a disconnect on the map transfer screen - TheGameSpyInfo->leaveStagingRoom(); - return; - } - else if (NATState == NATSTATE_FAILED) - { - // Just back out. This cleans up some slot list problems - buttonPushed = true; - - // delete TheNAT, its no good for us anymore. - delete TheNAT; - TheNAT = NULL; - - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:NATNegotiationFailed")); - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - return; - } - } - - PeerResponse resp; - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - while (allowedMessages-- && !sawImportantMessage) - { - - if (!TheLobbyQueuedUTMs.empty()) - { - DEBUG_LOG(("Got response from queued lobby UTM list\n")); - resp = TheLobbyQueuedUTMs.front(); - TheLobbyQueuedUTMs.pop_front(); - } - else if (TheGameSpyPeerMessageQueue->getResponse( resp )) - { - DEBUG_LOG(("Got response from message queue\n")); - } - else - { - break; - } - - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_FAILEDTOHOST: - { - // oops - we've not heard from the qr server. bail. - TheGameSpyInfo->addText(TheGameText->fetch("GUI:GSFailedToHost"), GameSpyColor[GSCOLOR_DEFAULT], NULL); - } - break; - case PeerResponse::PEERRESPONSE_GAMESTART: - { - sawImportantMessage = TRUE; - GameSpyStagingRoom *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - if (!myGame || !myGame->isInGame()) - break; - - if (!TheGameSpyGame) - break; - - SendStatsToOtherPlayers(TheGameSpyGame); - - // we've started, there's no going back - // i.e. disable the back button. - buttonBack->winEnable(FALSE); - GameWindow *buttonBuddy = TheWindowManager->winGetWindowFromId(NULL, NAMEKEY("GameSpyGameOptionsMenu.wnd:ButtonCommunicator")); - if (buttonBuddy) - buttonBuddy->winEnable(FALSE); - GameSpyCloseOverlay(GSOVERLAY_BUDDY); - - *TheGameSpyGame = *myGame; - TheGameSpyGame->startGame(0); - } - break; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDFLAGS: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - WOLDisplaySlotList(); - } - break; - case PeerResponse::PEERRESPONSE_PLAYERINFO: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - WOLDisplaySlotList(); - // send out new slotlist if I'm host - TheGameSpyInfo->setGameOptions(); - } - break; - case PeerResponse::PEERRESPONSE_PLAYERJOIN: - { - if (resp.player.roomType != StagingRoom) - { - break; - } - sawImportantMessage = TRUE; - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - - if (p.m_profileID) - { - if (TheGameSpyPSMessageQueue->findPlayerStatsByID(p.m_profileID).id == 0) - { - PSRequest req; - req.requestType = PSRequest::PSREQUEST_READPLAYERSTATS; - req.player.id = p.m_profileID; - TheGameSpyPSMessageQueue->addRequest(req); - } - } - - // check if we have room for the dude - GameInfo *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (TheGameSpyInfo->amIHost() && game) - { - if (TheNAT) - { - // ditch him - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "KICK/"; - req.nick = p.m_name.str(); - req.options = "GameStarted"; - TheGameSpyPeerMessageQueue->addRequest(req); - } - else - { - // look for room for him - // See if there's room - // First get the number of players currently in the room. - Int numPlayers = 0; - for (Int player = 0; player < MAX_SLOTS; ++player) - { - if (game->getSlot(player)->isOccupied() && - game->getSlot(player)->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - ++numPlayers; - } - } - - // now get the number of starting spots on the map. - Int numStartingSpots = MAX_SLOTS; - const MapMetaData *md = TheMapCache->findMap(game->getMap()); - if (md != NULL) - { - numStartingSpots = md->m_numPlayers; - } - - Int openSlotIndex = -1; - for (Int i=0; igetConstSlot(i); - if (slot && slot->isOpen()) - { - openSlotIndex = i; - break; - } - } - - if (openSlotIndex >= 0) - { - // add him - GameSlot newSlot; - UnicodeString uName; - uName.translate(p.m_name); - newSlot.setState(SLOT_PLAYER, uName); - newSlot.setIP(ntohl(resp.player.IP)); - game->setSlot( openSlotIndex, newSlot ); - game->resetAccepted(); // BGC - need to unaccept everyone if someone joins the game. - } - else - { - // ditch him - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "KICK/"; - req.nick = p.m_name.str(); - req.options = "GameFull"; - TheGameSpyPeerMessageQueue->addRequest(req); - } - - // send out new slotlist if I'm host - TheGameSpyInfo->setGameOptions(); - } - } - WOLDisplaySlotList(); - } - break; - - case PeerResponse::PEERRESPONSE_PLAYERLEFT: - { - sawImportantMessage = TRUE; - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->playerLeftGroupRoom(resp.nick.c_str()); - - if (TheGameSpyGame && TheGameSpyGame->isGameInProgress()) - { - break; - } - - if (TheNAT == NULL) // don't update slot list if we're trying to start a game - { - - GameInfo *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (game && TheGameSpyInfo->amIHost()) - { - Int idx = game->getSlotNum(resp.nick.c_str()); - if (idx >= 0) - { - game->getSlot(idx)->setState(SLOT_OPEN); - game->resetAccepted(); // BGC - need to unaccept everyone if someone leaves the game. - } - } - - // send out new slotlist if I'm host - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - - if (game && !TheGameSpyInfo->amIHost()) - { - Int idx = game->getSlotNum(resp.nick.c_str()); - if (idx == 0) - { - // host left - buttonPushed = true; - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - GSMessageBoxOk(TheGameText->fetch("GUI:HostLeftTitle"), TheGameText->fetch("GUI:HostLeft")); - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - } - } - - } - } - break; - - case PeerResponse::PEERRESPONSE_MESSAGE: - { - TheGameSpyInfo->addChat(resp.nick.c_str(), resp.message.profileID, - UnicodeString(resp.text.c_str()), !resp.message.isPrivate, resp.message.isAction, listboxGameSetupChat); - } - break; - - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheGameSpyInfo->reset(); - TheShell->pop(); - } - - case PeerResponse::PEERRESPONSE_ROOMUTM: - { - sawImportantMessage = TRUE; -#if defined(_DEBUG) || defined(_INTERNAL) - if (g_debugSlots) - { - DEBUG_LOG(("About to process a room UTM. Command is '%s', command options is '%s'\n", - resp.command.c_str(), resp.commandOptions.c_str())); - } -#endif - if (!strcmp(resp.command.c_str(), "SL")) - { - // slotlist - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - Bool isValidSlotList = game && game->getSlot(0) && game->getSlot(0)->isPlayer( resp.nick.c_str() ) && !TheGameSpyInfo->amIHost(); - if (!isValidSlotList) - { - SLOTLIST_DEBUG_LOG(("Not a valid slotlist\n")); - if (!game) - { - SLOTLIST_DEBUG_LOG(("No game!\n")); - } - else - { - if (!game->getSlot(0)) - { - SLOTLIST_DEBUG_LOG(("No slot 0!\n")); - } - else - { - if (TheGameSpyInfo->amIHost()) - { - SLOTLIST_DEBUG_LOG(("I'm the host!\n")); - } - else - { - SLOTLIST_DEBUG_LOG(("Not from the host! isHuman:%d, name:'%ls', sender:'%s'\n", - game->getSlot(0)->isHuman(), game->getSlot(0)->getName().str(), - resp.nick.c_str())); - } - } - } - } - else // isValidSlotList - { - Int oldLocalSlotNum = (game->isInGame()) ? game->getLocalSlotNum() : -1; - Bool wasInGame = oldLocalSlotNum >= 0; - AsciiString oldMap = game->getMap(); - UnsignedInt oldMapCRC, newMapCRC; - oldMapCRC = game->getMapCRC(); - - AsciiString options = resp.commandOptions.c_str(); - options.trim(); - UnsignedShort ports[MAX_SLOTS]; - UnsignedInt ips[MAX_SLOTS]; - Int i; - for (i=0; igetConstSlot(i)) - { - ips[i] = game->getConstSlot(i)->getIP(); - ports[i] = game->getConstSlot(i)->getPort(); - } - else - { - ips[i] = 0; - ports[i] = 0; - } - } - Bool optionsOK = ParseAsciiStringToGameInfo(game, options.str()); - if (TheNAT) - { - for (i=0; igetSlot(i)) - { -#ifdef DEBUG_LOGGING - UnsignedShort newPort = game->getConstSlot(i)->getPort(); - UnsignedInt newIP = game->getConstSlot(i)->getIP(); - DEBUG_ASSERTLOG(newIP == ips[i], ("IP was different for player %d (%X --> %X)\n", - i, ips[i], newIP)); - DEBUG_ASSERTLOG(newPort == ports[i], ("Port was different for player %d (%d --> %d)\n", - i, ports[i], newPort)); -#endif - game->getSlot(i)->setPort(ports[i]); - game->getSlot(i)->setIP(ips[i]); - } - } - } - Int newLocalSlotNum = (game->isInGame()) ? game->getLocalSlotNum() : -1; - Bool isInGame = newLocalSlotNum >= 0; - if (!optionsOK) - { - SLOTLIST_DEBUG_LOG(("Options are bad! bailing!\n")); - break; - } - else - { - SLOTLIST_DEBUG_LOG(("Options are good, local slot is %d\n", newLocalSlotNum)); - if (!isInGame) - { - SLOTLIST_DEBUG_LOG(("Not in game; players are:\n")); - for (Int i=0; igetGameSpySlot(i); - if (slot && slot->isHuman()) - { - UnicodeString munkee; - munkee.format(L"\t%d: %ls", i, slot->getName().str()); - SLOTLIST_DEBUG_LOG(("%ls\n", munkee.str())); - } - } - } - } - WOLDisplaySlotList(); - - // if I changed map availability, send it across - newMapCRC = game->getMapCRC(); - if (isInGame) - { - lastSlotlistTime = timeGetTime(); - if ( (oldMapCRC ^ newMapCRC) || (!wasInGame && isInGame) ) - { - // it changed. send it - UnicodeString hostName = TheGameSpyInfo->getCurrentStagingRoom()->getSlot(0)->getName(); - AsciiString asciiName; - asciiName.translate(hostName); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "MAP"; - req.nick = asciiName.str(); - req.options = (game->getSlot(newLocalSlotNum)->hasMap())?"1":"0"; - TheGameSpyPeerMessageQueue->addRequest(req); - if (!game->getSlot(newLocalSlotNum)->hasMap()) - { - UnicodeString text; - UnicodeString mapDisplayName; - const MapMetaData *mapData = TheMapCache->findMap( game->getMap() ); - Bool willTransfer = TRUE; - if (mapData) - { - mapDisplayName.format(L"%ls", mapData->m_displayName.str()); - willTransfer = !mapData->m_isOfficial; - } - else - { - mapDisplayName.format(L"%hs", TheGameState->getMapLeafName(game->getMap()).str()); - willTransfer = WouldMapTransfer(game->getMap()); - } - if (willTransfer) - text.format(TheGameText->fetch("GUI:LocalPlayerNoMapWillTransfer"), mapDisplayName.str()); - else - text.format(TheGameText->fetch("GUI:LocalPlayerNoMap"), mapDisplayName.str()); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - } - if (!initialAcceptEnable) - { - buttonStart->winEnable( TRUE ); - initialAcceptEnable = TRUE; - } - } - else - { - if (lastSlotlistTime) - { - // can't see ourselves - buttonPushed = true; - DEBUG_LOG(("Can't see ourselves in slotlist %s\n", options.str())); - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSKicked")); - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - } - } - } - } - else if (!strcmp(resp.command.c_str(), "HWS")) - { - // host wants to start - GameInfo *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (game && game->isInGame() && game->getSlot(0) && game->getSlot(0)->isPlayer( resp.nick.c_str() )) - { - Int slotNum = game->getLocalSlotNum(); - GameSlot *slot = game->getSlot(slotNum); - if (slot && (slot->isAccepted() == false)) - { - TheGameSpyInfo->addText(TheGameText->fetch("GUI:HostWantsToStart"), GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - } - } - else if (!stricmp(resp.command.c_str(), "NAT")) - { - if (TheNAT != NULL) { - TheNAT->processGlobalMessage(-1, resp.commandOptions.c_str()); - } - } - else if (!stricmp(resp.command.c_str(), "Pings")) - { - if (!TheGameSpyInfo->amIHost()) - { - AsciiString pings = resp.commandOptions.c_str(); - AsciiString token; - for (Int i=0; igetCurrentStagingRoom()->getGameSpySlot(i); - if (pings.nextToken(&token, ",")) - { - token.trim(); - slot->setPingString(token); - } - else - { - slot->setPingString(""); - } - } - } - } - } - break; - - case PeerResponse::PEERRESPONSE_PLAYERUTM: - { - sawImportantMessage = TRUE; - if (!strcmp(resp.command.c_str(), "STATS")) - { - PSPlayerStats stats = TheGameSpyPSMessageQueue->parsePlayerKVPairs(resp.commandOptions.c_str()); - if (stats.id && (TheGameSpyPSMessageQueue->findPlayerStatsByID(stats.id).id == 0)) - TheGameSpyPSMessageQueue->trackPlayerStats(stats); - break; - } - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (game) - { - Int slotNum = game->getSlotNum(resp.nick.c_str()); - if ((slotNum >= 0) && (slotNum < MAX_SLOTS) && (!stricmp(resp.command.c_str(), "NAT"))) { - // this is a command for NAT negotiations, pass if off to TheNAT - if (TheNAT != NULL) { - TheNAT->processGlobalMessage(slotNum, resp.commandOptions.c_str()); - } - } - if (slotNum == 0 && !TheGameSpyInfo->amIHost()) - { - if (!strcmp(resp.command.c_str(), "KICK")) - { - // oops - we've been kicked. bail. - buttonPushed = true; - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - UnicodeString message = TheGameText->fetch("GUI:GSKicked"); - AsciiString commandMessage = resp.commandOptions.c_str(); - commandMessage.trim(); - DEBUG_LOG(("We were kicked: reason was '%s'\n", resp.commandOptions.c_str())); - if (commandMessage == "GameStarted") - { - message = TheGameText->fetch("GUI:GSKickedGameStarted"); - } - else if (commandMessage == "GameFull") - { - message = TheGameText->fetch("GUI:GSKickedGameFull"); - } - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), message); - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - } - } - else if (slotNum > 0 && TheGameSpyInfo->amIHost()) - { - if (!strcmp(resp.command.c_str(), "accept")) - { - game->getSlot(slotNum)->setAccept(); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - else if (!strcmp(resp.command.c_str(), "MAP")) - { - Bool hasMap = atoi(resp.commandOptions.c_str()); - game->getSlot(slotNum)->setMapAvailability(hasMap); - if (!hasMap) - { - // tell the host the user doesn't have the map - UnicodeString mapDisplayName; - const MapMetaData *mapData = TheMapCache->findMap( game->getMap() ); - Bool willTransfer = TRUE; - if (mapData) - { - mapDisplayName.format(L"%ls", mapData->m_displayName.str()); - willTransfer = !mapData->m_isOfficial; - } - else - { - mapDisplayName.format(L"%hs", game->getMap().str()); - willTransfer = WouldMapTransfer(game->getMap()); - } - UnicodeString text; - if (willTransfer) - text.format(TheGameText->fetch("GUI:PlayerNoMapWillTransfer"), game->getSlot(slotNum)->getName().str(), mapDisplayName.str()); - else - text.format(TheGameText->fetch("GUI:PlayerNoMap"), game->getSlot(slotNum)->getName().str(), mapDisplayName.str()); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - WOLDisplaySlotList(); - } - else if (!strcmp(resp.command.c_str(), "REQ")) - { - AsciiString options = resp.commandOptions.c_str(); - options.trim(); - - Bool change = false; - Bool shouldUnaccept = false; - AsciiString key; - options.nextToken(&key, "="); - Int val = atoi(options.str()+1); - UnsignedInt uVal = atoi(options.str()+1); - DEBUG_LOG(("GameOpt request: key=%s, val=%s from player %d\n", key.str(), options.str()+1, slotNum)); - - GameSpyGameSlot *slot = game->getGameSpySlot(slotNum); - if (!slot) - break; - - if (key == "Color") - { - if (val >= -1 && val < TheMultiplayerSettings->getNumColors() && val != slot->getColor() && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - Bool colorAvailable = TRUE; - if(val != -1 ) - { - for(Int i=0; i getSlot(i); - if(val == checkSlot->getColor() && slot != checkSlot) - { - colorAvailable = FALSE; - break; - } - } - } - if(colorAvailable) - slot->setColor(val); - change = true; - } - else - { - DEBUG_LOG(("Rejecting invalid color %d\n", val)); - } - } - else if (key == "PlayerTemplate") - { - if (val >= PLAYERTEMPLATE_MIN && val < ThePlayerTemplateStore->getPlayerTemplateCount() && val != slot->getPlayerTemplate()) - { - slot->setPlayerTemplate(val); - if (val == PLAYERTEMPLATE_OBSERVER) - { - slot->setColor(-1); - slot->setStartPos(-1); - slot->setTeamNumber(-1); - } - change = true; - shouldUnaccept = true; - } - else - { - DEBUG_LOG(("Rejecting invalid PlayerTemplate %d\n", val)); - } - } - else if (key == "StartPos") - { - if (val >= -1 && val < MAX_SLOTS && val != slot->getStartPos() && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - Bool startPosAvailable = TRUE; - if(val != -1) - { - for(Int i=0; i getSlot(i); - if(val == checkSlot->getStartPos() && slot != checkSlot) - { - startPosAvailable = FALSE; - break; - } - } - } - if(startPosAvailable) - slot->setStartPos(val); - change = true; - shouldUnaccept = true; - } - else - { - DEBUG_LOG(("Rejecting invalid startPos %d\n", val)); - } - } - else if (key == "Team") - { - if (val >= -1 && val < MAX_SLOTS/2 && val != slot->getTeamNumber() && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - slot->setTeamNumber(val); - change = true; - shouldUnaccept = true; - } - else - { - DEBUG_LOG(("Rejecting invalid team %d\n", val)); - } - } - else if (key == "IP") - { - if (uVal != slot->getIP()) - { - DEBUG_LOG(("setting IP of player %ls from 0x%08x to be 0x%08x", slot->getName().str(), slot->getIP(), uVal)); - slot->setIP(uVal); - change = true; - shouldUnaccept = true; - } - else - { - DEBUG_LOG(("Rejecting invalid IP %d\n", uVal)); - } - } - else if (key == "NAT") - { - if ((val >= FirewallHelperClass::FIREWALL_MIN) && - (val <= FirewallHelperClass::FIREWALL_MAX)) - { - slot->setNATBehavior((FirewallHelperClass::FirewallBehaviorType)val); - DEBUG_LOG(("Setting NAT behavior to %d for player %d\n", val, slotNum)); - change = true; - } - else - { - DEBUG_LOG(("Rejecting invalid NAT behavior %d from player %d\n", val, slotNum)); - } - } - else if (key == "Ping") - { - slot->setPingString(options.str()+1); - TheGameSpyInfo->setGameOptions(); - DEBUG_LOG(("Setting ping string to %s for player %d\n", options.str()+1, slotNum)); - } - - if (change) - { - if (shouldUnaccept) - game->resetAccepted(); - - TheGameSpyInfo->setGameOptions(); - - WOLDisplaySlotList(); - DEBUG_LOG(("Slot value is color=%d, PlayerTemplate=%d, startPos=%d, team=%d, IP=0x%8.8X\n", - slot->getColor(), slot->getPlayerTemplate(), slot->getStartPos(), slot->getTeamNumber(), slot->getIP())); - DEBUG_LOG(("Slot list updated to %s\n", GameInfoToAsciiString(game).str())); - } - } - } - } - } - break; - - } - } - - - } -}// void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData) - -//------------------------------------------------------------------------------------------------- -/** Lan Game Options menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLGameSetupMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - /* - switch( msg ) - { - - //------------------------------------------------------------------------------------------------- - case GWM_RIGHT_UP: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - NameKeyType controlID = (NameKeyType)control->winGetWindowId(); - DEBUG_LOG(("GWM_RIGHT_UP for control %d(%s)\n", controlID, TheNameKeyGenerator->keyToName(controlID).str())); - break; - } - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - if (buttonPushed) - break; - - switch( key ) - { - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - } // end if - // don't let key fall through anywhere else - return MSG_HANDLED; - } // end escape - } // end switch( key ) - } // end char - } // end switch( msg ) - */ - return MSG_IGNORED; -}//WindowMsgHandledType WOLGameSetupMenuInput( GameWindow *window, UnsignedInt msg, - - -// Slash commands ------------------------------------------------------------------------- -//extern "C" { -//int getQR2HostingStatus(void); -//} -extern int isThreadHosting; - -Bool handleGameSetupSlashCommands(UnicodeString uText) -{ - AsciiString message; - message.translate(uText); - - if (message.getCharAt(0) != '/') - { - return FALSE; // not a slash command - } - - AsciiString remainder = message.str() + 1; - AsciiString token; - remainder.nextToken(&token); - token.toLower(); - - if (token == "host") - { - UnicodeString s; - s.format(L"Hosting qr2:%d thread:%d", 0, isThreadHosting); - TheGameSpyInfo->addText(s, GameSpyColor[GSCOLOR_DEFAULT], NULL); - return TRUE; // was a slash command - } - else if (token == "me" && uText.getLength()>4) - { - TheGameSpyInfo->sendChat(UnicodeString(uText.str()+4), TRUE, NULL); - return TRUE; // was a slash command - } -#if defined(_DEBUG) || defined(_INTERNAL) - else if (token == "slots") - { - g_debugSlots = !g_debugSlots; - TheGameSpyInfo->addText(UnicodeString(L"Toggled SlotList debug"), GameSpyColor[GSCOLOR_DEFAULT], NULL); - return TRUE; // was a slash command - } - else if (token == "discon") - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_LOGOUT; - TheGameSpyPeerMessageQueue->addRequest( req ); - return TRUE; - } -#endif // defined(_DEBUG) || defined(_INTERNAL) - - return FALSE; // not a slash command -} - -static Int getNextSelectablePlayer(Int start) -{ - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (!game->amIHost()) - return -1; - for (Int j=start; jgetGameSpySlot(j); - if (slot && slot->getStartPos() == -1 && - ( (j==game->getLocalSlotNum() && game->getConstSlot(j)->getPlayerTemplate()!=PLAYERTEMPLATE_OBSERVER) - || slot->isAI())) - { - return j; - } - } - return -1; -} - -static Int getFirstSelectablePlayer(const GameInfo *game) -{ - const GameSlot *slot = game->getConstSlot(game->getLocalSlotNum()); - if (!game->amIHost() || slot && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - return game->getLocalSlotNum(); - - for (Int i=0; igetConstSlot(i); - if (slot && slot->isAI()) - return i; - } - - return game->getLocalSlotNum(); -} - -//------------------------------------------------------------------------------------------------- -/** WOL Game Options menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - static buttonCommunicatorID = NAMEKEY_INVALID; - switch( msg ) - { - //------------------------------------------------------------------------------------------------- - case GWM_CREATE: - { - buttonCommunicatorID = NAMEKEY("GameSpyGameOptionsMenu.wnd:ButtonCommunicator"); - break; - } // case GWM_DESTROY: - //------------------------------------------------------------------------------------------------- - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - //------------------------------------------------------------------------------------------------- - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - //------------------------------------------------------------------------------------------------- - case GCM_SELECTED: - { - if (!initDone) - break; - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - GameSpyStagingRoom *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - for (Int i = 0; i < MAX_SLOTS; i++) - { - if (controlID == comboBoxColorID[i]) - { - handleColorSelection(i); - } - else if (controlID == comboBoxPlayerTemplateID[i]) - { - handlePlayerTemplateSelection(i); - } - else if (controlID == comboBoxTeamID[i]) - { - handleTeamSelection(i); - } - else if( controlID == comboBoxPlayerID[i] && TheGameSpyInfo->amIHost() ) - { - // We don't have anything that'll happen if we click on ourselves - if(i == myGame->getLocalSlotNum()) - break; - // Get - Int pos = -1; - GadgetComboBoxGetSelectedPos(comboBoxPlayer[i], &pos); - if( pos != SLOT_PLAYER && pos >= 0) - { - if( myGame->getSlot(i)->getState() == SLOT_PLAYER ) - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - AsciiString aName; - aName.translate(myGame->getSlot(i)->getName()); - req.nick = aName.str(); - req.id = "KICK/"; - req.options = "true"; - TheGameSpyPeerMessageQueue->addRequest(req); - - UnicodeString name = myGame->getSlot(i)->getName(); - myGame->getSlot(i)->setState(SlotState(pos)); - myGame->resetAccepted(); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - //TheLAN->OnPlayerLeave(name); - } - else if( myGame->getSlot(i)->getState() != pos ) - { - Bool wasAI = (myGame->getSlot(i)->isAI()); - myGame->getSlot(i)->setState(SlotState(pos)); - Bool isAI = (myGame->getSlot(i)->isAI()); - myGame->resetAccepted(); - if (wasAI ^ isAI) - PopulatePlayerTemplateComboBox(i, comboBoxPlayerTemplate, myGame, wasAI && myGame->getAllowObservers()); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - } - break; - } - } - }// case GCM_SELECTED: - //------------------------------------------------------------------------------------------------- - case GBM_SELECTED: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - static buttonCommunicatorID = NAMEKEY("GameSpyGameOptionsMenu.wnd:ButtonCommunicator"); - - if ( controlID == buttonBackID ) - { - savePlayerInfo(); - if( WOLMapSelectLayout ) - { - WOLMapSelectLayout->destroyWindows(); - WOLMapSelectLayout->deleteInstance(); - WOLMapSelectLayout = NULL; - } - - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - //peerLeaveRoom(TheGameSpyChat->getPeer(), StagingRoom, NULL); - TheGameSpyInfo->leaveStagingRoom(); - buttonPushed = true; - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - - } //if ( controlID == buttonBack ) - else if ( controlID == buttonCommunicatorID ) - { - GameSpyToggleOverlay( GSOVERLAY_BUDDY ); - - } - else if ( controlID == buttonEmoteID ) - { - // read the user's input - txtInput.set(GadgetTextEntryGetText( textEntryChat )); - // Clear the text entry line - GadgetTextEntrySetText(textEntryChat, UnicodeString::TheEmptyString); - // Clean up the text (remove leading/trailing chars, etc) - txtInput.trim(); - // Echo the user's input to the chat window - if (!txtInput.isEmpty()) - TheGameSpyInfo->sendChat(txtInput, FALSE, NULL); // 'emote' button is now carriage-return - } //if ( controlID == buttonEmote ) - else if ( controlID == buttonSelectMapID ) - { - WOLMapSelectLayout = TheWindowManager->winCreateLayout( "Menus/WOLMapSelectMenu.wnd" ); - WOLMapSelectLayout->runInit(); - WOLMapSelectLayout->hide( FALSE ); - WOLMapSelectLayout->bringForward(); - } - else if ( controlID == buttonStartID ) - { - savePlayerInfo(); - if (TheGameSpyInfo->amIHost()) - { - StartPressed(); - } - else - { - //I'm the Client... send an accept message to the host. - GameSlot *localSlot = TheGameSpyInfo->getCurrentStagingRoom()->getSlot(TheGameSpyInfo->getCurrentStagingRoom()->getLocalSlotNum()); - if (localSlot) - { - localSlot->setAccept(); - } - UnicodeString hostName = TheGameSpyInfo->getCurrentStagingRoom()->getSlot(0)->getName(); - AsciiString asciiName; - asciiName.translate(hostName); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "accept"; - req.nick = asciiName.str(); - req.options = "true"; - TheGameSpyPeerMessageQueue->addRequest(req); - //peerSetReady( PEER, PEERTrue ); - WOLDisplaySlotList(); - } - } - else - { - for (Int i = 0; i < MAX_SLOTS; i++) - { - if (controlID == buttonMapStartPositionID[i]) - { - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - Int playerIdxInPos = -1; - for (Int j=0; jgetGameSpySlot(j); - if (slot && slot->getStartPos() == i) - { - playerIdxInPos = j; - break; - } - } - if (playerIdxInPos >= 0) - { - GameSpyGameSlot *slot = game->getGameSpySlot(playerIdxInPos); - if (playerIdxInPos == game->getLocalSlotNum() || (game->amIHost() && slot && slot->isAI())) - { - // it's one of my type. Try to change it. - Int nextPlayer = getNextSelectablePlayer(playerIdxInPos+1); - handleStartPositionSelection(playerIdxInPos, -1); - if (nextPlayer >= 0) - { - handleStartPositionSelection(nextPlayer, i); - } - } - } - else - { - // nobody in the slot - put us in - Int nextPlayer = getNextSelectablePlayer(0); - if (nextPlayer < 0) - nextPlayer = getFirstSelectablePlayer(game); - handleStartPositionSelection(nextPlayer, i); - } - } - } - } - - - break; - }// case GBM_SELECTED: - //------------------------------------------------------------------------------------------------- - case GBM_SELECTED_RIGHT: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - for (Int i = 0; i < MAX_SLOTS; i++) - { - if (controlID == buttonMapStartPositionID[i]) - { - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - Int playerIdxInPos = -1; - for (Int j=0; jgetGameSpySlot(j); - if (slot && slot->getStartPos() == i) - { - playerIdxInPos = j; - break; - } - } - if (playerIdxInPos >= 0) - { - GameSpyGameSlot *slot = game->getGameSpySlot(playerIdxInPos); - if (playerIdxInPos == game->getLocalSlotNum() || (game->amIHost() && slot && slot->isAI())) - { - // it's one of my type. Remove it. - handleStartPositionSelection(playerIdxInPos, -1); - } - } - } - } - break; - } - - //------------------------------------------------------------------------------------------------- - case GEM_EDIT_DONE: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - // Take the user's input and echo it into the chat window as well as - // send it to the other clients on the lan - if ( controlID == textEntryChatID ) - { - - // read the user's input - txtInput.set(GadgetTextEntryGetText( textEntryChat )); - // Clear the text entry line - GadgetTextEntrySetText(textEntryChat, UnicodeString::TheEmptyString); - // Clean up the text (remove leading/trailing chars, etc) - txtInput.trim(); - // Echo the user's input to the chat window - if (!txtInput.isEmpty()) - { - if (!handleGameSetupSlashCommands(txtInput)) - { - TheGameSpyInfo->sendChat(txtInput, false, NULL); - } - } - - }// if ( controlID == textEntryChatID ) - break; - } - //------------------------------------------------------------------------------------------------- - default: - return MSG_IGNORED; - }//Switch - return MSG_HANDLED; -}//WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg, - - diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLadderScreen.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLadderScreen.cpp deleted file mode 100644 index ae044416076..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLadderScreen.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: ReplayMenu.cpp ///////////////////////////////////////////////////////////////////// -// Author: Chris The masta Huybregts, December 2001 -// Description: Replay Menus -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/MessageBox.h" - -// window ids ------------------------------------------------------------------------------------- -static NameKeyType parentWindowID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; -static NameKeyType windowLadderID = NAMEKEY_INVALID; - - -// window pointers -------------------------------------------------------------------------------- -static GameWindow *parentWindow = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *windowLadder = NULL; - - -//------------------------------------------------------------------------------------------------- -/** Initialize the single player menu */ -//------------------------------------------------------------------------------------------------- -void WOLLadderScreenInit( WindowLayout *layout, void *userData ) -{ - TheShell->showShellMap(TRUE); - - // get ids for our children controls - parentWindowID = TheNameKeyGenerator->nameToKey( AsciiString("WOLLadderScreen.wnd:LadderParent") ); - buttonBackID = TheNameKeyGenerator->nameToKey( AsciiString("WOLLadderScreen.wnd:ButtonBack") ); - windowLadderID = TheNameKeyGenerator->nameToKey( AsciiString("WOLLadderScreen.wnd:WindowLadder") ); - - parentWindow = TheWindowManager->winGetWindowFromId( NULL, parentWindowID ); - buttonBack = TheWindowManager->winGetWindowFromId( parentWindow, buttonBackID ); - windowLadder = TheWindowManager->winGetWindowFromId( parentWindow, windowLadderID ); - - //Load the listbox shiznit -// PopulateReplayFileListbox(listboxReplayFiles); - - // show menu - layout->hide( FALSE ); - - // set keyboard focus to main parent - TheWindowManager->winSetFocus( parentWindow ); - -} // end ReplayMenuInit - -//------------------------------------------------------------------------------------------------- -/** single player menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLLadderScreenShutdown( WindowLayout *layout, void *userData ) -{ - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); - -} // end ReplayMenuShutdown - -//------------------------------------------------------------------------------------------------- -/** single player menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLLadderScreenUpdate( WindowLayout *layout, void *userData ) -{ - -} // end ReplayMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** Replay menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLadderScreenInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; - -} // end ReplayMenuInput - -//------------------------------------------------------------------------------------------------- -/** single player menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLadderScreenSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CREATE: - { - - - break; - - } // end create - - //--------------------------------------------------------------------------------------------- - case GWM_DESTROY: - { - - break; - - } // end case - - // -------------------------------------------------------------------------------------------- - case GWM_INPUT_FOCUS: - { - - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - - } // end input - //--------------------------------------------------------------------------------------------- - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if( controlID == buttonBackID ) - { - - // thou art directed to return to thy known solar system immediately! - TheShell->pop(); - - } // end else if - - break; - - } // end selected - - default: - return MSG_IGNORED; - } // end switch - - return MSG_HANDLED; -} // end ReplayMenuSystem - diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp deleted file mode 100644 index 63d64aa6780..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp +++ /dev/null @@ -1,1857 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLLobbyMenu.cpp -// Author: Chris Huybregts, November 2001 -// Description: WOL Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "Common/GameState.h" -#include "Common/MiniLog.h" -#include "Common/MultiplayerSettings.h" -#include "Common/PlayerTemplate.h" -#include "Common/CustomMatchPreferences.h" -#include "Common/Version.h" -#include "GameClient/AnimateWindowManager.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GameClient.h" -#include "GameClient/Shell.h" -#include "GameClient/ShellHooks.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetComboBox.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetSlider.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GameText.h" -#include "GameClient/MessageBox.h" -#include "GameClient/Mouse.h" -#include "GameClient/Display.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameClient/GameWindowTransitions.h" - -#include "GameLogic/GameLogic.h" - -#include "GameClient/LanguageFilter.h" -#include "GameNetwork/GameSpy/BuddyDefs.h" -#include "GameNetwork/GameSpy/GSConfig.h" -#include "GameNetwork/GameSpy/LadderDefs.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" -#include "GameNetwork/GameSpy/LobbyUtils.h" -#include "GameNetwork/RankPointValue.h" - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif -void refreshGameList( Bool forceRefresh = FALSE ); -void refreshPlayerList( Bool forceRefresh = FALSE ); - -#ifdef DEBUG_LOGGING -#define PERF_TEST -static LogClass s_perfLog("Perf.txt"); -#define PERF_LOG(x) s_perfLog.log x -#else // DEBUG_LOGGING -#define PERF_LOG(x) {} -#endif // DEBUG_LOGGING - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -static Bool isShuttingDown = false; -static Bool buttonPushed = false; -static char *nextScreen = NULL; -static Bool raiseMessageBoxes = false; -static time_t gameListRefreshTime = 0; -static const time_t gameListRefreshInterval = 10000; -static time_t playerListRefreshTime = 0; -static const time_t playerListRefreshInterval = 5000; - -void setUnignoreText( WindowLayout *layout, AsciiString nick, GPProfile id); -static void doSliderTrack(GameWindow *control, Int val); -Bool DontShowMainMenu = FALSE; -enum { COLUMN_PLAYERNAME = 2 }; - -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLLobbyID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; -static NameKeyType buttonHostID = NAMEKEY_INVALID; -static NameKeyType buttonRefreshID = NAMEKEY_INVALID; -static NameKeyType buttonJoinID = NAMEKEY_INVALID; -static NameKeyType buttonBuddyID = NAMEKEY_INVALID; -static NameKeyType buttonEmoteID = NAMEKEY_INVALID; -static NameKeyType textEntryChatID = NAMEKEY_INVALID; -static NameKeyType listboxLobbyPlayersID = NAMEKEY_INVALID; -static NameKeyType listboxLobbyChatID = NAMEKEY_INVALID; -static NameKeyType comboLobbyGroupRoomsID = NAMEKEY_INVALID; -//static NameKeyType // sliderChatAdjustID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLLobby = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *buttonHost = NULL; -static GameWindow *buttonRefresh = NULL; -static GameWindow *buttonJoin = NULL; -static GameWindow *buttonBuddy = NULL; -static GameWindow *buttonEmote = NULL; -static GameWindow *textEntryChat = NULL; -static GameWindow *listboxLobbyPlayers = NULL; -static GameWindow *listboxLobbyChat = NULL; -static GameWindow *comboLobbyGroupRooms = NULL; -static GameWindow *parent = NULL; - -static Int groupRoomToJoin = 0; -static Int initialGadgetDelay = 2; -static Bool justEntered = FALSE; - -#if defined(_INTERNAL) || defined(_DEBUG) -Bool g_fakeCRC = FALSE; -Bool g_debugSlots = FALSE; -#endif - -std::list TheLobbyQueuedUTMs; - -// Slash commands ------------------------------------------------------------------------- -//extern "C" { -//int getQR2HostingStatus(void); -//} -extern int isThreadHosting; - -Bool handleLobbySlashCommands(UnicodeString uText) -{ - AsciiString message; - message.translate(uText); - - if (message.getCharAt(0) != '/') - { - return FALSE; // not a slash command - } - - AsciiString remainder = message.str() + 1; - AsciiString token; - remainder.nextToken(&token); - token.toLower(); - - if (token == "host") - { - UnicodeString s; - s.format(L"Hosting qr2:%d thread:%d", 0, isThreadHosting); - TheGameSpyInfo->addText(s, GameSpyColor[GSCOLOR_DEFAULT], NULL); - return TRUE; // was a slash command - } - else if (token == "me" && uText.getLength()>4) - { - TheGameSpyInfo->sendChat(UnicodeString(uText.str()+4), TRUE, listboxLobbyPlayers); - return TRUE; // was a slash command - } - else if (token == "refresh") - { - // Added 2/19/03 added the game refresh - refreshGameList(TRUE); - refreshPlayerList(TRUE); - return TRUE; // was a slash command - } - /* - if (token == "togglegamelist") - { - NameKeyType buttonID = NAMEKEY("WOLCustomLobby.wnd:ButtonGameListToggle"); - GameWindow *button = TheWindowManager->winGetWindowFromId(parent, buttonID); - if (button) - { - button->winHide(!button->winIsHidden()); - } - return TRUE; // was a slash command - } - else if (token == "adjustchat") - { - NameKeyType sliderID = NAMEKEY("WOLCustomLobby.wnd:SliderChatAdjust"); - GameWindow *slider = TheWindowManager->winGetWindowFromId(parent, sliderID); - if (slider) - { - slider->winHide(!slider->winIsHidden()); - } - return TRUE; // was a slash command - } - */ -#if defined(_INTERNAL) || defined(_DEBUG) - else if (token == "fakecrc") - { - g_fakeCRC = !g_fakeCRC; - TheGameSpyInfo->addText(UnicodeString(L"Toggled CRC fakery"), GameSpyColor[GSCOLOR_DEFAULT], NULL); - return TRUE; // was a slash command - } - else if (token == "slots") - { - g_debugSlots = !g_debugSlots; - TheGameSpyInfo->addText(UnicodeString(L"Toggled SlotList debug"), GameSpyColor[GSCOLOR_DEFAULT], NULL); - return TRUE; // was a slash command - } -#endif - - return FALSE; // not a slash command -} - -static Bool s_tryingToHostOrJoin = FALSE; -void SetLobbyAttemptHostJoin(Bool start) -{ - s_tryingToHostOrJoin = start; -} - -// Tooltips ------------------------------------------------------------------------------- - -static void playerTooltip(GameWindow *window, - WinInstanceData *instData, - UnsignedInt mouse) -{ - Int x, y, row, col; - x = LOLONGTOSHORT(mouse); - y = HILONGTOSHORT(mouse); - - GadgetListBoxGetEntryBasedOnXY(window, x, y, row, col); - - if (row == -1 || col == -1) - { - TheMouse->setCursorTooltip( UnicodeString::TheEmptyString);//TheGameText->fetch("TOOLTIP:PlayersInLobby") ); - return; - } - - UnicodeString uName = GadgetListBoxGetText(window, row, 2); - AsciiString aName; - aName.translate(uName); - - PlayerInfoMap::iterator it = TheGameSpyInfo->getPlayerInfoMap()->find(aName); - PlayerInfo *info = &(it->second); - Bool isLocalPlayer = (TheGameSpyInfo->getLocalName().compareNoCase(info->m_name) == 0); - - if (col == 0) - { - if (info->m_preorder) - { - TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:LobbyOfficersClub") ); - } - else - { - TheMouse->setCursorTooltip( UnicodeString::TheEmptyString); - } - return; - } - - AsciiString playerLocale = info->m_locale; - AsciiString localeIdentifier; - localeIdentifier.format("WOL:Locale%2.2d", atoi(playerLocale.str())); - Int playerWins = info->m_wins; - Int playerLosses = info->m_losses; - UnicodeString playerInfo; - playerInfo.format(TheGameText->fetch("TOOLTIP:PlayerInfo"), TheGameText->fetch(localeIdentifier).str(), playerWins, playerLosses); - - UnicodeString tooltip = UnicodeString::TheEmptyString;//TheGameText->fetch("TOOLTIP:PlayersInLobby"); - if (isLocalPlayer) - { - tooltip.format(TheGameText->fetch("TOOLTIP:LocalPlayer"), uName.str()); - } - else - { - // not us - if (TheGameSpyInfo->getBuddyMap()->find(info->m_profileID) != TheGameSpyInfo->getBuddyMap()->end()) - { - // buddy - tooltip.format(TheGameText->fetch("TOOLTIP:BuddyPlayer"), uName.str()); - } - else - { - if (info->m_profileID) - { - // non-buddy profiled player - tooltip.format(TheGameText->fetch("TOOLTIP:ProfiledPlayer"), uName.str()); - } - else - { - // non-profiled player - tooltip.format(TheGameText->fetch("TOOLTIP:GenericPlayer"), uName.str()); - } - } - } - - if (info->isIgnored()) - { - tooltip.concat(TheGameText->fetch("TOOLTIP:IgnoredModifier")); - } - - if (info->m_profileID) - { - tooltip.concat(playerInfo); - } - - Int rank = 0; - Int i = 0; - while( info->m_rankPoints >= TheRankPointValues->m_ranks[i + 1]) - ++i; - rank = i; - AsciiString sideName = "GUI:RandomSide"; - if (info->m_side > 0) - { - const PlayerTemplate *fac = ThePlayerTemplateStore->getNthPlayerTemplate(info->m_side); - if (fac) - { - sideName.format("SIDE:%s", fac->getSide().str()); - } - } - AsciiString rankName; - rankName.format("GUI:GSRank%d", rank); - UnicodeString tmp; - tmp.format(L"\n%ls %ls", TheGameText->fetch(sideName).str(), TheGameText->fetch(rankName).str()); - tooltip.concat(tmp); - - TheMouse->setCursorTooltip( tooltip, -1, NULL, 1.5f ); // the text and width are the only params used. the others are the default values. -} - -static void populateGroupRoomListbox(GameWindow *lb) -{ - if (!lb) - return; - - GadgetComboBoxReset(lb); - Int indexToSelect = -1; - GroupRoomMap::iterator iter; - - // now populate the combo box - for (iter = TheGameSpyInfo->getGroupRoomList()->begin(); iter != TheGameSpyInfo->getGroupRoomList()->end(); ++iter) - { - GameSpyGroupRoom room = iter->second; - if (room.m_groupID != TheGameSpyConfig->getQMChannel()) - { - DEBUG_LOG(("populateGroupRoomListbox(): groupID %d\n", room.m_groupID)); - if (room.m_groupID == TheGameSpyInfo->getCurrentGroupRoom()) - { - Int selected = GadgetComboBoxAddEntry(lb, room.m_translatedName, GameSpyColor[GSCOLOR_CURRENTROOM]); - GadgetComboBoxSetItemData(lb, selected, (void *)(room.m_groupID)); - indexToSelect = selected; - } - else - { - Int selected = GadgetComboBoxAddEntry(lb, room.m_translatedName, GameSpyColor[GSCOLOR_ROOM]); - GadgetComboBoxSetItemData(lb, selected, (void *)(room.m_groupID)); - } - } - else - { - DEBUG_LOG(("populateGroupRoomListbox(): skipping QM groupID %d\n", room.m_groupID)); - } - } - - GadgetComboBoxSetSelectedPos(lb, indexToSelect); -} - -static const char *rankNames[] = { - "Private", - "Corporal", - "Sergeant", - "Lieutenant", - "Captain", - "Major", - "Colonel", - "General", - "Brigadier", - "Commander", -}; - -const Image* LookupSmallRankImage(Int side, Int rankPoints) -{ - if (rankPoints == 0) - return NULL; - - Int rank = 0; - Int i = 0; - while( rankPoints >= TheRankPointValues->m_ranks[i + 1]) - ++i; - rank = i; - - if (rank < 0 || rank >= 10) - return NULL; - - AsciiString sideStr = "N"; - switch(side) - { - case 2: - sideStr = "USA"; - break; - case 3: - sideStr = "CHA"; - break; - case 4: - sideStr = "GLA"; - break; - } - - AsciiString fullImageName; - fullImageName.format("%s-%s", rankNames[rank], sideStr.str()); - const Image *img = TheMappedImageCollection->findImageByName(fullImageName); - DEBUG_ASSERTLOG(img, ("*** Could not load small rank image '%s' from TheMappedImageCollection!\n", fullImageName.str())); - return img; -} - -static Int insertPlayerInListbox(const PlayerInfo& info, Color color) -{ - UnicodeString uStr; - uStr.translate(info.m_name); - - Int currentRank = info.m_rankPoints; - Int currentSide = info.m_side; - /* since PersistentStorage updates now update PlayerInfo, we don't need this. - if (info.m_profileID) - { - PSPlayerStats psStats = TheGameSpyPSMessageQueue->findPlayerStatsByID(info.m_profileID); - if (psStats.id) - { - currentRank = CalculateRank(psStats); - - PerGeneralMap::iterator it; - Int numGames = 0; - for(it = psStats.games.begin(); it != psStats.games.end(); ++it) - { - if(it->second >= numGames) - { - numGames = it->second; - currentSide = it->first; - } - } - if(numGames == 0 || psStats.gamesAsRandom >= numGames ) - { - currentSide = 0; - } - } - } - */ - - Bool isPreorder = TheGameSpyInfo->didPlayerPreorder(info.m_profileID); - - const Image *preorderImg = TheMappedImageCollection->findImageByName("OfficersClubsmall"); - Int w = (preorderImg)?preorderImg->getImageWidth():10; - //Int h = (preorderImg)?preorderImg->getImageHeight():10; - w = min(GadgetListBoxGetColumnWidth(listboxLobbyPlayers, 0), w); - Int h = w; - if (!isPreorder) - preorderImg = NULL; - - const Image *rankImg = LookupSmallRankImage(currentSide, currentRank); - - Int index = GadgetListBoxAddEntryImage(listboxLobbyPlayers, preorderImg, -1, 0, w, h); - GadgetListBoxAddEntryImage(listboxLobbyPlayers, rankImg, index, 1, w, h); - GadgetListBoxAddEntryText(listboxLobbyPlayers, uStr, color, index, 2); - - return index; -} - -void PopulateLobbyPlayerListbox(void) -{ - if (!listboxLobbyPlayers) - return; - - // Display players - PlayerInfoMap *players = TheGameSpyInfo->getPlayerInfoMap(); - PlayerInfoMap::iterator it; - BuddyInfoMap *buddies = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator bIt; - if (listboxLobbyPlayers) - { - // save off old selection - Int maxSelectedItems = GadgetListBoxGetNumEntries(listboxLobbyPlayers); - Int *selectedIndices; - GadgetListBoxGetSelected(listboxLobbyPlayers, (Int *)(&selectedIndices)); - std::set selectedNames; - std::set::const_iterator selIt; - std::set indicesToSelect; - UnicodeString uStr; - Int numSelected = 0; - for (Int i=0; ibegin(); it != players->end(); ++it) - { - PlayerInfo info = it->second; - if (info.m_flags & PEER_FLAG_OP || TheGameSpyConfig->isPlayerVIP(info.m_profileID)) - { - Int index = insertPlayerInListbox(info, info.isIgnored()?GameSpyColor[GSCOLOR_PLAYER_IGNORED]:GameSpyColor[GSCOLOR_PLAYER_OWNER]); - - selIt = selectedNames.find(info.m_name); - if (selIt != selectedNames.end()) - { - DEBUG_LOG(("Marking index %d (%s) to re-select\n", index, info.m_name.str())); - indicesToSelect.insert(index); - } - } - } - - // Buddies - for (it = players->begin(); it != players->end(); ++it) - { - PlayerInfo info = it->second; - bIt = buddies->find(info.m_profileID); - if ( !(info.m_flags & PEER_FLAG_OP || TheGameSpyConfig->isPlayerVIP(info.m_profileID)) && bIt != buddies->end() ) - { - Int index = insertPlayerInListbox(info, info.isIgnored()?GameSpyColor[GSCOLOR_PLAYER_IGNORED]:GameSpyColor[GSCOLOR_PLAYER_BUDDY]); - - selIt = selectedNames.find(info.m_name); - if (selIt != selectedNames.end()) - { - DEBUG_LOG(("Marking index %d (%s) to re-select\n", index, info.m_name.str())); - indicesToSelect.insert(index); - } - } - } - - // Everyone else - for (it = players->begin(); it != players->end(); ++it) - { - PlayerInfo info = it->second; - bIt = buddies->find(info.m_profileID); - if ( !(info.m_flags & PEER_FLAG_OP || TheGameSpyConfig->isPlayerVIP(info.m_profileID)) && bIt == buddies->end() ) - { - Int index = insertPlayerInListbox(info, info.isIgnored()?GameSpyColor[GSCOLOR_PLAYER_IGNORED]:GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - - selIt = selectedNames.find(info.m_name); - if (selIt != selectedNames.end()) - { - DEBUG_LOG(("Marking index %d (%s) to re-select\n", index, info.m_name.str())); - indicesToSelect.insert(index); - } - } - } - - // restore selection - if (indicesToSelect.size()) - { - std::set::const_iterator indexIt; - Int *newIndices = NEW Int[indicesToSelect.size()]; - for (i=0, indexIt = indicesToSelect.begin(); indexIt != indicesToSelect.end(); ++i, ++indexIt) - { - newIndices[i] = *indexIt; - DEBUG_LOG(("Queueing up index %d to re-select\n", *indexIt)); - } - GadgetListBoxSetSelected(listboxLobbyPlayers, newIndices, indicesToSelect.size()); - delete[] newIndices; - } - - if (indicesToSelect.size() != numSelected) - { - TheWindowManager->winSetLoneWindow(NULL); - } - - // restore top visible entry - GadgetListBoxSetTopVisibleEntry(listboxLobbyPlayers, previousTopIndex); - } - -} - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Lobby Menu */ -//------------------------------------------------------------------------------------------------- -void WOLLobbyMenuInit( WindowLayout *layout, void *userData ) -{ - nextScreen = NULL; - buttonPushed = false; - isShuttingDown = false; - - SetLobbyAttemptHostJoin(FALSE); // not trying to host or join - - gameListRefreshTime = 0; - playerListRefreshTime = 0; - - parentWOLLobbyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLCustomLobby.wnd:WOLLobbyMenuParent" ) ); - parent = TheWindowManager->winGetWindowFromId(NULL, parentWOLLobbyID); - - buttonBackID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonBack")); - buttonBack = TheWindowManager->winGetWindowFromId(parent, buttonBackID); - - buttonHostID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonHost")); - buttonHost = TheWindowManager->winGetWindowFromId(parent, buttonHostID); - - buttonRefreshID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonRefresh")); - buttonRefresh = TheWindowManager->winGetWindowFromId(parent, buttonRefreshID); - - buttonJoinID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonJoin")); - buttonJoin = TheWindowManager->winGetWindowFromId(parent, buttonJoinID); - buttonJoin->winEnable(FALSE); - - buttonBuddyID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonBuddy")); - buttonBuddy = TheWindowManager->winGetWindowFromId(parent, buttonBuddyID); - - buttonEmoteID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonEmote")); - buttonEmote = TheWindowManager->winGetWindowFromId(parent, buttonEmoteID); - - textEntryChatID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:TextEntryChat")); - textEntryChat = TheWindowManager->winGetWindowFromId(parent, textEntryChatID); - - listboxLobbyPlayersID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ListboxPlayers")); - listboxLobbyPlayers = TheWindowManager->winGetWindowFromId(parent, listboxLobbyPlayersID); - listboxLobbyPlayers->winSetTooltipFunc(playerTooltip); - - listboxLobbyChatID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ListboxChat")); - listboxLobbyChat = TheWindowManager->winGetWindowFromId(parent, listboxLobbyChatID); - TheGameSpyInfo->registerTextWindow(listboxLobbyChat); - - comboLobbyGroupRoomsID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ComboBoxGroupRooms")); - comboLobbyGroupRooms = TheWindowManager->winGetWindowFromId(parent, comboLobbyGroupRoomsID); - - GadgetTextEntrySetText(textEntryChat, UnicodeString.TheEmptyString); - - populateGroupRoomListbox(comboLobbyGroupRooms); - - // Show Menu - layout->hide( FALSE ); - - // if we're not in a room, this will join the best available one - if (!TheGameSpyInfo->getCurrentGroupRoom()) - { - if (groupRoomToJoin) - { - DEBUG_LOG(("WOLLobbyMenuInit() - rejoining group room %d\n", groupRoomToJoin)); - TheGameSpyInfo->joinGroupRoom(groupRoomToJoin); - groupRoomToJoin = 0; - } - else - { - DEBUG_LOG(("WOLLobbyMenuInit() - joining best group room\n")); - TheGameSpyInfo->joinBestGroupRoom(); - } - } - else - { - DEBUG_LOG(("WOLLobbyMenuInit() - not joining group room because we're already in one\n")); - } - - GrabWindowInfo(); - - TheGameSpyInfo->clearStagingRoomList(); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STARTGAMELIST; - req.gameList.restrictGameList = TheGameSpyConfig->restrictGamesToLobby(); - TheGameSpyPeerMessageQueue->addRequest(req); - - // animate controls -// TheShell->registerWithAnimateManager(parent, WIN_ANIMATION_SLIDE_TOP, TRUE); - TheShell->showShellMap(TRUE); - TheGameSpyGame->reset(); - - CustomMatchPreferences pref; -// GameWindow *slider = TheWindowManager->winGetWindowFromId(parent, sliderChatAdjustID); -// if (slider) -// { -// GadgetSliderSetPosition(slider, pref.getChatSizeSlider()); -// doSliderTrack(slider, pref.getChatSizeSlider()); -// } -// - if (pref.usesLongGameList()) - { - ToggleGameListType(); - } - - // Set Keyboard to chat window - TheWindowManager->winSetFocus( textEntryChat ); - raiseMessageBoxes = true; - - TheLobbyQueuedUTMs.clear(); - justEntered = TRUE; - initialGadgetDelay = 2; - GameWindow *win = TheWindowManager->winGetWindowFromId(NULL, TheNameKeyGenerator->nameToKey("WOLCustomLobby.wnd:GadgetParent")); - if(win) - win->winHide(TRUE); - DontShowMainMenu = TRUE; -} // WOLLobbyMenuInit - -//------------------------------------------------------------------------------------------------- -/** This is called when a shutdown is complete for this menu */ -//------------------------------------------------------------------------------------------------- -static void shutdownComplete( WindowLayout *layout ) -{ - - isShuttingDown = false; - - // hide the layout - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout, (nextScreen != NULL) ); - - if (nextScreen != NULL) - { - TheShell->push(nextScreen); - } - - nextScreen = NULL; - -} // end if - -//------------------------------------------------------------------------------------------------- -/** WOL Lobby Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLLobbyMenuShutdown( WindowLayout *layout, void *userData ) -{ - CustomMatchPreferences pref; -// GameWindow *slider = TheWindowManager->winGetWindowFromId(parent, sliderChatAdjustID); -// if (slider) -// { -// pref.setChatSizeSlider(GadgetSliderGetPosition(slider)); -// } - if (GetGameInfoListBox()) - { - pref.setUsesLongGameList(FALSE); - } - else - { - pref.setUsesLongGameList(TRUE); - } - pref.write(); - - ReleaseWindowInfo(); - - TheGameSpyInfo->unregisterTextWindow(listboxLobbyChat); - - //TheGameSpyChat->stopListingGames(); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STOPGAMELIST; - TheGameSpyPeerMessageQueue->addRequest(req); - - listboxLobbyChat = NULL; - listboxLobbyPlayers = NULL; - - isShuttingDown = true; - - // if we are shutting down for an immediate pop, skip the animations - Bool popImmediate = *(Bool *)userData; - if( popImmediate ) - { - - shutdownComplete( layout ); - return; - - } //end if - - TheShell->reverseAnimatewindow(); - DontShowMainMenu = FALSE; - - RaiseGSMessageBox(); - TheTransitionHandler->reverse("WOLCustomLobbyFade"); - -} // WOLLobbyMenuShutdown - -static void fillPlayerInfo(const PeerResponse *resp, PlayerInfo *info) -{ - info->m_name = resp->nick.c_str(); - info->m_profileID = resp->player.profileID; - info->m_flags = resp->player.flags; - info->m_wins = resp->player.wins; - info->m_losses = resp->player.losses; - info->m_locale = resp->locale.c_str(); - info->m_rankPoints= resp->player.rankPoints; - info->m_side = resp->player.side; - info->m_preorder = resp->player.preorder; -} - -#ifdef PERF_TEST -static const char* getMessageString(Int t) -{ - switch(t) - { - case PeerResponse::PEERRESPONSE_LOGIN: - return "login"; - case PeerResponse::PEERRESPONSE_DISCONNECT: - return "disconnect"; - case PeerResponse::PEERRESPONSE_MESSAGE: - return "message"; - case PeerResponse::PEERRESPONSE_GROUPROOM: - return "group room"; - case PeerResponse::PEERRESPONSE_STAGINGROOM: - return "staging room"; - case PeerResponse::PEERRESPONSE_STAGINGROOMPLAYERINFO: - return "staging room player info"; - case PeerResponse::PEERRESPONSE_JOINGROUPROOM: - return "group room join"; - case PeerResponse::PEERRESPONSE_CREATESTAGINGROOM: - return "staging room create"; - case PeerResponse::PEERRESPONSE_JOINSTAGINGROOM: - return "staging room join"; - case PeerResponse::PEERRESPONSE_PLAYERJOIN: - return "player join"; - case PeerResponse::PEERRESPONSE_PLAYERLEFT: - return "player part"; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDNICK: - return "player nick"; - case PeerResponse::PEERRESPONSE_PLAYERINFO: - return "player info"; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDFLAGS: - return "player flags"; - case PeerResponse::PEERRESPONSE_ROOMUTM: - return "room UTM"; - case PeerResponse::PEERRESPONSE_PLAYERUTM: - return "player UTM"; - case PeerResponse::PEERRESPONSE_QUICKMATCHSTATUS: - return "QM status"; - case PeerResponse::PEERRESPONSE_GAMESTART: - return "game start"; - case PeerResponse::PEERRESPONSE_FAILEDTOHOST: - return "host failure"; - } - return "unknown"; -} -#endif // PERF_TEST - -//------------------------------------------------------------------------------------------------- -/** refreshGameList - The Bool is used to force refresh if the refresh button was hit.*/ -//------------------------------------------------------------------------------------------------- -static void refreshGameList( Bool forceRefresh ) -{ - Int refreshInterval = gameListRefreshInterval; - - if (forceRefresh || ((gameListRefreshTime == 0) || ((gameListRefreshTime + refreshInterval) <= timeGetTime()))) - { - if (TheGameSpyInfo->hasStagingRoomListChanged()) - { - //DEBUG_LOG(("################### refreshing game list\n")); - //DEBUG_LOG(("gameRefreshTime=%d, refreshInterval=%d, now=%d\n", gameListRefreshTime, refreshInterval, timeGetTime())); - RefreshGameListBoxes(); - gameListRefreshTime = timeGetTime(); - } else { - //DEBUG_LOG(("-")); - } - } else { - //DEBUG_LOG(("gameListRefreshTime: %d refreshInterval: %d\n")); - } -} -//------------------------------------------------------------------------------------------------- -/** refreshPlayerList - The Bool is used to force refresh if the refresh button was hit.*/ -//------------------------------------------------------------------------------------------------- -static void refreshPlayerList( Bool forceRefresh ) -{ - Int refreshInterval = playerListRefreshInterval; - - if (forceRefresh ||((playerListRefreshTime == 0) || ((playerListRefreshTime + refreshInterval) <= timeGetTime()))) - { - PopulateLobbyPlayerListbox(); - playerListRefreshTime = timeGetTime(); - } -} -//------------------------------------------------------------------------------------------------- -/** WOL Lobby Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLLobbyMenuUpdate( WindowLayout * layout, void *userData) -{ - if(justEntered) - { - if(initialGadgetDelay == 1) - { - TheTransitionHandler->remove("MainMenuDefaultMenuLogoFade"); - TheTransitionHandler->setGroup("WOLCustomLobbyFade"); - initialGadgetDelay = 2; - justEntered = FALSE; - } - else - initialGadgetDelay--; - } - if (TheGameLogic->isInShellGame() && TheGameLogic->getFrame() == 1) - { - SignalUIInteraction(SHELL_SCRIPT_HOOK_GENERALS_ONLINE_ENTERED_FROM_GAME); - } - - - // We'll only be successful if we've requested to - if(isShuttingDown && TheShell->isAnimFinished() && TheTransitionHandler->isFinished()) - shutdownComplete(layout); - - if (raiseMessageBoxes) - { - RaiseGSMessageBox(); - raiseMessageBoxes = false; - } - - if (TheShell->isAnimFinished() && TheTransitionHandler->isFinished() && !buttonPushed && TheGameSpyPeerMessageQueue) - { - HandleBuddyResponses(); - HandlePersistentStorageResponses(); - -#ifdef PERF_TEST - UnsignedInt start = timeGetTime(); - UnsignedInt end = timeGetTime(); - std::list responses; - Int numMessages = 0; -#endif // PERF_TEST - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - Bool shouldRepopulatePlayers = FALSE; - PeerResponse resp; - while (allowedMessages-- && !sawImportantMessage && TheGameSpyPeerMessageQueue->getResponse( resp )) - { -#ifdef PERF_TEST - ++numMessages; - responses.push_back(resp.peerResponseType); -#endif // PERF_TEST - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_JOINGROUPROOM: - sawImportantMessage = TRUE; - if (resp.joinGroupRoom.ok) - { - //buttonPushed = true; - TheGameSpyInfo->setCurrentGroupRoom(resp.joinGroupRoom.id); - TheGameSpyInfo->getPlayerInfoMap()->clear(); - GroupRoomMap::iterator iter = TheGameSpyInfo->getGroupRoomList()->find(resp.joinGroupRoom.id); - if (iter != TheGameSpyInfo->getGroupRoomList()->end()) - { - GameSpyGroupRoom room = iter->second; - UnicodeString msg; - msg.format(TheGameText->fetch("GUI:LobbyJoined"), room.m_translatedName.str()); - TheGameSpyInfo->addText(msg, GameSpyColor[GSCOLOR_DEFAULT], NULL); - } - } - else - { - DEBUG_LOG(("WOLLobbyMenuUpdate() - joining best group room\n")); - TheGameSpyInfo->joinBestGroupRoom(); - } - populateGroupRoomListbox(comboLobbyGroupRooms); - shouldRepopulatePlayers = TRUE; - break; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDFLAGS: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - shouldRepopulatePlayers = TRUE; - } - break; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDNICK: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - shouldRepopulatePlayers = TRUE; - } - break; - case PeerResponse::PEERRESPONSE_PLAYERINFO: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - shouldRepopulatePlayers = TRUE; - } - break; - case PeerResponse::PEERRESPONSE_PLAYERJOIN: - { - if (resp.player.roomType == GroupRoom) - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - shouldRepopulatePlayers = TRUE; - } - } - break; - case PeerResponse::PEERRESPONSE_PLAYERUTM: - case PeerResponse::PEERRESPONSE_ROOMUTM: - { - DEBUG_LOG(("Putting off a UTM in the lobby\n")); - TheLobbyQueuedUTMs.push_back(resp); - } - break; - case PeerResponse::PEERRESPONSE_PLAYERLEFT: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->playerLeftGroupRoom(resp.nick.c_str()); - shouldRepopulatePlayers = TRUE; - } - break; - case PeerResponse::PEERRESPONSE_MESSAGE: - { - TheGameSpyInfo->addChat(resp.nick.c_str(), resp.message.profileID, - UnicodeString(resp.text.c_str()), !resp.message.isPrivate, resp.message.isAction, listboxLobbyChat); - } - break; - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheGameSpyInfo->reset(); - TheShell->pop(); - } - case PeerResponse::PEERRESPONSE_CREATESTAGINGROOM: - { - sawImportantMessage = TRUE; - SetLobbyAttemptHostJoin(FALSE); - if (resp.createStagingRoom.result == PEERJoinSuccess) - { - // Woohoo! On to our next screen! - buttonPushed = true; - nextScreen = "Menus/GameSpyGameOptionsMenu.wnd"; - TheShell->pop(); - TheGameSpyInfo->markAsStagingRoomHost(); - TheGameSpyInfo->setGameOptions(); - } - } - break; - case PeerResponse::PEERRESPONSE_JOINSTAGINGROOM: - { - sawImportantMessage = TRUE; - SetLobbyAttemptHostJoin(FALSE); - Bool isHostPresent = TRUE; - if (resp.joinStagingRoom.ok == PEERTrue) - { - GameSpyStagingRoom *room = TheGameSpyInfo->getCurrentStagingRoom(); - if (!room) - { - isHostPresent = FALSE; - } - else - { - isHostPresent = FALSE; - for (Int i=0; igetConstSlot(0)->getName()); - const char *firstPlayer = resp.stagingRoomPlayerNames[i].c_str(); - if (!strcmp(hostName.str(), firstPlayer)) - { - DEBUG_LOG(("Saw host %s == %s in slot %d\n", hostName.str(), firstPlayer, i)); - isHostPresent = TRUE; - } - } - } - } - if (resp.joinStagingRoom.ok == PEERTrue && isHostPresent) - { - // Woohoo! On to our next screen! - buttonPushed = true; - nextScreen = "Menus/GameSpyGameOptionsMenu.wnd"; - TheShell->pop(); - } - else - { - UnicodeString s; - - switch(resp.joinStagingRoom.result) - { - case PEERFullRoom: // The room is full. - s = TheGameText->fetch("GUI:JoinFailedRoomFull"); - break; - case PEERInviteOnlyRoom: // The room is invite only. - s = TheGameText->fetch("GUI:JoinFailedInviteOnly"); - break; - case PEERBannedFromRoom: // The local user is banned from the room. - s = TheGameText->fetch("GUI:JoinFailedBannedFromRoom"); - break; - case PEERBadPassword: // An incorrect password (or none) was given for a passworded room. - s = TheGameText->fetch("GUI:JoinFailedBadPassword"); - break; - case PEERAlreadyInRoom: // The local user is already in or entering a room of the same type. - s = TheGameText->fetch("GUI:JoinFailedAlreadyInRoom"); - break; - case PEERNoConnection: // Can't join a room if there's no chat connection. - s = TheGameText->fetch("GUI:JoinFailedNoConnection"); - break; - default: - s = TheGameText->fetch("GUI:JoinFailedDefault"); - break; - } - GSMessageBoxOk(TheGameText->fetch("GUI:JoinFailedDefault"), s); - if (groupRoomToJoin) - { - DEBUG_LOG(("WOLLobbyMenuUpdate() - rejoining group room %d\n", groupRoomToJoin)); - TheGameSpyInfo->joinGroupRoom(groupRoomToJoin); - groupRoomToJoin = 0; - } - else - { - DEBUG_LOG(("WOLLobbyMenuUpdate() - joining best group room\n")); - TheGameSpyInfo->joinBestGroupRoom(); - } - } - } - break; - case PeerResponse::PEERRESPONSE_STAGINGROOMLISTCOMPLETE: - TheGameSpyInfo->sawFullGameList(); - break; - case PeerResponse::PEERRESPONSE_STAGINGROOM: - { - GameSpyStagingRoom room; - switch(resp.stagingRoom.action) - { - case PEER_CLEAR: - TheGameSpyInfo->clearStagingRoomList(); - //TheGameSpyInfo->addText( UnicodeString(L"gameList: PEER_CLEAR"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - break; - case PEER_ADD: - case PEER_UPDATE: - { - if (resp.stagingRoom.percentComplete == 100) - { - TheGameSpyInfo->sawFullGameList(); - } - - //if (ParseAsciiStringToGameInfo(&room, resp.stagingRoomMapName.c_str())) - //if (ParseAsciiStringToGameInfo(&room, resp.stagingServerGameOptions.c_str())) - Bool serverOk = TRUE; - if (!resp.stagingRoomMapName.length()) - { - serverOk = FALSE; - } - // fix for ghost game problem - need to iterate over all resp.stagingRoomPlayerNames[i] - Bool sawSelf = FALSE; - //for (Int i=0; igetLocalName() == resp.stagingRoomPlayerNames[0].c_str()) - { - sawSelf = TRUE; // don't show ghost games for myself - } - //} - if (sawSelf) - serverOk = FALSE; - - if (serverOk) - { - room.setGameName(UnicodeString(resp.stagingServerName.c_str())); - room.setID(resp.stagingRoom.id); - room.setHasPassword(resp.stagingRoom.requiresPassword); - room.setVersion(resp.stagingRoom.version); - room.setExeCRC(resp.stagingRoom.exeCRC); - room.setIniCRC(resp.stagingRoom.iniCRC); - room.setAllowObservers(resp.stagingRoom.allowObservers); - room.setPingString(resp.stagingServerPingString.c_str()); - room.setLadderIP(resp.stagingServerLadderIP.c_str()); - room.setLadderPort(resp.stagingRoom.ladderPort); - room.setReportedNumPlayers(resp.stagingRoom.numPlayers); - room.setReportedMaxPlayers(resp.stagingRoom.maxPlayers); - room.setReportedNumObservers(resp.stagingRoom.numObservers); - - Int i; - AsciiString gsMapName = resp.stagingRoomMapName.c_str(); - AsciiString mapName = ""; - for (i=0; iportableMapPathToRealMapPath(mapName)); - - Int numPlayers = 0; - for (i=0; isetWins( resp.stagingRoom.wins[i] ); - slot->setLosses( resp.stagingRoom.losses[i] ); - slot->setProfileID( resp.stagingRoom.profileID[i] ); - slot->setPlayerTemplate( resp.stagingRoom.faction[i] ); - slot->setColor( resp.stagingRoom.color[i] ); - if (resp.stagingRoom.profileID[i] == SLOT_EASY_AI) - { - slot->setState(SLOT_EASY_AI); - ++numPlayers; - } - else if (resp.stagingRoom.profileID[i] == SLOT_MED_AI) - { - slot->setState(SLOT_MED_AI); - ++numPlayers; - } - else if (resp.stagingRoom.profileID[i] == SLOT_BRUTAL_AI) - { - slot->setState(SLOT_BRUTAL_AI); - ++numPlayers; - } - else if (resp.stagingRoomPlayerNames[i].length()) - { - UnicodeString nameUStr; - nameUStr.translate(resp.stagingRoomPlayerNames[i].c_str()); - slot->setState(SLOT_PLAYER, nameUStr); - ++numPlayers; - } - else - { - slot->setState(SLOT_OPEN); - } - } - } - DEBUG_ASSERTCRASH(numPlayers, ("Game had no players!\n")); - //DEBUG_LOG(("Saw room: hasPass=%d, allowsObservers=%d\n", room.getHasPassword(), room.getAllowObservers())); - if (resp.stagingRoom.action == PEER_ADD) - { - TheGameSpyInfo->addStagingRoom(room); - //TheGameSpyInfo->addText( UnicodeString(L"gameList: PEER_ADD"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - } - else - { - TheGameSpyInfo->updateStagingRoom(room); - //TheGameSpyInfo->addText( UnicodeString(L"gameList: PEER_UPDATE"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - } - } - else - { - room.setID(resp.stagingRoom.id); - TheGameSpyInfo->removeStagingRoom(room); - //TheGameSpyInfo->addText( UnicodeString(L"gameList: PEER_UPDATE FAILED"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - } - break; - } - case PEER_REMOVE: - room.setID(resp.stagingRoom.id); - TheGameSpyInfo->removeStagingRoom(room); - //TheGameSpyInfo->addText( UnicodeString(L"gameList: PEER_REMOVE"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - break; - default: - //TheGameSpyInfo->addText( UnicodeString(L"gameList: Unknown"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - break; - } - } - break; - } - } -#if 0 - if (shouldRepopulatePlayers) - { - PopulateLobbyPlayerListbox(); - } -#else - refreshPlayerList(); -#endif - -#ifdef PERF_TEST - // check performance - end = timeGetTime(); - PERF_LOG(("Frame time was %d ms\n", end-start)); - std::list::const_iterator it; - for (it = responses.begin(); it != responses.end(); ++it) - { - PERF_LOG((" %s\n", getMessageString(*it))); - } - PERF_LOG(("\n")); -#endif // PERF_TEST - -#if 0 -// Removed 2-17-03 to pull out into a function so we can do the same checks - Int refreshInterval = gameListRefreshInterval; - - if ((gameListRefreshTime == 0) || ((gameListRefreshTime + refreshInterval) <= timeGetTime())) - { - if (TheGameSpyInfo->hasStagingRoomListChanged()) - { - //DEBUG_LOG(("################### refreshing game list\n")); - //DEBUG_LOG(("gameRefreshTime=%d, refreshInterval=%d, now=%d\n", gameListRefreshTime, refreshInterval, timeGetTime())); - RefreshGameListBoxes(); - gameListRefreshTime = timeGetTime(); - } else { - //DEBUG_LOG(("-")); - } - } else { - //DEBUG_LOG(("gameListRefreshTime: %d refreshInterval: %d\n")); - } -#else - refreshGameList(); -#endif - } -}// WOLLobbyMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Lobby Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLobbyMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - if (buttonPushed) - break; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLLobbyMenuInput - -//static void doSliderTrack(GameWindow *control, Int val) -//{ -// Int sliderW, sliderH, sliderX, sliderY; -// control->winGetPosition(&sliderX, &sliderY); -// control->winGetSize(&sliderW, &sliderH); -// Real cursorY = sliderY + (100-val)*0.01f*sliderH; -// -// extern GameWindow *listboxLobbyGamesSmall; -// extern GameWindow *listboxLobbyGamesLarge; -// extern GameWindow *listboxLobbyGameInfo; -// -// static Int gwsX = 0, gwsY = 0, gwsW = 0, gwsH = 0; -// static Int gwlX = 0, gwlY = 0, gwlW = 0, gwlH = 0; -// static Int gwiX = 0, gwiY = 0, gwiW = 0, gwiH = 0; -// static Int pwX = 0, pwY = 0, pwW = 0, pwH = 0; -// static Int chatPosX = 0, chatPosY = 0, chatW = 0, chatH = 0; -// static Int spacing = 0; -// if (chatPosX == 0) -// { -// listboxLobbyChat->winGetPosition(&chatPosX, &chatPosY); -// listboxLobbyChat->winGetSize(&chatW, &chatH); -// -//// listboxLobbyGamesSmall->winGetPosition(&gwsX, &gwsY); -//// listboxLobbyGamesSmall->winGetSize(&gwsW, &gwsH); -// -// listboxLobbyGamesLarge->winGetPosition(&gwlX, &gwlY); -// listboxLobbyGamesLarge->winGetSize(&gwlW, &gwlH); -// -//// listboxLobbyGameInfo->winGetPosition(&gwiX, &gwiY); -//// listboxLobbyGameInfo->winGetSize(&gwiW, &gwiH); -//// -// listboxLobbyPlayers->winGetPosition(&pwX, &pwY); -// listboxLobbyPlayers->winGetSize(&pwW, &pwH); -// -// spacing = chatPosY - pwY - pwH; -// } -// -// Int newChatY = cursorY; -// Int newChatH = chatH + chatPosY - newChatY; -// listboxLobbyChat->winSetPosition(chatPosX, newChatY); -// listboxLobbyChat->winSetSize(chatW, newChatH); -// -// Int newH = cursorY - pwY - spacing; -// listboxLobbyPlayers->winSetSize(pwW, newH); -//// listboxLobbyGamesSmall->winSetSize(gwsW, newH); -// listboxLobbyGamesLarge->winSetSize(gwlW, newH); -//// listboxLobbyGameInfo->winSetSize(gwiW, newH); - - -//------------------------------------------------------------------------------------------------- -/** WOL Lobby Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLobbyMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - static NameKeyType buttonGameListTypeToggleID = NAMEKEY_INVALID; - - switch( msg ) - { - - - //--------------------------------------------------------------------------------------------- - case GWM_CREATE: - { - buttonGameListTypeToggleID = NAMEKEY("WOLCustomLobby.wnd:ButtonGameListToggle"); -// sliderChatAdjustID = NAMEKEY("WOLCustomLobby.wnd:SliderChatAdjust"); - - break; - } // case GWM_DESTROY: - - //--------------------------------------------------------------------------------------------- - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - //--------------------------------------------------------------------------------------------- - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - //--------------------------------------------------------------------------------------------- - case GLM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if ( controlID == GetGameListBoxID() ) - { - int rowSelected = mData2; - if( rowSelected >= 0 ) - { - buttonJoin->winEnable(TRUE); - static UnsignedInt lastFrame = 0; - static Int lastID = -1; - UnsignedInt now = TheGameClient->getFrame(); - - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_GETEXTENDEDSTAGINGROOMINFO; - req.stagingRoom.id = (Int)GadgetListBoxGetItemData(control, rowSelected, 0); - - if (lastID != req.stagingRoom.id || now > lastFrame + 60) - { - TheGameSpyPeerMessageQueue->addRequest(req); - } - - lastID = req.stagingRoom.id; - lastFrame = now; - } - else - { - buttonJoin->winEnable(FALSE); - } - if (GetGameInfoListBox()) - { - RefreshGameInfoListBox(GetGameListBox(), GetGameInfoListBox()); - } - } //if ( controlID == GetGameListBoxID() ) - - break; - } - - //--------------------------------------------------------------------------------------------- - case GBM_SELECTED: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if (HandleSortButton((NameKeyType)controlID)) - break; - - // If we back out, just bail - we haven't gotten far enough to need to log out - if ( controlID == buttonBackID ) - { - if (s_tryingToHostOrJoin) - break; - - // Leave any group room, then pop off the screen - TheGameSpyInfo->leaveGroupRoom(); - - SetLobbyAttemptHostJoin( TRUE ); // pretend, since we don't want to queue up another action - buttonPushed = true; - nextScreen = "Menus/WOLWelcomeMenu.wnd"; - TheShell->pop(); - - } //if ( controlID == buttonBack ) - else if ( controlID == buttonRefreshID ) - { - // Added 2/17/03 added the game refresh button - refreshGameList(TRUE); - refreshPlayerList(TRUE); - } - else if ( controlID == buttonHostID ) - { - if (s_tryingToHostOrJoin) - break; - - SetLobbyAttemptHostJoin( TRUE ); - TheLobbyQueuedUTMs.clear(); - groupRoomToJoin = TheGameSpyInfo->getCurrentGroupRoom(); - GameSpyOpenOverlay(GSOVERLAY_GAMEOPTIONS); - } - else if ( controlID == buttonJoinID ) - { - if (s_tryingToHostOrJoin) - break; - - TheLobbyQueuedUTMs.clear(); - // Look for a game to join - groupRoomToJoin = TheGameSpyInfo->getCurrentGroupRoom(); - Int selected; - GadgetListBoxGetSelected(GetGameListBox(), &selected); - if (selected >= 0) - { - Int selectedID = (Int)GadgetListBoxGetItemData(GetGameListBox(), selected); - if (selectedID > 0) - { - StagingRoomMap *srm = TheGameSpyInfo->getStagingRoomList(); - StagingRoomMap::iterator srmIt = srm->find(selectedID); - if (srmIt != srm->end()) - { - GameSpyStagingRoom *roomToJoin = srmIt->second; - if (!roomToJoin || roomToJoin->getExeCRC() != TheGlobalData->m_exeCRC || roomToJoin->getIniCRC() != TheGlobalData->m_iniCRC) - { - // bad crc. don't go. - DEBUG_LOG(("WOLLobbyMenuSystem - CRC mismatch with the game I'm trying to join. My CRC's - EXE:0x%08X INI:0x%08X Their CRC's - EXE:0x%08x INI:0x%08x\n", TheGlobalData->m_exeCRC, TheGlobalData->m_iniCRC, roomToJoin->getExeCRC(), roomToJoin->getIniCRC())); -#if defined(_DEBUG) || defined(_INTERNAL) - if (TheGlobalData->m_netMinPlayers) - { - GSMessageBoxOk(TheGameText->fetch("GUI:JoinFailedDefault"), TheGameText->fetch("GUI:JoinFailedCRCMismatch")); - break; - } - else if (g_fakeCRC) - { - TheWritableGlobalData->m_exeCRC = roomToJoin->getExeCRC(); - TheWritableGlobalData->m_iniCRC = roomToJoin->getIniCRC(); - } -#else - GSMessageBoxOk(TheGameText->fetch("GUI:JoinFailedDefault"), TheGameText->fetch("GUI:JoinFailedCRCMismatch")); - break; -#endif - } - Bool unknownLadder = (roomToJoin->getLadderPort() && TheLadderList->findLadder(roomToJoin->getLadderIP(), roomToJoin->getLadderPort()) == NULL); - if (unknownLadder) - { - GSMessageBoxOk(TheGameText->fetch("GUI:JoinFailedDefault"), TheGameText->fetch("GUI:JoinFailedUnknownLadder")); - break; - } - if (roomToJoin->getNumPlayers() == MAX_SLOTS) - { - GSMessageBoxOk(TheGameText->fetch("GUI:JoinFailedDefault"), TheGameText->fetch("GUI:JoinFailedRoomFull")); - break; - } - TheGameSpyInfo->markAsStagingRoomJoiner(selectedID); - TheGameSpyGame->setGameName(roomToJoin->getGameName()); - TheGameSpyGame->setLadderIP(roomToJoin->getLadderIP()); - TheGameSpyGame->setLadderPort(roomToJoin->getLadderPort()); - SetLobbyAttemptHostJoin( TRUE ); - if (roomToJoin->getHasPassword()) - { - GameSpyOpenOverlay(GSOVERLAY_GAMEPASSWORD); - } - else - { - // no password - just join it - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_JOINSTAGINGROOM; - req.text = srmIt->second->getGameName().str(); - req.stagingRoom.id = selectedID; - req.password = ""; - TheGameSpyPeerMessageQueue->addRequest(req); - } - } - } - else - { - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:NoGameInfo"), NULL); - } - } - else - { - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:NoGameSelected"), NULL); - } - } - else if ( controlID == buttonBuddyID ) - { - GameSpyToggleOverlay( GSOVERLAY_BUDDY ); - } - else if ( controlID == buttonGameListTypeToggleID ) - { - ToggleGameListType(); - } - else if ( controlID == buttonEmoteID ) - { - // read the user's input and clear the entry box - UnicodeString txtInput; - txtInput.set(GadgetTextEntryGetText( textEntryChat )); - GadgetTextEntrySetText(textEntryChat, UnicodeString::TheEmptyString); - txtInput.trim(); - if (!txtInput.isEmpty()) - { - // Send the message - TheGameSpyInfo->sendChat( txtInput, FALSE, listboxLobbyPlayers ); // 'emote' button now just sends text - } - } - - break; - }// case GBM_SELECTED: - - //--------------------------------------------------------------------------------------------- - case GCM_SELECTED: - { - if (s_tryingToHostOrJoin) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if( controlID == comboLobbyGroupRoomsID ) - { - int rowSelected = -1; - GadgetComboBoxGetSelectedPos(control, &rowSelected); - - DEBUG_LOG(("Row selected = %d\n", rowSelected)); - if (rowSelected >= 0) - { - Int groupID; - groupID = (Int)GadgetComboBoxGetItemData(comboLobbyGroupRooms, rowSelected); - DEBUG_LOG(("ItemData was %d, current Group Room is %d\n", groupID, TheGameSpyInfo->getCurrentGroupRoom())); - if (groupID && groupID != TheGameSpyInfo->getCurrentGroupRoom()) - { - TheGameSpyInfo->leaveGroupRoom(); - TheGameSpyInfo->joinGroupRoom(groupID); - - if (TheGameSpyConfig->restrictGamesToLobby()) - { - TheGameSpyInfo->clearStagingRoomList(); - RefreshGameListBoxes(); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STARTGAMELIST; - req.gameList.restrictGameList = TRUE; - TheGameSpyPeerMessageQueue->addRequest(req); - } - } - } - } - } // case GCM_SELECTED - break; - - //--------------------------------------------------------------------------------------------- - case GLM_DOUBLE_CLICKED: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if (controlID == GetGameListBoxID()) - { - int rowSelected = mData2; - - if (rowSelected >= 0) - { - GadgetListBoxSetSelected( control, rowSelected ); - GameWindow *button = TheWindowManager->winGetWindowFromId( window, buttonJoinID ); - - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)button, buttonJoinID ); - } - } - break; - }// case GLM_DOUBLE_CLICKED: - - //--------------------------------------------------------------------------------------------- - case GLM_RIGHT_CLICKED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if( controlID == listboxLobbyPlayersID ) - { - RightClickStruct *rc = (RightClickStruct *)mData2; - WindowLayout *rcLayout = NULL; - GameWindow *rcMenu; - if(rc->pos < 0) - { - GadgetListBoxSetSelected(control, -1); - break; - } - - GPProfile profileID = 0; - AsciiString aName; - aName.translate(GadgetListBoxGetText(control, rc->pos, COLUMN_PLAYERNAME)); - PlayerInfoMap::iterator it = TheGameSpyInfo->getPlayerInfoMap()->find(aName); - if (it != TheGameSpyInfo->getPlayerInfoMap()->end()) - profileID = it->second.m_profileID; - - Bool isBuddy = FALSE; - if (profileID <= 0) - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCNoProfileMenu.wnd")); - else - { - if (profileID == TheGameSpyInfo->getLocalProfileID()) - { - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCLocalPlayerMenu.wnd")); - } - else if(TheGameSpyInfo->isBuddy(profileID)) - { - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCBuddiesMenu.wnd")); - isBuddy = TRUE; - } - else - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCNonBuddiesMenu.wnd")); - } - if(!rcLayout) - break; - - GadgetListBoxSetSelected(control, rc->pos); - - rcMenu = rcLayout->getFirstWindow(); - rcMenu->winGetLayout()->runInit(); - rcMenu->winBringToTop(); - rcMenu->winHide(FALSE); - setUnignoreText( rcLayout, aName, profileID); - ICoord2D rcSize, rcPos; - rcMenu->winGetSize(&rcSize.x, &rcSize.y); - rcPos.x = rc->mouseX; - rcPos.y = rc->mouseY; - if(rc->mouseX + rcSize.x > TheDisplay->getWidth()) - rcPos.x = TheDisplay->getWidth() - rcSize.x; - if(rc->mouseY + rcSize.y > TheDisplay->getHeight()) - rcPos.y = TheDisplay->getHeight() - rcSize.y; - rcMenu->winSetPosition(rcPos.x, rcPos.y); - - GameSpyRCMenuData *rcData = NEW GameSpyRCMenuData; - rcData->m_id = profileID; - rcData->m_nick = aName; - rcData->m_itemType = (isBuddy)?ITEM_BUDDY:ITEM_NONBUDDY; - rcMenu->winSetUserData((void *)rcData); - TheWindowManager->winSetLoneWindow(rcMenu); - } - else if( controlID == GetGameListBoxID() ) - { - RightClickStruct *rc = (RightClickStruct *)mData2; - WindowLayout *rcLayout = NULL; - GameWindow *rcMenu; - if(rc->pos < 0) - { - GadgetListBoxSetSelected(control, -1); - break; - } - - Int selectedID = (Int)GadgetListBoxGetItemData(control, rc->pos); - if (selectedID > 0) - { - StagingRoomMap *srm = TheGameSpyInfo->getStagingRoomList(); - StagingRoomMap::iterator srmIt = srm->find(selectedID); - if (srmIt != srm->end()) - { - GameSpyStagingRoom *theRoom = srmIt->second; - if (!theRoom) - break; - const LadderInfo *linfo = TheLadderList->findLadder(theRoom->getLadderIP(), theRoom->getLadderPort()); - if (linfo) - { - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCGameDetailsMenu.wnd")); - if (!rcLayout) - break; - - GadgetListBoxSetSelected(control, rc->pos); - - rcMenu = rcLayout->getFirstWindow(); - rcMenu->winGetLayout()->runInit(); - rcMenu->winBringToTop(); - rcMenu->winHide(FALSE); - rcMenu->winSetPosition(rc->mouseX, rc->mouseY); - - rcMenu->winSetUserData((void *)selectedID); - TheWindowManager->winSetLoneWindow(rcMenu); - } - } - } - } - break; - } - -// //--------------------------------------------------------------------------------------------- -// case GSM_SLIDER_TRACK: -// { -// if (buttonPushed) -// break; -// -// GameWindow *control = (GameWindow *)mData1; -// Int val = (Int)mData2; -// Int controlID = control->winGetWindowId(); -// if (controlID == sliderChatAdjustID) -// { -// doSliderTrack(control, val); -// } -// break; -// } - - //--------------------------------------------------------------------------------------------- - case GEM_EDIT_DONE: - { - if (buttonPushed) - break; - - // read the user's input and clear the entry box - UnicodeString txtInput; - txtInput.set(GadgetTextEntryGetText( textEntryChat )); - GadgetTextEntrySetText(textEntryChat, UnicodeString::TheEmptyString); - txtInput.trim(); - if (!txtInput.isEmpty()) - { - // Send the message - if (!handleLobbySlashCommands(txtInput)) - { - TheGameSpyInfo->sendChat( txtInput, false, listboxLobbyPlayers ); - } - } - break; - } - - //--------------------------------------------------------------------------------------------- - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLLobbyMenuSystem diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLocaleSelectPopup.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLocaleSelectPopup.cpp deleted file mode 100644 index 6d088b5c00b..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLocaleSelectPopup.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLLocaleSelectPopup.cpp -// Author: Matt Campbell, December 2001 -// Description: WOL locale select popup -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "GameClient/GameText.h" -#include "Common/CustomMatchPreferences.h" -#include "Common/GameEngine.h" -#include "Common/GameSpyMiscPreferences.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "Common/GlobalData.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentLocaleSelectID = NAMEKEY_INVALID; -static NameKeyType buttonOkID = NAMEKEY_INVALID; -static NameKeyType listboxLocaleID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentLocaleSelect = NULL; -static GameWindow *buttonOk = NULL; -static GameWindow *listboxLocale = NULL; - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Status Menu */ -//------------------------------------------------------------------------------------------------- -void WOLLocaleSelectInit( WindowLayout *layout, void *userData ) -{ - parentLocaleSelectID = TheNameKeyGenerator->nameToKey( AsciiString( "PopupLocaleSelect.wnd:ParentLocaleSelect" ) ); - buttonOkID = TheNameKeyGenerator->nameToKey( AsciiString( "PopupLocaleSelect.wnd:ButtonOk" ) ); - listboxLocaleID = TheNameKeyGenerator->nameToKey( AsciiString( "PopupLocaleSelect.wnd:ListBoxLocaleSelect" ) ); - parentLocaleSelect = TheWindowManager->winGetWindowFromId( NULL, parentLocaleSelectID ); - buttonOk = TheWindowManager->winGetWindowFromId( NULL, buttonOkID); - listboxLocale = TheWindowManager->winGetWindowFromId( NULL, listboxLocaleID); - - for (int i=LOC_MIN; i<=LOC_MAX; ++i) - { - AsciiString id; - id.format("WOL:Locale%2.2d", i); - GadgetListBoxAddEntryText(listboxLocale, TheGameText->fetch(id.str()), GameSpyColor[GSCOLOR_DEFAULT], -1, -1); - } - GadgetListBoxSetSelected(listboxLocale, 0); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentLocaleSelect ); - TheWindowManager->winSetModal( parentLocaleSelect ); -} // WOLLocaleSelectInit - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLLocaleSelectShutdown( WindowLayout *layout, void *userData ) -{ - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); - -} // WOLLocaleSelectShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLLocaleSelectUpdate( WindowLayout * layout, void *userData) -{ - -}// WOLLocaleSelectUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLocaleSelectInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { -// UnsignedByte key = mData1; -// UnsignedByte state = mData2; - - // ---------------------------------------------------------------------------------------- - // don't let key fall through anywhere else - return MSG_HANDLED; - } // end char - } // end switch( msg ) - return MSG_IGNORED; -}// WOLLocaleSelectInput - -//Int getRegistryNicknameOffset(AsciiString nick); /// @todo: mdc remove this once we can save ini pref files -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLocaleSelectSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == buttonOkID ) - { - int selected; - GadgetListBoxGetSelected(listboxLocale, &selected); - if (selected < 0) - return MSG_HANDLED; // can't select nothing! - PSRequest psReq; - psReq.requestType = PSRequest::PSREQUEST_UPDATEPLAYERLOCALE; - psReq.player.locale = selected + LOC_MIN; - psReq.email = TheGameSpyInfo->getLocalEmail().str(); - psReq.nick = TheGameSpyInfo->getLocalBaseName().str(); - psReq.password = TheGameSpyInfo->getLocalPassword().str(); - psReq.player.id = TheGameSpyInfo->getLocalProfileID(); - - TheGameSpyPSMessageQueue->addRequest(psReq); - GameSpyCloseOverlay(GSOVERLAY_LOCALESELECT); - - GameSpyMiscPreferences cPref; - cPref.setLocale(psReq.player.locale); - cPref.write(); - - PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID()); - stats.locale = psReq.player.locale; - if (stats.id == TheGameSpyInfo->getLocalProfileID()) - TheGameSpyPSMessageQueue->trackPlayerStats(stats); - - if(stats.id == 0) - { - stats = TheGameSpyInfo->getCachedLocalPlayerStats(); - stats.locale = psReq.player.locale; - TheGameSpyInfo->setCachedLocalPlayerStats(stats); - } - else - { - // force an update of our shtuff - PSResponse newResp; - newResp.responseType = PSResponse::PSRESPONSE_PLAYERSTATS; - newResp.player = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID()); - TheGameSpyPSMessageQueue->addResponse(newResp); - } - CheckReOpenPlayerInfo(); - } //if ( controlID == buttonDisconnect ) - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLLocaleSelectSystem diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp deleted file mode 100644 index f60e693e50e..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp +++ /dev/null @@ -1,1511 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLLoginMenu.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/STLTypedefs.h" - -#include "Common/File.h" -#include "Common/FileSystem.h" -#include "Common/GameEngine.h" -#include "Common/GameSpyMiscPreferences.h" -#include "Common/QuotedPrintable.h" -#include "Common/Registry.h" -#include "Common/UserPreferences.h" -#include "GameClient/AnimateWindowManager.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GameText.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetComboBox.h" -#include "GameClient/GadgetCheckBox.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/MessageBox.h" -#include "GameClient/ShellHooks.h" -#include "GameClient/GameWindowTransitions.h" - -#include "GameNetwork/GameSpy/GSConfig.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PingThread.h" -#include "GameNetwork/GameSpy/BuddyThread.h" -#include "GameNetwork/GameSpy/ThreadUtils.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" - -#include "GameNetwork/GameSpyOverlay.h" - - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -#ifdef ALLOW_NON_PROFILED_LOGIN -Bool GameSpyUseProfiles = false; -#endif // ALLOW_NON_PROFILED_LOGIN - - -static Bool isShuttingDown = false; -static Bool buttonPushed = false; -static char *nextScreen = NULL; - -static const UnsignedInt loginTimeoutInMS = 10000; -static UnsignedInt loginAttemptTime = 0; - -class GameSpyLoginPreferences : public UserPreferences -{ -public: - GameSpyLoginPreferences() { m_emailPasswordMap.clear(); m_emailNickMap.clear(); } - virtual ~GameSpyLoginPreferences() { m_emailPasswordMap.clear(); m_emailNickMap.clear(); } - - virtual Bool load(AsciiString fname); - virtual Bool write(void); - - AsciiString getPasswordForEmail( AsciiString email ); - AsciiString getDateForEmail( AsciiString email, AsciiString &month, AsciiString &date, AsciiString &year ); - AsciiStringList getNicksForEmail( AsciiString email ); - void addLogin( AsciiString email, AsciiString nick, AsciiString password, AsciiString date ); - void forgetLogin( AsciiString email ); - AsciiStringList getEmails( void ); - -private: - typedef std::map PassMap; - typedef std::map DateMap; - typedef std::map NickMap; - PassMap m_emailPasswordMap; - NickMap m_emailNickMap; - DateMap m_emailDateMap; -}; - -static AsciiString obfuscate( AsciiString in ) -{ - char *buf = NEW char[in.getLength() + 1]; - strcpy(buf, in.str()); - static const char *xor = "1337Munkee"; - char *c = buf; - const char *c2 = xor; - while (*c) - { - if (!*c2) - c2 = xor; - if (*c != *c2) - *c = *c++ ^ *c2++; - else - c++, c2++; - } - AsciiString out = buf; - delete buf; - return out; -} - -Bool GameSpyLoginPreferences::load( AsciiString fname ) -{ - if (!UserPreferences::load(fname)) - return false; - - UserPreferences::iterator upIt = begin(); - while (upIt != end()) - { - AsciiString key = upIt->first; - if (key.startsWith("pass_")) - { - AsciiString email, pass; - email = key.str() + 5; - pass = upIt->second; - - AsciiString quoPass = QuotedPrintableToAsciiString(pass); - pass = obfuscate(quoPass); - - m_emailPasswordMap[email] = pass; - } - if (key.startsWith("date_")) - { - AsciiString email, date; - email = key.str() + 5; - date = upIt->second; - - date = QuotedPrintableToAsciiString(date); - - m_emailDateMap[email] = date; - } - else if (key.startsWith("nick_")) - { - AsciiString email, nick, nicks; - email = key.str() + 5; - nicks = upIt->second; - while (nicks.nextToken(&nick, ",")) - { - m_emailNickMap[email].push_back(nick); - } - } - ++upIt; - } - - return true; -} - -Bool GameSpyLoginPreferences::write( void ) -{ - if (m_filename.isEmpty()) - return false; - - FILE *fp = fopen(m_filename.str(), "w"); - if (fp) - { - fprintf(fp, "lastEmail = %s\n", ((*this)["lastEmail"].str())); - fprintf(fp, "lastName = %s\n", ((*this)["lastName"].str())); - fprintf(fp, "useProfiles = %s\n", ((*this)["useProfiles"].str())); - PassMap::iterator passIt = m_emailPasswordMap.begin(); - while (passIt != m_emailPasswordMap.end()) - { - AsciiString pass = obfuscate(passIt->second); - AsciiString quoPass = AsciiStringToQuotedPrintable(pass); - - fprintf(fp, "pass_%s = %s\n", passIt->first.str(), quoPass.str()); - ++passIt; - } - - PassMap::iterator dateIt = m_emailDateMap.begin(); - while (dateIt != m_emailDateMap.end()) - { - AsciiString date = AsciiStringToQuotedPrintable(dateIt->second); - - fprintf(fp, "date_%s = %s\n", dateIt->first.str(), date.str()); - ++dateIt; - } - - NickMap::iterator nickIt = m_emailNickMap.begin(); - while (nickIt != m_emailNickMap.end()) - { - AsciiString nicks; - AsciiStringListIterator listIt = nickIt->second.begin(); - while (listIt != nickIt->second.end()) - { - nicks.concat(*listIt); - nicks.concat(','); - ++listIt; - } - fprintf(fp, "nick_%s = %s\n", nickIt->first.str(), nicks.str()); - ++nickIt; - } - - fclose(fp); - return true; - } - return false; -} -AsciiString GameSpyLoginPreferences::getDateForEmail( AsciiString email, AsciiString &month, AsciiString &date, AsciiString &year ) -{ - if ( m_emailDateMap.find(email) == m_emailDateMap.end() ) - return AsciiString::TheEmptyString; - AsciiString fullDate = m_emailDateMap[email]; - if(fullDate.getLength() != 8) - return AsciiString::TheEmptyString; - month.format("%c%c", fullDate.getCharAt(0), fullDate.getCharAt(1)); - date.format("%c%c", fullDate.getCharAt(2), fullDate.getCharAt(3)); - year.format("%c%c%c%c", fullDate.getCharAt(4), fullDate.getCharAt(5), fullDate.getCharAt(6), fullDate.getCharAt(7)); - return m_emailDateMap[email]; -} - -AsciiString GameSpyLoginPreferences::getPasswordForEmail( AsciiString email ) -{ - if ( m_emailPasswordMap.find(email) == m_emailPasswordMap.end() ) - return AsciiString::TheEmptyString; - return m_emailPasswordMap[email]; -} - -AsciiStringList GameSpyLoginPreferences::getNicksForEmail( AsciiString email ) -{ - if ( m_emailNickMap.find(email) == m_emailNickMap.end() ) - { - AsciiStringList empty; - return empty; - } - return m_emailNickMap[email]; -} - -void GameSpyLoginPreferences::addLogin( AsciiString email, AsciiString nick, AsciiString password, AsciiString date ) -{ - if ( std::find(m_emailNickMap[email].begin(), m_emailNickMap[email].end(), nick) == m_emailNickMap[email].end() ) - m_emailNickMap[email].push_back(nick); - m_emailPasswordMap[email] = password; - m_emailDateMap[email] = date; -} - -void GameSpyLoginPreferences::forgetLogin( AsciiString email ) -{ - m_emailNickMap.erase(email); - m_emailPasswordMap.erase(email); - m_emailDateMap.erase(email); - -} - -AsciiStringList GameSpyLoginPreferences::getEmails( void ) -{ - AsciiStringList theList; - NickMap::iterator it = m_emailNickMap.begin(); - while (it != m_emailNickMap.end()) - { - theList.push_back(it->first); - ++it; - } - return theList; -} - -static const char *PREF_FILENAME = "GameSpyLogin.ini"; -static GameSpyLoginPreferences *loginPref = NULL; - -static void startPings( void ) -{ - std::list pingServers = TheGameSpyConfig->getPingServers(); - Int timeout = TheGameSpyConfig->getPingTimeoutInMs(); - Int reps = TheGameSpyConfig->getNumPingRepetitions(); - - for (std::list::const_iterator it = pingServers.begin(); it != pingServers.end(); ++it) - { - AsciiString pingServer = *it; - PingRequest req; - req.hostname = pingServer.str(); - req.repetitions = reps; - req.timeout = timeout; - ThePinger->addRequest(req); - } -} - -//------------------------------------------------------------------------------------------------- -/** This is called when a shutdown is complete for this menu */ -//------------------------------------------------------------------------------------------------- -static void shutdownComplete( WindowLayout *layout ) -{ - - isShuttingDown = false; - - // hide the layout - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout, (nextScreen != NULL) ); - - if (nextScreen != NULL) - { - if (loginPref) - { - loginPref->write(); - delete loginPref; - loginPref = NULL; - } - TheShell->push(nextScreen); - } - else - { - DEBUG_ASSERTCRASH(loginPref != NULL, ("loginPref == NULL")); - if (loginPref) - { - loginPref->write(); - delete loginPref; - loginPref = NULL; - } - } - - nextScreen = NULL; - -} // end if - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLLoginID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; // profile, quick -static NameKeyType buttonLoginID = NAMEKEY_INVALID; // profile, quick -static NameKeyType buttonCreateAccountID = NAMEKEY_INVALID; // profile, quick -static NameKeyType buttonUseAccountID = NAMEKEY_INVALID; // quick -static NameKeyType buttonDontUseAccountID = NAMEKEY_INVALID; // profile -static NameKeyType buttonTOSID = NAMEKEY_INVALID; // TOS -static NameKeyType parentTOSID = NAMEKEY_INVALID; // TOS Parent -static NameKeyType buttonTOSOKID = NAMEKEY_INVALID; // TOS -static NameKeyType listboxTOSID = NAMEKEY_INVALID; // TOS -static NameKeyType comboBoxEmailID = NAMEKEY_INVALID; // profile -static NameKeyType comboBoxLoginNameID = NAMEKEY_INVALID; // profile -static NameKeyType textEntryLoginNameID = NAMEKEY_INVALID; // quick -static NameKeyType textEntryPasswordID = NAMEKEY_INVALID; // profile -static NameKeyType checkBoxRememberPasswordID = NAMEKEY_INVALID; // checkbox to remember information or not -static NameKeyType textEntryMonthID = NAMEKEY_INVALID; // profile -static NameKeyType textEntryDayID = NAMEKEY_INVALID; // profile -static NameKeyType textEntryYearID = NAMEKEY_INVALID; // profile - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLLogin = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *buttonLogin = NULL; -static GameWindow *buttonCreateAccount = NULL; -static GameWindow *buttonUseAccount = NULL; -static GameWindow *buttonDontUseAccount = NULL; -static GameWindow *buttonTOS = NULL; -static GameWindow *parentTOS = NULL; -static GameWindow *buttonTOSOK = NULL; -static GameWindow *listboxTOS = NULL; -static GameWindow *comboBoxEmail = NULL; -static GameWindow *comboBoxLoginName = NULL; -static GameWindow *textEntryLoginName = NULL; -static GameWindow *textEntryPassword = NULL; -static GameWindow *checkBoxRememberPassword = NULL; -static GameWindow *textEntryMonth = NULL; -static GameWindow *textEntryDay = NULL; -static GameWindow *textEntryYear = NULL; - -void EnableLoginControls( Bool state ) -{ - if (buttonLogin) - buttonLogin->winEnable(state); - if (buttonCreateAccount) - buttonCreateAccount->winEnable(state); - if (buttonUseAccount) - buttonUseAccount->winEnable(state); - if (buttonDontUseAccount) - buttonDontUseAccount->winEnable(state); - if (comboBoxEmail) - comboBoxEmail->winEnable(state); - if (comboBoxLoginName) - comboBoxLoginName->winEnable(state); - if (textEntryLoginName) - textEntryLoginName->winEnable(state); - if (textEntryPassword) - textEntryPassword->winEnable(state); - if (checkBoxRememberPassword) - checkBoxRememberPassword->winEnable(state); - if( buttonTOS ) - buttonTOS->winEnable(state); - - if (textEntryMonth) - textEntryMonth->winEnable(state); - if (textEntryDay) - textEntryDay->winEnable(state); - if( textEntryYear ) - textEntryYear->winEnable(state); -} - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Login Menu */ -//------------------------------------------------------------------------------------------------- -void WOLLoginMenuInit( WindowLayout *layout, void *userData ) -{ - nextScreen = NULL; - buttonPushed = false; - isShuttingDown = false; - loginAttemptTime = 0; - - if (!loginPref) - { - loginPref = NEW GameSpyLoginPreferences; - loginPref->load(PREF_FILENAME); - } - - // if the ESRB warning is blank (other country) hide the box - GameWindow *esrbTitle = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("GameSpyLoginProfile.wnd:StaticTextESRBTop") ); - GameWindow *esrbParent = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("GameSpyLoginProfile.wnd:ParentESRB") ); - if (esrbTitle && esrbParent) - { - if ( GadgetStaticTextGetText( esrbTitle ).getLength() < 2 ) - { - esrbParent->winHide(TRUE); - } - } - - parentWOLLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:WOLLoginMenuParent" ); - buttonBackID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonBack" ); - buttonLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonLogin" ); - buttonCreateAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonCreateAccount" ); - buttonUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonUseAccount" ); - buttonDontUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonDontUseAccount" ); - buttonTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonTOS" ); - parentTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ParentTOS" ); - buttonTOSOKID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonTOSOK" ); - listboxTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ListboxTOS" ); - comboBoxEmailID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ComboBoxEmail" ); - comboBoxLoginNameID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ComboBoxLoginName" ); - textEntryLoginNameID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryLoginName" ); - textEntryPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryPassword" ); - checkBoxRememberPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:CheckBoxRememberInfo" ); - textEntryMonthID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryMonth" ); - textEntryDayID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryDay" ); - textEntryYearID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryYear" ); - - parentWOLLogin = TheWindowManager->winGetWindowFromId( NULL, parentWOLLoginID ); - buttonBack = TheWindowManager->winGetWindowFromId( NULL, buttonBackID); - buttonLogin = TheWindowManager->winGetWindowFromId( NULL, buttonLoginID); - buttonCreateAccount = TheWindowManager->winGetWindowFromId( NULL, buttonCreateAccountID); - buttonUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonUseAccountID); - buttonDontUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonDontUseAccountID); - buttonTOS = TheWindowManager->winGetWindowFromId( NULL, buttonTOSID); - parentTOS = TheWindowManager->winGetWindowFromId( NULL, parentTOSID); - buttonTOSOK = TheWindowManager->winGetWindowFromId( NULL, buttonTOSOKID); - listboxTOS = TheWindowManager->winGetWindowFromId( NULL, listboxTOSID); - comboBoxEmail = TheWindowManager->winGetWindowFromId( NULL, comboBoxEmailID); - comboBoxLoginName = TheWindowManager->winGetWindowFromId( NULL, comboBoxLoginNameID); - textEntryLoginName = TheWindowManager->winGetWindowFromId( NULL, textEntryLoginNameID); - textEntryPassword = TheWindowManager->winGetWindowFromId( NULL, textEntryPasswordID); - checkBoxRememberPassword = TheWindowManager->winGetWindowFromId( NULL, checkBoxRememberPasswordID); - textEntryMonth = TheWindowManager->winGetWindowFromId( NULL, textEntryMonthID); - textEntryDay = TheWindowManager->winGetWindowFromId( NULL, textEntryDayID); - textEntryYear = TheWindowManager->winGetWindowFromId( NULL, textEntryYearID); - - GadgetTextEntrySetText(textEntryMonth, UnicodeString::TheEmptyString); - - GadgetTextEntrySetText(textEntryDay, UnicodeString::TheEmptyString); - - GadgetTextEntrySetText(textEntryYear, UnicodeString::TheEmptyString); - - - - GameWindowList tabList; - tabList.push_front(comboBoxEmail); - tabList.push_back(comboBoxLoginName); - tabList.push_back(textEntryPassword); - tabList.push_back(textEntryMonth); - tabList.push_back(textEntryDay); - tabList.push_back(textEntryYear); - tabList.push_back(checkBoxRememberPassword); - tabList.push_back(buttonLogin); - tabList.push_back(buttonCreateAccount); - tabList.push_back(buttonTOS); - tabList.push_back(buttonBack); - TheWindowManager->clearTabList(); - TheWindowManager->registerTabList(tabList); - TheWindowManager->winSetFocus( comboBoxEmail ); - // short form or long form? -#ifdef ALLOW_NON_PROFILED_LOGIN - if (parentWOLLogin) - { - GameSpyUseProfiles = true; -#endif // ALLOW_NON_PROFILED_LOGIN - - DEBUG_ASSERTCRASH(buttonBack, ("buttonBack missing!")); - DEBUG_ASSERTCRASH(buttonLogin, ("buttonLogin missing!")); - DEBUG_ASSERTCRASH(buttonCreateAccount, ("buttonCreateAccount missing!")); - //DEBUG_ASSERTCRASH(buttonDontUseAccount, ("buttonDontUseAccount missing!")); - DEBUG_ASSERTCRASH(comboBoxEmail, ("comboBoxEmail missing!")); - DEBUG_ASSERTCRASH(comboBoxLoginName, ("comboBoxLoginName missing!")); - DEBUG_ASSERTCRASH(textEntryPassword, ("textEntryPassword missing!")); - - //TheShell->registerWithAnimateManager(parentWOLLogin, WIN_ANIMATION_SLIDE_TOP, TRUE); - /**/ -// TheShell->registerWithAnimateManager(buttonTOS, WIN_ANIMATION_SLIDE_BOTTOM, TRUE); - //TheShell->registerWithAnimateManager(buttonCreateAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE); - //TheShell->registerWithAnimateManager(buttonDontUseAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE); -// TheShell->registerWithAnimateManager(buttonBack, WIN_ANIMATION_SLIDE_BOTTOM, TRUE); - /**/ -#ifdef ALLOW_NON_PROFILED_LOGIN - } - else - { - GameSpyUseProfiles = false; - - parentWOLLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:WOLLoginMenuParent" ); - buttonBackID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonBack" ); - buttonLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonLogin" ); - buttonCreateAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonCreateAccount" ); - buttonUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonUseAccount" ); - buttonDontUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonDontUseAccount" ); - buttonTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonTOS" ); - parentTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ParentTOS" ); - buttonTOSOKID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonTOSOK" ); - listboxTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ListboxTOS" ); - comboBoxEmailID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ComboBoxEmail" ); - textEntryLoginNameID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:TextEntryLoginName" ); - textEntryPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:TextEntryPassword" ); - checkBoxRememberPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:CheckBoxRememberPassword" ); - - parentWOLLogin = TheWindowManager->winGetWindowFromId( NULL, parentWOLLoginID ); - buttonBack = TheWindowManager->winGetWindowFromId( NULL, buttonBackID); - buttonLogin = TheWindowManager->winGetWindowFromId( NULL, buttonLoginID); - buttonCreateAccount = TheWindowManager->winGetWindowFromId( NULL, buttonCreateAccountID); - buttonUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonUseAccountID); - buttonDontUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonDontUseAccountID); - comboBoxEmail = TheWindowManager->winGetWindowFromId( NULL, comboBoxEmailID); - buttonTOS = TheWindowManager->winGetWindowFromId( NULL, buttonTOSID); - parentTOS = TheWindowManager->winGetWindowFromId( NULL, parentTOSID); - buttonTOSOK = TheWindowManager->winGetWindowFromId( NULL, buttonTOSOKID); - listboxTOS = TheWindowManager->winGetWindowFromId( NULL, listboxTOSID); - textEntryLoginName = TheWindowManager->winGetWindowFromId( NULL, textEntryLoginNameID); - textEntryPassword = TheWindowManager->winGetWindowFromId( NULL, textEntryPasswordID); - checkBoxRememberPassword = TheWindowManager->winGetWindowFromId( NULL, checkBoxRememberPasswordID); - - DEBUG_ASSERTCRASH(buttonBack, ("buttonBack missing!")); - DEBUG_ASSERTCRASH(buttonLogin, ("buttonLogin missing!")); - DEBUG_ASSERTCRASH(buttonCreateAccount, ("buttonCreateAccount missing!")); - DEBUG_ASSERTCRASH(buttonUseAccount, ("buttonUseAccount missing!")); - DEBUG_ASSERTCRASH(textEntryLoginName, ("textEntryLoginName missing!")); - TheWindowManager->winSetFocus( textEntryLoginName ); - //TheShell->registerWithAnimateManager(parentWOLLogin, WIN_ANIMATION_SLIDE_TOP, TRUE); - -// TheShell->registerWithAnimateManager(buttonTOS, WIN_ANIMATION_SLIDE_LEFT, TRUE); -// TheShell->registerWithAnimateManager(buttonCreateAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE); -// TheShell->registerWithAnimateManager(buttonUseAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE); -// TheShell->registerWithAnimateManager(buttonBack, WIN_ANIMATION_SLIDE_RIGHT, TRUE); - - } -#endif // ALLOW_NON_PROFILED_LOGIN - - -#ifdef ALLOW_NON_PROFILED_LOGIN - if (GameSpyUseProfiles) - { -#endif // ALLOW_NON_PROFILED_LOGIN - // Read login names from registry... - GadgetComboBoxReset(comboBoxEmail); - GadgetTextEntrySetText(textEntryPassword, UnicodeString.TheEmptyString); - - // look for cached nicks to add - AsciiString lastName; - AsciiString lastEmail; - Bool markCheckBox = FALSE; - UserPreferences::const_iterator it = loginPref->find("lastName"); - if (it != loginPref->end()) - { - lastName = it->second; - } - it = loginPref->find("lastEmail"); - if (it != loginPref->end()) - { - lastEmail = it->second; - } - - // fill in list of Emails, and select the most recent - AsciiStringList cachedEmails = loginPref->getEmails(); - AsciiStringListIterator eIt = cachedEmails.begin(); - Int selectedPos = -1; - while (eIt != cachedEmails.end()) - { - UnicodeString uniEmail; - uniEmail.translate(*eIt); - Int pos = GadgetComboBoxAddEntry(comboBoxEmail, uniEmail, GameSpyColor[GSCOLOR_DEFAULT]); - if (*eIt == lastEmail) - selectedPos = pos; - - ++eIt; - } - if (selectedPos >= 0) - { - GadgetComboBoxSetSelectedPos(comboBoxEmail, selectedPos); - - // fill in the password for the selected email - UnicodeString pass; - pass.translate(loginPref->getPasswordForEmail(lastEmail)); - GadgetTextEntrySetText(textEntryPassword, pass); - - AsciiString month,day,year; - loginPref->getDateForEmail(lastEmail, month, day, year); - pass.translate(month); - GadgetTextEntrySetText(textEntryMonth, pass); - pass.translate(day); - GadgetTextEntrySetText(textEntryDay, pass); - pass.translate(year); - GadgetTextEntrySetText(textEntryYear, pass); - - markCheckBox = TRUE; - } - - // fill in list of nicks for selected email, selecting the most recent - GadgetComboBoxReset(comboBoxLoginName); - AsciiStringList cachedNicks = loginPref->getNicksForEmail(lastEmail); - AsciiStringListIterator nIt = cachedNicks.begin(); - selectedPos = -1; - while (nIt != cachedNicks.end()) - { - UnicodeString uniNick; - uniNick.translate(*nIt); - Int pos = GadgetComboBoxAddEntry(comboBoxLoginName, uniNick, GameSpyColor[GSCOLOR_DEFAULT]); - if (*nIt == lastName) - selectedPos = pos; - - ++nIt; - } - if (selectedPos >= 0) - { - GadgetComboBoxSetSelectedPos(comboBoxLoginName, selectedPos); - markCheckBox = TRUE; - } - // always start with not storing information - if( markCheckBox) - GadgetCheckBoxSetChecked(checkBoxRememberPassword, TRUE); - else - GadgetCheckBoxSetChecked(checkBoxRememberPassword, FALSE); -#ifdef ALLOW_NON_PROFILED_LOGIN - } - else - { - // Read login names from registry... - GadgetComboBoxReset(comboBoxLoginName); - UnicodeString nick; - - UserPreferences::const_iterator it = loginPref->find("lastName"); - if (it != loginPref->end()) - { - nick.translate(it->second); - } - else - { - char userBuf[32] = ""; - unsigned long bufSize = 32; - GetUserName(userBuf, &bufSize); - nick.translate(userBuf); - } - - GadgetTextEntrySetText(textEntryLoginName, nick); - } -#endif // ALLOW_NON_PROFILED_LOGIN - - EnableLoginControls(TRUE); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - - RaiseGSMessageBox(); - - OptionPreferences optionPref; - if (!optionPref.getBool("SawTOS", TRUE)) - { - TheWindowManager->winSendSystemMsg( parentWOLLogin, GBM_SELECTED, - (WindowMsgData)buttonTOS, buttonTOSID ); - } - TheTransitionHandler->setGroup("GameSpyLoginProfileFade"); - -} // WOLLoginMenuInit - -//------------------------------------------------------------------------------------------------- -/** WOL Login Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -static Bool loggedInOK = false; -void WOLLoginMenuShutdown( WindowLayout *layout, void *userData ) -{ - isShuttingDown = true; - loggedInOK = false; - TheWindowManager->clearTabList(); - - // if we are shutting down for an immediate pop, skip the animations - Bool popImmediate = *(Bool *)userData; - if( popImmediate ) - { - - shutdownComplete( layout ); - return; - - } //end if - - TheShell->reverseAnimatewindow(); - TheTransitionHandler->reverse("GameSpyLoginProfileFade"); - -} // WOLLoginMenuShutdown - - -// this is used to check if we've got all the pings -static void checkLogin( void ) -{ - if (loggedInOK && ThePinger && !ThePinger->arePingsInProgress()) - { - // save off our ping string, and end those threads - AsciiString pingStr = ThePinger->getPingString( 1000 ); - DEBUG_LOG(("Ping string is %s\n", pingStr.str())); - TheGameSpyInfo->setPingString(pingStr); - //delete ThePinger; - //ThePinger = NULL; - - buttonPushed = true; - loggedInOK = false; // don't try this again - - loginAttemptTime = 0; - - // start looking for group rooms - TheGameSpyInfo->clearGroupRoomList(); - - SignalUIInteraction(SHELL_SCRIPT_HOOK_GENERALS_ONLINE_LOGIN); - nextScreen = "Menus/WOLWelcomeMenu.wnd"; - TheShell->pop(); - - // read in some cached data - GameSpyMiscPreferences mPref; - PSPlayerStats localPSStats = GameSpyPSMessageQueueInterface::parsePlayerKVPairs(mPref.getCachedStats().str()); - localPSStats.id = TheGameSpyInfo->getLocalProfileID(); - TheGameSpyInfo->setCachedLocalPlayerStats(localPSStats); -// TheGameSpyPSMessageQueue->trackPlayerStats(localPSStats); - - // and push the info around to other players -// PSResponse newResp; -// newResp.responseType = PSResponse::PSRESPONSE_PLAYERSTATS; -// newResp.player = localPSStats; -// TheGameSpyPSMessageQueue->addResponse(newResp); - } -} - -//------------------------------------------------------------------------------------------------- -/** WOL Login Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLLoginMenuUpdate( WindowLayout * layout, void *userData) -{ - - // We'll only be successful if we've requested to - if(isShuttingDown && TheShell->isAnimFinished() && TheTransitionHandler->isFinished()) - shutdownComplete(layout); - - if (TheShell->isAnimFinished() && !buttonPushed && TheGameSpyPeerMessageQueue) - { - PingResponse pingResp; - if (ThePinger && ThePinger->getResponse(pingResp)) - { - checkLogin(); - } - - PeerResponse resp; - if (!loggedInOK && TheGameSpyPeerMessageQueue->getResponse( resp )) - { - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_GROUPROOM: - { - GameSpyGroupRoom room; - room.m_groupID = resp.groupRoom.id; - room.m_maxWaiting = resp.groupRoom.maxWaiting; - room.m_name = resp.groupRoomName.c_str(); - room.m_translatedName = UnicodeString(L"TEST"); - room.m_numGames = resp.groupRoom.numGames; - room.m_numPlaying = resp.groupRoom.numPlaying; - room.m_numWaiting = resp.groupRoom.numWaiting; - TheGameSpyInfo->addGroupRoom( room ); - } - break; - case PeerResponse::PEERRESPONSE_LOGIN: - { - loggedInOK = true; - - // fetch our player info - TheGameSpyInfo->setLocalName( resp.nick.c_str() ); - TheGameSpyInfo->setLocalProfileID( resp.player.profileID ); - TheGameSpyInfo->loadSavedIgnoreList(); - TheGameSpyInfo->setLocalIPs(resp.player.internalIP, resp.player.externalIP); - TheGameSpyInfo->readAdditionalDisconnects(); - //TheGameSpyInfo->setLocalEmail( resp.player.email ); - //TheGameSpyInfo->setLocalPassword( resp) - - GameSpyMiscPreferences miscPref; - TheGameSpyInfo->setMaxMessagesPerUpdate(miscPref.getMaxMessagesPerUpdate()); - } - break; - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - loginAttemptTime = 0; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GSMessageBoxOk( title, body ); - EnableLoginControls( TRUE ); - - // kill & restart the threads - AsciiString motd = TheGameSpyInfo->getMOTD(); - AsciiString config = TheGameSpyInfo->getConfig(); - DEBUG_LOG(("Tearing down GameSpy from WOLLoginMenuUpdate(PEERRESPONSE_DISCONNECT)\n")); - TearDownGameSpy(); - SetUpGameSpy( motd.str(), config.str() ); - } - break; - } - } - - checkLogin(); - } - - if (TheGameSpyInfo && !buttonPushed && loginAttemptTime && (loginAttemptTime + loginTimeoutInMS < timeGetTime())) - { - // timed out a login attempt, so say so - loginAttemptTime = 0; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason4"); // ("could not connect to server") - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GSMessageBoxOk( title, body ); - EnableLoginControls( TRUE ); - - // kill & restart the threads - AsciiString motd = TheGameSpyInfo->getMOTD(); - AsciiString config = TheGameSpyInfo->getConfig(); - DEBUG_LOG(("Tearing down GameSpy from WOLLoginMenuUpdate(login timeout)\n")); - TearDownGameSpy(); - SetUpGameSpy( motd.str(), config.str() ); - } - -}// WOLLoginMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Login Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLoginMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - if (buttonPushed) - break; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLLoginMenuInput - -static Bool isNickOkay(UnicodeString nick) -{ - static const WideChar * legalIRCChars = L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789[]`_^{|}-"; - - Int len = nick.getLength(); - if (len == 0) - return TRUE; - - if (len == 1 && nick.getCharAt(0) == L'-') - return FALSE; - - WideChar newChar = nick.getCharAt(len-1); - if (wcschr(legalIRCChars, newChar) == NULL) - return FALSE; - - return TRUE; -} - -static Bool isAgeOkay(AsciiString &month, AsciiString &day, AsciiString year) -{ - if(month.isEmpty() || day.isEmpty() || year.isEmpty() || year.getLength() != 4) - return FALSE; - - Int monthInt = atoi(month.str()); - Int dayInt = atoi(day.str()); - - if(monthInt > 12 || dayInt > 31) - return FALSE; - // setup date buffer for local region date format - month.format("%02.2d",monthInt); - day.format("%02.2d",dayInt); - - // test the year first - #define DATE_BUFFER_SIZE 256 - char dateBuffer[ DATE_BUFFER_SIZE ]; - GetDateFormat( LOCALE_SYSTEM_DEFAULT, - 0, NULL, - "yyyy", - dateBuffer, DATE_BUFFER_SIZE ); - Int sysVal = atoi(dateBuffer); - Int userVal = atoi(year.str()); - if(sysVal - userVal >= 14) - return TRUE; - else if( sysVal - userVal <= 12) - return FALSE; - - GetDateFormat( LOCALE_SYSTEM_DEFAULT, - 0, NULL, - "MM", - dateBuffer, DATE_BUFFER_SIZE ); - sysVal = atoi(dateBuffer); - userVal = atoi(month.str()); - if(sysVal - userVal >0 ) - return TRUE; - else if( sysVal -userVal < 0 ) - return FALSE; -// month.format("%02.2d",userVal); - GetDateFormat( LOCALE_SYSTEM_DEFAULT, - 0, NULL, - "dd", - dateBuffer, DATE_BUFFER_SIZE ); - sysVal = atoi(dateBuffer); - userVal = atoi(day.str()); - if(sysVal - userVal< 0) - return FALSE; -// day.format("%02.2d",userVal); - return TRUE; -} - -//------------------------------------------------------------------------------------------------- -/** WOL Login Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLoginMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - // someone typed in a combo box. Clear password (or fill it in if the typed name matches a known login name) - case GCM_UPDATE_TEXT: - { - UnicodeString uNick = GadgetComboBoxGetText(comboBoxLoginName); - UnicodeString uEmail = GadgetComboBoxGetText(comboBoxEmail); - AsciiString nick, email; - nick.translate(uNick); - email.translate(uEmail); - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - UnicodeString trimmedNick = uNick, trimmedEmail = uEmail; - trimmedNick.trim(); - trimmedEmail.trim(); - if (!trimmedNick.isEmpty()) - { - if (trimmedNick.getCharAt(trimmedNick.getLength()-1) == L'\\') - trimmedNick.removeLastChar(); - if (trimmedNick.getCharAt(trimmedNick.getLength()-1) == L'/') - trimmedNick.removeLastChar(); - } - if (!trimmedEmail.isEmpty()) - { - if (trimmedEmail.getCharAt(trimmedEmail.getLength()-1) == L'\\') - trimmedEmail.removeLastChar(); - if (trimmedEmail.getCharAt(trimmedEmail.getLength()-1) == L'/') - trimmedEmail.removeLastChar(); - } - if (trimmedEmail.getLength() != uEmail.getLength()) - { - // we just trimmed a space. set the text back and bail - GadgetComboBoxSetText(comboBoxEmail, trimmedEmail); - break; - } - if (trimmedNick.getLength() != nick.getLength()) - { - // we just trimmed a space. set the text back and bail - GadgetComboBoxSetText(comboBoxLoginName, trimmedNick); - break; - } - - if (controlID == comboBoxEmailID) - { - // email changed. look up password, and choose new login names - - // fill in the password for the selected email - UnicodeString pass; - pass.translate(loginPref->getPasswordForEmail(email)); - GadgetTextEntrySetText(textEntryPassword, pass); - - // fill in list of nicks for selected email, selecting the first - AsciiStringList cachedNicks = loginPref->getNicksForEmail(email); - AsciiStringListIterator nIt = cachedNicks.begin(); - Int selectedPos = -1; - GadgetComboBoxReset(comboBoxLoginName); - while (nIt != cachedNicks.end()) - { - UnicodeString uniNick; - uniNick.translate(*nIt); - GadgetComboBoxAddEntry(comboBoxLoginName, uniNick, GameSpyColor[GSCOLOR_DEFAULT]); - selectedPos = 0; - ++nIt; - } - if (selectedPos >= 0) - { - GadgetComboBoxSetSelectedPos(comboBoxLoginName, selectedPos); - GadgetCheckBoxSetChecked(checkBoxRememberPassword, true); - AsciiString month,day,year; - loginPref->getDateForEmail(email, month, day, year); - pass.translate(month); - GadgetTextEntrySetText(textEntryMonth, pass); - pass.translate(day); - GadgetTextEntrySetText(textEntryDay, pass); - pass.translate(year); - GadgetTextEntrySetText(textEntryYear, pass); - - } - else - { - GadgetCheckBoxSetChecked(checkBoxRememberPassword, false); - GadgetTextEntrySetText(textEntryMonth, UnicodeString::TheEmptyString); - GadgetTextEntrySetText(textEntryDay, UnicodeString::TheEmptyString); - GadgetTextEntrySetText(textEntryYear, UnicodeString::TheEmptyString); - - } - } - else if (controlID == comboBoxLoginNameID) - { - // they typed a new login name. Email & pass shouldn't change - } - - break; - } - - case GCM_SELECTED: - { - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if (controlID == comboBoxEmailID) - { - // email changed. look up password, and choose new login names - UnicodeString uEmail = GadgetComboBoxGetText(comboBoxEmail); - AsciiString email; - email.translate(uEmail); - - // fill in the password for the selected email - UnicodeString pass; - pass.translate(loginPref->getPasswordForEmail(email)); - GadgetTextEntrySetText(textEntryPassword, pass); - - // fill in list of nicks for selected email, selecting the first - AsciiStringList cachedNicks = loginPref->getNicksForEmail(email); - AsciiStringListIterator nIt = cachedNicks.begin(); - Int selectedPos = -1; - GadgetComboBoxReset(comboBoxLoginName); - while (nIt != cachedNicks.end()) - { - UnicodeString uniNick; - uniNick.translate(*nIt); - GadgetComboBoxAddEntry(comboBoxLoginName, uniNick, GameSpyColor[GSCOLOR_DEFAULT]); - selectedPos = 0; - ++nIt; - } - if (selectedPos >= 0) - { - GadgetComboBoxSetSelectedPos(comboBoxLoginName, selectedPos); - GadgetCheckBoxSetChecked(checkBoxRememberPassword, true); - AsciiString month,day,year; - loginPref->getDateForEmail(email, month, day, year); - pass.translate(month); - GadgetTextEntrySetText(textEntryMonth, pass); - pass.translate(day); - GadgetTextEntrySetText(textEntryDay, pass); - pass.translate(year); - GadgetTextEntrySetText(textEntryYear, pass); - - } - else - { - GadgetCheckBoxSetChecked(checkBoxRememberPassword, false); - GadgetTextEntrySetText(textEntryMonth, UnicodeString::TheEmptyString); - GadgetTextEntrySetText(textEntryDay, UnicodeString::TheEmptyString); - GadgetTextEntrySetText(textEntryYear, UnicodeString::TheEmptyString); - } - - } - else if (controlID == comboBoxLoginNameID) - { - // they typed a new login name. Email & pass shouldn't change - } - break; - } - - case GBM_SELECTED: - { - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - // If we back out, just bail - we haven't gotten far enough to need to log out - if ( controlID == buttonBackID ) - { - buttonPushed = true; - TearDownGameSpy(); - TheShell->pop(); - } //if ( controlID == buttonBack ) -#ifdef ALLOW_NON_PROFILED_LOGIN - else if ( controlID == buttonUseAccountID ) - { - buttonPushed = true; - nextScreen = "Menus/GameSpyLoginProfile.wnd"; - TheShell->pop(); - //TheShell->push( "Menus/GameSpyLoginProfile.wnd" ); - } //if ( controlID == buttonUseAccount ) - else if ( controlID == buttonDontUseAccountID ) - { - buttonPushed = true; - nextScreen = "Menus/GameSpyLoginQuick.wnd"; - TheShell->pop(); - //TheShell->push( "Menus/GameSpyLoginQuick.wnd" ); - } //if ( controlID == buttonDontUseAccount ) -#endif // ALLOW_NON_PROFILED_LOGIN - else if ( controlID == buttonCreateAccountID ) - { -#ifdef ALLOW_NON_PROFILED_LOGIN - if (GameSpyUseProfiles) - { -#endif // ALLOW_NON_PROFILED_LOGIN - // actually attempt to create an account based on info entered - AsciiString month, day, year; - month.translate( GadgetTextEntryGetText(textEntryMonth) ); - day.translate( GadgetTextEntryGetText(textEntryDay) ); - year.translate( GadgetTextEntryGetText(textEntryYear) ); - - if(!isAgeOkay(month, day, year)) - { - GSMessageBoxOk(TheGameText->fetch("GUI:AgeFailedTitle"), TheGameText->fetch("GUI:AgeFailed")); - break; - } - - AsciiString login, password, email; - email.translate( GadgetComboBoxGetText(comboBoxEmail) ); - login.translate( GadgetComboBoxGetText(comboBoxLoginName) ); - password.translate( GadgetTextEntryGetText(textEntryPassword) ); - - if ( !email.isEmpty() && !login.isEmpty() && !password.isEmpty() ) - { - loginAttemptTime = timeGetTime(); - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_LOGINNEW; - strcpy(req.arg.login.nick, login.str()); - strcpy(req.arg.login.email, email.str()); - strcpy(req.arg.login.password, password.str()); - req.arg.login.hasFirewall = TRUE; - - TheGameSpyInfo->setLocalBaseName( login ); - //TheGameSpyInfo->setLocalProfileID( resp.player.profileID ); - TheGameSpyInfo->setLocalEmail( email ); - TheGameSpyInfo->setLocalPassword( password ); - DEBUG_LOG(("before create: TheGameSpyInfo->stuff(%s/%s/%s)\n", TheGameSpyInfo->getLocalBaseName().str(), TheGameSpyInfo->getLocalEmail().str(), TheGameSpyInfo->getLocalPassword().str())); - - TheGameSpyBuddyMessageQueue->addRequest( req ); - if(checkBoxRememberPassword && GadgetCheckBoxIsChecked(checkBoxRememberPassword)) - { - (*loginPref)["lastName"] = login; - (*loginPref)["lastEmail"] = email; - (*loginPref)["useProfiles"] = "yes"; - AsciiString date; - date = month; - date.concat(day); - date.concat(year); - - loginPref->addLogin(email, login, password, date); - } - - EnableLoginControls( FALSE ); - - // fire off some pings - startPings(); - } - else - { - // user didn't fill in all info. prompt him. - if(email.isEmpty() && login.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoAll")); - else if( email.isEmpty() && login.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoEmailNickname")); - else if( email.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoEmailPassword")); - else if( login.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoNicknamePassword")); - else if( email.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoEmail")); - else if( password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoPassword")); - else if( login.isEmpty() ) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoNickname")); - else - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoAll")); - } -#ifdef ALLOW_NON_PROFILED_LOGIN - } - else - { - // not the profile screen - switch to it - buttonPushed = TRUE; - nextScreen = "Menus/GameSpyLoginProfile.wnd"; - TheShell->pop(); - } -#endif // ALLOW_NON_PROFILED_LOGIN - } //if ( controlID == buttonCreateAccount ) - else if ( controlID == buttonLoginID ) - { - AsciiString login, password, email; - -#ifdef ALLOW_NON_PROFILED_LOGIN - if (GameSpyUseProfiles) - { -#endif // ALLOW_NON_PROFILED_LOGIN - AsciiString month, day, year; - month.translate( GadgetTextEntryGetText(textEntryMonth) ); - day.translate( GadgetTextEntryGetText(textEntryDay) ); - year.translate( GadgetTextEntryGetText(textEntryYear) ); - - if(!isAgeOkay(month, day, year)) - { - GSMessageBoxOk(TheGameText->fetch("GUI:AgeFailedTitle"), TheGameText->fetch("GUI:AgeFailed")); - break; - } - - email.translate( GadgetComboBoxGetText(comboBoxEmail) ); - login.translate( GadgetComboBoxGetText(comboBoxLoginName) ); - password.translate( GadgetTextEntryGetText(textEntryPassword) ); - - if ( !email.isEmpty() && !login.isEmpty() && !password.isEmpty() ) - { - loginAttemptTime = timeGetTime(); - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_LOGIN; - strcpy(req.arg.login.nick, login.str()); - strcpy(req.arg.login.email, email.str()); - strcpy(req.arg.login.password, password.str()); - req.arg.login.hasFirewall = true; - - TheGameSpyInfo->setLocalBaseName( login ); - //TheGameSpyInfo->setLocalProfileID( resp.player.profileID ); - TheGameSpyInfo->setLocalEmail( email ); - TheGameSpyInfo->setLocalPassword( password ); - DEBUG_LOG(("before login: TheGameSpyInfo->stuff(%s/%s/%s)\n", TheGameSpyInfo->getLocalBaseName().str(), TheGameSpyInfo->getLocalEmail().str(), TheGameSpyInfo->getLocalPassword().str())); - - TheGameSpyBuddyMessageQueue->addRequest( req ); - if(checkBoxRememberPassword && GadgetCheckBoxIsChecked(checkBoxRememberPassword)) - { - (*loginPref)["lastName"] = login; - (*loginPref)["lastEmail"] = email; - (*loginPref)["useProfiles"] = "yes"; - AsciiString date; - date = month; - date.concat(day); - date.concat(year); - - loginPref->addLogin(email, login, password,date); - } - else - { - loginPref->forgetLogin(email); - } - EnableLoginControls( FALSE ); - - // fire off some pings - startPings(); - } - else - { - // user didn't fill in all info. prompt him. - if(email.isEmpty() && login.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoAll")); - else if( email.isEmpty() && login.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoEmailNickname")); - else if( email.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoEmailPassword")); - else if( login.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoNicknamePassword")); - else if( email.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoEmail")); - else if( password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoPassword")); - else if( login.isEmpty() ) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoNickname")); - else - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoAll")); - } -#ifdef ALLOW_NON_PROFILED_LOGIN - } - else - { - login.translate( GadgetTextEntryGetText(textEntryLoginName) ); - - if ( !login.isEmpty() ) - { - loginAttemptTime = timeGetTime(); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_LOGIN; - req.nick = login.str(); - req.login.profileID = 0; - TheGameSpyPeerMessageQueue->addRequest( req ); - - (*loginPref)["lastName"] = login; - loginPref->erase("lastEmail"); - (*loginPref)["useProfiles"] = "no"; - EnableLoginControls( FALSE ); - - // fire off some pings - startPings(); - } - } -#endif // ALLOW_NON_PROFILED_LOGIN - - } //if ( controlID == buttonLogin ) - else if ( controlID == buttonTOSID ) - { - parentTOS->winHide(FALSE); - - if (1) - { - // Okay, no web browser. This means we're looking at a UTF-8 text file. - GadgetListBoxReset(listboxTOS); - AsciiString fileName; - fileName.format("Data\\%s\\TOS.txt", GetRegistryLanguage().str()); - File *theFile = TheFileSystem->openFile(fileName.str(), File::READ); - if (theFile) - { - Int size = theFile->size(); - - char *fileBuf = new char[size]; - Color tosColor = GameMakeColor(255, 255, 255, 255); - - Int bytesRead = theFile->read(fileBuf, size); - if (bytesRead == size && size > 2) - { - fileBuf[size-1] = 0; // just to be safe - AsciiString asciiBuf = fileBuf+2; - AsciiString asciiLine; - while (asciiBuf.nextToken(&asciiLine, "\r\n")) - { - UnicodeString uniLine; - uniLine = UnicodeString(MultiByteToWideCharSingleLine(asciiLine.str()).c_str()); - int len = uniLine.getLength(); - for (int index = len-1; index >= 0; index--) - { - if (iswspace(uniLine.getCharAt(index))) - { - uniLine.removeLastChar(); - } - else - { - break; - } - } - //uniLine.trim(); - DEBUG_LOG(("adding TOS line: [%ls]\n", uniLine.str())); - GadgetListBoxAddEntryText(listboxTOS, uniLine, tosColor, -1); - } - - } - - delete fileBuf; - fileBuf = NULL; - - theFile->close(); - theFile = NULL; - } - } - EnableLoginControls( FALSE ); - buttonBack->winEnable(FALSE); - - } - else if ( controlID == buttonTOSOKID ) - { - EnableLoginControls( TRUE ); - - parentTOS->winHide(TRUE); - - OptionPreferences optionPref; - optionPref["SawTOS"] = "yes"; - optionPref.write(); - buttonBack->winEnable(TRUE); - } - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - /* - case GEM_UPDATE_TEXT: - { - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == textEntryLoginNameID ) - { - UnicodeString munkee = GadgetTextEntryGetText( textEntryLoginName ); - if ( !isNickOkay( munkee ) ) - { - munkee.removeLastChar(); - GadgetTextEntrySetText( textEntryLoginName, munkee ); - } - }// if ( controlID == textEntryLoginNameID ) - break; - }//case GEM_UPDATE_TEXT: - */ - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLLoginMenuSystem - - diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp deleted file mode 100644 index 7cef8850394..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: WOLMapSelectMenu.cpp //////////////////////////////////////////////////////////////////////// -// Author: Matt Campbell, December 2001 -// Description: MapSelect menu window callbacks -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/CustomMatchPreferences.h" -#include "Common/GameEngine.h" -#include "Common/MessageStream.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GadgetRadioButton.h" -#include "GameClient/Shell.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameClient/MapUtil.h" -#include "GameNetwork/GUIUtil.h" - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -static NameKeyType buttonBack = NAMEKEY_INVALID; -static NameKeyType buttonOK = NAMEKEY_INVALID; -static NameKeyType listboxMap = NAMEKEY_INVALID; -static GameWindow *parent = NULL; -static Bool raiseMessageBoxes = FALSE; -static GameWindow *winMapPreview = NULL; -static NameKeyType winMapPreviewID = NAMEKEY_INVALID; - -static NameKeyType radioButtonSystemMapsID = NAMEKEY_INVALID; -static NameKeyType radioButtonUserMapsID = NAMEKEY_INVALID; - -extern WindowLayout *WOLMapSelectLayout; ///< Map selection overlay -static GameWindow *mapList = NULL; - -static GameWindow *buttonMapStartPosition[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; -static NameKeyType buttonMapStartPositionID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static GameWindow *winMapWindow = NULL; - -static void NullifyControls(void) -{ - parent = NULL; - winMapPreview = NULL; - mapList = NULL; - for (Int i=0; iwinGetWindowFromId( NULL, TheNameKeyGenerator->nameToKey("GameSpyGameOptionsMenu.wnd:ButtonBack") ); - if(win) - win->winEnable( show ); -} - -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------------------------------- -/** Initialize the MapSelect menu */ -//------------------------------------------------------------------------------------------------- -void WOLMapSelectMenuInit( WindowLayout *layout, void *userData ) -{ - - // set keyboard focus to main parent - AsciiString parentName( "WOLMapSelectMenu.wnd:WOLMapSelectMenuParent" ); - NameKeyType parentID = TheNameKeyGenerator->nameToKey( parentName ); - parent = TheWindowManager->winGetWindowFromId( NULL, parentID ); - - TheWindowManager->winSetFocus( parent ); - - CustomMatchPreferences pref; - Bool usesSystemMapDir = pref.usesSystemMapDir(); - winMapPreviewID = TheNameKeyGenerator->nameToKey( AsciiString("WOLMapSelectMenu.wnd:WinMapPreview") ); - winMapPreview = TheWindowManager->winGetWindowFromId(parent, winMapPreviewID); - - const MapMetaData *mmd = TheMapCache->findMap(TheGameSpyGame->getMap()); - if (mmd) - { - usesSystemMapDir = mmd->m_isOfficial; - } - - buttonBack = TheNameKeyGenerator->nameToKey( AsciiString("WOLMapSelectMenu.wnd:ButtonBack") ); - buttonOK = TheNameKeyGenerator->nameToKey( AsciiString("WOLMapSelectMenu.wnd:ButtonOK") ); - listboxMap = TheNameKeyGenerator->nameToKey( AsciiString("WOLMapSelectMenu.wnd:ListboxMap") ); - radioButtonSystemMapsID = TheNameKeyGenerator->nameToKey( "WOLMapSelectMenu.wnd:RadioButtonSystemMaps" ); - radioButtonUserMapsID = TheNameKeyGenerator->nameToKey( "WOLMapSelectMenu.wnd:RadioButtonUserMaps" ); - winMapWindow = TheWindowManager->winGetWindowFromId( parent, listboxMap ); - - GameWindow *radioButtonSystemMaps = TheWindowManager->winGetWindowFromId( parent, radioButtonSystemMapsID ); - GameWindow *radioButtonUserMaps = TheWindowManager->winGetWindowFromId( parent, radioButtonUserMapsID ); - if (usesSystemMapDir) - GadgetRadioSetSelection( radioButtonSystemMaps, FALSE ); - else - GadgetRadioSetSelection( radioButtonUserMaps, FALSE ); - - AsciiString tmpString; - for (Int i = 0; i < MAX_SLOTS; i++) - { - tmpString.format("WOLMapSelectMenu.wnd:ButtonMapStartPosition%d", i); - buttonMapStartPositionID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - buttonMapStartPosition[i] = TheWindowManager->winGetWindowFromId( winMapPreview, buttonMapStartPositionID[i] ); - DEBUG_ASSERTCRASH(buttonMapStartPosition[i], ("Could not find the ButtonMapStartPosition[%d]",i )); - buttonMapStartPosition[i]->winHide(TRUE); - buttonMapStartPosition[i]->winEnable(FALSE); - } - - raiseMessageBoxes = TRUE; - showGameSpyGameOptionsUnderlyingGUIElements( FALSE ); - - // get the listbox window - AsciiString listString( "WOLMapSelectMenu.wnd:ListboxMap" ); - NameKeyType mapListID = TheNameKeyGenerator->nameToKey( listString ); - mapList = TheWindowManager->winGetWindowFromId( parent, mapListID ); - if( mapList ) - { - if (TheMapCache) - TheMapCache->updateCache(); - populateMapListbox( mapList, usesSystemMapDir, TRUE, TheGameSpyGame->getMap() ); - } - -} // end WOLMapSelectMenuInit - -//------------------------------------------------------------------------------------------------- -/** MapSelect menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLMapSelectMenuShutdown( WindowLayout *layout, void *userData ) -{ - NullifyControls(); - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); - -} // end WOLMapSelectMenuShutdown - -//------------------------------------------------------------------------------------------------- -/** MapSelect menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLMapSelectMenuUpdate( WindowLayout *layout, void *userData ) -{ - - if (raiseMessageBoxes) - { - RaiseGSMessageBox(); - raiseMessageBoxes = false; - } - - // No update because the game setup screen is up at the same - // time and it does the update for us... -} // end WOLMapSelectMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** Map select menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLMapSelectMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - AsciiString buttonName( "WOLMapSelectMenu.wnd:ButtonBack" ); - NameKeyType buttonID = TheNameKeyGenerator->nameToKey( buttonName ); - GameWindow *button = TheWindowManager->winGetWindowFromId( window, buttonID ); - - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)button, buttonID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; - -} // end WOLMapSelectMenuInput -void WOLPositionStartSpots( void ); - -//------------------------------------------------------------------------------------------------- -/** MapSelect menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLMapSelectMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CREATE: - { - break; - - } // end create - - //--------------------------------------------------------------------------------------------- - case GWM_DESTROY: - { - NullifyControls(); - break; - - } // end case - - // -------------------------------------------------------------------------------------------- - case GWM_INPUT_FOCUS: - { - - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - - } // end input - - //--------------------------------------------------------------------------------------------- - case GLM_DOUBLE_CLICKED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if( controlID == listboxMap ) - { - int rowSelected = mData2; - - if (rowSelected >= 0) - { - GadgetListBoxSetSelected( control, rowSelected ); - GameWindow *button = TheWindowManager->winGetWindowFromId( window, buttonOK ); - - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)button, buttonOK ); - } - } - break; - } - //--------------------------------------------------------------------------------------------- - case GLM_SELECTED: - { - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if( controlID == listboxMap ) - { - int rowSelected = mData2; - if( rowSelected < 0 ) - { - positionStartSpots( AsciiString::TheEmptyString, buttonMapStartPosition, winMapPreview); -// winMapPreview->winClearStatus(WIN_STATUS_IMAGE); - break; - } - winMapPreview->winSetStatus(WIN_STATUS_IMAGE); - UnicodeString map; - // get text of the map to load - map = GadgetListBoxGetText( winMapWindow, rowSelected, 0 ); - - // set the map name in the global data map name - AsciiString asciiMap; - const char *mapFname = (const char *)GadgetListBoxGetItemData( winMapWindow, rowSelected ); - DEBUG_ASSERTCRASH(mapFname, ("No map item data")); - if (mapFname) - asciiMap = mapFname; - else - asciiMap.translate( map ); - asciiMap.toLower(); - Image *image = getMapPreviewImage(asciiMap); - winMapPreview->winSetUserData((void *)TheMapCache->findMap(asciiMap)); - if(image) - { - winMapPreview->winSetEnabledImage(0, image); - } - else - { - winMapPreview->winClearStatus(WIN_STATUS_IMAGE); - } - positionStartSpots( asciiMap, buttonMapStartPosition, winMapPreview); - } - break; - } - //--------------------------------------------------------------------------------------------- - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if( controlID == buttonBack ) - { - showGameSpyGameOptionsUnderlyingGUIElements( TRUE ); - - WOLMapSelectLayout->destroyWindows(); - WOLMapSelectLayout->deleteInstance(); - WOLMapSelectLayout = NULL; - WOLPositionStartSpots(); - } // end if - else if ( controlID == radioButtonSystemMapsID ) - { - if (TheMapCache) - TheMapCache->updateCache(); - populateMapListbox( mapList, TRUE, TRUE, TheGameSpyGame->getMap() ); - CustomMatchPreferences pref; - pref.setUsesSystemMapDir(TRUE); - pref.write(); - } - else if ( controlID == radioButtonUserMapsID ) - { - if (TheMapCache) - TheMapCache->updateCache(); - populateMapListbox( mapList, FALSE, TRUE, TheGameSpyGame->getMap() ); - CustomMatchPreferences pref; - pref.setUsesSystemMapDir(FALSE); - pref.write(); - } - else if( controlID == buttonOK ) - { - Int selected; - UnicodeString map; - - // get the selected index - GadgetListBoxGetSelected( winMapWindow, &selected ); - - if( selected != -1 ) - { - - // get text of the map to load - map = GadgetListBoxGetText( winMapWindow, selected, 0 ); - - - // set the map name in the global data map name - AsciiString asciiMap; - const char *mapFname = (const char *)GadgetListBoxGetItemData( winMapWindow, selected ); - DEBUG_ASSERTCRASH(mapFname, ("No map item data")); - if (mapFname) - asciiMap = mapFname; - else - asciiMap.translate( map ); - TheGameSpyGame->setMap(asciiMap); - asciiMap.toLower(); - std::map::iterator it = TheMapCache->find(asciiMap); - if (it != TheMapCache->end()) - { - TheGameSpyGame->getGameSpySlot(0)->setMapAvailability(TRUE); - TheGameSpyGame->setMapCRC( it->second.m_CRC ); - TheGameSpyGame->setMapSize( it->second.m_filesize ); - } - - TheGameSpyGame->adjustSlotsForMap(); // BGC- adjust the slots for the new map. - TheGameSpyGame->resetAccepted(); - TheGameSpyGame->resetStartSpots(); - TheGameSpyInfo->setGameOptions(); - - WOLDisplaySlotList(); - WOLDisplayGameOptions(); - - WOLMapSelectLayout->destroyWindows(); - WOLMapSelectLayout->deleteInstance(); - WOLMapSelectLayout = NULL; - - showGameSpyGameOptionsUnderlyingGUIElements( TRUE ); - - WOLPositionStartSpots(); - - } // end if - - } // end else if - - break; - - } // end selected - - default: - return MSG_IGNORED; - - } // end switch - - return MSG_HANDLED; - -} // end WOLMapSelectMenuSystem diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMessageWindow.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMessageWindow.cpp deleted file mode 100644 index 897b3defb8f..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMessageWindow.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLMessageWindow.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameNetwork/IPEnumeration.h" -//#include "GameNetwork/WOL.h" - - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLMessageWindowID = NAMEKEY_INVALID; -static NameKeyType buttonCancelID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLMessageWindow = NULL; -static GameWindow *buttonCancel = NULL; - - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOLMessage Window */ -//------------------------------------------------------------------------------------------------- -void WOLMessageWindowInit( WindowLayout *layout, void *userData ) -{ - parentWOLMessageWindowID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLMessageWindow.wnd:WOLMessageWindowParent" ) ); - buttonCancelID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLMessageWindow.wnd:ButtonCancel" ) ); - parentWOLMessageWindow = TheWindowManager->winGetWindowFromId( NULL, parentWOLMessageWindowID ); - buttonCancel = TheWindowManager->winGetWindowFromId( NULL, buttonCancelID); - - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLMessageWindow ); - -} // WOLMessageWindowInit - -//------------------------------------------------------------------------------------------------- -/** WOLMessage Window shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLMessageWindowShutdown( WindowLayout *layout, void *userData ) -{ - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); -} // WOLMessageWindowShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOLMessage Window update method */ -//------------------------------------------------------------------------------------------------- -void WOLMessageWindowUpdate( WindowLayout * layout, void *userData) -{ - /* - if (WOL::TheWOL) - WOL::TheWOL->update(); - */ - -}// WOLMessageWindowUpdate - -//------------------------------------------------------------------------------------------------- -/** WOLMessage Window input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLMessageWindowInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonCancel, buttonCancelID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLMessageWindowInput - -//------------------------------------------------------------------------------------------------- -/** WOLMessage Window window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLMessageWindowSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLMessageWindowSystem diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQMScoreScreen.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQMScoreScreen.cpp deleted file mode 100644 index 26b21f3e7bd..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQMScoreScreen.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLQMScoreScreen.cpp -// Author: Matt Campbell, November 2001 -// Description: QuickMatch score screen (different from normal screen in that it has 'QM' and 'Discon' buttons) -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -//#include "GameNetwork/WOL.h" -//#include "GameNetwork/WOLmenus.h" - - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLQMScoreID = NAMEKEY_INVALID; -static NameKeyType buttonDisconnectID = NAMEKEY_INVALID; -static NameKeyType buttonQuickmatchID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLQMScore = NULL; -static GameWindow *buttonDisconnect = NULL; -static GameWindow *buttonQuickmatch = NULL; - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Status Menu */ -//------------------------------------------------------------------------------------------------- -void WOLQMScoreScreenInit( WindowLayout *layout, void *userData ) -{ - parentWOLQMScoreID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLQMScoreScreen.wnd:WOLQMScoreScreenParent" ) ); - buttonDisconnectID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLQMScoreScreen.wnd:ButtonDisconnect" ) ); - buttonQuickmatchID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLQMScoreScreen.wnd:ButtonQuickMatch" ) ); - parentWOLQMScore = TheWindowManager->winGetWindowFromId( NULL, parentWOLQMScoreID ); - buttonDisconnect = TheWindowManager->winGetWindowFromId( NULL, buttonDisconnectID); - buttonQuickmatch = TheWindowManager->winGetWindowFromId( NULL, buttonQuickmatchID); - - /* - if (WOL::TheWOL->getState() == WOL::WOLAPI_FATAL_ERROR) - { - // We can get to the score screen even though we've been disconnected. Just hide - // any buttons that lead back into WOL. - - buttonQuickmatch->winHide( TRUE ); - } - */ - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLQMScore ); - - //progressLayout = TheShell->top(); - -} // WOLQMScoreScreenInit - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLQMScoreScreenShutdown( WindowLayout *layout, void *userData ) -{ - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); - - //progressLayout = NULL; - -} // WOLQMScoreScreenShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLQMScoreScreenUpdate( WindowLayout * layout, void *userData) -{ - /* - if (WOL::TheWOL) - WOL::TheWOL->update(); - */ -}// WOLQMScoreScreenUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLQMScoreScreenInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonDisconnect, buttonDisconnectID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLQMScoreScreenInput - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLQMScoreScreenSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're given the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - /* - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == buttonDisconnectID ) - { - //TheShell->pop(); - if (WOL::TheWOL->setState( WOL::WOLAPI_FATAL_ERROR )) - { - WOL::TheWOL->addCommand( WOL::WOLCOMMAND_RESET ); // don't display an error, log out, or anything - } - - } //if ( controlID == buttonDisconnect ) - else if ( controlID == buttonQuickmatchID ) - { - //TheShell->pop(); - if (WOL::TheWOL->getState() != WOL::WOLAPI_FATAL_ERROR) - { - if (WOL::TheWOL->setState( WOL::WOLAPI_TOURNAMENT )) - { - WOL::TheWOL->setScreen( WOL::WOLAPI_MENU_QUICKMATCH ); - WOL::TheWOL->addCommand( WOL::WOLCOMMAND_FIND_MATCH_CHANNEL ); - } - } - - } //if ( controlID == buttonDisconnect ) - */ - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLQMScoreScreenSystem diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp deleted file mode 100644 index 2b42682acb8..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp +++ /dev/null @@ -1,1832 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLQuickMatchMenu.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "Common/QuickmatchPreferences.h" -#include "Common/LadderPreferences.h" -#include "Common/MultiplayerSettings.h" -#include "Common/PlayerTemplate.h" -#include "GameClient/AnimateWindowManager.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GameText.h" -#include "GameClient/InGameUI.h" -#include "GameClient/Shell.h" -#include "GameClient/ShellHooks.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetComboBox.h" -#include "GameClient/GadgetPushButton.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/MapUtil.h" -#include "GameClient/GameWindowTransitions.h" - -#include "GameLogic/GameLogic.h" - -#include "GameNetwork/NAT.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameNetwork/GameSpy/BuddyDefs.h" -#include "GameNetwork/GameSpy/GSConfig.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" -#include "GameNetwork/RankPointValue.h" -#include "GameNetwork/GameSpy/LadderDefs.h" -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -#ifdef DEBUG_LOGGING -#include "Common/MiniLog.h" -//#define PERF_TEST -static LogClass s_perfLog("QMPerf.txt"); -static Bool s_inQM = FALSE; -#define PERF_LOG(x) s_perfLog.log x -#else // DEBUG_LOGGING -#define PERF_LOG(x) {} -#endif // DEBUG_LOGGING - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLQuickMatchID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; -static NameKeyType buttonStartID = NAMEKEY_INVALID; -static NameKeyType buttonStopID = NAMEKEY_INVALID; -static NameKeyType buttonWidenID = NAMEKEY_INVALID; -static NameKeyType buttonBuddiesID = NAMEKEY_INVALID; -static NameKeyType listboxQuickMatchID = NAMEKEY_INVALID; -static NameKeyType listboxMapSelectID = NAMEKEY_INVALID; -static NameKeyType buttonSelectAllMapsID = NAMEKEY_INVALID; -static NameKeyType buttonSelectNoMapsID = NAMEKEY_INVALID; -//static NameKeyType textEntryMaxDisconnectsID = NAMEKEY_INVALID; -//static NameKeyType textEntryMaxPointsID = NAMEKEY_INVALID; -//static NameKeyType textEntryMinPointsID = NAMEKEY_INVALID; -static NameKeyType textEntryWaitTimeID = NAMEKEY_INVALID; -static NameKeyType comboBoxNumPlayersID = NAMEKEY_INVALID; -static NameKeyType comboBoxMaxPingID = NAMEKEY_INVALID; -static NameKeyType comboBoxLadderID = NAMEKEY_INVALID; -static NameKeyType comboBoxMaxDisconnectsID = NAMEKEY_INVALID; -static NameKeyType staticTextNumPlayersID = NAMEKEY_INVALID; -static NameKeyType comboBoxSideID = NAMEKEY_INVALID; -static NameKeyType comboBoxColorID = NAMEKEY_INVALID; - - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLQuickMatch = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *buttonStart = NULL; -static GameWindow *buttonStop = NULL; -static GameWindow *buttonWiden = NULL; -GameWindow *quickmatchTextWindow = NULL; -static GameWindow *listboxMapSelect = NULL; -//static GameWindow *textEntryMaxDisconnects = NULL; -//static GameWindow *textEntryMaxPoints = NULL; -//static GameWindow *textEntryMinPoints = NULL; -static GameWindow *textEntryWaitTime = NULL; -static GameWindow *comboBoxNumPlayers = NULL; -static GameWindow *comboBoxMaxPing = NULL; -static GameWindow *comboBoxLadder = NULL; -static GameWindow *comboBoxDisabledLadder = NULL; // enable and disable this, but never use it. it is a stand-in for comboBoxLadder for when there are no ladders -static GameWindow *comboBoxMaxDisconnects = NULL; -static GameWindow *staticTextNumPlayers = NULL; -static GameWindow *comboBoxSide = NULL; -static GameWindow *comboBoxColor = NULL; - -static Bool isShuttingDown = false; -static Bool buttonPushed = false; -static char *nextScreen = NULL; -static Bool raiseMessageBoxes = false; -static Bool isInInit = FALSE; -static const Image *selectedImage = NULL; -static const Image *unselectedImage = NULL; - -static bool isPopulatingLadderBox = false; -static Int maxPingEntries = 0; -static Int maxPoints= 100; -static Int minPoints = 0; - -static const LadderInfo * getLadderInfo( void ); - - -// [SKB: Jul 01 2003 @ 7:7pm] : -// German2 now has fewer maps. When trying to do a QM with a Retail version -// the bool string sent to the QMBot is almost always a different size. This -// mapping is kept so that we now send a string of all maps instead of just -// the ones that are visible to the user. - -#define VARIABLE_NUMBER_OF_MAPS 1 - -#if VARIABLE_NUMBER_OF_MAPS -typedef std::vector MapListboxIndex; -static MapListboxIndex mapListboxIndex; -#endif - - -static Bool isInfoShown(void) -{ - static NameKeyType parentStatsID = NAMEKEY("WOLQuickMatchMenu.wnd:ParentStats"); - GameWindow *parentStats = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, parentStatsID ); - if (parentStats) - return !parentStats->winIsHidden(); - return FALSE; -} - -static void hideInfoGadgets(Bool doIt) -{ - static NameKeyType parentStatsID = NAMEKEY("WOLQuickMatchMenu.wnd:ParentStats"); - GameWindow *parentStats = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, parentStatsID ); - if (parentStats) - { - parentStats->winHide(doIt); - } -} - -static void hideOptionsGadgets(Bool doIt) -{ - static NameKeyType parentOptionsID = NAMEKEY("WOLQuickMatchMenu.wnd:ParentOptions"); - GameWindow *parentOptions = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, parentOptionsID ); - if (parentOptions) - { - parentOptions->winHide(doIt); - if (comboBoxSide) - comboBoxSide->winHide(doIt); - if (comboBoxColor) - comboBoxColor->winHide(doIt); - if (comboBoxNumPlayers) - comboBoxNumPlayers->winHide(doIt); - if (comboBoxLadder) - comboBoxLadder->winHide(doIt); - if (comboBoxDisabledLadder) - comboBoxDisabledLadder->winHide(doIt); - if (comboBoxMaxPing) - comboBoxMaxPing->winHide(doIt); - if (comboBoxMaxDisconnects) - comboBoxMaxDisconnects->winHide(doIt); - } -} - -static void enableOptionsGadgets(Bool doIt) -{ -#ifdef PERF_TEST - s_inQM = !doIt; -#endif // PERF_TEST - static NameKeyType parentOptionsID = NAMEKEY("WOLQuickMatchMenu.wnd:ParentOptions"); - GameWindow *parentOptions = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, parentOptionsID ); - const LadderInfo *li = getLadderInfo(); - if (parentOptions) - { - parentOptions->winEnable(doIt); - if (comboBoxSide) - comboBoxSide->winEnable(doIt && (!li || !li->randomFactions)); - if (comboBoxColor) - comboBoxColor->winEnable(doIt); - if (comboBoxNumPlayers) - comboBoxNumPlayers->winEnable(doIt); - if (comboBoxLadder) - comboBoxLadder->winEnable(doIt); - if (comboBoxDisabledLadder) - comboBoxDisabledLadder->winEnable(FALSE); - if (comboBoxMaxPing) - comboBoxMaxPing->winEnable(doIt); - if (comboBoxMaxDisconnects) - comboBoxMaxDisconnects->winEnable(doIt); - } -} - -enum -{ - MAX_DISCONNECTS_ANY = 0, - MAX_DISCONNECTS_5 = 5, - MAX_DISCONNECTS_10 = 10, - MAX_DISCONNECTS_25 = 25, - MAX_DISCONNECTS_50 = 50, -}; -enum{ MAX_DISCONNECTS_COUNT = 5 }; - -static Int MAX_DISCONNECTS[MAX_DISCONNECTS_COUNT] = {MAX_DISCONNECTS_ANY, MAX_DISCONNECTS_5, - MAX_DISCONNECTS_10, MAX_DISCONNECTS_25, - MAX_DISCONNECTS_50}; - - -void UpdateStartButton(void) -{ - if (!comboBoxLadder || !buttonStart || !listboxMapSelect) - return; - - Int index; - Int selected; - GadgetComboBoxGetSelectedPos( comboBoxLadder, &selected ); - index = (Int)GadgetComboBoxGetItemData( comboBoxLadder, selected ); - const LadderInfo *li = TheLadderList->findLadderByIndex( index ); - if (li) - { - buttonStart->winEnable(TRUE); - return; - } - - Int numMaps = GadgetListBoxGetNumEntries(listboxMapSelect); - for ( Int i=0; iwinEnable(TRUE); - return; - } - } - buttonStart->winEnable(FALSE); -} - -// ----------------------------------------------------------------------------- - -static void populateQMColorComboBox(QuickMatchPreferences& pref) -{ - Int numColors = TheMultiplayerSettings->getNumColors(); - UnicodeString colorName; - - GadgetComboBoxReset(comboBoxColor); - - MultiplayerColorDefinition *def = TheMultiplayerSettings->getColor(PLAYERTEMPLATE_RANDOM); - Int newIndex = GadgetComboBoxAddEntry(comboBoxColor, TheGameText->fetch("GUI:???"), def->getColor()); - GadgetComboBoxSetItemData(comboBoxColor, newIndex, (void *)-1); - - for (Int c=0; cgetColor(c); - if (!def) - continue; - - colorName = TheGameText->fetch(def->getTooltipName().str()); - newIndex = GadgetComboBoxAddEntry(comboBoxColor, colorName, def->getColor()); - GadgetComboBoxSetItemData(comboBoxColor, newIndex, (void *)c); - } - GadgetComboBoxSetSelectedPos(comboBoxColor, pref.getColor()); -} - -// ----------------------------------------------------------------------------- - -static void populateQMSideComboBox(Int favSide, const LadderInfo *li = NULL) -{ - Int numPlayerTemplates = ThePlayerTemplateStore->getPlayerTemplateCount(); - UnicodeString playerTemplateName; - - GadgetComboBoxReset(comboBoxSide); - - MultiplayerColorDefinition *def = TheMultiplayerSettings->getColor(PLAYERTEMPLATE_RANDOM); - Int newIndex = GadgetComboBoxAddEntry(comboBoxSide, TheGameText->fetch("GUI:Random"), def->getColor()); - GadgetComboBoxSetItemData(comboBoxSide, newIndex, (void *)PLAYERTEMPLATE_RANDOM); - - std::set seenSides; - - Int entryToSelect = 0; // select Random by default - - for (Int c=0; cgetNthPlayerTemplate(c); - if (!fac) - continue; - - if (fac->getStartingBuilding().isEmpty()) - continue; - - AsciiString side; - side.format("SIDE:%s", fac->getSide().str()); - if (seenSides.find(side) != seenSides.end()) - continue; - - if (li) - { - if (std::find(li->validFactions.begin(), li->validFactions.end(), fac->getSide()) == li->validFactions.end()) - continue; // ladder doesn't allow it. - } - - seenSides.insert(side); - - newIndex = GadgetComboBoxAddEntry(comboBoxSide, TheGameText->fetch(side), def->getColor()); - GadgetComboBoxSetItemData(comboBoxSide, newIndex, (void *)c); - - if (c == favSide) - entryToSelect = newIndex; - } - seenSides.clear(); - - GadgetComboBoxSetSelectedPos(comboBoxSide, entryToSelect); - if (li && li->randomFactions) - comboBoxSide->winEnable(FALSE); - else - comboBoxSide->winEnable(TRUE); -} - -void HandleQMLadderSelection(Int ladderID) -{ - if (!parentWOLQuickMatch) - return; - - QuickMatchPreferences pref; - - if (ladderID < 1) - { - pref.setLastLadder(AsciiString::TheEmptyString, 0); - pref.write(); - return; - } - - const LadderInfo *info = TheLadderList->findLadderByIndex(ladderID); - if (!info) - { - pref.setLastLadder(AsciiString::TheEmptyString, 0); - } - else - { - pref.setLastLadder(info->address, info->port); - } - - pref.write(); -} - -static inline Bool isValidLadder( const LadderInfo *lad ) -{ - if (lad && lad->index > 0 && lad->validQM) - { - PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID()); - Int numWins = 0; - PerGeneralMap::iterator it; - for (it = stats.wins.begin(); it != stats.wins.end(); ++it) - { - numWins += it->second; - } - if (!lad->maxWins || lad->maxWins >=numWins) - { - if (!lad->minWins || lad->minWins<=numWins) - { - return TRUE; - } - } - } - return FALSE; -} - -void PopulateQMLadderListBox( GameWindow *win ) -{ - if (!parentWOLQuickMatch || !comboBoxLadder) - return; - - isPopulatingLadderBox = true; - - QuickMatchPreferences pref; - AsciiString userPrefFilename; - Int localProfile = TheGameSpyInfo->getLocalProfileID(); - - Color specialColor = GameSpyColor[GSCOLOR_MAP_SELECTED]; - Color normalColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED]; - Color favoriteColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED]; - Int index; - GadgetListBoxReset( win ); - - std::set usedLadders; - - // start with "No Ladder" - index = GadgetListBoxAddEntryText( win, TheGameText->fetch("GUI:NoLadder"), normalColor, -1 ); - GadgetListBoxSetItemData( win, 0, index ); - - // add the last ladder - Int selectedPos = 0; - AsciiString lastLadderAddr = pref.getLastLadderAddr(); - UnsignedShort lastLadderPort = pref.getLastLadderPort(); - const LadderInfo *info = TheLadderList->findLadder( lastLadderAddr, lastLadderPort ); - if (isValidLadder(info)) - { - usedLadders.insert(info); - index = GadgetListBoxAddEntryText( win, info->name, favoriteColor, -1 ); - GadgetListBoxSetItemData( win, (void *)(info->index), index ); - selectedPos = index; - } - - // our recent ladders - LadderPreferences ladPref; - ladPref.loadProfile( localProfile ); - const LadderPrefMap recentLadders = ladPref.getRecentLadders(); - for (LadderPrefMap::const_iterator cit = recentLadders.begin(); cit != recentLadders.end(); ++cit) - { - AsciiString addr = cit->second.address; - UnsignedShort port = cit->second.port; - if (addr == lastLadderAddr && port == lastLadderPort) - continue; - const LadderInfo *info = TheLadderList->findLadder( addr, port ); - if (isValidLadder(info) && usedLadders.find(info) == usedLadders.end()) - { - usedLadders.insert(info); - index = GadgetListBoxAddEntryText( win, info->name, favoriteColor, -1 ); - GadgetListBoxSetItemData( win, (void *)(info->index), index ); - } - } - - // special ladders - const LadderInfoList *lil = TheLadderList->getSpecialLadders(); - LadderInfoList::const_iterator lit; - for (lit = lil->begin(); lit != lil->end(); ++lit) - { - const LadderInfo *info = *lit; - if (isValidLadder(info) && usedLadders.find(info) == usedLadders.end()) - { - usedLadders.insert(info); - index = GadgetListBoxAddEntryText( win, info->name, specialColor, -1 ); - GadgetListBoxSetItemData( win, (void *)(info->index), index ); - } - } - - // standard ladders - lil = TheLadderList->getStandardLadders(); - for (lit = lil->begin(); lit != lil->end(); ++lit) - { - const LadderInfo *info = *lit; - if (isValidLadder(info) && usedLadders.find(info) == usedLadders.end()) - { - usedLadders.insert(info); - index = GadgetListBoxAddEntryText( win, info->name, normalColor, -1 ); - GadgetListBoxSetItemData( win, (void *)(info->index), index ); - } - } - - GadgetListBoxSetSelected( win, selectedPos ); - isPopulatingLadderBox = false; -} - -static const LadderInfo * getLadderInfo( void ) -{ - Int index; - Int selected; - GadgetComboBoxGetSelectedPos( comboBoxLadder, &selected ); - index = (Int)GadgetComboBoxGetItemData( comboBoxLadder, selected ); - const LadderInfo *li = TheLadderList->findLadderByIndex( index ); - return li; -} - -void PopulateQMLadderComboBox( void ) -{ - if (!parentWOLQuickMatch || !comboBoxLadder) - return; - - isPopulatingLadderBox = true; - - QuickMatchPreferences pref; - Int localProfile = TheGameSpyInfo->getLocalProfileID(); - - Color specialColor = GameSpyColor[GSCOLOR_MAP_SELECTED]; - Color normalColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED]; - Int index; - GadgetComboBoxReset( comboBoxLadder ); - index = GadgetComboBoxAddEntry( comboBoxLadder, TheGameText->fetch("GUI:NoLadder"), normalColor ); - GadgetComboBoxSetItemData( comboBoxLadder, index, 0 ); - - std::set usedLadders; - - Int selectedPos = 0; - AsciiString lastLadderAddr = pref.getLastLadderAddr(); - UnsignedShort lastLadderPort = pref.getLastLadderPort(); - const LadderInfo *info = TheLadderList->findLadder( lastLadderAddr, lastLadderPort ); - if (isValidLadder(info)) - { - usedLadders.insert(info); - index = GadgetComboBoxAddEntry( comboBoxLadder, info->name, specialColor ); - GadgetComboBoxSetItemData( comboBoxLadder, index, (void *)(info->index) ); - selectedPos = index; - - // we selected a ladder? No game size choice for us... - GadgetComboBoxSetSelectedPos(comboBoxNumPlayers, info->playersPerTeam-1); - comboBoxNumPlayers->winEnable( FALSE ); - } - else - { - comboBoxNumPlayers->winEnable( TRUE ); - } - - LadderPreferences ladPref; - ladPref.loadProfile( localProfile ); - const LadderPrefMap recentLadders = ladPref.getRecentLadders(); - for (LadderPrefMap::const_iterator cit = recentLadders.begin(); cit != recentLadders.end(); ++cit) - { - AsciiString addr = cit->second.address; - UnsignedShort port = cit->second.port; - if (addr == lastLadderAddr && port == lastLadderPort) - continue; - const LadderInfo *info = TheLadderList->findLadder( addr, port ); - if (isValidLadder(info) && usedLadders.find(info) == usedLadders.end()) - { - usedLadders.insert(info); - index = GadgetComboBoxAddEntry( comboBoxLadder, info->name, normalColor ); - GadgetComboBoxSetItemData( comboBoxLadder, index, (void *)(info->index) ); - } - } - - index = GadgetComboBoxAddEntry( comboBoxLadder, TheGameText->fetch("GUI:ChooseLadder"), normalColor ); - GadgetComboBoxSetItemData( comboBoxLadder, index, (void *)-1 ); - - GadgetComboBoxSetSelectedPos( comboBoxLadder, selectedPos ); - isPopulatingLadderBox = false; - - populateQMSideComboBox(pref.getSide(), getLadderInfo()); // this will set side to random and disable if necessary -} - -static void populateQuickMatchMapSelectListbox( QuickMatchPreferences& pref ) -{ - std::list maps = TheGameSpyConfig->getQMMaps(); - - // enable/disable box based on ladder status - Int index; - Int selected; - GadgetComboBoxGetSelectedPos( comboBoxLadder, &selected ); - index = (Int)GadgetComboBoxGetItemData( comboBoxLadder, selected ); - const LadderInfo *li = TheLadderList->findLadderByIndex( index ); - //listboxMapSelect->winEnable( li == NULL || li->randomMaps == FALSE ); - - Int numPlayers = 0; - if (li) - { - numPlayers = li->playersPerTeam*2; - - maps = li->validMaps; - } - else - { - GadgetComboBoxGetSelectedPos(comboBoxNumPlayers, &selected); - if (selected < 0) - selected = 0; - numPlayers = (selected+1)*2; - } - - #if VARIABLE_NUMBER_OF_MAPS - mapListboxIndex.clear(); - #endif - - GadgetListBoxReset(listboxMapSelect); - for (std::list::const_iterator it = maps.begin(); it != maps.end(); ++it) - { - AsciiString theMap = *it; - const MapMetaData *md = TheMapCache->findMap(theMap); - if (md && md->m_numPlayers >= numPlayers) - { - UnicodeString displayName; - displayName = md->m_displayName; - Bool isSelected = pref.isMapSelected(theMap); - if (li && li->randomMaps) - isSelected = TRUE; - Int width = 10; - Int height = 10; - const Image *img = (isSelected)?selectedImage:unselectedImage; - if ( img ) - { - width = min(GadgetListBoxGetColumnWidth(listboxMapSelect, 0), img->getImageWidth()); - height = width; - } - Int index = GadgetListBoxAddEntryImage(listboxMapSelect, img, -1, 0, height, width); - GadgetListBoxAddEntryText(listboxMapSelect, displayName, GameSpyColor[(isSelected)?GSCOLOR_MAP_SELECTED:GSCOLOR_MAP_UNSELECTED], index, 1); - GadgetListBoxSetItemData(listboxMapSelect, (void *)isSelected, index); - GadgetListBoxSetItemData(listboxMapSelect, (void *)md, index, 1); - - #if VARIABLE_NUMBER_OF_MAPS - mapListboxIndex.push_back(index); - #endif - } - else - { - #if VARIABLE_NUMBER_OF_MAPS - // [SKB: Jul 01 2003 @ 7:9pm] : - // Keep track of maps that are not visible right now so - // they are added to the information sent to the QMBot. - mapListboxIndex.push_back(-1); - #endif - } - } -} - -static void saveQuickMatchOptions( void ) -{ - if(isInInit) - return; - QuickMatchPreferences pref; - - std::list maps = TheGameSpyConfig->getQMMaps(); - - Int index; - Int selected; - GadgetComboBoxGetSelectedPos( comboBoxLadder, &selected ); - index = (Int)GadgetComboBoxGetItemData( comboBoxLadder, selected ); - const LadderInfo *li = TheLadderList->findLadderByIndex( index ); - Int numPlayers = 0; - - if (li) - { - pref.setLastLadder( li->address, li->port ); - numPlayers = li->playersPerTeam*2; - - pref.write(); - //return; // don't save our defaults based on the tournament's defaults - } - else - { - pref.setLastLadder( AsciiString::TheEmptyString, 0 ); - GadgetComboBoxGetSelectedPos(comboBoxNumPlayers, &selected); - if (selected < 0) - selected = 0; - numPlayers = (selected+1)*2; - } - - if (!li || !li->randomMaps) // don't save the map as selected if we couldn't choose - { - Int row = 0; - Int entries = GadgetListBoxGetNumEntries(listboxMapSelect); - while ( row < entries) - { - const MapMetaData *md = (const MapMetaData *)GadgetListBoxGetItemData(listboxMapSelect, row, 1); - if(md) - pref.setMapSelected(md->m_fileName, (Bool)GadgetListBoxGetItemData(listboxMapSelect, row)); - row++; - } - } - - UnicodeString u; - AsciiString a; -// u = GadgetTextEntryGetText(textEntryMaxDisconnects); -// a.translate(u); -// pref.setMaxDisconnects(atoi(a.str())); -// u = GadgetTextEntryGetText(textEntryMaxPoints); -// a.translate(u); -// pref.setMaxPoints(max(100, atoi(a.str()))); -// u = GadgetTextEntryGetText(textEntryMinPoints); -// a.translate(u); -// pref.setMinPoints(min(100, atoi(a.str()))); - //u = GadgetTextEntryGetText(textEntryWaitTime); - //a.translate(u); - //pref.setWaitTime(atoi(a.str())); - - GadgetComboBoxGetSelectedPos(comboBoxNumPlayers, &selected); - pref.setNumPlayers(selected); - GadgetComboBoxGetSelectedPos(comboBoxMaxPing, &selected); - pref.setMaxPing(selected); - - Int item; - GadgetComboBoxGetSelectedPos(comboBoxSide, &selected); - item = (Int)GadgetComboBoxGetItemData(comboBoxSide, selected); - pref.setSide(max(0, item)); - GadgetComboBoxGetSelectedPos(comboBoxColor, &selected); - pref.setColor(max(0, selected)); - - GadgetComboBoxGetSelectedPos(comboBoxMaxDisconnects, &selected); - pref.setMaxDisconnects(selected); - - - pref.write(); -} - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Quick Match Menu */ -//------------------------------------------------------------------------------------------------- -void WOLQuickMatchMenuInit( WindowLayout *layout, void *userData ) -{ - isInInit = TRUE; - if (TheGameSpyGame && TheGameSpyGame->isGameInProgress()) - { - TheGameSpyGame->setGameInProgress(FALSE); - - // check if we were disconnected - Int disconReason; - if (TheGameSpyInfo->isDisconnectedAfterGameStart(&disconReason)) - { - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", disconReason); - UnicodeString title, body; - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheGameSpyInfo->reset(); - DEBUG_LOG(("WOLQuickMatchMenuInit() - game was in progress, and we were disconnected, so pop immediate back to main menu\n")); - TheShell->popImmediate(); - return; - } - } - - nextScreen = NULL; - buttonPushed = false; - isShuttingDown = false; - raiseMessageBoxes = true; - - if (TheNAT != NULL) { - delete TheNAT; - TheNAT = NULL; - } - - parentWOLQuickMatchID = NAMEKEY( "WOLQuickMatchMenu.wnd:WOLQuickMatchMenuParent" ); - buttonBackID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonBack" ); - buttonBuddiesID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonBuddies" ); - buttonStartID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonStart" ); - buttonStopID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonStop" ); - buttonWidenID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonWiden" ); - listboxQuickMatchID = NAMEKEY( "WOLQuickMatchMenu.wnd:ListboxQuickMatch" ); - listboxMapSelectID = NAMEKEY( "WOLQuickMatchMenu.wnd:ListBoxMapSelect" ); - buttonSelectAllMapsID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonSelectAllMaps" ); - buttonSelectNoMapsID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonSelectNoMaps" ); - //textEntryMaxDisconnectsID = NAMEKEY( "WOLQuickMatchMenu.wnd:TextEntryMaxDisconnects" ); - //textEntryMaxPointsID = NAMEKEY( "WOLQuickMatchMenu.wnd:TextEntryMaxPointPercent" ); - //textEntryMinPointsID = NAMEKEY( "WOLQuickMatchMenu.wnd:TextEntryMinPointPercent" ); - textEntryWaitTimeID = NAMEKEY( "WOLQuickMatchMenu.wnd:TextEntryWaitTime" ); - comboBoxMaxPingID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxMaxPing" ); - comboBoxNumPlayersID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxNumPlayers" ); - comboBoxLadderID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxLadder" ); - comboBoxMaxDisconnectsID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxMaxDisconnects" ); - staticTextNumPlayersID = NAMEKEY( "WOLQuickMatchMenu.wnd:StaticTextNumPlayers" ); - comboBoxSideID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxSide" ); - comboBoxColorID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxColor" ); - - parentWOLQuickMatch = TheWindowManager->winGetWindowFromId( NULL, parentWOLQuickMatchID ); - buttonBack = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, buttonBackID); - buttonStart = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, buttonStartID); - buttonStop = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, buttonStopID); - buttonWiden = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, buttonWidenID); - quickmatchTextWindow = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, listboxQuickMatchID); - listboxMapSelect = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, listboxMapSelectID); - //textEntryMaxDisconnects = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, textEntryMaxDisconnectsID ); - //textEntryMaxPoints = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, textEntryMaxPointsID ); - //textEntryMinPoints = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, textEntryMinPointsID ); - textEntryWaitTime = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, textEntryWaitTimeID ); - comboBoxMaxPing = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxMaxPingID ); - comboBoxNumPlayers = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxNumPlayersID ); - comboBoxLadder = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxLadderID ); - comboBoxMaxDisconnects = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxMaxDisconnectsID ); - TheGameSpyInfo->registerTextWindow(quickmatchTextWindow); - staticTextNumPlayers = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, staticTextNumPlayersID ); - comboBoxSide = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxSideID ); - comboBoxColor = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxColorID ); - - if (TheLadderList->getStandardLadders()->size() == 0 - && TheLadderList->getSpecialLadders()->size() == 0 - && TheLadderList->getLocalLadders()->size() == 0) - { - // no ladders, so just disable them - comboBoxDisabledLadder = comboBoxLadder; - comboBoxLadder = NULL; - - isPopulatingLadderBox = TRUE; - - Color normalColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED]; - Int index; - GadgetComboBoxReset( comboBoxDisabledLadder ); - index = GadgetComboBoxAddEntry( comboBoxDisabledLadder, TheGameText->fetch("GUI:NoLadder"), normalColor ); - GadgetComboBoxSetItemData( comboBoxDisabledLadder, index, 0 ); - GadgetComboBoxSetSelectedPos( comboBoxDisabledLadder, index ); - - isPopulatingLadderBox = FALSE; - - /** This code would actually *hide* the combo box, but it doesn't look as good. Left here since someone will want to - ** see it at some point. :P - if (comboBoxLadder) - { - comboBoxLadder->winHide(TRUE); - comboBoxLadder->winEnable(FALSE); - } - comboBoxLadder = NULL; - GameWindow *staticTextLadder = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, - NAMEKEY("WOLQuickMatchMenu.wnd:StaticTextLadder") ); - if (staticTextLadder) - staticTextLadder->winHide(TRUE); - */ - } - - GameWindow *buttonBuddies = TheWindowManager->winGetWindowFromId(NULL, buttonBuddiesID); - if (buttonBuddies) - buttonBuddies->winEnable(TRUE); - - GameWindow *staticTextTitle = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, - NAMEKEY("WOLQuickMatchMenu.wnd:StaticTextTitle") ); - if (staticTextTitle) - { - UnicodeString tmp; - tmp.format(TheGameText->fetch("GUI:QuickMatchTitle"), TheGameSpyInfo->getLocalName().str()); - GadgetStaticTextSetText(staticTextTitle, tmp); - } - - // QM is not going yet, so disable the Widen Search button - buttonWiden->winEnable( FALSE ); - buttonStop->winHide( TRUE ); - buttonStart->winHide( FALSE ); - GadgetListBoxReset(quickmatchTextWindow); - enableOptionsGadgets(TRUE); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLQuickMatch ); - - // fill in preferences - selectedImage = TheMappedImageCollection->findImageByName("CustomMatch_selected"); - unselectedImage = TheMappedImageCollection->findImageByName("CustomMatch_deselected"); - QuickMatchPreferences pref; - - - UnicodeString s; -// s.format(L"%d", pref.getMaxDisconnects()); -// GadgetTextEntrySetText(textEntryMaxDisconnects, s); -// s.format(L"%d", pref.getMaxPoints()); -// GadgetTextEntrySetText(textEntryMaxPoints, s); -// s.format(L"%d", pref.getMinPoints()); -// GadgetTextEntrySetText(textEntryMinPoints, s); - //s.format(L"%d", pref.getWaitTime()); - //GadgetTextEntrySetText(textEntryWaitTime, s); - maxPoints= pref.getMaxPoints(); - minPoints = pref.getMinPoints(); - - Color c = GameSpyColor[GSCOLOR_DEFAULT]; - GadgetComboBoxReset( comboBoxNumPlayers ); - Int i; - for (i=1; i<5; ++i) - { - s.format(TheGameText->fetch("GUI:PlayersVersusPlayers"), i, i); - GadgetComboBoxAddEntry( comboBoxNumPlayers, s, c ); - } - GadgetComboBoxSetSelectedPos( comboBoxNumPlayers, max(0, pref.getNumPlayers()) ); - - GadgetComboBoxReset(comboBoxMaxDisconnects); - GadgetComboBoxAddEntry( comboBoxMaxDisconnects, TheGameText->fetch("GUI:Any"), c); - for( i = 1; i < MAX_DISCONNECTS_COUNT; ++i ) - { - s.format(L"%d", MAX_DISCONNECTS[i]); - GadgetComboBoxAddEntry( comboBoxMaxDisconnects, s, c ); - } - Int maxDisconIndex = max(0, pref.getMaxDisconnects()); - GadgetComboBoxSetSelectedPos(comboBoxMaxDisconnects, maxDisconIndex); - - GadgetComboBoxReset( comboBoxMaxPing ); - maxPingEntries = (TheGameSpyConfig->getPingTimeoutInMs() - 1) / 100; - maxPingEntries++; // need to add the entry for the actual timeout - for (i=1; i fetch("GUI:TimeInMilliseconds"), i*100); - GadgetComboBoxAddEntry( comboBoxMaxPing, s, c ); - } - GadgetComboBoxAddEntry( comboBoxMaxPing, TheGameText->fetch("GUI:ANY"), c ); - i = pref.getMaxPing(); - if( i < 0 ) - i = 0; - if( i >= maxPingEntries ) - i = maxPingEntries - 1; - GadgetComboBoxSetSelectedPos( comboBoxMaxPing, i ); - - populateQMColorComboBox(pref); - populateQMSideComboBox(pref.getSide(), getLadderInfo()); - - PopulateQMLadderComboBox(); - TheShell->showShellMap(TRUE); - TheGameSpyGame->reset(); - - GadgetListBoxReset(listboxMapSelect); - populateQuickMatchMapSelectListbox(pref); - - UpdateLocalPlayerStats(); - UpdateStartButton(); - TheTransitionHandler->setGroup("WOLQuickMatchMenuFade"); - isInInit= FALSE; -} // WOLQuickMatchMenuInit - -//------------------------------------------------------------------------------------------------- -/** This is called when a shutdown is complete for this menu */ -//------------------------------------------------------------------------------------------------- -static void shutdownComplete( WindowLayout *layout ) -{ - - isShuttingDown = false; - - // hide the layout - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout, (nextScreen != NULL) ); - - if (nextScreen != NULL) - { - TheShell->push(nextScreen); - } - - nextScreen = NULL; - -} // end if - -//------------------------------------------------------------------------------------------------- -/** WOL Quick Match Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLQuickMatchMenuShutdown( WindowLayout *layout, void *userData ) -{ - TheGameSpyInfo->unregisterTextWindow(quickmatchTextWindow); - - if (!TheGameEngine->getQuitting()) - saveQuickMatchOptions(); - - parentWOLQuickMatch = NULL; - buttonBack = NULL; - quickmatchTextWindow = NULL; - selectedImage = unselectedImage = NULL; - - isShuttingDown = true; - - // if we are shutting down for an immediate pop, skip the animations - Bool popImmediate = *(Bool *)userData; - if( popImmediate ) - { - - shutdownComplete( layout ); - return; - - } //end if - - TheShell->reverseAnimatewindow(); - TheTransitionHandler->reverse("WOLQuickMatchMenuFade"); - - RaiseGSMessageBox(); -} // WOLQuickMatchMenuShutdown - - -#ifdef PERF_TEST -static const char* getMessageString(Int t) -{ - switch(t) - { - case PeerResponse::PEERRESPONSE_LOGIN: - return "login"; - case PeerResponse::PEERRESPONSE_DISCONNECT: - return "disconnect"; - case PeerResponse::PEERRESPONSE_MESSAGE: - return "message"; - case PeerResponse::PEERRESPONSE_GROUPROOM: - return "group room"; - case PeerResponse::PEERRESPONSE_STAGINGROOM: - return "staging room"; - case PeerResponse::PEERRESPONSE_STAGINGROOMPLAYERINFO: - return "staging room player info"; - case PeerResponse::PEERRESPONSE_JOINGROUPROOM: - return "group room join"; - case PeerResponse::PEERRESPONSE_CREATESTAGINGROOM: - return "staging room create"; - case PeerResponse::PEERRESPONSE_JOINSTAGINGROOM: - return "staging room join"; - case PeerResponse::PEERRESPONSE_PLAYERJOIN: - return "player join"; - case PeerResponse::PEERRESPONSE_PLAYERLEFT: - return "player part"; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDNICK: - return "player nick"; - case PeerResponse::PEERRESPONSE_PLAYERINFO: - return "player info"; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDFLAGS: - return "player flags"; - case PeerResponse::PEERRESPONSE_ROOMUTM: - return "room UTM"; - case PeerResponse::PEERRESPONSE_PLAYERUTM: - return "player UTM"; - case PeerResponse::PEERRESPONSE_QUICKMATCHSTATUS: - return "QM status"; - case PeerResponse::PEERRESPONSE_GAMESTART: - return "game start"; - case PeerResponse::PEERRESPONSE_FAILEDTOHOST: - return "host failure"; - } - return "unknown"; -} -#endif // PERF_TEST - -//------------------------------------------------------------------------------------------------- -/** WOL Quick Match Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLQuickMatchMenuUpdate( WindowLayout * layout, void *userData) -{ - if (TheGameLogic->isInShellGame() && TheGameLogic->getFrame() == 1) - { - SignalUIInteraction(SHELL_SCRIPT_HOOK_GENERALS_ONLINE_ENTERED_FROM_GAME); - } - - // We'll only be successful if we've requested to - if(isShuttingDown && TheShell->isAnimFinished()&& TheTransitionHandler->isFinished()) - shutdownComplete(layout); - - if (raiseMessageBoxes) - { - RaiseGSMessageBox(); - raiseMessageBoxes = false; - } - - /// @todo: MDC handle disconnects in-game the same way as Custom Match! - - if (TheShell->isAnimFinished() && !buttonPushed && TheGameSpyPeerMessageQueue) - { - HandleBuddyResponses(); - HandlePersistentStorageResponses(); - - if (TheGameSpyGame && TheGameSpyGame->isGameInProgress()) - { - if (TheGameSpyInfo->isDisconnectedAfterGameStart(NULL)) - { - return; // already been disconnected, so don't worry. - } - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - PeerResponse resp; - while (allowedMessages-- && !sawImportantMessage && TheGameSpyPeerMessageQueue->getResponse( resp )) - { - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - - // check for scorescreen - NameKeyType listboxChatWindowScoreScreenID = NAMEKEY("ScoreScreen.wnd:ListboxChatWindowScoreScreen"); - GameWindow *listboxChatWindowScoreScreen = TheWindowManager->winGetWindowFromId( NULL, listboxChatWindowScoreScreenID ); - if (listboxChatWindowScoreScreen) - { - GadgetListBoxAddEntryText(listboxChatWindowScoreScreen, TheGameText->fetch(disconMunkee), - GameSpyColor[GSCOLOR_DEFAULT], -1); - } - else - { - // still ingame - TheInGameUI->message(disconMunkee); - } - TheGameSpyInfo->markAsDisconnectedAfterGameStart(resp.discon.reason); - } - } - } - - return; // if we're in game, all we care about is if we've been disconnected from the chat server - } - - if (TheNAT != NULL) { - NATStateType NATState = TheNAT->update(); - if (NATState == NATSTATE_DONE) - { - TheGameSpyGame->launchGame(); - if (TheGameSpyInfo) // this can be blown away by a disconnect on the map transfer screen - TheGameSpyInfo->leaveStagingRoom(); - return; // don't do any more processing this frame, in case the screen goes away - } - else if (NATState == NATSTATE_FAILED) - { - // delete TheNAT, its no good for us anymore. - delete TheNAT; - TheNAT = NULL; - - // Just back out. This cleans up some slot list problems - buttonPushed = true; - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:NATNegotiationFailed")); - nextScreen = "Menus/WOLWelcomeMenu.wnd"; - TheShell->pop(); - return; // don't do any more processing this frame, in case the screen goes away - } - } - -#ifdef PERF_TEST - UnsignedInt start = timeGetTime(); - UnsignedInt end = timeGetTime(); - std::list responses; - Int numMessages = 0; -#endif // PERF_TEST - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - PeerResponse resp; - while (allowedMessages-- && !sawImportantMessage && TheGameSpyPeerMessageQueue->getResponse( resp )) - { -#ifdef PERF_TEST - ++numMessages; - responses.push_back(resp.peerResponseType); -#endif // PERF_TEST - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_PLAYERUTM: - { - if (!stricmp(resp.command.c_str(), "STATS")) - { - DEBUG_LOG(("Saw STATS from %s, data was '%s'\n", resp.nick.c_str(), resp.commandOptions.c_str())); - AsciiString data = resp.commandOptions.c_str(); - AsciiString idStr; - data.nextToken(&idStr, " "); - Int id = atoi(idStr.str()); - DEBUG_LOG(("data: %d(%s) - '%s'\n", id, idStr.str(), data.str())); - - PSPlayerStats stats = TheGameSpyPSMessageQueue->parsePlayerKVPairs(data.str()); - PSPlayerStats oldStats = TheGameSpyPSMessageQueue->findPlayerStatsByID(id); - stats.id = id; - DEBUG_LOG(("Parsed ID is %d, old ID is %d\n", stats.id, oldStats.id)); - if (stats.id && (oldStats.id == 0)) - TheGameSpyPSMessageQueue->trackPlayerStats(stats); - - // now fill in the profileID in the game slot - AsciiString nick = resp.nick.c_str(); - for (Int i=0; igetGameSpySlot(i); - if (slot && slot->isHuman() && (slot->getLoginName().compareNoCase(nick) == 0)) - { - slot->setProfileID(id); - break; - } - } - } - Int slotNum = TheGameSpyGame->getSlotNum(resp.nick.c_str()); - if ((slotNum >= 0) && (slotNum < MAX_SLOTS) && (!stricmp(resp.command.c_str(), "NAT"))) { - // this is a command for NAT negotiations, pass if off to TheNAT - sawImportantMessage = TRUE; - if (TheNAT != NULL) { - TheNAT->processGlobalMessage(slotNum, resp.commandOptions.c_str()); - } - } - /* - else if (key == "NAT") - { - if ((val >= FirewallHelperClass::FIREWALL_TYPE_SIMPLE) && - (val <= FirewallHelperClass::FIREWALL_TYPE_DESTINATION_PORT_DELTA)) - { - slot->setNATBehavior((FirewallHelperClass::FirewallBehaviorType)val); - DEBUG_LOG(("Setting NAT behavior to %d for player %d\n", val, slotNum)); - change = true; - } - else - { - DEBUG_LOG(("Rejecting invalid NAT behavior %d from player %d\n", val, slotNum)); - } - } - */ - } - break; - - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheGameSpyInfo->reset(); - TheShell->pop(); - } - case PeerResponse::PEERRESPONSE_QUICKMATCHSTATUS: - { - sawImportantMessage = TRUE; - switch( resp.qmStatus.status ) - { - case QM_IDLE: - //TheGameSpyInfo->addText(UnicodeString(L"Status: QM_IDLE"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_JOININGQMCHANNEL: - TheGameSpyInfo->addText(TheGameText->fetch("QM:JOININGQMCHANNEL"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_LOOKINGFORBOT: - TheGameSpyInfo->addText(TheGameText->fetch("QM:LOOKINGFORBOT"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_SENTINFO: - TheGameSpyInfo->addText(TheGameText->fetch("QM:SENTINFO"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_WORKING: - { - UnicodeString s; - s.format(TheGameText->fetch("QM:WORKING"), resp.qmStatus.poolSize); - TheGameSpyInfo->addText(s, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - buttonWiden->winEnable( TRUE ); - break; - case QM_POOLSIZE: - { - UnicodeString s; - s.format(TheGameText->fetch("QM:POOLSIZE"), resp.qmStatus.poolSize); - TheGameSpyInfo->addText(s, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - break; - case QM_WIDENINGSEARCH: - TheGameSpyInfo->addText(TheGameText->fetch("QM:WIDENINGSEARCH"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - break; - case QM_MATCHED: - { - TheGameSpyInfo->addText(TheGameText->fetch("QM:MATCHED"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - - TheGameSpyGame->enterGame(); - TheGameSpyGame->setSeed(resp.qmStatus.seed); - - TheGameSpyGame->markGameAsQM(); - - const LadderInfo *info = getLadderInfo(); - if (!info) - { - TheGameSpyGame->setLadderIP("localhost"); - TheGameSpyGame->setLadderPort(0); - } - else - { - TheGameSpyGame->setLadderIP(info->address); - TheGameSpyGame->setLadderPort(info->port); - } - - Int i; - Int numPlayers = 0; - for (i=0; i maps = TheGameSpyConfig->getQMMaps(); - - #if VARIABLE_NUMBER_OF_MAPS - std::list::const_iterator it = maps.begin(); - std::advance(it, resp.qmStatus.mapIdx); - - AsciiString theMap = *it; - theMap.toLower(); - TheGameSpyGame->setMap(theMap); - - #else - for (std::list::const_iterator it = maps.begin(); it != maps.end(); ++it) - { - AsciiString theMap = *it; - theMap.toLower(); - const MapMetaData *md = TheMapCache->findMap(theMap); - - if (md && md->m_numPlayers >= numPlayers) - { - TheGameSpyGame->setMap(*it); - if (resp.qmStatus.mapIdx-- == 0) - break; - } - } - #endif - - Int numPlayersPerTeam = numPlayers/2; - DEBUG_ASSERTCRASH(numPlayersPerTeam, ("0 players per team???")); - if (!numPlayersPerTeam) - numPlayersPerTeam = 1; - - for (i=0; igetGameSpySlot(i); - if (resp.stagingRoomPlayerNames[i].empty()) - { - slot->setState(SLOT_CLOSED); - } - else - { - AsciiString aName = resp.stagingRoomPlayerNames[i].c_str(); - UnicodeString uName; - uName.translate(aName); - slot->setState(SLOT_PLAYER, uName, resp.qmStatus.IP[i]); - slot->setColor(resp.qmStatus.color[i]); - slot->setPlayerTemplate(resp.qmStatus.side[i]); - //slot->setProfileID(0); - slot->setNATBehavior((FirewallHelperClass::FirewallBehaviorType)resp.qmStatus.nat[i]); - slot->setLocale(""); - slot->setTeamNumber( i/numPlayersPerTeam ); - if (i==0) - TheGameSpyGame->setGameName(uName); - } - } - - DEBUG_LOG(("Starting a QM game: options=[%s]\n", GameInfoToAsciiString(TheGameSpyGame).str())); - SendStatsToOtherPlayers(TheGameSpyGame); - TheGameSpyGame->startGame(0); - GameWindow *buttonBuddies = TheWindowManager->winGetWindowFromId(NULL, buttonBuddiesID); - if (buttonBuddies) - buttonBuddies->winEnable(FALSE); - GameSpyCloseOverlay(GSOVERLAY_BUDDY); - } - break; - case QM_INCHANNEL: - TheGameSpyInfo->addText(TheGameText->fetch("QM:INCHANNEL"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_NEGOTIATINGFIREWALLS: - TheGameSpyInfo->addText(TheGameText->fetch("QM:NEGOTIATINGFIREWALLS"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_STARTINGGAME: - TheGameSpyInfo->addText(TheGameText->fetch("QM:STARTINGGAME"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_COULDNOTFINDBOT: - TheGameSpyInfo->addText(TheGameText->fetch("QM:COULDNOTFINDBOT"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( FALSE ); - buttonStop->winHide( TRUE ); - enableOptionsGadgets(TRUE); - break; - case QM_COULDNOTFINDCHANNEL: - TheGameSpyInfo->addText(TheGameText->fetch("QM:COULDNOTFINDCHANNEL"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( FALSE ); - buttonStop->winHide( TRUE ); - enableOptionsGadgets(TRUE); - break; - case QM_COULDNOTNEGOTIATEFIREWALLS: - TheGameSpyInfo->addText(TheGameText->fetch("QM:COULDNOTNEGOTIATEFIREWALLS"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( FALSE ); - buttonStop->winHide( TRUE ); - enableOptionsGadgets(TRUE); - break; - case QM_STOPPED: - TheGameSpyInfo->addText(TheGameText->fetch("QM:STOPPED"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( FALSE ); - buttonStop->winHide( TRUE ); - enableOptionsGadgets(TRUE); - break; - } - } - break; - } - } -#ifdef PERF_TEST - // check performance - end = timeGetTime(); - UnsignedInt frameTime = end-start; - if (frameTime > 100 || responses.size() > 20) - { - UnicodeString munkee; - munkee.format(L"inQM:%d %d ms, %d messages", s_inQM, frameTime, responses.size()); - TheGameSpyInfo->addText(munkee, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - PERF_LOG(("%ls\n", munkee.str())); - - std::list::const_iterator it; - for (it = responses.begin(); it != responses.end(); ++it) - { - PERF_LOG((" %s\n", getMessageString(*it))); - } - } -#endif // PERF_TEST - } -}// WOLQuickMatchMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Quick Match Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLQuickMatchMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - if (buttonPushed) - break; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - if(!buttonBack->winIsHidden()) - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLQuickMatchMenuInput - -//------------------------------------------------------------------------------------------------- -/** WOL Quick Match Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLQuickMatchMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GCM_SELECTED: - { - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - Int pos = -1; - GadgetComboBoxGetSelectedPos(control, &pos); - - saveQuickMatchOptions(); - if (controlID == comboBoxLadderID && !isPopulatingLadderBox) - { - if (pos >= 0) - { - QuickMatchPreferences pref; - Int ladderID = (Int)GadgetComboBoxGetItemData(control, pos); - if (ladderID == 0) - { - // no ladder selected - enable buttons - GadgetComboBoxSetSelectedPos(comboBoxNumPlayers, max(0, pref.getNumPlayers()/2-1)); - comboBoxNumPlayers->winEnable( TRUE ); - populateQMSideComboBox(pref.getSide()); // this will set side to random and disable if necessary - } - else if (ladderID > 0) - { - // ladder selected - disable buttons - const LadderInfo *li = TheLadderList->findLadderByIndex(ladderID); - if (li) - GadgetComboBoxSetSelectedPos(comboBoxNumPlayers, li->playersPerTeam-1); - else - GadgetComboBoxSetSelectedPos(comboBoxNumPlayers, 0); - comboBoxNumPlayers->winEnable( FALSE ); - - populateQMSideComboBox(pref.getSide(), li); // this will set side to random and disable if necessary - } - else - { - // "Choose a ladder" selected - open overlay - PopulateQMLadderComboBox(); // this restores the non-"Choose a ladder" selection - GameSpyOpenOverlay( GSOVERLAY_LADDERSELECT ); - } - } - } - if (!isInInit) - { - QuickMatchPreferences pref; - populateQuickMatchMapSelectListbox(pref); - UpdateStartButton(); - } - break; - } // case GCM_SELECTED - - case GBM_SELECTED: - { - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - static NameKeyType buttonOptionsID = NAMEKEY("WOLQuickMatchMenu.wnd:ButtonOptions"); - - if ( controlID == buttonStopID ) - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STOPQUICKMATCH; - TheGameSpyPeerMessageQueue->addRequest(req); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( FALSE ); - buttonStop->winHide( TRUE ); - enableOptionsGadgets(TRUE); - TheGameSpyInfo->addText(TheGameText->fetch("GUI:QMAborted"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - else if ( controlID == buttonOptionsID ) - { - GameWindow *win =TheWindowManager->winGetWindowFromId(parentWOLQuickMatch,buttonOptionsID); - if (isInfoShown()) - { - hideInfoGadgets(TRUE); - hideOptionsGadgets(FALSE); - GadgetButtonSetText(win, TheGameText->fetch("GUI:PlayerInfo")); - } - else - { - hideInfoGadgets(FALSE); - hideOptionsGadgets(TRUE); - GadgetButtonSetText(win, TheGameText->fetch("GUI:Setup")); - } - } - else if ( controlID == buttonWidenID ) - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_WIDENQUICKMATCHSEARCH; - TheGameSpyPeerMessageQueue->addRequest(req); - buttonWiden->winEnable( FALSE ); - } - else if ( controlID == buttonStartID ) - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STARTQUICKMATCH; - req.qmMaps.clear(); - - #if VARIABLE_NUMBER_OF_MAPS - for (MapListboxIndex::iterator idxIt = mapListboxIndex.begin(); idxIt != mapListboxIndex.end(); ++idxIt) { - Int index = (*idxIt); - if (index >= 0) - { - req.qmMaps.push_back(GadgetListBoxGetItemData(listboxMapSelect, index, 0)); - } - else - { - req.qmMaps.push_back(false); - } - } - #else - Int numMaps = GadgetListBoxGetNumEntries(listboxMapSelect); - for ( Int i=0; i= maxPingEntries - 1) - { - req.QM.maxPing = TheGameSpyConfig->getPingTimeoutInMs(); - } - else - req.QM.maxPing = (val+1)*100; - - PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID()); - req.QM.points = CalculateRank(stats); - - Int ladderIndex, index, selected; - GadgetComboBoxGetSelectedPos( comboBoxLadder, &selected ); - ladderIndex = (Int)GadgetComboBoxGetItemData( comboBoxLadder, selected ); - const LadderInfo *ladderInfo = NULL; - if (ladderIndex < 0) - { - ladderIndex = 0; - } - if (ladderIndex) - { - ladderInfo = TheLadderList->findLadderByIndex( ladderIndex ); - if (!ladderInfo) - { - ladderIndex = 0; // sanity - } - } - req.QM.ladderID = ladderIndex; - - req.QM.ladderPassCRC = 0; - - index = -1; - GadgetComboBoxGetSelectedPos( comboBoxSide, &selected ); - if (selected >= 0) - index = (Int)GadgetComboBoxGetItemData( comboBoxSide, selected ); - req.QM.side = index; - if (ladderInfo && ladderInfo->randomFactions) - { - Int sideNum = GameClientRandomValue(0, ladderInfo->validFactions.size()-1); - DEBUG_LOG(("Looking for %d out of %d random sides\n", sideNum, ladderInfo->validFactions.size())); - AsciiStringListConstIterator cit = ladderInfo->validFactions.begin(); - while (sideNum) - { - ++cit; - --sideNum; - } - if (cit != ladderInfo->validFactions.end()) - { - Int numPlayerTemplates = ThePlayerTemplateStore->getPlayerTemplateCount(); - AsciiString sideStr = *cit; - DEBUG_LOG(("Chose %s as our side... finding\n", sideStr.str())); - for (Int c=0; cgetNthPlayerTemplate(c); - if (fac && fac->getSide() == sideStr) - { - DEBUG_LOG(("Found %s in index %d\n", sideStr.str(), c)); - req.QM.side = c; - break; - } - } - } - } - - index = -1; - GadgetComboBoxGetSelectedPos( comboBoxColor, &selected ); - if (selected >= 0) - index = (Int)GadgetComboBoxGetItemData( comboBoxColor, selected ); - req.QM.color = index; - - OptionPreferences natPref; - req.QM.NAT = natPref.getFirewallBehavior(); - - if (ladderIndex) - { - req.QM.numPlayers = (ladderInfo)?ladderInfo->playersPerTeam*2 : 2; - } - else - { - GadgetComboBoxGetSelectedPos(comboBoxNumPlayers, &val); - if (val < 0) - val = 0; - req.QM.numPlayers = (val+1)*2; - } - - Int numDiscons = 0; - PerGeneralMap::iterator it; - for(it =stats.discons.begin(); it != stats.discons.end(); ++it) - { - numDiscons += it->second; - } - for(it =stats.desyncs.begin(); it != stats.desyncs.end(); ++it) - { - numDiscons += it->second; - } - req.QM.discons = numDiscons; - - - strncpy(req.QM.pings, TheGameSpyInfo->getPingString().str(), 17); - req.QM.pings[16] = 0; - - req.QM.botID = TheGameSpyConfig->getQMBotID(); - req.QM.roomID = TheGameSpyConfig->getQMChannel(); - - req.QM.exeCRC = TheGlobalData->m_exeCRC; - req.QM.iniCRC = TheGlobalData->m_iniCRC; - - TheGameSpyPeerMessageQueue->addRequest(req); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( TRUE ); - buttonStop->winHide( FALSE ); - enableOptionsGadgets(FALSE); - - if (ladderIndex > 0) - { - // save the ladder as being played upon even if we cancel out of matching early... - LadderPreferences ladPref; - ladPref.loadProfile( TheGameSpyInfo->getLocalProfileID() ); - LadderPref p; - p.lastPlayDate = time(NULL); - p.address = ladderInfo->address; - p.port = ladderInfo->port; - p.name = ladderInfo->name; - ladPref.addRecentLadder( p ); - ladPref.write(); - } - } - else if ( controlID == buttonBuddiesID ) - { - GameSpyToggleOverlay( GSOVERLAY_BUDDY ); - } - else if ( controlID == buttonBackID ) - { - buttonPushed = true; - TheGameSpyInfo->leaveGroupRoom(); - nextScreen = "Menus/WOLWelcomeMenu.wnd"; - TheShell->pop(); - } //if ( controlID == buttonBack ) - else if ( controlID == buttonSelectAllMapsID ) - { - Int numMaps = GadgetListBoxGetNumEntries(listboxMapSelect); - for ( Int i=0; iwinGetWindowId(); - Int selected = (Int)mData2; - - if ( controlID == listboxMapSelectID ) - { - const LadderInfo *li = getLadderInfo(); - if (selected >= 0 && (!li || !li->randomMaps)) - { - Bool wasSelected = (Bool)GadgetListBoxGetItemData(control, selected, 0); - GadgetListBoxSetItemData(control, (void *)(!wasSelected), selected, 0); - Int width = 10; - Int height = 10; - const Image *img = (!wasSelected)?selectedImage:unselectedImage; - if ( img ) - { - width = min(GadgetListBoxGetColumnWidth(control, 0), img->getImageWidth()); - height = width; - } - GadgetListBoxAddEntryImage(control, img, selected, 0, height, width); - GadgetListBoxAddEntryText(control, GadgetListBoxGetText(control, selected, 1), GameSpyColor[(wasSelected)?GSCOLOR_MAP_UNSELECTED:GSCOLOR_MAP_SELECTED], selected, 1); - } - if (selected >= 0) - GadgetListBoxSetSelected(control, -1); - } - UpdateStartButton(); - break; - }// case GLM_SELECTED - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLQuickMatchMenuSystem diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLStatusMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLStatusMenu.cpp deleted file mode 100644 index 87f13e7dcf1..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLStatusMenu.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLLoginMenu.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -//#include "GameNetwork/WOL.h" -//#include "GameNetwork/WOLmenus.h" - - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLStatusID = NAMEKEY_INVALID; -static NameKeyType buttonDisconnectID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLStatus = NULL; -static GameWindow *buttonDisconnect = NULL; -GameWindow *progressTextWindow = NULL; - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Status Menu */ -//------------------------------------------------------------------------------------------------- -void WOLStatusMenuInit( WindowLayout *layout, void *userData ) -{ - parentWOLStatusID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLStatusMenu.wnd:WOLStatusMenuParent" ) ); - buttonDisconnectID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLStatusMenu.wnd:ButtonDisconnect" ) ); - parentWOLStatus = TheWindowManager->winGetWindowFromId( NULL, parentWOLStatusID ); - buttonDisconnect = TheWindowManager->winGetWindowFromId( NULL, buttonDisconnectID); - - progressTextWindow = TheWindowManager->winGetWindowFromId( NULL, - TheNameKeyGenerator->nameToKey( AsciiString( "WOLStatusMenu.wnd:ListboxStatus" ) ) ); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLStatus ); - - //progressLayout = TheShell->top(); - - //WOL::raiseWOLMessageBox(); -} // WOLStatusMenuInit - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLStatusMenuShutdown( WindowLayout *layout, void *userData ) -{ - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); - - //progressLayout = NULL; - - //WOL::raiseWOLMessageBox(); -} // WOLStatusMenuShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLStatusMenuUpdate( WindowLayout * layout, void *userData) -{ - //if (WOL::TheWOL) - //WOL::TheWOL->update(); -}// WOLStatusMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLStatusMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonDisconnect, buttonDisconnectID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLStatusMenuInput - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLStatusMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - /* - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == buttonDisconnectID ) - { - //TheShell->pop(); - if (WOL::TheWOL->setState( WOL::WOLAPI_FATAL_ERROR )) - { - WOL::TheWOL->addCommand( WOL::WOLCOMMAND_RESET ); // don't display an error, log out, or anything - } - - } //if ( controlID == buttonDisconnect ) - */ - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLStatusMenuSystem diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp deleted file mode 100644 index 9721fee7a36..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp +++ /dev/null @@ -1,893 +0,0 @@ -/* -** Command & Conquer Generals(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLWelcomeMenu.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "GameSpy/peer/peer.h" - -#include "Common/GameEngine.h" -#include "Common/GameSpyMiscPreferences.h" -#include "Common/CustomMatchPreferences.h" -#include "Common/GlobalData.h" -#include "Common/UserPreferences.h" - -#include "GameClient/AnimateWindowManager.h" -#include "GameClient/Display.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GameText.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/MessageBox.h" -#include "GameClient/GameWindowTransitions.h" - -#include "GameNetwork/FirewallHelper.h" -#include "GameNetwork/GameSpyOverlay.h" - -#include "GameNetwork/GameSpy/BuddyDefs.h" -#include "GameNetwork/GameSpy/BuddyThread.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" -#include "GameNetwork/GameSpy/BuddyThread.h" -#include "GameNetwork/GameSpy/ThreadUtils.h" -#include "GameNetwork/GameSpy/MainMenuUtils.h" - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -static Bool isShuttingDown = FALSE; -static Bool buttonPushed = FALSE; -static char *nextScreen = NULL; - -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLWelcomeID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; -static NameKeyType buttonQuickMatchID = NAMEKEY_INVALID; -static NameKeyType buttonLobbyID = NAMEKEY_INVALID; -static NameKeyType buttonBuddiesID = NAMEKEY_INVALID; -static NameKeyType buttonLadderID = NAMEKEY_INVALID; -static NameKeyType buttonMyInfoID = NAMEKEY_INVALID; - -static NameKeyType listboxInfoID = NAMEKEY_INVALID; -static NameKeyType buttonOptionsID = NAMEKEY_INVALID; -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLWelcome = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *buttonQuickMatch = NULL; -static GameWindow *buttonLobby = NULL; -static GameWindow *buttonBuddies = NULL; -static GameWindow *buttonLadder = NULL; -static GameWindow *buttonMyInfo = NULL; -static GameWindow *buttonbuttonOptions = NULL; -static WindowLayout *welcomeLayout = NULL; -static GameWindow *listboxInfo = NULL; - -static GameWindow *staticTextServerName = NULL; -static GameWindow *staticTextLastUpdated = NULL; - -static GameWindow *staticTextLadderWins = NULL; -static GameWindow *staticTextLadderLosses = NULL; -static GameWindow *staticTextLadderRank = NULL; -static GameWindow *staticTextLadderPoints = NULL; -static GameWindow *staticTextLadderDisconnects = NULL; - -static GameWindow *staticTextHighscoreWins = NULL; -static GameWindow *staticTextHighscoreLosses = NULL; -static GameWindow *staticTextHighscoreRank = NULL; -static GameWindow *staticTextHighscorePoints = NULL; - -static UnicodeString gServerName; -void updateServerDisplay(UnicodeString serverName) -{ - if (staticTextServerName) - { - GadgetStaticTextSetText(staticTextServerName, serverName); - } - gServerName = serverName; -} - -/* -void updateLocalPlayerScores(AsciiString name, const WOL::Ladder *ladder, const WOL::Highscore *highscore) -{ - if (ladder) - { - AsciiString a; - UnicodeString u; - - a.format("%d", ladder->wins); - u.translate(a); - GadgetStaticTextSetText(staticTextLadderWins, u); - - a.format("%d", ladder->losses); - u.translate(a); - GadgetStaticTextSetText(staticTextLadderLosses, u); - - a.format("%d", ladder->rank); - u.translate(a); - GadgetStaticTextSetText(staticTextLadderRank, u); - - a.format("%d", ladder->points); - u.translate(a); - GadgetStaticTextSetText(staticTextLadderPoints, u); - - a.format("%d", ladder->disconnects); - u.translate(a); - GadgetStaticTextSetText(staticTextLadderDisconnects, u); - } - if (highscore) - { - AsciiString a; - UnicodeString u; - - a.format("%d", highscore->wins); - u.translate(a); - GadgetStaticTextSetText(staticTextHighscoreWins, u); - - a.format("%d", highscore->losses); - u.translate(a); - GadgetStaticTextSetText(staticTextHighscoreLosses, u); - - a.format("%d", highscore->rank); - u.translate(a); - GadgetStaticTextSetText(staticTextHighscoreRank, u); - - a.format("%d", highscore->points); - u.translate(a); - GadgetStaticTextSetText(staticTextHighscorePoints, u); - } -} -*/ - - -static void enableControls( Bool state ) -{ -#ifndef _PLAYTEST - if (buttonQuickMatch) - buttonQuickMatch->winEnable(state); -#else - if (buttonQuickMatch) - buttonQuickMatch->winEnable(FALSE); -#endif - if (buttonLobby) - buttonLobby->winEnable(state); -} - -//------------------------------------------------------------------------------------------------- -/** This is called when a shutdown is complete for this menu */ -//------------------------------------------------------------------------------------------------- -static void shutdownComplete( WindowLayout *layout ) -{ - - isShuttingDown = FALSE; - - // hide the layout - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout, (nextScreen != NULL) ); - - if (nextScreen != NULL) - { - TheShell->push(nextScreen); - } - - nextScreen = NULL; - -} // end if - -//------------------------------------------------------------------------------------------------- -/** Handle Num Players Online data */ -//------------------------------------------------------------------------------------------------- - -static Int lastNumPlayersOnline = 0; - -static UnsignedByte grabUByte(const char *s) -{ - char tmp[5] = "0xff"; - tmp[2] = s[0]; - tmp[3] = s[1]; - UnsignedByte b = strtol(tmp, NULL, 16); - return b; -} - -static void updateNumPlayersOnline(void) -{ - GameWindow *playersOnlineWindow = TheWindowManager->winGetWindowFromId( - NULL, NAMEKEY("WOLWelcomeMenu.wnd:StaticTextNumPlayersOnline") ); - - if (playersOnlineWindow) - { - UnicodeString valStr; - valStr.format(TheGameText->fetch("GUI:NumPlayersOnline"), lastNumPlayersOnline); - GadgetStaticTextSetText(playersOnlineWindow, valStr); - } - - if (listboxInfo && TheGameSpyInfo) - { - GadgetListBoxReset(listboxInfo); - AsciiString aLine; - UnicodeString line; - AsciiString aMotd = TheGameSpyInfo->getMOTD(); - UnicodeString headingStr; - headingStr.format(TheGameText->fetch("MOTD:NumPlayersHeading"), lastNumPlayersOnline); - - while (headingStr.nextToken(&line, UnicodeString(L"\n"))) - { - if (line.getCharAt(line.getLength()-1) == '\r') - line.removeLastChar(); // there is a trailing '\r' - - line.trim(); - - if (line.isEmpty()) - { - line = UnicodeString(L" "); - } - - GadgetListBoxAddEntryText(listboxInfo, line, GameSpyColor[GSCOLOR_MOTD_HEADING], -1, -1); - } - GadgetListBoxAddEntryText(listboxInfo, UnicodeString(L" "), GameSpyColor[GSCOLOR_MOTD_HEADING], -1, -1); - - while (aMotd.nextToken(&aLine, "\n")) - { - if (aLine.getCharAt(aLine.getLength()-1) == '\r') - aLine.removeLastChar(); // there is a trailing '\r' - - aLine.trim(); - - if (aLine.isEmpty()) - { - aLine = " "; - } - - Color c = GameSpyColor[GSCOLOR_MOTD]; - if (aLine.startsWith("\\\\")) - { - aLine = aLine.str()+1; - } - else if (aLine.startsWith("\\") && aLine.getLength() > 9) - { - // take out the hex value from strings starting as "\ffffffffText" - UnsignedByte a, r, g, b; - a = grabUByte(aLine.str()+1); - r = grabUByte(aLine.str()+3); - g = grabUByte(aLine.str()+5); - b = grabUByte(aLine.str()+7); - c = GameMakeColor(r, g, b, a); - DEBUG_LOG(("MOTD line '%s' has color %X\n", aLine.str(), c)); - aLine = aLine.str() + 9; - } - line = UnicodeString(MultiByteToWideCharSingleLine(aLine.str()).c_str()); - - GadgetListBoxAddEntryText(listboxInfo, line, c, -1, -1); - } - } -} - -void HandleNumPlayersOnline( Int numPlayersOnline ) -{ - lastNumPlayersOnline = numPlayersOnline; - if (lastNumPlayersOnline < 1) - lastNumPlayersOnline = 1; - updateNumPlayersOnline(); -} - -//------------------------------------------------------------------------------------------------- -/** Handle Overall Stats data */ -//------------------------------------------------------------------------------------------------- - -static OverallStats s_statsUSA, s_statsChina, s_statsGLA; - -OverallStats::OverallStats() -{ - for (Int i=0; ifetch("GUI:PerSideWinPercentage"), REAL_TO_INT(val), sideStr.str()); - - /* - Int totalDenominator = s_statsUSA.wins[n] + s_statsChina.wins[n] + s_statsGLA.wins[n]; - if (!totalDenominator) - totalDenominator = 1; - - UnicodeString s; - s.format(TheGameText->fetch("GUI:PerSideWinPercentage"), REAL_TO_INT(stats.wins[n]*100/totalDenominator), sideStr.str()); - */ - return s; -} - -static void updateOverallStats(void) -{ - UnicodeString usa, china, gla; - GameWindow *win; - - usa = calcPercent(s_statsUSA, STATS_LASTWEEK, TheGameText->fetch("SIDE:America")); - china = calcPercent(s_statsChina, STATS_LASTWEEK, TheGameText->fetch("SIDE:China")); - gla = calcPercent(s_statsGLA, STATS_LASTWEEK, TheGameText->fetch("SIDE:GLA")); - DEBUG_LOG(("Last Week: %ls %ls %ls\n", usa.str(), china.str(), gla.str())); - win = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("WOLWelcomeMenu.wnd:StaticTextUSALastWeek") ); - GadgetStaticTextSetText(win, usa); - win = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("WOLWelcomeMenu.wnd:StaticTextChinaLastWeek") ); - GadgetStaticTextSetText(win, china); - win = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("WOLWelcomeMenu.wnd:StaticTextGLALastWeek") ); - GadgetStaticTextSetText(win, gla); - - usa = calcPercent(s_statsUSA, STATS_TODAY, TheGameText->fetch("SIDE:America")); - china = calcPercent(s_statsChina, STATS_TODAY, TheGameText->fetch("SIDE:China")); - gla = calcPercent(s_statsGLA, STATS_TODAY, TheGameText->fetch("SIDE:GLA")); - DEBUG_LOG(("Today: %ls %ls %ls\n", usa.str(), china.str(), gla.str())); - win = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("WOLWelcomeMenu.wnd:StaticTextUSAToday") ); - GadgetStaticTextSetText(win, usa); - win = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("WOLWelcomeMenu.wnd:StaticTextChinaToday") ); - GadgetStaticTextSetText(win, china); - win = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("WOLWelcomeMenu.wnd:StaticTextGLAToday") ); - GadgetStaticTextSetText(win, gla); -} - -void HandleOverallStats( const OverallStats& USA, const OverallStats& China, const OverallStats& GLA ) -{ - s_statsUSA = USA; - s_statsChina = China; - s_statsGLA = GLA; - updateOverallStats(); -} - -//------------------------------------------------------------------------------------------------- -/** Handle player stats */ -//------------------------------------------------------------------------------------------------- - -void UpdateLocalPlayerStats(void) -{ - - GameWindow *welcomeParent = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("WOLWelcomeMenu.wnd:WOLWelcomeMenuParent") ); - - if (welcomeParent) - { - PopulatePlayerInfoWindows( "WOLWelcomeMenu.wnd" ); - } - else - { - PopulatePlayerInfoWindows( "WOLQuickMatchMenu.wnd" ); - } - - return; -} - -static Bool raiseMessageBoxes = FALSE; -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Welcome Menu */ -//------------------------------------------------------------------------------------------------- -void WOLWelcomeMenuInit( WindowLayout *layout, void *userData ) -{ - nextScreen = NULL; - buttonPushed = FALSE; - isShuttingDown = FALSE; - - welcomeLayout = layout; - - //TheWOL->reset(); - - parentWOLWelcomeID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:WOLWelcomeMenuParent" ) ); - buttonBackID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonBack" ) ); - parentWOLWelcome = TheWindowManager->winGetWindowFromId( NULL, parentWOLWelcomeID ); - buttonBack = TheWindowManager->winGetWindowFromId( NULL, buttonBackID); - buttonOptionsID = TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:ButtonOptions" ); - buttonbuttonOptions = TheWindowManager->winGetWindowFromId( NULL, buttonOptionsID); - listboxInfoID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:InfoListbox" ) ); - - listboxInfo = TheWindowManager->winGetWindowFromId( NULL, listboxInfoID); - - staticTextServerName = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextServerName" )); - staticTextLastUpdated = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextLastUpdated" )); - - staticTextLadderWins = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextLadderWins" )); - staticTextLadderLosses = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextLadderLosses" )); - staticTextLadderPoints = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextLadderPoints" )); - staticTextLadderRank = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextLadderRank" )); - staticTextLadderDisconnects = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextDisconnects" )); - - staticTextHighscoreWins = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextHighscoreWins" )); - staticTextHighscoreLosses = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextHighscoreLosses" )); - staticTextHighscorePoints = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextHighscorePoints" )); - staticTextHighscoreRank = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextHighscoreRank" )); - - if (staticTextServerName) - { - GadgetStaticTextSetText(staticTextServerName, gServerName); - } - - GameWindow *staticTextTitle = TheWindowManager->winGetWindowFromId(parentWOLWelcome, NAMEKEY("WOLWelcomeMenu.wnd:StaticTextTitle")); - if (staticTextTitle && TheGameSpyInfo) - { - UnicodeString title; - title.format(TheGameText->fetch("GUI:WOLWelcome"), TheGameSpyInfo->getLocalBaseName().str()); - GadgetStaticTextSetText(staticTextTitle, title); - } - - // Clear some defaults - /* - UnicodeString questionMark = UnicodeString(L"?"); - GadgetStaticTextSetText(staticTextLastUpdated, questionMark); - GadgetStaticTextSetText(staticTextLadderWins, questionMark); - GadgetStaticTextSetText(staticTextLadderLosses, questionMark); - GadgetStaticTextSetText(staticTextLadderPoints, questionMark); - GadgetStaticTextSetText(staticTextLadderRank, questionMark); - GadgetStaticTextSetText(staticTextLadderDisconnects, questionMark); - GadgetStaticTextSetText(staticTextHighscoreWins, questionMark); - GadgetStaticTextSetText(staticTextHighscoreLosses, questionMark); - GadgetStaticTextSetText(staticTextHighscorePoints, questionMark); - GadgetStaticTextSetText(staticTextHighscoreRank, questionMark); - */ - - //DEBUG_ASSERTCRASH(listboxInfo, ("No control found!")); - - buttonQuickMatchID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonQuickMatch" ) ); - buttonQuickMatch = TheWindowManager->winGetWindowFromId( parentWOLWelcome, buttonQuickMatchID ); - - buttonLobbyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonCustomMatch" ) ); - buttonLobby = TheWindowManager->winGetWindowFromId( parentWOLWelcome, buttonLobbyID ); - - buttonBuddiesID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonBuddies" ) ); - buttonBuddies = TheWindowManager->winGetWindowFromId( parentWOLWelcome, buttonBuddiesID ); - - buttonMyInfoID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonMyInfo" ) ); - buttonMyInfo = TheWindowManager->winGetWindowFromId( parentWOLWelcome, buttonMyInfoID ); - - buttonLadderID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonLadder" ) ); - buttonLadder = TheWindowManager->winGetWindowFromId( parentWOLWelcome, buttonLadderID ); - - if (TheFirewallHelper == NULL) { - TheFirewallHelper = createFirewallHelper(); - } - if (TheFirewallHelper->detectFirewall() == TRUE) { - // don't need to detect firewall, already been done. - delete TheFirewallHelper; - TheFirewallHelper = NULL; - } - /* - - if (TheGameSpyChat && TheGameSpyChat->isConnected()) - { - const char *keys[3] = { "locale", "wins", "losses" }; - char valueStrings[3][20]; - char *values[3] = { valueStrings[0], valueStrings[1], valueStrings[2] }; - _snprintf(values[0], 20, "%s", TheGameSpyPlayerInfo->getLocale().str()); - _snprintf(values[1], 20, "%d", TheGameSpyPlayerInfo->getWins()); - _snprintf(values[2], 20, "%d", TheGameSpyPlayerInfo->getLosses()); - peerSetGlobalKeys(TheGameSpyChat->getPeer(), 3, (const char **)keys, (const char **)values); - peerSetGlobalWatchKeys(TheGameSpyChat->getPeer(), GroupRoom, 3, keys, PEERFalse); - peerSetGlobalWatchKeys(TheGameSpyChat->getPeer(), StagingRoom, 3, keys, PEERFalse); - } - */ - -// // animate controls -// TheShell->registerWithAnimateManager(buttonQuickMatch, WIN_ANIMATION_SLIDE_LEFT, TRUE, 800); -// TheShell->registerWithAnimateManager(buttonLobby, WIN_ANIMATION_SLIDE_LEFT, TRUE, 600); -// //TheShell->registerWithAnimateManager(NULL, WIN_ANIMATION_SLIDE_LEFT, TRUE, 400); -// TheShell->registerWithAnimateManager(buttonBuddies, WIN_ANIMATION_SLIDE_LEFT, TRUE, 200); -// //TheShell->registerWithAnimateManager(NULL, WIN_ANIMATION_SLIDE_LEFT, TRUE, 1); -// TheShell->registerWithAnimateManager(buttonBack, WIN_ANIMATION_SLIDE_BOTTOM, TRUE, 1); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLWelcome ); - - enableControls( TheGameSpyInfo->gotGroupRoomList() ); - TheShell->showShellMap(TRUE); - - updateNumPlayersOnline(); - updateOverallStats(); - - UpdateLocalPlayerStats(); - - GameSpyMiscPreferences cPref; - if (cPref.getLocale() < LOC_MIN || cPref.getLocale() > LOC_MAX) - { - GameSpyOpenOverlay(GSOVERLAY_LOCALESELECT); - } - - raiseMessageBoxes = TRUE; - TheTransitionHandler->setGroup("WOLWelcomeMenuFade"); - -} // WOLWelcomeMenuInit - -//------------------------------------------------------------------------------------------------- -/** WOL Welcome Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLWelcomeMenuShutdown( WindowLayout *layout, void *userData ) -{ - listboxInfo = NULL; - - if (TheFirewallHelper != NULL) { - delete TheFirewallHelper; - TheFirewallHelper = NULL; - } - - isShuttingDown = TRUE; - - // if we are shutting down for an immediate pop, skip the animations - Bool popImmediate = *(Bool *)userData; - if( popImmediate ) - { - - shutdownComplete( layout ); - return; - - } //end if - - TheShell->reverseAnimatewindow(); - TheTransitionHandler->reverse("WOLWelcomeMenuFade"); - - - RaiseGSMessageBox(); -} // WOLWelcomeMenuShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Welcome Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLWelcomeMenuUpdate( WindowLayout * layout, void *userData) -{ - // We'll only be successful if we've requested to - if(isShuttingDown && TheShell->isAnimFinished() && TheTransitionHandler->isFinished()) - shutdownComplete(layout); - - if (raiseMessageBoxes) - { - RaiseGSMessageBox(); - raiseMessageBoxes = FALSE; - } - - if (TheFirewallHelper != NULL) - { - if (TheFirewallHelper->behaviorDetectionUpdate()) - { - TheWritableGlobalData->m_firewallBehavior = TheFirewallHelper->getFirewallBehavior(); - - TheFirewallHelper->writeFirewallBehavior(); - - TheFirewallHelper->flagNeedToRefresh(FALSE); // 2/19/03 BGC, we're done, so we don't need to refresh the NAT anymore. - - // we are now done with the firewall helper - delete TheFirewallHelper; - TheFirewallHelper = NULL; - } - } - - if (TheShell->isAnimFinished() && !buttonPushed && TheGameSpyPeerMessageQueue) - { - HandleBuddyResponses(); - HandlePersistentStorageResponses(); - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - PeerResponse resp; - while (allowedMessages-- && !sawImportantMessage && TheGameSpyPeerMessageQueue->getResponse( resp )) - { - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_GROUPROOM: - { - GameSpyGroupRoom room; - room.m_groupID = resp.groupRoom.id; - room.m_maxWaiting = resp.groupRoom.maxWaiting; - room.m_name = resp.groupRoomName.c_str(); - room.m_translatedName = UnicodeString(L"TEST"); - room.m_numGames = resp.groupRoom.numGames; - room.m_numPlaying = resp.groupRoom.numPlaying; - room.m_numWaiting = resp.groupRoom.numWaiting; - TheGameSpyInfo->addGroupRoom( room ); - if (room.m_groupID == 0) - { - enableControls( TRUE ); - } - } - break; - case PeerResponse::PEERRESPONSE_JOINGROUPROOM: - { - sawImportantMessage = TRUE; - enableControls( TRUE ); - if (resp.joinGroupRoom.ok) - { - //buttonPushed = TRUE; - TheGameSpyInfo->setCurrentGroupRoom(resp.joinGroupRoom.id); - //GSMessageBoxOk( TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSGroupRoomJoinOK") ); - - buttonPushed = TRUE; - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - //TheShell->push( "Menus/WOLCustomLobby.wnd" ); - } - else - { - GSMessageBoxOk( TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSGroupRoomJoinFail") ); - } - } - break; - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheShell->pop(); - } - break; - } - } - } - -}// WOLWelcomeMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Welcome Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLWelcomeMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - if (buttonPushed) - break; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLWelcomeMenuInput - -//------------------------------------------------------------------------------------------------- -/** WOL Welcome Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLWelcomeMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == buttonBackID ) - { - //DEBUG_ASSERTCRASH(TheGameSpyChat->getPeer(), ("No GameSpy Peer object!")); - //TheGameSpyChat->disconnectFromChat(); - - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_LOGOUT; - TheGameSpyPeerMessageQueue->addRequest( req ); - BuddyRequest breq; - breq.buddyRequestType = BuddyRequest::BUDDYREQUEST_LOGOUT; - TheGameSpyBuddyMessageQueue->addRequest( breq ); - - DEBUG_LOG(("Tearing down GameSpy from WOLWelcomeMenuSystem(GBM_SELECTED)\n")); - TearDownGameSpy(); - - /* - if (TheGameSpyChat->getPeer()) - { - peerDisconnect(TheGameSpyChat->getPeer()); - } - */ - - buttonPushed = TRUE; - - TheShell->pop(); - - /// @todo: log out instead of disconnecting - //TheWOL->addCommand( WOL::WOLCOMMAND_LOGOUT ); - /** - closeAllOverlays(); - TheShell->pop(); - delete TheWOL; - TheWOL = NULL; - delete TheWOLGame; - TheWOLGame = NULL; - **/ - - } //if ( controlID == buttonBack ) - else if (controlID == buttonOptionsID) - { - GameSpyOpenOverlay( GSOVERLAY_OPTIONS ); - } - else if (controlID == buttonQuickMatchID) - { - GameSpyMiscPreferences mPref; - if ((TheDisplay->getWidth() != 800 || TheDisplay->getHeight() != 600) && mPref.getQuickMatchResLocked()) - { - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:QuickMatch800x600")); - } - else - { - buttonPushed = TRUE; - nextScreen = "Menus/WOLQuickMatchMenu.wnd"; - TheShell->pop(); - } - }// else if - else if (controlID == buttonMyInfoID ) - { - SetLookAtPlayer(TheGameSpyInfo->getLocalProfileID(), TheGameSpyInfo->getLocalName()); - GameSpyToggleOverlay(GSOVERLAY_PLAYERINFO); - } - else if (controlID == buttonLobbyID) - { - //TheGameSpyChat->clearGroupRoomList(); - //peerListGroupRooms(TheGameSpyChat->getPeer(), ListGroupRoomsCallback, NULL, PEERTrue); - TheGameSpyInfo->joinBestGroupRoom(); - enableControls( FALSE ); - - - /* - TheWOL->setScreen(WOL::WOLAPI_MENU_CUSTOMLOBBY); - TheWOL->setGameMode(WOL::WOLTYPE_CUSTOM); - TheWOL->setState( WOL::WOLAPI_LOBBY ); - TheWOL->addCommand( WOL::WOLCOMMAND_REFRESH_CHANNELS ); - */ - }// else if - else if (controlID == buttonBuddiesID) - { - GameSpyToggleOverlay( GSOVERLAY_BUDDY ); - /* - Bool joinedRoom = FALSE; - ClearGroupRoomList(); - peerJoinTitleRoom(TheGameSpyChat->getPeer(), JoinRoomCallback, &joinedRoom, PEERTrue); - if (joinedRoom) - { - GameSpyUsingGroupRooms = FALSE; - GameSpyCurrentGroupRoomID = 0; - TheShell->pop(); - TheShell->push("Menus/WOLCustomLobby.wnd"); - } - else - { - GameSpyCurrentGroupRoomID = 0; - GSMessageBoxOk(UnicodeString(L"Oops"), UnicodeString(L"Unable to join title room"), NULL); - } - */ - } - else if (controlID == buttonLadderID) - { - TheShell->push(AsciiString("Menus/WOLLadderScreen.wnd")); - } - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLWelcomeMenuSystem diff --git a/GeneralsMD/Code/GameEngine/GameEngine.dsp b/GeneralsMD/Code/GameEngine/GameEngine.dsp index 803e13bf105..f791a280df5 100644 --- a/GeneralsMD/Code/GameEngine/GameEngine.dsp +++ b/GeneralsMD/Code/GameEngine/GameEngine.dsp @@ -2055,58 +2055,6 @@ SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\SkirmishGameOptionsMenu.cpp SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\SkirmishMapSelectMenu.cpp # End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLBuddyOverlay.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLCustomScoreScreen.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLGameSetupMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLLadderScreen.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLLobbyMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLLocaleSelectPopup.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLLoginMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLMapSelectMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLMessageWindow.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLQMScoreScreen.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLQuickMatchMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLStatusMenu.cpp -# End Source File -# Begin Source File - -SOURCE=.\Source\GameClient\GUI\GUICallbacks\Menus\WOLWelcomeMenu.cpp -# End Source File # End Group # Begin Source File @@ -4659,7 +4607,6 @@ SOURCE=.\Include\GameClient\WinInstanceData.h # End Group # Begin Group "GameNetwork.H" - # PROP Default_Filter "" # Begin Group "md5" @@ -5027,6 +4974,5 @@ SOURCE=.\Include\GameNetwork\User.h SOURCE=.\Include\Precompiled\PreRTS.h # End Source File # End Group -# End Group # End Target # End Project diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.h b/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.h index 8d3bfd23f5d..489301c5f60 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.h +++ b/GeneralsMD/Code/GameEngine/Include/GameClient/GUICallbacks.h @@ -171,105 +171,6 @@ extern void DifficultySelectInit( WindowLayout *layout, void *userData ); extern WindowMsgHandledType DifficultySelectSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); extern WindowMsgHandledType DifficultySelectInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -//================================================================================================= -// WOL UI // -//================================================================================================= -// WOL Ladder Screen --------------------------------------------------------------------------------- -extern void WOLLadderScreenInit( WindowLayout *layout, void *userData ); -extern void WOLLadderScreenUpdate( WindowLayout *layout, void *userData ); -extern void WOLLadderScreenShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLLadderScreenSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLLadderScreenInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Login Menu --------------------------------------------------------------------------------- -extern void WOLLoginMenuInit( WindowLayout *layout, void *userData ); -extern void WOLLoginMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLLoginMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLLoginMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLLoginMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Locale Select Popup --------------------------------------------------------------------------------- -extern void WOLLocaleSelectInit( WindowLayout *layout, void *userData ); -extern void WOLLocaleSelectUpdate( WindowLayout *layout, void *userData ); -extern void WOLLocaleSelectShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLLocaleSelectSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLLocaleSelectInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Message Window ------------------------------------------------------------------------------ -extern void WOLMessageWindowInit( WindowLayout *layout, void *userData ); -extern void WOLMessageWindowUpdate( WindowLayout *layout, void *userData ); -extern void WOLMessageWindowShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLMessageWindowSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLMessageWindowInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Quick Match Menu ---------------------------------------------------------------------------- -extern void WOLQuickMatchMenuInit( WindowLayout *layout, void *userData ); -extern void WOLQuickMatchMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLQuickMatchMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLQuickMatchMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLQuickMatchMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Welcome Menu -------------------------------------------------------------------------------- -extern void WOLWelcomeMenuInit( WindowLayout *layout, void *userData ); -extern void WOLWelcomeMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLWelcomeMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLWelcomeMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLWelcomeMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Welcome Menu -------------------------------------------------------------------------------- -extern void WOLStatusMenuInit( WindowLayout *layout, void *userData ); -extern void WOLStatusMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLStatusMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLStatusMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLStatusMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Quickmatch Score Screen -------------------------------------------------------------------------------- -extern void WOLQMScoreScreenInit( WindowLayout *layout, void *userData ); -extern void WOLQMScoreScreenUpdate( WindowLayout *layout, void *userData ); -extern void WOLQMScoreScreenShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLQMScoreScreenSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLQMScoreScreenInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Lobby Menu --------------------------------------------------------------------------------- -extern void WOLLobbyMenuInit( WindowLayout *layout, void *userData ); -extern void WOLLobbyMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLLobbyMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLLobbyMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLLobbyMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Game Setup Menu --------------------------------------------------------------------------------- -extern void WOLGameSetupMenuInit( WindowLayout *layout, void *userData ); -extern void WOLGameSetupMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLGameSetupMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLGameSetupMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Custom Score Screen -------------------------------------------------------------------------------- -extern void WOLCustomScoreScreenInit( WindowLayout *layout, void *userData ); -extern void WOLCustomScoreScreenUpdate( WindowLayout *layout, void *userData ); -extern void WOLCustomScoreScreenShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLCustomScoreScreenSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLCustomScoreScreenInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Map Select Overlay --------------------------------------------------------------------------------- -extern void WOLMapSelectMenuInit( WindowLayout *layout, void *userData ); -extern void WOLMapSelectMenuUpdate( WindowLayout *layout, void *userData ); -extern void WOLMapSelectMenuShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLMapSelectMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLMapSelectMenuInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Buddy Overlay --------------------------------------------------------------------------------- -extern void WOLBuddyOverlayInit( WindowLayout *layout, void *userData ); -extern void WOLBuddyOverlayUpdate( WindowLayout *layout, void *userData ); -extern void WOLBuddyOverlayShutdown( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLBuddyOverlaySystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -extern WindowMsgHandledType WOLBuddyOverlayInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - -// WOL Buddy Overlay Right Click menu callbacks -------------------------------------------------------------- -extern void WOLBuddyOverlayRCMenuInit( WindowLayout *layout, void *userData ); -extern WindowMsgHandledType WOLBuddyOverlayRCMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); - // GameSpy Player Info Overlay --------------------------------------------------------------------------------- extern void GameSpyPlayerInfoOverlayInit( WindowLayout *layout, void *userData ); extern void GameSpyPlayerInfoOverlayUpdate( WindowLayout *layout, void *userData ); diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/FunctionLexicon.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/FunctionLexicon.cpp index 2f6a9569dc3..36538488fb5 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/FunctionLexicon.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/FunctionLexicon.cpp @@ -43,7 +43,6 @@ extern WindowMsgHandledType PopupLadderSelectInput( GameWindow *window, Unsigned extern WindowMsgHandledType PopupBuddyNotificationSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); -// WOL Buddy Overlay Right Click menu callbacks -------------------------------------------------------------- extern void RCGameDetailsMenuInit( WindowLayout *layout, void *userData ); extern WindowMsgHandledType RCGameDetailsMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ); @@ -112,22 +111,8 @@ static FunctionLexicon::TableEntry gameWinSystemTable[] = { NAMEKEY_INVALID, "PopupBuddyNotificationSystem", PopupBuddyNotificationSystem }, { NAMEKEY_INVALID, "PopupReplaySystem", PopupReplaySystem }, { NAMEKEY_INVALID, "KeyboardOptionsMenuSystem", KeyboardOptionsMenuSystem }, - { NAMEKEY_INVALID, "WOLLadderScreenSystem", WOLLadderScreenSystem }, - { NAMEKEY_INVALID, "WOLLoginMenuSystem", WOLLoginMenuSystem }, - { NAMEKEY_INVALID, "WOLLocaleSelectSystem", WOLLocaleSelectSystem }, - { NAMEKEY_INVALID, "WOLLobbyMenuSystem", WOLLobbyMenuSystem }, - { NAMEKEY_INVALID, "WOLGameSetupMenuSystem", WOLGameSetupMenuSystem }, - { NAMEKEY_INVALID, "WOLMapSelectMenuSystem", WOLMapSelectMenuSystem }, - { NAMEKEY_INVALID, "WOLBuddyOverlaySystem", WOLBuddyOverlaySystem }, - { NAMEKEY_INVALID, "WOLBuddyOverlayRCMenuSystem", WOLBuddyOverlayRCMenuSystem }, { NAMEKEY_INVALID, "RCGameDetailsMenuSystem", RCGameDetailsMenuSystem }, { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlaySystem",GameSpyPlayerInfoOverlaySystem }, - { NAMEKEY_INVALID, "WOLMessageWindowSystem", WOLMessageWindowSystem }, - { NAMEKEY_INVALID, "WOLQuickMatchMenuSystem", WOLQuickMatchMenuSystem }, - { NAMEKEY_INVALID, "WOLWelcomeMenuSystem", WOLWelcomeMenuSystem }, - { NAMEKEY_INVALID, "WOLStatusMenuSystem", WOLStatusMenuSystem }, - { NAMEKEY_INVALID, "WOLQMScoreScreenSystem", WOLQMScoreScreenSystem }, - { NAMEKEY_INVALID, "WOLCustomScoreScreenSystem", WOLCustomScoreScreenSystem }, { NAMEKEY_INVALID, "NetworkDirectConnectSystem", NetworkDirectConnectSystem }, { NAMEKEY_INVALID, "PopupHostGameSystem", PopupHostGameSystem }, { NAMEKEY_INVALID, "PopupJoinGameSystem", PopupJoinGameSystem }, @@ -185,20 +170,7 @@ static FunctionLexicon::TableEntry gameWinInputTable[] = { NAMEKEY_INVALID, "SkirmishGameOptionsMenuInput", SkirmishGameOptionsMenuInput }, { NAMEKEY_INVALID, "SkirmishMapSelectMenuInput", SkirmishMapSelectMenuInput }, { NAMEKEY_INVALID, "ChallengeMenuInput", ChallengeMenuInput }, - { NAMEKEY_INVALID, "WOLLadderScreenInput", WOLLadderScreenInput }, - { NAMEKEY_INVALID, "WOLLoginMenuInput", WOLLoginMenuInput }, - { NAMEKEY_INVALID, "WOLLocaleSelectInput", WOLLocaleSelectInput }, - { NAMEKEY_INVALID, "WOLLobbyMenuInput", WOLLobbyMenuInput }, - { NAMEKEY_INVALID, "WOLGameSetupMenuInput", WOLGameSetupMenuInput }, - { NAMEKEY_INVALID, "WOLMapSelectMenuInput", WOLMapSelectMenuInput }, - { NAMEKEY_INVALID, "WOLBuddyOverlayInput", WOLBuddyOverlayInput }, { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayInput", GameSpyPlayerInfoOverlayInput }, - { NAMEKEY_INVALID, "WOLMessageWindowInput", WOLMessageWindowInput }, - { NAMEKEY_INVALID, "WOLQuickMatchMenuInput", WOLQuickMatchMenuInput }, - { NAMEKEY_INVALID, "WOLWelcomeMenuInput", WOLWelcomeMenuInput }, - { NAMEKEY_INVALID, "WOLStatusMenuInput", WOLStatusMenuInput }, - { NAMEKEY_INVALID, "WOLQMScoreScreenInput", WOLQMScoreScreenInput }, - { NAMEKEY_INVALID, "WOLCustomScoreScreenInput", WOLCustomScoreScreenInput }, { NAMEKEY_INVALID, "NetworkDirectConnectInput", NetworkDirectConnectInput }, { NAMEKEY_INVALID, "PopupHostGameInput", PopupHostGameInput }, { NAMEKEY_INVALID, "PopupJoinGameInput", PopupJoinGameInput }, @@ -257,22 +229,8 @@ static FunctionLexicon::TableEntry winLayoutInitTable[] = { NAMEKEY_INVALID, "SkirmishGameOptionsMenuInit", SkirmishGameOptionsMenuInit }, { NAMEKEY_INVALID, "SkirmishMapSelectMenuInit", SkirmishMapSelectMenuInit }, { NAMEKEY_INVALID, "ChallengeMenuInit", ChallengeMenuInit }, - { NAMEKEY_INVALID, "WOLLadderScreenInit", WOLLadderScreenInit }, - { NAMEKEY_INVALID, "WOLLoginMenuInit", WOLLoginMenuInit }, - { NAMEKEY_INVALID, "WOLLocaleSelectInit", WOLLocaleSelectInit }, - { NAMEKEY_INVALID, "WOLLobbyMenuInit", WOLLobbyMenuInit }, - { NAMEKEY_INVALID, "WOLGameSetupMenuInit", WOLGameSetupMenuInit }, - { NAMEKEY_INVALID, "WOLMapSelectMenuInit", WOLMapSelectMenuInit }, - { NAMEKEY_INVALID, "WOLBuddyOverlayInit", WOLBuddyOverlayInit }, - { NAMEKEY_INVALID, "WOLBuddyOverlayRCMenuInit", WOLBuddyOverlayRCMenuInit }, { NAMEKEY_INVALID, "RCGameDetailsMenuInit", RCGameDetailsMenuInit }, { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayInit", GameSpyPlayerInfoOverlayInit }, - { NAMEKEY_INVALID, "WOLMessageWindowInit", WOLMessageWindowInit }, - { NAMEKEY_INVALID, "WOLQuickMatchMenuInit", WOLQuickMatchMenuInit }, - { NAMEKEY_INVALID, "WOLWelcomeMenuInit", WOLWelcomeMenuInit }, - { NAMEKEY_INVALID, "WOLStatusMenuInit", WOLStatusMenuInit }, - { NAMEKEY_INVALID, "WOLQMScoreScreenInit", WOLQMScoreScreenInit }, - { NAMEKEY_INVALID, "WOLCustomScoreScreenInit", WOLCustomScoreScreenInit }, { NAMEKEY_INVALID, "NetworkDirectConnectInit", NetworkDirectConnectInit }, { NAMEKEY_INVALID, "PopupHostGameInit", PopupHostGameInit }, { NAMEKEY_INVALID, "PopupJoinGameInit", PopupJoinGameInit }, @@ -306,21 +264,8 @@ static FunctionLexicon::TableEntry winLayoutUpdateTable[] = { NAMEKEY_INVALID, "SkirmishGameOptionsMenuUpdate", SkirmishGameOptionsMenuUpdate }, { NAMEKEY_INVALID, "SkirmishMapSelectMenuUpdate", SkirmishMapSelectMenuUpdate }, { NAMEKEY_INVALID, "ChallengeMenuUpdate", ChallengeMenuUpdate }, - { NAMEKEY_INVALID, "WOLLadderScreenUpdate", WOLLadderScreenUpdate }, - { NAMEKEY_INVALID, "WOLLoginMenuUpdate", WOLLoginMenuUpdate }, - { NAMEKEY_INVALID, "WOLLocaleSelectUpdate", WOLLocaleSelectUpdate }, - { NAMEKEY_INVALID, "WOLLobbyMenuUpdate", WOLLobbyMenuUpdate }, - { NAMEKEY_INVALID, "WOLGameSetupMenuUpdate", WOLGameSetupMenuUpdate }, { NAMEKEY_INVALID, "PopupHostGameUpdate", PopupHostGameUpdate }, - { NAMEKEY_INVALID, "WOLMapSelectMenuUpdate", WOLMapSelectMenuUpdate }, - { NAMEKEY_INVALID, "WOLBuddyOverlayUpdate", WOLBuddyOverlayUpdate }, { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayUpdate",GameSpyPlayerInfoOverlayUpdate }, - { NAMEKEY_INVALID, "WOLMessageWindowUpdate", WOLMessageWindowUpdate }, - { NAMEKEY_INVALID, "WOLQuickMatchMenuUpdate", WOLQuickMatchMenuUpdate }, - { NAMEKEY_INVALID, "WOLWelcomeMenuUpdate", WOLWelcomeMenuUpdate }, - { NAMEKEY_INVALID, "WOLStatusMenuUpdate", WOLStatusMenuUpdate }, - { NAMEKEY_INVALID, "WOLQMScoreScreenUpdate", WOLQMScoreScreenUpdate }, - { NAMEKEY_INVALID, "WOLCustomScoreScreenUpdate", WOLCustomScoreScreenUpdate }, { NAMEKEY_INVALID, "NetworkDirectConnectUpdate", NetworkDirectConnectUpdate }, { NAMEKEY_INVALID, "ScoreScreenUpdate", ScoreScreenUpdate }, { NAMEKEY_INVALID, "DownloadMenuUpdate", DownloadMenuUpdate }, @@ -348,20 +293,7 @@ static FunctionLexicon::TableEntry winLayoutShutdownTable[] = { NAMEKEY_INVALID, "SkirmishGameOptionsMenuShutdown",SkirmishGameOptionsMenuShutdown }, { NAMEKEY_INVALID, "SkirmishMapSelectMenuShutdown", SkirmishMapSelectMenuShutdown }, { NAMEKEY_INVALID, "ChallengeMenuShutdown", ChallengeMenuShutdown }, - { NAMEKEY_INVALID, "WOLLadderScreenShutdown", WOLLadderScreenShutdown }, - { NAMEKEY_INVALID, "WOLLoginMenuShutdown", WOLLoginMenuShutdown }, - { NAMEKEY_INVALID, "WOLLocaleSelectShutdown", WOLLocaleSelectShutdown }, - { NAMEKEY_INVALID, "WOLLobbyMenuShutdown", WOLLobbyMenuShutdown }, - { NAMEKEY_INVALID, "WOLGameSetupMenuShutdown", WOLGameSetupMenuShutdown }, - { NAMEKEY_INVALID, "WOLMapSelectMenuShutdown", WOLMapSelectMenuShutdown }, - { NAMEKEY_INVALID, "WOLBuddyOverlayShutdown", WOLBuddyOverlayShutdown }, { NAMEKEY_INVALID, "GameSpyPlayerInfoOverlayShutdown",GameSpyPlayerInfoOverlayShutdown }, - { NAMEKEY_INVALID, "WOLMessageWindowShutdown", WOLMessageWindowShutdown }, - { NAMEKEY_INVALID, "WOLQuickMatchMenuShutdown", WOLQuickMatchMenuShutdown }, - { NAMEKEY_INVALID, "WOLWelcomeMenuShutdown", WOLWelcomeMenuShutdown }, - { NAMEKEY_INVALID, "WOLStatusMenuShutdown", WOLStatusMenuShutdown }, - { NAMEKEY_INVALID, "WOLQMScoreScreenShutdown", WOLQMScoreScreenShutdown }, - { NAMEKEY_INVALID, "WOLCustomScoreScreenShutdown", WOLCustomScoreScreenShutdown }, { NAMEKEY_INVALID, "NetworkDirectConnectShutdown", NetworkDirectConnectShutdown }, { NAMEKEY_INVALID, "ScoreScreenShutdown", ScoreScreenShutdown }, { NAMEKEY_INVALID, "DownloadMenuShutdown", DownloadMenuShutdown }, diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp deleted file mode 100644 index be7280dec14..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp +++ /dev/null @@ -1,1450 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLBuddyOverlay.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/AudioEventRTS.h" -#include "Common/PlayerList.h" -#include "Common/Player.h" -#include "GameClient/GameText.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetPushButton.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GadgetRadioButton.h" -#include "GameClient/Display.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/BuddyDefs.h" -#include "GameNetwork/GameSpy/BuddyThread.h" -#include "GameNetwork/GameSpy/LobbyUtils.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" -#include "GameNetwork/GameSpy/ThreadUtils.h" - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentID = NAMEKEY_INVALID; -static NameKeyType buttonHideID = NAMEKEY_INVALID; -static NameKeyType buttonAddBuddyID = NAMEKEY_INVALID; -static NameKeyType buttonDeleteBuddyID = NAMEKEY_INVALID; -static NameKeyType textEntryID = NAMEKEY_INVALID; -static NameKeyType listboxBuddyID = NAMEKEY_INVALID; -static NameKeyType listboxChatID = NAMEKEY_INVALID; -static NameKeyType buttonAcceptBuddyID = NAMEKEY_INVALID; -static NameKeyType buttonDenyBuddyID = NAMEKEY_INVALID; -static NameKeyType radioButtonBuddiesID = NAMEKEY_INVALID; -static NameKeyType radioButtonIgnoreID = NAMEKEY_INVALID; -static NameKeyType parentBuddiesID = NAMEKEY_INVALID; -static NameKeyType parentIgnoreID = NAMEKEY_INVALID; -static NameKeyType listboxIgnoreID = NAMEKEY_INVALID; -static NameKeyType buttonNotificationID = NAMEKEY_INVALID; - - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parent = NULL; -static GameWindow *buttonHide = NULL; -static GameWindow *buttonAddBuddy = NULL; -static GameWindow *buttonDeleteBuddy = NULL; -static GameWindow *textEntry = NULL; -static GameWindow *listboxBuddy = NULL; -static GameWindow *listboxChat = NULL; -static GameWindow *buttonAcceptBuddy = NULL; -static GameWindow *buttonDenyBuddy = NULL; -static GameWindow *radioButtonBuddies = NULL; -static GameWindow *radioButtonIgnore = NULL; -static GameWindow *parentBuddies = NULL; -static GameWindow *parentIgnore = NULL; -static GameWindow *listboxIgnore = NULL; - -static Bool isOverlayActive = false; -void insertChat( BuddyMessage msg ); -// RightClick pointers --------------------------------------------------------------------- -static GameWindow *rcMenu = NULL; -static WindowLayout *noticeLayout = NULL; -static UnsignedInt noticeExpires = 0; -enum { NOTIFICATION_EXPIRES = 3000 }; - -void setUnignoreText( WindowLayout *layout, AsciiString nick, GPProfile id); -void refreshIgnoreList( void ); -void showNotificationBox( AsciiString nick, UnicodeString message); -void deleteNotificationBox( void ); -static Bool lastNotificationWasStatus = FALSE; -static Int numOnlineInNotification = 0; - -class BuddyControls -{ -public: - BuddyControls(void ); - GameWindow *listboxChat; - NameKeyType listboxChatID; - - GameWindow *listboxBuddies; - NameKeyType listboxBuddiesID; - - GameWindow *textEntryEdit; - NameKeyType textEntryEditID; - Bool isInit; -}; - -static BuddyControls buddyControls; -BuddyControls::BuddyControls( void ) -{ - listboxChat = NULL; - listboxChatID = NAMEKEY_INVALID; - listboxBuddies = NULL; - listboxBuddiesID = NAMEKEY_INVALID; - textEntryEdit = NULL; - textEntryEditID = NAMEKEY_INVALID; - isInit = FALSE; -} -// At this point I don't give a damn about how good this way is. I'm doing it anyway. -enum -{ - BUDDY_RESETALL_CRAP = -1, - BUDDY_WINDOW_BUDDIES = 0, - BUDDY_WINDOW_DIPLOMACY, - BUDDY_WINDOW_WELCOME_SCREEN, -}; - -void InitBuddyControls(Int type) -{ - if(!TheGameSpyInfo) - { - buddyControls.textEntryEditID = NAMEKEY_INVALID; - buddyControls.textEntryEdit = NULL; - buddyControls.listboxBuddiesID = NAMEKEY_INVALID; - buddyControls.listboxChatID = NAMEKEY_INVALID; - buddyControls.listboxBuddies = NULL; - buddyControls.listboxChat = NULL; - buddyControls.isInit = FALSE; - return; - } - switch (type) { - case BUDDY_RESETALL_CRAP: - buddyControls.textEntryEditID = NAMEKEY_INVALID; - buddyControls.textEntryEdit = NULL; - buddyControls.listboxBuddiesID = NAMEKEY_INVALID; - buddyControls.listboxChatID = NAMEKEY_INVALID; - buddyControls.listboxBuddies = NULL; - buddyControls.listboxChat = NULL; - buddyControls.isInit = FALSE; - break; - case BUDDY_WINDOW_BUDDIES: - buddyControls.textEntryEditID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:TextEntryChat" ) ); - buddyControls.textEntryEdit = TheWindowManager->winGetWindowFromId(NULL, buddyControls.textEntryEditID); - buddyControls.listboxBuddiesID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ListboxBuddies" ) ); - buddyControls.listboxChatID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ListboxBuddyChat" ) ); - buddyControls.listboxBuddies = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxBuddiesID ); - buddyControls.listboxChat = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxChatID); - GadgetTextEntrySetText(buddyControls.textEntryEdit, UnicodeString.TheEmptyString); - buddyControls.isInit = TRUE; - break; - case BUDDY_WINDOW_DIPLOMACY: - buddyControls.textEntryEditID = TheNameKeyGenerator->nameToKey( AsciiString( "Diplomacy.wnd:TextEntryChat" ) ); - buddyControls.textEntryEdit = TheWindowManager->winGetWindowFromId(NULL, buddyControls.textEntryEditID); - buddyControls.listboxBuddiesID = TheNameKeyGenerator->nameToKey( AsciiString( "Diplomacy.wnd:ListboxBuddies" ) ); - buddyControls.listboxChatID = TheNameKeyGenerator->nameToKey( AsciiString( "Diplomacy.wnd:ListboxBuddyChat" ) ); - buddyControls.listboxBuddies = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxBuddiesID ); - buddyControls.listboxChat = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxChatID); - GadgetTextEntrySetText(buddyControls.textEntryEdit, UnicodeString.TheEmptyString); - buddyControls.isInit = TRUE; - break; - case BUDDY_WINDOW_WELCOME_SCREEN: - break; - default: - DEBUG_ASSERTCRASH(FALSE, ("Well, you really shouldn't have gotten here, if you really care about GUI Bugs, search for this string, you you don't care, call chris (who probably doesn't care either")); - } - -} - -WindowMsgHandledType BuddyControlSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2) -{ - if(!TheGameSpyInfo || TheGameSpyInfo->getLocalProfileID() == 0 || !buddyControls.isInit) - { - return MSG_IGNORED; - } - - switch( msg ) - { - case GLM_RIGHT_CLICKED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if( controlID == buddyControls.listboxBuddiesID ) - { - RightClickStruct *rc = (RightClickStruct *)mData2; - WindowLayout *rcLayout; - if(rc->pos < 0) - break; - - GPProfile profileID = (GPProfile)GadgetListBoxGetItemData(control, rc->pos, 0); - RCItemType itemType = (RCItemType)(Int)GadgetListBoxGetItemData(control, rc->pos, 1); - UnicodeString nick = GadgetListBoxGetText(control, rc->pos); - - GadgetListBoxSetSelected(control, rc->pos); - if (itemType == ITEM_BUDDY) - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCBuddiesMenu.wnd")); - else if (itemType == ITEM_REQUEST) - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCBuddyRequestMenu.wnd")); - else - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCNonBuddiesMenu.wnd")); - rcMenu = rcLayout->getFirstWindow(); - rcMenu->winGetLayout()->runInit(); - rcMenu->winBringToTop(); - rcMenu->winHide(FALSE); - - - ICoord2D rcSize, rcPos; - rcMenu->winGetSize(&rcSize.x, &rcSize.y); - rcPos.x = rc->mouseX; - rcPos.y = rc->mouseY; - if(rc->mouseX + rcSize.x > TheDisplay->getWidth()) - rcPos.x = TheDisplay->getWidth() - rcSize.x; - if(rc->mouseY + rcSize.y > TheDisplay->getHeight()) - rcPos.y = TheDisplay->getHeight() - rcSize.y; - rcMenu->winSetPosition(rcPos.x, rcPos.y); - - - GameSpyRCMenuData *rcData = NEW GameSpyRCMenuData; - rcData->m_id = profileID; - rcData->m_nick.translate(nick); - rcData->m_itemType = itemType; - setUnignoreText(rcLayout, rcData->m_nick, rcData->m_id); - rcMenu->winSetUserData((void *)rcData); - TheWindowManager->winSetLoneWindow(rcMenu); - } - else - return MSG_IGNORED; - break; - } - case GEM_EDIT_DONE: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if(controlID != buddyControls.textEntryEditID) - return MSG_IGNORED; - - // see if someone's selected - Int selected = -1; - GadgetListBoxGetSelected(buddyControls.listboxBuddies, &selected); - if (selected >= 0) - { - GPProfile selectedProfile = (GPProfile)GadgetListBoxGetItemData(buddyControls.listboxBuddies, selected); - BuddyInfoMap *m = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator recipIt = m->find(selectedProfile); - if (recipIt == m->end()) - break; - - DEBUG_LOG(("Trying to send a buddy message to %d.\n", selectedProfile)); - if (TheGameSpyGame && TheGameSpyGame->isInGame() && TheGameSpyGame->isGameInProgress() && - !ThePlayerList->getLocalPlayer()->isPlayerActive()) - { - DEBUG_LOG(("I'm dead - gotta look for cheats.\n")); - for (Int i=0; igetGameSpySlot(i)->getProfileID())); - if (TheGameSpyGame->getGameSpySlot(i)->getProfileID() == selectedProfile) - { - // can't send to someone in our game if we're dead/observing. security breach and all that. no seances for you. - if (buddyControls.listboxChat) - { - GadgetListBoxAddEntryText( buddyControls.listboxChat, TheGameText->fetch("Buddy:CantTalkToIngameBuddy"), - GameSpyColor[GSCOLOR_DEFAULT], -1, -1 ); - } - return MSG_HANDLED; - } - } - } - - // read the user's input and clear the entry box - UnicodeString txtInput; - txtInput.set(GadgetTextEntryGetText( buddyControls.textEntryEdit )); - GadgetTextEntrySetText(buddyControls.textEntryEdit, UnicodeString::TheEmptyString); - txtInput.trim(); - if (!txtInput.isEmpty()) - { - // Send the message - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_MESSAGE; - wcsncpy(req.arg.message.text, txtInput.str(), MAX_BUDDY_CHAT_LEN); - req.arg.message.text[MAX_BUDDY_CHAT_LEN-1] = 0; - req.arg.message.recipient = selectedProfile; - TheGameSpyBuddyMessageQueue->addRequest(req); - - // save message for future incarnations of the buddy window - BuddyMessageList *messages = TheGameSpyInfo->getBuddyMessages(); - BuddyMessage message; - message.m_timestamp = time(NULL); - message.m_senderID = TheGameSpyInfo->getLocalProfileID(); - message.m_senderNick = TheGameSpyInfo->getLocalBaseName(); - message.m_recipientID = selectedProfile; - message.m_recipientNick = recipIt->second.m_name; - message.m_message = UnicodeString(req.arg.message.text); - messages->push_back(message); - - // put message on screen - insertChat(message); - } - } - else - { - // nobody selected. Prompt the user. - if (buddyControls.listboxChat) - { - GadgetListBoxAddEntryText( buddyControls.listboxChat, TheGameText->fetch("Buddy:SelectBuddyToChat"), - GameSpyColor[GSCOLOR_DEFAULT], -1, -1 ); - } - } - break; - } - default: - return MSG_IGNORED; - } - return MSG_HANDLED; -} - - -static void insertChat( BuddyMessage msg ) -{ - if (buddyControls.listboxChat) - { - BuddyInfoMap *m = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator senderIt = m->find(msg.m_senderID); - BuddyInfoMap::iterator recipientIt = m->find(msg.m_recipientID); - Bool localSender = (msg.m_senderID == TheGameSpyInfo->getLocalProfileID()); - UnicodeString s; - //UnicodeString timeStr = UnicodeString(_wctime( (const time_t *)&msg.m_timestamp )); - UnicodeString timeStr; - if (localSender /*&& recipientIt != m->end()*/) - { - s.format(L"[%hs -> %hs] %s", TheGameSpyInfo->getLocalBaseName().str(), msg.m_recipientNick.str(), msg.m_message.str()); - Int index = GadgetListBoxAddEntryText( buddyControls.listboxChat, s, GameSpyColor[GSCOLOR_PLAYER_SELF], -1, -1 ); - GadgetListBoxAddEntryText( buddyControls.listboxChat, timeStr, GameSpyColor[GSCOLOR_PLAYER_SELF], index, 1); - } - else if (!localSender /*&& senderIt != m->end()*/) - { - if (!msg.m_senderID) - { - s = msg.m_message; - Int index = GadgetListBoxAddEntryText( buddyControls.listboxChat, s, GameSpyColor[GSCOLOR_DEFAULT], -1, -1 ); - GadgetListBoxAddEntryText( buddyControls.listboxChat, timeStr, GameSpyColor[GSCOLOR_DEFAULT], index, 1); - } - else - { - s.format(L"[%hs] %s", msg.m_senderNick.str(), msg.m_message.str()); - Int index = GadgetListBoxAddEntryText( buddyControls.listboxChat, s, GameSpyColor[GSCOLOR_PLAYER_BUDDY], -1, -1 ); - GadgetListBoxAddEntryText( buddyControls.listboxChat, timeStr, GameSpyColor[GSCOLOR_PLAYER_BUDDY], index, 1); - } - } - } -} - -void updateBuddyInfo( void ) -{ - if (!TheGameSpyBuddyMessageQueue->isConnected()) - { - GadgetListBoxReset(buddyControls.listboxBuddies); - return; - } - - if (!buddyControls.isInit) - return; - - int selected; - GPProfile selectedProfile = 0; - int visiblePos = GadgetListBoxGetTopVisibleEntry(buddyControls.listboxBuddies); - - GadgetListBoxGetSelected(buddyControls.listboxBuddies, &selected); - if (selected >= 0) - selectedProfile = (GPProfile)GadgetListBoxGetItemData(buddyControls.listboxBuddies, selected); - - selected = -1; - GadgetListBoxReset(buddyControls.listboxBuddies); - - // Add buddies - BuddyInfoMap *buddies = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator bIt; - for (bIt = buddies->begin(); bIt != buddies->end(); ++bIt) - { - BuddyInfo info = bIt->second; - GPProfile profileID = bIt->first; - - // insert name into box - UnicodeString formatStr; - formatStr.translate(info.m_name.str());//, info.m_status, info.m_statusString.str(), info.m_locationString.str()); - Color nameColor = (TheGameSpyInfo->isSavedIgnored(profileID)) ? - GameSpyColor[GSCOLOR_PLAYER_IGNORED] : GameSpyColor[GSCOLOR_PLAYER_BUDDY]; - int index = GadgetListBoxAddEntryText(buddyControls.listboxBuddies, formatStr, nameColor, -1, -1); - - // insert status into box - AsciiString marker; - marker.format("Buddy:%ls", info.m_statusString.str()); - if (!info.m_statusString.compareNoCase(L"Offline") || - !info.m_statusString.compareNoCase(L"Online") || - !info.m_statusString.compareNoCase(L"Matching")) - { - formatStr = TheGameText->fetch(marker); - } - else if (!info.m_statusString.compareNoCase(L"Staging") || - !info.m_statusString.compareNoCase(L"Loading") || - !info.m_statusString.compareNoCase(L"Playing")) - { - formatStr.format(TheGameText->fetch(marker), info.m_locationString.str()); - } - else if (!info.m_statusString.compareNoCase(L"Chatting")) - { - UnicodeString roomName; - GroupRoomMap::iterator gIt = TheGameSpyInfo->getGroupRoomList()->find( _wtoi(info.m_locationString.str()) ); - if (gIt != TheGameSpyInfo->getGroupRoomList()->end()) - { - AsciiString s; - s.format("GUI:%s", gIt->second.m_name.str()); - roomName = TheGameText->fetch(s); - } - formatStr.format(TheGameText->fetch(marker), roomName.str()); - } - else - { - formatStr = info.m_statusString; - } - GadgetListBoxAddEntryText(buddyControls.listboxBuddies, formatStr, GameSpyColor[GSCOLOR_DEFAULT], index, 1); - GadgetListBoxSetItemData(buddyControls.listboxBuddies, (void *)(profileID), index, 0 ); - GadgetListBoxSetItemData(buddyControls.listboxBuddies, (void *)(ITEM_BUDDY), index, 1 ); - - if (profileID == selectedProfile) - selected = index; - } - - // add requests - buddies = TheGameSpyInfo->getBuddyRequestMap(); - for (bIt = buddies->begin(); bIt != buddies->end(); ++bIt) - { - BuddyInfo info = bIt->second; - GPProfile profileID = bIt->first; - - // insert name into box - UnicodeString formatStr; - formatStr.translate(info.m_name.str()); - int index = GadgetListBoxAddEntryText(buddyControls.listboxBuddies, formatStr, GameSpyColor[GSCOLOR_DEFAULT], -1, -1); - GadgetListBoxSetItemData(buddyControls.listboxBuddies, (void *)(profileID), index, 0 ); - - // insert status into box - formatStr = TheGameText->fetch("GUI:BuddyAddReq"); - GadgetListBoxAddEntryText(buddyControls.listboxBuddies, formatStr, GameSpyColor[GSCOLOR_DEFAULT], index, 1); - GadgetListBoxSetItemData(buddyControls.listboxBuddies, (void *)(ITEM_REQUEST), index, 1 ); - - if (profileID == selectedProfile) - selected = index; - } - - - // select the same guy - if (selected >= 0) - { - GadgetListBoxSetSelected(buddyControls.listboxBuddies, selected); - } - - // view the same spot - GadgetListBoxSetTopVisibleEntry(buddyControls.listboxBuddies, visiblePos); -} - -void HandleBuddyResponses( void ) -{ - if (TheGameSpyBuddyMessageQueue) - { - BuddyResponse resp; - if (TheGameSpyBuddyMessageQueue->getResponse( resp )) - { - switch (resp.buddyResponseType) - { - case BuddyResponse::BUDDYRESPONSE_LOGIN: - { - deleteNotificationBox(); - } - break; - case BuddyResponse::BUDDYRESPONSE_DISCONNECT: - { - lastNotificationWasStatus = FALSE; - numOnlineInNotification = 0; - showNotificationBox(AsciiString::TheEmptyString, TheGameText->fetch("Buddy:MessageDisconnected")); - } - break; - case BuddyResponse::BUDDYRESPONSE_MESSAGE: - { - if ( !wcscmp(resp.arg.message.text, L"I have authorized your request to add me to your list") ) - break; - - if (TheGameSpyInfo->isSavedIgnored(resp.profile)) - { - //DEBUG_CRASH(("Player is ignored!\n")); - break; // no buddy messages from ignored people - } - - // save message for future incarnations of the buddy window - BuddyMessageList *messages = TheGameSpyInfo->getBuddyMessages(); - BuddyMessage message; - message.m_timestamp = resp.arg.message.date; - message.m_senderID = resp.profile; - message.m_recipientID = TheGameSpyInfo->getLocalProfileID(); - message.m_recipientNick = TheGameSpyInfo->getLocalBaseName(); - message.m_message = resp.arg.message.text; - // insert status into box - BuddyInfoMap *m = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator senderIt = m->find(message.m_senderID); - AsciiString nick; - if (senderIt != m->end()) - nick = senderIt->second.m_name.str(); - else - nick = resp.arg.message.nick; - message.m_senderNick = nick; - messages->push_back(message); - - DEBUG_LOG(("Inserting buddy chat from '%s'/'%s'\n", nick.str(), resp.arg.message.nick)); - - // put message on screen - insertChat(message); - - // play audio notification - AudioEventRTS buddyMsgAudio("GUIMessageReceived"); - if( TheAudio ) - { - TheAudio->addAudioEvent( &buddyMsgAudio ); - } // end if - - UnicodeString snippet = message.m_message; - while (snippet.getLength() > 11) - { - snippet.removeLastChar(); - } - UnicodeString s; - s.format(TheGameText->fetch("Buddy:MessageNotification"), nick.str(), snippet.str()); - lastNotificationWasStatus = FALSE; - numOnlineInNotification = 0; - showNotificationBox(AsciiString::TheEmptyString, s); - } - break; - case BuddyResponse::BUDDYRESPONSE_REQUEST: - { - // save request for future incarnations of the buddy window - BuddyInfoMap *m = TheGameSpyInfo->getBuddyRequestMap(); - BuddyInfo info; - info.m_countryCode = resp.arg.request.countrycode; - info.m_email = resp.arg.request.email; - info.m_name = resp.arg.request.nick; - info.m_id = resp.profile; - info.m_status = (GPEnum)0; - info.m_statusString = resp.arg.request.text; - (*m)[resp.profile] = info; - - // TODO: put request on screen - updateBuddyInfo(); - // insert status into box - lastNotificationWasStatus = FALSE; - numOnlineInNotification = 0; - showNotificationBox(info.m_name, TheGameText->fetch("Buddy:AddNotification")); - } - break; - case BuddyResponse::BUDDYRESPONSE_STATUS: - { - BuddyInfoMap *m = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::const_iterator bit = m->find(resp.profile); - Bool seenPreviously = FALSE; - GPEnum oldStatus = GP_OFFLINE; - GPEnum newStatus = resp.arg.status.status; - if (bit != m->end()) - { - seenPreviously = TRUE; - oldStatus = (*m)[resp.profile].m_status; - } - BuddyInfo info; - info.m_countryCode = resp.arg.status.countrycode; - info.m_email = resp.arg.status.email; - info.m_name = resp.arg.status.nick; - info.m_id = resp.profile; - info.m_status = newStatus; - info.m_statusString = UnicodeString(MultiByteToWideCharSingleLine(resp.arg.status.statusString).c_str()); - info.m_locationString = UnicodeString(MultiByteToWideCharSingleLine(resp.arg.status.location).c_str()); - (*m)[resp.profile] = info; - - updateBuddyInfo(); - PopulateLobbyPlayerListbox(); - RefreshGameListBoxes(); - if ( (newStatus == GP_OFFLINE && seenPreviously) || - (newStatus == GP_ONLINE && (oldStatus == GP_OFFLINE || !seenPreviously)) ) - //if (!info.m_statusString.compareNoCase(L"Offline") || - //!info.m_statusString.compareNoCase(L"Online")) - { - // insert status into box - AsciiString marker; - marker.format("Buddy:%lsNotification", info.m_statusString.str()); - - lastNotificationWasStatus = TRUE; - if (newStatus != GP_OFFLINE) - ++numOnlineInNotification; - - showNotificationBox(info.m_name, TheGameText->fetch(marker)); - } - else if( newStatus == GP_RECV_GAME_INVITE && !seenPreviously) - { - lastNotificationWasStatus = TRUE; - if (newStatus != GP_OFFLINE) - ++numOnlineInNotification; - - showNotificationBox(info.m_name, TheGameText->fetch("Buddy:OnlineNotification")); - } - } - break; - } - } - } - else - { - DEBUG_CRASH(("No buddy message queue!\n")); - } - if(noticeLayout && timeGetTime() > noticeExpires) - { - deleteNotificationBox(); - } -} - -void showNotificationBox( AsciiString nick, UnicodeString message) -{ -// if(!GameSpyIsOverlayOpen(GSOVERLAY_BUDDY)) -// return; - if( !noticeLayout ) - noticeLayout = TheWindowManager->winCreateLayout( "Menus/PopupBuddyListNotification.wnd" ); - noticeLayout->hide( FALSE ); - if (buttonNotificationID == NAMEKEY_INVALID) - { - buttonNotificationID = TheNameKeyGenerator->nameToKey("PopupBuddyListNotification.wnd:ButtonNotification"); - } - GameWindow *win = TheWindowManager->winGetWindowFromId(NULL,buttonNotificationID); - if(!win) - { - deleteNotificationBox(); - return; - } - - if (lastNotificationWasStatus && numOnlineInNotification > 1) - { - message = TheGameText->fetch("Buddy:MultipleOnlineNotification"); - } - - if (nick.isNotEmpty()) - message.format(message, nick.str()); - GadgetButtonSetText(win, message); - //GadgetStaticTextSetText(win, message); - noticeExpires = timeGetTime() + NOTIFICATION_EXPIRES; - noticeLayout->bringForward(); - - AudioEventRTS buttonClick("GUICommunicatorIncoming"); - - if( TheAudio ) - { - TheAudio->addAudioEvent( &buttonClick ); - } // end if - -} - -void deleteNotificationBox( void ) -{ - lastNotificationWasStatus = FALSE; - numOnlineInNotification = 0; - if(noticeLayout) - { - noticeLayout->destroyWindows(); - noticeLayout->deleteInstance(); - noticeLayout = NULL; - } -} - -void PopulateOldBuddyMessages(void) -{ - // show previous messages - BuddyMessageList *messages = TheGameSpyInfo->getBuddyMessages(); - for (BuddyMessageList::iterator mIt = messages->begin(); mIt != messages->end(); ++mIt) - { - BuddyMessage message = *mIt; - insertChat(message); - } -} - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Buddy Overlay */ -//------------------------------------------------------------------------------------------------- -void WOLBuddyOverlayInit( WindowLayout *layout, void *userData ) -{ - parentID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:BuddyMenuParent" ) ); - buttonHideID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ButtonHide" ) ); - buttonAddBuddyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ButtonAdd" ) ); - buttonDeleteBuddyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ButtonDelete" ) ); - //textEntryID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:TextEntryChat" ) ); - //listboxBuddyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ListboxBuddies" ) ); - //listboxChatID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ListboxBuddyChat" ) ); - buttonAcceptBuddyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ButtonYes" ) ); - buttonDenyBuddyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ButtonNo" ) ); - radioButtonBuddiesID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:RadioButtonBuddies" ) ); - radioButtonIgnoreID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:RadioButtonIgnore" ) ); - parentBuddiesID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:BuddiesParent" ) ); - parentIgnoreID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:IgnoreParent" ) ); - listboxIgnoreID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ListboxIgnore" ) ); - - - parent = TheWindowManager->winGetWindowFromId( NULL, parentID ); - buttonHide = TheWindowManager->winGetWindowFromId( parent, buttonHideID); - buttonAddBuddy = TheWindowManager->winGetWindowFromId( parent, buttonAddBuddyID); - buttonDeleteBuddy = TheWindowManager->winGetWindowFromId( parent, buttonDeleteBuddyID); - // textEntry = TheWindowManager->winGetWindowFromId( parent, textEntryID); - //listboxBuddy = TheWindowManager->winGetWindowFromId( parent, listboxBuddyID); - //listboxChat = TheWindowManager->winGetWindowFromId( parent, listboxChatID); - buttonAcceptBuddy = TheWindowManager->winGetWindowFromId( parent, buttonAcceptBuddyID); - buttonDenyBuddy = TheWindowManager->winGetWindowFromId( parent, buttonDenyBuddyID); - radioButtonBuddies = TheWindowManager->winGetWindowFromId( parent, radioButtonBuddiesID); - radioButtonIgnore = TheWindowManager->winGetWindowFromId( parent, radioButtonIgnoreID); - parentBuddies = TheWindowManager->winGetWindowFromId( parent, parentBuddiesID); - parentIgnore = TheWindowManager->winGetWindowFromId( parent, parentIgnoreID); - listboxIgnore = TheWindowManager->winGetWindowFromId( parent, listboxIgnoreID); - - InitBuddyControls(BUDDY_WINDOW_BUDDIES); - - GadgetRadioSetSelection(radioButtonBuddies,FALSE); - parentBuddies->winHide(FALSE); - parentIgnore->winHide(TRUE); - - //GadgetTextEntrySetText(textEntry, UnicodeString.TheEmptyString); - - PopulateOldBuddyMessages(); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parent ); - - isOverlayActive = true; - updateBuddyInfo(); - -} // WOLBuddyOverlayInit - -//------------------------------------------------------------------------------------------------- -/** WOL Buddy Overlay shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLBuddyOverlayShutdown( WindowLayout *layout, void *userData ) -{ - listboxIgnore = NULL; - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - //TheShell->shutdownComplete( layout ); - - isOverlayActive = false; - - InitBuddyControls(BUDDY_RESETALL_CRAP); - -} // WOLBuddyOverlayShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Buddy Overlay update method */ -//------------------------------------------------------------------------------------------------- -void WOLBuddyOverlayUpdate( WindowLayout * layout, void *userData) -{ - if (!TheGameSpyBuddyMessageQueue || !TheGameSpyBuddyMessageQueue->isConnected()) - GameSpyCloseOverlay(GSOVERLAY_BUDDY); -}// WOLBuddyOverlayUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Buddy Overlay input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLBuddyOverlayInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonHide, buttonHideID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLBuddyOverlayInput - -//------------------------------------------------------------------------------------------------- -/** WOL Buddy Overlay window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLBuddyOverlaySystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - if(BuddyControlSystem(window, msg, mData1, mData2) == MSG_HANDLED) - { - return MSG_HANDLED; - } - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - case GLM_RIGHT_CLICKED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if( controlID == listboxIgnoreID ) - { - RightClickStruct *rc = (RightClickStruct *)mData2; - WindowLayout *rcLayout; - if(rc->pos < 0) - break; - - Bool isBuddy = false, isRequest = false; - GPProfile profileID = (GPProfile)GadgetListBoxGetItemData(control, rc->pos); - UnicodeString nick = GadgetListBoxGetText(control, rc->pos); - BuddyInfoMap *buddies = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator bIt; - bIt = buddies->find(profileID); - if (bIt != buddies->end()) - { - isBuddy = true; - } - else - { - buddies = TheGameSpyInfo->getBuddyRequestMap(); - bIt = buddies->find(profileID); - if (bIt != buddies->end()) - { - isRequest = true; - } - else - { - // neither buddy nor request - //break; - } - } - - GadgetListBoxSetSelected(control, rc->pos); - if (isBuddy) - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCBuddiesMenu.wnd")); - else if (isRequest) - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCBuddyRequestMenu.wnd")); - else - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCNonBuddiesMenu.wnd")); - rcMenu = rcLayout->getFirstWindow(); - rcMenu->winGetLayout()->runInit(); - rcMenu->winBringToTop(); - rcMenu->winHide(FALSE); - - - - rcMenu->winSetPosition(rc->mouseX, rc->mouseY); - GameSpyRCMenuData *rcData = NEW GameSpyRCMenuData; - rcData->m_id = profileID; - rcData->m_nick.translate(nick); - rcData->m_itemType = (isBuddy)?ITEM_BUDDY:((isRequest)?ITEM_REQUEST:ITEM_NONBUDDY); - setUnignoreText(rcLayout, rcData->m_nick, rcData->m_id); - rcMenu->winSetUserData((void *)rcData); - TheWindowManager->winSetLoneWindow(rcMenu); - } - break; - } - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if (controlID == buttonHideID) - { - GameSpyCloseOverlay( GSOVERLAY_BUDDY ); - } - else if (controlID == radioButtonBuddiesID) - { - parentBuddies->winHide(FALSE); - parentIgnore->winHide(TRUE); - } - else if (controlID == radioButtonIgnoreID) - { - parentBuddies->winHide(TRUE); - parentIgnore->winHide(FALSE); - refreshIgnoreList(); - } - else if (controlID == buttonAddBuddyID) - { - /* - UnicodeString uName = GadgetTextEntryGetText(textEntry); - AsciiString aName; - aName.translate(uName); - if (!aName.isEmpty()) - { - TheWOLBuddyList->requestBuddyAdd(aName); - } - GadgetTextEntrySetText(textEntry, UnicodeString::TheEmptyString); - */ - } - else if (controlID == buttonDeleteBuddyID) - { - /* - int selected; - AsciiString selectedName = AsciiString::TheEmptyString; - - GadgetListBoxGetSelected(listbox, &selected); - if (selected >= 0) - selectedName = TheNameKeyGenerator->keyToName((NameKeyType)(int)GadgetListBoxGetItemData(listbox, selected)); - - if (!selectedName.isEmpty()) - { - TheWOLBuddyList->requestBuddyDelete(selectedName); - } - */ - } - break; - }// case GBM_SELECTED: - case GLM_DOUBLE_CLICKED: - { - /* - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if( controlID == listboxBuddyID ) - { - int rowSelected = mData2; - - if (rowSelected >= 0) - { - UnicodeString buddyName; - GameWindow *listboxWindow = TheWindowManager->winGetWindowFromId( parent, listboxBuddyID ); - - // get text of buddy name - buddyName = GadgetListBoxGetText( listboxWindow, rowSelected,0 ); - GPProfile buddyID = (GPProfile)GadgetListBoxGetItemData( listboxWindow, rowSelected, 0 ); - - Int index = -1; - gpGetBuddyIndex(TheGPConnection, buddyID, &index); - if (index >= 0) - { - GPBuddyStatus status; - gpGetBuddyStatus(TheGPConnection, rowSelected, &status); - - UnicodeString string; - string.format(L"To join %s in %hs:", buddyName.str(), status.locationString); - GameSpyAddText(string, GSCOLOR_DEFAULT); - - if (status.status == GP_CHATTING) - { - AsciiString location = status.locationString; - AsciiString val; - location.nextToken(&val, "/"); - location.nextToken(&val, "/"); - location.nextToken(&val, "/"); - - string.format(L" ???"); - if (!val.isEmpty()) - { - Int groupRoom = atoi(val.str()); - if (TheGameSpyChat->getCurrentGroupRoomID() == groupRoom) - { - // already there - string.format(L" nothing"); - GameSpyAddText(string, GSCOLOR_DEFAULT); - } - else - { - GroupRoomMap *rooms = TheGameSpyChat->getGroupRooms(); - if (rooms) - { - Bool needToJoin = true; - GroupRoomMap::iterator it = rooms->find(groupRoom); - if (it != rooms->end()) - { - // he's in a different room - if (TheGameSpyChat->getCurrentGroupRoomID()) - { - string.format(L" leave group room"); - GameSpyAddText(string, GSCOLOR_DEFAULT); - - TheGameSpyChat->leaveRoom(GroupRoom); - } - else if (TheGameSpyGame->isInGame()) - { - if (TheGameSpyGame->isGameInProgress()) - { - string.format(L" can't leave game in progress"); - GameSpyAddText(string, GSCOLOR_DEFAULT); - needToJoin = false; - } - else - { - string.format(L" leave game setup"); - GameSpyAddText(string, GSCOLOR_DEFAULT); - - TheGameSpyChat->leaveRoom(StagingRoom); - TheGameSpyGame->leaveGame(); - } - } - if (needToJoin) - { - string.format(L" join lobby %d", groupRoom); - TheGameSpyChat->joinGroupRoom(groupRoom); - GameSpyAddText(string, GSCOLOR_DEFAULT); - } - } - } - } - } - } - } - else - { - DEBUG_CRASH(("No buddy associated with that ProfileID")); - GameSpyUpdateBuddyOverlay(); - } - } - } - */ - break; - } - - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLBuddyOverlaySystem - -WindowMsgHandledType PopupBuddyNotificationSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - case GWM_CREATE: - { - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if (controlID == buttonNotificationID) - { - GameSpyOpenOverlay( GSOVERLAY_BUDDY ); - } - break; - } - - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// PopupBuddyNotificationSystem - -/* -static NameKeyType buttonAcceptBuddyID = NAMEKEY_INVALID; -static NameKeyType buttonDenyBuddyID = NAMEKEY_INVALID; -*/ -static NameKeyType buttonAddID = NAMEKEY_INVALID; -static NameKeyType buttonDeleteID = NAMEKEY_INVALID; -static NameKeyType buttonPlayID = NAMEKEY_INVALID; -static NameKeyType buttonIgnoreID = NAMEKEY_INVALID; -static NameKeyType buttonStatsID = NAMEKEY_INVALID; -// Window Pointers ------------------------------------------------------------------------ -//static GameWindow *rCparent = NULL; - - -//------------------------------------------------------------------------------------------------- -/** WOL Buddy Overlay Right Click menu callbacks */ -//------------------------------------------------------------------------------------------------- -void WOLBuddyOverlayRCMenuInit( WindowLayout *layout, void *userData ) -{ - AsciiString controlName; - controlName.format("%s:ButtonAdd",layout->getFilename().str()+6); - buttonAddID = TheNameKeyGenerator->nameToKey( controlName ); - controlName.format("%s:ButtonDelete",layout->getFilename().str()+6); - buttonDeleteID = TheNameKeyGenerator->nameToKey( controlName ); - controlName.format("%s:ButtonPlay",layout->getFilename().str()+6); - buttonPlayID = TheNameKeyGenerator->nameToKey( controlName ); - controlName.format("%s:ButtonIgnore",layout->getFilename().str()+6); - buttonIgnoreID = TheNameKeyGenerator->nameToKey( controlName ); - controlName.format("%s:ButtonStats",layout->getFilename().str()+6); - buttonStatsID = TheNameKeyGenerator->nameToKey( controlName ); -} -static void closeRightClickMenu(GameWindow *win) -{ - - if(win) - { - WindowLayout *winLay = win->winGetLayout(); - if(!winLay) - return; - winLay->destroyWindows(); - winLay->deleteInstance(); - winLay = NULL; - - } -} - -void RequestBuddyAdd(Int profileID, AsciiString nick) -{ - // request to add a buddy - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_ADDBUDDY; - req.arg.addbuddy.id = profileID; - UnicodeString buddyAddstr; - buddyAddstr = TheGameText->fetch("GUI:BuddyAddReq"); - wcsncpy(req.arg.addbuddy.text, buddyAddstr.str(), MAX_BUDDY_CHAT_LEN); - req.arg.addbuddy.text[MAX_BUDDY_CHAT_LEN-1] = 0; - TheGameSpyBuddyMessageQueue->addRequest(req); - - UnicodeString s; - Bool exists = TRUE; - s.format(TheGameText->fetch("Buddy:InviteSent", &exists)); - if (!exists) - { - // no string yet. don't display. - return; - } - - // save message for future incarnations of the buddy window - BuddyMessageList *messages = TheGameSpyInfo->getBuddyMessages(); - BuddyMessage message; - message.m_timestamp = time(NULL); - message.m_senderID = 0; - message.m_senderNick = ""; - message.m_recipientID = TheGameSpyInfo->getLocalProfileID(); - message.m_recipientNick = TheGameSpyInfo->getLocalBaseName(); - message.m_message.format(TheGameText->fetch("Buddy:InviteSentToPlayer"), nick.str()); - - // insert status into box - messages->push_back(message); - - DEBUG_LOG(("Inserting buddy add request\n")); - - // put message on screen - insertChat(message); - - // play audio notification - AudioEventRTS buddyMsgAudio("GUIMessageReceived"); - if( TheAudio ) - { - TheAudio->addAudioEvent( &buddyMsgAudio ); - } // end if - - lastNotificationWasStatus = FALSE; - numOnlineInNotification = 0; - showNotificationBox(AsciiString::TheEmptyString, s); -} - -WindowMsgHandledType WOLBuddyOverlayRCMenuSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 ) -{ - - switch( msg ) - { - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - rcMenu = NULL; - break; - } // case GWM_DESTROY: - - case GGM_CLOSE: - { - closeRightClickMenu(window); - //rcMenu = NULL; - break; - } - - - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - GameSpyRCMenuData *rcData = (GameSpyRCMenuData*)window->winGetUserData(); - if(!rcData) - break; - DEBUG_ASSERTCRASH(rcData, ("WOLBuddyOverlayRCMenuSystem GBM_SELECTED:: we're attempting to read the GameSpyRCMenuData from the window, but the data's not there")); - GPProfile profileID = rcData->m_id; - AsciiString nick = rcData->m_nick; - - Bool isBuddy = false, isRequest = false; - Bool isGameSpyUser = profileID > 0; - if (rcData->m_itemType == ITEM_BUDDY) - isBuddy = TRUE; - else if (rcData->m_itemType == ITEM_REQUEST) - isRequest = TRUE; - - if(rcData) - { - delete rcData; - rcData = NULL; - } - window->winSetUserData(NULL); - //DEBUG_ASSERTCRASH(profileID > 0, ("Bad profile ID in user data!")); - - if( controlID == buttonAddID ) - { - if(!isGameSpyUser) - break; - DEBUG_LOG(("ButtonAdd was pushed\n")); - if (isRequest) - { - // ok the request - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_OKADD; - req.arg.profile.id = profileID; - TheGameSpyBuddyMessageQueue->addRequest(req); - - BuddyInfoMap *m = TheGameSpyInfo->getBuddyRequestMap(); - m->erase( profileID ); - // if the profile ID is not from a buddy and we're okaying his request, then - // request to add him to our list automatically CLH 2-18-03 - if(!TheGameSpyInfo->isBuddy(profileID)) - { - RequestBuddyAdd(profileID, nick); - } - updateBuddyInfo(); - } - else if (!isBuddy) - { - RequestBuddyAdd(profileID, nick); - } - } - else if( controlID == buttonDeleteID ) - { - if(!isGameSpyUser) - break; - if (isBuddy) - { - // delete the buddy - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_DELBUDDY; - req.arg.profile.id = profileID; - TheGameSpyBuddyMessageQueue->addRequest(req); - } - else - { - // delete the request - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_DENYADD; - req.arg.profile.id = profileID; - TheGameSpyBuddyMessageQueue->addRequest(req); - BuddyInfoMap *m = TheGameSpyInfo->getBuddyRequestMap(); - m->erase( profileID ); - } - BuddyInfoMap *buddies = (isBuddy)?TheGameSpyInfo->getBuddyMap():TheGameSpyInfo->getBuddyRequestMap(); - buddies->erase(profileID); - updateBuddyInfo(); - DEBUG_LOG(("ButtonDelete was pushed\n")); - PopulateLobbyPlayerListbox(); - } - else if( controlID == buttonPlayID ) - { - DEBUG_LOG(("buttonPlayID was pushed\n")); - } - else if( controlID == buttonIgnoreID ) - { - DEBUG_LOG(("%s is isGameSpyUser %d", nick.str(), isGameSpyUser)); - if( isGameSpyUser ) - { - if(TheGameSpyInfo->isSavedIgnored(profileID)) - { - TheGameSpyInfo->removeFromSavedIgnoreList(profileID); - } - else - { - TheGameSpyInfo->addToSavedIgnoreList(profileID, nick); - } - } - else - { - if(TheGameSpyInfo->isIgnored(nick)) - { - TheGameSpyInfo->removeFromIgnoreList(nick); - } - else - { - TheGameSpyInfo->addToIgnoreList(nick); - } - } - updateBuddyInfo(); - refreshIgnoreList(); - // repopulate our player listboxes now - PopulateLobbyPlayerListbox(); - } - else if( controlID == buttonStatsID ) - { - DEBUG_LOG(("buttonStatsID was pushed\n")); - GameSpyCloseOverlay(GSOVERLAY_PLAYERINFO); - SetLookAtPlayer(profileID,nick ); - GameSpyOpenOverlay(GSOVERLAY_PLAYERINFO); - PSRequest req; - req.requestType = PSRequest::PSREQUEST_READPLAYERSTATS; - req.player.id = profileID; - TheGameSpyPSMessageQueue->addRequest(req); - } - closeRightClickMenu(window); - break; - } - default: - return MSG_IGNORED; - - }//Switch - return MSG_HANDLED; -} - - -void setUnignoreText( WindowLayout *layout, AsciiString nick, GPProfile id) -{ - AsciiString controlName; - controlName.format("%s:ButtonIgnore",layout->getFilename().str()+6); - NameKeyType ID = TheNameKeyGenerator->nameToKey( controlName ); - GameWindow *win = TheWindowManager->winGetWindowFromId(layout->getFirstWindow(), ID); - if(win) - { - if(TheGameSpyInfo->isSavedIgnored(id) || TheGameSpyInfo->isIgnored(nick)) - GadgetButtonSetText(win, TheGameText->fetch("GUI:Unignore")); - } -} - -void refreshIgnoreList( void ) -{ - - - SavedIgnoreMap tempMap; - tempMap = TheGameSpyInfo->returnSavedIgnoreList(); - SavedIgnoreMap::iterator it = tempMap.begin(); - GadgetListBoxReset(listboxIgnore); - while(it != tempMap.end()) - { - UnicodeString name; - name.translate(it->second); - Int pos = GadgetListBoxAddEntryText(listboxIgnore, name, GameMakeColor(255,100,100,255),-1); - GadgetListBoxSetItemData(listboxIgnore, (void *)it->first,pos ); - ++it; - } - IgnoreList tempList; - tempList = TheGameSpyInfo->returnIgnoreList(); - IgnoreList::iterator iListIt = tempList.begin(); - while( iListIt != tempList.end()) - { - AsciiString aName = *iListIt; - UnicodeString name; - name.translate(aName); - Int pos = GadgetListBoxAddEntryText(listboxIgnore, name, GameMakeColor(255,100,100,255),-1); - GadgetListBoxSetItemData(listboxIgnore, 0,pos ); - ++iListIt; - } - -// -// GPProfile profileID = 0; -// PlayerInfoMap::iterator it = TheGameSpyInfo->getPlayerInfoMap()->find(aName); -// if (it != TheGameSpyInfo->getPlayerInfoMap()->end()) -// profileID = it->second.m_profileID; - -} diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLCustomScoreScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLCustomScoreScreen.cpp deleted file mode 100644 index a045c27f255..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLCustomScoreScreen.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLCustomScoreScreen.cpp -// Author: Matt Campbell, December 2001 -// Description: Custom match score screen -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Lib/BaseType.h" -#include "Common/GameEngine.h" -#include "Common/NameKeyGenerator.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -#include "Common/GlobalData.h" -//#include "GameNetwork/WOL.h" -//#include "GameNetwork/WOLmenus.h" - - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLCustomScoreID = NAMEKEY_INVALID; -static NameKeyType buttonDisconnectID = NAMEKEY_INVALID; -static NameKeyType buttonLobbyID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLCustomScore = NULL; -static GameWindow *buttonDisconnect = NULL; -static GameWindow *buttonLobby = NULL; - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Status Menu */ -//------------------------------------------------------------------------------------------------- -void WOLCustomScoreScreenInit( WindowLayout *layout, void *userData ) -{ - parentWOLCustomScoreID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLCustomScoreScreen.wnd:WOLCustomScoreScreenParent" ) ); - buttonDisconnectID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLCustomScoreScreen.wnd:ButtonDisconnect" ) ); - buttonLobbyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLCustomScoreScreen.wnd:ButtonLobby" ) ); - parentWOLCustomScore = TheWindowManager->winGetWindowFromId( NULL, parentWOLCustomScoreID ); - buttonDisconnect = TheWindowManager->winGetWindowFromId( NULL, buttonDisconnectID); - buttonLobby = TheWindowManager->winGetWindowFromId( NULL, buttonLobbyID); - - /* - if (WOL::TheWOL->getState() == WOL::WOLAPI_FATAL_ERROR) - { - // We can get to the score screen even though we've been disconnected. Just hide - // any buttons that lead back into WOL. - buttonLobby->winHide( TRUE ); - } - */ - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLCustomScore ); -} // WOLCustomScoreScreenInit - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLCustomScoreScreenShutdown( WindowLayout *layout, void *userData ) -{ - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); -} // WOLCustomScoreScreenShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLCustomScoreScreenUpdate( WindowLayout * layout, void *userData) -{ - /* - if (WOL::TheWOL) - WOL::TheWOL->update(); - */ -}// WOLCustomScoreScreenUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLCustomScoreScreenInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonDisconnect, buttonDisconnectID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLCustomScoreScreenInput - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLCustomScoreScreenSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're given the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - /* - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == buttonDisconnectID ) - { - if (WOL::TheWOL->setState( WOL::WOLAPI_FATAL_ERROR )) - { - WOL::TheWOL->addCommand( WOL::WOLCOMMAND_RESET ); // don't display an error, log out, or anything - } - - } //if ( controlID == buttonDisconnect ) - else if ( controlID == buttonLobbyID ) - { - if (WOL::TheWOL->getState() != WOL::WOLAPI_FATAL_ERROR) - { - WOL::TheWOL->setScreen(WOL::WOLAPI_MENU_CUSTOMLOBBY); - WOL::TheWOL->setGameMode(WOL::WOLTYPE_CUSTOM); - WOL::TheWOL->setState( WOL::WOLAPI_LOBBY ); - WOL::TheWOL->addCommand( WOL::WOLCOMMAND_REFRESH_CHANNELS ); - } - else - { - } - } //if ( controlID == buttonDisconnect ) - */ - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLCustomScoreScreenSystem diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp deleted file mode 100644 index 43d42d7e109..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp +++ /dev/null @@ -1,2887 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLGameSetupMenu.cpp -// Author: Matt Campbell, December 2001 -// Description: WOL Game Options Menu -/////////////////////////////////////////////////////////////////////////////////////// - -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "Common/GameState.h" -#include "GameClient/GameText.h" -#include "Common/MultiplayerSettings.h" -#include "Common/PlayerTemplate.h" -#include "Common/CustomMatchPreferences.h" -#include "GameClient/AnimateWindowManager.h" -#include "GameClient/InGameUI.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Mouse.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetComboBox.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GadgetPushButton.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/GadgetCheckBox.h" -#include "GameClient/MapUtil.h" -#include "GameClient/EstablishConnectionsMenu.h" -#include "GameClient/GameWindowTransitions.h" -#include "GameNetwork/GameSpy/LobbyUtils.h" - -#include "GameNetwork/GameSpy/BuddyDefs.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameNetwork/NAT.h" -#include "GameNetwork/GUIUtil.h" -#include "GameNetwork/GameSpy/GSConfig.h" - -void WOLDisplaySlotList( void ); - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -extern std::list TheLobbyQueuedUTMs; -extern void MapSelectorTooltip(GameWindow *window, WinInstanceData *instData, UnsignedInt mouse); - - -#if defined(_DEBUG) || defined(_INTERNAL) -extern Bool g_debugSlots; -void slotListDebugLog(const char *fmt, ...) -{ - static char buf[1024]; - va_list va; - va_start( va, fmt ); - _vsnprintf(buf, 1024, fmt, va ); - va_end( va ); - buf[1023] = 0; - - DEBUG_LOG(("%s", buf)); - if (g_debugSlots) - { - UnicodeString msg; - msg.translate(buf); - TheGameSpyInfo->addText(msg, GameSpyColor[GSCOLOR_DEFAULT], NULL); - } -} -#define SLOTLIST_DEBUG_LOG(x) slotListDebugLog x -#else -#define SLOTLIST_DEBUG_LOG(x) DEBUG_LOG(x) -#endif - -void SendStatsToOtherPlayers(const GameInfo *game) -{ - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "STATS/"; - AsciiString fullStr; - PSPlayerStats fullStats = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID()); - PSPlayerStats subStats; - subStats.id = fullStats.id; - subStats.wins = fullStats.wins; - subStats.losses = fullStats.losses; - subStats.discons = fullStats.discons; - subStats.desyncs = fullStats.desyncs; - subStats.games = fullStats.games; - subStats.locale = fullStats.locale; - subStats.gamesAsRandom = fullStats.gamesAsRandom; - GetAdditionalDisconnectsFromUserFile(&subStats); - fullStr.format("%d %s", TheGameSpyInfo->getLocalProfileID(), TheGameSpyPSMessageQueue->formatPlayerKVPairs( subStats )); - req.options = fullStr.str(); - - Int localIndex = game->getLocalSlotNum(); - for (Int i=0; igetConstSlot(i); - if (slot->isHuman() && i != localIndex) - { - AsciiString hostName; - hostName.translate(slot->getName()); - req.nick = hostName.str(); - DEBUG_LOG(("SendStatsToOtherPlayers() - sending to '%s', data of\n\t'%s'\n", hostName.str(), req.options.c_str())); - TheGameSpyPeerMessageQueue->addRequest(req); - } - } -} - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -static Bool isShuttingDown = false; -static Bool buttonPushed = false; -static char *nextScreen = NULL; -static Bool raiseMessageBoxes = false; -static Bool launchGameNext = FALSE; - -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLGameSetupID = NAMEKEY_INVALID; - -static NameKeyType comboBoxPlayerID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType staticTextPlayerID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType buttonAcceptID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType comboBoxColorID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType comboBoxPlayerTemplateID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType comboBoxTeamID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; -//static NameKeyType buttonStartPositionID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, -// NAMEKEY_INVALID,NAMEKEY_INVALID, -// NAMEKEY_INVALID,NAMEKEY_INVALID, -// NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType buttonMapStartPositionID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; -static NameKeyType genericPingWindowID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static NameKeyType textEntryChatID = NAMEKEY_INVALID; -static NameKeyType textEntryMapDisplayID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; -static NameKeyType buttonStartID = NAMEKEY_INVALID; -static NameKeyType buttonEmoteID = NAMEKEY_INVALID; -static NameKeyType buttonSelectMapID = NAMEKEY_INVALID; -static NameKeyType windowMapID = NAMEKEY_INVALID; - -static NameKeyType windowMapSelectMapID = NAMEKEY_INVALID; -static NameKeyType checkBoxUseStatsID = NAMEKEY_INVALID; -static NameKeyType checkBoxLimitSuperweaponsID = NAMEKEY_INVALID; -static NameKeyType comboBoxStartingCashID = NAMEKEY_INVALID; -static NameKeyType checkBoxLimitArmiesID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLGameSetup = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *buttonStart = NULL; -static GameWindow *buttonSelectMap = NULL; -static GameWindow *buttonEmote = NULL; -static GameWindow *textEntryChat = NULL; -static GameWindow *textEntryMapDisplay = NULL; -static GameWindow *windowMap = NULL; -static GameWindow *checkBoxUseStats = NULL; -static GameWindow *checkBoxLimitSuperweapons = NULL; -static GameWindow *comboBoxStartingCash = NULL; -static GameWindow *checkBoxLimitArmies = NULL; - -static GameWindow *comboBoxPlayer[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; -static GameWindow *staticTextPlayer[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; -static GameWindow *buttonAccept[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -static GameWindow *comboBoxColor[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -static GameWindow *comboBoxPlayerTemplate[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -static GameWindow *comboBoxTeam[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -//static GameWindow *buttonStartPosition[MAX_SLOTS] = {NULL,NULL,NULL,NULL, -// NULL,NULL,NULL,NULL }; -// -static GameWindow *buttonMapStartPosition[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -static GameWindow *genericPingWindow[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; - -static const Image *pingImages[3] = { NULL, NULL, NULL }; - -WindowLayout *WOLMapSelectLayout = NULL; - -void PopBackToLobby( void ) -{ - // delete TheNAT, its no good for us anymore. - delete TheNAT; - TheNAT = NULL; - - if (TheGameSpyInfo) // this can be blown away by a disconnect on the map transfer screen - { - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - } - - DEBUG_LOG(("PopBackToLobby() - parentWOLGameSetup is %X\n", parentWOLGameSetup)); - if (parentWOLGameSetup) - { - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - } -} - -void updateMapStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[], Bool onLoadScreen = FALSE ); -void positionStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[], GameWindow *mapWindow); -void positionStartSpots(AsciiString mapName, GameWindow *buttonMapStartPositions[], GameWindow *mapWindow); -void WOLPositionStartSpots( void ) -{ - GameWindow *win = windowMap; - if (WOLMapSelectLayout != NULL) { - win = TheWindowManager->winGetWindowFromId(NULL, windowMapSelectMapID); - - // get the controls. - NameKeyType listboxMapID = TheNameKeyGenerator->nameToKey( AsciiString("WOLMapSelectMenu.wnd:ListboxMap") ); - GameWindow *listboxMap = TheWindowManager->winGetWindowFromId( NULL, listboxMapID ); - - if (listboxMap != NULL) { - Int selected; - UnicodeString map; - - // get the selected index - GadgetListBoxGetSelected( listboxMap, &selected ); - - if( selected != -1 ) - { - - // get text of the map to load - map = GadgetListBoxGetText( listboxMap, selected, 0 ); - - - // set the map name in the global data map name - AsciiString asciiMap; - const char *mapFname = (const char *)GadgetListBoxGetItemData( listboxMap, selected ); - DEBUG_ASSERTCRASH(mapFname, ("No map item data")); - if (mapFname) { - asciiMap = mapFname; - } else { - asciiMap.translate( map ); - } - - positionStartSpots(asciiMap, buttonMapStartPosition, win); - } - } - - } else { - DEBUG_ASSERTCRASH(win != NULL, ("no map preview window")); - positionStartSpots( TheGameSpyInfo->getCurrentStagingRoom(), buttonMapStartPosition, win); - } -} -static void savePlayerInfo( void ) -{ - if (TheGameSpyGame) - { - Int slotNum = TheGameSpyGame->getLocalSlotNum(); - if (slotNum >= 0) - { - GameSpyGameSlot *slot = TheGameSpyGame->getGameSpySlot(slotNum); - if (slot) - { - // save off some prefs - CustomMatchPreferences pref; - pref.setPreferredColor(slot->getColor()); - pref.setPreferredFaction(slot->getPlayerTemplate()); - if (TheGameSpyGame->amIHost()) - { - pref.setPreferredMap(TheGameSpyGame->getMap()); - pref.setSuperweaponRestricted( TheGameSpyGame->getSuperweaponRestriction() != 0 ); - pref.setStartingCash( TheGameSpyGame->getStartingCash() ); - } - pref.write(); - } - } - } -} - -// Tooltips ------------------------------------------------------------------------------- - -static void playerTooltip(GameWindow *window, - WinInstanceData *instData, - UnsignedInt mouse) -{ - Int slotIdx = -1; - for (Int i=0; isetCursorTooltip( UnicodeString::TheEmptyString, -1, NULL, 1.5f ); - return; - } - - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (!game) - { - TheMouse->setCursorTooltip( UnicodeString::TheEmptyString, -1, NULL, 1.5f ); - return; - } - - GameSpyGameSlot *slot = game->getGameSpySlot(slotIdx); - if (!slot || !slot->isHuman()) - { - TheMouse->setCursorTooltip( UnicodeString::TheEmptyString, -1, NULL, 1.5f ); - return; - } - - // for tooltip, we want: - // * player name - // * ping - // * locale - // * win/loss history - // * discons/desyncs as one var - // * favorite army - // in that order. got it? good. - - UnicodeString uName = slot->getName(); - - AsciiString aName; - aName.translate(uName); - PlayerInfoMap::iterator pmIt = TheGameSpyInfo->getPlayerInfoMap()->find(aName); - if (pmIt == TheGameSpyInfo->getPlayerInfoMap()->end()) - { - TheMouse->setCursorTooltip( uName, -1, NULL, 1.5f ); - return; - } - Int profileID = pmIt->second.m_profileID; - - PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(profileID); - if (stats.id == 0) - { - TheMouse->setCursorTooltip( uName, -1, NULL, 1.5f ); - return; - } - - Bool isLocalPlayer = slot == game->getGameSpySlot(game->getLocalSlotNum()); - - AsciiString localeIdentifier; - localeIdentifier.format("WOL:Locale%2.2d", stats.locale); - UnicodeString playerInfo; - Int totalWins = 0, totalLosses = 0, totalDiscons = 0; - PerGeneralMap::iterator it; - - for (it = stats.wins.begin(); it != stats.wins.end(); ++it) - { - totalWins += it->second; - } - for (it = stats.losses.begin(); it != stats.losses.end(); ++it) - { - totalLosses += it->second; - } - for (it = stats.discons.begin(); it != stats.discons.end(); ++it) - { - totalDiscons += it->second; - } - for (it = stats.desyncs.begin(); it != stats.desyncs.end(); ++it) - { - totalDiscons += it->second; - } - UnicodeString favoriteSide; - Int numGames = 0; - Int favorite = 0; - for(it = stats.games.begin(); it != stats.games.end(); ++it) - { - if(it->second >= numGames) - { - numGames = it->second; - favorite = it->first; - } - } - if(numGames == 0) - favoriteSide = TheGameText->fetch("GUI:None"); - else if( stats.gamesAsRandom >= numGames ) - favoriteSide = TheGameText->fetch("GUI:Random"); - else - { - const PlayerTemplate *fac = ThePlayerTemplateStore->getNthPlayerTemplate(favorite); - if (fac) - { - AsciiString side; - side.format("SIDE:%s", fac->getSide().str()); - - favoriteSide = TheGameText->fetch(side); - } - } - - playerInfo.format(TheGameText->fetch("TOOLTIP:StagingPlayerInfo"), - TheGameText->fetch(localeIdentifier).str(), - slot->getPingAsInt(), - totalWins, totalLosses, totalDiscons, - favoriteSide.str()); - - UnicodeString tooltip = UnicodeString::TheEmptyString; - if (isLocalPlayer) - { - tooltip.format(TheGameText->fetch("TOOLTIP:LocalPlayer"), uName.str()); - } - else - { - // not us - if (TheGameSpyInfo->getBuddyMap()->find(profileID) != TheGameSpyInfo->getBuddyMap()->end()) - { - // buddy - tooltip.format(TheGameText->fetch("TOOLTIP:BuddyPlayer"), uName.str()); - } - else - { - if (profileID) - { - // non-buddy profiled player - tooltip.format(TheGameText->fetch("TOOLTIP:ProfiledPlayer"), uName.str()); - } - else - { - // non-profiled player - tooltip.format(TheGameText->fetch("TOOLTIP:GenericPlayer"), uName.str()); - } - } - } - - tooltip.concat(playerInfo); - - TheMouse->setCursorTooltip( tooltip, -1, NULL, 1.5f ); // the text and width are the only params used. the others are the default values. -} - -void gameAcceptTooltip(GameWindow *window, WinInstanceData *instData, UnsignedInt mouse) -{ - Int x, y; - x = LOLONGTOSHORT(mouse); - y = HILONGTOSHORT(mouse); - - Int winPosX, winPosY, winWidth, winHeight; - - window->winGetScreenPosition(&winPosX, &winPosY); - - window->winGetSize(&winWidth, &winHeight); - - if ((x > winPosX && x < (winPosX + winWidth)) && (y > winPosY && y < (winPosY + winHeight))) - { - TheMouse->setCursorTooltip(TheGameText->fetch("TOOLTIP:GameAcceptance"), -1, NULL); - } -} - -void pingTooltip(GameWindow *window, WinInstanceData *instData, UnsignedInt mouse) -{ - Int x, y; - x = LOLONGTOSHORT(mouse); - y = HILONGTOSHORT(mouse); - - - Int winPosX, winPosY, winWidth, winHeight; - - window->winGetScreenPosition(&winPosX, &winPosY); - - window->winGetSize(&winWidth, &winHeight); - - if ((x > winPosX && x < (winPosX + winWidth)) && (y > winPosY && y < (winPosY + winHeight))) - { - TheMouse->setCursorTooltip(TheGameText->fetch("TOOLTIP:ConnectionSpeed"), -1, NULL); - } -} - -//external declarations of the Gadgets the callbacks can use -GameWindow *listboxGameSetupChat = NULL; -NameKeyType listboxGameSetupChatID = NAMEKEY_INVALID; - -static void handleColorSelection(int index) -{ - GameWindow *combo = comboBoxColor[index]; - Int color, selIndex; - GadgetComboBoxGetSelectedPos(combo, &selIndex); - color = (Int)GadgetComboBoxGetItemData(combo, selIndex); - - GameInfo *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - - if (myGame) - { - GameSlot * slot = myGame->getSlot(index); - if (color == slot->getColor()) - return; - - if (color >= -1 && color < TheMultiplayerSettings->getNumColors()) - { - Bool colorAvailable = TRUE; - if(color != -1 ) - { - for(Int i=0; i getSlot(i); - if(color == checkSlot->getColor() && slot != checkSlot) - { - colorAvailable = FALSE; - break; - } - } - } - if(!colorAvailable) - return; - } - - slot->setColor(color); - - if (TheGameSpyInfo->amIHost()) - { - // send around a new slotlist - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - else - { - // request the color from the host - if (!slot->isPlayer(TheGameSpyInfo->getLocalName())) - return; - - AsciiString options; - options.format("Color=%d", color); - AsciiString hostName; - hostName.translate(myGame->getSlot(0)->getName()); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "REQ/"; - req.nick = hostName.str(); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - } - } -} - -static void handlePlayerTemplateSelection(int index) -{ - GameWindow *combo = comboBoxPlayerTemplate[index]; - Int playerTemplate, selIndex; - GadgetComboBoxGetSelectedPos(combo, &selIndex); - playerTemplate = (Int)GadgetComboBoxGetItemData(combo, selIndex); - GameInfo *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - - if (myGame) - { - GameSlot * slot = myGame->getSlot(index); - if (playerTemplate == slot->getPlayerTemplate()) - return; - - Int oldTemplate = slot->getPlayerTemplate(); - slot->setPlayerTemplate(playerTemplate); - - if (oldTemplate == PLAYERTEMPLATE_OBSERVER) - { - // was observer, so populate color & team with all, and enable - GadgetComboBoxSetSelectedPos(comboBoxColor[index], 0); - GadgetComboBoxSetSelectedPos(comboBoxTeam[index], 0); - slot->setStartPos(-1); - } - else if (playerTemplate == PLAYERTEMPLATE_OBSERVER) - { - // is becoming observer, so populate color & team with random only, and disable - GadgetComboBoxSetSelectedPos(comboBoxColor[index], 0); - GadgetComboBoxSetSelectedPos(comboBoxTeam[index], 0); - slot->setStartPos(-1); - } - - - if (TheGameSpyInfo->amIHost()) - { - // send around a new slotlist - myGame->resetAccepted(); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - else - { - // request the playerTemplate from the host - AsciiString options; - options.format("PlayerTemplate=%d", playerTemplate); - AsciiString hostName; - hostName.translate(myGame->getSlot(0)->getName()); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "REQ/"; - req.nick = hostName.str(); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - } - } -} - - -static void handleStartPositionSelection(Int player, int startPos) -{ - GameSpyStagingRoom *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - - if (myGame) - { - GameSpyGameSlot * slot = myGame->getGameSpySlot(player); - if (!slot) - return; - - if (startPos == slot->getStartPos()) - return; - Bool skip = FALSE; - if (startPos < 0) - { - skip = TRUE; - } - - if(!skip) - { - Bool isAvailable = TRUE; - for(Int i = 0; i < MAX_SLOTS; ++i) - { - if(i != player && myGame->getSlot(i)->getStartPos() == startPos) - { - isAvailable = FALSE; - break; - } - } - if( !isAvailable ) - return; - } - slot->setStartPos(startPos); - - if (myGame->amIHost()) - { - // send around a new slotlist - myGame->resetAccepted(); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - else - { - // request the color from the host - if (AreSlotListUpdatesEnabled()) - { - // request the playerTemplate from the host - AsciiString options; - options.format("StartPos=%d", slot->getStartPos()); - AsciiString hostName; - hostName.translate(myGame->getSlot(0)->getName()); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "REQ/"; - req.nick = hostName.str(); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - - } - } - } -} - - - -static void handleTeamSelection(int index) -{ - GameWindow *combo = comboBoxTeam[index]; - Int team, selIndex; - GadgetComboBoxGetSelectedPos(combo, &selIndex); - team = (Int)GadgetComboBoxGetItemData(combo, selIndex); - GameInfo *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - - if (myGame) - { - GameSlot * slot = myGame->getSlot(index); - if (team == slot->getTeamNumber()) - return; - - slot->setTeamNumber(team); - - if (TheGameSpyInfo->amIHost()) - { - // send around a new slotlist - myGame->resetAccepted(); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - else - { - // request the team from the host - AsciiString options; - options.format("Team=%d", team); - AsciiString hostName; - hostName.translate(myGame->getSlot(0)->getName()); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "REQ/"; - req.nick = hostName.str(); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - } - } -} - -static void handleStartingCashSelection() -{ - GameInfo *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - - if (myGame) - { - Int selIndex; - GadgetComboBoxGetSelectedPos(comboBoxStartingCash, &selIndex); - - Money startingCash; - startingCash.deposit( (UnsignedInt)GadgetComboBoxGetItemData( comboBoxStartingCash, selIndex ), FALSE ); - myGame->setStartingCash( startingCash ); - myGame->resetAccepted(); - - if (myGame->amIHost()) - { - // send around the new data - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList();// Update the accepted button UI - } - } -} - -static void handleLimitSuperweaponsClick() -{ - GameInfo *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - - if (myGame) - { - // At the moment, 1 and 0 are the only choices supported in the GUI, though the system could - // support more. - if ( GadgetCheckBoxIsChecked( checkBoxLimitSuperweapons ) ) - { - myGame->setSuperweaponRestriction( 1 ); - } - else - { - myGame->setSuperweaponRestriction( 0 ); - } - myGame->resetAccepted(); - - if (myGame->amIHost()) - { - // send around a new slotlist - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList();// Update the accepted button UI - } - } -} - - -static void StartPressed(void) -{ - Bool isReady = TRUE; - Bool allHaveMap = TRUE; - Int playerCount = 0; - Int humanCount = 0; - GameSpyStagingRoom *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - if (!myGame) - return; - - // see if everyone's accepted and count the number of players in the game - UnicodeString mapDisplayName; - const MapMetaData *mapData = TheMapCache->findMap( myGame->getMap() ); - Bool willTransfer = TRUE; - if (mapData) - { - mapDisplayName.format(L"%ls", mapData->m_displayName.str()); - willTransfer = !mapData->m_isOfficial; - } - else - { - mapDisplayName.format(L"%hs", myGame->getMap().str()); - willTransfer = WouldMapTransfer(myGame->getMap()); - } - for( int i = 0; i < MAX_SLOTS; i++ ) - { - if ((myGame->getSlot(i)->isAccepted() == FALSE) && (myGame->getSlot(i)->isHuman() == TRUE)) - { - isReady = FALSE; - if (!myGame->getSlot(i)->hasMap() && !willTransfer) - { - UnicodeString msg; - msg.format(TheGameText->fetch("GUI:PlayerNoMap"), myGame->getSlot(i)->getName().str(), mapDisplayName.str()); - TheGameSpyInfo->addText(msg, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - allHaveMap = FALSE; - } - } - if(myGame->getSlot(i)->isOccupied() && myGame->getSlot(i)->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - if (myGame->getSlot(i)->isHuman()) - humanCount++; - playerCount++; - } - } - - // Check for too many players - const MapMetaData *md = TheMapCache->findMap( myGame->getMap() ); - if (!md || md->m_numPlayers < playerCount) - { - if (myGame->amIHost()) - { - UnicodeString text; - text.format(TheGameText->fetch("LAN:TooManyPlayers"), (md)?md->m_numPlayers:0); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - return; - } - - // Check for observer + AI players - if (TheGlobalData->m_netMinPlayers && !humanCount) - { - if (myGame->amIHost()) - { - UnicodeString text = TheGameText->fetch("GUI:NeedHumanPlayers"); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - return; - } - - // Check for too few players - if (playerCount < TheGlobalData->m_netMinPlayers) - { - if (myGame->amIHost()) - { - UnicodeString text; - text.format(TheGameText->fetch("LAN:NeedMorePlayers"),playerCount); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - return; - } - - // Check for too few teams - int numRandom = 0; - std::set teams; - for (i=0; igetSlot(i); - if (slot && slot->isOccupied() && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - if (slot->getTeamNumber() >= 0) - { - teams.insert(slot->getTeamNumber()); - } - else - { - ++numRandom; - } - } - } - if (numRandom + teams.size() < TheGlobalData->m_netMinPlayers) - { - if (myGame->amIHost()) - { - UnicodeString text; - text.format(TheGameText->fetch("LAN:NeedMoreTeams")); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - return; - } - - if (numRandom + teams.size() < 2) - { - UnicodeString text; - text.format(TheGameText->fetch("GUI:SandboxMode")); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - - if(isReady) - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STARTGAME; - TheGameSpyPeerMessageQueue->addRequest(req); - - SendStatsToOtherPlayers(myGame); - - // we've started, there's no going back - // i.e. disable the back button. - buttonBack->winEnable(FALSE); - GameWindow *buttonBuddy = TheWindowManager->winGetWindowFromId(NULL, NAMEKEY("GameSpyGameOptionsMenu.wnd:ButtonCommunicator")); - if (buttonBuddy) - buttonBuddy->winEnable(FALSE); - GameSpyCloseOverlay(GSOVERLAY_BUDDY); - - *TheGameSpyGame = *myGame; - TheGameSpyGame->startGame(0); - } - else if (allHaveMap) - { - TheGameSpyInfo->addText(TheGameText->fetch("GUI:NotifiedStartIntent"), GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMROOM; - req.UTM.isStagingRoom = TRUE; - req.id = "HWS/"; - req.options = "true"; - TheGameSpyPeerMessageQueue->addRequest(req); - } - -}//void StartPressed(void) - -//------------------------------------------------------------------------------------------------- -/** Update options on screen */ -//------------------------------------------------------------------------------------------------- -void WOLDisplayGameOptions( void ) -{ - GameSpyStagingRoom *theGame = TheGameSpyInfo->getCurrentStagingRoom(); - if (!parentWOLGameSetup || !theGame) - return; - - const GameSlot *localSlot = NULL; - if (theGame->getLocalSlotNum() >= 0) - localSlot = theGame->getConstSlot(theGame->getLocalSlotNum()); - - const MapMetaData *md = TheMapCache->findMap(TheGameSpyInfo->getCurrentStagingRoom()->getMap()); - if (md && localSlot && localSlot->hasMap()) - { - GadgetStaticTextSetText(textEntryMapDisplay, md->m_displayName); - } - else - { - AsciiString s = TheGameSpyInfo->getCurrentStagingRoom()->getMap(); - if (s.reverseFind('\\')) - { - s = s.reverseFind('\\') + 1; - } - UnicodeString mapDisplay; - mapDisplay.translate(s); - GadgetStaticTextSetText(textEntryMapDisplay, mapDisplay); - } - WOLPositionStartSpots(); - updateMapStartSpots(TheGameSpyInfo->getCurrentStagingRoom(), buttonMapStartPosition); - - //If our display does not match the current state of game settings, update the checkbox. - Bool isUsingStats = TheGameSpyInfo->getCurrentStagingRoom()->getUseStats() ? TRUE : FALSE; - if (GadgetCheckBoxIsChecked(checkBoxUseStats) != isUsingStats) - { - GadgetCheckBoxSetChecked(checkBoxUseStats, isUsingStats); - checkBoxUseStats->winSetTooltip( TheGameText->fetch( isUsingStats ? "TOOLTIP:UseStatsOn" : "TOOLTIP:UseStatsOff" ) ); - } - - Bool oldFactionsOnly = theGame->oldFactionsOnly(); - if (GadgetCheckBoxIsChecked(checkBoxLimitArmies) != oldFactionsOnly) - { - GadgetCheckBoxSetChecked(checkBoxLimitArmies, oldFactionsOnly); - // Repopulate the lists of available armies, since the old list is now wrong - for (Int i = 0; i < MAX_SLOTS; i++) - { - PopulatePlayerTemplateComboBox(i, comboBoxPlayerTemplate, theGame, theGame->getAllowObservers() ); - - // Make sure selections are up to date on all machines - handlePlayerTemplateSelection(i) ; - } - } - - // Note: must check if checkbox is already correct to avoid infinite recursion - Bool limitSuperweapons = (theGame->getSuperweaponRestriction() != 0); - if ( limitSuperweapons != GadgetCheckBoxIsChecked(checkBoxLimitSuperweapons)) - GadgetCheckBoxSetChecked( checkBoxLimitSuperweapons, limitSuperweapons ); - - Int itemCount = GadgetComboBoxGetLength(comboBoxStartingCash); - for ( Int index = 0; index < itemCount; index++ ) - { - Int value = (Int)GadgetComboBoxGetItemData(comboBoxStartingCash, index); - if ( value == theGame->getStartingCash().countMoney() ) - { - // Note: must check if combobox is already correct to avoid infinite recursion - Int selectedIndex; - GadgetComboBoxGetSelectedPos( comboBoxStartingCash, &selectedIndex ); - if ( index != selectedIndex ) - GadgetComboBoxSetSelectedPos(comboBoxStartingCash, index, TRUE); - - break; - } - } - - DEBUG_ASSERTCRASH( index < itemCount, ("Could not find new starting cash amount %d in list", theGame->getStartingCash().countMoney() ) ); -} - - -// ----------------------------------------------------------------------------------------- -// The Bad munkee slot list displaying function -//------------------------------------------------------------------------------------------------- -void WOLDisplaySlotList( void ) -{ - if (!parentWOLGameSetup || !TheGameSpyInfo->getCurrentStagingRoom()) - return; - - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (!game->isInGame()) - return; - - DEBUG_ASSERTCRASH(!game->getConstSlot(0)->isOpen(), ("Open host!")); - - UpdateSlotList( game, comboBoxPlayer, comboBoxColor, - comboBoxPlayerTemplate, comboBoxTeam, buttonAccept, buttonStart, buttonMapStartPosition ); - - WOLDisplayGameOptions(); - - for (Int i=0; igetGameSpySlot(i); - if (slot && slot->isHuman()) - { - if (i == game->getLocalSlotNum()) - { - // set up my own ping... - slot->setPingString(TheGameSpyInfo->getPingString()); - } - - if (genericPingWindow[i]) - { - genericPingWindow[i]->winHide(FALSE); - Int ping = slot->getPingAsInt(); - if (ping < TheGameSpyConfig->getPingCutoffGood()) - { - genericPingWindow[i]->winSetEnabledImage(0, pingImages[0]); - } - else if (ping < TheGameSpyConfig->getPingCutoffBad()) - { - genericPingWindow[i]->winSetEnabledImage(0, pingImages[1]); - } - else - { - genericPingWindow[i]->winSetEnabledImage(0, pingImages[2]); - } - } - } - else - { - if (genericPingWindow[i]) - genericPingWindow[i]->winHide(TRUE); - } - } -} - -//------------------------------------------------------------------------------------------------- -/** Initialize the Gadgets Options Menu */ -//------------------------------------------------------------------------------------------------- -void InitWOLGameGadgets( void ) -{ - GameSpyStagingRoom *theGameInfo = TheGameSpyInfo->getCurrentStagingRoom(); - pingImages[0] = TheMappedImageCollection->findImageByName("Ping03"); - pingImages[1] = TheMappedImageCollection->findImageByName("Ping02"); - pingImages[2] = TheMappedImageCollection->findImageByName("Ping01"); - DEBUG_ASSERTCRASH(pingImages[0], ("Can't find ping image!")); - DEBUG_ASSERTCRASH(pingImages[1], ("Can't find ping image!")); - DEBUG_ASSERTCRASH(pingImages[2], ("Can't find ping image!")); - - //Initialize the gadget IDs - parentWOLGameSetupID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:GameSpyGameOptionsMenuParent" ) ); - buttonBackID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:ButtonBack" ) ); - buttonStartID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:ButtonStart" ) ); - textEntryChatID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:TextEntryChat" ) ); - textEntryMapDisplayID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:TextEntryMapDisplay" ) ); - listboxGameSetupChatID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:ListboxChatWindowGameSpyGameSetup" ) ); - buttonEmoteID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:ButtonEmote" ) ); - buttonSelectMapID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:ButtonSelectMap" ) ); - checkBoxUseStatsID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:CheckBoxUseStats" ) ); - windowMapID = TheNameKeyGenerator->nameToKey( AsciiString( "GameSpyGameOptionsMenu.wnd:MapWindow" ) ); - checkBoxLimitSuperweaponsID = TheNameKeyGenerator->nameToKey(AsciiString("GameSpyGameOptionsMenu.wnd:CheckboxLimitSuperweapons")); - comboBoxStartingCashID = TheNameKeyGenerator->nameToKey(AsciiString("GameSpyGameOptionsMenu.wnd:ComboBoxStartingCash")); - checkBoxLimitArmiesID = TheNameKeyGenerator->nameToKey(AsciiString("GameSpyGameOptionsMenu.wnd:CheckBoxLimitArmies")); - windowMapSelectMapID = TheNameKeyGenerator->nameToKey(AsciiString("WOLMapSelectMenu.wnd:WinMapPreview")); - - NameKeyType staticTextTitleID = NAMEKEY("GameSpyGameOptionsMenu.wnd:StaticTextGameName"); - - // Initialize the pointers to our gadgets - parentWOLGameSetup = TheWindowManager->winGetWindowFromId( NULL, parentWOLGameSetupID ); - buttonEmote = TheWindowManager->winGetWindowFromId( parentWOLGameSetup,buttonEmoteID ); - buttonSelectMap = TheWindowManager->winGetWindowFromId( parentWOLGameSetup,buttonSelectMapID ); - checkBoxUseStats = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, checkBoxUseStatsID ); - buttonStart = TheWindowManager->winGetWindowFromId( parentWOLGameSetup,buttonStartID ); - buttonBack = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, buttonBackID); - listboxGameSetupChat = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, listboxGameSetupChatID ); - textEntryChat = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, textEntryChatID ); - textEntryMapDisplay = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, textEntryMapDisplayID ); - windowMap = TheWindowManager->winGetWindowFromId( parentWOLGameSetup,windowMapID ); - DEBUG_ASSERTCRASH(windowMap, ("Could not find the parentWOLGameSetup.wnd:MapWindow" )); - - checkBoxLimitSuperweapons = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, checkBoxLimitSuperweaponsID ); - DEBUG_ASSERTCRASH(windowMap, ("Could not find the GameSpyGameOptionsMenu.wnd:CheckboxLimitSuperweapons" )); - comboBoxStartingCash = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, comboBoxStartingCashID ); - DEBUG_ASSERTCRASH(windowMap, ("Could not find the GameSpyGameOptionsMenu.wnd:ComboBoxStartingCash" )); - PopulateStartingCashComboBox( comboBoxStartingCash, TheGameSpyGame ); - checkBoxLimitArmies = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, checkBoxLimitArmiesID ); - DEBUG_ASSERTCRASH(windowMap, ("Could not find the GameSpyGameOptionsMenu.wnd:CheckBoxLimitArmies" )); - - // Limit Armies can ONLY be set in the Host Game window (PopupHostGame.wnd) - checkBoxLimitArmies->winEnable( false ); - // Ditto use stats - checkBoxUseStats->winEnable( false ); - Int isUsingStats = TheGameSpyGame->getUseStats(); - GadgetCheckBoxSetChecked(checkBoxUseStats, isUsingStats ); - checkBoxUseStats->winSetTooltip( TheGameText->fetch( isUsingStats ? "TOOLTIP:UseStatsOn" : "TOOLTIP:UseStatsOff" ) ); - - if ( !TheGameSpyGame->amIHost() ) - { - checkBoxLimitSuperweapons->winEnable( false ); - comboBoxStartingCash->winEnable( false ); - NameKeyType labelID = TheNameKeyGenerator->nameToKey(AsciiString("GameSpyGameOptionsMenu.wnd:StartingCashLabel")); - TheWindowManager->winGetWindowFromId(parentWOLGameSetup, labelID)->winEnable( FALSE ); - } - - if (isUsingStats) - { - // Recorded stats games can never limit superweapons, limit armies, or have inflated starting cash. - // This should probably be enforced at the gamespy level as well, to prevent expoits. - checkBoxLimitSuperweapons->winEnable( FALSE ); - comboBoxStartingCash->winEnable( FALSE ); - checkBoxLimitArmies->winEnable( FALSE ); - NameKeyType labelID = TheNameKeyGenerator->nameToKey(AsciiString("GameSpyGameOptionsMenu.wnd:StartingCashLabel")); - TheWindowManager->winGetWindowFromId(parentWOLGameSetup, labelID)->winEnable( FALSE ); - } - - //Added By Sadullah Nader - //Tooltip Function set - windowMap->winSetTooltipFunc(MapSelectorTooltip); - // - - GameWindow *staticTextTitle = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, staticTextTitleID ); - if (staticTextTitle) - { - GadgetStaticTextSetText(staticTextTitle, TheGameSpyGame->getGameName()); - } - - if (!theGameInfo) - { - DEBUG_CRASH(("No staging room!")); - return; - } - - for (Int i = 0; i < MAX_SLOTS; i++) - { - AsciiString tmpString; - tmpString.format("GameSpyGameOptionsMenu.wnd:ComboBoxPlayer%d", i); - comboBoxPlayerID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - comboBoxPlayer[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, comboBoxPlayerID[i] ); - GadgetComboBoxReset(comboBoxPlayer[i]); - comboBoxPlayer[i]->winSetTooltipFunc(playerTooltip); - - tmpString.format("GameSpyGameOptionsMenu.wnd:StaticTextPlayer%d", i); - staticTextPlayerID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - staticTextPlayer[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, staticTextPlayerID[i] ); - staticTextPlayer[i]->winSetTooltipFunc(playerTooltip); - if (TheGameSpyInfo->amIHost()) - staticTextPlayer[i]->winHide(TRUE); - - if(i==0 && TheGameSpyInfo->amIHost()) - { - UnicodeString uName; - uName.translate(TheGameSpyInfo->getLocalName()); - GadgetComboBoxAddEntry(comboBoxPlayer[i],uName,GameSpyColor[GSCOLOR_PLAYER_OWNER]); - GadgetComboBoxSetSelectedPos(comboBoxPlayer[0],0); - } - else - { - GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:Open"),GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:Closed"),GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:EasyAI"),GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:MediumAI"),GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - GadgetComboBoxAddEntry(comboBoxPlayer[i],TheGameText->fetch("GUI:HardAI"),GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - GadgetComboBoxSetSelectedPos(comboBoxPlayer[i],0); - } - - tmpString.format("GameSpyGameOptionsMenu.wnd:ComboBoxColor%d", i); - comboBoxColorID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - comboBoxColor[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, comboBoxColorID[i] ); - DEBUG_ASSERTCRASH(comboBoxColor[i], ("Could not find the comboBoxColor[%d]",i )); - PopulateColorComboBox(i, comboBoxColor, theGameInfo); - GadgetComboBoxSetSelectedPos(comboBoxColor[i], 0); - - tmpString.format("GameSpyGameOptionsMenu.wnd:ComboBoxPlayerTemplate%d", i); - comboBoxPlayerTemplateID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - comboBoxPlayerTemplate[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, comboBoxPlayerTemplateID[i] ); - DEBUG_ASSERTCRASH(comboBoxPlayerTemplate[i], ("Could not find the comboBoxPlayerTemplate[%d]",i )); - PopulatePlayerTemplateComboBox(i, comboBoxPlayerTemplate, theGameInfo, theGameInfo->getAllowObservers() ); - - // add tooltips to the player template combobox and listbox - comboBoxPlayerTemplate[i]->winSetTooltipFunc(playerTemplateComboBoxTooltip); - GadgetComboBoxGetListBox(comboBoxPlayerTemplate[i])->winSetTooltipFunc(playerTemplateListBoxTooltip); - - tmpString.format("GameSpyGameOptionsMenu.wnd:ComboBoxTeam%d", i); - comboBoxTeamID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - comboBoxTeam[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, comboBoxTeamID[i] ); - DEBUG_ASSERTCRASH(comboBoxTeam[i], ("Could not find the comboBoxTeam[%d]",i )); - PopulateTeamComboBox(i, comboBoxTeam, theGameInfo); - - tmpString.format("GameSpyGameOptionsMenu.wnd:ButtonAccept%d", i); - buttonAcceptID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - buttonAccept[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, buttonAcceptID[i] ); - DEBUG_ASSERTCRASH(buttonAccept[i], ("Could not find the buttonAccept[%d]",i )); - buttonAccept[i]->winSetTooltipFunc(gameAcceptTooltip); - - tmpString.format("GameSpyGameOptionsMenu.wnd:GenericPing%d", i); - genericPingWindowID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - genericPingWindow[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, genericPingWindowID[i] ); - DEBUG_ASSERTCRASH(genericPingWindow[i], ("Could not find the genericPingWindow[%d]",i )); - genericPingWindow[i]->winSetTooltipFunc(pingTooltip); - -// tmpString.format("GameSpyGameOptionsMenu.wnd:ButtonStartPosition%d", i); -// buttonStartPositionID[i] = TheNameKeyGenerator->nameToKey( tmpString ); -// buttonStartPosition[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, buttonStartPositionID[i] ); -// DEBUG_ASSERTCRASH(buttonStartPosition[i], ("Could not find the ButtonStartPosition[%d]",i )); - - tmpString.format("GameSpyGameOptionsMenu.wnd:ButtonMapStartPosition%d", i); - buttonMapStartPositionID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - buttonMapStartPosition[i] = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, buttonMapStartPositionID[i] ); - DEBUG_ASSERTCRASH(buttonMapStartPosition[i], ("Could not find the ButtonMapStartPosition[%d]",i )); - -// if (buttonStartPosition[i]) -// buttonStartPosition[i]->winHide(TRUE); - - if(i !=0 && buttonAccept[i]) - buttonAccept[i]->winHide(TRUE); - } - - if( buttonAccept[0] ) - buttonAccept[0]->winEnable(TRUE); - - if (buttonBack != NULL) - { - buttonBack->winEnable(TRUE); - } - //GadgetButtonSetEnabledColor(buttonAccept[0], GameSpyColor[GSCOLOR_ACCEPT_TRUE]); -} - -void DeinitWOLGameGadgets( void ) -{ - parentWOLGameSetup = NULL; - buttonEmote = NULL; - buttonSelectMap = NULL; - buttonStart = NULL; - buttonBack = NULL; - listboxGameSetupChat = NULL; - textEntryChat = NULL; - textEntryMapDisplay = NULL; - windowMap = NULL; - checkBoxUseStats = NULL; - checkBoxLimitSuperweapons = NULL; - comboBoxStartingCash = NULL; - -// GameWindow *staticTextTitle = NULL; - for (Int i = 0; i < MAX_SLOTS; i++) - { - comboBoxPlayer[i] = NULL; - staticTextPlayer[i] = NULL; - comboBoxColor[i] = NULL; - comboBoxPlayerTemplate[i] = NULL; - comboBoxTeam[i] = NULL; - buttonAccept[i] = NULL; -// buttonStartPosition[i] = NULL; - buttonMapStartPosition[i] = NULL; - genericPingWindow[i] = NULL; - } -} - -static Bool initDone = false; -UnsignedInt lastSlotlistTime = 0; -UnsignedInt enterTime = 0; -Bool initialAcceptEnable = FALSE; -//------------------------------------------------------------------------------------------------- -/** Initialize the Lan Game Options Menu */ -//------------------------------------------------------------------------------------------------- -void WOLGameSetupMenuInit( WindowLayout *layout, void *userData ) -{ - if (TheGameSpyGame && TheGameSpyGame->isGameInProgress()) - { - TheGameSpyGame->setGameInProgress(FALSE); - - // check if we were disconnected - Int disconReason; - if (TheGameSpyInfo->isDisconnectedAfterGameStart(&disconReason)) - { - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", disconReason); - UnicodeString title, body; - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheGameSpyInfo->reset(); - DEBUG_LOG(("WOLGameSetupMenuInit() - game was in progress, and we were disconnected, so pop immediate back to main menu\n")); - TheShell->popImmediate(); - return; - } - - // If we init while the game is in progress, we are really returning to the menu - // after the game. So, we pop the menu and go back to the lobby. Whee! - DEBUG_LOG(("WOLGameSetupMenuInit() - game was in progress, so pop immediate back to lobby\n")); - TheShell->popImmediate(); - if (TheGameSpyPeerMessageQueue && TheGameSpyPeerMessageQueue->isConnected()) - { - DEBUG_LOG(("We're still connected, so pushing back on the lobby\n")); - TheShell->push("Menus/WOLCustomLobby.wnd", TRUE); - } - return; - } - TheGameSpyInfo->setCurrentGroupRoom(0); - - if (TheNAT != NULL) { - delete TheNAT; - TheNAT = NULL; - } - - nextScreen = NULL; - buttonPushed = false; - isShuttingDown = false; - launchGameNext = FALSE; - - //initialize the gadgets - EnableSlotListUpdates(FALSE); - InitWOLGameGadgets(); - EnableSlotListUpdates(TRUE); - TheGameSpyInfo->registerTextWindow(listboxGameSetupChat); - - //The dialog needs to react differently depending on whether it's the host or not. - TheMapCache->updateCache(); - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - GameSpyGameSlot *hostSlot = game->getGameSpySlot(0); - hostSlot->setAccept(); - if (TheGameSpyInfo->amIHost()) - { - OptionPreferences natPref; - CustomMatchPreferences customPref; - hostSlot->setColor( customPref.getPreferredColor() ); - hostSlot->setPlayerTemplate( customPref.getPreferredFaction() ); - hostSlot->setNATBehavior((FirewallHelperClass::FirewallBehaviorType)natPref.getFirewallBehavior()); - hostSlot->setPingString(TheGameSpyInfo->getPingString()); - game->setMap(customPref.getPreferredMap()); - - // Recorded stats games can never limit superweapons, limit armies, or have inflated starting cash. - // This should probably be enforced at the gamespy level as well, to prevent expoits. - Int isUsingStats = TheGameSpyGame->getUseStats(); - game->setStartingCash( isUsingStats? TheMultiplayerSettings->getDefaultStartingMoney() : customPref.getStartingCash() ); - game->setSuperweaponRestriction( isUsingStats? 0 : customPref.getSuperweaponRestricted() ? 1 : 0 ); - if (isUsingStats) - game->setOldFactionsOnly( 0 ); - - //game->setOldFactionsOnly( customPref.getFactionsLimited() ); - if ( game->oldFactionsOnly() ) - { - // Make sure host follows the old factions only restrictions! - const PlayerTemplate *fac = ThePlayerTemplateStore->getNthPlayerTemplate(hostSlot->getPlayerTemplate()); - - if ( fac != NULL && !fac->isOldFaction() ) - { - hostSlot->setPlayerTemplate( PLAYERTEMPLATE_RANDOM ); - } - } - - for (Int i=1; igetGameSpySlot(i); - slot->setState( SLOT_OPEN ); - } - - AsciiString lowerMap = customPref.getPreferredMap(); - lowerMap.toLower(); - std::map::iterator it = TheMapCache->find(lowerMap); - if (it != TheMapCache->end()) - { - hostSlot->setMapAvailability(TRUE); - game->setMapCRC( it->second.m_CRC ); - game->setMapSize( it->second.m_filesize ); - - game->adjustSlotsForMap(); // BGC- adjust the slots for the new map. - } - - - WOLDisplaySlotList(); - WOLDisplayGameOptions(); - } - else - { - OptionPreferences natPref; - CustomMatchPreferences customPref; - AsciiString options; - PeerRequest req; - UnicodeString uName = hostSlot->getName(); - AsciiString aName; - aName.translate(uName); - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "REQ/"; - req.nick = aName.str(); - options.format("PlayerTemplate=%d", customPref.getPreferredFaction()); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - options.format("Color=%d", customPref.getPreferredColor()); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - options.format("NAT=%d", natPref.getFirewallBehavior()); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - options.format("Ping=%s", TheGameSpyInfo->getPingString().str()); - req.options = options.str(); - TheGameSpyPeerMessageQueue->addRequest(req); - - game->setMapCRC( game->getMapCRC() ); // force a recheck - game->setMapSize( game->getMapSize() ); // of if we have the map - - for (Int i = 0; i < MAX_SLOTS; ++i) - { - //I'm a client, disable the controls I can't touch. - comboBoxPlayer[i]->winEnable(FALSE); - - comboBoxColor[i]->winEnable(FALSE); - comboBoxPlayerTemplate[i]->winEnable(FALSE); - comboBoxTeam[i]->winEnable(FALSE); -// buttonStartPosition[i]->winEnable(FALSE); - buttonMapStartPosition[i]->winEnable(FALSE); - - } - buttonStart->winSetText(TheGameText->fetch("GUI:Accept")); - buttonStart->winEnable( FALSE ); - buttonSelectMap->winEnable( FALSE ); - checkBoxLimitSuperweapons->winEnable( FALSE ); // Can look but only host can touch - comboBoxStartingCash->winEnable( FALSE ); // Ditto - initialAcceptEnable = FALSE; - } - - // Show the Menu - layout->hide( FALSE ); - - // Make sure the text fields are clear - GadgetListBoxReset( listboxGameSetupChat ); - GadgetTextEntrySetText(textEntryChat, UnicodeString::TheEmptyString); - - initDone = true; - TheGameSpyInfo->setGameOptions(); - //TheShell->registerWithAnimateManager(parentWOLGameSetup, WIN_ANIMATION_SLIDE_TOP, TRUE); - WOLPositionStartSpots(); - - lastSlotlistTime = 0; - enterTime = timeGetTime(); - - // Set Keyboard to chat entry - TheWindowManager->winSetFocus( textEntryChat ); - raiseMessageBoxes = true; - TheTransitionHandler->setGroup("GameSpyGameOptionsMenuFade"); -}// void WOLGameSetupMenuInit( WindowLayout *layout, void *userData ) - -//------------------------------------------------------------------------------------------------- -/** This is called when a shutdown is complete for this menu */ -//------------------------------------------------------------------------------------------------- -static void shutdownComplete( WindowLayout *layout ) -{ - - isShuttingDown = false; - - // hide the layout - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout, (nextScreen != NULL) ); - - if (nextScreen != NULL) - { - if (!TheGameSpyPeerMessageQueue || !TheGameSpyPeerMessageQueue->isConnected()) - { - DEBUG_LOG(("GameSetup shutdownComplete() - skipping push because we're disconnected\n")); - } - else - { - TheShell->push(nextScreen); - } - } - - /* - if (launchGameNext) - { - TheGameSpyGame->launchGame(); - TheGameSpyInfo->leaveStagingRoom(); - } - */ - - nextScreen = NULL; - -} // end if - -//------------------------------------------------------------------------------------------------- -/** GameSpy Game Options menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLGameSetupMenuShutdown( WindowLayout *layout, void *userData ) -{ - TheGameSpyInfo->unregisterTextWindow(listboxGameSetupChat); - - if( WOLMapSelectLayout ) - { - WOLMapSelectLayout->destroyWindows(); - WOLMapSelectLayout->deleteInstance(); - WOLMapSelectLayout = NULL; - } - parentWOLGameSetup = NULL; - EnableSlotListUpdates(FALSE); - DeinitWOLGameGadgets(); - if (TheEstablishConnectionsMenu != NULL) - { - TheEstablishConnectionsMenu->endMenu(); - } - initDone = false; - - isShuttingDown = true; - - // if we are shutting down for an immediate pop, skip the animations - Bool popImmediate = *(Bool *)userData; - if( popImmediate ) - { - - shutdownComplete( layout ); - return; - - } //end if - - TheShell->reverseAnimatewindow(); - - RaiseGSMessageBox(); - TheTransitionHandler->reverse("GameSpyGameOptionsMenuFade"); -} // void WOLGameSetupMenuShutdown( WindowLayout *layout, void *userData ) - -static void fillPlayerInfo(const PeerResponse *resp, PlayerInfo *info) -{ - info->m_name = resp->nick.c_str(); - info->m_profileID = resp->player.profileID; - info->m_flags = resp->player.flags; - info->m_wins = resp->player.wins; - info->m_losses = resp->player.losses; - info->m_locale = resp->locale.c_str(); - info->m_rankPoints= resp->player.rankPoints; - info->m_side = resp->player.side; - info->m_preorder = resp->player.preorder; -} - -//------------------------------------------------------------------------------------------------- -/** Lan Game Options menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData) -{ - // We'll only be successful if we've requested to - if(isShuttingDown && TheShell->isAnimFinished() && TheTransitionHandler->isFinished()) - { - shutdownComplete(layout); - return; - } - - if (raiseMessageBoxes) - { - RaiseGSMessageBox(); - raiseMessageBoxes = false; - } - - if (TheShell->isAnimFinished() && !buttonPushed && TheGameSpyPeerMessageQueue) - { - HandleBuddyResponses(); - HandlePersistentStorageResponses(); - - if (TheGameSpyGame && TheGameSpyGame->isGameInProgress()) - { - if (TheGameSpyInfo->isDisconnectedAfterGameStart(NULL)) - { - return; // already been disconnected, so don't worry. - } - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - PeerResponse resp; - while (allowedMessages-- && !sawImportantMessage && TheGameSpyPeerMessageQueue->getResponse( resp )) - { - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - - // check for scorescreen - NameKeyType listboxChatWindowScoreScreenID = NAMEKEY("ScoreScreen.wnd:ListboxChatWindowScoreScreen"); - GameWindow *listboxChatWindowScoreScreen = TheWindowManager->winGetWindowFromId( NULL, listboxChatWindowScoreScreenID ); - if (listboxChatWindowScoreScreen) - { - GadgetListBoxAddEntryText(listboxChatWindowScoreScreen, TheGameText->fetch(disconMunkee), - GameSpyColor[GSCOLOR_DEFAULT], -1); - } - else - { - // still ingame - TheInGameUI->message(disconMunkee); - } - TheGameSpyInfo->markAsDisconnectedAfterGameStart(resp.discon.reason); - } - } - } - - return; // if we're in game, all we care about is if we've been disconnected from the chat server - } - - Bool isHosting = TheGameSpyInfo->amIHost(); // only while in game setup screen - isHosting = isHosting || (TheGameSpyGame && TheGameSpyGame->isInGame() && TheGameSpyGame->amIHost()); // while in game - if (!isHosting && !lastSlotlistTime && timeGetTime() > enterTime + 10000) - { - // don't do this if we're disconnected - if (TheGameSpyPeerMessageQueue->isConnected()) - { - // haven't seen ourselves - buttonPushed = true; - DEBUG_LOG(("Haven't seen ourselves in slotlist\n")); - if (TheGameSpyGame) - TheGameSpyGame->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - GSMessageBoxOk(TheGameText->fetch("GUI:HostLeftTitle"), TheGameText->fetch("GUI:HostLeft")); - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - } - return; - } - - if (TheNAT != NULL) { - NATStateType NATState = TheNAT->update(); - if (NATState == NATSTATE_DONE) - { - //launchGameNext = TRUE; - //TheShell->pop(); - TheGameSpyGame->launchGame(); - if (TheGameSpyInfo) // this can be blown away by a disconnect on the map transfer screen - TheGameSpyInfo->leaveStagingRoom(); - return; - } - else if (NATState == NATSTATE_FAILED) - { - // Just back out. This cleans up some slot list problems - buttonPushed = true; - - // delete TheNAT, its no good for us anymore. - delete TheNAT; - TheNAT = NULL; - - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:NATNegotiationFailed")); - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - return; - } - } - - PeerResponse resp; - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - while (allowedMessages-- && !sawImportantMessage) - { - - if (!TheLobbyQueuedUTMs.empty()) - { - DEBUG_LOG(("Got response from queued lobby UTM list\n")); - resp = TheLobbyQueuedUTMs.front(); - TheLobbyQueuedUTMs.pop_front(); - } - else if (TheGameSpyPeerMessageQueue->getResponse( resp )) - { - DEBUG_LOG(("Got response from message queue\n")); - } - else - { - break; - } - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_FAILEDTOHOST: - { - // oops - we've not heard from the qr server. bail. - TheGameSpyInfo->addText(TheGameText->fetch("GUI:GSFailedToHost"), GameSpyColor[GSCOLOR_DEFAULT], NULL); - } - break; - case PeerResponse::PEERRESPONSE_GAMESTART: - { - sawImportantMessage = TRUE; - GameSpyStagingRoom *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - if (!myGame || !myGame->isInGame()) - break; - - if (!TheGameSpyGame) - break; - - SendStatsToOtherPlayers(TheGameSpyGame); - - // we've started, there's no going back - // i.e. disable the back button. - buttonBack->winEnable(FALSE); - GameWindow *buttonBuddy = TheWindowManager->winGetWindowFromId(NULL, NAMEKEY("GameSpyGameOptionsMenu.wnd:ButtonCommunicator")); - if (buttonBuddy) - buttonBuddy->winEnable(FALSE); - GameSpyCloseOverlay(GSOVERLAY_BUDDY); - - *TheGameSpyGame = *myGame; - TheGameSpyGame->startGame(0); - } - break; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDFLAGS: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - WOLDisplaySlotList(); - } - break; - case PeerResponse::PEERRESPONSE_PLAYERINFO: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - WOLDisplaySlotList(); - // send out new slotlist if I'm host - TheGameSpyInfo->setGameOptions(); - } - break; - case PeerResponse::PEERRESPONSE_PLAYERJOIN: - { - if (resp.player.roomType != StagingRoom) - { - break; - } - sawImportantMessage = TRUE; - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - - if (p.m_profileID) - { - if (TheGameSpyPSMessageQueue->findPlayerStatsByID(p.m_profileID).id == 0) - { - PSRequest req; - req.requestType = PSRequest::PSREQUEST_READPLAYERSTATS; - req.player.id = p.m_profileID; - TheGameSpyPSMessageQueue->addRequest(req); - } - } - - // check if we have room for the dude - GameInfo *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (TheGameSpyInfo->amIHost() && game) - { - if (TheNAT) - { - // ditch him - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "KICK/"; - req.nick = p.m_name.str(); - req.options = "GameStarted"; - TheGameSpyPeerMessageQueue->addRequest(req); - } - else - { - // look for room for him - // See if there's room - // First get the number of players currently in the room. - Int numPlayers = 0; - for (Int player = 0; player < MAX_SLOTS; ++player) - { - if (game->getSlot(player)->isOccupied() && - game->getSlot(player)->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - ++numPlayers; - } - } - - // now get the number of starting spots on the map. - Int numStartingSpots = MAX_SLOTS; - const MapMetaData *md = TheMapCache->findMap(game->getMap()); - if (md != NULL) - { - numStartingSpots = md->m_numPlayers; - } - - Int openSlotIndex = -1; - for (Int i=0; igetConstSlot(i); - if (slot && slot->isOpen()) - { - openSlotIndex = i; - break; - } - } - - if (openSlotIndex >= 0) - { - // add him - GameSlot newSlot; - UnicodeString uName; - uName.translate(p.m_name); - newSlot.setState(SLOT_PLAYER, uName); - newSlot.setIP(ntohl(resp.player.IP)); - game->setSlot( openSlotIndex, newSlot ); - game->resetAccepted(); // BGC - need to unaccept everyone if someone joins the game. - } - else - { - // ditch him - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "KICK/"; - req.nick = p.m_name.str(); - req.options = "GameFull"; - TheGameSpyPeerMessageQueue->addRequest(req); - } - - // send out new slotlist if I'm host - TheGameSpyInfo->setGameOptions(); - } - } - WOLDisplaySlotList(); - } - break; - - case PeerResponse::PEERRESPONSE_PLAYERLEFT: - { - sawImportantMessage = TRUE; - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->playerLeftGroupRoom(resp.nick.c_str()); - - if (TheGameSpyGame && TheGameSpyGame->isGameInProgress()) - { - break; - } - - if (TheNAT == NULL) // don't update slot list if we're trying to start a game - { - - GameInfo *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (game && TheGameSpyInfo->amIHost()) - { - Int idx = game->getSlotNum(resp.nick.c_str()); - if (idx >= 0) - { - game->getSlot(idx)->setState(SLOT_OPEN); - game->resetAccepted(); // BGC - need to unaccept everyone if someone leaves the game. - } - } - - // send out new slotlist if I'm host - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - - if (game && !TheGameSpyInfo->amIHost()) - { - Int idx = game->getSlotNum(resp.nick.c_str()); - if (idx == 0) - { - // host left - buttonPushed = true; - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - GSMessageBoxOk(TheGameText->fetch("GUI:HostLeftTitle"), TheGameText->fetch("GUI:HostLeft")); - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - } - } - - } - } - break; - - case PeerResponse::PEERRESPONSE_MESSAGE: - { - TheGameSpyInfo->addChat(resp.nick.c_str(), resp.message.profileID, - UnicodeString(resp.text.c_str()), !resp.message.isPrivate, resp.message.isAction, listboxGameSetupChat); - } - break; - - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheGameSpyInfo->reset(); - TheShell->pop(); - } - - case PeerResponse::PEERRESPONSE_ROOMUTM: - { - sawImportantMessage = TRUE; -#if defined(_DEBUG) || defined(_INTERNAL) - if (g_debugSlots) - { - DEBUG_LOG(("About to process a room UTM. Command is '%s', command options is '%s'\n", - resp.command.c_str(), resp.commandOptions.c_str())); - } -#endif - if (!strcmp(resp.command.c_str(), "SL")) - { - // slotlist - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - Bool isValidSlotList = game && game->getSlot(0) && game->getSlot(0)->isPlayer( resp.nick.c_str() ) && !TheGameSpyInfo->amIHost(); - if (!isValidSlotList) - { - SLOTLIST_DEBUG_LOG(("Not a valid slotlist\n")); - if (!game) - { - SLOTLIST_DEBUG_LOG(("No game!\n")); - } - else - { - if (!game->getSlot(0)) - { - SLOTLIST_DEBUG_LOG(("No slot 0!\n")); - } - else - { - if (TheGameSpyInfo->amIHost()) - { - SLOTLIST_DEBUG_LOG(("I'm the host!\n")); - } - else - { - SLOTLIST_DEBUG_LOG(("Not from the host! isHuman:%d, name:'%ls', sender:'%s'\n", - game->getSlot(0)->isHuman(), game->getSlot(0)->getName().str(), - resp.nick.c_str())); - } - } - } - } - else // isValidSlotList - { - Int oldLocalSlotNum = (game->isInGame()) ? game->getLocalSlotNum() : -1; - Bool wasInGame = oldLocalSlotNum >= 0; - AsciiString oldMap = game->getMap(); - UnsignedInt oldMapCRC, newMapCRC; - oldMapCRC = game->getMapCRC(); - - AsciiString options = resp.commandOptions.c_str(); - options.trim(); - UnsignedShort ports[MAX_SLOTS]; - UnsignedInt ips[MAX_SLOTS]; - Int i; - for (i=0; igetConstSlot(i)) - { - ips[i] = game->getConstSlot(i)->getIP(); - ports[i] = game->getConstSlot(i)->getPort(); - } - else - { - ips[i] = 0; - ports[i] = 0; - } - } - Bool optionsOK = ParseAsciiStringToGameInfo(game, options.str()); - if (TheNAT) - { - for (i=0; igetSlot(i)) - { -#ifdef DEBUG_LOGGING - UnsignedShort newPort = game->getConstSlot(i)->getPort(); - UnsignedInt newIP = game->getConstSlot(i)->getIP(); - DEBUG_ASSERTLOG(newIP == ips[i], ("IP was different for player %d (%X --> %X)\n", - i, ips[i], newIP)); - DEBUG_ASSERTLOG(newPort == ports[i], ("Port was different for player %d (%d --> %d)\n", - i, ports[i], newPort)); -#endif - game->getSlot(i)->setPort(ports[i]); - game->getSlot(i)->setIP(ips[i]); - } - } - } - Int newLocalSlotNum = (game->isInGame()) ? game->getLocalSlotNum() : -1; - Bool isInGame = newLocalSlotNum >= 0; - if (!optionsOK) - { - SLOTLIST_DEBUG_LOG(("Options are bad! bailing!\n")); - break; - } - else - { - SLOTLIST_DEBUG_LOG(("Options are good, local slot is %d\n", newLocalSlotNum)); - if (!isInGame) - { - SLOTLIST_DEBUG_LOG(("Not in game; players are:\n")); - for (Int i=0; igetGameSpySlot(i); - if (slot && slot->isHuman()) - { - UnicodeString munkee; - munkee.format(L"\t%d: %ls", i, slot->getName().str()); - SLOTLIST_DEBUG_LOG(("%ls\n", munkee.str())); - } - } - } - } - WOLDisplaySlotList(); - - // if I changed map availability, send it across - newMapCRC = game->getMapCRC(); - if (isInGame) - { - lastSlotlistTime = timeGetTime(); - if ( (oldMapCRC ^ newMapCRC) || (!wasInGame && isInGame) ) - { - // it changed. send it - UnicodeString hostName = TheGameSpyInfo->getCurrentStagingRoom()->getSlot(0)->getName(); - AsciiString asciiName; - asciiName.translate(hostName); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "MAP"; - req.nick = asciiName.str(); - req.options = (game->getSlot(newLocalSlotNum)->hasMap())?"1":"0"; - TheGameSpyPeerMessageQueue->addRequest(req); - if (!game->getSlot(newLocalSlotNum)->hasMap()) - { - UnicodeString text; - UnicodeString mapDisplayName; - const MapMetaData *mapData = TheMapCache->findMap( game->getMap() ); - Bool willTransfer = TRUE; - if (mapData) - { - mapDisplayName.format(L"%ls", mapData->m_displayName.str()); - willTransfer = !mapData->m_isOfficial; - } - else - { - mapDisplayName.format(L"%hs", TheGameState->getMapLeafName(game->getMap()).str()); - willTransfer = WouldMapTransfer(game->getMap()); - } - if (willTransfer) - text.format(TheGameText->fetch("GUI:LocalPlayerNoMapWillTransfer"), mapDisplayName.str()); - else - text.format(TheGameText->fetch("GUI:LocalPlayerNoMap"), mapDisplayName.str()); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - } - if (!initialAcceptEnable) - { - buttonStart->winEnable( TRUE ); - initialAcceptEnable = TRUE; - } - } - else - { - if (lastSlotlistTime) - { - // can't see ourselves - buttonPushed = true; - DEBUG_LOG(("Can't see ourselves in slotlist %s\n", options.str())); - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSKicked")); - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - } - } - } - } - else if (!strcmp(resp.command.c_str(), "HWS")) - { - // host wants to start - GameInfo *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (game && game->isInGame() && game->getSlot(0) && game->getSlot(0)->isPlayer( resp.nick.c_str() )) - { - Int slotNum = game->getLocalSlotNum(); - GameSlot *slot = game->getSlot(slotNum); - if (slot && (slot->isAccepted() == false)) - { - TheGameSpyInfo->addText(TheGameText->fetch("GUI:HostWantsToStart"), GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - } - } - else if (!stricmp(resp.command.c_str(), "NAT")) - { - if (TheNAT != NULL) { - TheNAT->processGlobalMessage(-1, resp.commandOptions.c_str()); - } - } - else if (!stricmp(resp.command.c_str(), "Pings")) - { - if (!TheGameSpyInfo->amIHost()) - { - AsciiString pings = resp.commandOptions.c_str(); - AsciiString token; - for (Int i=0; igetCurrentStagingRoom()->getGameSpySlot(i); - if (pings.nextToken(&token, ",")) - { - token.trim(); - slot->setPingString(token); - } - else - { - slot->setPingString(""); - } - } - } - } - } - break; - - case PeerResponse::PEERRESPONSE_PLAYERUTM: - { - sawImportantMessage = TRUE; - if (!strcmp(resp.command.c_str(), "STATS")) - { - PSPlayerStats stats = TheGameSpyPSMessageQueue->parsePlayerKVPairs(resp.commandOptions.c_str()); - if (stats.id && (TheGameSpyPSMessageQueue->findPlayerStatsByID(stats.id).id == 0)) - TheGameSpyPSMessageQueue->trackPlayerStats(stats); - break; - } - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (game) - { - Int slotNum = game->getSlotNum(resp.nick.c_str()); - if ((slotNum >= 0) && (slotNum < MAX_SLOTS) && (!stricmp(resp.command.c_str(), "NAT"))) { - // this is a command for NAT negotiations, pass if off to TheNAT - if (TheNAT != NULL) { - TheNAT->processGlobalMessage(slotNum, resp.commandOptions.c_str()); - } - } - if (slotNum == 0 && !TheGameSpyInfo->amIHost()) - { - if (!strcmp(resp.command.c_str(), "KICK")) - { - // oops - we've been kicked. bail. - buttonPushed = true; - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - TheGameSpyInfo->leaveStagingRoom(); - //TheGameSpyInfo->joinBestGroupRoom(); - UnicodeString message = TheGameText->fetch("GUI:GSKicked"); - AsciiString commandMessage = resp.commandOptions.c_str(); - commandMessage.trim(); - DEBUG_LOG(("We were kicked: reason was '%s'\n", resp.commandOptions.c_str())); - if (commandMessage == "GameStarted") - { - message = TheGameText->fetch("GUI:GSKickedGameStarted"); - } - else if (commandMessage == "GameFull") - { - message = TheGameText->fetch("GUI:GSKickedGameFull"); - } - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), message); - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - } - } - else if (slotNum > 0 && TheGameSpyInfo->amIHost()) - { - if (!strcmp(resp.command.c_str(), "accept")) - { - game->getSlot(slotNum)->setAccept(); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - else if (!strcmp(resp.command.c_str(), "MAP")) - { - Bool hasMap = atoi(resp.commandOptions.c_str()); - game->getSlot(slotNum)->setMapAvailability(hasMap); - if (!hasMap) - { - // tell the host the user doesn't have the map - UnicodeString mapDisplayName; - const MapMetaData *mapData = TheMapCache->findMap( game->getMap() ); - Bool willTransfer = TRUE; - if (mapData) - { - mapDisplayName.format(L"%ls", mapData->m_displayName.str()); - willTransfer = !mapData->m_isOfficial; - } - else - { - mapDisplayName.format(L"%hs", game->getMap().str()); - willTransfer = WouldMapTransfer(game->getMap()); - } - UnicodeString text; - if (willTransfer) - text.format(TheGameText->fetch("GUI:PlayerNoMapWillTransfer"), game->getSlot(slotNum)->getName().str(), mapDisplayName.str()); - else - text.format(TheGameText->fetch("GUI:PlayerNoMap"), game->getSlot(slotNum)->getName().str(), mapDisplayName.str()); - TheGameSpyInfo->addText(text, GameSpyColor[GSCOLOR_DEFAULT], listboxGameSetupChat); - } - WOLDisplaySlotList(); - } - else if (!strcmp(resp.command.c_str(), "REQ")) - { - AsciiString options = resp.commandOptions.c_str(); - options.trim(); - - Bool change = false; - Bool shouldUnaccept = false; - AsciiString key; - options.nextToken(&key, "="); - Int val = atoi(options.str()+1); - UnsignedInt uVal = atoi(options.str()+1); - DEBUG_LOG(("GameOpt request: key=%s, val=%s from player %d\n", key.str(), options.str()+1, slotNum)); - - GameSpyGameSlot *slot = game->getGameSpySlot(slotNum); - if (!slot) - break; - - if (key == "Color") - { - if (val >= -1 && val < TheMultiplayerSettings->getNumColors() && val != slot->getColor() && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - Bool colorAvailable = TRUE; - if(val != -1 ) - { - for(Int i=0; i getSlot(i); - if(val == checkSlot->getColor() && slot != checkSlot) - { - colorAvailable = FALSE; - break; - } - } - } - if(colorAvailable) - slot->setColor(val); - change = true; - } - else - { - DEBUG_LOG(("Rejecting invalid color %d\n", val)); - } - } - else if (key == "PlayerTemplate") - { - if (val >= PLAYERTEMPLATE_MIN && val < ThePlayerTemplateStore->getPlayerTemplateCount() && val != slot->getPlayerTemplate()) - { - // Validate for LimitArmies checkbox - if ( game->oldFactionsOnly() ) - { - const PlayerTemplate *fac = ThePlayerTemplateStore->getNthPlayerTemplate(val); - if ( fac != NULL && !fac->isOldFaction()) - { - val = PLAYERTEMPLATE_RANDOM; - } - } - - slot->setPlayerTemplate(val); - if (val == PLAYERTEMPLATE_OBSERVER) - { - slot->setColor(-1); - slot->setStartPos(-1); - slot->setTeamNumber(-1); - } - change = true; - shouldUnaccept = true; - } - else - { - DEBUG_LOG(("Rejecting invalid PlayerTemplate %d\n", val)); - } - } - else if (key == "StartPos") - { - if (val >= -1 && val < MAX_SLOTS && val != slot->getStartPos() && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - Bool startPosAvailable = TRUE; - if(val != -1) - { - for(Int i=0; i getSlot(i); - if(val == checkSlot->getStartPos() && slot != checkSlot) - { - startPosAvailable = FALSE; - break; - } - } - } - if(startPosAvailable) - slot->setStartPos(val); - change = true; - shouldUnaccept = true; - } - else - { - DEBUG_LOG(("Rejecting invalid startPos %d\n", val)); - } - } - else if (key == "Team") - { - if (val >= -1 && val < MAX_SLOTS/2 && val != slot->getTeamNumber() && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - { - slot->setTeamNumber(val); - change = true; - shouldUnaccept = true; - } - else - { - DEBUG_LOG(("Rejecting invalid team %d\n", val)); - } - } - else if (key == "IP") - { - if (uVal != slot->getIP()) - { - DEBUG_LOG(("setting IP of player %ls from 0x%08x to be 0x%08x", slot->getName().str(), slot->getIP(), uVal)); - slot->setIP(uVal); - change = true; - shouldUnaccept = true; - } - else - { - DEBUG_LOG(("Rejecting invalid IP %d\n", uVal)); - } - } - else if (key == "NAT") - { - if ((val >= FirewallHelperClass::FIREWALL_MIN) && - (val <= FirewallHelperClass::FIREWALL_MAX)) - { - slot->setNATBehavior((FirewallHelperClass::FirewallBehaviorType)val); - DEBUG_LOG(("Setting NAT behavior to %d for player %d\n", val, slotNum)); - change = true; - } - else - { - DEBUG_LOG(("Rejecting invalid NAT behavior %d from player %d\n", val, slotNum)); - } - } - else if (key == "Ping") - { - slot->setPingString(options.str()+1); - TheGameSpyInfo->setGameOptions(); - DEBUG_LOG(("Setting ping string to %s for player %d\n", options.str()+1, slotNum)); - } - - if (change) - { - if (shouldUnaccept) - game->resetAccepted(); - - TheGameSpyInfo->setGameOptions(); - - WOLDisplaySlotList(); - DEBUG_LOG(("Slot value is color=%d, PlayerTemplate=%d, startPos=%d, team=%d, IP=0x%8.8X\n", - slot->getColor(), slot->getPlayerTemplate(), slot->getStartPos(), slot->getTeamNumber(), slot->getIP())); - DEBUG_LOG(("Slot list updated to %s\n", GameInfoToAsciiString(game).str())); - } - } - } - } - } - break; - - } - } - - - } -}// void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData) - -//------------------------------------------------------------------------------------------------- -/** Lan Game Options menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLGameSetupMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - /* - switch( msg ) - { - - //------------------------------------------------------------------------------------------------- - case GWM_RIGHT_UP: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - NameKeyType controlID = (NameKeyType)control->winGetWindowId(); - DEBUG_LOG(("GWM_RIGHT_UP for control %d(%s)\n", controlID, TheNameKeyGenerator->keyToName(controlID).str())); - break; - } - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - if (buttonPushed) - break; - - switch( key ) - { - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - } // end if - // don't let key fall through anywhere else - return MSG_HANDLED; - } // end escape - } // end switch( key ) - } // end char - } // end switch( msg ) - */ - return MSG_IGNORED; -}//WindowMsgHandledType WOLGameSetupMenuInput( GameWindow *window, UnsignedInt msg, - - -// Slash commands ------------------------------------------------------------------------- -//extern "C" { -//int getQR2HostingStatus(void); -//} -extern int isThreadHosting; - -Bool handleGameSetupSlashCommands(UnicodeString uText) -{ - AsciiString message; - message.translate(uText); - - if (message.getCharAt(0) != '/') - { - return FALSE; // not a slash command - } - - AsciiString remainder = message.str() + 1; - AsciiString token; - remainder.nextToken(&token); - token.toLower(); - - if (token == "host") - { - UnicodeString s; - s.format(L"Hosting qr2:%d thread:%d", 0, isThreadHosting); - TheGameSpyInfo->addText(s, GameSpyColor[GSCOLOR_DEFAULT], NULL); - return TRUE; // was a slash command - } - else if (token == "me" && uText.getLength()>4) - { - TheGameSpyInfo->sendChat(UnicodeString(uText.str()+4), TRUE, NULL); - return TRUE; // was a slash command - } -#if defined(_DEBUG) || defined(_INTERNAL) - else if (token == "slots") - { - g_debugSlots = !g_debugSlots; - TheGameSpyInfo->addText(UnicodeString(L"Toggled SlotList debug"), GameSpyColor[GSCOLOR_DEFAULT], NULL); - return TRUE; // was a slash command - } - else if (token == "discon") - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_LOGOUT; - TheGameSpyPeerMessageQueue->addRequest( req ); - return TRUE; - } -#endif // defined(_DEBUG) || defined(_INTERNAL) - - return FALSE; // not a slash command -} - -static Int getNextSelectablePlayer(Int start) -{ - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - if (!game->amIHost()) - return -1; - for (Int j=start; jgetGameSpySlot(j); - if (slot && slot->getStartPos() == -1 && - ( (j==game->getLocalSlotNum() && game->getConstSlot(j)->getPlayerTemplate()!=PLAYERTEMPLATE_OBSERVER) - || slot->isAI())) - { - return j; - } - } - return -1; -} - -static Int getFirstSelectablePlayer(const GameInfo *game) -{ - const GameSlot *slot = game->getConstSlot(game->getLocalSlotNum()); - if (!game->amIHost() || slot && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER) - return game->getLocalSlotNum(); - - for (Int i=0; igetConstSlot(i); - if (slot && slot->isAI()) - return i; - } - - return game->getLocalSlotNum(); -} - -//------------------------------------------------------------------------------------------------- -/** WOL Game Options menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - static buttonCommunicatorID = NAMEKEY_INVALID; - switch( msg ) - { - //------------------------------------------------------------------------------------------------- - case GWM_CREATE: - { - buttonCommunicatorID = NAMEKEY("GameSpyGameOptionsMenu.wnd:ButtonCommunicator"); - break; - } // case GWM_DESTROY: - //------------------------------------------------------------------------------------------------- - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - //------------------------------------------------------------------------------------------------- - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - //------------------------------------------------------------------------------------------------- - case GCM_SELECTED: - { - if (!initDone) - break; - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if ( controlID == comboBoxStartingCashID ) - { - handleStartingCashSelection(); - } - else - { - GameSpyStagingRoom *myGame = TheGameSpyInfo->getCurrentStagingRoom(); - for (Int i = 0; i < MAX_SLOTS; i++) - { - if (controlID == comboBoxColorID[i]) - { - handleColorSelection(i); - } - else if (controlID == comboBoxPlayerTemplateID[i]) - { - handlePlayerTemplateSelection(i); - } - else if (controlID == comboBoxTeamID[i]) - { - handleTeamSelection(i); - } - else if( controlID == comboBoxPlayerID[i] && TheGameSpyInfo->amIHost() ) - { - // We don't have anything that'll happen if we click on ourselves - if(i == myGame->getLocalSlotNum()) - break; - // Get - Int pos = -1; - GadgetComboBoxGetSelectedPos(comboBoxPlayer[i], &pos); - if( pos != SLOT_PLAYER && pos >= 0) - { - if( myGame->getSlot(i)->getState() == SLOT_PLAYER ) - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - AsciiString aName; - aName.translate(myGame->getSlot(i)->getName()); - req.nick = aName.str(); - req.id = "KICK/"; - req.options = "true"; - TheGameSpyPeerMessageQueue->addRequest(req); - - UnicodeString name = myGame->getSlot(i)->getName(); - myGame->getSlot(i)->setState(SlotState(pos)); - myGame->resetAccepted(); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - //TheLAN->OnPlayerLeave(name); - } - else if( myGame->getSlot(i)->getState() != pos ) - { - Bool wasAI = (myGame->getSlot(i)->isAI()); - myGame->getSlot(i)->setState(SlotState(pos)); - Bool isAI = (myGame->getSlot(i)->isAI()); - myGame->resetAccepted(); - if (wasAI ^ isAI) - PopulatePlayerTemplateComboBox(i, comboBoxPlayerTemplate, myGame, wasAI && myGame->getAllowObservers()); - TheGameSpyInfo->setGameOptions(); - WOLDisplaySlotList(); - } - } - break; - } - } - } - break; - }// case GCM_SELECTED: - //------------------------------------------------------------------------------------------------- - case GBM_SELECTED: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - static buttonCommunicatorID = NAMEKEY("GameSpyGameOptionsMenu.wnd:ButtonCommunicator"); - if ( controlID == buttonBackID ) - { - savePlayerInfo(); - if( WOLMapSelectLayout ) - { - WOLMapSelectLayout->destroyWindows(); - WOLMapSelectLayout->deleteInstance(); - WOLMapSelectLayout = NULL; - } - - TheGameSpyInfo->getCurrentStagingRoom()->reset(); - //peerLeaveRoom(TheGameSpyChat->getPeer(), StagingRoom, NULL); - TheGameSpyInfo->leaveStagingRoom(); - buttonPushed = true; - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - - } //if ( controlID == buttonBack ) - else if ( controlID == buttonCommunicatorID ) - { - GameSpyToggleOverlay( GSOVERLAY_BUDDY ); - - } - else if ( controlID == buttonEmoteID ) - { - // read the user's input - txtInput.set(GadgetTextEntryGetText( textEntryChat )); - // Clear the text entry line - GadgetTextEntrySetText(textEntryChat, UnicodeString::TheEmptyString); - // Clean up the text (remove leading/trailing chars, etc) - txtInput.trim(); - // Echo the user's input to the chat window - if (!txtInput.isEmpty()) - TheGameSpyInfo->sendChat(txtInput, FALSE, NULL); // 'emote' button is now carriage-return - } //if ( controlID == buttonEmote ) - else if ( controlID == buttonSelectMapID ) - { - WOLMapSelectLayout = TheWindowManager->winCreateLayout( "Menus/WOLMapSelectMenu.wnd" ); - WOLMapSelectLayout->runInit(); - WOLMapSelectLayout->hide( FALSE ); - WOLMapSelectLayout->bringForward(); - } - else if ( controlID == buttonStartID ) - { - savePlayerInfo(); - if (TheGameSpyInfo->amIHost()) - { - StartPressed(); - } - else - { - //I'm the Client... send an accept message to the host. - GameSlot *localSlot = TheGameSpyInfo->getCurrentStagingRoom()->getSlot(TheGameSpyInfo->getCurrentStagingRoom()->getLocalSlotNum()); - if (localSlot) - { - localSlot->setAccept(); - } - UnicodeString hostName = TheGameSpyInfo->getCurrentStagingRoom()->getSlot(0)->getName(); - AsciiString asciiName; - asciiName.translate(hostName); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - req.id = "accept"; - req.nick = asciiName.str(); - req.options = "true"; - TheGameSpyPeerMessageQueue->addRequest(req); - //peerSetReady( PEER, PEERTrue ); - WOLDisplaySlotList(); - } - } - else if ( controlID == checkBoxLimitSuperweaponsID ) - { - handleLimitSuperweaponsClick(); - } - else - { - for (Int i = 0; i < MAX_SLOTS; i++) - { - if (controlID == buttonMapStartPositionID[i]) - { - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - Int playerIdxInPos = -1; - for (Int j=0; jgetGameSpySlot(j); - if (slot && slot->getStartPos() == i) - { - playerIdxInPos = j; - break; - } - } - if (playerIdxInPos >= 0) - { - GameSpyGameSlot *slot = game->getGameSpySlot(playerIdxInPos); - if (playerIdxInPos == game->getLocalSlotNum() || (game->amIHost() && slot && slot->isAI())) - { - // it's one of my type. Try to change it. - Int nextPlayer = getNextSelectablePlayer(playerIdxInPos+1); - handleStartPositionSelection(playerIdxInPos, -1); - if (nextPlayer >= 0) - { - handleStartPositionSelection(nextPlayer, i); - } - } - } - else - { - // nobody in the slot - put us in - Int nextPlayer = getNextSelectablePlayer(0); - if (nextPlayer < 0) - nextPlayer = getFirstSelectablePlayer(game); - handleStartPositionSelection(nextPlayer, i); - } - } - } - } - - - break; - }// case GBM_SELECTED: - //------------------------------------------------------------------------------------------------- - case GBM_SELECTED_RIGHT: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - for (Int i = 0; i < MAX_SLOTS; i++) - { - if (controlID == buttonMapStartPositionID[i]) - { - GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom(); - Int playerIdxInPos = -1; - for (Int j=0; jgetGameSpySlot(j); - if (slot && slot->getStartPos() == i) - { - playerIdxInPos = j; - break; - } - } - if (playerIdxInPos >= 0) - { - GameSpyGameSlot *slot = game->getGameSpySlot(playerIdxInPos); - if (playerIdxInPos == game->getLocalSlotNum() || (game->amIHost() && slot && slot->isAI())) - { - // it's one of my type. Remove it. - handleStartPositionSelection(playerIdxInPos, -1); - } - } - } - } - break; - } - - //------------------------------------------------------------------------------------------------- - case GEM_EDIT_DONE: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - // Take the user's input and echo it into the chat window as well as - // send it to the other clients on the lan - if ( controlID == textEntryChatID ) - { - - // read the user's input - txtInput.set(GadgetTextEntryGetText( textEntryChat )); - // Clear the text entry line - GadgetTextEntrySetText(textEntryChat, UnicodeString::TheEmptyString); - // Clean up the text (remove leading/trailing chars, etc) - txtInput.trim(); - // Echo the user's input to the chat window - if (!txtInput.isEmpty()) - { - if (!handleGameSetupSlashCommands(txtInput)) - { - TheGameSpyInfo->sendChat(txtInput, false, NULL); - } - } - - }// if ( controlID == textEntryChatID ) - break; - } - //------------------------------------------------------------------------------------------------- - default: - return MSG_IGNORED; - }//Switch - return MSG_HANDLED; -}//WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg, - - diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLadderScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLadderScreen.cpp deleted file mode 100644 index 95899d4850e..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLadderScreen.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: ReplayMenu.cpp ///////////////////////////////////////////////////////////////////// -// Author: Chris The masta Huybregts, December 2001 -// Description: Replay Menus -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/MessageBox.h" - -// window ids ------------------------------------------------------------------------------------- -static NameKeyType parentWindowID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; -static NameKeyType windowLadderID = NAMEKEY_INVALID; - - -// window pointers -------------------------------------------------------------------------------- -static GameWindow *parentWindow = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *windowLadder = NULL; - - -//------------------------------------------------------------------------------------------------- -/** Initialize the single player menu */ -//------------------------------------------------------------------------------------------------- -void WOLLadderScreenInit( WindowLayout *layout, void *userData ) -{ - TheShell->showShellMap(TRUE); - - // get ids for our children controls - parentWindowID = TheNameKeyGenerator->nameToKey( AsciiString("WOLLadderScreen.wnd:LadderParent") ); - buttonBackID = TheNameKeyGenerator->nameToKey( AsciiString("WOLLadderScreen.wnd:ButtonBack") ); - windowLadderID = TheNameKeyGenerator->nameToKey( AsciiString("WOLLadderScreen.wnd:WindowLadder") ); - - parentWindow = TheWindowManager->winGetWindowFromId( NULL, parentWindowID ); - buttonBack = TheWindowManager->winGetWindowFromId( parentWindow, buttonBackID ); - windowLadder = TheWindowManager->winGetWindowFromId( parentWindow, windowLadderID ); - - //Load the listbox shiznit -// PopulateReplayFileListbox(listboxReplayFiles); - - // show menu - layout->hide( FALSE ); - - // set keyboard focus to main parent - TheWindowManager->winSetFocus( parentWindow ); - -} // end ReplayMenuInit - -//------------------------------------------------------------------------------------------------- -/** single player menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLLadderScreenShutdown( WindowLayout *layout, void *userData ) -{ - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); - -} // end ReplayMenuShutdown - -//------------------------------------------------------------------------------------------------- -/** single player menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLLadderScreenUpdate( WindowLayout *layout, void *userData ) -{ - -} // end ReplayMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** Replay menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLadderScreenInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; - -} // end ReplayMenuInput - -//------------------------------------------------------------------------------------------------- -/** single player menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLadderScreenSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CREATE: - { - - - break; - - } // end create - - //--------------------------------------------------------------------------------------------- - case GWM_DESTROY: - { - - break; - - } // end case - - // -------------------------------------------------------------------------------------------- - case GWM_INPUT_FOCUS: - { - - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - - } // end input - //--------------------------------------------------------------------------------------------- - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if( controlID == buttonBackID ) - { - - // thou art directed to return to thy known solar system immediately! - TheShell->pop(); - - } // end else if - - break; - - } // end selected - - default: - return MSG_IGNORED; - } // end switch - - return MSG_HANDLED; -} // end ReplayMenuSystem - diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp deleted file mode 100644 index 6d4fb2c52e4..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp +++ /dev/null @@ -1,1876 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLLobbyMenu.cpp -// Author: Chris Huybregts, November 2001 -// Description: WOL Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "Common/GameState.h" -#include "Common/MiniLog.h" -#include "Common/MultiplayerSettings.h" -#include "Common/PlayerTemplate.h" -#include "Common/CustomMatchPreferences.h" -#include "Common/Version.h" -#include "GameClient/AnimateWindowManager.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GameClient.h" -#include "GameClient/Shell.h" -#include "GameClient/ShellHooks.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetComboBox.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetSlider.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GameText.h" -#include "GameClient/MessageBox.h" -#include "GameClient/Mouse.h" -#include "GameClient/Display.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameClient/GameWindowTransitions.h" - -#include "GameLogic/GameLogic.h" - -#include "GameClient/LanguageFilter.h" -#include "GameNetwork/GameSpy/BuddyDefs.h" -#include "GameNetwork/GameSpy/GSConfig.h" -#include "GameNetwork/GameSpy/LadderDefs.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" -#include "GameNetwork/GameSpy/LobbyUtils.h" -#include "GameNetwork/RankPointValue.h" - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif -void refreshGameList( Bool forceRefresh = FALSE ); -void refreshPlayerList( Bool forceRefresh = FALSE ); - -#ifdef DEBUG_LOGGING -#define PERF_TEST -static LogClass s_perfLog("Perf.txt"); -#define PERF_LOG(x) s_perfLog.log x -#else // DEBUG_LOGGING -#define PERF_LOG(x) {} -#endif // DEBUG_LOGGING - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -static Bool isShuttingDown = false; -static Bool buttonPushed = false; -static char *nextScreen = NULL; -static Bool raiseMessageBoxes = false; -static time_t gameListRefreshTime = 0; -static const time_t gameListRefreshInterval = 10000; -static time_t playerListRefreshTime = 0; -static const time_t playerListRefreshInterval = 5000; - -void setUnignoreText( WindowLayout *layout, AsciiString nick, GPProfile id); -static void doSliderTrack(GameWindow *control, Int val); -Bool DontShowMainMenu = FALSE; -enum { COLUMN_PLAYERNAME = 1 }; - -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLLobbyID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; -static NameKeyType buttonHostID = NAMEKEY_INVALID; -static NameKeyType buttonRefreshID = NAMEKEY_INVALID; -static NameKeyType buttonJoinID = NAMEKEY_INVALID; -static NameKeyType buttonBuddyID = NAMEKEY_INVALID; -static NameKeyType buttonEmoteID = NAMEKEY_INVALID; -static NameKeyType textEntryChatID = NAMEKEY_INVALID; -static NameKeyType listboxLobbyPlayersID = NAMEKEY_INVALID; -static NameKeyType listboxLobbyChatID = NAMEKEY_INVALID; -static NameKeyType comboLobbyGroupRoomsID = NAMEKEY_INVALID; -//static NameKeyType // sliderChatAdjustID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLLobby = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *buttonHost = NULL; -static GameWindow *buttonRefresh = NULL; -static GameWindow *buttonJoin = NULL; -static GameWindow *buttonBuddy = NULL; -static GameWindow *buttonEmote = NULL; -static GameWindow *textEntryChat = NULL; -static GameWindow *listboxLobbyPlayers = NULL; -static GameWindow *listboxLobbyChat = NULL; -static GameWindow *comboLobbyGroupRooms = NULL; -static GameWindow *parent = NULL; - -static Int groupRoomToJoin = 0; -static Int initialGadgetDelay = 2; -static Bool justEntered = FALSE; - -#if defined(_INTERNAL) || defined(_DEBUG) -Bool g_fakeCRC = FALSE; -Bool g_debugSlots = FALSE; -#endif - -std::list TheLobbyQueuedUTMs; - -// Slash commands ------------------------------------------------------------------------- -//extern "C" { -//int getQR2HostingStatus(void); -//} -extern int isThreadHosting; - -Bool handleLobbySlashCommands(UnicodeString uText) -{ - AsciiString message; - message.translate(uText); - - if (message.getCharAt(0) != '/') - { - return FALSE; // not a slash command - } - - AsciiString remainder = message.str() + 1; - AsciiString token; - remainder.nextToken(&token); - token.toLower(); - - if (token == "host") - { - UnicodeString s; - s.format(L"Hosting qr2:%d thread:%d", 0, isThreadHosting); - TheGameSpyInfo->addText(s, GameSpyColor[GSCOLOR_DEFAULT], NULL); - return TRUE; // was a slash command - } - else if (token == "me" && uText.getLength()>4) - { - TheGameSpyInfo->sendChat(UnicodeString(uText.str()+4), TRUE, listboxLobbyPlayers); - return TRUE; // was a slash command - } - else if (token == "refresh") - { - // Added 2/19/03 added the game refresh - refreshGameList(TRUE); - refreshPlayerList(TRUE); - return TRUE; // was a slash command - } - /* - if (token == "togglegamelist") - { - NameKeyType buttonID = NAMEKEY("WOLCustomLobby.wnd:ButtonGameListToggle"); - GameWindow *button = TheWindowManager->winGetWindowFromId(parent, buttonID); - if (button) - { - button->winHide(!button->winIsHidden()); - } - return TRUE; // was a slash command - } - else if (token == "adjustchat") - { - NameKeyType sliderID = NAMEKEY("WOLCustomLobby.wnd:SliderChatAdjust"); - GameWindow *slider = TheWindowManager->winGetWindowFromId(parent, sliderID); - if (slider) - { - slider->winHide(!slider->winIsHidden()); - } - return TRUE; // was a slash command - } - */ -#if defined(_INTERNAL) || defined(_DEBUG) - else if (token == "fakecrc") - { - g_fakeCRC = !g_fakeCRC; - TheGameSpyInfo->addText(UnicodeString(L"Toggled CRC fakery"), GameSpyColor[GSCOLOR_DEFAULT], NULL); - return TRUE; // was a slash command - } - else if (token == "slots") - { - g_debugSlots = !g_debugSlots; - TheGameSpyInfo->addText(UnicodeString(L"Toggled SlotList debug"), GameSpyColor[GSCOLOR_DEFAULT], NULL); - return TRUE; // was a slash command - } -#endif - - return FALSE; // not a slash command -} - -static Bool s_tryingToHostOrJoin = FALSE; -void SetLobbyAttemptHostJoin(Bool start) -{ - s_tryingToHostOrJoin = start; -} - -// Tooltips ------------------------------------------------------------------------------- - -static void playerTooltip(GameWindow *window, - WinInstanceData *instData, - UnsignedInt mouse) -{ - Int x, y, row, col; - x = LOLONGTOSHORT(mouse); - y = HILONGTOSHORT(mouse); - - GadgetListBoxGetEntryBasedOnXY(window, x, y, row, col); - - if (row == -1 || col == -1) - { - TheMouse->setCursorTooltip( UnicodeString::TheEmptyString);//TheGameText->fetch("TOOLTIP:PlayersInLobby") ); - return; - } - - UnicodeString uName = GadgetListBoxGetText(window, row, COLUMN_PLAYERNAME); - AsciiString aName; - aName.translate(uName); - - PlayerInfoMap::iterator it = TheGameSpyInfo->getPlayerInfoMap()->find(aName); - PlayerInfo *info = &(it->second); - Bool isLocalPlayer = (TheGameSpyInfo->getLocalName().compareNoCase(info->m_name) == 0); - - if (col == 0) - { - if (info->m_preorder) - { - TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:LobbyOfficersClub") ); - } - else - { - TheMouse->setCursorTooltip( UnicodeString::TheEmptyString); - } - return; - } - - AsciiString playerLocale = info->m_locale; - AsciiString localeIdentifier; - localeIdentifier.format("WOL:Locale%2.2d", atoi(playerLocale.str())); - Int playerWins = info->m_wins; - Int playerLosses = info->m_losses; - UnicodeString playerInfo; - playerInfo.format(TheGameText->fetch("TOOLTIP:PlayerInfo"), TheGameText->fetch(localeIdentifier).str(), playerWins, playerLosses); - - UnicodeString tooltip = UnicodeString::TheEmptyString;//TheGameText->fetch("TOOLTIP:PlayersInLobby"); - if (isLocalPlayer) - { - tooltip.format(TheGameText->fetch("TOOLTIP:LocalPlayer"), uName.str()); - } - else - { - // not us - if (TheGameSpyInfo->getBuddyMap()->find(info->m_profileID) != TheGameSpyInfo->getBuddyMap()->end()) - { - // buddy - tooltip.format(TheGameText->fetch("TOOLTIP:BuddyPlayer"), uName.str()); - } - else - { - if (info->m_profileID) - { - // non-buddy profiled player - tooltip.format(TheGameText->fetch("TOOLTIP:ProfiledPlayer"), uName.str()); - } - else - { - // non-profiled player - tooltip.format(TheGameText->fetch("TOOLTIP:GenericPlayer"), uName.str()); - } - } - } - - if (info->isIgnored()) - { - tooltip.concat(TheGameText->fetch("TOOLTIP:IgnoredModifier")); - } - - if (info->m_profileID) - { - tooltip.concat(playerInfo); - } - - Int rank = 0; - Int i = 0; - while( info->m_rankPoints >= TheRankPointValues->m_ranks[i + 1]) - ++i; - rank = i; - AsciiString sideName = "GUI:RandomSide"; - if (info->m_side > 0) - { - const PlayerTemplate *fac = ThePlayerTemplateStore->getNthPlayerTemplate(info->m_side); - if (fac) - { - sideName.format("SIDE:%s", fac->getSide().str()); - } - } - AsciiString rankName; - rankName.format("GUI:GSRank%d", rank); - UnicodeString tmp; - tmp.format(L"\n%ls %ls", TheGameText->fetch(sideName).str(), TheGameText->fetch(rankName).str()); - tooltip.concat(tmp); - - TheMouse->setCursorTooltip( tooltip, -1, NULL, 1.5f ); // the text and width are the only params used. the others are the default values. -} - -static void populateGroupRoomListbox(GameWindow *lb) -{ - if (!lb) - return; - - GadgetComboBoxReset(lb); - Int indexToSelect = -1; - GroupRoomMap::iterator iter; - - // now populate the combo box - for (iter = TheGameSpyInfo->getGroupRoomList()->begin(); iter != TheGameSpyInfo->getGroupRoomList()->end(); ++iter) - { - GameSpyGroupRoom room = iter->second; - if (room.m_groupID != TheGameSpyConfig->getQMChannel()) - { - DEBUG_LOG(("populateGroupRoomListbox(): groupID %d\n", room.m_groupID)); - if (room.m_groupID == TheGameSpyInfo->getCurrentGroupRoom()) - { - Int selected = GadgetComboBoxAddEntry(lb, room.m_translatedName, GameSpyColor[GSCOLOR_CURRENTROOM]); - GadgetComboBoxSetItemData(lb, selected, (void *)(room.m_groupID)); - indexToSelect = selected; - } - else - { - Int selected = GadgetComboBoxAddEntry(lb, room.m_translatedName, GameSpyColor[GSCOLOR_ROOM]); - GadgetComboBoxSetItemData(lb, selected, (void *)(room.m_groupID)); - } - } - else - { - DEBUG_LOG(("populateGroupRoomListbox(): skipping QM groupID %d\n", room.m_groupID)); - } - } - - GadgetComboBoxSetSelectedPos(lb, indexToSelect); -} - -static const char *rankNames[] = { - "Private", - "Corporal", - "Sergeant", - "Lieutenant", - "Captain", - "Major", - "Colonel", - "General", - "Brigadier", - "Commander", -}; - -const Image* LookupSmallRankImage(Int side, Int rankPoints) -{ - if (rankPoints == 0) - return NULL; - - Int rank = 0; - Int i = 0; - while( rankPoints >= TheRankPointValues->m_ranks[i + 1]) - ++i; - rank = i; - - if (rank < 0 || rank >= 10) - return NULL; - - AsciiString sideStr = "N"; - switch(side) - { - case 2: //USA - case 5: //Super Weapon - case 6: //Laser - case 7: //Air Force - sideStr = "USA"; - break; - - case 3: //China - case 8: //Tank - case 9: //Infantry - case 10: //Nuke - sideStr = "CHA"; - break; - - case 4: //GLA - case 11: //Toxin - case 12: //Demolition - case 13: //Stealth - sideStr = "GLA"; - break; - } - - AsciiString fullImageName; - fullImageName.format("%s-%s", rankNames[rank], sideStr.str()); - const Image *img = TheMappedImageCollection->findImageByName(fullImageName); - DEBUG_ASSERTLOG(img, ("*** Could not load small rank image '%s' from TheMappedImageCollection!\n", fullImageName.str())); - return img; -} - -static Int insertPlayerInListbox(const PlayerInfo& info, Color color) -{ - UnicodeString uStr; - uStr.translate(info.m_name); - - Int currentRank = info.m_rankPoints; - Int currentSide = info.m_side; - /* since PersistentStorage updates now update PlayerInfo, we don't need this. - if (info.m_profileID) - { - PSPlayerStats psStats = TheGameSpyPSMessageQueue->findPlayerStatsByID(info.m_profileID); - if (psStats.id) - { - currentRank = CalculateRank(psStats); - - PerGeneralMap::iterator it; - Int numGames = 0; - for(it = psStats.games.begin(); it != psStats.games.end(); ++it) - { - if(it->second >= numGames) - { - numGames = it->second; - currentSide = it->first; - } - } - if(numGames == 0 || psStats.gamesAsRandom >= numGames ) - { - currentSide = 0; - } - } - } - */ - - Bool isPreorder = TheGameSpyInfo->didPlayerPreorder(info.m_profileID); - - const Image *preorderImg = TheMappedImageCollection->findImageByName("OfficersClubsmall"); - Int w = (preorderImg)?preorderImg->getImageWidth():10; - //Int h = (preorderImg)?preorderImg->getImageHeight():10; - w = min(GadgetListBoxGetColumnWidth(listboxLobbyPlayers, 0), w); - Int h = w; - if (!isPreorder) - preorderImg = NULL; - - const Image *rankImg = LookupSmallRankImage(currentSide, currentRank); - -#if 0 //Officer's Club (preorder image) no longer used in Zero Hour - Int index = GadgetListBoxAddEntryImage(listboxLobbyPlayers, preorderImg, -1, 0, w, h); - GadgetListBoxAddEntryImage(listboxLobbyPlayers, rankImg, index, 1, w, h); - GadgetListBoxAddEntryText(listboxLobbyPlayers, uStr, color, index, 2); -#else - Int index = GadgetListBoxAddEntryImage(listboxLobbyPlayers, rankImg, -1, 0, w, h); - GadgetListBoxAddEntryText(listboxLobbyPlayers, uStr, color, index, 1); -#endif - return index; -} - - -void PopulateLobbyPlayerListbox(void) -{ - - if (!listboxLobbyPlayers) - return; - - // Display players - PlayerInfoMap *players = TheGameSpyInfo->getPlayerInfoMap(); - PlayerInfoMap::iterator it; - BuddyInfoMap *buddies = TheGameSpyInfo->getBuddyMap(); - BuddyInfoMap::iterator bIt; - if (listboxLobbyPlayers) - { - // save off old selection - Int maxSelectedItems = GadgetListBoxGetNumEntries(listboxLobbyPlayers); - Int *selectedIndices; - GadgetListBoxGetSelected(listboxLobbyPlayers, (Int *)(&selectedIndices)); - std::set selectedNames; - std::set::const_iterator selIt; - std::set indicesToSelect; - UnicodeString uStr; - Int numSelected = 0; - for (Int i=0; ibegin(); it != players->end(); ++it) - { - PlayerInfo info = it->second; - if (info.m_flags & PEER_FLAG_OP || TheGameSpyConfig->isPlayerVIP(info.m_profileID)) - { - Int index = insertPlayerInListbox(info, info.isIgnored()?GameSpyColor[GSCOLOR_PLAYER_IGNORED]:GameSpyColor[GSCOLOR_PLAYER_OWNER]); - - selIt = selectedNames.find(info.m_name); - if (selIt != selectedNames.end()) - { - DEBUG_LOG(("Marking index %d (%s) to re-select\n", index, info.m_name.str())); - indicesToSelect.insert(index); - } - } - } - - // Buddies - for (it = players->begin(); it != players->end(); ++it) - { - PlayerInfo info = it->second; - bIt = buddies->find(info.m_profileID); - if ( !(info.m_flags & PEER_FLAG_OP || TheGameSpyConfig->isPlayerVIP(info.m_profileID)) && bIt != buddies->end() ) - { - Int index = insertPlayerInListbox(info, info.isIgnored()?GameSpyColor[GSCOLOR_PLAYER_IGNORED]:GameSpyColor[GSCOLOR_PLAYER_BUDDY]); - - selIt = selectedNames.find(info.m_name); - if (selIt != selectedNames.end()) - { - DEBUG_LOG(("Marking index %d (%s) to re-select\n", index, info.m_name.str())); - indicesToSelect.insert(index); - } - } - } - - // Everyone else - for (it = players->begin(); it != players->end(); ++it) - { - PlayerInfo info = it->second; - bIt = buddies->find(info.m_profileID); - if ( !(info.m_flags & PEER_FLAG_OP || TheGameSpyConfig->isPlayerVIP(info.m_profileID)) && bIt == buddies->end() ) - { - Int index = insertPlayerInListbox(info, info.isIgnored()?GameSpyColor[GSCOLOR_PLAYER_IGNORED]:GameSpyColor[GSCOLOR_PLAYER_NORMAL]); - - selIt = selectedNames.find(info.m_name); - if (selIt != selectedNames.end()) - { - DEBUG_LOG(("Marking index %d (%s) to re-select\n", index, info.m_name.str())); - indicesToSelect.insert(index); - } - } - } - - // restore selection - if (indicesToSelect.size()) - { - std::set::const_iterator indexIt; - Int *newIndices = NEW Int[indicesToSelect.size()]; - for (i=0, indexIt = indicesToSelect.begin(); indexIt != indicesToSelect.end(); ++i, ++indexIt) - { - newIndices[i] = *indexIt; - DEBUG_LOG(("Queueing up index %d to re-select\n", *indexIt)); - } - GadgetListBoxSetSelected(listboxLobbyPlayers, newIndices, indicesToSelect.size()); - delete[] newIndices; - } - - if (indicesToSelect.size() != numSelected) - { - TheWindowManager->winSetLoneWindow(NULL); - } - - // restore top visible entry - GadgetListBoxSetTopVisibleEntry(listboxLobbyPlayers, previousTopIndex); - } - -} - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Lobby Menu */ -//------------------------------------------------------------------------------------------------- -void WOLLobbyMenuInit( WindowLayout *layout, void *userData ) -{ - nextScreen = NULL; - buttonPushed = false; - isShuttingDown = false; - - SetLobbyAttemptHostJoin(FALSE); // not trying to host or join - - gameListRefreshTime = 0; - playerListRefreshTime = 0; - - parentWOLLobbyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLCustomLobby.wnd:WOLLobbyMenuParent" ) ); - parent = TheWindowManager->winGetWindowFromId(NULL, parentWOLLobbyID); - - buttonBackID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonBack")); - buttonBack = TheWindowManager->winGetWindowFromId(parent, buttonBackID); - - buttonHostID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonHost")); - buttonHost = TheWindowManager->winGetWindowFromId(parent, buttonHostID); - - buttonRefreshID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonRefresh")); - buttonRefresh = TheWindowManager->winGetWindowFromId(parent, buttonRefreshID); - - buttonJoinID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonJoin")); - buttonJoin = TheWindowManager->winGetWindowFromId(parent, buttonJoinID); - buttonJoin->winEnable(FALSE); - - buttonBuddyID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonBuddy")); - buttonBuddy = TheWindowManager->winGetWindowFromId(parent, buttonBuddyID); - - buttonEmoteID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ButtonEmote")); - buttonEmote = TheWindowManager->winGetWindowFromId(parent, buttonEmoteID); - - textEntryChatID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:TextEntryChat")); - textEntryChat = TheWindowManager->winGetWindowFromId(parent, textEntryChatID); - - listboxLobbyPlayersID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ListboxPlayers")); - listboxLobbyPlayers = TheWindowManager->winGetWindowFromId(parent, listboxLobbyPlayersID); - listboxLobbyPlayers->winSetTooltipFunc(playerTooltip); - - listboxLobbyChatID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ListboxChat")); - listboxLobbyChat = TheWindowManager->winGetWindowFromId(parent, listboxLobbyChatID); - TheGameSpyInfo->registerTextWindow(listboxLobbyChat); - - comboLobbyGroupRoomsID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ComboBoxGroupRooms")); - comboLobbyGroupRooms = TheWindowManager->winGetWindowFromId(parent, comboLobbyGroupRoomsID); - - GadgetTextEntrySetText(textEntryChat, UnicodeString.TheEmptyString); - - populateGroupRoomListbox(comboLobbyGroupRooms); - - // Show Menu - layout->hide( FALSE ); - - // if we're not in a room, this will join the best available one - if (!TheGameSpyInfo->getCurrentGroupRoom()) - { - if (groupRoomToJoin) - { - DEBUG_LOG(("WOLLobbyMenuInit() - rejoining group room %d\n", groupRoomToJoin)); - TheGameSpyInfo->joinGroupRoom(groupRoomToJoin); - groupRoomToJoin = 0; - } - else - { - DEBUG_LOG(("WOLLobbyMenuInit() - joining best group room\n")); - TheGameSpyInfo->joinBestGroupRoom(); - } - } - else - { - DEBUG_LOG(("WOLLobbyMenuInit() - not joining group room because we're already in one\n")); - } - - GrabWindowInfo(); - - TheGameSpyInfo->clearStagingRoomList(); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STARTGAMELIST; - req.gameList.restrictGameList = TheGameSpyConfig->restrictGamesToLobby(); - TheGameSpyPeerMessageQueue->addRequest(req); - - // animate controls -// TheShell->registerWithAnimateManager(parent, WIN_ANIMATION_SLIDE_TOP, TRUE); - TheShell->showShellMap(TRUE); - TheGameSpyGame->reset(); - - CustomMatchPreferences pref; -// GameWindow *slider = TheWindowManager->winGetWindowFromId(parent, sliderChatAdjustID); -// if (slider) -// { -// GadgetSliderSetPosition(slider, pref.getChatSizeSlider()); -// doSliderTrack(slider, pref.getChatSizeSlider()); -// } -// - if (pref.usesLongGameList()) - { - ToggleGameListType(); - } - - // Set Keyboard to chat window - TheWindowManager->winSetFocus( textEntryChat ); - raiseMessageBoxes = true; - - TheLobbyQueuedUTMs.clear(); - justEntered = TRUE; - initialGadgetDelay = 2; - GameWindow *win = TheWindowManager->winGetWindowFromId(NULL, TheNameKeyGenerator->nameToKey("WOLCustomLobby.wnd:GadgetParent")); - if(win) - win->winHide(TRUE); - DontShowMainMenu = TRUE; - -} // WOLLobbyMenuInit - -//------------------------------------------------------------------------------------------------- -/** This is called when a shutdown is complete for this menu */ -//------------------------------------------------------------------------------------------------- -static void shutdownComplete( WindowLayout *layout ) -{ - - isShuttingDown = false; - - // hide the layout - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout, (nextScreen != NULL) ); - - if (nextScreen != NULL) - { - TheShell->push(nextScreen); - } - - nextScreen = NULL; - -} // end if - -//------------------------------------------------------------------------------------------------- -/** WOL Lobby Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLLobbyMenuShutdown( WindowLayout *layout, void *userData ) -{ - CustomMatchPreferences pref; -// GameWindow *slider = TheWindowManager->winGetWindowFromId(parent, sliderChatAdjustID); -// if (slider) -// { -// pref.setChatSizeSlider(GadgetSliderGetPosition(slider)); -// } - if (GetGameInfoListBox()) - { - pref.setUsesLongGameList(FALSE); - } - else - { - pref.setUsesLongGameList(TRUE); - } - pref.write(); - - ReleaseWindowInfo(); - - TheGameSpyInfo->unregisterTextWindow(listboxLobbyChat); - - //TheGameSpyChat->stopListingGames(); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STOPGAMELIST; - TheGameSpyPeerMessageQueue->addRequest(req); - - listboxLobbyChat = NULL; - listboxLobbyPlayers = NULL; - - isShuttingDown = true; - - // if we are shutting down for an immediate pop, skip the animations - Bool popImmediate = *(Bool *)userData; - if( popImmediate ) - { - - shutdownComplete( layout ); - return; - - } //end if - - TheShell->reverseAnimatewindow(); - DontShowMainMenu = FALSE; - - RaiseGSMessageBox(); - TheTransitionHandler->reverse("WOLCustomLobbyFade"); - -} // WOLLobbyMenuShutdown - -static void fillPlayerInfo(const PeerResponse *resp, PlayerInfo *info) -{ - info->m_name = resp->nick.c_str(); - info->m_profileID = resp->player.profileID; - info->m_flags = resp->player.flags; - info->m_wins = resp->player.wins; - info->m_losses = resp->player.losses; - info->m_locale = resp->locale.c_str(); - info->m_rankPoints= resp->player.rankPoints; - info->m_side = resp->player.side; - info->m_preorder = resp->player.preorder; -} - -#ifdef PERF_TEST -static const char* getMessageString(Int t) -{ - switch(t) - { - case PeerResponse::PEERRESPONSE_LOGIN: - return "login"; - case PeerResponse::PEERRESPONSE_DISCONNECT: - return "disconnect"; - case PeerResponse::PEERRESPONSE_MESSAGE: - return "message"; - case PeerResponse::PEERRESPONSE_GROUPROOM: - return "group room"; - case PeerResponse::PEERRESPONSE_STAGINGROOM: - return "staging room"; - case PeerResponse::PEERRESPONSE_STAGINGROOMPLAYERINFO: - return "staging room player info"; - case PeerResponse::PEERRESPONSE_JOINGROUPROOM: - return "group room join"; - case PeerResponse::PEERRESPONSE_CREATESTAGINGROOM: - return "staging room create"; - case PeerResponse::PEERRESPONSE_JOINSTAGINGROOM: - return "staging room join"; - case PeerResponse::PEERRESPONSE_PLAYERJOIN: - return "player join"; - case PeerResponse::PEERRESPONSE_PLAYERLEFT: - return "player part"; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDNICK: - return "player nick"; - case PeerResponse::PEERRESPONSE_PLAYERINFO: - return "player info"; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDFLAGS: - return "player flags"; - case PeerResponse::PEERRESPONSE_ROOMUTM: - return "room UTM"; - case PeerResponse::PEERRESPONSE_PLAYERUTM: - return "player UTM"; - case PeerResponse::PEERRESPONSE_QUICKMATCHSTATUS: - return "QM status"; - case PeerResponse::PEERRESPONSE_GAMESTART: - return "game start"; - case PeerResponse::PEERRESPONSE_FAILEDTOHOST: - return "host failure"; - } - return "unknown"; -} -#endif // PERF_TEST - -//------------------------------------------------------------------------------------------------- -/** refreshGameList - The Bool is used to force refresh if the refresh button was hit.*/ -//------------------------------------------------------------------------------------------------- -static void refreshGameList( Bool forceRefresh ) -{ - Int refreshInterval = gameListRefreshInterval; - - if (forceRefresh || ((gameListRefreshTime == 0) || ((gameListRefreshTime + refreshInterval) <= timeGetTime()))) - { - if (TheGameSpyInfo->hasStagingRoomListChanged()) - { - //DEBUG_LOG(("################### refreshing game list\n")); - //DEBUG_LOG(("gameRefreshTime=%d, refreshInterval=%d, now=%d\n", gameListRefreshTime, refreshInterval, timeGetTime())); - RefreshGameListBoxes(); - gameListRefreshTime = timeGetTime(); - } else { - //DEBUG_LOG(("-")); - } - } else { - //DEBUG_LOG(("gameListRefreshTime: %d refreshInterval: %d\n")); - } -} -//------------------------------------------------------------------------------------------------- -/** refreshPlayerList - The Bool is used to force refresh if the refresh button was hit.*/ -//------------------------------------------------------------------------------------------------- -static void refreshPlayerList( Bool forceRefresh ) -{ - Int refreshInterval = playerListRefreshInterval; - - if (forceRefresh ||((playerListRefreshTime == 0) || ((playerListRefreshTime + refreshInterval) <= timeGetTime()))) - { - PopulateLobbyPlayerListbox(); - playerListRefreshTime = timeGetTime(); - } -} -//------------------------------------------------------------------------------------------------- -/** WOL Lobby Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLLobbyMenuUpdate( WindowLayout * layout, void *userData) -{ - if(justEntered) - { - if(initialGadgetDelay == 1) - { - TheTransitionHandler->remove("MainMenuDefaultMenuLogoFade"); - TheTransitionHandler->setGroup("WOLCustomLobbyFade"); - initialGadgetDelay = 2; - justEntered = FALSE; - } - else - initialGadgetDelay--; - } - if (TheGameLogic->isInShellGame() && TheGameLogic->getFrame() == 1) - { - SignalUIInteraction(SHELL_SCRIPT_HOOK_GENERALS_ONLINE_ENTERED_FROM_GAME); - } - - - // We'll only be successful if we've requested to - if(isShuttingDown && TheShell->isAnimFinished() && TheTransitionHandler->isFinished()) - shutdownComplete(layout); - - if (raiseMessageBoxes) - { - RaiseGSMessageBox(); - raiseMessageBoxes = false; - } - - if (TheShell->isAnimFinished() && TheTransitionHandler->isFinished() && !buttonPushed && TheGameSpyPeerMessageQueue) - { - HandleBuddyResponses(); - HandlePersistentStorageResponses(); - -#ifdef PERF_TEST - UnsignedInt start = timeGetTime(); - UnsignedInt end = timeGetTime(); - std::list responses; - Int numMessages = 0; -#endif // PERF_TEST - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - Bool shouldRepopulatePlayers = FALSE; - PeerResponse resp; - while (allowedMessages-- && !sawImportantMessage && TheGameSpyPeerMessageQueue->getResponse( resp )) - { -#ifdef PERF_TEST - ++numMessages; - responses.push_back(resp.peerResponseType); -#endif // PERF_TEST - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_JOINGROUPROOM: - sawImportantMessage = TRUE; - if (resp.joinGroupRoom.ok) - { - //buttonPushed = true; - TheGameSpyInfo->setCurrentGroupRoom(resp.joinGroupRoom.id); - TheGameSpyInfo->getPlayerInfoMap()->clear(); - GroupRoomMap::iterator iter = TheGameSpyInfo->getGroupRoomList()->find(resp.joinGroupRoom.id); - if (iter != TheGameSpyInfo->getGroupRoomList()->end()) - { - GameSpyGroupRoom room = iter->second; - UnicodeString msg; - msg.format(TheGameText->fetch("GUI:LobbyJoined"), room.m_translatedName.str()); - TheGameSpyInfo->addText(msg, GameSpyColor[GSCOLOR_DEFAULT], NULL); - } - } - else - { - DEBUG_LOG(("WOLLobbyMenuUpdate() - joining best group room\n")); - TheGameSpyInfo->joinBestGroupRoom(); - } - populateGroupRoomListbox(comboLobbyGroupRooms); - shouldRepopulatePlayers = TRUE; - break; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDFLAGS: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - shouldRepopulatePlayers = TRUE; - } - break; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDNICK: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - shouldRepopulatePlayers = TRUE; - } - break; - case PeerResponse::PEERRESPONSE_PLAYERINFO: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - shouldRepopulatePlayers = TRUE; - } - break; - case PeerResponse::PEERRESPONSE_PLAYERJOIN: - { - if (resp.player.roomType == GroupRoom) - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->updatePlayerInfo(p); - shouldRepopulatePlayers = TRUE; - } - } - break; - case PeerResponse::PEERRESPONSE_PLAYERUTM: - case PeerResponse::PEERRESPONSE_ROOMUTM: - { - DEBUG_LOG(("Putting off a UTM in the lobby\n")); - TheLobbyQueuedUTMs.push_back(resp); - } - break; - case PeerResponse::PEERRESPONSE_PLAYERLEFT: - { - PlayerInfo p; - fillPlayerInfo(&resp, &p); - TheGameSpyInfo->playerLeftGroupRoom(resp.nick.c_str()); - shouldRepopulatePlayers = TRUE; - } - break; - case PeerResponse::PEERRESPONSE_MESSAGE: - { - TheGameSpyInfo->addChat(resp.nick.c_str(), resp.message.profileID, - UnicodeString(resp.text.c_str()), !resp.message.isPrivate, resp.message.isAction, listboxLobbyChat); - } - break; - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheGameSpyInfo->reset(); - TheShell->pop(); - } - case PeerResponse::PEERRESPONSE_CREATESTAGINGROOM: - { - sawImportantMessage = TRUE; - SetLobbyAttemptHostJoin(FALSE); - if (resp.createStagingRoom.result == PEERJoinSuccess) - { - // Woohoo! On to our next screen! - buttonPushed = true; - nextScreen = "Menus/GameSpyGameOptionsMenu.wnd"; - TheShell->pop(); - TheGameSpyInfo->markAsStagingRoomHost(); - TheGameSpyInfo->setGameOptions(); - } - } - break; - case PeerResponse::PEERRESPONSE_JOINSTAGINGROOM: - { - sawImportantMessage = TRUE; - SetLobbyAttemptHostJoin(FALSE); - Bool isHostPresent = TRUE; - if (resp.joinStagingRoom.ok == PEERTrue) - { - GameSpyStagingRoom *room = TheGameSpyInfo->getCurrentStagingRoom(); - if (!room) - { - isHostPresent = FALSE; - } - else - { - isHostPresent = FALSE; - for (Int i=0; igetConstSlot(0)->getName()); - const char *firstPlayer = resp.stagingRoomPlayerNames[i].c_str(); - if (!strcmp(hostName.str(), firstPlayer)) - { - DEBUG_LOG(("Saw host %s == %s in slot %d\n", hostName.str(), firstPlayer, i)); - isHostPresent = TRUE; - } - } - } - } - if (resp.joinStagingRoom.ok == PEERTrue && isHostPresent) - { - // Woohoo! On to our next screen! - buttonPushed = true; - nextScreen = "Menus/GameSpyGameOptionsMenu.wnd"; - TheShell->pop(); - } - else - { - UnicodeString s; - - switch(resp.joinStagingRoom.result) - { - case PEERFullRoom: // The room is full. - s = TheGameText->fetch("GUI:JoinFailedRoomFull"); - break; - case PEERInviteOnlyRoom: // The room is invite only. - s = TheGameText->fetch("GUI:JoinFailedInviteOnly"); - break; - case PEERBannedFromRoom: // The local user is banned from the room. - s = TheGameText->fetch("GUI:JoinFailedBannedFromRoom"); - break; - case PEERBadPassword: // An incorrect password (or none) was given for a passworded room. - s = TheGameText->fetch("GUI:JoinFailedBadPassword"); - break; - case PEERAlreadyInRoom: // The local user is already in or entering a room of the same type. - s = TheGameText->fetch("GUI:JoinFailedAlreadyInRoom"); - break; - case PEERNoConnection: // Can't join a room if there's no chat connection. - s = TheGameText->fetch("GUI:JoinFailedNoConnection"); - break; - default: - s = TheGameText->fetch("GUI:JoinFailedDefault"); - break; - } - GSMessageBoxOk(TheGameText->fetch("GUI:JoinFailedDefault"), s); - if (groupRoomToJoin) - { - DEBUG_LOG(("WOLLobbyMenuUpdate() - rejoining group room %d\n", groupRoomToJoin)); - TheGameSpyInfo->joinGroupRoom(groupRoomToJoin); - groupRoomToJoin = 0; - } - else - { - DEBUG_LOG(("WOLLobbyMenuUpdate() - joining best group room\n")); - TheGameSpyInfo->joinBestGroupRoom(); - } - } - } - break; - case PeerResponse::PEERRESPONSE_STAGINGROOMLISTCOMPLETE: - TheGameSpyInfo->sawFullGameList(); - break; - case PeerResponse::PEERRESPONSE_STAGINGROOM: - { - GameSpyStagingRoom room; - switch(resp.stagingRoom.action) - { - case PEER_CLEAR: - TheGameSpyInfo->clearStagingRoomList(); - //TheGameSpyInfo->addText( UnicodeString(L"gameList: PEER_CLEAR"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - break; - case PEER_ADD: - case PEER_UPDATE: - { - if (resp.stagingRoom.percentComplete == 100) - { - TheGameSpyInfo->sawFullGameList(); - } - - //if (ParseAsciiStringToGameInfo(&room, resp.stagingRoomMapName.c_str())) - //if (ParseAsciiStringToGameInfo(&room, resp.stagingServerGameOptions.c_str())) - Bool serverOk = TRUE; - if (!resp.stagingRoomMapName.length()) - { - serverOk = FALSE; - } - // fix for ghost game problem - need to iterate over all resp.stagingRoomPlayerNames[i] - Bool sawSelf = FALSE; - //for (Int i=0; igetLocalName() == resp.stagingRoomPlayerNames[0].c_str()) - { - sawSelf = TRUE; // don't show ghost games for myself - } - //} - if (sawSelf) - serverOk = FALSE; - - if (serverOk) - { - room.setGameName(UnicodeString(resp.stagingServerName.c_str())); - room.setID(resp.stagingRoom.id); - room.setHasPassword(resp.stagingRoom.requiresPassword); - room.setVersion(resp.stagingRoom.version); - room.setExeCRC(resp.stagingRoom.exeCRC); - room.setIniCRC(resp.stagingRoom.iniCRC); - room.setAllowObservers(resp.stagingRoom.allowObservers); - room.setUseStats(resp.stagingRoom.useStats); - room.setPingString(resp.stagingServerPingString.c_str()); - room.setLadderIP(resp.stagingServerLadderIP.c_str()); - room.setLadderPort(resp.stagingRoom.ladderPort); - room.setReportedNumPlayers(resp.stagingRoom.numPlayers); - room.setReportedMaxPlayers(resp.stagingRoom.maxPlayers); - room.setReportedNumObservers(resp.stagingRoom.numObservers); - - Int i; - AsciiString gsMapName = resp.stagingRoomMapName.c_str(); - AsciiString mapName = ""; - for (i=0; iportableMapPathToRealMapPath(mapName)); - - Int numPlayers = 0; - for (i=0; isetWins( resp.stagingRoom.wins[i] ); - slot->setLosses( resp.stagingRoom.losses[i] ); - slot->setProfileID( resp.stagingRoom.profileID[i] ); - slot->setPlayerTemplate( resp.stagingRoom.faction[i] ); - slot->setColor( resp.stagingRoom.color[i] ); - if (resp.stagingRoom.profileID[i] == SLOT_EASY_AI) - { - slot->setState(SLOT_EASY_AI); - ++numPlayers; - } - else if (resp.stagingRoom.profileID[i] == SLOT_MED_AI) - { - slot->setState(SLOT_MED_AI); - ++numPlayers; - } - else if (resp.stagingRoom.profileID[i] == SLOT_BRUTAL_AI) - { - slot->setState(SLOT_BRUTAL_AI); - ++numPlayers; - } - else if (resp.stagingRoomPlayerNames[i].length()) - { - UnicodeString nameUStr; - nameUStr.translate(resp.stagingRoomPlayerNames[i].c_str()); - slot->setState(SLOT_PLAYER, nameUStr); - ++numPlayers; - } - else - { - slot->setState(SLOT_OPEN); - } - } - } - DEBUG_ASSERTCRASH(numPlayers, ("Game had no players!\n")); - //DEBUG_LOG(("Saw room: hasPass=%d, allowsObservers=%d\n", room.getHasPassword(), room.getAllowObservers())); - if (resp.stagingRoom.action == PEER_ADD) - { - TheGameSpyInfo->addStagingRoom(room); - //TheGameSpyInfo->addText( UnicodeString(L"gameList: PEER_ADD"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - } - else - { - TheGameSpyInfo->updateStagingRoom(room); - //TheGameSpyInfo->addText( UnicodeString(L"gameList: PEER_UPDATE"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - } - } - else - { - room.setID(resp.stagingRoom.id); - TheGameSpyInfo->removeStagingRoom(room); - //TheGameSpyInfo->addText( UnicodeString(L"gameList: PEER_UPDATE FAILED"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - } - break; - } - case PEER_REMOVE: - room.setID(resp.stagingRoom.id); - TheGameSpyInfo->removeStagingRoom(room); - //TheGameSpyInfo->addText( UnicodeString(L"gameList: PEER_REMOVE"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - break; - default: - //TheGameSpyInfo->addText( UnicodeString(L"gameList: Unknown"), GameSpyColor[GSCOLOR_DEFAULT], listboxLobbyChat ); - break; - } - } - break; - } - } -#if 0 - if (shouldRepopulatePlayers) - { - PopulateLobbyPlayerListbox(); - } -#else - refreshPlayerList(); -#endif - -#ifdef PERF_TEST - // check performance - end = timeGetTime(); - PERF_LOG(("Frame time was %d ms\n", end-start)); - std::list::const_iterator it; - for (it = responses.begin(); it != responses.end(); ++it) - { - PERF_LOG((" %s\n", getMessageString(*it))); - } - PERF_LOG(("\n")); -#endif // PERF_TEST - -#if 0 -// Removed 2-17-03 to pull out into a function so we can do the same checks - Int refreshInterval = gameListRefreshInterval; - - if ((gameListRefreshTime == 0) || ((gameListRefreshTime + refreshInterval) <= timeGetTime())) - { - if (TheGameSpyInfo->hasStagingRoomListChanged()) - { - //DEBUG_LOG(("################### refreshing game list\n")); - //DEBUG_LOG(("gameRefreshTime=%d, refreshInterval=%d, now=%d\n", gameListRefreshTime, refreshInterval, timeGetTime())); - RefreshGameListBoxes(); - gameListRefreshTime = timeGetTime(); - } else { - //DEBUG_LOG(("-")); - } - } else { - //DEBUG_LOG(("gameListRefreshTime: %d refreshInterval: %d\n")); - } -#else - refreshGameList(); -#endif - } -}// WOLLobbyMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Lobby Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLobbyMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - if (buttonPushed) - break; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLLobbyMenuInput - -//static void doSliderTrack(GameWindow *control, Int val) -//{ -// Int sliderW, sliderH, sliderX, sliderY; -// control->winGetPosition(&sliderX, &sliderY); -// control->winGetSize(&sliderW, &sliderH); -// Real cursorY = sliderY + (100-val)*0.01f*sliderH; -// -// extern GameWindow *listboxLobbyGamesSmall; -// extern GameWindow *listboxLobbyGamesLarge; -// extern GameWindow *listboxLobbyGameInfo; -// -// static Int gwsX = 0, gwsY = 0, gwsW = 0, gwsH = 0; -// static Int gwlX = 0, gwlY = 0, gwlW = 0, gwlH = 0; -// static Int gwiX = 0, gwiY = 0, gwiW = 0, gwiH = 0; -// static Int pwX = 0, pwY = 0, pwW = 0, pwH = 0; -// static Int chatPosX = 0, chatPosY = 0, chatW = 0, chatH = 0; -// static Int spacing = 0; -// if (chatPosX == 0) -// { -// listboxLobbyChat->winGetPosition(&chatPosX, &chatPosY); -// listboxLobbyChat->winGetSize(&chatW, &chatH); -// -//// listboxLobbyGamesSmall->winGetPosition(&gwsX, &gwsY); -//// listboxLobbyGamesSmall->winGetSize(&gwsW, &gwsH); -// -// listboxLobbyGamesLarge->winGetPosition(&gwlX, &gwlY); -// listboxLobbyGamesLarge->winGetSize(&gwlW, &gwlH); -// -//// listboxLobbyGameInfo->winGetPosition(&gwiX, &gwiY); -//// listboxLobbyGameInfo->winGetSize(&gwiW, &gwiH); -//// -// listboxLobbyPlayers->winGetPosition(&pwX, &pwY); -// listboxLobbyPlayers->winGetSize(&pwW, &pwH); -// -// spacing = chatPosY - pwY - pwH; -// } -// -// Int newChatY = cursorY; -// Int newChatH = chatH + chatPosY - newChatY; -// listboxLobbyChat->winSetPosition(chatPosX, newChatY); -// listboxLobbyChat->winSetSize(chatW, newChatH); -// -// Int newH = cursorY - pwY - spacing; -// listboxLobbyPlayers->winSetSize(pwW, newH); -//// listboxLobbyGamesSmall->winSetSize(gwsW, newH); -// listboxLobbyGamesLarge->winSetSize(gwlW, newH); -//// listboxLobbyGameInfo->winSetSize(gwiW, newH); - - -//------------------------------------------------------------------------------------------------- -/** WOL Lobby Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLobbyMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - static NameKeyType buttonGameListTypeToggleID = NAMEKEY_INVALID; - - switch( msg ) - { - - - //--------------------------------------------------------------------------------------------- - case GWM_CREATE: - { - buttonGameListTypeToggleID = NAMEKEY("WOLCustomLobby.wnd:ButtonGameListToggle"); -// sliderChatAdjustID = NAMEKEY("WOLCustomLobby.wnd:SliderChatAdjust"); - - break; - } // case GWM_DESTROY: - - //--------------------------------------------------------------------------------------------- - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - //--------------------------------------------------------------------------------------------- - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - //--------------------------------------------------------------------------------------------- - case GLM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if ( controlID == GetGameListBoxID() ) - { - int rowSelected = mData2; - if( rowSelected >= 0 ) - { - buttonJoin->winEnable(TRUE); - static UnsignedInt lastFrame = 0; - static Int lastID = -1; - UnsignedInt now = TheGameClient->getFrame(); - - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_GETEXTENDEDSTAGINGROOMINFO; - req.stagingRoom.id = (Int)GadgetListBoxGetItemData(control, rowSelected, 0); - - if (lastID != req.stagingRoom.id || now > lastFrame + 60) - { - TheGameSpyPeerMessageQueue->addRequest(req); - } - - lastID = req.stagingRoom.id; - lastFrame = now; - } - else - { - buttonJoin->winEnable(FALSE); - } - if (GetGameInfoListBox()) - { - RefreshGameInfoListBox(GetGameListBox(), GetGameInfoListBox()); - } - } //if ( controlID == GetGameListBoxID() ) - - break; - } - - //--------------------------------------------------------------------------------------------- - case GBM_SELECTED: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if (HandleSortButton((NameKeyType)controlID)) - break; - - // If we back out, just bail - we haven't gotten far enough to need to log out - if ( controlID == buttonBackID ) - { - if (s_tryingToHostOrJoin) - break; - - // Leave any group room, then pop off the screen - TheGameSpyInfo->leaveGroupRoom(); - - SetLobbyAttemptHostJoin( TRUE ); // pretend, since we don't want to queue up another action - buttonPushed = true; - nextScreen = "Menus/WOLWelcomeMenu.wnd"; - TheShell->pop(); - - } //if ( controlID == buttonBack ) - else if ( controlID == buttonRefreshID ) - { - // Added 2/17/03 added the game refresh button - refreshGameList(TRUE); - refreshPlayerList(TRUE); - } - else if ( controlID == buttonHostID ) - { - if (s_tryingToHostOrJoin) - break; - - SetLobbyAttemptHostJoin( TRUE ); - TheLobbyQueuedUTMs.clear(); - groupRoomToJoin = TheGameSpyInfo->getCurrentGroupRoom(); - GameSpyOpenOverlay(GSOVERLAY_GAMEOPTIONS); - } - else if ( controlID == buttonJoinID ) - { - if (s_tryingToHostOrJoin) - break; - - TheLobbyQueuedUTMs.clear(); - // Look for a game to join - groupRoomToJoin = TheGameSpyInfo->getCurrentGroupRoom(); - Int selected; - GadgetListBoxGetSelected(GetGameListBox(), &selected); - if (selected >= 0) - { - Int selectedID = (Int)GadgetListBoxGetItemData(GetGameListBox(), selected); - if (selectedID > 0) - { - StagingRoomMap *srm = TheGameSpyInfo->getStagingRoomList(); - StagingRoomMap::iterator srmIt = srm->find(selectedID); - if (srmIt != srm->end()) - { - GameSpyStagingRoom *roomToJoin = srmIt->second; - if (!roomToJoin || roomToJoin->getExeCRC() != TheGlobalData->m_exeCRC || roomToJoin->getIniCRC() != TheGlobalData->m_iniCRC) - { - // bad crc. don't go. - DEBUG_LOG(("WOLLobbyMenuSystem - CRC mismatch with the game I'm trying to join. My CRC's - EXE:0x%08X INI:0x%08X Their CRC's - EXE:0x%08x INI:0x%08x\n", TheGlobalData->m_exeCRC, TheGlobalData->m_iniCRC, roomToJoin->getExeCRC(), roomToJoin->getIniCRC())); -#if defined(_DEBUG) || defined(_INTERNAL) - if (TheGlobalData->m_netMinPlayers) - { - GSMessageBoxOk(TheGameText->fetch("GUI:JoinFailedDefault"), TheGameText->fetch("GUI:JoinFailedCRCMismatch")); - break; - } - else if (g_fakeCRC) - { - TheWritableGlobalData->m_exeCRC = roomToJoin->getExeCRC(); - TheWritableGlobalData->m_iniCRC = roomToJoin->getIniCRC(); - } -#else - GSMessageBoxOk(TheGameText->fetch("GUI:JoinFailedDefault"), TheGameText->fetch("GUI:JoinFailedCRCMismatch")); - break; -#endif - } - Bool unknownLadder = (roomToJoin->getLadderPort() && TheLadderList->findLadder(roomToJoin->getLadderIP(), roomToJoin->getLadderPort()) == NULL); - if (unknownLadder) - { - GSMessageBoxOk(TheGameText->fetch("GUI:JoinFailedDefault"), TheGameText->fetch("GUI:JoinFailedUnknownLadder")); - break; - } - if (roomToJoin->getNumPlayers() == MAX_SLOTS) - { - GSMessageBoxOk(TheGameText->fetch("GUI:JoinFailedDefault"), TheGameText->fetch("GUI:JoinFailedRoomFull")); - break; - } - TheGameSpyInfo->markAsStagingRoomJoiner(selectedID); - TheGameSpyGame->setGameName(roomToJoin->getGameName()); - TheGameSpyGame->setLadderIP(roomToJoin->getLadderIP()); - TheGameSpyGame->setLadderPort(roomToJoin->getLadderPort()); - SetLobbyAttemptHostJoin( TRUE ); - if (roomToJoin->getHasPassword()) - { - GameSpyOpenOverlay(GSOVERLAY_GAMEPASSWORD); - } - else - { - // no password - just join it - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_JOINSTAGINGROOM; - req.text = srmIt->second->getGameName().str(); - req.stagingRoom.id = selectedID; - req.password = ""; - TheGameSpyPeerMessageQueue->addRequest(req); - } - } - } - else - { - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:NoGameInfo"), NULL); - } - } - else - { - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:NoGameSelected"), NULL); - } - } - else if ( controlID == buttonBuddyID ) - { - GameSpyToggleOverlay( GSOVERLAY_BUDDY ); - } - else if ( controlID == buttonGameListTypeToggleID ) - { - ToggleGameListType(); - } - else if ( controlID == buttonEmoteID ) - { - // read the user's input and clear the entry box - UnicodeString txtInput; - txtInput.set(GadgetTextEntryGetText( textEntryChat )); - GadgetTextEntrySetText(textEntryChat, UnicodeString::TheEmptyString); - txtInput.trim(); - if (!txtInput.isEmpty()) - { - // Send the message - TheGameSpyInfo->sendChat( txtInput, FALSE, listboxLobbyPlayers ); // 'emote' button now just sends text - } - } - - break; - }// case GBM_SELECTED: - - //--------------------------------------------------------------------------------------------- - case GCM_SELECTED: - { - if (s_tryingToHostOrJoin) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if( controlID == comboLobbyGroupRoomsID ) - { - int rowSelected = -1; - GadgetComboBoxGetSelectedPos(control, &rowSelected); - - DEBUG_LOG(("Row selected = %d\n", rowSelected)); - if (rowSelected >= 0) - { - Int groupID; - groupID = (Int)GadgetComboBoxGetItemData(comboLobbyGroupRooms, rowSelected); - DEBUG_LOG(("ItemData was %d, current Group Room is %d\n", groupID, TheGameSpyInfo->getCurrentGroupRoom())); - if (groupID && groupID != TheGameSpyInfo->getCurrentGroupRoom()) - { - TheGameSpyInfo->leaveGroupRoom(); - TheGameSpyInfo->joinGroupRoom(groupID); - - if (TheGameSpyConfig->restrictGamesToLobby()) - { - TheGameSpyInfo->clearStagingRoomList(); - RefreshGameListBoxes(); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STARTGAMELIST; - req.gameList.restrictGameList = TRUE; - TheGameSpyPeerMessageQueue->addRequest(req); - } - } - } - } - } // case GCM_SELECTED - break; - - //--------------------------------------------------------------------------------------------- - case GLM_DOUBLE_CLICKED: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if (controlID == GetGameListBoxID()) - { - int rowSelected = mData2; - - if (rowSelected >= 0) - { - GadgetListBoxSetSelected( control, rowSelected ); - GameWindow *button = TheWindowManager->winGetWindowFromId( window, buttonJoinID ); - - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)button, buttonJoinID ); - } - } - break; - }// case GLM_DOUBLE_CLICKED: - - //--------------------------------------------------------------------------------------------- - case GLM_RIGHT_CLICKED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if( controlID == listboxLobbyPlayersID ) - { - RightClickStruct *rc = (RightClickStruct *)mData2; - WindowLayout *rcLayout = NULL; - GameWindow *rcMenu; - if(rc->pos < 0) - { - GadgetListBoxSetSelected(control, -1); - break; - } - - GPProfile profileID = 0; - AsciiString aName; - aName.translate(GadgetListBoxGetText(control, rc->pos, COLUMN_PLAYERNAME)); - PlayerInfoMap::iterator it = TheGameSpyInfo->getPlayerInfoMap()->find(aName); - if (it != TheGameSpyInfo->getPlayerInfoMap()->end()) - profileID = it->second.m_profileID; - - Bool isBuddy = FALSE; - if (profileID <= 0) - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCNoProfileMenu.wnd")); - else - { - if (profileID == TheGameSpyInfo->getLocalProfileID()) - { - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCLocalPlayerMenu.wnd")); - } - else if(TheGameSpyInfo->isBuddy(profileID)) - { - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCBuddiesMenu.wnd")); - isBuddy = TRUE; - } - else - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCNonBuddiesMenu.wnd")); - } - if(!rcLayout) - break; - - GadgetListBoxSetSelected(control, rc->pos); - - rcMenu = rcLayout->getFirstWindow(); - rcMenu->winGetLayout()->runInit(); - rcMenu->winBringToTop(); - rcMenu->winHide(FALSE); - setUnignoreText( rcLayout, aName, profileID); - ICoord2D rcSize, rcPos; - rcMenu->winGetSize(&rcSize.x, &rcSize.y); - rcPos.x = rc->mouseX; - rcPos.y = rc->mouseY; - if(rc->mouseX + rcSize.x > TheDisplay->getWidth()) - rcPos.x = TheDisplay->getWidth() - rcSize.x; - if(rc->mouseY + rcSize.y > TheDisplay->getHeight()) - rcPos.y = TheDisplay->getHeight() - rcSize.y; - rcMenu->winSetPosition(rcPos.x, rcPos.y); - - GameSpyRCMenuData *rcData = NEW GameSpyRCMenuData; - rcData->m_id = profileID; - rcData->m_nick = aName; - rcData->m_itemType = (isBuddy)?ITEM_BUDDY:ITEM_NONBUDDY; - rcMenu->winSetUserData((void *)rcData); - TheWindowManager->winSetLoneWindow(rcMenu); - } - else if( controlID == GetGameListBoxID() ) - { - RightClickStruct *rc = (RightClickStruct *)mData2; - WindowLayout *rcLayout = NULL; - GameWindow *rcMenu; - if(rc->pos < 0) - { - GadgetListBoxSetSelected(control, -1); - break; - } - - Int selectedID = (Int)GadgetListBoxGetItemData(control, rc->pos); - if (selectedID > 0) - { - StagingRoomMap *srm = TheGameSpyInfo->getStagingRoomList(); - StagingRoomMap::iterator srmIt = srm->find(selectedID); - if (srmIt != srm->end()) - { - GameSpyStagingRoom *theRoom = srmIt->second; - if (!theRoom) - break; - const LadderInfo *linfo = TheLadderList->findLadder(theRoom->getLadderIP(), theRoom->getLadderPort()); - if (linfo) - { - rcLayout = TheWindowManager->winCreateLayout(AsciiString("Menus/RCGameDetailsMenu.wnd")); - if (!rcLayout) - break; - - GadgetListBoxSetSelected(control, rc->pos); - - rcMenu = rcLayout->getFirstWindow(); - rcMenu->winGetLayout()->runInit(); - rcMenu->winBringToTop(); - rcMenu->winHide(FALSE); - rcMenu->winSetPosition(rc->mouseX, rc->mouseY); - - rcMenu->winSetUserData((void *)selectedID); - TheWindowManager->winSetLoneWindow(rcMenu); - } - } - } - } - break; - } - -// //--------------------------------------------------------------------------------------------- -// case GSM_SLIDER_TRACK: -// { -// if (buttonPushed) -// break; -// -// GameWindow *control = (GameWindow *)mData1; -// Int val = (Int)mData2; -// Int controlID = control->winGetWindowId(); -// if (controlID == sliderChatAdjustID) -// { -// doSliderTrack(control, val); -// } -// break; -// } - - //--------------------------------------------------------------------------------------------- - case GEM_EDIT_DONE: - { - if (buttonPushed) - break; - - // read the user's input and clear the entry box - UnicodeString txtInput; - txtInput.set(GadgetTextEntryGetText( textEntryChat )); - GadgetTextEntrySetText(textEntryChat, UnicodeString::TheEmptyString); - txtInput.trim(); - if (!txtInput.isEmpty()) - { - // Send the message - if (!handleLobbySlashCommands(txtInput)) - { - TheGameSpyInfo->sendChat( txtInput, false, listboxLobbyPlayers ); - } - } - break; - } - - //--------------------------------------------------------------------------------------------- - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLLobbyMenuSystem diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLocaleSelectPopup.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLocaleSelectPopup.cpp deleted file mode 100644 index 5da99177a7d..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLocaleSelectPopup.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLLocaleSelectPopup.cpp -// Author: Matt Campbell, December 2001 -// Description: WOL locale select popup -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "GameClient/GameText.h" -#include "Common/CustomMatchPreferences.h" -#include "Common/GameEngine.h" -#include "Common/GameSpyMiscPreferences.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "Common/GlobalData.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentLocaleSelectID = NAMEKEY_INVALID; -static NameKeyType buttonOkID = NAMEKEY_INVALID; -static NameKeyType listboxLocaleID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentLocaleSelect = NULL; -static GameWindow *buttonOk = NULL; -static GameWindow *listboxLocale = NULL; - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Status Menu */ -//------------------------------------------------------------------------------------------------- -void WOLLocaleSelectInit( WindowLayout *layout, void *userData ) -{ - parentLocaleSelectID = TheNameKeyGenerator->nameToKey( AsciiString( "PopupLocaleSelect.wnd:ParentLocaleSelect" ) ); - buttonOkID = TheNameKeyGenerator->nameToKey( AsciiString( "PopupLocaleSelect.wnd:ButtonOk" ) ); - listboxLocaleID = TheNameKeyGenerator->nameToKey( AsciiString( "PopupLocaleSelect.wnd:ListBoxLocaleSelect" ) ); - parentLocaleSelect = TheWindowManager->winGetWindowFromId( NULL, parentLocaleSelectID ); - buttonOk = TheWindowManager->winGetWindowFromId( NULL, buttonOkID); - listboxLocale = TheWindowManager->winGetWindowFromId( NULL, listboxLocaleID); - - for (int i=LOC_MIN; i<=LOC_MAX; ++i) - { - AsciiString id; - id.format("WOL:Locale%2.2d", i); - GadgetListBoxAddEntryText(listboxLocale, TheGameText->fetch(id.str()), GameSpyColor[GSCOLOR_DEFAULT], -1, -1); - } - GadgetListBoxSetSelected(listboxLocale, 0); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentLocaleSelect ); - TheWindowManager->winSetModal( parentLocaleSelect ); -} // WOLLocaleSelectInit - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLLocaleSelectShutdown( WindowLayout *layout, void *userData ) -{ - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); - -} // WOLLocaleSelectShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLLocaleSelectUpdate( WindowLayout * layout, void *userData) -{ - -}// WOLLocaleSelectUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLocaleSelectInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { -// UnsignedByte key = mData1; -// UnsignedByte state = mData2; - - // ---------------------------------------------------------------------------------------- - // don't let key fall through anywhere else - return MSG_HANDLED; - } // end char - } // end switch( msg ) - return MSG_IGNORED; -}// WOLLocaleSelectInput - -//Int getRegistryNicknameOffset(AsciiString nick); /// @todo: mdc remove this once we can save ini pref files -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLocaleSelectSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == buttonOkID ) - { - int selected; - GadgetListBoxGetSelected(listboxLocale, &selected); - if (selected < 0) - return MSG_HANDLED; // can't select nothing! - PSRequest psReq; - psReq.requestType = PSRequest::PSREQUEST_UPDATEPLAYERLOCALE; - psReq.player.locale = selected + LOC_MIN; - psReq.email = TheGameSpyInfo->getLocalEmail().str(); - psReq.nick = TheGameSpyInfo->getLocalBaseName().str(); - psReq.password = TheGameSpyInfo->getLocalPassword().str(); - psReq.player.id = TheGameSpyInfo->getLocalProfileID(); - - TheGameSpyPSMessageQueue->addRequest(psReq); - GameSpyCloseOverlay(GSOVERLAY_LOCALESELECT); - - GameSpyMiscPreferences cPref; - cPref.setLocale(psReq.player.locale); - cPref.write(); - - PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID()); - stats.locale = psReq.player.locale; - if (stats.id == TheGameSpyInfo->getLocalProfileID()) - TheGameSpyPSMessageQueue->trackPlayerStats(stats); - - if(stats.id == 0) - { - stats = TheGameSpyInfo->getCachedLocalPlayerStats(); - stats.locale = psReq.player.locale; - TheGameSpyInfo->setCachedLocalPlayerStats(stats); - } - else - { - // force an update of our shtuff - PSResponse newResp; - newResp.responseType = PSResponse::PSRESPONSE_PLAYERSTATS; - newResp.player = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID()); - TheGameSpyPSMessageQueue->addResponse(newResp); - } - CheckReOpenPlayerInfo(); - } //if ( controlID == buttonDisconnect ) - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLLocaleSelectSystem diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp deleted file mode 100644 index 3a4378ebb81..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp +++ /dev/null @@ -1,1511 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLLoginMenu.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/STLTypedefs.h" - -#include "Common/File.h" -#include "Common/FileSystem.h" -#include "Common/GameEngine.h" -#include "Common/GameSpyMiscPreferences.h" -#include "Common/QuotedPrintable.h" -#include "Common/Registry.h" -#include "Common/UserPreferences.h" -#include "GameClient/AnimateWindowManager.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GameText.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetComboBox.h" -#include "GameClient/GadgetCheckBox.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/MessageBox.h" -#include "GameClient/ShellHooks.h" -#include "GameClient/GameWindowTransitions.h" - -#include "GameNetwork/GameSpy/GSConfig.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PingThread.h" -#include "GameNetwork/GameSpy/BuddyThread.h" -#include "GameNetwork/GameSpy/ThreadUtils.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" - -#include "GameNetwork/GameSpyOverlay.h" - - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -#ifdef ALLOW_NON_PROFILED_LOGIN -Bool GameSpyUseProfiles = false; -#endif // ALLOW_NON_PROFILED_LOGIN - - -static Bool isShuttingDown = false; -static Bool buttonPushed = false; -static char *nextScreen = NULL; - -static const UnsignedInt loginTimeoutInMS = 10000; -static UnsignedInt loginAttemptTime = 0; - -class GameSpyLoginPreferences : public UserPreferences -{ -public: - GameSpyLoginPreferences() { m_emailPasswordMap.clear(); m_emailNickMap.clear(); } - virtual ~GameSpyLoginPreferences() { m_emailPasswordMap.clear(); m_emailNickMap.clear(); } - - virtual Bool load(AsciiString fname); - virtual Bool write(void); - - AsciiString getPasswordForEmail( AsciiString email ); - AsciiString getDateForEmail( AsciiString email, AsciiString &month, AsciiString &date, AsciiString &year ); - AsciiStringList getNicksForEmail( AsciiString email ); - void addLogin( AsciiString email, AsciiString nick, AsciiString password, AsciiString date ); - void forgetLogin( AsciiString email ); - AsciiStringList getEmails( void ); - -private: - typedef std::map PassMap; - typedef std::map DateMap; - typedef std::map NickMap; - PassMap m_emailPasswordMap; - NickMap m_emailNickMap; - DateMap m_emailDateMap; -}; - -static AsciiString obfuscate( AsciiString in ) -{ - char *buf = NEW char[in.getLength() + 1]; - strcpy(buf, in.str()); - static const char *xor = "1337Munkee"; - char *c = buf; - const char *c2 = xor; - while (*c) - { - if (!*c2) - c2 = xor; - if (*c != *c2) - *c = *c++ ^ *c2++; - else - c++, c2++; - } - AsciiString out = buf; - delete buf; - return out; -} - -Bool GameSpyLoginPreferences::load( AsciiString fname ) -{ - if (!UserPreferences::load(fname)) - return false; - - UserPreferences::iterator upIt = begin(); - while (upIt != end()) - { - AsciiString key = upIt->first; - if (key.startsWith("pass_")) - { - AsciiString email, pass; - email = key.str() + 5; - pass = upIt->second; - - AsciiString quoPass = QuotedPrintableToAsciiString(pass); - pass = obfuscate(quoPass); - - m_emailPasswordMap[email] = pass; - } - if (key.startsWith("date_")) - { - AsciiString email, date; - email = key.str() + 5; - date = upIt->second; - - date = QuotedPrintableToAsciiString(date); - - m_emailDateMap[email] = date; - } - else if (key.startsWith("nick_")) - { - AsciiString email, nick, nicks; - email = key.str() + 5; - nicks = upIt->second; - while (nicks.nextToken(&nick, ",")) - { - m_emailNickMap[email].push_back(nick); - } - } - ++upIt; - } - - return true; -} - -Bool GameSpyLoginPreferences::write( void ) -{ - if (m_filename.isEmpty()) - return false; - - FILE *fp = fopen(m_filename.str(), "w"); - if (fp) - { - fprintf(fp, "lastEmail = %s\n", ((*this)["lastEmail"].str())); - fprintf(fp, "lastName = %s\n", ((*this)["lastName"].str())); - fprintf(fp, "useProfiles = %s\n", ((*this)["useProfiles"].str())); - PassMap::iterator passIt = m_emailPasswordMap.begin(); - while (passIt != m_emailPasswordMap.end()) - { - AsciiString pass = obfuscate(passIt->second); - AsciiString quoPass = AsciiStringToQuotedPrintable(pass); - - fprintf(fp, "pass_%s = %s\n", passIt->first.str(), quoPass.str()); - ++passIt; - } - - PassMap::iterator dateIt = m_emailDateMap.begin(); - while (dateIt != m_emailDateMap.end()) - { - AsciiString date = AsciiStringToQuotedPrintable(dateIt->second); - - fprintf(fp, "date_%s = %s\n", dateIt->first.str(), date.str()); - ++dateIt; - } - - NickMap::iterator nickIt = m_emailNickMap.begin(); - while (nickIt != m_emailNickMap.end()) - { - AsciiString nicks; - AsciiStringListIterator listIt = nickIt->second.begin(); - while (listIt != nickIt->second.end()) - { - nicks.concat(*listIt); - nicks.concat(','); - ++listIt; - } - fprintf(fp, "nick_%s = %s\n", nickIt->first.str(), nicks.str()); - ++nickIt; - } - - fclose(fp); - return true; - } - return false; -} -AsciiString GameSpyLoginPreferences::getDateForEmail( AsciiString email, AsciiString &month, AsciiString &date, AsciiString &year ) -{ - if ( m_emailDateMap.find(email) == m_emailDateMap.end() ) - return AsciiString::TheEmptyString; - AsciiString fullDate = m_emailDateMap[email]; - if(fullDate.getLength() != 8) - return AsciiString::TheEmptyString; - month.format("%c%c", fullDate.getCharAt(0), fullDate.getCharAt(1)); - date.format("%c%c", fullDate.getCharAt(2), fullDate.getCharAt(3)); - year.format("%c%c%c%c", fullDate.getCharAt(4), fullDate.getCharAt(5), fullDate.getCharAt(6), fullDate.getCharAt(7)); - return m_emailDateMap[email]; -} - -AsciiString GameSpyLoginPreferences::getPasswordForEmail( AsciiString email ) -{ - if ( m_emailPasswordMap.find(email) == m_emailPasswordMap.end() ) - return AsciiString::TheEmptyString; - return m_emailPasswordMap[email]; -} - -AsciiStringList GameSpyLoginPreferences::getNicksForEmail( AsciiString email ) -{ - if ( m_emailNickMap.find(email) == m_emailNickMap.end() ) - { - AsciiStringList empty; - return empty; - } - return m_emailNickMap[email]; -} - -void GameSpyLoginPreferences::addLogin( AsciiString email, AsciiString nick, AsciiString password, AsciiString date ) -{ - if ( std::find(m_emailNickMap[email].begin(), m_emailNickMap[email].end(), nick) == m_emailNickMap[email].end() ) - m_emailNickMap[email].push_back(nick); - m_emailPasswordMap[email] = password; - m_emailDateMap[email] = date; -} - -void GameSpyLoginPreferences::forgetLogin( AsciiString email ) -{ - m_emailNickMap.erase(email); - m_emailPasswordMap.erase(email); - m_emailDateMap.erase(email); - -} - -AsciiStringList GameSpyLoginPreferences::getEmails( void ) -{ - AsciiStringList theList; - NickMap::iterator it = m_emailNickMap.begin(); - while (it != m_emailNickMap.end()) - { - theList.push_back(it->first); - ++it; - } - return theList; -} - -static const char *PREF_FILENAME = "GameSpyLogin.ini"; -static GameSpyLoginPreferences *loginPref = NULL; - -static void startPings( void ) -{ - std::list pingServers = TheGameSpyConfig->getPingServers(); - Int timeout = TheGameSpyConfig->getPingTimeoutInMs(); - Int reps = TheGameSpyConfig->getNumPingRepetitions(); - - for (std::list::const_iterator it = pingServers.begin(); it != pingServers.end(); ++it) - { - AsciiString pingServer = *it; - PingRequest req; - req.hostname = pingServer.str(); - req.repetitions = reps; - req.timeout = timeout; - ThePinger->addRequest(req); - } -} - -//------------------------------------------------------------------------------------------------- -/** This is called when a shutdown is complete for this menu */ -//------------------------------------------------------------------------------------------------- -static void shutdownComplete( WindowLayout *layout ) -{ - - isShuttingDown = false; - - // hide the layout - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout, (nextScreen != NULL) ); - - if (nextScreen != NULL) - { - if (loginPref) - { - loginPref->write(); - delete loginPref; - loginPref = NULL; - } - TheShell->push(nextScreen); - } - else - { - DEBUG_ASSERTCRASH(loginPref != NULL, ("loginPref == NULL")); - if (loginPref) - { - loginPref->write(); - delete loginPref; - loginPref = NULL; - } - } - - nextScreen = NULL; - -} // end if - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLLoginID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; // profile, quick -static NameKeyType buttonLoginID = NAMEKEY_INVALID; // profile, quick -static NameKeyType buttonCreateAccountID = NAMEKEY_INVALID; // profile, quick -static NameKeyType buttonUseAccountID = NAMEKEY_INVALID; // quick -static NameKeyType buttonDontUseAccountID = NAMEKEY_INVALID; // profile -static NameKeyType buttonTOSID = NAMEKEY_INVALID; // TOS -static NameKeyType parentTOSID = NAMEKEY_INVALID; // TOS Parent -static NameKeyType buttonTOSOKID = NAMEKEY_INVALID; // TOS -static NameKeyType listboxTOSID = NAMEKEY_INVALID; // TOS -static NameKeyType comboBoxEmailID = NAMEKEY_INVALID; // profile -static NameKeyType comboBoxLoginNameID = NAMEKEY_INVALID; // profile -static NameKeyType textEntryLoginNameID = NAMEKEY_INVALID; // quick -static NameKeyType textEntryPasswordID = NAMEKEY_INVALID; // profile -static NameKeyType checkBoxRememberPasswordID = NAMEKEY_INVALID; // checkbox to remember information or not -static NameKeyType textEntryMonthID = NAMEKEY_INVALID; // profile -static NameKeyType textEntryDayID = NAMEKEY_INVALID; // profile -static NameKeyType textEntryYearID = NAMEKEY_INVALID; // profile - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLLogin = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *buttonLogin = NULL; -static GameWindow *buttonCreateAccount = NULL; -static GameWindow *buttonUseAccount = NULL; -static GameWindow *buttonDontUseAccount = NULL; -static GameWindow *buttonTOS = NULL; -static GameWindow *parentTOS = NULL; -static GameWindow *buttonTOSOK = NULL; -static GameWindow *listboxTOS = NULL; -static GameWindow *comboBoxEmail = NULL; -static GameWindow *comboBoxLoginName = NULL; -static GameWindow *textEntryLoginName = NULL; -static GameWindow *textEntryPassword = NULL; -static GameWindow *checkBoxRememberPassword = NULL; -static GameWindow *textEntryMonth = NULL; -static GameWindow *textEntryDay = NULL; -static GameWindow *textEntryYear = NULL; - -void EnableLoginControls( Bool state ) -{ - if (buttonLogin) - buttonLogin->winEnable(state); - if (buttonCreateAccount) - buttonCreateAccount->winEnable(state); - if (buttonUseAccount) - buttonUseAccount->winEnable(state); - if (buttonDontUseAccount) - buttonDontUseAccount->winEnable(state); - if (comboBoxEmail) - comboBoxEmail->winEnable(state); - if (comboBoxLoginName) - comboBoxLoginName->winEnable(state); - if (textEntryLoginName) - textEntryLoginName->winEnable(state); - if (textEntryPassword) - textEntryPassword->winEnable(state); - if (checkBoxRememberPassword) - checkBoxRememberPassword->winEnable(state); - if( buttonTOS ) - buttonTOS->winEnable(state); - - if (textEntryMonth) - textEntryMonth->winEnable(state); - if (textEntryDay) - textEntryDay->winEnable(state); - if( textEntryYear ) - textEntryYear->winEnable(state); -} - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Login Menu */ -//------------------------------------------------------------------------------------------------- -void WOLLoginMenuInit( WindowLayout *layout, void *userData ) -{ - nextScreen = NULL; - buttonPushed = false; - isShuttingDown = false; - loginAttemptTime = 0; - - if (!loginPref) - { - loginPref = NEW GameSpyLoginPreferences; - loginPref->load(PREF_FILENAME); - } - - // if the ESRB warning is blank (other country) hide the box - GameWindow *esrbTitle = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("GameSpyLoginProfile.wnd:StaticTextESRBTop") ); - GameWindow *esrbParent = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("GameSpyLoginProfile.wnd:ParentESRB") ); - if (esrbTitle && esrbParent) - { - if ( GadgetStaticTextGetText( esrbTitle ).getLength() < 2 ) - { - esrbParent->winHide(TRUE); - } - } - - parentWOLLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:WOLLoginMenuParent" ); - buttonBackID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonBack" ); - buttonLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonLogin" ); - buttonCreateAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonCreateAccount" ); - buttonUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonUseAccount" ); - buttonDontUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonDontUseAccount" ); - buttonTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonTOS" ); - parentTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ParentTOS" ); - buttonTOSOKID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonTOSOK" ); - listboxTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ListboxTOS" ); - comboBoxEmailID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ComboBoxEmail" ); - comboBoxLoginNameID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ComboBoxLoginName" ); - textEntryLoginNameID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryLoginName" ); - textEntryPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryPassword" ); - checkBoxRememberPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:CheckBoxRememberInfo" ); - textEntryMonthID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryMonth" ); - textEntryDayID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryDay" ); - textEntryYearID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryYear" ); - - parentWOLLogin = TheWindowManager->winGetWindowFromId( NULL, parentWOLLoginID ); - buttonBack = TheWindowManager->winGetWindowFromId( NULL, buttonBackID); - buttonLogin = TheWindowManager->winGetWindowFromId( NULL, buttonLoginID); - buttonCreateAccount = TheWindowManager->winGetWindowFromId( NULL, buttonCreateAccountID); - buttonUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonUseAccountID); - buttonDontUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonDontUseAccountID); - buttonTOS = TheWindowManager->winGetWindowFromId( NULL, buttonTOSID); - parentTOS = TheWindowManager->winGetWindowFromId( NULL, parentTOSID); - buttonTOSOK = TheWindowManager->winGetWindowFromId( NULL, buttonTOSOKID); - listboxTOS = TheWindowManager->winGetWindowFromId( NULL, listboxTOSID); - comboBoxEmail = TheWindowManager->winGetWindowFromId( NULL, comboBoxEmailID); - comboBoxLoginName = TheWindowManager->winGetWindowFromId( NULL, comboBoxLoginNameID); - textEntryLoginName = TheWindowManager->winGetWindowFromId( NULL, textEntryLoginNameID); - textEntryPassword = TheWindowManager->winGetWindowFromId( NULL, textEntryPasswordID); - checkBoxRememberPassword = TheWindowManager->winGetWindowFromId( NULL, checkBoxRememberPasswordID); - textEntryMonth = TheWindowManager->winGetWindowFromId( NULL, textEntryMonthID); - textEntryDay = TheWindowManager->winGetWindowFromId( NULL, textEntryDayID); - textEntryYear = TheWindowManager->winGetWindowFromId( NULL, textEntryYearID); - - GadgetTextEntrySetText(textEntryMonth, UnicodeString::TheEmptyString); - - GadgetTextEntrySetText(textEntryDay, UnicodeString::TheEmptyString); - - GadgetTextEntrySetText(textEntryYear, UnicodeString::TheEmptyString); - - - - GameWindowList tabList; - tabList.push_front(comboBoxEmail); - tabList.push_back(comboBoxLoginName); - tabList.push_back(textEntryPassword); - tabList.push_back(textEntryMonth); - tabList.push_back(textEntryDay); - tabList.push_back(textEntryYear); - tabList.push_back(checkBoxRememberPassword); - tabList.push_back(buttonLogin); - tabList.push_back(buttonCreateAccount); - tabList.push_back(buttonTOS); - tabList.push_back(buttonBack); - TheWindowManager->clearTabList(); - TheWindowManager->registerTabList(tabList); - TheWindowManager->winSetFocus( comboBoxEmail ); - // short form or long form? -#ifdef ALLOW_NON_PROFILED_LOGIN - if (parentWOLLogin) - { - GameSpyUseProfiles = true; -#endif // ALLOW_NON_PROFILED_LOGIN - - DEBUG_ASSERTCRASH(buttonBack, ("buttonBack missing!")); - DEBUG_ASSERTCRASH(buttonLogin, ("buttonLogin missing!")); - DEBUG_ASSERTCRASH(buttonCreateAccount, ("buttonCreateAccount missing!")); - //DEBUG_ASSERTCRASH(buttonDontUseAccount, ("buttonDontUseAccount missing!")); - DEBUG_ASSERTCRASH(comboBoxEmail, ("comboBoxEmail missing!")); - DEBUG_ASSERTCRASH(comboBoxLoginName, ("comboBoxLoginName missing!")); - DEBUG_ASSERTCRASH(textEntryPassword, ("textEntryPassword missing!")); - - //TheShell->registerWithAnimateManager(parentWOLLogin, WIN_ANIMATION_SLIDE_TOP, TRUE); - /**/ -// TheShell->registerWithAnimateManager(buttonTOS, WIN_ANIMATION_SLIDE_BOTTOM, TRUE); - //TheShell->registerWithAnimateManager(buttonCreateAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE); - //TheShell->registerWithAnimateManager(buttonDontUseAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE); -// TheShell->registerWithAnimateManager(buttonBack, WIN_ANIMATION_SLIDE_BOTTOM, TRUE); - /**/ -#ifdef ALLOW_NON_PROFILED_LOGIN - } - else - { - GameSpyUseProfiles = false; - - parentWOLLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:WOLLoginMenuParent" ); - buttonBackID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonBack" ); - buttonLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonLogin" ); - buttonCreateAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonCreateAccount" ); - buttonUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonUseAccount" ); - buttonDontUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonDontUseAccount" ); - buttonTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonTOS" ); - parentTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ParentTOS" ); - buttonTOSOKID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonTOSOK" ); - listboxTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ListboxTOS" ); - comboBoxEmailID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ComboBoxEmail" ); - textEntryLoginNameID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:TextEntryLoginName" ); - textEntryPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:TextEntryPassword" ); - checkBoxRememberPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:CheckBoxRememberPassword" ); - - parentWOLLogin = TheWindowManager->winGetWindowFromId( NULL, parentWOLLoginID ); - buttonBack = TheWindowManager->winGetWindowFromId( NULL, buttonBackID); - buttonLogin = TheWindowManager->winGetWindowFromId( NULL, buttonLoginID); - buttonCreateAccount = TheWindowManager->winGetWindowFromId( NULL, buttonCreateAccountID); - buttonUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonUseAccountID); - buttonDontUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonDontUseAccountID); - comboBoxEmail = TheWindowManager->winGetWindowFromId( NULL, comboBoxEmailID); - buttonTOS = TheWindowManager->winGetWindowFromId( NULL, buttonTOSID); - parentTOS = TheWindowManager->winGetWindowFromId( NULL, parentTOSID); - buttonTOSOK = TheWindowManager->winGetWindowFromId( NULL, buttonTOSOKID); - listboxTOS = TheWindowManager->winGetWindowFromId( NULL, listboxTOSID); - textEntryLoginName = TheWindowManager->winGetWindowFromId( NULL, textEntryLoginNameID); - textEntryPassword = TheWindowManager->winGetWindowFromId( NULL, textEntryPasswordID); - checkBoxRememberPassword = TheWindowManager->winGetWindowFromId( NULL, checkBoxRememberPasswordID); - - DEBUG_ASSERTCRASH(buttonBack, ("buttonBack missing!")); - DEBUG_ASSERTCRASH(buttonLogin, ("buttonLogin missing!")); - DEBUG_ASSERTCRASH(buttonCreateAccount, ("buttonCreateAccount missing!")); - DEBUG_ASSERTCRASH(buttonUseAccount, ("buttonUseAccount missing!")); - DEBUG_ASSERTCRASH(textEntryLoginName, ("textEntryLoginName missing!")); - TheWindowManager->winSetFocus( textEntryLoginName ); - //TheShell->registerWithAnimateManager(parentWOLLogin, WIN_ANIMATION_SLIDE_TOP, TRUE); - -// TheShell->registerWithAnimateManager(buttonTOS, WIN_ANIMATION_SLIDE_LEFT, TRUE); -// TheShell->registerWithAnimateManager(buttonCreateAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE); -// TheShell->registerWithAnimateManager(buttonUseAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE); -// TheShell->registerWithAnimateManager(buttonBack, WIN_ANIMATION_SLIDE_RIGHT, TRUE); - - } -#endif // ALLOW_NON_PROFILED_LOGIN - - -#ifdef ALLOW_NON_PROFILED_LOGIN - if (GameSpyUseProfiles) - { -#endif // ALLOW_NON_PROFILED_LOGIN - // Read login names from registry... - GadgetComboBoxReset(comboBoxEmail); - GadgetTextEntrySetText(textEntryPassword, UnicodeString.TheEmptyString); - - // look for cached nicks to add - AsciiString lastName; - AsciiString lastEmail; - Bool markCheckBox = FALSE; - UserPreferences::const_iterator it = loginPref->find("lastName"); - if (it != loginPref->end()) - { - lastName = it->second; - } - it = loginPref->find("lastEmail"); - if (it != loginPref->end()) - { - lastEmail = it->second; - } - - // fill in list of Emails, and select the most recent - AsciiStringList cachedEmails = loginPref->getEmails(); - AsciiStringListIterator eIt = cachedEmails.begin(); - Int selectedPos = -1; - while (eIt != cachedEmails.end()) - { - UnicodeString uniEmail; - uniEmail.translate(*eIt); - Int pos = GadgetComboBoxAddEntry(comboBoxEmail, uniEmail, GameSpyColor[GSCOLOR_DEFAULT]); - if (*eIt == lastEmail) - selectedPos = pos; - - ++eIt; - } - if (selectedPos >= 0) - { - GadgetComboBoxSetSelectedPos(comboBoxEmail, selectedPos); - - // fill in the password for the selected email - UnicodeString pass; - pass.translate(loginPref->getPasswordForEmail(lastEmail)); - GadgetTextEntrySetText(textEntryPassword, pass); - - AsciiString month,day,year; - loginPref->getDateForEmail(lastEmail, month, day, year); - pass.translate(month); - GadgetTextEntrySetText(textEntryMonth, pass); - pass.translate(day); - GadgetTextEntrySetText(textEntryDay, pass); - pass.translate(year); - GadgetTextEntrySetText(textEntryYear, pass); - - markCheckBox = TRUE; - } - - // fill in list of nicks for selected email, selecting the most recent - GadgetComboBoxReset(comboBoxLoginName); - AsciiStringList cachedNicks = loginPref->getNicksForEmail(lastEmail); - AsciiStringListIterator nIt = cachedNicks.begin(); - selectedPos = -1; - while (nIt != cachedNicks.end()) - { - UnicodeString uniNick; - uniNick.translate(*nIt); - Int pos = GadgetComboBoxAddEntry(comboBoxLoginName, uniNick, GameSpyColor[GSCOLOR_DEFAULT]); - if (*nIt == lastName) - selectedPos = pos; - - ++nIt; - } - if (selectedPos >= 0) - { - GadgetComboBoxSetSelectedPos(comboBoxLoginName, selectedPos); - markCheckBox = TRUE; - } - // always start with not storing information - if( markCheckBox) - GadgetCheckBoxSetChecked(checkBoxRememberPassword, TRUE); - else - GadgetCheckBoxSetChecked(checkBoxRememberPassword, FALSE); -#ifdef ALLOW_NON_PROFILED_LOGIN - } - else - { - // Read login names from registry... - GadgetComboBoxReset(comboBoxLoginName); - UnicodeString nick; - - UserPreferences::const_iterator it = loginPref->find("lastName"); - if (it != loginPref->end()) - { - nick.translate(it->second); - } - else - { - char userBuf[32] = ""; - unsigned long bufSize = 32; - GetUserName(userBuf, &bufSize); - nick.translate(userBuf); - } - - GadgetTextEntrySetText(textEntryLoginName, nick); - } -#endif // ALLOW_NON_PROFILED_LOGIN - - EnableLoginControls(TRUE); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - - RaiseGSMessageBox(); - - OptionPreferences optionPref; - if (!optionPref.getBool("SawTOS", TRUE)) - { - TheWindowManager->winSendSystemMsg( parentWOLLogin, GBM_SELECTED, - (WindowMsgData)buttonTOS, buttonTOSID ); - } - TheTransitionHandler->setGroup("GameSpyLoginProfileFade"); - -} // WOLLoginMenuInit - -//------------------------------------------------------------------------------------------------- -/** WOL Login Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -static Bool loggedInOK = false; -void WOLLoginMenuShutdown( WindowLayout *layout, void *userData ) -{ - isShuttingDown = true; - loggedInOK = false; - TheWindowManager->clearTabList(); - - // if we are shutting down for an immediate pop, skip the animations - Bool popImmediate = *(Bool *)userData; - if( popImmediate ) - { - - shutdownComplete( layout ); - return; - - } //end if - - TheShell->reverseAnimatewindow(); - TheTransitionHandler->reverse("GameSpyLoginProfileFade"); - -} // WOLLoginMenuShutdown - - -// this is used to check if we've got all the pings -static void checkLogin( void ) -{ - if (loggedInOK && ThePinger && !ThePinger->arePingsInProgress()) - { - // save off our ping string, and end those threads - AsciiString pingStr = ThePinger->getPingString( 1000 ); - DEBUG_LOG(("Ping string is %s\n", pingStr.str())); - TheGameSpyInfo->setPingString(pingStr); - //delete ThePinger; - //ThePinger = NULL; - - buttonPushed = true; - loggedInOK = false; // don't try this again - - loginAttemptTime = 0; - - // start looking for group rooms - TheGameSpyInfo->clearGroupRoomList(); - - SignalUIInteraction(SHELL_SCRIPT_HOOK_GENERALS_ONLINE_LOGIN); - nextScreen = "Menus/WOLWelcomeMenu.wnd"; - TheShell->pop(); - - // read in some cached data - GameSpyMiscPreferences mPref; - PSPlayerStats localPSStats = GameSpyPSMessageQueueInterface::parsePlayerKVPairs(mPref.getCachedStats().str()); - localPSStats.id = TheGameSpyInfo->getLocalProfileID(); - TheGameSpyInfo->setCachedLocalPlayerStats(localPSStats); -// TheGameSpyPSMessageQueue->trackPlayerStats(localPSStats); - - // and push the info around to other players -// PSResponse newResp; -// newResp.responseType = PSResponse::PSRESPONSE_PLAYERSTATS; -// newResp.player = localPSStats; -// TheGameSpyPSMessageQueue->addResponse(newResp); - } -} - -//------------------------------------------------------------------------------------------------- -/** WOL Login Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLLoginMenuUpdate( WindowLayout * layout, void *userData) -{ - - // We'll only be successful if we've requested to - if(isShuttingDown && TheShell->isAnimFinished() && TheTransitionHandler->isFinished()) - shutdownComplete(layout); - - if (TheShell->isAnimFinished() && !buttonPushed && TheGameSpyPeerMessageQueue) - { - PingResponse pingResp; - if (ThePinger && ThePinger->getResponse(pingResp)) - { - checkLogin(); - } - - PeerResponse resp; - if (!loggedInOK && TheGameSpyPeerMessageQueue->getResponse( resp )) - { - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_GROUPROOM: - { - GameSpyGroupRoom room; - room.m_groupID = resp.groupRoom.id; - room.m_maxWaiting = resp.groupRoom.maxWaiting; - room.m_name = resp.groupRoomName.c_str(); - room.m_translatedName = UnicodeString(L"TEST"); - room.m_numGames = resp.groupRoom.numGames; - room.m_numPlaying = resp.groupRoom.numPlaying; - room.m_numWaiting = resp.groupRoom.numWaiting; - TheGameSpyInfo->addGroupRoom( room ); - } - break; - case PeerResponse::PEERRESPONSE_LOGIN: - { - loggedInOK = true; - - // fetch our player info - TheGameSpyInfo->setLocalName( resp.nick.c_str() ); - TheGameSpyInfo->setLocalProfileID( resp.player.profileID ); - TheGameSpyInfo->loadSavedIgnoreList(); - TheGameSpyInfo->setLocalIPs(resp.player.internalIP, resp.player.externalIP); - TheGameSpyInfo->readAdditionalDisconnects(); - //TheGameSpyInfo->setLocalEmail( resp.player.email ); - //TheGameSpyInfo->setLocalPassword( resp) - - GameSpyMiscPreferences miscPref; - TheGameSpyInfo->setMaxMessagesPerUpdate(miscPref.getMaxMessagesPerUpdate()); - } - break; - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - loginAttemptTime = 0; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GSMessageBoxOk( title, body ); - EnableLoginControls( TRUE ); - - // kill & restart the threads - AsciiString motd = TheGameSpyInfo->getMOTD(); - AsciiString config = TheGameSpyInfo->getConfig(); - DEBUG_LOG(("Tearing down GameSpy from WOLLoginMenuUpdate(PEERRESPONSE_DISCONNECT)\n")); - TearDownGameSpy(); - SetUpGameSpy( motd.str(), config.str() ); - } - break; - } - } - - checkLogin(); - } - - if (TheGameSpyInfo && !buttonPushed && loginAttemptTime && (loginAttemptTime + loginTimeoutInMS < timeGetTime())) - { - // timed out a login attempt, so say so - loginAttemptTime = 0; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason4"); // ("could not connect to server") - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GSMessageBoxOk( title, body ); - EnableLoginControls( TRUE ); - - // kill & restart the threads - AsciiString motd = TheGameSpyInfo->getMOTD(); - AsciiString config = TheGameSpyInfo->getConfig(); - DEBUG_LOG(("Tearing down GameSpy from WOLLoginMenuUpdate(login timeout)\n")); - TearDownGameSpy(); - SetUpGameSpy( motd.str(), config.str() ); - } - -}// WOLLoginMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Login Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLoginMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - if (buttonPushed) - break; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLLoginMenuInput - -static Bool isNickOkay(UnicodeString nick) -{ - static const WideChar * legalIRCChars = L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789[]`_^{|}-"; - - Int len = nick.getLength(); - if (len == 0) - return TRUE; - - if (len == 1 && nick.getCharAt(0) == L'-') - return FALSE; - - WideChar newChar = nick.getCharAt(len-1); - if (wcschr(legalIRCChars, newChar) == NULL) - return FALSE; - - return TRUE; -} - -static Bool isAgeOkay(AsciiString &month, AsciiString &day, AsciiString year) -{ - if(month.isEmpty() || day.isEmpty() || year.isEmpty() || year.getLength() != 4) - return FALSE; - - Int monthInt = atoi(month.str()); - Int dayInt = atoi(day.str()); - - if(monthInt > 12 || dayInt > 31) - return FALSE; - // setup date buffer for local region date format - month.format("%02.2d",monthInt); - day.format("%02.2d",dayInt); - - // test the year first - #define DATE_BUFFER_SIZE 256 - char dateBuffer[ DATE_BUFFER_SIZE ]; - GetDateFormat( LOCALE_SYSTEM_DEFAULT, - 0, NULL, - "yyyy", - dateBuffer, DATE_BUFFER_SIZE ); - Int sysVal = atoi(dateBuffer); - Int userVal = atoi(year.str()); - if(sysVal - userVal >= 14) - return TRUE; - else if( sysVal - userVal <= 12) - return FALSE; - - GetDateFormat( LOCALE_SYSTEM_DEFAULT, - 0, NULL, - "MM", - dateBuffer, DATE_BUFFER_SIZE ); - sysVal = atoi(dateBuffer); - userVal = atoi(month.str()); - if(sysVal - userVal >0 ) - return TRUE; - else if( sysVal -userVal < 0 ) - return FALSE; -// month.format("%02.2d",userVal); - GetDateFormat( LOCALE_SYSTEM_DEFAULT, - 0, NULL, - "dd", - dateBuffer, DATE_BUFFER_SIZE ); - sysVal = atoi(dateBuffer); - userVal = atoi(day.str()); - if(sysVal - userVal< 0) - return FALSE; -// day.format("%02.2d",userVal); - return TRUE; -} - -//------------------------------------------------------------------------------------------------- -/** WOL Login Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLLoginMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - // someone typed in a combo box. Clear password (or fill it in if the typed name matches a known login name) - case GCM_UPDATE_TEXT: - { - UnicodeString uNick = GadgetComboBoxGetText(comboBoxLoginName); - UnicodeString uEmail = GadgetComboBoxGetText(comboBoxEmail); - AsciiString nick, email; - nick.translate(uNick); - email.translate(uEmail); - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - UnicodeString trimmedNick = uNick, trimmedEmail = uEmail; - trimmedNick.trim(); - trimmedEmail.trim(); - if (!trimmedNick.isEmpty()) - { - if (trimmedNick.getCharAt(trimmedNick.getLength()-1) == L'\\') - trimmedNick.removeLastChar(); - if (trimmedNick.getCharAt(trimmedNick.getLength()-1) == L'/') - trimmedNick.removeLastChar(); - } - if (!trimmedEmail.isEmpty()) - { - if (trimmedEmail.getCharAt(trimmedEmail.getLength()-1) == L'\\') - trimmedEmail.removeLastChar(); - if (trimmedEmail.getCharAt(trimmedEmail.getLength()-1) == L'/') - trimmedEmail.removeLastChar(); - } - if (trimmedEmail.getLength() != uEmail.getLength()) - { - // we just trimmed a space. set the text back and bail - GadgetComboBoxSetText(comboBoxEmail, trimmedEmail); - break; - } - if (trimmedNick.getLength() != nick.getLength()) - { - // we just trimmed a space. set the text back and bail - GadgetComboBoxSetText(comboBoxLoginName, trimmedNick); - break; - } - - if (controlID == comboBoxEmailID) - { - // email changed. look up password, and choose new login names - - // fill in the password for the selected email - UnicodeString pass; - pass.translate(loginPref->getPasswordForEmail(email)); - GadgetTextEntrySetText(textEntryPassword, pass); - - // fill in list of nicks for selected email, selecting the first - AsciiStringList cachedNicks = loginPref->getNicksForEmail(email); - AsciiStringListIterator nIt = cachedNicks.begin(); - Int selectedPos = -1; - GadgetComboBoxReset(comboBoxLoginName); - while (nIt != cachedNicks.end()) - { - UnicodeString uniNick; - uniNick.translate(*nIt); - GadgetComboBoxAddEntry(comboBoxLoginName, uniNick, GameSpyColor[GSCOLOR_DEFAULT]); - selectedPos = 0; - ++nIt; - } - if (selectedPos >= 0) - { - GadgetComboBoxSetSelectedPos(comboBoxLoginName, selectedPos); - GadgetCheckBoxSetChecked(checkBoxRememberPassword, true); - AsciiString month,day,year; - loginPref->getDateForEmail(email, month, day, year); - pass.translate(month); - GadgetTextEntrySetText(textEntryMonth, pass); - pass.translate(day); - GadgetTextEntrySetText(textEntryDay, pass); - pass.translate(year); - GadgetTextEntrySetText(textEntryYear, pass); - - } - else - { - GadgetCheckBoxSetChecked(checkBoxRememberPassword, false); - GadgetTextEntrySetText(textEntryMonth, UnicodeString::TheEmptyString); - GadgetTextEntrySetText(textEntryDay, UnicodeString::TheEmptyString); - GadgetTextEntrySetText(textEntryYear, UnicodeString::TheEmptyString); - - } - } - else if (controlID == comboBoxLoginNameID) - { - // they typed a new login name. Email & pass shouldn't change - } - - break; - } - - case GCM_SELECTED: - { - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if (controlID == comboBoxEmailID) - { - // email changed. look up password, and choose new login names - UnicodeString uEmail = GadgetComboBoxGetText(comboBoxEmail); - AsciiString email; - email.translate(uEmail); - - // fill in the password for the selected email - UnicodeString pass; - pass.translate(loginPref->getPasswordForEmail(email)); - GadgetTextEntrySetText(textEntryPassword, pass); - - // fill in list of nicks for selected email, selecting the first - AsciiStringList cachedNicks = loginPref->getNicksForEmail(email); - AsciiStringListIterator nIt = cachedNicks.begin(); - Int selectedPos = -1; - GadgetComboBoxReset(comboBoxLoginName); - while (nIt != cachedNicks.end()) - { - UnicodeString uniNick; - uniNick.translate(*nIt); - GadgetComboBoxAddEntry(comboBoxLoginName, uniNick, GameSpyColor[GSCOLOR_DEFAULT]); - selectedPos = 0; - ++nIt; - } - if (selectedPos >= 0) - { - GadgetComboBoxSetSelectedPos(comboBoxLoginName, selectedPos); - GadgetCheckBoxSetChecked(checkBoxRememberPassword, true); - AsciiString month,day,year; - loginPref->getDateForEmail(email, month, day, year); - pass.translate(month); - GadgetTextEntrySetText(textEntryMonth, pass); - pass.translate(day); - GadgetTextEntrySetText(textEntryDay, pass); - pass.translate(year); - GadgetTextEntrySetText(textEntryYear, pass); - - } - else - { - GadgetCheckBoxSetChecked(checkBoxRememberPassword, false); - GadgetTextEntrySetText(textEntryMonth, UnicodeString::TheEmptyString); - GadgetTextEntrySetText(textEntryDay, UnicodeString::TheEmptyString); - GadgetTextEntrySetText(textEntryYear, UnicodeString::TheEmptyString); - } - - } - else if (controlID == comboBoxLoginNameID) - { - // they typed a new login name. Email & pass shouldn't change - } - break; - } - - case GBM_SELECTED: - { - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - // If we back out, just bail - we haven't gotten far enough to need to log out - if ( controlID == buttonBackID ) - { - buttonPushed = true; - TearDownGameSpy(); - TheShell->pop(); - } //if ( controlID == buttonBack ) -#ifdef ALLOW_NON_PROFILED_LOGIN - else if ( controlID == buttonUseAccountID ) - { - buttonPushed = true; - nextScreen = "Menus/GameSpyLoginProfile.wnd"; - TheShell->pop(); - //TheShell->push( "Menus/GameSpyLoginProfile.wnd" ); - } //if ( controlID == buttonUseAccount ) - else if ( controlID == buttonDontUseAccountID ) - { - buttonPushed = true; - nextScreen = "Menus/GameSpyLoginQuick.wnd"; - TheShell->pop(); - //TheShell->push( "Menus/GameSpyLoginQuick.wnd" ); - } //if ( controlID == buttonDontUseAccount ) -#endif // ALLOW_NON_PROFILED_LOGIN - else if ( controlID == buttonCreateAccountID ) - { -#ifdef ALLOW_NON_PROFILED_LOGIN - if (GameSpyUseProfiles) - { -#endif // ALLOW_NON_PROFILED_LOGIN - // actually attempt to create an account based on info entered - AsciiString month, day, year; - month.translate( GadgetTextEntryGetText(textEntryMonth) ); - day.translate( GadgetTextEntryGetText(textEntryDay) ); - year.translate( GadgetTextEntryGetText(textEntryYear) ); - - if(!isAgeOkay(month, day, year)) - { - GSMessageBoxOk(TheGameText->fetch("GUI:AgeFailedTitle"), TheGameText->fetch("GUI:AgeFailed")); - break; - } - - AsciiString login, password, email; - email.translate( GadgetComboBoxGetText(comboBoxEmail) ); - login.translate( GadgetComboBoxGetText(comboBoxLoginName) ); - password.translate( GadgetTextEntryGetText(textEntryPassword) ); - - if ( !email.isEmpty() && !login.isEmpty() && !password.isEmpty() ) - { - loginAttemptTime = timeGetTime(); - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_LOGINNEW; - strcpy(req.arg.login.nick, login.str()); - strcpy(req.arg.login.email, email.str()); - strcpy(req.arg.login.password, password.str()); - req.arg.login.hasFirewall = TRUE; - - TheGameSpyInfo->setLocalBaseName( login ); - //TheGameSpyInfo->setLocalProfileID( resp.player.profileID ); - TheGameSpyInfo->setLocalEmail( email ); - TheGameSpyInfo->setLocalPassword( password ); - DEBUG_LOG(("before create: TheGameSpyInfo->stuff(%s/%s/%s)\n", TheGameSpyInfo->getLocalBaseName().str(), TheGameSpyInfo->getLocalEmail().str(), TheGameSpyInfo->getLocalPassword().str())); - - TheGameSpyBuddyMessageQueue->addRequest( req ); - if(checkBoxRememberPassword && GadgetCheckBoxIsChecked(checkBoxRememberPassword)) - { - (*loginPref)["lastName"] = login; - (*loginPref)["lastEmail"] = email; - (*loginPref)["useProfiles"] = "yes"; - AsciiString date; - date = month; - date.concat(day); - date.concat(year); - - loginPref->addLogin(email, login, password, date); - } - - EnableLoginControls( FALSE ); - - // fire off some pings - startPings(); - } - else - { - // user didn't fill in all info. prompt him. - if(email.isEmpty() && login.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoAll")); - else if( email.isEmpty() && login.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoEmailNickname")); - else if( email.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoEmailPassword")); - else if( login.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoNicknamePassword")); - else if( email.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoEmail")); - else if( password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoPassword")); - else if( login.isEmpty() ) - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoNickname")); - else - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoAll")); - } -#ifdef ALLOW_NON_PROFILED_LOGIN - } - else - { - // not the profile screen - switch to it - buttonPushed = TRUE; - nextScreen = "Menus/GameSpyLoginProfile.wnd"; - TheShell->pop(); - } -#endif // ALLOW_NON_PROFILED_LOGIN - } //if ( controlID == buttonCreateAccount ) - else if ( controlID == buttonLoginID ) - { - AsciiString login, password, email; - -#ifdef ALLOW_NON_PROFILED_LOGIN - if (GameSpyUseProfiles) - { -#endif // ALLOW_NON_PROFILED_LOGIN - AsciiString month, day, year; - month.translate( GadgetTextEntryGetText(textEntryMonth) ); - day.translate( GadgetTextEntryGetText(textEntryDay) ); - year.translate( GadgetTextEntryGetText(textEntryYear) ); - - if(!isAgeOkay(month, day, year)) - { - GSMessageBoxOk(TheGameText->fetch("GUI:AgeFailedTitle"), TheGameText->fetch("GUI:AgeFailed")); - break; - } - - email.translate( GadgetComboBoxGetText(comboBoxEmail) ); - login.translate( GadgetComboBoxGetText(comboBoxLoginName) ); - password.translate( GadgetTextEntryGetText(textEntryPassword) ); - - if ( !email.isEmpty() && !login.isEmpty() && !password.isEmpty() ) - { - loginAttemptTime = timeGetTime(); - BuddyRequest req; - req.buddyRequestType = BuddyRequest::BUDDYREQUEST_LOGIN; - strcpy(req.arg.login.nick, login.str()); - strcpy(req.arg.login.email, email.str()); - strcpy(req.arg.login.password, password.str()); - req.arg.login.hasFirewall = true; - - TheGameSpyInfo->setLocalBaseName( login ); - //TheGameSpyInfo->setLocalProfileID( resp.player.profileID ); - TheGameSpyInfo->setLocalEmail( email ); - TheGameSpyInfo->setLocalPassword( password ); - DEBUG_LOG(("before login: TheGameSpyInfo->stuff(%s/%s/%s)\n", TheGameSpyInfo->getLocalBaseName().str(), TheGameSpyInfo->getLocalEmail().str(), TheGameSpyInfo->getLocalPassword().str())); - - TheGameSpyBuddyMessageQueue->addRequest( req ); - if(checkBoxRememberPassword && GadgetCheckBoxIsChecked(checkBoxRememberPassword)) - { - (*loginPref)["lastName"] = login; - (*loginPref)["lastEmail"] = email; - (*loginPref)["useProfiles"] = "yes"; - AsciiString date; - date = month; - date.concat(day); - date.concat(year); - - loginPref->addLogin(email, login, password,date); - } - else - { - loginPref->forgetLogin(email); - } - EnableLoginControls( FALSE ); - - // fire off some pings - startPings(); - } - else - { - // user didn't fill in all info. prompt him. - if(email.isEmpty() && login.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoAll")); - else if( email.isEmpty() && login.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoEmailNickname")); - else if( email.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoEmailPassword")); - else if( login.isEmpty() && password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoNicknamePassword")); - else if( email.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoEmail")); - else if( password.isEmpty()) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoPassword")); - else if( login.isEmpty() ) - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoNickname")); - else - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoAll")); - } -#ifdef ALLOW_NON_PROFILED_LOGIN - } - else - { - login.translate( GadgetTextEntryGetText(textEntryLoginName) ); - - if ( !login.isEmpty() ) - { - loginAttemptTime = timeGetTime(); - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_LOGIN; - req.nick = login.str(); - req.login.profileID = 0; - TheGameSpyPeerMessageQueue->addRequest( req ); - - (*loginPref)["lastName"] = login; - loginPref->erase("lastEmail"); - (*loginPref)["useProfiles"] = "no"; - EnableLoginControls( FALSE ); - - // fire off some pings - startPings(); - } - } -#endif // ALLOW_NON_PROFILED_LOGIN - - } //if ( controlID == buttonLogin ) - else if ( controlID == buttonTOSID ) - { - parentTOS->winHide(FALSE); - - if (1) - { - // Okay, no web browser. This means we're looking at a UTF-8 text file. - GadgetListBoxReset(listboxTOS); - AsciiString fileName; - fileName.format("Data\\%s\\TOS.txt", GetRegistryLanguage().str()); - File *theFile = TheFileSystem->openFile(fileName.str(), File::READ); - if (theFile) - { - Int size = theFile->size(); - - char *fileBuf = new char[size]; - Color tosColor = GameMakeColor(255, 255, 255, 255); - - Int bytesRead = theFile->read(fileBuf, size); - if (bytesRead == size && size > 2) - { - fileBuf[size-1] = 0; // just to be safe - AsciiString asciiBuf = fileBuf+2; - AsciiString asciiLine; - while (asciiBuf.nextToken(&asciiLine, "\r\n")) - { - UnicodeString uniLine; - uniLine = UnicodeString(MultiByteToWideCharSingleLine(asciiLine.str()).c_str()); - int len = uniLine.getLength(); - for (int index = len-1; index >= 0; index--) - { - if (iswspace(uniLine.getCharAt(index))) - { - uniLine.removeLastChar(); - } - else - { - break; - } - } - //uniLine.trim(); - DEBUG_LOG(("adding TOS line: [%ls]\n", uniLine.str())); - GadgetListBoxAddEntryText(listboxTOS, uniLine, tosColor, -1); - } - - } - - delete fileBuf; - fileBuf = NULL; - - theFile->close(); - theFile = NULL; - } - } - EnableLoginControls( FALSE ); - buttonBack->winEnable(FALSE); - - } - else if ( controlID == buttonTOSOKID ) - { - EnableLoginControls( TRUE ); - - parentTOS->winHide(TRUE); - - OptionPreferences optionPref; - optionPref["SawTOS"] = "yes"; - optionPref.write(); - buttonBack->winEnable(TRUE); - } - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - /* - case GEM_UPDATE_TEXT: - { - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == textEntryLoginNameID ) - { - UnicodeString munkee = GadgetTextEntryGetText( textEntryLoginName ); - if ( !isNickOkay( munkee ) ) - { - munkee.removeLastChar(); - GadgetTextEntrySetText( textEntryLoginName, munkee ); - } - }// if ( controlID == textEntryLoginNameID ) - break; - }//case GEM_UPDATE_TEXT: - */ - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLLoginMenuSystem - - diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp deleted file mode 100644 index 7e140bbace7..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMapSelectMenu.cpp +++ /dev/null @@ -1,483 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: WOLMapSelectMenu.cpp //////////////////////////////////////////////////////////////////////// -// Author: Matt Campbell, December 2001 -// Description: MapSelect menu window callbacks -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/CustomMatchPreferences.h" -#include "Common/GameEngine.h" -#include "Common/MessageStream.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GadgetRadioButton.h" -#include "GameClient/Shell.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameClient/MapUtil.h" -#include "GameNetwork/GUIUtil.h" - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -static NameKeyType buttonBack = NAMEKEY_INVALID; -static NameKeyType buttonOK = NAMEKEY_INVALID; -static NameKeyType listboxMap = NAMEKEY_INVALID; -static GameWindow *parent = NULL; -static Bool raiseMessageBoxes = FALSE; -static GameWindow *winMapPreview = NULL; -static NameKeyType winMapPreviewID = NAMEKEY_INVALID; - -static NameKeyType radioButtonSystemMapsID = NAMEKEY_INVALID; -static NameKeyType radioButtonUserMapsID = NAMEKEY_INVALID; - -extern WindowLayout *WOLMapSelectLayout; ///< Map selection overlay -static GameWindow *mapList = NULL; - -static GameWindow *buttonMapStartPosition[MAX_SLOTS] = {NULL,NULL,NULL,NULL, - NULL,NULL,NULL,NULL }; -static NameKeyType buttonMapStartPositionID[MAX_SLOTS] = { NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID, - NAMEKEY_INVALID,NAMEKEY_INVALID }; - -static GameWindow *winMapWindow = NULL; - -static void NullifyControls(void) -{ - parent = NULL; - winMapPreview = NULL; - mapList = NULL; - for (Int i=0; iwinGetWindowFromId( NULL, TheNameKeyGenerator->nameToKey("GameSpyGameOptionsMenu.wnd:ButtonBack") ); - if(win) - win->winEnable( show ); -} - -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------------------------------- -/** Initialize the MapSelect menu */ -//------------------------------------------------------------------------------------------------- -void WOLMapSelectMenuInit( WindowLayout *layout, void *userData ) -{ - - // set keyboard focus to main parent - AsciiString parentName( "WOLMapSelectMenu.wnd:WOLMapSelectMenuParent" ); - NameKeyType parentID = TheNameKeyGenerator->nameToKey( parentName ); - parent = TheWindowManager->winGetWindowFromId( NULL, parentID ); - - TheWindowManager->winSetFocus( parent ); - - CustomMatchPreferences pref; - Bool usesSystemMapDir = pref.usesSystemMapDir(); - winMapPreviewID = TheNameKeyGenerator->nameToKey( AsciiString("WOLMapSelectMenu.wnd:WinMapPreview") ); - winMapPreview = TheWindowManager->winGetWindowFromId(parent, winMapPreviewID); - - const MapMetaData *mmd = TheMapCache->findMap(TheGameSpyGame->getMap()); - if (mmd) - { - usesSystemMapDir = mmd->m_isOfficial; - } - - //if stats are enabled, only official maps can be used - if( TheGameSpyInfo->getCurrentStagingRoom()->getUseStats() ) - usesSystemMapDir = true; - - buttonBack = TheNameKeyGenerator->nameToKey( AsciiString("WOLMapSelectMenu.wnd:ButtonBack") ); - buttonOK = TheNameKeyGenerator->nameToKey( AsciiString("WOLMapSelectMenu.wnd:ButtonOK") ); - listboxMap = TheNameKeyGenerator->nameToKey( AsciiString("WOLMapSelectMenu.wnd:ListboxMap") ); - radioButtonSystemMapsID = TheNameKeyGenerator->nameToKey( "WOLMapSelectMenu.wnd:RadioButtonSystemMaps" ); - radioButtonUserMapsID = TheNameKeyGenerator->nameToKey( "WOLMapSelectMenu.wnd:RadioButtonUserMaps" ); - winMapWindow = TheWindowManager->winGetWindowFromId( parent, listboxMap ); - - GameWindow *radioButtonSystemMaps = TheWindowManager->winGetWindowFromId( parent, radioButtonSystemMapsID ); - GameWindow *radioButtonUserMaps = TheWindowManager->winGetWindowFromId( parent, radioButtonUserMapsID ); - if( TheGameSpyInfo->getCurrentStagingRoom()->getUseStats() ) - { //disable unofficial maps if stats are being recorded - GadgetRadioSetSelection( radioButtonSystemMaps, FALSE ); - radioButtonUserMaps->winEnable( FALSE ); - } - else if (usesSystemMapDir) - GadgetRadioSetSelection( radioButtonSystemMaps, FALSE ); - else - GadgetRadioSetSelection( radioButtonUserMaps, FALSE ); - - AsciiString tmpString; - for (Int i = 0; i < MAX_SLOTS; i++) - { - tmpString.format("WOLMapSelectMenu.wnd:ButtonMapStartPosition%d", i); - buttonMapStartPositionID[i] = TheNameKeyGenerator->nameToKey( tmpString ); - buttonMapStartPosition[i] = TheWindowManager->winGetWindowFromId( winMapPreview, buttonMapStartPositionID[i] ); - DEBUG_ASSERTCRASH(buttonMapStartPosition[i], ("Could not find the ButtonMapStartPosition[%d]",i )); - buttonMapStartPosition[i]->winHide(TRUE); - buttonMapStartPosition[i]->winEnable(FALSE); - } - - raiseMessageBoxes = TRUE; - showGameSpyGameOptionsUnderlyingGUIElements( FALSE ); - - // get the listbox window - AsciiString listString( "WOLMapSelectMenu.wnd:ListboxMap" ); - NameKeyType mapListID = TheNameKeyGenerator->nameToKey( listString ); - mapList = TheWindowManager->winGetWindowFromId( parent, mapListID ); - if( mapList ) - { - if (TheMapCache) - TheMapCache->updateCache(); - populateMapListbox( mapList, usesSystemMapDir, TRUE, TheGameSpyGame->getMap() ); - } - -} // end WOLMapSelectMenuInit - -//------------------------------------------------------------------------------------------------- -/** MapSelect menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLMapSelectMenuShutdown( WindowLayout *layout, void *userData ) -{ - NullifyControls(); - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); - -} // end WOLMapSelectMenuShutdown - -//------------------------------------------------------------------------------------------------- -/** MapSelect menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLMapSelectMenuUpdate( WindowLayout *layout, void *userData ) -{ - - if (raiseMessageBoxes) - { - RaiseGSMessageBox(); - raiseMessageBoxes = false; - } - - // No update because the game setup screen is up at the same - // time and it does the update for us... -} // end WOLMapSelectMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** Map select menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLMapSelectMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - AsciiString buttonName( "WOLMapSelectMenu.wnd:ButtonBack" ); - NameKeyType buttonID = TheNameKeyGenerator->nameToKey( buttonName ); - GameWindow *button = TheWindowManager->winGetWindowFromId( window, buttonID ); - - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)button, buttonID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; - -} // end WOLMapSelectMenuInput -void WOLPositionStartSpots( void ); - -//------------------------------------------------------------------------------------------------- -/** MapSelect menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLMapSelectMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CREATE: - { - break; - - } // end create - - //--------------------------------------------------------------------------------------------- - case GWM_DESTROY: - { - NullifyControls(); - break; - - } // end case - - // -------------------------------------------------------------------------------------------- - case GWM_INPUT_FOCUS: - { - - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - - } // end input - - //--------------------------------------------------------------------------------------------- - case GLM_DOUBLE_CLICKED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if( controlID == listboxMap ) - { - int rowSelected = mData2; - - if (rowSelected >= 0) - { - GadgetListBoxSetSelected( control, rowSelected ); - GameWindow *button = TheWindowManager->winGetWindowFromId( window, buttonOK ); - - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)button, buttonOK ); - } - } - break; - } - //--------------------------------------------------------------------------------------------- - - - - case GLM_SELECTED: - { - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - if( controlID == listboxMap ) - { - int rowSelected = mData2; - if( rowSelected < 0 ) - { - positionStartSpots( AsciiString::TheEmptyString, buttonMapStartPosition, winMapPreview); -// winMapPreview->winClearStatus(WIN_STATUS_IMAGE); - break; - } - winMapPreview->winSetStatus(WIN_STATUS_IMAGE); - UnicodeString map; - // get text of the map to load - map = GadgetListBoxGetText( winMapWindow, rowSelected, 0 ); - - // set the map name in the global data map name - AsciiString asciiMap; - const char *mapFname = (const char *)GadgetListBoxGetItemData( winMapWindow, rowSelected ); - DEBUG_ASSERTCRASH(mapFname, ("No map item data")); - if (mapFname) - asciiMap = mapFname; - else - asciiMap.translate( map ); - asciiMap.toLower(); - Image *image = getMapPreviewImage(asciiMap); - winMapPreview->winSetUserData((void *)TheMapCache->findMap(asciiMap)); - if(image) - { - winMapPreview->winSetEnabledImage(0, image); - } - else - { - winMapPreview->winClearStatus(WIN_STATUS_IMAGE); - } - positionStartSpots( asciiMap, buttonMapStartPosition, winMapPreview); - } - break; - } - //--------------------------------------------------------------------------------------------- - case GBM_SELECTED: - { - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if( controlID == buttonBack ) - { - showGameSpyGameOptionsUnderlyingGUIElements( TRUE ); - - WOLMapSelectLayout->destroyWindows(); - WOLMapSelectLayout->deleteInstance(); - WOLMapSelectLayout = NULL; - WOLPositionStartSpots(); - } // end if - else if ( controlID == radioButtonSystemMapsID ) - { - if (TheMapCache) - TheMapCache->updateCache(); - populateMapListbox( mapList, TRUE, TRUE, TheGameSpyGame->getMap() ); - CustomMatchPreferences pref; - pref.setUsesSystemMapDir(TRUE); - pref.write(); - } - else if ( controlID == radioButtonUserMapsID ) - { - if (TheMapCache) - TheMapCache->updateCache(); - populateMapListbox( mapList, FALSE, TRUE, TheGameSpyGame->getMap() ); - CustomMatchPreferences pref; - pref.setUsesSystemMapDir(FALSE); - pref.write(); - } - else if( controlID == buttonOK ) - { - Int selected; - UnicodeString map; - - // get the selected index - GadgetListBoxGetSelected( winMapWindow, &selected ); - - if( selected != -1 ) - { - - // get text of the map to load - map = GadgetListBoxGetText( winMapWindow, selected, 0 ); - - - // set the map name in the global data map name - AsciiString asciiMap; - const char *mapFname = (const char *)GadgetListBoxGetItemData( winMapWindow, selected ); - DEBUG_ASSERTCRASH(mapFname, ("No map item data")); - if (mapFname) - asciiMap = mapFname; - else - asciiMap.translate( map ); - TheGameSpyGame->setMap(asciiMap); - asciiMap.toLower(); - std::map::iterator it = TheMapCache->find(asciiMap); - if (it != TheMapCache->end()) - { - TheGameSpyGame->getGameSpySlot(0)->setMapAvailability(TRUE); - TheGameSpyGame->setMapCRC( it->second.m_CRC ); - TheGameSpyGame->setMapSize( it->second.m_filesize ); - } - - TheGameSpyGame->adjustSlotsForMap(); // BGC- adjust the slots for the new map. - TheGameSpyGame->resetAccepted(); - TheGameSpyGame->resetStartSpots(); - TheGameSpyInfo->setGameOptions(); - - WOLDisplaySlotList(); - WOLDisplayGameOptions(); - - WOLMapSelectLayout->destroyWindows(); - WOLMapSelectLayout->deleteInstance(); - WOLMapSelectLayout = NULL; - - showGameSpyGameOptionsUnderlyingGUIElements( TRUE ); - - WOLPositionStartSpots(); - - } // end if - - } // end else if - - break; - - } // end selected - - default: - return MSG_IGNORED; - - } // end switch - - return MSG_HANDLED; - -} // end WOLMapSelectMenuSystem diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMessageWindow.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMessageWindow.cpp deleted file mode 100644 index 5f93a32d7cd..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLMessageWindow.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLMessageWindow.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameNetwork/IPEnumeration.h" -//#include "GameNetwork/WOL.h" - - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLMessageWindowID = NAMEKEY_INVALID; -static NameKeyType buttonCancelID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLMessageWindow = NULL; -static GameWindow *buttonCancel = NULL; - - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOLMessage Window */ -//------------------------------------------------------------------------------------------------- -void WOLMessageWindowInit( WindowLayout *layout, void *userData ) -{ - parentWOLMessageWindowID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLMessageWindow.wnd:WOLMessageWindowParent" ) ); - buttonCancelID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLMessageWindow.wnd:ButtonCancel" ) ); - parentWOLMessageWindow = TheWindowManager->winGetWindowFromId( NULL, parentWOLMessageWindowID ); - buttonCancel = TheWindowManager->winGetWindowFromId( NULL, buttonCancelID); - - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLMessageWindow ); - -} // WOLMessageWindowInit - -//------------------------------------------------------------------------------------------------- -/** WOLMessage Window shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLMessageWindowShutdown( WindowLayout *layout, void *userData ) -{ - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); -} // WOLMessageWindowShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOLMessage Window update method */ -//------------------------------------------------------------------------------------------------- -void WOLMessageWindowUpdate( WindowLayout * layout, void *userData) -{ - /* - if (WOL::TheWOL) - WOL::TheWOL->update(); - */ - -}// WOLMessageWindowUpdate - -//------------------------------------------------------------------------------------------------- -/** WOLMessage Window input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLMessageWindowInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonCancel, buttonCancelID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLMessageWindowInput - -//------------------------------------------------------------------------------------------------- -/** WOLMessage Window window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLMessageWindowSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLMessageWindowSystem diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQMScoreScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQMScoreScreen.cpp deleted file mode 100644 index 80ecc295549..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQMScoreScreen.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLQMScoreScreen.cpp -// Author: Matt Campbell, November 2001 -// Description: QuickMatch score screen (different from normal screen in that it has 'QM' and 'Discon' buttons) -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -//#include "GameNetwork/WOL.h" -//#include "GameNetwork/WOLmenus.h" - - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLQMScoreID = NAMEKEY_INVALID; -static NameKeyType buttonDisconnectID = NAMEKEY_INVALID; -static NameKeyType buttonQuickmatchID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLQMScore = NULL; -static GameWindow *buttonDisconnect = NULL; -static GameWindow *buttonQuickmatch = NULL; - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Status Menu */ -//------------------------------------------------------------------------------------------------- -void WOLQMScoreScreenInit( WindowLayout *layout, void *userData ) -{ - parentWOLQMScoreID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLQMScoreScreen.wnd:WOLQMScoreScreenParent" ) ); - buttonDisconnectID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLQMScoreScreen.wnd:ButtonDisconnect" ) ); - buttonQuickmatchID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLQMScoreScreen.wnd:ButtonQuickMatch" ) ); - parentWOLQMScore = TheWindowManager->winGetWindowFromId( NULL, parentWOLQMScoreID ); - buttonDisconnect = TheWindowManager->winGetWindowFromId( NULL, buttonDisconnectID); - buttonQuickmatch = TheWindowManager->winGetWindowFromId( NULL, buttonQuickmatchID); - - /* - if (WOL::TheWOL->getState() == WOL::WOLAPI_FATAL_ERROR) - { - // We can get to the score screen even though we've been disconnected. Just hide - // any buttons that lead back into WOL. - - buttonQuickmatch->winHide( TRUE ); - } - */ - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLQMScore ); - - //progressLayout = TheShell->top(); - -} // WOLQMScoreScreenInit - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLQMScoreScreenShutdown( WindowLayout *layout, void *userData ) -{ - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); - - //progressLayout = NULL; - -} // WOLQMScoreScreenShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLQMScoreScreenUpdate( WindowLayout * layout, void *userData) -{ - /* - if (WOL::TheWOL) - WOL::TheWOL->update(); - */ -}// WOLQMScoreScreenUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLQMScoreScreenInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonDisconnect, buttonDisconnectID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLQMScoreScreenInput - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLQMScoreScreenSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're given the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - /* - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == buttonDisconnectID ) - { - //TheShell->pop(); - if (WOL::TheWOL->setState( WOL::WOLAPI_FATAL_ERROR )) - { - WOL::TheWOL->addCommand( WOL::WOLCOMMAND_RESET ); // don't display an error, log out, or anything - } - - } //if ( controlID == buttonDisconnect ) - else if ( controlID == buttonQuickmatchID ) - { - //TheShell->pop(); - if (WOL::TheWOL->getState() != WOL::WOLAPI_FATAL_ERROR) - { - if (WOL::TheWOL->setState( WOL::WOLAPI_TOURNAMENT )) - { - WOL::TheWOL->setScreen( WOL::WOLAPI_MENU_QUICKMATCH ); - WOL::TheWOL->addCommand( WOL::WOLCOMMAND_FIND_MATCH_CHANNEL ); - } - } - - } //if ( controlID == buttonDisconnect ) - */ - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLQMScoreScreenSystem diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp deleted file mode 100644 index d119217f1f2..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp +++ /dev/null @@ -1,1897 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLQuickMatchMenu.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "Common/QuickmatchPreferences.h" -#include "Common/LadderPreferences.h" -#include "Common/MultiplayerSettings.h" -#include "Common/PlayerTemplate.h" -#include "GameClient/AnimateWindowManager.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GameText.h" -#include "GameClient/InGameUI.h" -#include "GameClient/Shell.h" -#include "GameClient/ShellHooks.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetComboBox.h" -#include "GameClient/GadgetPushButton.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/MapUtil.h" -#include "GameClient/GameWindowTransitions.h" -#include "GameClient/ChallengeGenerals.h" - -#include "GameLogic/GameLogic.h" - -#include "GameNetwork/NAT.h" -#include "GameNetwork/GameSpyOverlay.h" -#include "GameNetwork/GameSpy/BuddyDefs.h" -#include "GameNetwork/GameSpy/GSConfig.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" -#include "GameNetwork/RankPointValue.h" -#include "GameNetwork/GameSpy/LadderDefs.h" -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif - -#ifdef DEBUG_LOGGING -#include "Common/MiniLog.h" -//#define PERF_TEST -static LogClass s_perfLog("QMPerf.txt"); -static Bool s_inQM = FALSE; -#define PERF_LOG(x) s_perfLog.log x -#else // DEBUG_LOGGING -#define PERF_LOG(x) {} -#endif // DEBUG_LOGGING - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLQuickMatchID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; -static NameKeyType buttonStartID = NAMEKEY_INVALID; -static NameKeyType buttonStopID = NAMEKEY_INVALID; -static NameKeyType buttonWidenID = NAMEKEY_INVALID; -static NameKeyType buttonBuddiesID = NAMEKEY_INVALID; -static NameKeyType listboxQuickMatchID = NAMEKEY_INVALID; -static NameKeyType listboxMapSelectID = NAMEKEY_INVALID; -static NameKeyType buttonSelectAllMapsID = NAMEKEY_INVALID; -static NameKeyType buttonSelectNoMapsID = NAMEKEY_INVALID; -//static NameKeyType textEntryMaxDisconnectsID = NAMEKEY_INVALID; -//static NameKeyType textEntryMaxPointsID = NAMEKEY_INVALID; -//static NameKeyType textEntryMinPointsID = NAMEKEY_INVALID; -static NameKeyType textEntryWaitTimeID = NAMEKEY_INVALID; -static NameKeyType comboBoxNumPlayersID = NAMEKEY_INVALID; -static NameKeyType comboBoxMaxPingID = NAMEKEY_INVALID; -static NameKeyType comboBoxLadderID = NAMEKEY_INVALID; -static NameKeyType comboBoxMaxDisconnectsID = NAMEKEY_INVALID; -static NameKeyType staticTextNumPlayersID = NAMEKEY_INVALID; -static NameKeyType comboBoxSideID = NAMEKEY_INVALID; -static NameKeyType comboBoxColorID = NAMEKEY_INVALID; - - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLQuickMatch = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *buttonStart = NULL; -static GameWindow *buttonStop = NULL; -static GameWindow *buttonWiden = NULL; -GameWindow *quickmatchTextWindow = NULL; -static GameWindow *listboxMapSelect = NULL; -//static GameWindow *textEntryMaxDisconnects = NULL; -//static GameWindow *textEntryMaxPoints = NULL; -//static GameWindow *textEntryMinPoints = NULL; -static GameWindow *textEntryWaitTime = NULL; -static GameWindow *comboBoxNumPlayers = NULL; -static GameWindow *comboBoxMaxPing = NULL; -static GameWindow *comboBoxLadder = NULL; -static GameWindow *comboBoxDisabledLadder = NULL; // enable and disable this, but never use it. it is a stand-in for comboBoxLadder for when there are no ladders -static GameWindow *comboBoxMaxDisconnects = NULL; -static GameWindow *staticTextNumPlayers = NULL; -static GameWindow *comboBoxSide = NULL; -static GameWindow *comboBoxColor = NULL; - -static Bool isShuttingDown = false; -static Bool buttonPushed = false; -static char *nextScreen = NULL; -static Bool raiseMessageBoxes = false; -static Bool isInInit = FALSE; -static const Image *selectedImage = NULL; -static const Image *unselectedImage = NULL; - -static bool isPopulatingLadderBox = false; -static Int maxPingEntries = 0; -static Int maxPoints= 100; -static Int minPoints = 0; - -static const LadderInfo * getLadderInfo( void ); - -static Bool isInfoShown(void) -{ - static NameKeyType parentStatsID = NAMEKEY("WOLQuickMatchMenu.wnd:ParentStats"); - GameWindow *parentStats = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, parentStatsID ); - if (parentStats) - return !parentStats->winIsHidden(); - return FALSE; -} - -static void hideInfoGadgets(Bool doIt) -{ - static NameKeyType parentStatsID = NAMEKEY("WOLQuickMatchMenu.wnd:ParentStats"); - GameWindow *parentStats = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, parentStatsID ); - if (parentStats) - { - parentStats->winHide(doIt); - } -} - -static void hideOptionsGadgets(Bool doIt) -{ - static NameKeyType parentOptionsID = NAMEKEY("WOLQuickMatchMenu.wnd:ParentOptions"); - GameWindow *parentOptions = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, parentOptionsID ); - if (parentOptions) - { - parentOptions->winHide(doIt); - if (comboBoxSide) - comboBoxSide->winHide(doIt); - if (comboBoxColor) - comboBoxColor->winHide(doIt); - if (comboBoxNumPlayers) - comboBoxNumPlayers->winHide(doIt); - if (comboBoxLadder) - comboBoxLadder->winHide(doIt); - if (comboBoxDisabledLadder) - comboBoxDisabledLadder->winHide(doIt); - if (comboBoxMaxPing) - comboBoxMaxPing->winHide(doIt); - if (comboBoxMaxDisconnects) - comboBoxMaxDisconnects->winHide(doIt); - } -} - -static void enableOptionsGadgets(Bool doIt) -{ -#ifdef PERF_TEST - s_inQM = !doIt; -#endif // PERF_TEST - static NameKeyType parentOptionsID = NAMEKEY("WOLQuickMatchMenu.wnd:ParentOptions"); - GameWindow *parentOptions = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, parentOptionsID ); - const LadderInfo *li = getLadderInfo(); - if (parentOptions) - { - parentOptions->winEnable(doIt); - if (comboBoxSide) - comboBoxSide->winEnable(doIt && (!li || !li->randomFactions)); - if (comboBoxColor) - comboBoxColor->winEnable(doIt); - if (comboBoxNumPlayers) - comboBoxNumPlayers->winEnable(doIt); - if (comboBoxLadder) - comboBoxLadder->winEnable(doIt); - if (comboBoxDisabledLadder) - comboBoxDisabledLadder->winEnable(FALSE); - if (comboBoxMaxPing) - comboBoxMaxPing->winEnable(doIt); - if (comboBoxMaxDisconnects) - comboBoxMaxDisconnects->winEnable(doIt); - } -} - -enum -{ - MAX_DISCONNECTS_ANY = 0, - MAX_DISCONNECTS_5 = 5, - MAX_DISCONNECTS_10 = 10, - MAX_DISCONNECTS_25 = 25, - MAX_DISCONNECTS_50 = 50, -}; -enum{ MAX_DISCONNECTS_COUNT = 5 }; - -static Int MAX_DISCONNECTS[MAX_DISCONNECTS_COUNT] = {MAX_DISCONNECTS_ANY, MAX_DISCONNECTS_5, - MAX_DISCONNECTS_10, MAX_DISCONNECTS_25, - MAX_DISCONNECTS_50}; - - -void UpdateStartButton(void) -{ - if (!comboBoxLadder || !buttonStart || !listboxMapSelect) - return; - - Int index; - Int selected; - GadgetComboBoxGetSelectedPos( comboBoxLadder, &selected ); - index = (Int)GadgetComboBoxGetItemData( comboBoxLadder, selected ); - const LadderInfo *li = TheLadderList->findLadderByIndex( index ); - if (li) - { - buttonStart->winEnable(TRUE); - return; - } - - Int numMaps = GadgetListBoxGetNumEntries(listboxMapSelect); - for ( Int i=0; iwinEnable(TRUE); - return; - } - } - buttonStart->winEnable(FALSE); -} - -// ----------------------------------------------------------------------------- - -static void populateQMColorComboBox(QuickMatchPreferences& pref) -{ - Int numColors = TheMultiplayerSettings->getNumColors(); - UnicodeString colorName; - - GadgetComboBoxReset(comboBoxColor); - - MultiplayerColorDefinition *def = TheMultiplayerSettings->getColor(PLAYERTEMPLATE_RANDOM); - Int newIndex = GadgetComboBoxAddEntry(comboBoxColor, TheGameText->fetch("GUI:???"), def->getColor()); - GadgetComboBoxSetItemData(comboBoxColor, newIndex, (void *)-1); - - for (Int c=0; cgetColor(c); - if (!def) - continue; - - colorName = TheGameText->fetch(def->getTooltipName().str()); - newIndex = GadgetComboBoxAddEntry(comboBoxColor, colorName, def->getColor()); - GadgetComboBoxSetItemData(comboBoxColor, newIndex, (void *)c); - } - GadgetComboBoxSetSelectedPos(comboBoxColor, pref.getColor()); -} - -// ----------------------------------------------------------------------------- - -static void populateQMSideComboBox(Int favSide, const LadderInfo *li = NULL) -{ - Int numPlayerTemplates = ThePlayerTemplateStore->getPlayerTemplateCount(); - UnicodeString playerTemplateName; - - GadgetComboBoxReset(comboBoxSide); - - MultiplayerColorDefinition *def = TheMultiplayerSettings->getColor(PLAYERTEMPLATE_RANDOM); - Int newIndex = GadgetComboBoxAddEntry(comboBoxSide, TheGameText->fetch("GUI:Random"), def->getColor()); - GadgetComboBoxSetItemData(comboBoxSide, newIndex, (void *)PLAYERTEMPLATE_RANDOM); - - std::set seenSides; - - Int entryToSelect = 0; // select Random by default - - for (Int c=0; cgetNthPlayerTemplate(c); - if (!fac) - continue; - - if (fac->getStartingBuilding().isEmpty()) - continue; - - AsciiString side; - side.format("SIDE:%s", fac->getSide().str()); - if (seenSides.find(side) != seenSides.end()) - continue; - - if (li) - { - if (std::find(li->validFactions.begin(), li->validFactions.end(), fac->getSide()) == li->validFactions.end()) - continue; // ladder doesn't allow it. - } - - // Remove disallowed generals from the choice list. - // This is also enforced at GUI setup (GUIUtil.cpp and UserPreferences.cpp). - // @todo: unlock these when something rad happens - Bool disallowLockedGenerals = TRUE; - const GeneralPersona *general = TheChallengeGenerals->getGeneralByTemplateName(fac->getName()); - Bool startsLocked = general ? !general->isStartingEnabled() : FALSE; - if (disallowLockedGenerals && startsLocked) - continue; - - seenSides.insert(side); - - newIndex = GadgetComboBoxAddEntry(comboBoxSide, TheGameText->fetch(side), def->getColor()); - GadgetComboBoxSetItemData(comboBoxSide, newIndex, (void *)c); - - if (c == favSide) - entryToSelect = newIndex; - } - seenSides.clear(); - - GadgetComboBoxSetSelectedPos(comboBoxSide, entryToSelect); - if (li && li->randomFactions) - comboBoxSide->winEnable(FALSE); - else - comboBoxSide->winEnable(TRUE); -} - -void HandleQMLadderSelection(Int ladderID) -{ - if (!parentWOLQuickMatch) - return; - - QuickMatchPreferences pref; - - if (ladderID < 1) - { - pref.setLastLadder(AsciiString::TheEmptyString, 0); - pref.write(); - return; - } - - const LadderInfo *info = TheLadderList->findLadderByIndex(ladderID); - if (!info) - { - pref.setLastLadder(AsciiString::TheEmptyString, 0); - } - else - { - pref.setLastLadder(info->address, info->port); - } - - pref.write(); -} - -static inline Bool isValidLadder( const LadderInfo *lad ) -{ - if (lad && lad->index > 0 && lad->validQM) - { - PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID()); - Int numWins = 0; - PerGeneralMap::iterator it; - for (it = stats.wins.begin(); it != stats.wins.end(); ++it) - { - numWins += it->second; - } - if (!lad->maxWins || lad->maxWins >=numWins) - { - if (!lad->minWins || lad->minWins<=numWins) - { - return TRUE; - } - } - } - return FALSE; -} - -void PopulateQMLadderListBox( GameWindow *win ) -{ - if (!parentWOLQuickMatch || !comboBoxLadder) - return; - - isPopulatingLadderBox = true; - - QuickMatchPreferences pref; - AsciiString userPrefFilename; - Int localProfile = TheGameSpyInfo->getLocalProfileID(); - - Color specialColor = GameSpyColor[GSCOLOR_MAP_SELECTED]; - Color normalColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED]; - Color favoriteColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED]; - Int index; - GadgetListBoxReset( win ); - - std::set usedLadders; - - // start with "No Ladder" - index = GadgetListBoxAddEntryText( win, TheGameText->fetch("GUI:NoLadder"), normalColor, -1 ); - GadgetListBoxSetItemData( win, 0, index ); - - // add the last ladder - Int selectedPos = 0; - AsciiString lastLadderAddr = pref.getLastLadderAddr(); - UnsignedShort lastLadderPort = pref.getLastLadderPort(); - const LadderInfo *info = TheLadderList->findLadder( lastLadderAddr, lastLadderPort ); - if (isValidLadder(info)) - { - usedLadders.insert(info); - index = GadgetListBoxAddEntryText( win, info->name, favoriteColor, -1 ); - GadgetListBoxSetItemData( win, (void *)(info->index), index ); - selectedPos = index; - } - - // our recent ladders - LadderPreferences ladPref; - ladPref.loadProfile( localProfile ); - const LadderPrefMap recentLadders = ladPref.getRecentLadders(); - for (LadderPrefMap::const_iterator cit = recentLadders.begin(); cit != recentLadders.end(); ++cit) - { - AsciiString addr = cit->second.address; - UnsignedShort port = cit->second.port; - if (addr == lastLadderAddr && port == lastLadderPort) - continue; - const LadderInfo *info = TheLadderList->findLadder( addr, port ); - if (isValidLadder(info) && usedLadders.find(info) == usedLadders.end()) - { - usedLadders.insert(info); - index = GadgetListBoxAddEntryText( win, info->name, favoriteColor, -1 ); - GadgetListBoxSetItemData( win, (void *)(info->index), index ); - } - } - - // special ladders - const LadderInfoList *lil = TheLadderList->getSpecialLadders(); - LadderInfoList::const_iterator lit; - for (lit = lil->begin(); lit != lil->end(); ++lit) - { - const LadderInfo *info = *lit; - if (isValidLadder(info) && usedLadders.find(info) == usedLadders.end()) - { - usedLadders.insert(info); - index = GadgetListBoxAddEntryText( win, info->name, specialColor, -1 ); - GadgetListBoxSetItemData( win, (void *)(info->index), index ); - } - } - - // standard ladders - lil = TheLadderList->getStandardLadders(); - for (lit = lil->begin(); lit != lil->end(); ++lit) - { - const LadderInfo *info = *lit; - if (isValidLadder(info) && usedLadders.find(info) == usedLadders.end()) - { - usedLadders.insert(info); - index = GadgetListBoxAddEntryText( win, info->name, normalColor, -1 ); - GadgetListBoxSetItemData( win, (void *)(info->index), index ); - } - } - - GadgetListBoxSetSelected( win, selectedPos ); - isPopulatingLadderBox = false; -} - -static const LadderInfo * getLadderInfo( void ) -{ - Int index; - Int selected; - GadgetComboBoxGetSelectedPos( comboBoxLadder, &selected ); - index = (Int)GadgetComboBoxGetItemData( comboBoxLadder, selected ); - const LadderInfo *li = TheLadderList->findLadderByIndex( index ); - return li; -} - -void PopulateQMLadderComboBox( void ) -{ - if (!parentWOLQuickMatch || !comboBoxLadder) - return; - - isPopulatingLadderBox = true; - - QuickMatchPreferences pref; - Int localProfile = TheGameSpyInfo->getLocalProfileID(); - - Color specialColor = GameSpyColor[GSCOLOR_MAP_SELECTED]; - Color normalColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED]; - Int index; - GadgetComboBoxReset( comboBoxLadder ); - index = GadgetComboBoxAddEntry( comboBoxLadder, TheGameText->fetch("GUI:NoLadder"), normalColor ); - GadgetComboBoxSetItemData( comboBoxLadder, index, 0 ); - - std::set usedLadders; - - Int selectedPos = 0; - AsciiString lastLadderAddr = pref.getLastLadderAddr(); - UnsignedShort lastLadderPort = pref.getLastLadderPort(); - const LadderInfo *info = TheLadderList->findLadder( lastLadderAddr, lastLadderPort ); - if (isValidLadder(info)) - { - usedLadders.insert(info); - index = GadgetComboBoxAddEntry( comboBoxLadder, info->name, specialColor ); - GadgetComboBoxSetItemData( comboBoxLadder, index, (void *)(info->index) ); - selectedPos = index; - - // we selected a ladder? No game size choice for us... - GadgetComboBoxSetSelectedPos(comboBoxNumPlayers, info->playersPerTeam-1); - comboBoxNumPlayers->winEnable( FALSE ); - } - else - { - comboBoxNumPlayers->winEnable( TRUE ); - } - - LadderPreferences ladPref; - ladPref.loadProfile( localProfile ); - const LadderPrefMap recentLadders = ladPref.getRecentLadders(); - for (LadderPrefMap::const_iterator cit = recentLadders.begin(); cit != recentLadders.end(); ++cit) - { - AsciiString addr = cit->second.address; - UnsignedShort port = cit->second.port; - if (addr == lastLadderAddr && port == lastLadderPort) - continue; - const LadderInfo *info = TheLadderList->findLadder( addr, port ); - if (isValidLadder(info) && usedLadders.find(info) == usedLadders.end()) - { - usedLadders.insert(info); - index = GadgetComboBoxAddEntry( comboBoxLadder, info->name, normalColor ); - GadgetComboBoxSetItemData( comboBoxLadder, index, (void *)(info->index) ); - } - } - - index = GadgetComboBoxAddEntry( comboBoxLadder, TheGameText->fetch("GUI:ChooseLadder"), normalColor ); - GadgetComboBoxSetItemData( comboBoxLadder, index, (void *)-1 ); - - GadgetComboBoxSetSelectedPos( comboBoxLadder, selectedPos ); - isPopulatingLadderBox = false; - - populateQMSideComboBox(pref.getSide(), getLadderInfo()); // this will set side to random and disable if necessary -} - -static void populateQuickMatchMapSelectListbox( QuickMatchPreferences& pref ) -{ - std::list maps = TheGameSpyConfig->getQMMaps(); - - // enable/disable box based on ladder status - Int index; - Int selected; - GadgetComboBoxGetSelectedPos( comboBoxLadder, &selected ); - index = (Int)GadgetComboBoxGetItemData( comboBoxLadder, selected ); - const LadderInfo *li = TheLadderList->findLadderByIndex( index ); - //listboxMapSelect->winEnable( li == NULL || li->randomMaps == FALSE ); - - Int numPlayers = 0; - if (li) - { - numPlayers = li->playersPerTeam*2; - - maps = li->validMaps; - } - else - { - GadgetComboBoxGetSelectedPos(comboBoxNumPlayers, &selected); - if (selected < 0) - selected = 0; - numPlayers = (selected+1)*2; - } - - - GadgetListBoxReset(listboxMapSelect); - for (std::list::const_iterator it = maps.begin(); it != maps.end(); ++it) - { - AsciiString theMap = *it; - const MapMetaData *md = TheMapCache->findMap(theMap); - if (md && md->m_numPlayers >= numPlayers) - { - UnicodeString displayName; - displayName = md->m_displayName; - Bool isSelected = pref.isMapSelected(theMap); - if (li && li->randomMaps) - isSelected = TRUE; - Int width = 10; - Int height = 10; - const Image *img = (isSelected)?selectedImage:unselectedImage; - if ( img ) - { - width = min(GadgetListBoxGetColumnWidth(listboxMapSelect, 0), img->getImageWidth()); - height = width; - } - Int index = GadgetListBoxAddEntryImage(listboxMapSelect, img, -1, 0, height, width); - GadgetListBoxAddEntryText(listboxMapSelect, displayName, GameSpyColor[(isSelected)?GSCOLOR_MAP_SELECTED:GSCOLOR_MAP_UNSELECTED], index, 1); - GadgetListBoxSetItemData(listboxMapSelect, (void *)isSelected, index); - GadgetListBoxSetItemData(listboxMapSelect, (void *)md, index, 1); - } - } -} - -static void saveQuickMatchOptions( void ) -{ - if(isInInit) - return; - QuickMatchPreferences pref; - - std::list maps = TheGameSpyConfig->getQMMaps(); - - Int index; - Int selected; - GadgetComboBoxGetSelectedPos( comboBoxLadder, &selected ); - index = (Int)GadgetComboBoxGetItemData( comboBoxLadder, selected ); - const LadderInfo *li = TheLadderList->findLadderByIndex( index ); - Int numPlayers = 0; - - if (li) - { - pref.setLastLadder( li->address, li->port ); - numPlayers = li->playersPerTeam*2; - - pref.write(); - //return; // don't save our defaults based on the tournament's defaults - } - else - { - pref.setLastLadder( AsciiString::TheEmptyString, 0 ); - GadgetComboBoxGetSelectedPos(comboBoxNumPlayers, &selected); - if (selected < 0) - selected = 0; - numPlayers = (selected+1)*2; - } - - if (!li || !li->randomMaps) // don't save the map as selected if we couldn't choose - { - Int row = 0; - Int entries = GadgetListBoxGetNumEntries(listboxMapSelect); - while ( row < entries) - { - const MapMetaData *md = (const MapMetaData *)GadgetListBoxGetItemData(listboxMapSelect, row, 1); - if(md) - pref.setMapSelected(md->m_fileName, (Bool)GadgetListBoxGetItemData(listboxMapSelect, row)); - row++; - } - } - - UnicodeString u; - AsciiString a; -// u = GadgetTextEntryGetText(textEntryMaxDisconnects); -// a.translate(u); -// pref.setMaxDisconnects(atoi(a.str())); -// u = GadgetTextEntryGetText(textEntryMaxPoints); -// a.translate(u); -// pref.setMaxPoints(max(100, atoi(a.str()))); -// u = GadgetTextEntryGetText(textEntryMinPoints); -// a.translate(u); -// pref.setMinPoints(min(100, atoi(a.str()))); - //u = GadgetTextEntryGetText(textEntryWaitTime); - //a.translate(u); - //pref.setWaitTime(atoi(a.str())); - - GadgetComboBoxGetSelectedPos(comboBoxNumPlayers, &selected); - pref.setNumPlayers(selected); - GadgetComboBoxGetSelectedPos(comboBoxMaxPing, &selected); - pref.setMaxPing(selected); - - Int item; - GadgetComboBoxGetSelectedPos(comboBoxSide, &selected); - item = (Int)GadgetComboBoxGetItemData(comboBoxSide, selected); - pref.setSide(max(0, item)); - GadgetComboBoxGetSelectedPos(comboBoxColor, &selected); - pref.setColor(max(0, selected)); - - GadgetComboBoxGetSelectedPos(comboBoxMaxDisconnects, &selected); - pref.setMaxDisconnects(selected); - - - pref.write(); -} - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Quick Match Menu */ -//------------------------------------------------------------------------------------------------- -void WOLQuickMatchMenuInit( WindowLayout *layout, void *userData ) -{ - isInInit = TRUE; - if (TheGameSpyGame && TheGameSpyGame->isGameInProgress()) - { - TheGameSpyGame->setGameInProgress(FALSE); - - // check if we were disconnected - Int disconReason; - if (TheGameSpyInfo->isDisconnectedAfterGameStart(&disconReason)) - { - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", disconReason); - UnicodeString title, body; - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheGameSpyInfo->reset(); - DEBUG_LOG(("WOLQuickMatchMenuInit() - game was in progress, and we were disconnected, so pop immediate back to main menu\n")); - TheShell->popImmediate(); - return; - } - } - - nextScreen = NULL; - buttonPushed = false; - isShuttingDown = false; - raiseMessageBoxes = true; - - if (TheNAT != NULL) { - delete TheNAT; - TheNAT = NULL; - } - - parentWOLQuickMatchID = NAMEKEY( "WOLQuickMatchMenu.wnd:WOLQuickMatchMenuParent" ); - buttonBackID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonBack" ); - buttonBuddiesID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonBuddies" ); - buttonStartID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonStart" ); - buttonStopID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonStop" ); - buttonWidenID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonWiden" ); - listboxQuickMatchID = NAMEKEY( "WOLQuickMatchMenu.wnd:ListboxQuickMatch" ); - listboxMapSelectID = NAMEKEY( "WOLQuickMatchMenu.wnd:ListBoxMapSelect" ); - buttonSelectAllMapsID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonSelectAllMaps" ); - buttonSelectNoMapsID = NAMEKEY( "WOLQuickMatchMenu.wnd:ButtonSelectNoMaps" ); - //textEntryMaxDisconnectsID = NAMEKEY( "WOLQuickMatchMenu.wnd:TextEntryMaxDisconnects" ); - //textEntryMaxPointsID = NAMEKEY( "WOLQuickMatchMenu.wnd:TextEntryMaxPointPercent" ); - //textEntryMinPointsID = NAMEKEY( "WOLQuickMatchMenu.wnd:TextEntryMinPointPercent" ); - textEntryWaitTimeID = NAMEKEY( "WOLQuickMatchMenu.wnd:TextEntryWaitTime" ); - comboBoxMaxPingID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxMaxPing" ); - comboBoxNumPlayersID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxNumPlayers" ); - comboBoxLadderID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxLadder" ); - comboBoxMaxDisconnectsID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxMaxDisconnects" ); - staticTextNumPlayersID = NAMEKEY( "WOLQuickMatchMenu.wnd:StaticTextNumPlayers" ); - comboBoxSideID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxSide" ); - comboBoxColorID = NAMEKEY( "WOLQuickMatchMenu.wnd:ComboBoxColor" ); - - parentWOLQuickMatch = TheWindowManager->winGetWindowFromId( NULL, parentWOLQuickMatchID ); - buttonBack = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, buttonBackID); - buttonStart = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, buttonStartID); - buttonStop = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, buttonStopID); - buttonWiden = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, buttonWidenID); - quickmatchTextWindow = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, listboxQuickMatchID); - listboxMapSelect = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, listboxMapSelectID); - //textEntryMaxDisconnects = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, textEntryMaxDisconnectsID ); - //textEntryMaxPoints = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, textEntryMaxPointsID ); - //textEntryMinPoints = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, textEntryMinPointsID ); - textEntryWaitTime = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, textEntryWaitTimeID ); - comboBoxMaxPing = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxMaxPingID ); - comboBoxNumPlayers = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxNumPlayersID ); - comboBoxLadder = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxLadderID ); - comboBoxMaxDisconnects = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxMaxDisconnectsID ); - TheGameSpyInfo->registerTextWindow(quickmatchTextWindow); - staticTextNumPlayers = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, staticTextNumPlayersID ); - comboBoxSide = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxSideID ); - comboBoxColor = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, comboBoxColorID ); - - if (TheLadderList->getStandardLadders()->size() == 0 - && TheLadderList->getSpecialLadders()->size() == 0 - && TheLadderList->getLocalLadders()->size() == 0) - { - // no ladders, so just disable them - comboBoxDisabledLadder = comboBoxLadder; - comboBoxLadder = NULL; - - isPopulatingLadderBox = TRUE; - - Color normalColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED]; - Int index; - GadgetComboBoxReset( comboBoxDisabledLadder ); - index = GadgetComboBoxAddEntry( comboBoxDisabledLadder, TheGameText->fetch("GUI:NoLadder"), normalColor ); - GadgetComboBoxSetItemData( comboBoxDisabledLadder, index, 0 ); - GadgetComboBoxSetSelectedPos( comboBoxDisabledLadder, index ); - - isPopulatingLadderBox = FALSE; - - /** This code would actually *hide* the combo box, but it doesn't look as good. Left here since someone will want to - ** see it at some point. :P - if (comboBoxLadder) - { - comboBoxLadder->winHide(TRUE); - comboBoxLadder->winEnable(FALSE); - } - comboBoxLadder = NULL; - GameWindow *staticTextLadder = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, - NAMEKEY("WOLQuickMatchMenu.wnd:StaticTextLadder") ); - if (staticTextLadder) - staticTextLadder->winHide(TRUE); - */ - } - - GameWindow *buttonBuddies = TheWindowManager->winGetWindowFromId(NULL, buttonBuddiesID); - if (buttonBuddies) - buttonBuddies->winEnable(TRUE); - - GameWindow *staticTextTitle = TheWindowManager->winGetWindowFromId( parentWOLQuickMatch, - NAMEKEY("WOLQuickMatchMenu.wnd:StaticTextTitle") ); - if (staticTextTitle) - { - UnicodeString tmp; - tmp.format(TheGameText->fetch("GUI:QuickMatchTitle"), TheGameSpyInfo->getLocalName().str()); - GadgetStaticTextSetText(staticTextTitle, tmp); - } - - // QM is not going yet, so disable the Widen Search button - buttonWiden->winEnable( FALSE ); - buttonStop->winHide( TRUE ); - buttonStart->winHide( FALSE ); - GadgetListBoxReset(quickmatchTextWindow); - enableOptionsGadgets(TRUE); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLQuickMatch ); - - // fill in preferences - selectedImage = TheMappedImageCollection->findImageByName("CustomMatch_selected"); - unselectedImage = TheMappedImageCollection->findImageByName("CustomMatch_deselected"); - QuickMatchPreferences pref; - - - UnicodeString s; -// s.format(L"%d", pref.getMaxDisconnects()); -// GadgetTextEntrySetText(textEntryMaxDisconnects, s); -// s.format(L"%d", pref.getMaxPoints()); -// GadgetTextEntrySetText(textEntryMaxPoints, s); -// s.format(L"%d", pref.getMinPoints()); -// GadgetTextEntrySetText(textEntryMinPoints, s); - //s.format(L"%d", pref.getWaitTime()); - //GadgetTextEntrySetText(textEntryWaitTime, s); - maxPoints= pref.getMaxPoints(); - minPoints = pref.getMinPoints(); - - Color c = GameSpyColor[GSCOLOR_DEFAULT]; - GadgetComboBoxReset( comboBoxNumPlayers ); - Int i; - for (i=1; i<5; ++i) - { - s.format(TheGameText->fetch("GUI:PlayersVersusPlayers"), i, i); - GadgetComboBoxAddEntry( comboBoxNumPlayers, s, c ); - } - GadgetComboBoxSetSelectedPos( comboBoxNumPlayers, max(0, pref.getNumPlayers()) ); - - GadgetComboBoxReset(comboBoxMaxDisconnects); - GadgetComboBoxAddEntry( comboBoxMaxDisconnects, TheGameText->fetch("GUI:Any"), c); - for( i = 1; i < MAX_DISCONNECTS_COUNT; ++i ) - { - s.format(L"%d", MAX_DISCONNECTS[i]); - GadgetComboBoxAddEntry( comboBoxMaxDisconnects, s, c ); - } - Int maxDisconIndex = max(0, pref.getMaxDisconnects()); - GadgetComboBoxSetSelectedPos(comboBoxMaxDisconnects, maxDisconIndex); - - GadgetComboBoxReset( comboBoxMaxPing ); - maxPingEntries = (TheGameSpyConfig->getPingTimeoutInMs() - 1) / 100; - maxPingEntries++; // need to add the entry for the actual timeout - for (i=1; i fetch("GUI:TimeInMilliseconds"), i*100); - GadgetComboBoxAddEntry( comboBoxMaxPing, s, c ); - } - GadgetComboBoxAddEntry( comboBoxMaxPing, TheGameText->fetch("GUI:ANY"), c ); - i = pref.getMaxPing(); - if( i < 0 ) - i = 0; - if( i >= maxPingEntries ) - i = maxPingEntries - 1; - GadgetComboBoxSetSelectedPos( comboBoxMaxPing, i ); - - populateQMColorComboBox(pref); - populateQMSideComboBox(pref.getSide(), getLadderInfo()); - - PopulateQMLadderComboBox(); - TheShell->showShellMap(TRUE); - TheGameSpyGame->reset(); - - GadgetListBoxReset(listboxMapSelect); - populateQuickMatchMapSelectListbox(pref); - - UpdateLocalPlayerStats(); - UpdateStartButton(); - TheTransitionHandler->setGroup("WOLQuickMatchMenuFade"); - isInInit= FALSE; -} // WOLQuickMatchMenuInit - -//------------------------------------------------------------------------------------------------- -/** This is called when a shutdown is complete for this menu */ -//------------------------------------------------------------------------------------------------- -static void shutdownComplete( WindowLayout *layout ) -{ - - isShuttingDown = false; - - // hide the layout - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout, (nextScreen != NULL) ); - - if (nextScreen != NULL) - { - TheShell->push(nextScreen); - } - - nextScreen = NULL; - -} // end if - -//------------------------------------------------------------------------------------------------- -/** WOL Quick Match Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLQuickMatchMenuShutdown( WindowLayout *layout, void *userData ) -{ - TheGameSpyInfo->unregisterTextWindow(quickmatchTextWindow); - - if (!TheGameEngine->getQuitting()) - saveQuickMatchOptions(); - - parentWOLQuickMatch = NULL; - buttonBack = NULL; - quickmatchTextWindow = NULL; - selectedImage = unselectedImage = NULL; - - isShuttingDown = true; - - // if we are shutting down for an immediate pop, skip the animations - Bool popImmediate = *(Bool *)userData; - if( popImmediate ) - { - - shutdownComplete( layout ); - return; - - } //end if - - TheShell->reverseAnimatewindow(); - TheTransitionHandler->reverse("WOLQuickMatchMenuFade"); - - RaiseGSMessageBox(); -} // WOLQuickMatchMenuShutdown - - -#ifdef PERF_TEST -static const char* getMessageString(Int t) -{ - switch(t) - { - case PeerResponse::PEERRESPONSE_LOGIN: - return "login"; - case PeerResponse::PEERRESPONSE_DISCONNECT: - return "disconnect"; - case PeerResponse::PEERRESPONSE_MESSAGE: - return "message"; - case PeerResponse::PEERRESPONSE_GROUPROOM: - return "group room"; - case PeerResponse::PEERRESPONSE_STAGINGROOM: - return "staging room"; - case PeerResponse::PEERRESPONSE_STAGINGROOMPLAYERINFO: - return "staging room player info"; - case PeerResponse::PEERRESPONSE_JOINGROUPROOM: - return "group room join"; - case PeerResponse::PEERRESPONSE_CREATESTAGINGROOM: - return "staging room create"; - case PeerResponse::PEERRESPONSE_JOINSTAGINGROOM: - return "staging room join"; - case PeerResponse::PEERRESPONSE_PLAYERJOIN: - return "player join"; - case PeerResponse::PEERRESPONSE_PLAYERLEFT: - return "player part"; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDNICK: - return "player nick"; - case PeerResponse::PEERRESPONSE_PLAYERINFO: - return "player info"; - case PeerResponse::PEERRESPONSE_PLAYERCHANGEDFLAGS: - return "player flags"; - case PeerResponse::PEERRESPONSE_ROOMUTM: - return "room UTM"; - case PeerResponse::PEERRESPONSE_PLAYERUTM: - return "player UTM"; - case PeerResponse::PEERRESPONSE_QUICKMATCHSTATUS: - return "QM status"; - case PeerResponse::PEERRESPONSE_GAMESTART: - return "game start"; - case PeerResponse::PEERRESPONSE_FAILEDTOHOST: - return "host failure"; - } - return "unknown"; -} -#endif // PERF_TEST - -//------------------------------------------------------------------------------------------------- -/** WOL Quick Match Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLQuickMatchMenuUpdate( WindowLayout * layout, void *userData) -{ - if (TheGameLogic->isInShellGame() && TheGameLogic->getFrame() == 1) - { - SignalUIInteraction(SHELL_SCRIPT_HOOK_GENERALS_ONLINE_ENTERED_FROM_GAME); - } - - // We'll only be successful if we've requested to - if(isShuttingDown && TheShell->isAnimFinished()&& TheTransitionHandler->isFinished()) - shutdownComplete(layout); - - if (raiseMessageBoxes) - { - RaiseGSMessageBox(); - raiseMessageBoxes = false; - } - - /// @todo: MDC handle disconnects in-game the same way as Custom Match! - - if (TheShell->isAnimFinished() && !buttonPushed && TheGameSpyPeerMessageQueue) - { - HandleBuddyResponses(); - HandlePersistentStorageResponses(); - - if (TheGameSpyGame && TheGameSpyGame->isGameInProgress()) - { - if (TheGameSpyInfo->isDisconnectedAfterGameStart(NULL)) - { - return; // already been disconnected, so don't worry. - } - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - PeerResponse resp; - while (allowedMessages-- && !sawImportantMessage && TheGameSpyPeerMessageQueue->getResponse( resp )) - { - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - - // check for scorescreen - NameKeyType listboxChatWindowScoreScreenID = NAMEKEY("ScoreScreen.wnd:ListboxChatWindowScoreScreen"); - GameWindow *listboxChatWindowScoreScreen = TheWindowManager->winGetWindowFromId( NULL, listboxChatWindowScoreScreenID ); - if (listboxChatWindowScoreScreen) - { - GadgetListBoxAddEntryText(listboxChatWindowScoreScreen, TheGameText->fetch(disconMunkee), - GameSpyColor[GSCOLOR_DEFAULT], -1); - } - else - { - // still ingame - TheInGameUI->message(disconMunkee); - } - TheGameSpyInfo->markAsDisconnectedAfterGameStart(resp.discon.reason); - } - } - } - - return; // if we're in game, all we care about is if we've been disconnected from the chat server - } - - if (TheNAT != NULL) { - NATStateType NATState = TheNAT->update(); - if (NATState == NATSTATE_DONE) - { - TheGameSpyGame->launchGame(); - if (TheGameSpyInfo) // this can be blown away by a disconnect on the map transfer screen - TheGameSpyInfo->leaveStagingRoom(); - return; // don't do any more processing this frame, in case the screen goes away - } - else if (NATState == NATSTATE_FAILED) - { - // delete TheNAT, its no good for us anymore. - delete TheNAT; - TheNAT = NULL; - - // Just back out. This cleans up some slot list problems - buttonPushed = true; - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:NATNegotiationFailed")); - nextScreen = "Menus/WOLWelcomeMenu.wnd"; - TheShell->pop(); - return; // don't do any more processing this frame, in case the screen goes away - } - } - -#ifdef PERF_TEST - UnsignedInt start = timeGetTime(); - UnsignedInt end = timeGetTime(); - std::list responses; - Int numMessages = 0; -#endif // PERF_TEST - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - PeerResponse resp; - while (allowedMessages-- && !sawImportantMessage && TheGameSpyPeerMessageQueue->getResponse( resp )) - { -#ifdef PERF_TEST - ++numMessages; - responses.push_back(resp.peerResponseType); -#endif // PERF_TEST - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_PLAYERUTM: - { - if (!stricmp(resp.command.c_str(), "STATS")) - { - DEBUG_LOG(("Saw STATS from %s, data was '%s'\n", resp.nick.c_str(), resp.commandOptions.c_str())); - AsciiString data = resp.commandOptions.c_str(); - AsciiString idStr; - data.nextToken(&idStr, " "); - Int id = atoi(idStr.str()); - DEBUG_LOG(("data: %d(%s) - '%s'\n", id, idStr.str(), data.str())); - - PSPlayerStats stats = TheGameSpyPSMessageQueue->parsePlayerKVPairs(data.str()); - PSPlayerStats oldStats = TheGameSpyPSMessageQueue->findPlayerStatsByID(id); - stats.id = id; - DEBUG_LOG(("Parsed ID is %d, old ID is %d\n", stats.id, oldStats.id)); - if (stats.id && (oldStats.id == 0)) - TheGameSpyPSMessageQueue->trackPlayerStats(stats); - - // now fill in the profileID in the game slot - AsciiString nick = resp.nick.c_str(); - for (Int i=0; igetGameSpySlot(i); - if (slot && slot->isHuman() && (slot->getLoginName().compareNoCase(nick) == 0)) - { - slot->setProfileID(id); - break; - } - } - } - Int slotNum = TheGameSpyGame->getSlotNum(resp.nick.c_str()); - if ((slotNum >= 0) && (slotNum < MAX_SLOTS) && (!stricmp(resp.command.c_str(), "NAT"))) { - // this is a command for NAT negotiations, pass if off to TheNAT - sawImportantMessage = TRUE; - if (TheNAT != NULL) { - TheNAT->processGlobalMessage(slotNum, resp.commandOptions.c_str()); - } - } - /* - else if (key == "NAT") - { - if ((val >= FirewallHelperClass::FIREWALL_TYPE_SIMPLE) && - (val <= FirewallHelperClass::FIREWALL_TYPE_DESTINATION_PORT_DELTA)) - { - slot->setNATBehavior((FirewallHelperClass::FirewallBehaviorType)val); - DEBUG_LOG(("Setting NAT behavior to %d for player %d\n", val, slotNum)); - change = true; - } - else - { - DEBUG_LOG(("Rejecting invalid NAT behavior %d from player %d\n", val, slotNum)); - } - } - */ - } - break; - - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheGameSpyInfo->reset(); - TheShell->pop(); - } - break; // LORENZEN ADDED. SORRY IF THIS "BREAKS" IT... - - - case PeerResponse::PEERRESPONSE_JOINGROUPROOM: - /* - if (resp.joinGroupRoom.ok) - { - TheGameSpyInfo->addText(UnicodeString(L"Joined group room"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - else - { - TheGameSpyInfo->addText(UnicodeString(L"Didn't join group room"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - */ - break; - case PeerResponse::PEERRESPONSE_PLAYERJOIN: - { - //UnicodeString str; - //str.format(L"Player %hs joined the room", resp.nick.c_str()); - //TheGameSpyInfo->addText(str, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - break; - case PeerResponse::PEERRESPONSE_PLAYERLEFT: - { - //UnicodeString str; - //str.format(L"Player %hs left the room", resp.nick.c_str()); - //TheGameSpyInfo->addText(str, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - break; - case PeerResponse::PEERRESPONSE_MESSAGE: - { - //UnicodeString m; - //m.format(L"[%hs]: %ls", resp.nick.c_str(), resp.text.c_str()); - //TheGameSpyInfo->addText(m, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - break; - - -// LORENZEN EXPRESSES DOUBT ABOUT THIS ONE, AS IT MAY HAVE SUFFERED MERGE MANGLING... SORRY - // I THINK THIS IS THE OBSOLETE VERSION... SEE THE NEWER LOOKING ONE ABOVE -/* - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheGameSpyInfo->reset(); - TheShell->pop(); - } -*/ - - - - case PeerResponse::PEERRESPONSE_CREATESTAGINGROOM: - { - if (resp.createStagingRoom.result == PEERJoinSuccess) - { - // Woohoo! On to our next screen! - UnicodeString str; - str.format(L"Created staging room"); - TheGameSpyInfo->addText(str, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - else - { - UnicodeString s; - s.format(L"createStagingRoom result: %d", resp.createStagingRoom.result); - TheGameSpyInfo->addText( s, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow ); - } - } - break; - case PeerResponse::PEERRESPONSE_JOINSTAGINGROOM: - { - if (resp.joinStagingRoom.ok == PEERTrue) - { - // Woohoo! On to our next screen! - UnicodeString s; - s.format(L"joinStagingRoom result: %d", resp.joinStagingRoom.ok); - TheGameSpyInfo->addText( s, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow ); - } - else - { - UnicodeString s; - s.format(L"joinStagingRoom result: %d", resp.joinStagingRoom.ok); - TheGameSpyInfo->addText( s, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow ); - } - } - break; - case PeerResponse::PEERRESPONSE_STAGINGROOM: - { - UnicodeString str; - str.format(L"Staging room list callback", resp.nick.c_str()); - TheGameSpyInfo->addText(str, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - break; - case PeerResponse::PEERRESPONSE_QUICKMATCHSTATUS: - { - sawImportantMessage = TRUE; - switch( resp.qmStatus.status ) - { - case QM_IDLE: - //TheGameSpyInfo->addText(UnicodeString(L"Status: QM_IDLE"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_JOININGQMCHANNEL: - TheGameSpyInfo->addText(TheGameText->fetch("QM:JOININGQMCHANNEL"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_LOOKINGFORBOT: - TheGameSpyInfo->addText(TheGameText->fetch("QM:LOOKINGFORBOT"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_SENTINFO: - TheGameSpyInfo->addText(TheGameText->fetch("QM:SENTINFO"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_WORKING: - { - UnicodeString s; - s.format(TheGameText->fetch("QM:WORKING"), resp.qmStatus.poolSize); - TheGameSpyInfo->addText(s, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - buttonWiden->winEnable( TRUE ); - break; - case QM_POOLSIZE: - { - UnicodeString s; - s.format(TheGameText->fetch("QM:POOLSIZE"), resp.qmStatus.poolSize); - TheGameSpyInfo->addText(s, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - break; - case QM_WIDENINGSEARCH: - TheGameSpyInfo->addText(TheGameText->fetch("QM:WIDENINGSEARCH"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - break; - case QM_MATCHED: - { - TheGameSpyInfo->addText(TheGameText->fetch("QM:MATCHED"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - - TheGameSpyGame->enterGame(); - TheGameSpyGame->setSeed(resp.qmStatus.seed); - - TheGameSpyGame->markGameAsQM(); - - const LadderInfo *info = getLadderInfo(); - if (!info) - { - TheGameSpyGame->setLadderIP("localhost"); - TheGameSpyGame->setLadderPort(0); - } - else - { - TheGameSpyGame->setLadderIP(info->address); - TheGameSpyGame->setLadderPort(info->port); - } - - Int i; - Int numPlayers = 0; - for (i=0; i maps = TheGameSpyConfig->getQMMaps(); - for (std::list::const_iterator it = maps.begin(); it != maps.end(); ++it) - { - AsciiString theMap = *it; - theMap.toLower(); - const MapMetaData *md = TheMapCache->findMap(theMap); - if (md && md->m_numPlayers >= numPlayers) - { - TheGameSpyGame->setMap(*it); - if (resp.qmStatus.mapIdx-- == 0) - break; - } - } - - Int numPlayersPerTeam = numPlayers/2; - DEBUG_ASSERTCRASH(numPlayersPerTeam, ("0 players per team???")); - if (!numPlayersPerTeam) - numPlayersPerTeam = 1; - - for (i=0; igetGameSpySlot(i); - if (resp.stagingRoomPlayerNames[i].empty()) - { - slot->setState(SLOT_CLOSED); - } - else - { - AsciiString aName = resp.stagingRoomPlayerNames[i].c_str(); - UnicodeString uName; - uName.translate(aName); - slot->setState(SLOT_PLAYER, uName, resp.qmStatus.IP[i]); - slot->setColor(resp.qmStatus.color[i]); - slot->setPlayerTemplate(resp.qmStatus.side[i]); - //slot->setProfileID(0); - slot->setNATBehavior((FirewallHelperClass::FirewallBehaviorType)resp.qmStatus.nat[i]); - slot->setLocale(""); - slot->setTeamNumber( i/numPlayersPerTeam ); - if (i==0) - TheGameSpyGame->setGameName(uName); - } - } - - DEBUG_LOG(("Starting a QM game: options=[%s]\n", GameInfoToAsciiString(TheGameSpyGame).str())); - SendStatsToOtherPlayers(TheGameSpyGame); - TheGameSpyGame->startGame(0); - GameWindow *buttonBuddies = TheWindowManager->winGetWindowFromId(NULL, buttonBuddiesID); - if (buttonBuddies) - buttonBuddies->winEnable(FALSE); - GameSpyCloseOverlay(GSOVERLAY_BUDDY); - } - break; - case QM_INCHANNEL: - TheGameSpyInfo->addText(TheGameText->fetch("QM:INCHANNEL"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_NEGOTIATINGFIREWALLS: - TheGameSpyInfo->addText(TheGameText->fetch("QM:NEGOTIATINGFIREWALLS"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_STARTINGGAME: - TheGameSpyInfo->addText(TheGameText->fetch("QM:STARTINGGAME"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - break; - case QM_COULDNOTFINDBOT: - TheGameSpyInfo->addText(TheGameText->fetch("QM:COULDNOTFINDBOT"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( FALSE ); - buttonStop->winHide( TRUE ); - enableOptionsGadgets(TRUE); - break; - case QM_COULDNOTFINDCHANNEL: - TheGameSpyInfo->addText(TheGameText->fetch("QM:COULDNOTFINDCHANNEL"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( FALSE ); - buttonStop->winHide( TRUE ); - enableOptionsGadgets(TRUE); - break; - case QM_COULDNOTNEGOTIATEFIREWALLS: - TheGameSpyInfo->addText(TheGameText->fetch("QM:COULDNOTNEGOTIATEFIREWALLS"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( FALSE ); - buttonStop->winHide( TRUE ); - enableOptionsGadgets(TRUE); - break; - case QM_STOPPED: - TheGameSpyInfo->addText(TheGameText->fetch("QM:STOPPED"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( FALSE ); - buttonStop->winHide( TRUE ); - enableOptionsGadgets(TRUE); - break; - } - } - break; - } - } -#ifdef PERF_TEST - // check performance - end = timeGetTime(); - UnsignedInt frameTime = end-start; - if (frameTime > 100 || responses.size() > 20) - { - UnicodeString munkee; - munkee.format(L"inQM:%d %d ms, %d messages", s_inQM, frameTime, responses.size()); - TheGameSpyInfo->addText(munkee, GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - PERF_LOG(("%ls\n", munkee.str())); - - std::list::const_iterator it; - for (it = responses.begin(); it != responses.end(); ++it) - { - PERF_LOG((" %s\n", getMessageString(*it))); - } - } -#endif // PERF_TEST - } -}// WOLQuickMatchMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Quick Match Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLQuickMatchMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - if (buttonPushed) - break; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - if(!buttonBack->winIsHidden()) - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLQuickMatchMenuInput - -//------------------------------------------------------------------------------------------------- -/** WOL Quick Match Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLQuickMatchMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GCM_SELECTED: - { - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - Int pos = -1; - GadgetComboBoxGetSelectedPos(control, &pos); - - saveQuickMatchOptions(); - if (controlID == comboBoxLadderID && !isPopulatingLadderBox) - { - if (pos >= 0) - { - QuickMatchPreferences pref; - Int ladderID = (Int)GadgetComboBoxGetItemData(control, pos); - if (ladderID == 0) - { - // no ladder selected - enable buttons - GadgetComboBoxSetSelectedPos(comboBoxNumPlayers, max(0, pref.getNumPlayers()/2-1)); - comboBoxNumPlayers->winEnable( TRUE ); - populateQMSideComboBox(pref.getSide()); // this will set side to random and disable if necessary - } - else if (ladderID > 0) - { - // ladder selected - disable buttons - const LadderInfo *li = TheLadderList->findLadderByIndex(ladderID); - if (li) - GadgetComboBoxSetSelectedPos(comboBoxNumPlayers, li->playersPerTeam-1); - else - GadgetComboBoxSetSelectedPos(comboBoxNumPlayers, 0); - comboBoxNumPlayers->winEnable( FALSE ); - - populateQMSideComboBox(pref.getSide(), li); // this will set side to random and disable if necessary - } - else - { - // "Choose a ladder" selected - open overlay - PopulateQMLadderComboBox(); // this restores the non-"Choose a ladder" selection - GameSpyOpenOverlay( GSOVERLAY_LADDERSELECT ); - } - } - } - if (!isInInit) - { - QuickMatchPreferences pref; - populateQuickMatchMapSelectListbox(pref); - UpdateStartButton(); - } - break; - } // case GCM_SELECTED - - case GBM_SELECTED: - { - if (buttonPushed) - break; - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - static NameKeyType buttonOptionsID = NAMEKEY("WOLQuickMatchMenu.wnd:ButtonOptions"); - - if ( controlID == buttonStopID ) - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STOPQUICKMATCH; - TheGameSpyPeerMessageQueue->addRequest(req); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( FALSE ); - buttonStop->winHide( TRUE ); - enableOptionsGadgets(TRUE); - TheGameSpyInfo->addText(TheGameText->fetch("GUI:QMAborted"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow); - } - else if ( controlID == buttonOptionsID ) - { - GameWindow *win =TheWindowManager->winGetWindowFromId(parentWOLQuickMatch,buttonOptionsID); - if (isInfoShown()) - { - hideInfoGadgets(TRUE); - hideOptionsGadgets(FALSE); - GadgetButtonSetText(win, TheGameText->fetch("GUI:PlayerInfo")); - } - else - { - hideInfoGadgets(FALSE); - hideOptionsGadgets(TRUE); - GadgetButtonSetText(win, TheGameText->fetch("GUI:Setup")); - } - } - else if ( controlID == buttonWidenID ) - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_WIDENQUICKMATCHSEARCH; - TheGameSpyPeerMessageQueue->addRequest(req); - buttonWiden->winEnable( FALSE ); - } - else if ( controlID == buttonStartID ) - { - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_STARTQUICKMATCH; - req.qmMaps.clear(); - Int numMaps = GadgetListBoxGetNumEntries(listboxMapSelect); - for ( Int i=0; i= maxPingEntries - 1) - { - req.QM.maxPing = TheGameSpyConfig->getPingTimeoutInMs(); - } - else - req.QM.maxPing = (val+1)*100; - - PSPlayerStats stats = TheGameSpyPSMessageQueue->findPlayerStatsByID(TheGameSpyInfo->getLocalProfileID()); - req.QM.points = CalculateRank(stats); - - Int ladderIndex, index, selected; - GadgetComboBoxGetSelectedPos( comboBoxLadder, &selected ); - ladderIndex = (Int)GadgetComboBoxGetItemData( comboBoxLadder, selected ); - const LadderInfo *ladderInfo = NULL; - if (ladderIndex < 0) - { - ladderIndex = 0; - } - if (ladderIndex) - { - ladderInfo = TheLadderList->findLadderByIndex( ladderIndex ); - if (!ladderInfo) - { - ladderIndex = 0; // sanity - } - } - req.QM.ladderID = ladderIndex; - - req.QM.ladderPassCRC = 0; - - index = -1; - GadgetComboBoxGetSelectedPos( comboBoxSide, &selected ); - if (selected >= 0) - index = (Int)GadgetComboBoxGetItemData( comboBoxSide, selected ); - req.QM.side = index; - if (ladderInfo && ladderInfo->randomFactions) - { - Int sideNum = GameClientRandomValue(0, ladderInfo->validFactions.size()-1); - DEBUG_LOG(("Looking for %d out of %d random sides\n", sideNum, ladderInfo->validFactions.size())); - AsciiStringListConstIterator cit = ladderInfo->validFactions.begin(); - while (sideNum) - { - ++cit; - --sideNum; - } - if (cit != ladderInfo->validFactions.end()) - { - Int numPlayerTemplates = ThePlayerTemplateStore->getPlayerTemplateCount(); - AsciiString sideStr = *cit; - DEBUG_LOG(("Chose %s as our side... finding\n", sideStr.str())); - for (Int c=0; cgetNthPlayerTemplate(c); - if (fac && fac->getSide() == sideStr) - { - DEBUG_LOG(("Found %s in index %d\n", sideStr.str(), c)); - req.QM.side = c; - break; - } - } - } - } - else if( index == PLAYERTEMPLATE_RANDOM ) - { - // If not a forced random ladder, then we need to resolve our pick of random right now anyway, or else - // we will get the same pick every darn time. - Int randomTries = 0;// Rare to hit Random 10 times in a row, but if it does then random will be converted to a set side by the very bug this tries to fix, so no harm done. - - while( randomTries < 10 && index == PLAYERTEMPLATE_RANDOM ) - { - Int numberComboBoxEntries = GadgetComboBoxGetLength(comboBoxSide); - Int randomPick = GameClientRandomValue(0, numberComboBoxEntries - 1); - index = (Int)GadgetComboBoxGetItemData( comboBoxSide, randomPick ); - req.QM.side = index; - - randomTries++; - } - } - - index = -1; - GadgetComboBoxGetSelectedPos( comboBoxColor, &selected ); - if (selected >= 0) - index = (Int)GadgetComboBoxGetItemData( comboBoxColor, selected ); - req.QM.color = index; - - OptionPreferences natPref; - req.QM.NAT = natPref.getFirewallBehavior(); - - if (ladderIndex) - { - req.QM.numPlayers = (ladderInfo)?ladderInfo->playersPerTeam*2 : 2; - } - else - { - GadgetComboBoxGetSelectedPos(comboBoxNumPlayers, &val); - if (val < 0) - val = 0; - req.QM.numPlayers = (val+1)*2; - } - - Int numDiscons = 0; - PerGeneralMap::iterator it; - for(it =stats.discons.begin(); it != stats.discons.end(); ++it) - { - numDiscons += it->second; - } - for(it =stats.desyncs.begin(); it != stats.desyncs.end(); ++it) - { - numDiscons += it->second; - } - req.QM.discons = numDiscons; - - - strncpy(req.QM.pings, TheGameSpyInfo->getPingString().str(), 17); - req.QM.pings[16] = 0; - - req.QM.botID = TheGameSpyConfig->getQMBotID(); - req.QM.roomID = TheGameSpyConfig->getQMChannel(); - - req.QM.exeCRC = TheGlobalData->m_exeCRC; - req.QM.iniCRC = TheGlobalData->m_iniCRC; - - TheGameSpyPeerMessageQueue->addRequest(req); - buttonWiden->winEnable( FALSE ); - buttonStart->winHide( TRUE ); - buttonStop->winHide( FALSE ); - enableOptionsGadgets(FALSE); - - if (ladderIndex > 0) - { - // save the ladder as being played upon even if we cancel out of matching early... - LadderPreferences ladPref; - ladPref.loadProfile( TheGameSpyInfo->getLocalProfileID() ); - LadderPref p; - p.lastPlayDate = time(NULL); - p.address = ladderInfo->address; - p.port = ladderInfo->port; - p.name = ladderInfo->name; - ladPref.addRecentLadder( p ); - ladPref.write(); - } - } - else if ( controlID == buttonBuddiesID ) - { - GameSpyToggleOverlay( GSOVERLAY_BUDDY ); - } - else if ( controlID == buttonBackID ) - { - buttonPushed = true; - TheGameSpyInfo->leaveGroupRoom(); - nextScreen = "Menus/WOLWelcomeMenu.wnd"; - TheShell->pop(); - } //if ( controlID == buttonBack ) - else if ( controlID == buttonSelectAllMapsID ) - { - Int numMaps = GadgetListBoxGetNumEntries(listboxMapSelect); - for ( Int i=0; iwinGetWindowId(); - Int selected = (Int)mData2; - - if ( controlID == listboxMapSelectID ) - { - const LadderInfo *li = getLadderInfo(); - if (selected >= 0 && (!li || !li->randomMaps)) - { - Bool wasSelected = (Bool)GadgetListBoxGetItemData(control, selected, 0); - GadgetListBoxSetItemData(control, (void *)(!wasSelected), selected, 0); - Int width = 10; - Int height = 10; - const Image *img = (!wasSelected)?selectedImage:unselectedImage; - if ( img ) - { - width = min(GadgetListBoxGetColumnWidth(control, 0), img->getImageWidth()); - height = width; - } - GadgetListBoxAddEntryImage(control, img, selected, 0, height, width); - GadgetListBoxAddEntryText(control, GadgetListBoxGetText(control, selected, 1), GameSpyColor[(wasSelected)?GSCOLOR_MAP_UNSELECTED:GSCOLOR_MAP_SELECTED], selected, 1); - } - if (selected >= 0) - GadgetListBoxSetSelected(control, -1); - } - UpdateStartButton(); - break; - }// case GLM_SELECTED - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLQuickMatchMenuSystem diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLStatusMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLStatusMenu.cpp deleted file mode 100644 index e951b7ed935..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLStatusMenu.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLLoginMenu.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "Common/GameEngine.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -//#include "GameNetwork/WOL.h" -//#include "GameNetwork/WOLmenus.h" - - - -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLStatusID = NAMEKEY_INVALID; -static NameKeyType buttonDisconnectID = NAMEKEY_INVALID; - -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLStatus = NULL; -static GameWindow *buttonDisconnect = NULL; -GameWindow *progressTextWindow = NULL; - -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Status Menu */ -//------------------------------------------------------------------------------------------------- -void WOLStatusMenuInit( WindowLayout *layout, void *userData ) -{ - parentWOLStatusID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLStatusMenu.wnd:WOLStatusMenuParent" ) ); - buttonDisconnectID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLStatusMenu.wnd:ButtonDisconnect" ) ); - parentWOLStatus = TheWindowManager->winGetWindowFromId( NULL, parentWOLStatusID ); - buttonDisconnect = TheWindowManager->winGetWindowFromId( NULL, buttonDisconnectID); - - progressTextWindow = TheWindowManager->winGetWindowFromId( NULL, - TheNameKeyGenerator->nameToKey( AsciiString( "WOLStatusMenu.wnd:ListboxStatus" ) ) ); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLStatus ); - - //progressLayout = TheShell->top(); - - //WOL::raiseWOLMessageBox(); -} // WOLStatusMenuInit - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLStatusMenuShutdown( WindowLayout *layout, void *userData ) -{ - - // hide menu - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout ); - - //progressLayout = NULL; - - //WOL::raiseWOLMessageBox(); -} // WOLStatusMenuShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLStatusMenuUpdate( WindowLayout * layout, void *userData) -{ - //if (WOL::TheWOL) - //WOL::TheWOL->update(); -}// WOLStatusMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLStatusMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonDisconnect, buttonDisconnectID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLStatusMenuInput - -//------------------------------------------------------------------------------------------------- -/** WOL Status Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLStatusMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - /* - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == buttonDisconnectID ) - { - //TheShell->pop(); - if (WOL::TheWOL->setState( WOL::WOLAPI_FATAL_ERROR )) - { - WOL::TheWOL->addCommand( WOL::WOLCOMMAND_RESET ); // don't display an error, log out, or anything - } - - } //if ( controlID == buttonDisconnect ) - */ - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLStatusMenuSystem diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp deleted file mode 100644 index 6aaf468ffd5..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp +++ /dev/null @@ -1,905 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: WOLWelcomeMenu.cpp -// Author: Chris Huybregts, November 2001 -// Description: Lan Lobby Menu -/////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine - -#include "GameSpy/peer/peer.h" - -#include "Common/GameEngine.h" -#include "Common/GameSpyMiscPreferences.h" -#include "Common/CustomMatchPreferences.h" -#include "Common/GlobalData.h" -#include "Common/UserPreferences.h" -#include "Common/PlayerTemplate.h" - -#include "GameClient/AnimateWindowManager.h" -#include "GameClient/Display.h" -#include "GameClient/WindowLayout.h" -#include "GameClient/Gadget.h" -#include "GameClient/GameText.h" -#include "GameClient/Shell.h" -#include "GameClient/KeyDefs.h" -#include "GameClient/GameWindowManager.h" -#include "GameClient/GadgetListBox.h" -#include "GameClient/GadgetTextEntry.h" -#include "GameClient/GadgetStaticText.h" -#include "GameClient/GadgetCheckBox.h" -#include "GameClient/MessageBox.h" -#include "GameClient/GameWindowTransitions.h" - -#include "GameNetwork/FirewallHelper.h" -#include "GameNetwork/GameSpyOverlay.h" - -#include "GameNetwork/GameSpy/BuddyDefs.h" -#include "GameNetwork/GameSpy/BuddyThread.h" -#include "GameNetwork/GameSpy/PeerDefs.h" -#include "GameNetwork/GameSpy/PeerThread.h" -#include "GameNetwork/GameSpy/PersistentStorageDefs.h" -#include "GameNetwork/GameSpy/PersistentStorageThread.h" -#include "GameNetwork/GameSpy/BuddyThread.h" -#include "GameNetwork/GameSpy/ThreadUtils.h" -#include "GameNetwork/GameSpy/MainMenuUtils.h" - -#ifdef _INTERNAL -// for occasional debugging... -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") -#endif -// PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// -static Bool isShuttingDown = FALSE; -static Bool buttonPushed = FALSE; -static char *nextScreen = NULL; - -// window ids ------------------------------------------------------------------------------ -static NameKeyType parentWOLWelcomeID = NAMEKEY_INVALID; -static NameKeyType buttonBackID = NAMEKEY_INVALID; -static NameKeyType buttonQuickMatchID = NAMEKEY_INVALID; -static NameKeyType buttonLobbyID = NAMEKEY_INVALID; -static NameKeyType buttonBuddiesID = NAMEKEY_INVALID; -static NameKeyType buttonLadderID = NAMEKEY_INVALID; -static NameKeyType buttonMyInfoID = NAMEKEY_INVALID; - -static NameKeyType listboxInfoID = NAMEKEY_INVALID; -static NameKeyType buttonOptionsID = NAMEKEY_INVALID; -// Window Pointers ------------------------------------------------------------------------ -static GameWindow *parentWOLWelcome = NULL; -static GameWindow *buttonBack = NULL; -static GameWindow *buttonQuickMatch = NULL; -static GameWindow *buttonLobby = NULL; -static GameWindow *buttonBuddies = NULL; -static GameWindow *buttonLadder = NULL; -static GameWindow *buttonMyInfo = NULL; -static GameWindow *buttonbuttonOptions = NULL; -static WindowLayout *welcomeLayout = NULL; -static GameWindow *listboxInfo = NULL; - -static GameWindow *staticTextServerName = NULL; -static GameWindow *staticTextLastUpdated = NULL; - -static GameWindow *staticTextLadderWins = NULL; -static GameWindow *staticTextLadderLosses = NULL; -static GameWindow *staticTextLadderRank = NULL; -static GameWindow *staticTextLadderPoints = NULL; -static GameWindow *staticTextLadderDisconnects = NULL; - -static GameWindow *staticTextHighscoreWins = NULL; -static GameWindow *staticTextHighscoreLosses = NULL; -static GameWindow *staticTextHighscoreRank = NULL; -static GameWindow *staticTextHighscorePoints = NULL; - -static UnicodeString gServerName; -void updateServerDisplay(UnicodeString serverName) -{ - if (staticTextServerName) - { - GadgetStaticTextSetText(staticTextServerName, serverName); - } - gServerName = serverName; -} - -/* -void updateLocalPlayerScores(AsciiString name, const WOL::Ladder *ladder, const WOL::Highscore *highscore) -{ - if (ladder) - { - AsciiString a; - UnicodeString u; - - a.format("%d", ladder->wins); - u.translate(a); - GadgetStaticTextSetText(staticTextLadderWins, u); - - a.format("%d", ladder->losses); - u.translate(a); - GadgetStaticTextSetText(staticTextLadderLosses, u); - - a.format("%d", ladder->rank); - u.translate(a); - GadgetStaticTextSetText(staticTextLadderRank, u); - - a.format("%d", ladder->points); - u.translate(a); - GadgetStaticTextSetText(staticTextLadderPoints, u); - - a.format("%d", ladder->disconnects); - u.translate(a); - GadgetStaticTextSetText(staticTextLadderDisconnects, u); - } - if (highscore) - { - AsciiString a; - UnicodeString u; - - a.format("%d", highscore->wins); - u.translate(a); - GadgetStaticTextSetText(staticTextHighscoreWins, u); - - a.format("%d", highscore->losses); - u.translate(a); - GadgetStaticTextSetText(staticTextHighscoreLosses, u); - - a.format("%d", highscore->rank); - u.translate(a); - GadgetStaticTextSetText(staticTextHighscoreRank, u); - - a.format("%d", highscore->points); - u.translate(a); - GadgetStaticTextSetText(staticTextHighscorePoints, u); - } -} -*/ - - -static void enableControls( Bool state ) -{ - if (buttonQuickMatch) - buttonQuickMatch->winEnable(state); - if (buttonLobby) - buttonLobby->winEnable(state); -} - -//------------------------------------------------------------------------------------------------- -/** This is called when a shutdown is complete for this menu */ -//------------------------------------------------------------------------------------------------- -static void shutdownComplete( WindowLayout *layout ) -{ - - isShuttingDown = FALSE; - - // hide the layout - layout->hide( TRUE ); - - // our shutdown is complete - TheShell->shutdownComplete( layout, (nextScreen != NULL) ); - - if (nextScreen != NULL) - { - TheShell->push(nextScreen); - } - - nextScreen = NULL; - -} // end if - -//------------------------------------------------------------------------------------------------- -/** Handle Num Players Online data */ -//------------------------------------------------------------------------------------------------- - -static Int lastNumPlayersOnline = 0; - -static UnsignedByte grabUByte(const char *s) -{ - char tmp[5] = "0xff"; - tmp[2] = s[0]; - tmp[3] = s[1]; - UnsignedByte b = strtol(tmp, NULL, 16); - return b; -} - -static void updateNumPlayersOnline(void) -{ - GameWindow *playersOnlineWindow = TheWindowManager->winGetWindowFromId( - NULL, NAMEKEY("WOLWelcomeMenu.wnd:StaticTextNumPlayersOnline") ); - - if (playersOnlineWindow) - { - UnicodeString valStr; - valStr.format(TheGameText->fetch("GUI:NumPlayersOnline"), lastNumPlayersOnline); - GadgetStaticTextSetText(playersOnlineWindow, valStr); - } - - if (listboxInfo && TheGameSpyInfo) - { - GadgetListBoxReset(listboxInfo); - AsciiString aLine; - UnicodeString line; - AsciiString aMotd = TheGameSpyInfo->getMOTD(); - UnicodeString headingStr; - //Kris: Patch 1.01 - November 12, 2003 - //Removed number of players from string, and removed the argument. The number is incorrect anyways... - //This was a Harvard initiated fix. - headingStr.format(TheGameText->fetch("MOTD:NumPlayersHeading")); - - while (headingStr.nextToken(&line, UnicodeString(L"\n"))) - { - if (line.getCharAt(line.getLength()-1) == '\r') - line.removeLastChar(); // there is a trailing '\r' - - line.trim(); - - if (line.isEmpty()) - { - line = UnicodeString(L" "); - } - - GadgetListBoxAddEntryText(listboxInfo, line, GameSpyColor[GSCOLOR_MOTD_HEADING], -1, -1); - } - GadgetListBoxAddEntryText(listboxInfo, UnicodeString(L" "), GameSpyColor[GSCOLOR_MOTD_HEADING], -1, -1); - - while (aMotd.nextToken(&aLine, "\n")) - { - if (aLine.getCharAt(aLine.getLength()-1) == '\r') - aLine.removeLastChar(); // there is a trailing '\r' - - aLine.trim(); - - if (aLine.isEmpty()) - { - aLine = " "; - } - - Color c = GameSpyColor[GSCOLOR_MOTD]; - if (aLine.startsWith("\\\\")) - { - aLine = aLine.str()+1; - } - else if (aLine.startsWith("\\") && aLine.getLength() > 9) - { - // take out the hex value from strings starting as "\ffffffffText" - UnsignedByte a, r, g, b; - a = grabUByte(aLine.str()+1); - r = grabUByte(aLine.str()+3); - g = grabUByte(aLine.str()+5); - b = grabUByte(aLine.str()+7); - c = GameMakeColor(r, g, b, a); - DEBUG_LOG(("MOTD line '%s' has color %X\n", aLine.str(), c)); - aLine = aLine.str() + 9; - } - line = UnicodeString(MultiByteToWideCharSingleLine(aLine.str()).c_str()); - - GadgetListBoxAddEntryText(listboxInfo, line, c, -1, -1); - } - } -} - -void HandleNumPlayersOnline( Int numPlayersOnline ) -{ - lastNumPlayersOnline = numPlayersOnline; - if (lastNumPlayersOnline < 1) - lastNumPlayersOnline = 1; - updateNumPlayersOnline(); -} - -//------------------------------------------------------------------------------------------------- -/** Handle Overall Stats data */ -//------------------------------------------------------------------------------------------------- -static std::map s_winStats; -static float s_totalWinPercent = 0; - -static const char* FindNextNumber( const char* pStart ) -{ - char* pNum = strchr( pStart, '\n' ); //go to next line - if( !pNum ) - return pStart; //error - - while( !isdigit(*pNum) ) - ++pNum; //go to next number - return pNum; -} - - -//parse win/loss stats received from GameSpy -void HandleOverallStats( const char* szHTTPStats, unsigned len ) -{ -//x DEBUG_LOG(("Parsing win percent stats:\n%s\n", szHTTPStats)); - //find today's stats - const char* pToday = strstr( szHTTPStats, "Today" ); - if( !pToday ) - { //error - DEBUG_LOG(( "Unable to parse win/loss stats. Could not find 'Today' in:\n%s\n", szHTTPStats )); - return; - } - s_winStats.clear(); - s_totalWinPercent = 0; - - //find win/loss for each side - for( int i = 0; i < ThePlayerTemplateStore->getPlayerTemplateCount(); i++) - { //get current side (USA, GLA, etc.) - const PlayerTemplate* pTemplate = ThePlayerTemplateStore->getNthPlayerTemplate(i); - if( !pTemplate->isPlayableSide() || pTemplate->getSide().compare("Boss") == 0 ) - continue; //skip non-players - - AsciiString side = pTemplate->getSide(); - if( side == "America" ) - side = "USA"; //conform to GameSpy name - - //find this side - const char* pSide = strstr( pToday, side.str() ); - if( pSide == NULL ) - { //error, skip this side - DEBUG_LOG(( "Unable to parse win/loss stats for %s in:\n%s\n", side.str(), szHTTPStats )); - continue; - } - - //Note: win% reported by GameSpy = team's wins / #games played by team - // we want win% = team's wins / total # games played by all teams - const char* pTotal = FindNextNumber(pSide); - const char* pWins = FindNextNumber(pTotal); - float percent = atof(pWins) / max(1,atof(pTotal)); //max prevents divide by zero - s_totalWinPercent += percent; - - s_winStats.insert(std::make_pair( side, percent )); -//x DEBUG_LOG(("Added win percent: %s, %d\n", side.str(), percent)); - } //for i -} //HandleOverallStats - - -//called only from WOLWelcomeMenuInit to set %win stats -static void updateOverallStats(void) -{ - UnicodeString percStr; - AsciiString wndName; - GameWindow* pWin; - - if( s_totalWinPercent <= 0 ) - s_totalWinPercent = 1; //prevent divide by zero - - std::map::iterator it; - for( it = s_winStats.begin(); it != s_winStats.end(); ++it ) - { - int percent = REAL_TO_INT(100.0f * (it->second / s_totalWinPercent)); - percStr.format( TheGameText->fetch("GUI:WinPercent"), percent ); - wndName.format( "WOLWelcomeMenu.wnd:Percent%s", it->first.str() ); - pWin = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY(wndName) ); - GadgetCheckBoxSetText( pWin, percStr ); -//x DEBUG_LOG(("Initialized win percent: %s -> %s %f=%s\n", wndName.str(), it->first.str(), it->second, percStr.str() )); - } //for -} //updateOverallStats - - -//------------------------------------------------------------------------------------------------- -/** Handle player stats */ -//------------------------------------------------------------------------------------------------- - -void UpdateLocalPlayerStats(void) -{ - - GameWindow *welcomeParent = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("WOLWelcomeMenu.wnd:WOLWelcomeMenuParent") ); - - if (welcomeParent) - { - PopulatePlayerInfoWindows( "WOLWelcomeMenu.wnd" ); - } - else - { - PopulatePlayerInfoWindows( "WOLQuickMatchMenu.wnd" ); - } - - return; -} - -static Bool raiseMessageBoxes = FALSE; -//------------------------------------------------------------------------------------------------- -/** Initialize the WOL Welcome Menu */ -//------------------------------------------------------------------------------------------------- -void WOLWelcomeMenuInit( WindowLayout *layout, void *userData ) -{ - nextScreen = NULL; - buttonPushed = FALSE; - isShuttingDown = FALSE; - - welcomeLayout = layout; - - //TheWOL->reset(); - - parentWOLWelcomeID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:WOLWelcomeMenuParent" ) ); - buttonBackID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonBack" ) ); - parentWOLWelcome = TheWindowManager->winGetWindowFromId( NULL, parentWOLWelcomeID ); - buttonBack = TheWindowManager->winGetWindowFromId( NULL, buttonBackID); - buttonOptionsID = TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:ButtonOptions" ); - buttonbuttonOptions = TheWindowManager->winGetWindowFromId( NULL, buttonOptionsID); - listboxInfoID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:InfoListbox" ) ); - - listboxInfo = TheWindowManager->winGetWindowFromId( NULL, listboxInfoID); - - staticTextServerName = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextServerName" )); - staticTextLastUpdated = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextLastUpdated" )); - - staticTextLadderWins = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextLadderWins" )); - staticTextLadderLosses = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextLadderLosses" )); - staticTextLadderPoints = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextLadderPoints" )); - staticTextLadderRank = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextLadderRank" )); - staticTextLadderDisconnects = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextDisconnects" )); - - staticTextHighscoreWins = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextHighscoreWins" )); - staticTextHighscoreLosses = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextHighscoreLosses" )); - staticTextHighscorePoints = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextHighscorePoints" )); - staticTextHighscoreRank = TheWindowManager->winGetWindowFromId( parentWOLWelcome, - TheNameKeyGenerator->nameToKey( "WOLWelcomeMenu.wnd:StaticTextHighscoreRank" )); - - if (staticTextServerName) - { - GadgetStaticTextSetText(staticTextServerName, gServerName); - } - - GameWindow *staticTextTitle = TheWindowManager->winGetWindowFromId(parentWOLWelcome, NAMEKEY("WOLWelcomeMenu.wnd:StaticTextTitle")); - if (staticTextTitle && TheGameSpyInfo) - { - UnicodeString title; - title.format(TheGameText->fetch("GUI:WOLWelcome"), TheGameSpyInfo->getLocalBaseName().str()); - GadgetStaticTextSetText(staticTextTitle, title); - } - - // Clear some defaults - /* - UnicodeString questionMark = UnicodeString(L"?"); - GadgetStaticTextSetText(staticTextLastUpdated, questionMark); - GadgetStaticTextSetText(staticTextLadderWins, questionMark); - GadgetStaticTextSetText(staticTextLadderLosses, questionMark); - GadgetStaticTextSetText(staticTextLadderPoints, questionMark); - GadgetStaticTextSetText(staticTextLadderRank, questionMark); - GadgetStaticTextSetText(staticTextLadderDisconnects, questionMark); - GadgetStaticTextSetText(staticTextHighscoreWins, questionMark); - GadgetStaticTextSetText(staticTextHighscoreLosses, questionMark); - GadgetStaticTextSetText(staticTextHighscorePoints, questionMark); - GadgetStaticTextSetText(staticTextHighscoreRank, questionMark); - */ - - //DEBUG_ASSERTCRASH(listboxInfo, ("No control found!")); - - buttonQuickMatchID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonQuickMatch" ) ); - buttonQuickMatch = TheWindowManager->winGetWindowFromId( parentWOLWelcome, buttonQuickMatchID ); - - buttonLobbyID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonCustomMatch" ) ); - buttonLobby = TheWindowManager->winGetWindowFromId( parentWOLWelcome, buttonLobbyID ); - - buttonBuddiesID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonBuddies" ) ); - buttonBuddies = TheWindowManager->winGetWindowFromId( parentWOLWelcome, buttonBuddiesID ); - - buttonMyInfoID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonMyInfo" ) ); - buttonMyInfo = TheWindowManager->winGetWindowFromId( parentWOLWelcome, buttonMyInfoID ); - - buttonLadderID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonLadder" ) ); - buttonLadder = TheWindowManager->winGetWindowFromId( parentWOLWelcome, buttonLadderID ); - - if (TheFirewallHelper == NULL) { - TheFirewallHelper = createFirewallHelper(); - } - if (TheFirewallHelper->detectFirewall() == TRUE) { - // don't need to detect firewall, already been done. - delete TheFirewallHelper; - TheFirewallHelper = NULL; - } - /* - - if (TheGameSpyChat && TheGameSpyChat->isConnected()) - { - const char *keys[3] = { "locale", "wins", "losses" }; - char valueStrings[3][20]; - char *values[3] = { valueStrings[0], valueStrings[1], valueStrings[2] }; - _snprintf(values[0], 20, "%s", TheGameSpyPlayerInfo->getLocale().str()); - _snprintf(values[1], 20, "%d", TheGameSpyPlayerInfo->getWins()); - _snprintf(values[2], 20, "%d", TheGameSpyPlayerInfo->getLosses()); - peerSetGlobalKeys(TheGameSpyChat->getPeer(), 3, (const char **)keys, (const char **)values); - peerSetGlobalWatchKeys(TheGameSpyChat->getPeer(), GroupRoom, 3, keys, PEERFalse); - peerSetGlobalWatchKeys(TheGameSpyChat->getPeer(), StagingRoom, 3, keys, PEERFalse); - } - */ - -// // animate controls -// TheShell->registerWithAnimateManager(buttonQuickMatch, WIN_ANIMATION_SLIDE_LEFT, TRUE, 800); -// TheShell->registerWithAnimateManager(buttonLobby, WIN_ANIMATION_SLIDE_LEFT, TRUE, 600); -// //TheShell->registerWithAnimateManager(NULL, WIN_ANIMATION_SLIDE_LEFT, TRUE, 400); -// TheShell->registerWithAnimateManager(buttonBuddies, WIN_ANIMATION_SLIDE_LEFT, TRUE, 200); -// //TheShell->registerWithAnimateManager(NULL, WIN_ANIMATION_SLIDE_LEFT, TRUE, 1); -// TheShell->registerWithAnimateManager(buttonBack, WIN_ANIMATION_SLIDE_BOTTOM, TRUE, 1); - - // Show Menu - layout->hide( FALSE ); - - // Set Keyboard to Main Parent - TheWindowManager->winSetFocus( parentWOLWelcome ); - - enableControls( TheGameSpyInfo->gotGroupRoomList() ); - TheShell->showShellMap(TRUE); - - updateNumPlayersOnline(); - updateOverallStats(); - - UpdateLocalPlayerStats(); - - GameSpyMiscPreferences cPref; - if (cPref.getLocale() < LOC_MIN || cPref.getLocale() > LOC_MAX) - { - GameSpyOpenOverlay(GSOVERLAY_LOCALESELECT); - } - - raiseMessageBoxes = TRUE; - TheTransitionHandler->setGroup("WOLWelcomeMenuFade"); - -} // WOLWelcomeMenuInit - -//------------------------------------------------------------------------------------------------- -/** WOL Welcome Menu shutdown method */ -//------------------------------------------------------------------------------------------------- -void WOLWelcomeMenuShutdown( WindowLayout *layout, void *userData ) -{ - listboxInfo = NULL; - - if (TheFirewallHelper != NULL) { - delete TheFirewallHelper; - TheFirewallHelper = NULL; - } - - isShuttingDown = TRUE; - - // if we are shutting down for an immediate pop, skip the animations - Bool popImmediate = *(Bool *)userData; - if( popImmediate ) - { - - shutdownComplete( layout ); - return; - - } //end if - - TheShell->reverseAnimatewindow(); - TheTransitionHandler->reverse("WOLWelcomeMenuFade"); - - - RaiseGSMessageBox(); -} // WOLWelcomeMenuShutdown - - -//------------------------------------------------------------------------------------------------- -/** WOL Welcome Menu update method */ -//------------------------------------------------------------------------------------------------- -void WOLWelcomeMenuUpdate( WindowLayout * layout, void *userData) -{ - // We'll only be successful if we've requested to - if(isShuttingDown && TheShell->isAnimFinished() && TheTransitionHandler->isFinished()) - shutdownComplete(layout); - - if (raiseMessageBoxes) - { - RaiseGSMessageBox(); - raiseMessageBoxes = FALSE; - } - - if (TheFirewallHelper != NULL) - { - if (TheFirewallHelper->behaviorDetectionUpdate()) - { - TheWritableGlobalData->m_firewallBehavior = TheFirewallHelper->getFirewallBehavior(); - - TheFirewallHelper->writeFirewallBehavior(); - - TheFirewallHelper->flagNeedToRefresh(FALSE); // 2/19/03 BGC, we're done, so we don't need to refresh the NAT anymore. - - // we are now done with the firewall helper - delete TheFirewallHelper; - TheFirewallHelper = NULL; - } - } - - if (TheShell->isAnimFinished() && !buttonPushed && TheGameSpyPeerMessageQueue) - { - HandleBuddyResponses(); - HandlePersistentStorageResponses(); - - Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate(); - Bool sawImportantMessage = FALSE; - PeerResponse resp; - while (allowedMessages-- && !sawImportantMessage && TheGameSpyPeerMessageQueue->getResponse( resp )) - { - switch (resp.peerResponseType) - { - case PeerResponse::PEERRESPONSE_GROUPROOM: - { - GameSpyGroupRoom room; - room.m_groupID = resp.groupRoom.id; - room.m_maxWaiting = resp.groupRoom.maxWaiting; - room.m_name = resp.groupRoomName.c_str(); - room.m_translatedName = UnicodeString(L"TEST"); - room.m_numGames = resp.groupRoom.numGames; - room.m_numPlaying = resp.groupRoom.numPlaying; - room.m_numWaiting = resp.groupRoom.numWaiting; - TheGameSpyInfo->addGroupRoom( room ); - if (room.m_groupID == 0) - { - enableControls( TRUE ); - } - } - break; - case PeerResponse::PEERRESPONSE_JOINGROUPROOM: - { - sawImportantMessage = TRUE; - enableControls( TRUE ); - if (resp.joinGroupRoom.ok) - { - //buttonPushed = TRUE; - TheGameSpyInfo->setCurrentGroupRoom(resp.joinGroupRoom.id); - //GSMessageBoxOk( TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSGroupRoomJoinOK") ); - - buttonPushed = TRUE; - nextScreen = "Menus/WOLCustomLobby.wnd"; - TheShell->pop(); - //TheShell->push( "Menus/WOLCustomLobby.wnd" ); - } - else - { - GSMessageBoxOk( TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSGroupRoomJoinFail") ); - } - } - break; - case PeerResponse::PEERRESPONSE_DISCONNECT: - { - sawImportantMessage = TRUE; - UnicodeString title, body; - AsciiString disconMunkee; - disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason); - title = TheGameText->fetch( "GUI:GSErrorTitle" ); - body = TheGameText->fetch( disconMunkee ); - GameSpyCloseAllOverlays(); - GSMessageBoxOk( title, body ); - TheShell->pop(); - } - break; - } - } - } - -}// WOLWelcomeMenuUpdate - -//------------------------------------------------------------------------------------------------- -/** WOL Welcome Menu input callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLWelcomeMenuInput( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - switch( msg ) - { - - // -------------------------------------------------------------------------------------------- - case GWM_CHAR: - { - UnsignedByte key = mData1; - UnsignedByte state = mData2; - if (buttonPushed) - break; - - switch( key ) - { - - // ---------------------------------------------------------------------------------------- - case KEY_ESC: - { - - // - // send a simulated selected event to the parent window of the - // back/exit button - // - if( BitTest( state, KEY_STATE_UP ) ) - { - TheWindowManager->winSendSystemMsg( window, GBM_SELECTED, - (WindowMsgData)buttonBack, buttonBackID ); - - } // end if - - // don't let key fall through anywhere else - return MSG_HANDLED; - - } // end escape - - } // end switch( key ) - - } // end char - - } // end switch( msg ) - - return MSG_IGNORED; -}// WOLWelcomeMenuInput - -//------------------------------------------------------------------------------------------------- -/** WOL Welcome Menu window system callback */ -//------------------------------------------------------------------------------------------------- -WindowMsgHandledType WOLWelcomeMenuSystem( GameWindow *window, UnsignedInt msg, - WindowMsgData mData1, WindowMsgData mData2 ) -{ - UnicodeString txtInput; - - switch( msg ) - { - - - case GWM_CREATE: - { - - break; - } // case GWM_DESTROY: - - case GWM_DESTROY: - { - break; - } // case GWM_DESTROY: - - case GWM_INPUT_FOCUS: - { - // if we're givin the opportunity to take the keyboard focus we must say we want it - if( mData1 == TRUE ) - *(Bool *)mData2 = TRUE; - - return MSG_HANDLED; - }//case GWM_INPUT_FOCUS: - - case GBM_SELECTED: - { - if (buttonPushed) - break; - - GameWindow *control = (GameWindow *)mData1; - Int controlID = control->winGetWindowId(); - - if ( controlID == buttonBackID ) - { - //DEBUG_ASSERTCRASH(TheGameSpyChat->getPeer(), ("No GameSpy Peer object!")); - //TheGameSpyChat->disconnectFromChat(); - - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_LOGOUT; - TheGameSpyPeerMessageQueue->addRequest( req ); - BuddyRequest breq; - breq.buddyRequestType = BuddyRequest::BUDDYREQUEST_LOGOUT; - TheGameSpyBuddyMessageQueue->addRequest( breq ); - - DEBUG_LOG(("Tearing down GameSpy from WOLWelcomeMenuSystem(GBM_SELECTED)\n")); - TearDownGameSpy(); - - /* - if (TheGameSpyChat->getPeer()) - { - peerDisconnect(TheGameSpyChat->getPeer()); - } - */ - - buttonPushed = TRUE; - - TheShell->pop(); - - /// @todo: log out instead of disconnecting - //TheWOL->addCommand( WOL::WOLCOMMAND_LOGOUT ); - /** - closeAllOverlays(); - TheShell->pop(); - delete TheWOL; - TheWOL = NULL; - delete TheWOLGame; - TheWOLGame = NULL; - **/ - - } //if ( controlID == buttonBack ) - else if (controlID == buttonOptionsID) - { - GameSpyOpenOverlay( GSOVERLAY_OPTIONS ); - } - else if (controlID == buttonQuickMatchID) - { - GameSpyMiscPreferences mPref; - if ((TheDisplay->getWidth() != 800 || TheDisplay->getHeight() != 600) && mPref.getQuickMatchResLocked()) - { - GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:QuickMatch800x600")); - } - else - { - buttonPushed = TRUE; - nextScreen = "Menus/WOLQuickMatchMenu.wnd"; - TheShell->pop(); - } - }// else if - else if (controlID == buttonMyInfoID ) - { - SetLookAtPlayer(TheGameSpyInfo->getLocalProfileID(), TheGameSpyInfo->getLocalName()); - GameSpyToggleOverlay(GSOVERLAY_PLAYERINFO); - } - else if (controlID == buttonLobbyID) - { - //TheGameSpyChat->clearGroupRoomList(); - //peerListGroupRooms(TheGameSpyChat->getPeer(), ListGroupRoomsCallback, NULL, PEERTrue); - TheGameSpyInfo->joinBestGroupRoom(); - enableControls( FALSE ); - - - /* - TheWOL->setScreen(WOL::WOLAPI_MENU_CUSTOMLOBBY); - TheWOL->setGameMode(WOL::WOLTYPE_CUSTOM); - TheWOL->setState( WOL::WOLAPI_LOBBY ); - TheWOL->addCommand( WOL::WOLCOMMAND_REFRESH_CHANNELS ); - */ - }// else if - else if (controlID == buttonBuddiesID) - { - GameSpyToggleOverlay( GSOVERLAY_BUDDY ); - /* - Bool joinedRoom = FALSE; - ClearGroupRoomList(); - peerJoinTitleRoom(TheGameSpyChat->getPeer(), JoinRoomCallback, &joinedRoom, PEERTrue); - if (joinedRoom) - { - GameSpyUsingGroupRooms = FALSE; - GameSpyCurrentGroupRoomID = 0; - TheShell->pop(); - TheShell->push("Menus/WOLCustomLobby.wnd"); - } - else - { - GameSpyCurrentGroupRoomID = 0; - GSMessageBoxOk(UnicodeString(L"Oops"), UnicodeString(L"Unable to join title room"), NULL); - } - */ - } - else if (controlID == buttonLadderID) - { - TheShell->push(AsciiString("Menus/WOLLadderScreen.wnd")); - } - break; - }// case GBM_SELECTED: - - case GEM_EDIT_DONE: - { - break; - } - default: - return MSG_IGNORED; - - }//Switch - - return MSG_HANDLED; -}// WOLWelcomeMenuSystem