summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-28 21:29:43 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-28 21:45:47 +0300
commit0b7ef18ac3c7fb4e3717f6311d4e21a31ff440d5 (patch)
tree6ed783279483538799567c38c2818c5dd136e302
parentbb87f2911b63eaf80e49d689bf52ecf2042ae098 (diff)
downloadmv-0b7ef18ac3c7fb4e3717f6311d4e21a31ff440d5.tar.gz
mv-0b7ef18ac3c7fb4e3717f6311d4e21a31ff440d5.tar.bz2
mv-0b7ef18ac3c7fb4e3717f6311d4e21a31ff440d5.tar.xz
mv-0b7ef18ac3c7fb4e3717f6311d4e21a31ff440d5.zip
Move dialogs related function into separate file.
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/actionmanager.cpp3
-rw-r--r--src/client.cpp11
-rw-r--r--src/client.h2
-rw-r--r--src/game.cpp23
-rw-r--r--src/game.h4
-rw-r--r--src/gui/dialogsmanager.cpp64
-rw-r--r--src/gui/dialogsmanager.h34
-rw-r--r--src/gui/windows/quitdialog.cpp9
-rw-r--r--src/gui/windows/updaterwindow.cpp2
-rw-r--r--src/listeners/playerdeathlistener.h5
12 files changed, 115 insertions, 46 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 86d4e3390..e6949e4c7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -984,6 +984,8 @@ SET(SRCS
gui/widgets/basiccontainer.cpp
gui/cliprect.cpp
gui/color.cpp
+ gui/dialogsmanager.cpp
+ gui/dialogsmanager.h
input/key.cpp
gui/rect.cpp
gui/widgets/widget.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 13220ba5e..4b2101d94 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -218,6 +218,8 @@ manaplus_SOURCES += events/actionevent.h \
gui/widgets/basiccontainer.cpp \
gui/cliprect.cpp \
gui/color.cpp \
+ gui/dialogsmanager.cpp \
+ gui/dialogsmanager.h \
input/key.cpp \
gui/rect.cpp \
gui/widgets/widget.cpp \
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index c751c9530..12e13845a 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -34,6 +34,7 @@
#include "input/inputmanager.h"
+#include "gui/dialogsmanager.h"
#include "gui/gui.h"
#include "gui/sdlinput.h"
#include "gui/viewport.h"
@@ -869,7 +870,7 @@ impHandler0(updaterWindowShow)
if (updaterWindow)
updaterWindow->deleteSelf();
else
- Game::createUpdaterWindow();
+ DialogsManager::createUpdaterWindow();
return true;
}
diff --git a/src/client.cpp b/src/client.cpp
index 3161bae41..1d0cb9609 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -2738,17 +2738,6 @@ int Client::getFramerate() const
return SDL_getFramerate(&client->mFpsManager);
}
-void Client::closeDialogs()
-{
- NpcDialog::clearDialogs();
- BuyDialog::closeAll();
- BuySellDialog::closeAll();
- NpcDialog::closeAll();
- SellDialog::closeAll();
- if (Net::getInventoryHandler())
- Net::getInventoryHandler()->closeStorage();
-}
-
bool Client::isTmw() const
{
const std::string &name = getServerName();
diff --git a/src/client.h b/src/client.h
index 18021b331..e1faaba90 100644
--- a/src/client.h
+++ b/src/client.h
@@ -248,8 +248,6 @@ public:
float getGuiAlpha() const A_WARN_UNUSED
{ return mGuiAlpha; }
- static void closeDialogs();
-
void setFramerate(const int fpsLimit) const;
int getFramerate() const A_WARN_UNUSED;
diff --git a/src/game.cpp b/src/game.cpp
index 67b887022..e12ff98a7 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -49,6 +49,7 @@
#include "input/keyboardconfig.h"
#include "gui/chatconsts.h"
+#include "gui/dialogsmanager.h"
#include "gui/gui.h"
#include "gui/viewport.h"
#include "gui/windowmenu.h"
@@ -156,7 +157,6 @@ BotCheckerWindow *botCheckerWindow = nullptr;
SocialWindow *socialWindow = nullptr;
QuestsWindow *questsWindow = nullptr;
WindowMenu *windowMenu = nullptr;
-UpdaterWindow *updaterWindow = nullptr;
ActorManager *actorManager = nullptr;
CommandHandler *commandHandler = nullptr;
@@ -690,7 +690,7 @@ void Game::slowLogic()
map->saveExtraLayer();
}
}
- closeDialogs();
+ DialogsManager::closeDialogs();
client->setFramerate(config.getIntValue("fpslimit"));
mNextAdjustTime = cur_time + adjustDelay;
if (client->getState() != STATE_ERROR)
@@ -1187,16 +1187,6 @@ void Game::clearKeysArray()
}
}
-void Game::closeDialogs()
-{
- Client::closeDialogs();
- if (deathNotice)
- {
- deathNotice->scheduleDelete();
- deathNotice = nullptr;
- }
-}
-
void Game::videoResized(const int width, const int height)
{
if (viewport)
@@ -1204,12 +1194,3 @@ void Game::videoResized(const int width, const int height)
if (windowMenu)
windowMenu->setPosition(width - windowMenu->getWidth(), 0);
}
-
-void Game::createUpdaterWindow()
-{
- updaterWindow = new UpdaterWindow(client->getUpdateHost(),
- client->getOldUpdates(),
- false,
- 0);
- updaterWindow->postInit();
-}
diff --git a/src/game.h b/src/game.h
index 8b25cd146..3d2536362 100644
--- a/src/game.h
+++ b/src/game.h
@@ -105,8 +105,6 @@ class Game final
void setAdjustLevel(const int n)
{ mAdjustLevel = n; }
- static void closeDialogs();
-
static void videoResized(const int width, const int height);
bool getValidSpeed() const A_WARN_UNUSED
@@ -120,8 +118,6 @@ class Game final
static bool saveScreenshot(SDL_Surface *const screenshot);
- static void createUpdaterWindow();
-
void updateHistory(const SDL_Event &event);
void checkKeys();
diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp
new file mode 100644
index 000000000..ed1ea9604
--- /dev/null
+++ b/src/gui/dialogsmanager.cpp
@@ -0,0 +1,64 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 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/dialogsmanager.h"
+
+#include "client.h"
+
+#include "gui/windows/buyselldialog.h"
+#include "gui/windows/buydialog.h"
+#include "gui/windows/npcdialog.h"
+#include "gui/windows/okdialog.h"
+#include "gui/windows/selldialog.h"
+#include "gui/windows/updaterwindow.h"
+
+#include "net/inventoryhandler.h"
+#include "net/net.h"
+
+#include "debug.h"
+
+extern OkDialog *deathNotice;
+
+void DialogsManager::closeDialogs()
+{
+ NpcDialog::clearDialogs();
+ BuyDialog::closeAll();
+ BuySellDialog::closeAll();
+ NpcDialog::closeAll();
+ SellDialog::closeAll();
+ if (Net::getInventoryHandler())
+ Net::getInventoryHandler()->closeStorage();
+ if (deathNotice)
+ {
+ deathNotice->scheduleDelete();
+ deathNotice = nullptr;
+ }
+}
+
+void DialogsManager::createUpdaterWindow()
+{
+ updaterWindow = new UpdaterWindow(client->getUpdateHost(),
+ client->getOldUpdates(),
+ false,
+ 0);
+ updaterWindow->postInit();
+}
diff --git a/src/gui/dialogsmanager.h b/src/gui/dialogsmanager.h
new file mode 100644
index 000000000..2814276a2
--- /dev/null
+++ b/src/gui/dialogsmanager.h
@@ -0,0 +1,34 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 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 DIALOGMANAGER_H
+#define DIALOGMANAGER_H
+
+class DialogsManager final
+{
+ public:
+ static void closeDialogs();
+
+ static void createUpdaterWindow();
+};
+
+#endif // DIALOGMANAGER_H
diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp
index 20c194360..6981936e3 100644
--- a/src/gui/windows/quitdialog.cpp
+++ b/src/gui/windows/quitdialog.cpp
@@ -32,6 +32,7 @@
#include "input/inputaction.h"
+#include "gui/dialogsmanager.h"
#include "gui/viewport.h"
#include "gui/widgets/containerplacer.h"
@@ -165,7 +166,7 @@ void QuitDialog::action(const ActionEvent &event)
}
else if (mLogoutQuit->isSelected())
{
- Game::closeDialogs();
+ DialogsManager::closeDialogs();
client->setState(STATE_EXIT);
}
else if (mRate && mRate->isSelected())
@@ -179,14 +180,14 @@ void QuitDialog::action(const ActionEvent &event)
}
else
{
- Game::closeDialogs();
+ DialogsManager::closeDialogs();
client->setState(STATE_EXIT);
}
}
else if (Net::getGameHandler()->isConnected()
&& mSwitchAccountServer->isSelected())
{
- Game::closeDialogs();
+ DialogsManager::closeDialogs();
client->setState(STATE_SWITCH_SERVER);
}
else if (mSwitchCharacter->isSelected())
@@ -194,7 +195,7 @@ void QuitDialog::action(const ActionEvent &event)
if (client->getState() == STATE_GAME)
{
Net::getCharServerHandler()->switchCharacter();
- Game::closeDialogs();
+ DialogsManager::closeDialogs();
serverConfig.write();
}
}
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index 49b2e986f..3248a3920 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -59,6 +59,8 @@
#include "debug.h"
+UpdaterWindow *updaterWindow = nullptr;
+
const std::string xmlUpdateFile("resources.xml");
const std::string txtUpdateFile("resources2.txt");
const std::string updateServer2
diff --git a/src/listeners/playerdeathlistener.h b/src/listeners/playerdeathlistener.h
index 3c4129e07..553898d1c 100644
--- a/src/listeners/playerdeathlistener.h
+++ b/src/listeners/playerdeathlistener.h
@@ -23,10 +23,9 @@
#ifndef LISTENERS_PLAYERDEATHLISTENER_H
#define LISTENERS_PLAYERDEATHLISTENER_H
-#include "game.h"
-
#include "being/localplayer.h"
+#include "gui/dialogsmanager.h"
#include "gui/viewport.h"
#include "gui/windows/okdialog.h"
@@ -50,7 +49,7 @@ struct PlayerDeathListener final : public ActionListener
Net::getPlayerHandler()->respawn();
deathNotice = nullptr;
- Game::closeDialogs();
+ DialogsManager::closeDialogs();
if (viewport)
viewport->closePopupMenu();