Skip to content

Commit

Permalink
UI: Fix map preview in multiplayer room list
Browse files Browse the repository at this point in the history
  • Loading branch information
IonAgorria committed May 21, 2024
1 parent a728588 commit acc0cbe
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Source/Network/ServerList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>(game_content);
gameList.emplace_back(info);
Expand Down
12 changes: 3 additions & 9 deletions Source/UserInterface/Menu/MultiplayerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(i);
}
}
return -1;
}

int SwitchMultiplayerToLoadQuant(float, float ) {
if (menuChangingDone) {
gameShell->currentSingleProfile.setLastGameType(UserSingleProfile::MULTIPLAYER);
Expand Down
1 change: 0 additions & 1 deletion Source/UserInterface/Menu/MultiplayerCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ extern std::vector<MissionDescription> multiplayerSaves;
void loadMultiplayerList();
int exitToMultiplayerScreenAction(float, float);

int getMultiplayerMapNumber(const std::string& missionName);
15 changes: 12 additions & 3 deletions Source/UserInterface/Menu/MultiplayerList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<int>(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 );
Expand Down
7 changes: 6 additions & 1 deletion Source/UserInterface/Menu/MultiplayerLobby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(i);
}
}
if (pos != -1) {
((CListBoxWindow*)_shellIconManager.GetWnd(SQSH_MM_LOBBY_MAP_LIST))->SetCurSelPassive(pos);
}
Expand Down

0 comments on commit acc0cbe

Please sign in to comment.