summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actions/windows.cpp21
-rw-r--r--src/actions/windows.h1
-rw-r--r--src/client.h3
-rw-r--r--src/dyetool/actions/windows.cpp1
-rw-r--r--src/enums/input/inputaction.h1
-rw-r--r--src/gui/windowmenu.cpp5
-rw-r--r--src/gui/windows/serverdialog.cpp5
-rw-r--r--src/gui/windows/serverinfowindow.cpp10
-rw-r--r--src/gui/windows/serverinfowindow.h4
-rw-r--r--src/input/inputactionmap.h6
-rw-r--r--src/input/pages/windows.cpp6
-rw-r--r--src/utils/browserboxtools.cpp6
12 files changed, 68 insertions, 1 deletions
diff --git a/src/actions/windows.cpp b/src/actions/windows.cpp
index 1cc9548c5..7c9b57d0a 100644
--- a/src/actions/windows.cpp
+++ b/src/actions/windows.cpp
@@ -21,6 +21,7 @@
#include "actions/windows.h"
#include "actormanager.h"
+#include "client.h"
#include "actions/actiondef.h"
@@ -45,10 +46,13 @@
#include "gui/windows/minimap.h"
#include "gui/windows/outfitwindow.h"
#include "gui/windows/setupwindow.h"
+#include "gui/windows/serverinfowindow.h"
#include "gui/windows/shopwindow.h"
#include "gui/windows/shortcutwindow.h"
#include "gui/windows/updaterwindow.h"
+#include "gui/widgets/createwidget.h"
+
#include "gui/widgets/tabs/chat/chattab.h"
#include "utils/gettext.h"
@@ -320,6 +324,23 @@ impHandler0(mailWindowShow)
return true;
}
+impHandler0(serverInfoWindowShow)
+{
+ if (serverInfoWindow != nullptr &&
+ serverInfoWindow->isWindowVisible())
+ {
+ serverInfoWindow->close();
+ serverInfoWindow = nullptr;
+ }
+ else
+ {
+ serverInfoWindow = CREATEWIDGETR(ServerInfoWindow,
+ client->getCurrentServer());
+ serverInfoWindow->requestMoveToTop();
+ }
+ return true;
+}
+
impHandler(showItems)
{
const std::string args = event.args;
diff --git a/src/actions/windows.h b/src/actions/windows.h
index 3820ee9fe..8b6311281 100644
--- a/src/actions/windows.h
+++ b/src/actions/windows.h
@@ -54,6 +54,7 @@ namespace Actions
decHandler(cartWindowShow);
decHandler(quickWindowShow);
decHandler(mailWindowShow);
+ decHandler(serverInfoWindowShow);
decHandler(showItems);
} // namespace Actions
diff --git a/src/client.h b/src/client.h
index a5c0a6135..f2681113a 100644
--- a/src/client.h
+++ b/src/client.h
@@ -95,6 +95,9 @@ class Client final : public ConfigListener,
void slowLogic();
+ ServerInfo &getCurrentServer()
+ { return mCurrentServer; }
+
private:
void initSoundManager();
diff --git a/src/dyetool/actions/windows.cpp b/src/dyetool/actions/windows.cpp
index 635a64f9f..ce5c72ce2 100644
--- a/src/dyetool/actions/windows.cpp
+++ b/src/dyetool/actions/windows.cpp
@@ -54,6 +54,7 @@ impHandlerVoid(cartWindowShow)
impHandlerVoid(updaterWindowShow)
impHandlerVoid(quickWindowShow)
impHandlerVoid(mailWindowShow)
+impHandlerVoid(serverInfoWindowShow)
impHandlerVoid(showItems)
} // namespace Actions
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index 101041992..0a0311114 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -700,6 +700,7 @@ enumStart(InputAction)
COMMAND_GOTO_PC,
COMMAND_RECALL_PC,
COMMAND_IP_CHECK,
+ WINDOW_SERVER_INFO,
TOTAL
}
enumEnd(InputAction);
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index f45b292f0..41640a458 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -171,6 +171,11 @@ WindowMenu::WindowMenu(const Widget2 *const widget) :
// TRANSLATORS: long button name for mail window.
_("Mail"), x, h, InputAction::WINDOW_MAIL,
Visible_true);
+ // TRANSLATORS: short button name for server info window.
+ addButton(N_("SI"),
+ // TRANSLATORS: long button name for server info window.
+ _("Server info"), x, h, InputAction::WINDOW_SERVER_INFO,
+ Visible_true);
// TRANSLATORS: short button name for debug window.
addButton(N_("DBG"),
// TRANSLATORS: long button name for debug window.
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index 501557c8c..c8c0256ee 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -246,6 +246,7 @@ void ServerDialog::connectToSelectedServer()
mServerInfo->freeSources = server.freeSources;
mServerInfo->nonFreeSources = server.nonFreeSources;
mServerInfo->docs = server.docs;
+ mServerInfo->serverUrl = server.serverUrl;
settings.persistentIp = mServerInfo->persistentIp;
settings.supportUrl = mServerInfo->supportUrl;
@@ -316,7 +317,9 @@ void ServerDialog::action(const ActionEvent &event)
const int index = mServersList->getSelected();
if (index >= 0)
{
- CREATEWIDGET(ServerInfoWindow,
+ if (serverInfoWindow != nullptr)
+ serverInfoWindow->scheduleDelete();
+ serverInfoWindow = CREATEWIDGETR(ServerInfoWindow,
mServers.at(index));
}
}
diff --git a/src/gui/windows/serverinfowindow.cpp b/src/gui/windows/serverinfowindow.cpp
index 660dd0241..c0099d356 100644
--- a/src/gui/windows/serverinfowindow.cpp
+++ b/src/gui/windows/serverinfowindow.cpp
@@ -33,6 +33,8 @@
#include "debug.h"
+ServerInfoWindow *serverInfoWindow = nullptr;
+
ServerInfoWindow::ServerInfoWindow(ServerInfo &serverInfo) :
// TRANSLATORS: servers dialog name
Window(_("Server info"), Modal_false, nullptr, "server_info.xml"),
@@ -170,3 +172,11 @@ void ServerInfoWindow::addServerComment(const std::string &url,
mBrowserBox->addRow(str);
}
}
+
+void ServerInfoWindow::close()
+{
+ Window::close();
+ if (serverInfoWindow == this)
+ serverInfoWindow = nullptr;
+ scheduleDelete();
+}
diff --git a/src/gui/windows/serverinfowindow.h b/src/gui/windows/serverinfowindow.h
index f3e2b545e..699a00451 100644
--- a/src/gui/windows/serverinfowindow.h
+++ b/src/gui/windows/serverinfowindow.h
@@ -46,6 +46,8 @@ class ServerInfoWindow final : public Window,
void handleLink(const std::string &link,
MouseEvent *const event A_UNUSED) override final;
+ void close() override final;
+
protected:
void showServerInfo();
@@ -61,4 +63,6 @@ class ServerInfoWindow final : public Window,
ScrollArea *mScrollArea A_NONNULLPOINTER;
};
+extern ServerInfoWindow *serverInfoWindow;
+
#endif // GUI_WINDOWS_SERVERINFOWINDOW_H
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index d593011b0..0de10a4e4 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5690,6 +5690,12 @@ static const InputActionData inputActionData
"ipcheck|checkip",
UseArgs_true,
Protected_true},
+ {"keyWindowServerInfo",
+ defaultAction(&Actions::serverInfoWindowShow),
+ InputCondition::GAME | InputCondition::NOTARGET,
+ "serverinfo|infoserver",
+ UseArgs_false,
+ Protected_false},
};
#undef defaultAction
diff --git a/src/input/pages/windows.cpp b/src/input/pages/windows.cpp
index b9d64acbc..ca232f914 100644
--- a/src/input/pages/windows.cpp
+++ b/src/input/pages/windows.cpp
@@ -67,6 +67,12 @@ SetupActionData setupActionDataWindows[] =
},
{
// TRANSLATORS: input action name
+ N_("Server Info Window"),
+ InputAction::WINDOW_SERVER_INFO,
+ "",
+ },
+ {
+ // TRANSLATORS: input action name
N_("Status Window"),
InputAction::WINDOW_STATUS,
"",
diff --git a/src/utils/browserboxtools.cpp b/src/utils/browserboxtools.cpp
index 5c7571c97..e3045c9ee 100644
--- a/src/utils/browserboxtools.cpp
+++ b/src/utils/browserboxtools.cpp
@@ -75,6 +75,12 @@ std::string BrowserBoxTools::replaceLinkCommands(const std::string &link)
std::string data = link;
+ if (strStartWith(data, "http://") ||
+ strStartWith(data, "https://"))
+ {
+ return data;
+ }
+
if (!link.empty() && link[0] == 'm')
{ // monster link
const BeingTypeId id = static_cast<BeingTypeId>(