summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-29 00:27:29 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-29 12:56:42 +0300
commit7c74dc533ce120a27ac4b68acb1c5b2f6c5cc680 (patch)
treec9689b1b707b73a8a4e3cc5b24d9ca67765ef217
parent1b500cb24655e2ad3e6c6fd20143ce0d2d070d6f (diff)
downloadmv-7c74dc533ce120a27ac4b68acb1c5b2f6c5cc680.tar.gz
mv-7c74dc533ce120a27ac4b68acb1c5b2f6c5cc680.tar.bz2
mv-7c74dc533ce120a27ac4b68acb1c5b2f6c5cc680.tar.xz
mv-7c74dc533ce120a27ac4b68acb1c5b2f6c5cc680.zip
Move openErrorDialog into DialogsManager.
-rw-r--r--src/client.cpp29
-rw-r--r--src/client.h4
-rw-r--r--src/game.cpp2
-rw-r--r--src/gui/dialogsmanager.cpp24
-rw-r--r--src/gui/dialogsmanager.h8
5 files changed, 39 insertions, 28 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 443928da9..e1df248b5 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -51,6 +51,7 @@
#include "input/joystick.h"
#include "input/keyboardconfig.h"
+#include "gui/dialogsmanager.h"
#include "gui/gui.h"
#include "gui/skin.h"
#include "gui/theme.h"
@@ -1686,7 +1687,7 @@ int Client::gameExec()
logger->log1("State: UNREGISTER SUCCESS");
Net::getLoginHandler()->disconnect();
- mCurrentDialog = openErrorDialog(
+ mCurrentDialog = DialogsManager::openErrorDialog(
// TRANSLATORS: unregister message header
_("Unregister Successful"),
// TRANSLATORS: unregister message text
@@ -1770,8 +1771,10 @@ int Client::gameExec()
logger->log1("State: ERROR");
logger->log("Error: %s\n", errorMessage.c_str());
// TRANSLATORS: error message header
- mCurrentDialog = openErrorDialog(_("Error"),
- errorMessage, true);
+ mCurrentDialog = DialogsManager::openErrorDialog(
+ _("Error"),
+ errorMessage,
+ true);
mCurrentDialog->addActionListener(&errorListener);
mCurrentDialog = nullptr; // OkDialog deletes itself
Net::getGameHandler()->disconnect();
@@ -2945,26 +2948,6 @@ void Client::checkConfigVersion()
config.setValue("cfgver", 8);
}
-Window *Client::openErrorDialog(const std::string &header,
- const std::string &message,
- const bool modal)
-{
- if (settings.supportUrl.empty() || config.getBoolValue("hidesupport"))
- {
- return new OkDialog(header, message, DialogType::ERROR, modal);
- }
- else
- {
- ConfirmDialog *const dialog = new ConfirmDialog(
- header, strprintf("%s %s", message.c_str(),
- // TRANSLATORS: error message question
- _("Do you want to open support page?")),
- SOUND_ERROR, false, modal);
- dialog->postInit();
- return dialog;
- }
-}
-
void Client::setIcon()
{
std::string iconFile = branding.getValue("appIcon", "icons/manaplus");
diff --git a/src/client.h b/src/client.h
index 4e891236f..06bc1faf0 100644
--- a/src/client.h
+++ b/src/client.h
@@ -245,10 +245,6 @@ public:
void reloadWallpaper();
- Window *openErrorDialog(const std::string &header,
- const std::string &message,
- const bool modal);
-
private:
static void createWindows();
diff --git a/src/game.cpp b/src/game.cpp
index 2e6e9ddd3..6d82f7138 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -674,7 +674,7 @@ void Game::slowLogic()
{
// TRANSLATORS: error message text
errorMessage = _("The connection to the server was lost.");
- disconnectedDialog = client->openErrorDialog(
+ disconnectedDialog = DialogsManager::openErrorDialog(
// TRANSLATORS: error message header
_("Network Error"), errorMessage, false);
disconnectedDialog->addActionListener(&errorListener);
diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp
index b23152605..ac15d960d 100644
--- a/src/gui/dialogsmanager.cpp
+++ b/src/gui/dialogsmanager.cpp
@@ -22,8 +22,10 @@
#include "gui/dialogsmanager.h"
+#include "configuration.h"
#include "settings.h"
+#include "gui/windows/confirmdialog.h"
#include "gui/windows/buyselldialog.h"
#include "gui/windows/buydialog.h"
#include "gui/windows/npcdialog.h"
@@ -34,6 +36,8 @@
#include "net/inventoryhandler.h"
#include "net/net.h"
+#include "utils/gettext.h"
+
#include "debug.h"
extern OkDialog *deathNotice;
@@ -62,3 +66,23 @@ void DialogsManager::createUpdaterWindow()
0);
updaterWindow->postInit();
}
+
+Window *DialogsManager::openErrorDialog(const std::string &header,
+ const std::string &message,
+ const bool modal)
+{
+ if (settings.supportUrl.empty() || config.getBoolValue("hidesupport"))
+ {
+ return new OkDialog(header, message, DialogType::ERROR, modal);
+ }
+ else
+ {
+ ConfirmDialog *const dialog = new ConfirmDialog(
+ header, strprintf("%s %s", message.c_str(),
+ // TRANSLATORS: error message question
+ _("Do you want to open support page?")),
+ SOUND_ERROR, false, modal);
+ dialog->postInit();
+ return dialog;
+ }
+}
diff --git a/src/gui/dialogsmanager.h b/src/gui/dialogsmanager.h
index 2814276a2..2190819c3 100644
--- a/src/gui/dialogsmanager.h
+++ b/src/gui/dialogsmanager.h
@@ -23,12 +23,20 @@
#ifndef DIALOGMANAGER_H
#define DIALOGMANAGER_H
+#include <string>
+
+class Window;
+
class DialogsManager final
{
public:
static void closeDialogs();
static void createUpdaterWindow();
+
+ static Window *openErrorDialog(const std::string &header,
+ const std::string &message,
+ const bool modal);
};
#endif // DIALOGMANAGER_H