EstablishConnectionsMenu.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. //// EstablishConnectionsMenu.cpp /////////////////////////////////////
  24. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  25. #include "GameClient/GUICallbacks.h"
  26. #include "GameClient/EstablishConnectionsMenu.h"
  27. #include "Common/NameKeyGenerator.h"
  28. #include "GameClient/GameWindow.h"
  29. #include "GameClient/GameWindowManager.h"
  30. #include "GameClient/GadgetStaticText.h"
  31. #include "GameClient/GameText.h"
  32. EstablishConnectionsMenu *TheEstablishConnectionsMenu = NULL;
  33. char *EstablishConnectionsMenu::m_playerReadyControlNames[] = {
  34. "EstablishConnectionsScreen.wnd:ButtonAccept1",
  35. "EstablishConnectionsScreen.wnd:ButtonAccept2",
  36. "EstablishConnectionsScreen.wnd:ButtonAccept3",
  37. "EstablishConnectionsScreen.wnd:ButtonAccept4",
  38. "EstablishConnectionsScreen.wnd:ButtonAccept5",
  39. "EstablishConnectionsScreen.wnd:ButtonAccept6",
  40. "EstablishConnectionsScreen.wnd:ButtonAccept7",
  41. NULL};
  42. char *EstablishConnectionsMenu::m_playerNameControlNames[] = {
  43. "EstablishConnectionsScreen.wnd:StaticPlayer1Name",
  44. "EstablishConnectionsScreen.wnd:StaticPlayer2Name",
  45. "EstablishConnectionsScreen.wnd:StaticPlayer3Name",
  46. "EstablishConnectionsScreen.wnd:StaticPlayer4Name",
  47. "EstablishConnectionsScreen.wnd:StaticPlayer5Name",
  48. "EstablishConnectionsScreen.wnd:StaticPlayer6Name",
  49. "EstablishConnectionsScreen.wnd:StaticPlayer7Name",
  50. NULL
  51. };
  52. char *EstablishConnectionsMenu::m_playerStatusControlNames[] = {
  53. "EstablishConnectionsScreen.wnd:StaticPlayer1Status",
  54. "EstablishConnectionsScreen.wnd:StaticPlayer2Status",
  55. "EstablishConnectionsScreen.wnd:StaticPlayer3Status",
  56. "EstablishConnectionsScreen.wnd:StaticPlayer4Status",
  57. "EstablishConnectionsScreen.wnd:StaticPlayer5Status",
  58. "EstablishConnectionsScreen.wnd:StaticPlayer6Status",
  59. "EstablishConnectionsScreen.wnd:StaticPlayer7Status",
  60. NULL
  61. };
  62. /**
  63. Constructor
  64. */
  65. EstablishConnectionsMenu::EstablishConnectionsMenu() {
  66. }
  67. /**
  68. Destructor
  69. */
  70. EstablishConnectionsMenu::~EstablishConnectionsMenu() {
  71. }
  72. /**
  73. Initialize the menu
  74. */
  75. void EstablishConnectionsMenu::initMenu() {
  76. ShowEstablishConnectionsWindow();
  77. }
  78. /**
  79. Close down the menu
  80. */
  81. void EstablishConnectionsMenu::endMenu() {
  82. HideEstablishConnectionsWindow();
  83. }
  84. /**
  85. Abort the game gracefully...ok, as gracefully as possible considering
  86. the game was supposed to be started and now for some reason we have to
  87. stop it. Its really sad that this game isn't going to be played
  88. considering how difficult it is to even get a game going in the first
  89. place, especially one with more than two players.
  90. */
  91. void EstablishConnectionsMenu::abortGame() {
  92. }
  93. // the slot number passed in is the index we are to use for the menu.
  94. void EstablishConnectionsMenu::setPlayerName(Int slot, UnicodeString name) {
  95. NameKeyType controlID = TheNameKeyGenerator->nameToKey(m_playerNameControlNames[slot]);
  96. GameWindow *control = TheWindowManager->winGetWindowFromId(NULL, controlID);
  97. if (control == NULL) {
  98. DEBUG_ASSERTCRASH(control != NULL, ("player name control for slot %d is NULL", slot));
  99. return;
  100. }
  101. GadgetStaticTextSetText(control, name);
  102. }
  103. void EstablishConnectionsMenu::setPlayerStatus(Int slot, NATConnectionState state) {
  104. NameKeyType controlID = TheNameKeyGenerator->nameToKey(m_playerStatusControlNames[slot]);
  105. GameWindow *control = TheWindowManager->winGetWindowFromId(NULL, controlID);
  106. if (control == NULL) {
  107. DEBUG_ASSERTCRASH(control != NULL, ("player status control for slot %d is NULL", slot));
  108. return;
  109. }
  110. // if (state == NATCONNECTIONSTATE_NETGEARDELAY) {
  111. // GadgetStaticTextSetText(control, TheGameText->fetch("GUI:NetgearDelay"));
  112. if (state == NATCONNECTIONSTATE_WAITINGFORMANGLERRESPONSE) {
  113. GadgetStaticTextSetText(control, TheGameText->fetch("GUI:WaitingForManglerResponse"));
  114. } else if (state == NATCONNECTIONSTATE_WAITINGFORMANGLEDPORT) {
  115. GadgetStaticTextSetText(control, TheGameText->fetch("GUI:WaitingForMangledPort"));
  116. } else if (state == NATCONNECTIONSTATE_WAITINGFORRESPONSE) {
  117. GadgetStaticTextSetText(control, TheGameText->fetch("GUI:WaitingForResponse"));
  118. } else if (state == NATCONNECTIONSTATE_DONE) {
  119. GadgetStaticTextSetText(control, TheGameText->fetch("GUI:ConnectionDone"));
  120. } else if (state == NATCONNECTIONSTATE_FAILED) {
  121. GadgetStaticTextSetText(control, TheGameText->fetch("GUI:ConnectionFailed"));
  122. } else if (state == NATCONNECTIONSTATE_WAITINGTOBEGIN) {
  123. GadgetStaticTextSetText(control, TheGameText->fetch("GUI:WaitingToBeginConnection"));
  124. } else {
  125. GadgetStaticTextSetText(control, TheGameText->fetch("GUI:UnknownConnectionState"));
  126. }
  127. }