From 4ead5c9f65ffbf1de9b0cb60cae06b116badbced Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 2 Feb 2011 22:15:55 +0200 Subject: Close npc and other dialogs if reconnecting. Also save extra layers if network error. --- src/gui/npcdialog.cpp | 6 ++++-- src/gui/npcdialog.h | 5 +++++ src/gui/quitdialog.cpp | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 3af0594f6..4fe5bf8ab 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -149,7 +149,6 @@ NpcDialog::~NpcDialog() mMinusButton = 0; instances.remove(this); - } void NpcDialog::setText(const std::string &text) @@ -418,7 +417,10 @@ void NpcDialog::closeAll() DialogList::iterator it_end = instances.end(); for (; it != it_end; ++it) - (*it)->close(); + { + if (*it) + (*it)->close(); + } } void NpcDialog::buildLayout() diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index eee4b32e2..c4a567c06 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -171,6 +171,11 @@ class NpcDialog : public Window, public gcn::ActionListener, */ static void closeAll(); + /** + * Closes all instances and destroy also net handler dialogs. + */ + static void destroyAll(); + private: typedef std::list DialogList; static DialogList instances; diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 221a94747..24dc953be 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -24,6 +24,7 @@ #include "client.h" #include "gui/chat.h" +#include "gui/npcdialog.h" #include "gui/sdlinput.h" #include "gui/viewport.h" @@ -34,6 +35,7 @@ #include "net/charhandler.h" #include "net/gamehandler.h" +#include "net/npchandler.h" #include "net/net.h" #include "utils/gettext.h" @@ -137,11 +139,13 @@ void QuitDialog::action(const gcn::ActionEvent &event) } else if (mLogoutQuit->isSelected()) { + Client::closeDialogs(); Client::setState(STATE_EXIT); } else if (Net::getGameHandler()->isConnected() && mSwitchAccountServer->isSelected()) { + Client::closeDialogs(); Client::setState(STATE_SWITCH_SERVER); } else if (mSwitchCharacter->isSelected()) @@ -149,6 +153,7 @@ void QuitDialog::action(const gcn::ActionEvent &event) assert(Client::getState() == STATE_GAME); Net::getCharHandler()->switchCharacter(); + Client::closeDialogs(); } } scheduleDelete(); -- cgit v1.2.3-70-g09d2