summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-06-30 16:50:50 +0300
committerAndrei Karas <akaras@inbox.ru>2013-06-30 16:50:50 +0300
commit143e04546197d75279d41e9eefe0fca4478673d4 (patch)
tree0a78eb7251943571342bba70210161af603473d8
parentdbe40332cd904f8e48504a2e8a3e7f74f4619712 (diff)
downloadmanaplus-143e04546197d75279d41e9eefe0fca4478673d4.tar.gz
manaplus-143e04546197d75279d41e9eefe0fca4478673d4.tar.bz2
manaplus-143e04546197d75279d41e9eefe0fca4478673d4.tar.xz
manaplus-143e04546197d75279d41e9eefe0fca4478673d4.zip
Add ability to open support page if error happend.
-rw-r--r--src/client.cpp34
-rw-r--r--src/client.h7
-rw-r--r--src/game.cpp9
-rw-r--r--src/gui/charselectdialog.cpp2
-rw-r--r--src/gui/confirmdialog.cpp8
-rw-r--r--src/gui/confirmdialog.h3
-rw-r--r--src/gui/logindialog.cpp2
-rw-r--r--src/gui/selldialog.cpp2
-rw-r--r--src/gui/serverdialog.cpp7
-rw-r--r--src/gui/shopwindow.cpp2
-rw-r--r--src/gui/socialwindow.cpp8
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp2
-rw-r--r--src/net/ea/network.cpp2
-rw-r--r--src/net/ea/tradehandler.cpp3
-rw-r--r--src/net/serverinfo.h4
15 files changed, 69 insertions, 26 deletions
diff --git a/src/client.cpp b/src/client.cpp
index d1dfadb92..cdda89585 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -51,6 +51,7 @@
#include "gui/changeemaildialog.h"
#include "gui/changepassworddialog.h"
#include "gui/charselectdialog.h"
+#include "gui/confirmdialog.h"
#include "gui/connectiondialog.h"
#include "gui/gui.h"
#include "gui/logindialog.h"
@@ -101,6 +102,7 @@
#include "utils/mkdir.h"
#include "utils/paths.h"
#include "utils/physfstools.h"
+#include "utils/process.h"
#include "utils/translation/translationmanager.h"
@@ -161,8 +163,10 @@ int openGLMode = 0;
static uint32_t nextTick(uint32_t interval, void *param A_UNUSED);
static uint32_t nextSecond(uint32_t interval, void *param A_UNUSED);
-void ErrorListener::action(const gcn::ActionEvent &)
+void ErrorListener::action(const gcn::ActionEvent &event)
{
+ if (event.getId() == "yes")
+ openBrowser(Client::getSupportUrl());
Client::setState(STATE_CHOOSE_SERVER);
}
@@ -1215,6 +1219,7 @@ int Client::gameExec()
{
BLOCK_START("Client::gameExec STATE_CHOOSE_SERVER")
logger->log1("State: CHOOSE SERVER");
+ mCurrentServer.supportUrl.clear();
ResourceManager *const resman
= ResourceManager::getInstance();
if (mOptions.dataPath.empty())
@@ -1696,9 +1701,9 @@ int Client::gameExec()
Net::getLoginHandler()->disconnect();
// TRANSLATORS: unregister message header
- mCurrentDialog = new OkDialog(_("Unregister Successful"),
+ mCurrentDialog = openErrorDialog(_("Unregister Successful"),
// TRANSLATORS: unregister message text
- _("Farewell, come back any time..."), DIALOG_ERROR);
+ _("Farewell, come back any time..."), true);
loginData.clear();
// The errorlistener sets the state to STATE_CHOOSE_SERVER
mCurrentDialog->addActionListener(&errorListener);
@@ -1775,8 +1780,8 @@ int Client::gameExec()
logger->log1("State: ERROR");
logger->log("Error: %s\n", errorMessage.c_str());
// TRANSLATORS: error message header
- mCurrentDialog = new OkDialog(_("Error"),
- errorMessage, DIALOG_ERROR);
+ mCurrentDialog = openErrorDialog(_("Error"),
+ errorMessage, true);
mCurrentDialog->addActionListener(&errorListener);
mCurrentDialog = nullptr; // OkDialog deletes itself
Net::getGameHandler()->disconnect();
@@ -2170,7 +2175,7 @@ void Client::initUpdatesDir()
{
logger->log("Error: Invalid update host: %s", mUpdateHost.c_str());
// TRANSLATORS: update server initialisation error
- errorMessage = strprintf(_("Invalid update host: %s"),
+ errorMessage = strprintf(_("Invalid update host: %s."),
mUpdateHost.c_str());
mState = STATE_ERROR;
}
@@ -3010,3 +3015,20 @@ void Client::checkConfigVersion()
config.setValue("cfgver", 2);
}
+
+Window *Client::openErrorDialog(const std::string &header,
+ const std::string &message,
+ const bool modal)
+{
+ if (getSupportUrl().empty())
+ {
+ return new OkDialog(header, message, DIALOG_ERROR, modal);
+ }
+ else
+ {
+ return new ConfirmDialog(header, strprintf("%s %s", message.c_str(),
+ // TRANSLATORS: error message question
+ _("Do you want to open support page?")),
+ SOUND_ERROR, false, modal);
+ }
+}
diff --git a/src/client.h b/src/client.h
index 09b73bd9f..44a71b460 100644
--- a/src/client.h
+++ b/src/client.h
@@ -287,6 +287,9 @@ public:
static std::string getOnlineUrl() A_WARN_UNUSED
{ return instance()->mOnlineListUrl; }
+ static std::string getSupportUrl() A_WARN_UNUSED
+ { return instance()->mCurrentServer.supportUrl; }
+
static void resize(const int width, const int height,
const bool always = false)
{ instance()->resizeVideo(width, height, always); }
@@ -340,6 +343,10 @@ public:
static void updateScreenKeyboard(int height);
+ static Window *openErrorDialog(const std::string &header,
+ const std::string &message,
+ const bool modal);
+
private:
void initRootDir();
diff --git a/src/game.cpp b/src/game.cpp
index bfe3aa5e0..052e20949 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -113,7 +113,7 @@ OkDialog *weightNotice = nullptr;
int weightNoticeTime = 0;
OkDialog *deathNotice = nullptr;
QuitDialog *quitDialog = nullptr;
-OkDialog *disconnectedDialog = nullptr;
+Window *disconnectedDialog = nullptr;
ChatWindow *chatWindow = nullptr;
StatusWindow *statusWindow = nullptr;
@@ -614,11 +614,12 @@ void Game::slowLogic()
{
if (!disconnectedDialog)
{
+
// TRANSLATORS: error message text
errorMessage = _("The connection to the server was lost.");
- // TRANSLATORS: error message header
- disconnectedDialog = new OkDialog(_("Network Error"),
- errorMessage, DIALOG_ERROR, false);
+ disconnectedDialog = Client::openErrorDialog(
+ // TRANSLATORS: error message header
+ _("Network Error"), errorMessage, false);
disconnectedDialog->addActionListener(&errorListener);
disconnectedDialog->requestMoveToTop();
}
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 84217e8f9..8daf1e279 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -61,7 +61,7 @@ class CharDeleteConfirm final : public ConfirmDialog
ConfirmDialog(_("Confirm Character Delete"),
// TRANSLATORS: char deletion message
_("Are you sure you want to delete this character?"),
- false, false, m),
+ SOUND_REQUEST, false, false, m),
mMaster(m),
mIndex(index)
{
diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp
index cef2237d7..a2441c63b 100644
--- a/src/gui/confirmdialog.cpp
+++ b/src/gui/confirmdialog.cpp
@@ -22,8 +22,6 @@
#include "gui/confirmdialog.h"
-#include "soundmanager.h"
-
#include "gui/gui.h"
#include "gui/widgets/button.h"
@@ -36,8 +34,8 @@
#include "debug.h"
ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
- const bool ignore, const bool modal,
- Window *const parent):
+ const std::string &soundEvent, const bool ignore,
+ const bool modal, Window *const parent):
Window(title, modal, parent, "confirm.xml"),
gcn::ActionListener(),
mTextBox(new TextBox(this))
@@ -100,7 +98,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
}
setVisible(true);
yesButton->requestFocus();
- soundManager.playGuiSound(SOUND_REQUEST);
+ soundManager.playGuiSound(soundEvent);
}
void ConfirmDialog::action(const gcn::ActionEvent &event)
diff --git a/src/gui/confirmdialog.h b/src/gui/confirmdialog.h
index 70eb10124..f2ac75bbb 100644
--- a/src/gui/confirmdialog.h
+++ b/src/gui/confirmdialog.h
@@ -25,6 +25,8 @@
#include "localconsts.h"
+#include "soundmanager.h"
+
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
@@ -45,6 +47,7 @@ class ConfirmDialog : public Window, public gcn::ActionListener
* @see Window::Window
*/
ConfirmDialog(const std::string &title, const std::string &msg,
+ const std::string &soundEvent = SOUND_REQUEST,
const bool ignore = false, const bool modal = false,
Window *const parent = nullptr);
diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp
index 7e10a7766..458cb15cd 100644
--- a/src/gui/logindialog.cpp
+++ b/src/gui/logindialog.cpp
@@ -295,7 +295,7 @@ void LoginDialog::action(const gcn::ActionEvent &event)
urlListener.url = url;
// TRANSLATORS: question dialog
ConfirmDialog *const confirmDlg = new ConfirmDialog(
- _("Open register url"), url, false, true);
+ _("Open register url"), url, SOUND_REQUEST, false, true);
confirmDlg->addActionListener(&urlListener);
}
}
diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp
index c61dec541..2b397b331 100644
--- a/src/gui/selldialog.cpp
+++ b/src/gui/selldialog.cpp
@@ -242,7 +242,7 @@ void SellDialog::action(const gcn::ActionEvent &event)
_("sell item"),
// TRANSLATORS: sell confirmation message
strprintf(_("Do you really want to sell %s?"),
- info.getName().c_str()), false, true);
+ info.getName().c_str()), SOUND_REQUEST, false, true);
dialog->addActionListener(this);
return;
}
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 2da780046..04a07198f 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -386,6 +386,7 @@ void ServerDialog::connectToSelectedServer()
mServerInfo->description = server.description;
mServerInfo->registerUrl = server.registerUrl;
mServerInfo->onlineListUrl = server.onlineListUrl;
+ mServerInfo->supportUrl = server.supportUrl;
mServerInfo->save = true;
if (chatLogger)
@@ -671,6 +672,11 @@ void ServerDialog::loadServers(const bool addNew)
server.onlineListUrl = reinterpret_cast<const char*>(
subNode->xmlChildrenNode->content);
}
+ else if (xmlNameEqual(subNode, "support"))
+ {
+ server.supportUrl = reinterpret_cast<const char*>(
+ subNode->xmlChildrenNode->content);
+ }
}
server.version.first = font->getWidth(version);
@@ -690,6 +696,7 @@ void ServerDialog::loadServers(const bool addNew)
mServers[i].description = server.description;
mServers[i].registerUrl = server.registerUrl;
mServers[i].onlineListUrl = server.onlineListUrl;
+ mServers[i].supportUrl = server.supportUrl;
mServers[i].althostname = server.althostname;
mServersListModel->setVersionString(i, version);
found = true;
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index d7fcc2a60..36a67a2af 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -774,7 +774,7 @@ void ShopWindow::processRequest(const std::string &nick, std::string data,
// TRANSLATORS: shop window dialog
(_("Request for Trade"), strprintf(_("%s wants to %s %s do you "
"accept?"), nick.c_str(), msg.c_str(),
- mTradeItem->getInfo().getName().c_str()), true);
+ mTradeItem->getInfo().getName().c_str()), SOUND_REQUEST, true);
confirmDlg->addActionListener(this);
}
}
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index bdac7cca6..b4398b29e 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -238,7 +238,7 @@ public:
mConfirmDialog = new ConfirmDialog(_("Leave Guild?"),
// TRANSLATORS: guild leave message
strprintf(_("Are you sure you want to leave guild %s?"),
- mGuild->getName().c_str()), socialWindow);
+ mGuild->getName().c_str()), SOUND_REQUEST, socialWindow);
mConfirmDialog->addActionListener(this);
}
@@ -381,7 +381,7 @@ public:
mConfirmDialog = new ConfirmDialog(_("Leave Party?"),
// TRANSLATORS: party leave message
strprintf(_("Are you sure you want to leave party %s?"),
- mParty->getName().c_str()), socialWindow);
+ mParty->getName().c_str()), SOUND_REQUEST, socialWindow);
mConfirmDialog->addActionListener(this);
}
@@ -1490,7 +1490,7 @@ void SocialWindow::showGuildInvite(const std::string &guildName,
// TRANSLATORS: guild invite message
mGuildAcceptDialog = new ConfirmDialog(_("Accept Guild Invite"),
- msg, false, false, this);
+ msg, SOUND_REQUEST, false, false, this);
mGuildAcceptDialog->addActionListener(this);
mGuildInvited = guildId;
}
@@ -1547,7 +1547,7 @@ void SocialWindow::showPartyInvite(const std::string &partyName,
// show invite
// TRANSLATORS: party invite message
mPartyAcceptDialog = new ConfirmDialog(_("Accept Party Invite"),
- msg, false, false, this);
+ msg, SOUND_REQUEST, false, false, this);
mPartyAcceptDialog->addActionListener(this);
mPartyInviter = inviter;
}
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index fefaae428..188bfa931 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -84,7 +84,7 @@ void ItemLinkHandler::handleLink(const std::string &link,
{
ConfirmDialog *const confirmDlg = new ConfirmDialog(
// TRANSLATORS: dialog message
- _("Open url"), url, false, true);
+ _("Open url"), url, SOUND_REQUEST, false, true);
confirmDlg->addActionListener(&listener);
}
else if (button == gcn::MouseInput::RIGHT)
diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp
index f83eab629..5214cf7e4 100644
--- a/src/net/ea/network.cpp
+++ b/src/net/ea/network.cpp
@@ -199,7 +199,7 @@ bool Network::realConnect()
const std::string errorMessage = std::string(
// TRANSLATORS: error message
_("Unable to resolve host \"")).append(
- mServer.hostname).append("\"");
+ mServer.hostname).append("\".");
setError(errorMessage);
logger->log("TcpNet::ResolveHost: %s", errorMessage.c_str());
return false;
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 03dc1bcac..4fa92e7d8 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -103,7 +103,8 @@ void TradeHandler::processTradeRequest(Net::MessageIn &msg)
confirmDlg = new ConfirmDialog(_("Request for Trade"),
// TRANSLATORS: trade message
strprintf(_("%s wants to trade with you, do"
- " you accept?"), tradePartnerName.c_str()), true);
+ " you accept?"), tradePartnerName.c_str()),
+ SOUND_REQUEST, true);
confirmDlg->addActionListener(&listener);
}
else
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index 515595f1f..c9a2d4f91 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -55,6 +55,7 @@ public:
std::string description;
std::string registerUrl;
std::string onlineListUrl;
+ std::string supportUrl;
VersionString version;
bool save;
@@ -68,6 +69,7 @@ public:
description(),
registerUrl(),
onlineListUrl(),
+ supportUrl(),
version(),
save(false)
{
@@ -83,6 +85,7 @@ public:
description(info.description),
registerUrl(info.registerUrl),
onlineListUrl(info.onlineListUrl),
+ supportUrl(info.supportUrl),
version(),
save(info.save)
{
@@ -105,6 +108,7 @@ public:
description.clear();
registerUrl.clear();
onlineListUrl.clear();
+ supportUrl.clear();
version.first = 0;
version.second.clear();
save = false;