From 0b7ef18ac3c7fb4e3717f6311d4e21a31ff440d5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 28 May 2014 21:29:43 +0300 Subject: Move dialogs related function into separate file. --- src/gui/dialogsmanager.cpp | 64 +++++++++++++++++++++++++++++++++++++++ src/gui/dialogsmanager.h | 34 +++++++++++++++++++++ src/gui/windows/quitdialog.cpp | 9 +++--- src/gui/windows/updaterwindow.cpp | 2 ++ 4 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 src/gui/dialogsmanager.cpp create mode 100644 src/gui/dialogsmanager.h (limited to 'src/gui') 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 . + */ + +#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 . + */ + +#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 -- cgit v1.2.3-70-g09d2