1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Allows to translate default playername

This commit is contained in:
Michael 2023-05-28 16:57:24 +02:00 committed by GitHub
parent ee49487dc8
commit 8672fc7e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 3 deletions

View File

@ -37,6 +37,7 @@
"vcmi.mainMenu.serverClosing" : "Closing...",
"vcmi.mainMenu.hostTCP" : "Host TCP/IP game",
"vcmi.mainMenu.joinTCP" : "Join TCP/IP game",
"vcmi.mainMenu.playerName" : "Player",
"vcmi.server.errors.existingProcess" : "Another VCMI server process is running. Please terminate it before starting a new game.",
"vcmi.server.errors.modsIncompatibility" : "The following mods are required to load the game:",

View File

@ -37,6 +37,7 @@
"vcmi.mainMenu.serverClosing" : "Trenne...",
"vcmi.mainMenu.hostTCP" : "Hoste TCP/IP Spiel",
"vcmi.mainMenu.joinTCP" : "Trete TCP/IP Spiel bei",
"vcmi.mainMenu.playerName" : "Spieler",
"vcmi.server.errors.existingProcess" : "Es läuft ein weiterer vcmiserver-Prozess, bitte beendet diesen zuerst",
"vcmi.server.errors.modsIncompatibility" : "Erforderliche Mods um das Spiel zu laden:",

View File

@ -400,7 +400,7 @@ CMultiMode::CMultiMode(ESelectionScreen ScreenType)
statusBar = CGStatusBar::create(std::make_shared<CPicture>(background->getSurface(), Rect(7, 465, 440, 18), 7, 465));
playerName = std::make_shared<CTextInput>(Rect(19, 436, 334, 16), background->getSurface());
playerName->setText(settings["general"]["playerName"].String());
playerName->setText(getDefaultPlayerName());
playerName->cb += std::bind(&CMultiMode::onNameChange, this, _1);
buttonHotseat = std::make_shared<CButton>(Point(373, 78), "MUBHOT.DEF", CGI->generaltexth->zelp[266], std::bind(&CMultiMode::hostTCP, this));
@ -413,14 +413,22 @@ void CMultiMode::hostTCP()
{
auto savedScreenType = screenType;
close();
GH.windows().createAndPushWindow<CMultiPlayers>(settings["general"]["playerName"].String(), savedScreenType, true, ELoadMode::MULTI);
GH.windows().createAndPushWindow<CMultiPlayers>(getDefaultPlayerName(), savedScreenType, true, ELoadMode::MULTI);
}
void CMultiMode::joinTCP()
{
auto savedScreenType = screenType;
close();
GH.windows().createAndPushWindow<CMultiPlayers>(settings["general"]["playerName"].String(), savedScreenType, false, ELoadMode::MULTI);
GH.windows().createAndPushWindow<CMultiPlayers>(getDefaultPlayerName(), savedScreenType, false, ELoadMode::MULTI);
}
std::string CMultiMode::getDefaultPlayerName()
{
std::string name = settings["general"]["playerName"].String();
if(name == "Player")
name = CGI->generaltexth->translate("vcmi.mainMenu.playerName");
return name;
}
void CMultiMode::onNameChange(std::string newText)

View File

@ -91,6 +91,7 @@ public:
CMultiMode(ESelectionScreen ScreenType);
void hostTCP();
void joinTCP();
getDefaultPlayerName()
void onNameChange(std::string newText);
};