Przeglądaj źródła

Show opponent name in 1-vs-1 games, minor tweaks

Ivan Savenko 1 rok temu
rodzic
commit
b50d9de912

+ 4 - 1
Mods/vcmi/config/vcmi/english.json

@@ -81,8 +81,11 @@
 	"vcmi.lobby.header.rooms" : "Game Rooms",
 	"vcmi.lobby.header.channels" : "Chat Channels",
 	"vcmi.lobby.header.chat" : "Game Chat",
-	"vcmi.lobby.header.history" : "Your Games",
+	"vcmi.lobby.header.history" : "Your Previous Games",
 	"vcmi.lobby.header.players" : "Players Online",
+	"vcmi.lobby.match.solo" : "Solo Game",
+	"vcmi.lobby.match.duel" : "Game with %s",
+	"vcmi.lobby.match.multi" : "%d players",
 	"vcmi.lobby.room.create" : "Create New Room",
 	"vcmi.lobby.room.players.limit" : "Players Limit",
 	"vcmi.lobby.room.description.public" : "Any player can join public room.",

+ 3 - 0
Mods/vcmi/config/vcmi/ukrainian.json

@@ -83,6 +83,9 @@
 	"vcmi.lobby.header.chat" : "Чат гри",
 	"vcmi.lobby.header.history" : "Ваші попередні ігри",
 	"vcmi.lobby.header.players" : "Гравці в мережі",
+	"vcmi.lobby.match.solo" : "Одиночна гра",
+	"vcmi.lobby.match.duel" : "Гра з %s",
+	"vcmi.lobby.match.multi" : "%d гравців",
 	"vcmi.lobby.room.create" : "Створити нову кімнату",
 	"vcmi.lobby.room.players.limit" : "Максимум гравців",
 	"vcmi.lobby.room.description.public" : "Будь-хто з гравців може приєднатися до публічної кімнати.",

+ 1 - 1
client/GameChatHandler.cpp

@@ -35,7 +35,7 @@ static std::string getCurrentTimeFormatted(int timeOffsetSeconds = 0)
 	return TextOperations::getFormattedTimeLocal(std::chrono::system_clock::to_time_t(timeNowChrono));
 }
 
-const std::vector<GameChatMessage> & GameChatHandler::getChatHistory()
+const std::vector<GameChatMessage> & GameChatHandler::getChatHistory() const
 {
 	return chatHistory;
 }

+ 1 - 1
client/GameChatHandler.h

@@ -25,7 +25,7 @@ class GameChatHandler : boost::noncopyable
 	std::vector<GameChatMessage> chatHistory;
 public:
 	/// Returns all message history for current match
-	const std::vector<GameChatMessage> & getChatHistory();
+	const std::vector<GameChatMessage> & getChatHistory() const;
 
 	/// Erases any local state, must be called when client disconnects from match server
 	void resetMatchState();

+ 13 - 3
client/globalLobby/GlobalLobbyWidget.cpp

@@ -24,6 +24,7 @@
 #include "../widgets/ObjectLists.h"
 #include "../widgets/TextControls.h"
 
+#include "../../lib/CConfigHandler.h"
 #include "../../lib/Languages.h"
 #include "../../lib/MetaString.h"
 
@@ -222,14 +223,23 @@ GlobalLobbyMatchCard::GlobalLobbyMatchCard(GlobalLobbyWindow * window, const Glo
 	MetaString opponentDescription;
 
 	if (matchDescription.participants.size() == 1)
-		opponentDescription.appendRawString("Solo game"); // or "Singleplayer game" is better?
+		opponentDescription.appendTextID("vcmi.lobby.match.solo");
 
 	if (matchDescription.participants.size() == 2)
-		opponentDescription.appendRawString(matchDescription.participants[0].displayName);//FIXME: find opponent - not our player
+	{
+		std::string ourAccountID = settings["lobby"]["accountID"].String();
+
+		opponentDescription.appendTextID("vcmi.lobby.match.duel");
+		// Find display name of our one and only opponent in this game
+		if (matchDescription.participants[0].accountID == ourAccountID)
+			opponentDescription.replaceRawString(matchDescription.participants[1].displayName);
+		else
+			opponentDescription.replaceRawString(matchDescription.participants[0].displayName);
+	}
 
 	if (matchDescription.participants.size() > 2)
 	{
-		opponentDescription.appendRawString("%d players");
+		opponentDescription.appendTextID("vcmi.lobby.match.multi");
 		opponentDescription.replaceNumber(matchDescription.participants.size());
 	}