From 76a67b908156124490210db74832f34d3ab3652e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 9 Apr 2016 20:36:58 +0300 Subject: Show server host name in window title. --- src/client.cpp | 2 ++ src/gui/windowmanager.cpp | 20 ++++++++++++++++++++ src/gui/windowmanager.h | 2 ++ 3 files changed, 24 insertions(+) diff --git a/src/client.cpp b/src/client.cpp index 3259f2265..ccc64b30f 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -775,6 +775,7 @@ void Client::stateConnectServer1() settings.persistentIp = mCurrentServer.persistentIp; settings.supportUrl = mCurrentServer.supportUrl; settings.updateMirrors = mCurrentServer.updateMirrors; + WindowManager::updateTitle(); if (settings.options.username.empty()) { @@ -1618,6 +1619,7 @@ int Client::gameExec() gameHandler->clear(); } settings.serverName.clear(); + WindowManager::updateTitle(); serverConfig.write(); serverConfig.unload(); if (setupWindow) diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp index e8c7f2425..822b3b3e9 100644 --- a/src/gui/windowmanager.cpp +++ b/src/gui/windowmanager.cpp @@ -163,6 +163,26 @@ void WindowManager::initTitle() #endif } +void WindowManager::updateTitle() +{ + const std::string str = settings.serverName; + if (str.empty()) + { + settings.windowCaption = strprintf("%s %s", + branding.getStringValue("appName").c_str(), + SMALL_VERSION); + } + else + { + settings.windowCaption = strprintf("%s %s - %s", + branding.getStringValue("appName").c_str(), + SMALL_VERSION, + str.c_str()); + } + SDL::SetWindowTitle(mainGraphics->getWindow(), + settings.windowCaption.c_str()); +} + void WindowManager::setFramerate(const unsigned int fpsLimit) { if (!fpsLimit) diff --git a/src/gui/windowmanager.h b/src/gui/windowmanager.h index b100288fc..74fe1c2f1 100644 --- a/src/gui/windowmanager.h +++ b/src/gui/windowmanager.h @@ -76,6 +76,8 @@ namespace WindowManager void setIcon(); void deleteIcon(); + + void updateTitle(); } // namespace WindowManager #endif // GUI_WINDOWMANAGER_H -- cgit v1.2.3-70-g09d2