summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gui/windows/serverdialog.cpp31
-rw-r--r--src/gui/windows/serverdialog.h1
-rw-r--r--src/gui/windows/serverinfowindow.cpp106
-rw-r--r--src/gui/windows/serverinfowindow.h63
6 files changed, 196 insertions, 9 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 47cbd4f76..8b3908a9b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -428,6 +428,8 @@ SET(SRCS
gui/widgets/selldialog.h
gui/windows/serverdialog.cpp
gui/windows/serverdialog.h
+ gui/windows/serverinfowindow.cpp
+ gui/windows/serverinfowindow.h
gui/windows/setupwindow.cpp
gui/windows/setupwindow.h
gui/widgets/tabs/setup_audio.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 1f9f1cc78..c4767ac47 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1216,6 +1216,8 @@ SRC = ${BASE_SRC} \
gui/windows/setupwindow.h \
gui/windows/serverdialog.cpp \
gui/windows/serverdialog.h \
+ gui/windows/serverinfowindow.cpp \
+ gui/windows/serverinfowindow.h \
gui/windows/quitdialog.cpp \
gui/windows/quitdialog.h \
gui/windows/questswindow.cpp \
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index c447bfc12..9600028b3 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -37,6 +37,7 @@
#include "gui/widgets/desktop.h"
#include "gui/windows/editserverdialog.h"
#include "gui/windows/logindialog.h"
+#include "gui/windows/serverinfowindow.h"
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
@@ -115,6 +116,8 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo,
mDeleteButton(new Button(this, _("Delete"), "remove", this)),
// TRANSLATORS: servers dialog button
mLoadButton(new Button(this, _("Load"), "load", this)),
+ // TRANSLATORS: servers dialog button
+ mInfoButton(new Button(this, _("Info"), "info", this)),
mServersListModel(new ServersListModel(&mServers, this)),
mServersList(CREATEWIDGETR(ServersListBox, this, mServersListModel)),
mDownload(nullptr),
@@ -151,15 +154,16 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo,
mServersList->addSelectionListener(this);
usedScroll->setVerticalScrollAmount(0);
- place(0, 0, usedScroll, 7, 5).setPadding(3);
- place(0, 5, mDescription, 7);
- place(0, 6, mPersistentIPCheckBox, 7);
- place(0, 7, mAddEntryButton);
- place(1, 7, mEditEntryButton);
- place(2, 7, mLoadButton);
- place(3, 7, mDeleteButton);
- place(5, 7, mQuitButton);
- place(6, 7, mConnectButton);
+ place(0, 0, usedScroll, 8, 5).setPadding(3);
+ place(0, 5, mDescription, 8);
+ place(0, 6, mPersistentIPCheckBox, 8);
+ place(0, 7, mInfoButton);
+ place(1, 7, mAddEntryButton);
+ place(2, 7, mEditEntryButton);
+ place(3, 7, mLoadButton);
+ place(4, 7, mDeleteButton);
+ place(6, 7, mQuitButton);
+ place(7, 7, mConnectButton);
// Make sure the list has enough height
getLayout().setRowHeight(0, 80);
@@ -304,6 +308,15 @@ void ServerDialog::action(const ActionEvent &event)
saveCustomServers();
}
}
+ else if (eventId == "info")
+ {
+ const int index = mServersList->getSelected();
+ if (index >= 0)
+ {
+ CREATEWIDGET(ServerInfoWindow,
+ mServers.at(index));
+ }
+ }
}
void ServerDialog::keyPressed(KeyEvent &event)
diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h
index 71c74f62e..b541e7f65 100644
--- a/src/gui/windows/serverdialog.h
+++ b/src/gui/windows/serverdialog.h
@@ -135,6 +135,7 @@ class ServerDialog final : public Window,
Button *mEditEntryButton A_NONNULLPOINTER;
Button *mDeleteButton A_NONNULLPOINTER;
Button *mLoadButton A_NONNULLPOINTER;
+ Button *mInfoButton A_NONNULLPOINTER;
ServersListModel *mServersListModel A_NONNULLPOINTER;
ListBox *mServersList A_NONNULLPOINTER;
diff --git a/src/gui/windows/serverinfowindow.cpp b/src/gui/windows/serverinfowindow.cpp
new file mode 100644
index 000000000..274fd97ce
--- /dev/null
+++ b/src/gui/windows/serverinfowindow.cpp
@@ -0,0 +1,106 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/windows/serverinfowindow.h"
+
+#include "enums/gui/layouttype.h"
+
+#include "gui/gui.h"
+
+#include "gui/widgets/browserbox.h"
+#include "gui/widgets/layout.h"
+#include "gui/widgets/scrollarea.h"
+
+#include "utils/gettext.h"
+#include "utils/process.h"
+#include "utils/stringutils.h"
+
+#include "debug.h"
+
+ServerInfoWindow::ServerInfoWindow(ServerInfo &serverInfo) :
+ // TRANSLATORS: servers dialog name
+ Window(_("Server info"), Modal_false, nullptr, "server_info.xml"),
+ LinkHandler(),
+ ActionListener(),
+ mServerInfo(serverInfo),
+ mBrowserBox(new BrowserBox(this, BrowserBoxMode::AUTO_SIZE, Opaque_true,
+ "browserbox.xml")),
+ mScrollArea(new ScrollArea(this, mBrowserBox,
+ Opaque_true, "serverinfo_background.xml"))
+{
+ setMinWidth(300);
+ setMinHeight(220);
+ setContentSize(455, 350);
+ setWindowName("ServerInfoWindow");
+ setCloseButton(true);
+ setResizable(true);
+ setStickyButtonLock(true);
+
+ setDefaultSize(500, 400, ImagePosition::CENTER);
+
+ mBrowserBox->setOpaque(Opaque_false);
+ mBrowserBox->setLinkHandler(this);
+ if (gui != nullptr)
+ mBrowserBox->setFont(gui->getHelpFont());
+ mBrowserBox->setProcessVars(true);
+ mBrowserBox->setEnableTabs(true);
+
+ place(0, 0, mScrollArea, 5, 3).setPadding(3);
+
+ Layout &layout = getLayout();
+ layout.setRowHeight(0, LayoutType::SET);
+
+ loadWindowState();
+ enableVisibleSound(true);
+ widgetResized(Event(nullptr));
+}
+
+void ServerInfoWindow::postInit()
+{
+ Window::postInit();
+ setVisible(Visible_true);
+ showServerInfo();
+}
+
+ServerInfoWindow::~ServerInfoWindow()
+{
+}
+
+void ServerInfoWindow::action(const ActionEvent &event)
+{
+ const std::string &eventId = event.getId();
+ if (eventId == "close")
+ {
+ }
+}
+
+void ServerInfoWindow::handleLink(const std::string &link,
+ MouseEvent *const event A_UNUSED)
+{
+ if (strStartWith(link, "http://") ||
+ strStartWith(link, "https://"))
+ {
+ openBrowser(link);
+ }
+}
+
+void ServerInfoWindow::showServerInfo()
+{
+}
diff --git a/src/gui/windows/serverinfowindow.h b/src/gui/windows/serverinfowindow.h
new file mode 100644
index 000000000..c0cf5c786
--- /dev/null
+++ b/src/gui/windows/serverinfowindow.h
@@ -0,0 +1,63 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GUI_WINDOWS_SERVERINFOWINDOW_H
+#define GUI_WINDOWS_SERVERINFOWINDOW_H
+
+#include "gui/widgets/window.h"
+
+#include "gui/widgets/linkhandler.h"
+
+#include "listeners/actionlistener.h"
+
+#include "net/serverinfo.h"
+
+class BrowserBox;
+class ScrollArea;
+class ServerInfo;
+
+class ServerInfoWindow final : public Window,
+ public LinkHandler,
+ public ActionListener
+{
+ public:
+ ServerInfoWindow(ServerInfo &serverInfo);
+
+ A_DELETE_COPY(ServerInfoWindow)
+
+ void postInit() override final;
+
+ ~ServerInfoWindow();
+
+ void action(const ActionEvent &event) override final;
+
+ void handleLink(const std::string &link,
+ MouseEvent *const event A_UNUSED) override final;
+
+ protected:
+ void showServerInfo();
+
+ private:
+ ServerInfo mServerInfo;
+ BrowserBox *mBrowserBox A_NONNULLPOINTER;
+ ScrollArea *mScrollArea A_NONNULLPOINTER;
+};
+
+#endif // GUI_WINDOWS_SERVERINFOWINDOW_H