From acc0cbe562044593c81ed8158a64cf22ce5ace36 Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Wed, 22 May 2024 01:13:36 +0200 Subject: [PATCH] UI: Fix map preview in multiplayer room list --- Source/Network/ServerList.cpp | 2 +- Source/UserInterface/Menu/MultiplayerCommon.cpp | 12 +++--------- Source/UserInterface/Menu/MultiplayerCommon.h | 1 - Source/UserInterface/Menu/MultiplayerList.cpp | 15 ++++++++++++--- Source/UserInterface/Menu/MultiplayerLobby.cpp | 7 ++++++- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Source/Network/ServerList.cpp b/Source/Network/ServerList.cpp index 52035aba..17bb70e8 100644 --- a/Source/Network/ServerList.cpp +++ b/Source/Network/ServerList.cpp @@ -140,7 +140,7 @@ void ServerList::fetchRelayHostInfoList() { info.gameStarted = room.game_started; info.gameClosed = room.room_closed; info.ping = room.ping; - info.scenario = getMapName(room.extra_data.scenario.c_str()); + info.scenario = room.extra_data.scenario; uint32_t game_content = strtoul(room.extra_data.game_content.c_str(), nullptr, 0); info.gameContent = static_cast(game_content); gameList.emplace_back(info); diff --git a/Source/UserInterface/Menu/MultiplayerCommon.cpp b/Source/UserInterface/Menu/MultiplayerCommon.cpp index 632c38dd..d583f4e5 100644 --- a/Source/UserInterface/Menu/MultiplayerCommon.cpp +++ b/Source/UserInterface/Menu/MultiplayerCommon.cpp @@ -29,21 +29,15 @@ void clearMultiplayerVars() { void loadMultiplayerList() { if (multiplayerMaps.empty()) { loadMapVector(multiplayerMaps, "RESOURCE/MULTIPLAYER", ".spg"); + for (int i = 0; i < multiplayerMaps.size(); ++i) { + checkMissionDescription(i, multiplayerMaps, GT_MULTI_PLAYER_CREATE); + } } if (multiplayerSaves.empty()) { loadMapVector(multiplayerSaves, "RESOURCE/SAVES/MULTIPLAYER", ".spg"); } } -int getMultiplayerMapNumber(const std::string& missionName) { - for (uint32_t i = 0, s = multiplayerMaps.size(); i < s; i++) { - if (missionName == multiplayerMaps[i].missionName()) { - return static_cast(i); - } - } - return -1; -} - int SwitchMultiplayerToLoadQuant(float, float ) { if (menuChangingDone) { gameShell->currentSingleProfile.setLastGameType(UserSingleProfile::MULTIPLAYER); diff --git a/Source/UserInterface/Menu/MultiplayerCommon.h b/Source/UserInterface/Menu/MultiplayerCommon.h index 44c1e053..0041d72c 100644 --- a/Source/UserInterface/Menu/MultiplayerCommon.h +++ b/Source/UserInterface/Menu/MultiplayerCommon.h @@ -9,4 +9,3 @@ extern std::vector multiplayerSaves; void loadMultiplayerList(); int exitToMultiplayerScreenAction(float, float); -int getMultiplayerMapNumber(const std::string& missionName); diff --git a/Source/UserInterface/Menu/MultiplayerList.cpp b/Source/UserInterface/Menu/MultiplayerList.cpp index bf3d259c..60b0902c 100644 --- a/Source/UserInterface/Menu/MultiplayerList.cpp +++ b/Source/UserInterface/Menu/MultiplayerList.cpp @@ -162,7 +162,9 @@ std::string formatGameInfoWindow(const GameInfo& info) { //Show map text += "&FFFFFF"; text += qdTextDB::instance().getText("Interface.Tips.Multiplayer.Map"); - text += ": " + info.scenario + "\n"; + text += ": "; + text += getMapName(info.scenario.c_str()); + text += "\n"; //Show players if (info.currentPlayers < info.maximumPlayers) { @@ -194,8 +196,15 @@ void updateMultiplayerListUI() { bool hasSelection = hasGameListSelection(); //Set map window - int mapPos = hasSelection ? getMultiplayerMapNumber(selectedGame.scenario) : -1; - if (0 <= mapPos && mapPos < multiplayerMaps.size()) { + int mapPos = -1; + if (hasSelection) { + for (uint32_t i = 0, s = multiplayerMaps.size(); i < s; i++) { + if (selectedGame.scenario == multiplayerMaps[i].worldName()) { + mapPos = static_cast(i); + } + } + } + if (0 <= mapPos) { setupMapDescWnd(mapPos, multiplayerMaps, SQSH_MM_MULTIPLAYER_LIST_MAP, -1, -1, GT_MULTI_PLAYER_CREATE); } else { ((CShowMapWindow*)_shellIconManager.GetWnd(SQSH_MM_MULTIPLAYER_LIST_MAP))->setWorldID( hasSelection ? -2 : -1 ); diff --git a/Source/UserInterface/Menu/MultiplayerLobby.cpp b/Source/UserInterface/Menu/MultiplayerLobby.cpp index adc42074..6f3bacd5 100644 --- a/Source/UserInterface/Menu/MultiplayerLobby.cpp +++ b/Source/UserInterface/Menu/MultiplayerLobby.cpp @@ -466,7 +466,12 @@ void onMMLobbyGameNameButton(CShellWindow* pWnd, InterfaceEventCode code, int pa _shellIconManager.GetWnd(SQSH_MM_LOBBY_GAME_MAP)->Show(0); CShowMapWindow* mapWindow = ((CShowMapWindow*)_shellIconManager.GetWnd(SQSH_MM_LOBBY_HOST_GAME_MAP)); mapWindow->setWorldID( missingContent.empty() ? currMission.worldID() : -2 ); - int pos = getMultiplayerMapNumber(currMission.missionName()); + int pos = -1; + for (uint32_t i = 0, s = multiplayerMaps.size(); i < s; i++) { + if (currMission.missionName() == multiplayerMaps[i].missionName()) { + pos = static_cast(i); + } + } if (pos != -1) { ((CListBoxWindow*)_shellIconManager.GetWnd(SQSH_MM_LOBBY_MAP_LIST))->SetCurSelPassive(pos); }