| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- /*
- ** 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 <http://www.gnu.org/licenses/>.
- */
- ////////////////////////////////////////////////////////////////////////////////
- // //
- // (c) 2001-2003 Electronic Arts Inc. //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- // FILE: DisconnectControls.cpp ///////////////////////////////////////////////////////////////////////
- // Author: Bryan Cleveland - March 2001
- // Desc: GUI menu for network disconnects
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
- #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
- #include "GameClient/GameWindow.h"
- #include "GameClient/GameText.h"
- #include "GameClient/Gadget.h"
- #include "GameClient/GadgetTextEntry.h"
- #include "GameClient/GadgetListBox.h"
- #include "GameClient/GameClient.h"
- #include "GameClient/DisconnectMenu.h"
- #include "GameClient/GameWindowManager.h"
- #include "Common/NameKeyGenerator.h"
- // Private Data -----------------------------
- static WindowLayout *disconnectMenuLayout;
- static NameKeyType textEntryID = NAMEKEY_INVALID;
- static NameKeyType textDisplayID = NAMEKEY_INVALID;
- static GameWindow *textEntryWindow = NULL;
- static GameWindow *textDisplayWindow = NULL;
- static NameKeyType buttonQuitID = NAMEKEY_INVALID;
- static GameWindow *buttonQuitWindow = NULL;
- static NameKeyType buttonVotePlayer1ID = NAMEKEY_INVALID;
- static NameKeyType buttonVotePlayer2ID = NAMEKEY_INVALID;
- static NameKeyType buttonVotePlayer3ID = NAMEKEY_INVALID;
- static NameKeyType buttonVotePlayer4ID = NAMEKEY_INVALID;
- static NameKeyType buttonVotePlayer5ID = NAMEKEY_INVALID;
- static NameKeyType buttonVotePlayer6ID = NAMEKEY_INVALID;
- static NameKeyType buttonVotePlayer7ID = NAMEKEY_INVALID;
- static GameWindow *buttonVotePlayer1Window = NULL;
- static GameWindow *buttonVotePlayer2Window = NULL;
- static GameWindow *buttonVotePlayer3Window = NULL;
- static GameWindow *buttonVotePlayer4Window = NULL;
- static GameWindow *buttonVotePlayer5Window = NULL;
- static GameWindow *buttonVotePlayer6Window = NULL;
- static GameWindow *buttonVotePlayer7Window = NULL;
- static void InitDisconnectWindow( void ) {
- textEntryID = TheNameKeyGenerator->nameToKey( AsciiString("DisconnectScreen.wnd:TextEntry"));
- textDisplayID = TheNameKeyGenerator->nameToKey( AsciiString("DisconnectScreen.wnd:ListboxTextDisplay"));
- textEntryWindow = TheWindowManager->winGetWindowFromId(NULL, textEntryID);
- textDisplayWindow = TheWindowManager->winGetWindowFromId(NULL, textDisplayID);
- if (textEntryWindow != NULL) {
- GadgetTextEntrySetText(textEntryWindow, UnicodeString::TheEmptyString);
- TheWindowManager->winSetFocus(textEntryWindow);
- }
- buttonQuitID = TheNameKeyGenerator->nameToKey( AsciiString("DisconnectScreen.wnd:ButtonQuitGame"));
- buttonQuitWindow = TheWindowManager->winGetWindowFromId(NULL, buttonQuitID);
- buttonVotePlayer1ID = TheNameKeyGenerator->nameToKey( AsciiString("DisconnectScreen.wnd:ButtonKickPlayer1"));
- buttonVotePlayer2ID = TheNameKeyGenerator->nameToKey( AsciiString("DisconnectScreen.wnd:ButtonKickPlayer2"));
- buttonVotePlayer3ID = TheNameKeyGenerator->nameToKey( AsciiString("DisconnectScreen.wnd:ButtonKickPlayer3"));
- buttonVotePlayer4ID = TheNameKeyGenerator->nameToKey( AsciiString("DisconnectScreen.wnd:ButtonKickPlayer4"));
- buttonVotePlayer5ID = TheNameKeyGenerator->nameToKey( AsciiString("DisconnectScreen.wnd:ButtonKickPlayer5"));
- buttonVotePlayer6ID = TheNameKeyGenerator->nameToKey( AsciiString("DisconnectScreen.wnd:ButtonKickPlayer6"));
- buttonVotePlayer7ID = TheNameKeyGenerator->nameToKey( AsciiString("DisconnectScreen.wnd:ButtonKickPlayer7"));
- buttonVotePlayer1Window = TheWindowManager->winGetWindowFromId(NULL, buttonVotePlayer1ID);
- buttonVotePlayer2Window = TheWindowManager->winGetWindowFromId(NULL, buttonVotePlayer2ID);
- buttonVotePlayer3Window = TheWindowManager->winGetWindowFromId(NULL, buttonVotePlayer3ID);
- buttonVotePlayer4Window = TheWindowManager->winGetWindowFromId(NULL, buttonVotePlayer4ID);
- buttonVotePlayer5Window = TheWindowManager->winGetWindowFromId(NULL, buttonVotePlayer5ID);
- buttonVotePlayer6Window = TheWindowManager->winGetWindowFromId(NULL, buttonVotePlayer6ID);
- buttonVotePlayer7Window = TheWindowManager->winGetWindowFromId(NULL, buttonVotePlayer7ID);
- }
- //------------------------------------------------------
- /** Show the Disconnect Screen */
- //------------------------------------------------------
- void ShowDisconnectWindow( void )
- {
- // load the quit menu from the layout file if needed
- if( disconnectMenuLayout == NULL )
- {
- // load layout from disk
- disconnectMenuLayout = TheWindowManager->winCreateLayout( "Menus/DisconnectScreen.wnd" );
- // init it
- InitDisconnectWindow();
-
- // show it
- disconnectMenuLayout->hide( FALSE );
- } // end if
- else
- {
- disconnectMenuLayout->hide( FALSE );
- } // end else
- buttonVotePlayer1Window->winEnable(TRUE);
- buttonVotePlayer2Window->winEnable(TRUE);
- buttonVotePlayer3Window->winEnable(TRUE);
- buttonVotePlayer4Window->winEnable(TRUE);
- buttonVotePlayer5Window->winEnable(TRUE);
- buttonVotePlayer6Window->winEnable(TRUE);
- buttonVotePlayer7Window->winEnable(TRUE);
- buttonQuitWindow->winEnable(TRUE);
- disconnectMenuLayout->bringForward();
- GadgetListBoxReset(textDisplayWindow);
- GadgetListBoxAddEntryText(textDisplayWindow, TheGameText->fetch("GUI:InternetDisconnectionMenuBody1"),
- GameMakeColor(255,255,255,255), -1);
- } // end ToggleQuitMenu
- //------------------------------------------------------
- /** Hide the Disconnect Screen */
- //------------------------------------------------------
- void HideDisconnectWindow( void )
- {
- // load the quit menu from the layout file if needed
- if( disconnectMenuLayout == NULL )
- {
- // load layout from disk
- disconnectMenuLayout = TheWindowManager->winCreateLayout( "Menus/DisconnectScreen.wnd" );
- // init it
- InitDisconnectWindow();
-
- // show it
- disconnectMenuLayout->hide( TRUE );
- } // end if
- else
- {
- disconnectMenuLayout->hide( TRUE );
- } // end else
- } // end ToggleQuitMenu
- //-------------------------------------------------------------------------------------------------
- /** Input callback for the control bar parent */
- //-------------------------------------------------------------------------------------------------
- WindowMsgHandledType DisconnectControlInput( GameWindow *window, UnsignedInt msg,
- WindowMsgData mData1, WindowMsgData mData2 )
- {
- return MSG_IGNORED;
- } // end DisconnectControlInput
- //-------------------------------------------------------------------------------------------------
- /** System callback for the control bar parent */
- //-------------------------------------------------------------------------------------------------
- WindowMsgHandledType DisconnectControlSystem( GameWindow *window, UnsignedInt msg,
- WindowMsgData mData1, WindowMsgData mData2 )
- {
- switch( msg )
- {
- //---------------------------------------------------------------------------------------------
- case GBM_SELECTED:
- {
- GameWindow *control = (GameWindow *) mData1;
- Int controlID = control->winGetWindowId();
- if (controlID == buttonQuitID) {
- TheDisconnectMenu->quitGame();
- buttonQuitWindow->winEnable(FALSE);
- } else if (controlID == buttonVotePlayer1ID) {
- TheDisconnectMenu->voteForPlayer(0);
- buttonVotePlayer1Window->winEnable(FALSE);
- } else if (controlID == buttonVotePlayer2ID) {
- TheDisconnectMenu->voteForPlayer(1);
- buttonVotePlayer2Window->winEnable(FALSE);
- } else if (controlID == buttonVotePlayer3ID) {
- TheDisconnectMenu->voteForPlayer(2);
- buttonVotePlayer3Window->winEnable(FALSE);
- } else if (controlID == buttonVotePlayer4ID) {
- TheDisconnectMenu->voteForPlayer(3);
- buttonVotePlayer4Window->winEnable(FALSE);
- } else if (controlID == buttonVotePlayer5ID) {
- TheDisconnectMenu->voteForPlayer(4);
- buttonVotePlayer5Window->winEnable(FALSE);
- } else if (controlID == buttonVotePlayer6ID) {
- TheDisconnectMenu->voteForPlayer(5);
- buttonVotePlayer6Window->winEnable(FALSE);
- } else if (controlID == buttonVotePlayer7ID) {
- TheDisconnectMenu->voteForPlayer(6);
- buttonVotePlayer7Window->winEnable(FALSE);
- }
- break;
- } // end button selected
- case GEM_EDIT_DONE:
- {
- // DEBUG_LOG(("DisconnectControlSystem - got GEM_EDIT_DONE.\n"));
- 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 == textEntryID )
- {
- UnicodeString txtInput;
- // DEBUG_LOG(("DisconnectControlSystem - GEM_EDIT_DONE was from the text entry control.\n"));
- // read the user's input
- txtInput.set(GadgetTextEntryGetText( textEntryWindow ));
- // Clear the text entry line
- GadgetTextEntrySetText(textEntryWindow, 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()) {
- // DEBUG_LOG(("DisconnectControlSystem - sending string %ls\n", txtInput.str()));
- TheDisconnectMenu->sendChat(txtInput);
- }
- }// if ( controlID == textEntryChatID )
- break;
- }
- //---------------------------------------------------------------------------------------------
- default:
- return MSG_IGNORED;
- } // end switch( msg )
- return MSG_HANDLED;
- } // end ControlBarSystem
|