From 31acb66791e27b6cfa846302156ad2e7a88f5f04 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 20 Aug 2012 14:20:26 +0300 Subject: Show clickable update links for manaplus. Site url and download link. --- src/gui/updaterwindow.cpp | 16 +++++++++++++++- src/gui/updaterwindow.h | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 71aec58a0..49977ae4b 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -46,6 +46,7 @@ #include "utils/gettext.h" #include "utils/mkdir.h" #include "utils/paths.h" +#include "utils/process.h" #include "utils/stringutils.h" #include "utils/xml.h" @@ -174,6 +175,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, mProgressBar->setSmoothProgress(false); mBrowserBox->setOpaque(false); + mBrowserBox->setLinkHandler(this); mPlayButton->setEnabled(false); ContainerPlacer placer; @@ -374,7 +376,12 @@ void UpdaterWindow::loadPatch() if (version > CHECK_VERSION) { mBrowserBox->addRow("", true); - mBrowserBox->addRow(" ##1http://manaplus.evolonline.org/", true); +#ifdef WIN32 + mBrowserBox->addRow(" ##1[@@http://download.evolonline.org/" + "manaplus/download/manaplus-win32.exe|download here@@]", true); +#endif + mBrowserBox->addRow(" ##1@@http://manaplus.evolonline.org/|" + "http://manaplus.evolonline.org/@@", true); mBrowserBox->addRow("##1You can download it from", true); mBrowserBox->addRow("##1ManaPlus updated.", true); } @@ -833,3 +840,10 @@ bool UpdaterWindow::validateFile(std::string filePath, unsigned long hash) fclose(file); return adler == hash; } + +void UpdaterWindow::handleLink(const std::string &link, + gcn::MouseEvent *event A_UNUSED) +{ + if (strStartWith(link, "http://")) + openBrowser(link); +} diff --git a/src/gui/updaterwindow.h b/src/gui/updaterwindow.h index 1039bbb9e..90bd06847 100644 --- a/src/gui/updaterwindow.h +++ b/src/gui/updaterwindow.h @@ -23,6 +23,7 @@ #ifndef UPDATERWINDOW_H #define UPDATERWINDOW_H +#include "gui/widgets/linkhandler.h" #include "gui/widgets/window.h" #include "net/download.h" @@ -61,7 +62,9 @@ struct updateFile * * \ingroup GUI */ -class UpdaterWindow : public Window, public gcn::ActionListener, +class UpdaterWindow : public Window, + public gcn::ActionListener, + public LinkHandler, public gcn::KeyListener { public: @@ -112,6 +115,8 @@ class UpdaterWindow : public Window, public gcn::ActionListener, void logic(); + void handleLink(const std::string &link, gcn::MouseEvent *event A_UNUSED); + static void loadLocalUpdates(std::string dir); static void addUpdateFile(ResourceManager *resman, std::string path, -- cgit v1.2.3-70-g09d2