Refactor exitCurrentGuiMode

new-script-api
scrawl 7 years ago
parent 20766fb508
commit 4fff2e2e34

@ -59,7 +59,7 @@ namespace MWGui
void AlchemyWindow::onCancelButtonClicked(MyGUI::Widget* _sender) void AlchemyWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Alchemy);
} }
void AlchemyWindow::onCreateButtonClicked(MyGUI::Widget* _sender) void AlchemyWindow::onCreateButtonClicked(MyGUI::Widget* _sender)
@ -103,6 +103,7 @@ namespace MWGui
void AlchemyWindow::onOpen() void AlchemyWindow::onOpen()
{ {
mAlchemy->clear();
mAlchemy->setAlchemist (MWMechanics::getPlayer()); mAlchemy->setAlchemist (MWMechanics::getPlayer());
InventoryItemModel* model = new InventoryItemModel(MWMechanics::getPlayer()); InventoryItemModel* model = new InventoryItemModel(MWMechanics::getPlayer());
@ -129,12 +130,6 @@ namespace MWGui
update(); update();
} }
void AlchemyWindow::exit() {
mAlchemy->clear();
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Alchemy);
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Inventory);
}
void AlchemyWindow::onIngredientSelected(MyGUI::Widget* _sender) void AlchemyWindow::onIngredientSelected(MyGUI::Widget* _sender)
{ {
removeIngredient(_sender); removeIngredient(_sender);

@ -25,7 +25,6 @@ namespace MWGui
AlchemyWindow(); AlchemyWindow();
virtual void onOpen(); virtual void onOpen();
virtual void exit();
private: private:
std::string mSuggestedPotionName; std::string mSuggestedPotionName;

@ -22,6 +22,8 @@ namespace MWGui
void setNextButtonShow(bool shown); void setNextButtonShow(bool shown);
virtual void onOpen(); virtual void onOpen();
bool exit() { return false; }
// Events // Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;

@ -96,11 +96,6 @@ namespace MWGui
setTakeButtonShow(showTakeButton); setTakeButtonShow(showTakeButton);
} }
void BookWindow::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Book);
}
void BookWindow::setTakeButtonShow(bool show) void BookWindow::setTakeButtonShow(bool show)
{ {
mTakeButtonShow = show; mTakeButtonShow = show;
@ -115,7 +110,7 @@ namespace MWGui
void BookWindow::onCloseButtonClicked (MyGUI::Widget* sender) void BookWindow::onCloseButtonClicked (MyGUI::Widget* sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Book);
} }
void BookWindow::onTakeButtonClicked (MyGUI::Widget* sender) void BookWindow::onTakeButtonClicked (MyGUI::Widget* sender)

@ -14,8 +14,6 @@ namespace MWGui
public: public:
BookWindow(); BookWindow();
virtual void exit();
void setPtr(const MWWorld::Ptr& book); void setPtr(const MWWorld::Ptr& book);
void setInventoryAllowed(bool allowed); void setInventoryAllowed(bool allowed);

@ -730,9 +730,10 @@ namespace MWGui
exit(); exit();
} }
void SelectSpecializationDialog::exit() bool SelectSpecializationDialog::exit()
{ {
eventCancel(); eventCancel();
return true;
} }
/* SelectAttributeDialog */ /* SelectAttributeDialog */
@ -778,9 +779,10 @@ namespace MWGui
exit(); exit();
} }
void SelectAttributeDialog::exit() bool SelectAttributeDialog::exit()
{ {
eventCancel(); eventCancel();
return true;
} }
@ -869,9 +871,10 @@ namespace MWGui
exit(); exit();
} }
void SelectSkillDialog::exit() bool SelectSkillDialog::exit()
{ {
eventCancel(); eventCancel();
return true;
} }
/* DescriptionDialog */ /* DescriptionDialog */

@ -23,6 +23,8 @@ namespace MWGui
virtual void onOpen(); virtual void onOpen();
bool exit() { return false; }
// Events // Events
typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_Int; typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_Int;
@ -67,6 +69,8 @@ namespace MWGui
std::string getClassId() const; std::string getClassId() const;
void setClassId(const std::string &classId); void setClassId(const std::string &classId);
bool exit() { return false; }
// Events // Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
@ -102,6 +106,8 @@ namespace MWGui
void setNextButtonShow(bool shown); void setNextButtonShow(bool shown);
virtual void onOpen(); virtual void onOpen();
bool exit() { return false; }
// Events // Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
@ -142,7 +148,7 @@ namespace MWGui
SelectSpecializationDialog(); SelectSpecializationDialog();
~SelectSpecializationDialog(); ~SelectSpecializationDialog();
virtual void exit(); virtual bool exit();
ESM::Class::Specialization getSpecializationId() const { return mSpecializationId; } ESM::Class::Specialization getSpecializationId() const { return mSpecializationId; }
@ -175,7 +181,7 @@ namespace MWGui
SelectAttributeDialog(); SelectAttributeDialog();
~SelectAttributeDialog(); ~SelectAttributeDialog();
virtual void exit(); virtual bool exit();
ESM::Attribute::AttributeID getAttributeId() const { return mAttributeId; } ESM::Attribute::AttributeID getAttributeId() const { return mAttributeId; }
@ -206,7 +212,7 @@ namespace MWGui
SelectSkillDialog(); SelectSkillDialog();
~SelectSkillDialog(); ~SelectSkillDialog();
virtual void exit(); virtual bool exit();
ESM::Skill::SkillEnum getSkillId() const { return mSkillId; } ESM::Skill::SkillEnum getSkillId() const { return mSkillId; }
@ -262,6 +268,8 @@ namespace MWGui
CreateClassDialog(); CreateClassDialog();
virtual ~CreateClassDialog(); virtual ~CreateClassDialog();
bool exit() { return false; }
std::string getName() const; std::string getName() const;
std::string getDescription() const; std::string getDescription() const;
ESM::Class::Specialization getSpecializationId() const; ESM::Class::Specialization getSpecializationId() const;

@ -139,10 +139,11 @@ void CompanionWindow::updateEncumbranceBar()
void CompanionWindow::onCloseButtonClicked(MyGUI::Widget* _sender) void CompanionWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
{ {
exit(); if (exit())
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Companion);
} }
void CompanionWindow::exit() bool CompanionWindow::exit()
{ {
if (mModel && mModel->hasProfit(mPtr) && getProfit(mPtr) < 0) if (mModel && mModel->hasProfit(mPtr) && getProfit(mPtr) < 0)
{ {
@ -151,9 +152,9 @@ void CompanionWindow::exit()
buttons.push_back("#{sCompanionWarningButtonTwo}"); buttons.push_back("#{sCompanionWarningButtonTwo}");
mMessageBoxManager->createInteractiveMessageBox("#{sCompanionWarningMessage}", buttons); mMessageBoxManager->createInteractiveMessageBox("#{sCompanionWarningMessage}", buttons);
mMessageBoxManager->eventButtonPressed += MyGUI::newDelegate(this, &CompanionWindow::onMessageBoxButtonClicked); mMessageBoxManager->eventButtonPressed += MyGUI::newDelegate(this, &CompanionWindow::onMessageBoxButtonClicked);
return false;
} }
else return true;
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Companion);
} }
void CompanionWindow::onMessageBoxButtonClicked(int button) void CompanionWindow::onMessageBoxButtonClicked(int button)

@ -18,7 +18,7 @@ namespace MWGui
public: public:
CompanionWindow(DragAndDrop* dragAndDrop, MessageBoxManager* manager); CompanionWindow(DragAndDrop* dragAndDrop, MessageBoxManager* manager);
virtual void exit(); virtual bool exit();
virtual void resetReference(); virtual void resetReference();

@ -46,15 +46,16 @@ namespace MWGui
center(); center();
} }
void ConfirmationDialog::exit() bool ConfirmationDialog::exit()
{ {
setVisible(false);
eventCancelClicked(); eventCancelClicked();
return true;
} }
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender) void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {
setVisible(false);
exit(); exit();
} }

@ -11,7 +11,7 @@ namespace MWGui
ConfirmationDialog(); ConfirmationDialog();
void askForConfirmation(const std::string& message); void askForConfirmation(const std::string& message);
void askForConfirmation(const std::string& message, const std::string& confirmMessage, const std::string& cancelMessage); void askForConfirmation(const std::string& message, const std::string& confirmMessage, const std::string& cancelMessage);
virtual void exit(); virtual bool exit();
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;

@ -159,11 +159,6 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(NULL); MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(NULL);
} }
void Console::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Console);
}
void Console::setFont(const std::string &fntName) void Console::setFont(const std::string &fntName)
{ {
mHistory->setFontName(fntName); mHistory->setFontName(fntName);

@ -42,8 +42,6 @@ namespace MWGui
virtual void onOpen(); virtual void onOpen();
virtual void onClose(); virtual void onClose();
virtual void exit();
void setFont(const std::string &fntName); void setFont(const std::string &fntName);
void onResChange(int width, int height); void onResChange(int width, int height);

@ -198,17 +198,9 @@ namespace MWGui
} }
} }
void ContainerWindow::exit()
{
if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop)
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
}
}
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender) void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
} }
void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender) void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender)

@ -38,8 +38,6 @@ namespace MWGui
virtual void resetReference(); virtual void resetReference();
virtual void exit();
private: private:
DragAndDrop* mDragAndDrop; DragAndDrop* mDragAndDrop;

@ -56,19 +56,9 @@ namespace MWGui
mItemEdit->setValue(maxCount); mItemEdit->setValue(maxCount);
} }
void CountDialog::cancel() //Keeping this here as I don't know if anything else relies on it.
{
exit();
}
void CountDialog::exit()
{
setVisible(false);
}
void CountDialog::onCancelButtonClicked(MyGUI::Widget* _sender) void CountDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {
cancel(); setVisible(false);
} }
void CountDialog::onOkButtonClicked(MyGUI::Widget* _sender) void CountDialog::onOkButtonClicked(MyGUI::Widget* _sender)

@ -15,8 +15,6 @@ namespace MWGui
public: public:
CountDialog(); CountDialog();
void openCountDialog(const std::string& item, const std::string& message, const int maxCount); void openCountDialog(const std::string& item, const std::string& message, const int maxCount);
void cancel();
virtual void exit();
typedef MyGUI::delegates::CMultiDelegate2<MyGUI::Widget*, int> EventHandle_WidgetInt; typedef MyGUI::delegates::CMultiDelegate2<MyGUI::Widget*, int> EventHandle_WidgetInt;

@ -52,7 +52,7 @@ namespace MWGui
void PersuasionDialog::onCancel(MyGUI::Widget *sender) void PersuasionDialog::onCancel(MyGUI::Widget *sender)
{ {
exit(); setVisible(false);
} }
void PersuasionDialog::onPersuade(MyGUI::Widget *sender) void PersuasionDialog::onPersuade(MyGUI::Widget *sender)
@ -88,11 +88,6 @@ namespace MWGui
mGoldLabel->setCaptionWithReplacing("#{sGold}: " + MyGUI::utility::toString(playerGold)); mGoldLabel->setCaptionWithReplacing("#{sGold}: " + MyGUI::utility::toString(playerGold));
} }
void PersuasionDialog::exit()
{
setVisible(false);
}
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
Response::Response(const std::string &text, const std::string &title, bool needMargin) Response::Response(const std::string &text, const std::string &title, bool needMargin)
@ -275,18 +270,18 @@ namespace MWGui
mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize); mMainWidget->castType<MyGUI::Window>()->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
} }
void DialogueWindow::exit() bool DialogueWindow::exit()
{ {
if ((!mEnabled || MWBase::Environment::get().getDialogueManager()->isInChoice()) if ((!mEnabled || MWBase::Environment::get().getDialogueManager()->isInChoice())
&& !mGoodbye) && !mGoodbye)
{ {
// in choice, not allowed to escape, but give access to main menu to allow loading other saves return false;
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
} }
else else
{ {
MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
mTopicsList->scrollToTop(); mTopicsList->scrollToTop();
return true;
} }
} }
@ -311,7 +306,8 @@ namespace MWGui
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
{ {
exit(); if (exit())
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Dialogue);
} }
void DialogueWindow::onSelectTopic(const std::string& topic, int id) void DialogueWindow::onSelectTopic(const std::string& topic, int id)

@ -29,7 +29,6 @@ namespace MWGui
PersuasionDialog(); PersuasionDialog();
virtual void onOpen(); virtual void onOpen();
virtual void exit();
private: private:
MyGUI::Button* mCancelButton; MyGUI::Button* mCancelButton;
@ -100,7 +99,7 @@ namespace MWGui
public: public:
DialogueWindow(); DialogueWindow();
virtual void exit(); virtual bool exit();
// Events // Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;

@ -100,11 +100,6 @@ namespace MWGui
} }
} }
void EnchantingDialog::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Enchanting);
}
void EnchantingDialog::updateLabels() void EnchantingDialog::updateLabels()
{ {
std::stringstream enchantCost; std::stringstream enchantCost;
@ -194,7 +189,7 @@ namespace MWGui
void EnchantingDialog::onCancelButtonClicked(MyGUI::Widget* sender) void EnchantingDialog::onCancelButtonClicked(MyGUI::Widget* sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Enchanting);
} }
void EnchantingDialog::onSelectItem(MyGUI::Widget *sender) void EnchantingDialog::onSelectItem(MyGUI::Widget *sender)

@ -21,8 +21,6 @@ namespace MWGui
virtual void onOpen(); virtual void onOpen();
virtual void exit();
void setSoulGem (const MWWorld::Ptr& gem); void setSoulGem (const MWWorld::Ptr& gem);
void setItem (const MWWorld::Ptr& item); void setItem (const MWWorld::Ptr& item);

@ -29,9 +29,10 @@ namespace MWGui
center(); center();
} }
void ItemSelectionDialog::exit() bool ItemSelectionDialog::exit()
{ {
eventDialogCanceled(); eventDialogCanceled();
return true;
} }
void ItemSelectionDialog::openContainer(const MWWorld::Ptr& container) void ItemSelectionDialog::openContainer(const MWWorld::Ptr& container)

@ -21,7 +21,7 @@ namespace MWGui
public: public:
ItemSelectionDialog(const std::string& label); ItemSelectionDialog(const std::string& label);
virtual void exit(); virtual bool exit();
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
typedef MyGUI::delegates::CMultiDelegate1<MWWorld::Ptr> EventHandle_Item; typedef MyGUI::delegates::CMultiDelegate1<MWWorld::Ptr> EventHandle_Item;

@ -14,6 +14,8 @@ namespace MWGui
void onFrame(float dt); void onFrame(float dt);
bool exit() { return false; }
private: private:
int mDays; int mDays;

@ -1114,11 +1114,6 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit); MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);
} }
void EditNoteDialog::exit()
{
setVisible(false);
}
void EditNoteDialog::onCancelButtonClicked(MyGUI::Widget *sender) void EditNoteDialog::onCancelButtonClicked(MyGUI::Widget *sender)
{ {
setVisible(false); setVisible(false);

@ -170,7 +170,6 @@ namespace MWGui
EditNoteDialog(); EditNoteDialog();
virtual void onOpen(); virtual void onOpen();
virtual void exit();
void showDeleteButton(bool show); void showDeleteButton(bool show);
bool getDeleteButtonShown(); bool getDeleteButtonShown();

@ -118,11 +118,6 @@ void MerchantRepair::onOpen()
mList->setViewOffset(MyGUI::IntPoint(0, 0)); mList->setViewOffset(MyGUI::IntPoint(0, 0));
} }
void MerchantRepair::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_MerchantRepair);
}
void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender) void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender)
{ {
MWWorld::Ptr player = MWMechanics::getPlayer(); MWWorld::Ptr player = MWMechanics::getPlayer();
@ -150,7 +145,7 @@ void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender)
void MerchantRepair::onOkButtonClick(MyGUI::Widget *sender) void MerchantRepair::onOkButtonClick(MyGUI::Widget *sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_MerchantRepair);
} }
} }

@ -14,8 +14,6 @@ public:
virtual void onOpen(); virtual void onOpen();
virtual void exit();
void setPtr(const MWWorld::Ptr& actor); void setPtr(const MWWorld::Ptr& actor);
private: private:

@ -64,11 +64,6 @@ namespace MWGui
} }
} }
void QuickKeysMenu::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_QuickKeysMenu);
}
void QuickKeysMenu::clear() void QuickKeysMenu::clear()
{ {
mActivatedIndex = -1; mActivatedIndex = -1;
@ -449,11 +444,6 @@ namespace MWGui
center(); center();
} }
void QuickKeysMenuAssign::exit()
{
setVisible(false);
}
void QuickKeysMenu::write(ESM::ESMWriter &writer) void QuickKeysMenu::write(ESM::ESMWriter &writer)
{ {
writer.startRecord(ESM::REC_KEYS); writer.startRecord(ESM::REC_KEYS);
@ -585,9 +575,10 @@ namespace MWGui
exit(); exit();
} }
void MagicSelectionDialog::exit() bool MagicSelectionDialog::exit()
{ {
mParent->onAssignMagicCancel(); mParent->onAssignMagicCancel();
return true;
} }
void MagicSelectionDialog::onOpen () void MagicSelectionDialog::onOpen ()

@ -22,8 +22,6 @@ namespace MWGui
QuickKeysMenu(); QuickKeysMenu();
~QuickKeysMenu(); ~QuickKeysMenu();
virtual void exit();
void onItemButtonClicked(MyGUI::Widget* sender); void onItemButtonClicked(MyGUI::Widget* sender);
void onMagicButtonClicked(MyGUI::Widget* sender); void onMagicButtonClicked(MyGUI::Widget* sender);
void onUnassignButtonClicked(MyGUI::Widget* sender); void onUnassignButtonClicked(MyGUI::Widget* sender);
@ -77,7 +75,6 @@ namespace MWGui
{ {
public: public:
QuickKeysMenuAssign(QuickKeysMenu* parent); QuickKeysMenuAssign(QuickKeysMenu* parent);
virtual void exit();
private: private:
MyGUI::TextBox* mLabel; MyGUI::TextBox* mLabel;
@ -95,7 +92,7 @@ namespace MWGui
MagicSelectionDialog(QuickKeysMenu* parent); MagicSelectionDialog(QuickKeysMenu* parent);
virtual void onOpen(); virtual void onOpen();
virtual void exit(); virtual bool exit();
private: private:
MyGUI::Button* mCancelButton; MyGUI::Button* mCancelButton;

@ -54,6 +54,8 @@ namespace MWGui
virtual void onOpen(); virtual void onOpen();
virtual void onClose(); virtual void onClose();
bool exit() { return false; }
// Events // Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;

@ -62,11 +62,6 @@ void Recharge::onOpen()
mBox->resetScrollbars(); mBox->resetScrollbars();
} }
void Recharge::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Recharge);
}
void Recharge::setPtr (const MWWorld::Ptr &item) void Recharge::setPtr (const MWWorld::Ptr &item)
{ {
mGemIcon->setItem(item); mGemIcon->setItem(item);
@ -107,7 +102,7 @@ void Recharge::updateView()
void Recharge::onCancel(MyGUI::Widget *sender) void Recharge::onCancel(MyGUI::Widget *sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Recharge);
} }
void Recharge::onSelectItem(MyGUI::Widget *sender) void Recharge::onSelectItem(MyGUI::Widget *sender)

@ -24,8 +24,6 @@ public:
virtual void onOpen(); virtual void onOpen();
virtual void exit();
void setPtr (const MWWorld::Ptr& gem); void setPtr (const MWWorld::Ptr& gem);
protected: protected:

@ -58,11 +58,6 @@ void Repair::onOpen()
mRepairBox->resetScrollbars(); mRepairBox->resetScrollbars();
} }
void Repair::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Repair);
}
void Repair::setPtr(const MWWorld::Ptr &item) void Repair::setPtr(const MWWorld::Ptr &item)
{ {
MWBase::Environment::get().getWindowManager()->playSound("Item Repair Up"); MWBase::Environment::get().getWindowManager()->playSound("Item Repair Up");
@ -145,7 +140,7 @@ void Repair::onItemCancel()
void Repair::onCancel(MyGUI::Widget* /*sender*/) void Repair::onCancel(MyGUI::Widget* /*sender*/)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Repair);
} }
void Repair::onRepairItem(MyGUI::Widget* /*sender*/, const MWWorld::Ptr& ptr) void Repair::onRepairItem(MyGUI::Widget* /*sender*/, const MWWorld::Ptr& ptr)

@ -21,8 +21,6 @@ public:
virtual void onOpen(); virtual void onOpen();
virtual void exit();
void setPtr (const MWWorld::Ptr& item); void setPtr (const MWWorld::Ptr& item);
protected: protected:

@ -31,6 +31,8 @@ namespace MWGui
ReviewDialog(); ReviewDialog();
bool exit() { return false; }
void setPlayerName(const std::string &name); void setPlayerName(const std::string &name);
void setRace(const std::string &raceId); void setRace(const std::string &raceId);
void setClass(const ESM::Class& class_); void setClass(const ESM::Class& class_);

@ -191,11 +191,6 @@ namespace MWGui
} }
void SaveGameDialog::exit()
{
setVisible(false);
}
void SaveGameDialog::setLoadOrSave(bool load) void SaveGameDialog::setLoadOrSave(bool load)
{ {
mSaving = !load; mSaving = !load;
@ -217,7 +212,7 @@ namespace MWGui
void SaveGameDialog::onCancelButtonClicked(MyGUI::Widget *sender) void SaveGameDialog::onCancelButtonClicked(MyGUI::Widget *sender)
{ {
exit(); setVisible(false);
} }
void SaveGameDialog::onDeleteButtonClicked(MyGUI::Widget *sender) void SaveGameDialog::onDeleteButtonClicked(MyGUI::Widget *sender)

@ -19,8 +19,6 @@ namespace MWGui
virtual void onOpen(); virtual void onOpen();
virtual void exit();
void setLoadOrSave(bool load); void setLoadOrSave(bool load);
private: private:

@ -76,11 +76,6 @@ namespace MWGui
setTakeButtonShow(showTakeButton); setTakeButtonShow(showTakeButton);
} }
void ScrollWindow::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Scroll);
}
void ScrollWindow::setTakeButtonShow(bool show) void ScrollWindow::setTakeButtonShow(bool show)
{ {
mTakeButtonShow = show; mTakeButtonShow = show;
@ -95,7 +90,7 @@ namespace MWGui
void ScrollWindow::onCloseButtonClicked (MyGUI::Widget* _sender) void ScrollWindow::onCloseButtonClicked (MyGUI::Widget* _sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Scroll);
} }
void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender) void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender)

@ -18,7 +18,6 @@ namespace MWGui
ScrollWindow (); ScrollWindow ();
void setPtr (const MWWorld::Ptr& scroll); void setPtr (const MWWorld::Ptr& scroll);
virtual void exit();
void setInventoryAllowed(bool allowed); void setInventoryAllowed(bool allowed);
protected: protected:

@ -258,7 +258,7 @@ namespace MWGui
void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender) void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Settings);
} }
void SettingsWindow::onResolutionSelected(MyGUI::ListBox* _sender, size_t index) void SettingsWindow::onResolutionSelected(MyGUI::ListBox* _sender, size_t index)
@ -559,11 +559,6 @@ namespace MWGui
resetScrollbars(); resetScrollbars();
} }
void SettingsWindow::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Settings);
}
void SettingsWindow::onWindowResize(MyGUI::Window *_sender) void SettingsWindow::onWindowResize(MyGUI::Window *_sender)
{ {
layoutControlsBox(); layoutControlsBox();

@ -17,8 +17,6 @@ namespace MWGui
virtual void onOpen(); virtual void onOpen();
virtual void exit();
void updateControlsBox(); void updateControlsBox();
protected: protected:

@ -31,11 +31,6 @@ namespace MWGui
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onCancelButtonClicked); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onCancelButtonClicked);
} }
void SpellBuyingWindow::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_SpellBuying);
}
bool SpellBuyingWindow::sortSpells (const ESM::Spell* left, const ESM::Spell* right) bool SpellBuyingWindow::sortSpells (const ESM::Spell* left, const ESM::Spell* right)
{ {
std::string leftName = Misc::StringUtils::lowerCase(left->mName); std::string leftName = Misc::StringUtils::lowerCase(left->mName);
@ -173,7 +168,7 @@ namespace MWGui
void SpellBuyingWindow::onCancelButtonClicked(MyGUI::Widget* _sender) void SpellBuyingWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_SpellBuying);
} }
void SpellBuyingWindow::updateLabels() void SpellBuyingWindow::updateLabels()

@ -28,8 +28,6 @@ namespace MWGui
void setPtr(const MWWorld::Ptr& actor); void setPtr(const MWWorld::Ptr& actor);
void setPtr(const MWWorld::Ptr& actor, int startOffset); void setPtr(const MWWorld::Ptr& actor, int startOffset);
virtual void exit();
protected: protected:
MyGUI::Button* mCancelButton; MyGUI::Button* mCancelButton;
MyGUI::TextBox* mPlayerGold; MyGUI::TextBox* mPlayerGold;

@ -102,13 +102,13 @@ namespace MWGui
center(); center();
} }
void EditEffectDialog::exit() bool EditEffectDialog::exit()
{ {
setVisible(false);
if(mEditing) if(mEditing)
eventEffectModified(mOldEffect); eventEffectModified(mOldEffect);
else else
eventEffectRemoved(mEffect); eventEffectRemoved(mEffect);
return true;
} }
void EditEffectDialog::newEffect (const ESM::MagicEffect *effect) void EditEffectDialog::newEffect (const ESM::MagicEffect *effect)
@ -275,6 +275,7 @@ namespace MWGui
void EditEffectDialog::onCancelButtonClicked (MyGUI::Widget* sender) void EditEffectDialog::onCancelButtonClicked (MyGUI::Widget* sender)
{ {
setVisible(false);
exit(); exit();
} }
@ -362,7 +363,7 @@ namespace MWGui
void SpellCreationDialog::onCancelButtonClicked (MyGUI::Widget* sender) void SpellCreationDialog::onCancelButtonClicked (MyGUI::Widget* sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_SpellCreation);
} }
void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender) void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender)
@ -420,11 +421,6 @@ namespace MWGui
center(); center();
} }
void SpellCreationDialog::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_SpellCreation);
}
void SpellCreationDialog::onReferenceUnavailable () void SpellCreationDialog::onReferenceUnavailable ()
{ {
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Dialogue); MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Dialogue);

@ -24,7 +24,7 @@ namespace MWGui
EditEffectDialog(); EditEffectDialog();
virtual void onOpen(); virtual void onOpen();
virtual void exit(); virtual bool exit();
void setConstantEffect(bool constant); void setConstantEffect(bool constant);
@ -151,7 +151,6 @@ namespace MWGui
SpellCreationDialog(); SpellCreationDialog();
virtual void onOpen(); virtual void onOpen();
virtual void exit();
void setPtr(const MWWorld::Ptr& actor); void setPtr(const MWWorld::Ptr& actor);

@ -22,6 +22,8 @@ namespace MWGui
void setTextLabel(const std::string &label); void setTextLabel(const std::string &label);
virtual void onOpen(); virtual void onOpen();
bool exit() { return false; }
/** Event : Dialog finished, OK button clicked.\n /** Event : Dialog finished, OK button clicked.\n
signature : void method()\n signature : void method()\n
*/ */

@ -171,11 +171,11 @@ namespace MWGui
return mPtr.getClass().getServices(mPtr); return mPtr.getClass().getServices(mPtr);
} }
void TradeWindow::exit() bool TradeWindow::exit()
{ {
mTradeModel->abort(); mTradeModel->abort();
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel()->abort(); MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel()->abort();
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Barter); return true;
} }
void TradeWindow::onItemSelected (int index) void TradeWindow::onItemSelected (int index)
@ -362,6 +362,7 @@ namespace MWGui
void TradeWindow::onCancelButtonClicked(MyGUI::Widget* _sender) void TradeWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {
exit(); exit();
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Barter);
} }
void TradeWindow::onMaxSaleButtonClicked(MyGUI::Widget* _sender) void TradeWindow::onMaxSaleButtonClicked(MyGUI::Widget* _sender)

@ -34,7 +34,7 @@ namespace MWGui
int getMerchantServices(); int getMerchantServices();
virtual void exit(); virtual bool exit();
virtual void resetReference(); virtual void resetReference();

@ -60,11 +60,6 @@ namespace MWGui
center(); center();
} }
void TrainingWindow::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Training);
}
void TrainingWindow::setPtr (const MWWorld::Ptr& actor) void TrainingWindow::setPtr (const MWWorld::Ptr& actor)
{ {
mPtr = actor; mPtr = actor;
@ -124,7 +119,7 @@ namespace MWGui
void TrainingWindow::onCancelButtonClicked (MyGUI::Widget *sender) void TrainingWindow::onCancelButtonClicked (MyGUI::Widget *sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Training);
} }
void TrainingWindow::onTrainingSelected (MyGUI::Widget *sender) void TrainingWindow::onTrainingSelected (MyGUI::Widget *sender)

@ -16,8 +16,6 @@ namespace MWGui
virtual void onOpen(); virtual void onOpen();
virtual void exit();
void setPtr(const MWWorld::Ptr& actor); void setPtr(const MWWorld::Ptr& actor);
void onFrame(float dt); void onFrame(float dt);

@ -45,11 +45,6 @@ namespace MWGui
mSelect->getHeight()); mSelect->getHeight());
} }
void TravelWindow::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Travel);
}
void TravelWindow::addDestination(const std::string& name,ESM::Position pos,bool interior) void TravelWindow::addDestination(const std::string& name,ESM::Position pos,bool interior)
{ {
int price; int price;
@ -194,7 +189,7 @@ namespace MWGui
void TravelWindow::onCancelButtonClicked(MyGUI::Widget* _sender) void TravelWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {
exit(); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Travel);
} }
void TravelWindow::updateLabels() void TravelWindow::updateLabels()

@ -24,8 +24,6 @@ namespace MWGui
public: public:
TravelWindow(); TravelWindow();
virtual void exit();
void setPtr (const MWWorld::Ptr& actor); void setPtr (const MWWorld::Ptr& actor);
protected: protected:

@ -79,10 +79,9 @@ namespace MWGui
mProgressBar.setVisible (false); mProgressBar.setVisible (false);
} }
void WaitDialog::exit() bool WaitDialog::exit()
{ {
if(!mProgressBar.isVisible()) //Only exit if not currently waiting return (!mProgressBar.isVisible()); //Only exit if not currently waiting
MWBase::Environment::get().getWindowManager()->popGuiMode();
} }
void WaitDialog::onOpen() void WaitDialog::onOpen()

@ -29,7 +29,7 @@ namespace MWGui
virtual void onOpen(); virtual void onOpen();
virtual void exit(); virtual bool exit();
void onFrame(float dt); void onFrame(float dt);

@ -34,7 +34,7 @@ namespace MWGui
/// Notify that window has been hidden /// Notify that window has been hidden
virtual void onClose () {} virtual void onClose () {}
/// Gracefully exits the window /// Gracefully exits the window
virtual void exit() {} virtual bool exit() {return true;}
/// Sets the visibility of the window /// Sets the visibility of the window
virtual void setVisible(bool visible); virtual void setVisible(bool visible);
/// Returns the visibility state of the window /// Returns the visibility state of the window
@ -52,7 +52,7 @@ namespace MWGui
WindowModal(const std::string& parLayout); WindowModal(const std::string& parLayout);
virtual void onOpen(); virtual void onOpen();
virtual void onClose(); virtual void onClose();
virtual void exit() {} virtual bool exit() {return true;}
}; };
/// A window that cannot be the target of a drag&drop action. /// A window that cannot be the target of a drag&drop action.

@ -769,89 +769,19 @@ namespace MWGui
return; return;
} }
switch(mGuiModes.back()) { GuiModeState& state = mGuiModeStates[mGuiModes.back()];
case GM_QuickKeysMenu: for (WindowBase* window : state.mWindows)
mQuickKeysMenu->exit(); {
break; if (!window->exit())
case GM_MainMenu: {
removeGuiMode(GM_MainMenu); //Simple way to remove it // unable to exit window, but give access to main menu
break; if (!MyGUI::InputManager::getInstance().isModalAny())
case GM_Settings: pushGuiMode (MWGui::GM_MainMenu);
mSettingsWindow->exit(); return;
break; }
case GM_Console:
mConsole->exit();
break;
case GM_Scroll:
mScrollWindow->exit();
break;
case GM_Book:
mBookWindow->exit();
break;
case GM_Alchemy:
mAlchemyWindow->exit();
break;
case GM_Rest:
mWaitDialog->exit();
break;
case GM_RestBed:
mWaitDialog->exit();
break;
case GM_Name:
case GM_Race:
case GM_Class:
case GM_ClassPick:
case GM_ClassCreate:
case GM_Birth:
case GM_ClassGenerate:
case GM_Review:
break;
case GM_Inventory:
removeGuiMode(GM_Inventory); //Simple way to remove it
break;
case GM_Container:
mContainerWindow->exit();
break;
case GM_Companion:
mCompanionWindow->exit();
break;
case GM_Dialogue:
mDialogueWindow->exit();
break;
case GM_Barter:
mTradeWindow->exit();
break;
case GM_SpellBuying:
mSpellBuyingWindow->exit();
break;
case GM_Travel:
mTravelWindow->exit();
break;
case GM_SpellCreation:
mSpellCreationDialog->exit();
break;
case GM_Recharge:
mRecharge->exit();
break;
case GM_Enchanting:
mEnchantingDialog->exit();
break;
case GM_Training:
mTrainingWindow->exit();
break;
case GM_MerchantRepair:
mMerchantRepair->exit();
break;
case GM_Repair:
mRepair->exit();
break;
case GM_Journal:
removeGuiMode(GM_Journal); //Simple way to remove it
break;
default:
// Unsupported mode, switch back to game
break;
} }
popGuiMode();
} }
void WindowManager::interactiveMessageBox(const std::string &message, const std::vector<std::string> &buttons, bool block) void WindowManager::interactiveMessageBox(const std::string &message, const std::vector<std::string> &buttons, bool block)
@ -1267,10 +1197,11 @@ namespace MWGui
if (!mGuiModes.empty()) if (!mGuiModes.empty())
{ {
mGuiModeStates[mGuiModes.back()].update(false); const GuiMode mode = mGuiModes.back();
if (!noSound)
playSound(mGuiModeStates[mGuiModes.back()].mCloseSound);
mGuiModes.pop_back(); mGuiModes.pop_back();
mGuiModeStates[mode].update(false);
if (!noSound)
playSound(mGuiModeStates[mode].mCloseSound);
} }
if (!mGuiModes.empty()) if (!mGuiModes.empty())
@ -1849,10 +1780,11 @@ namespace MWGui
void WindowManager::exitCurrentModal() void WindowManager::exitCurrentModal()
{ {
if (!mCurrentModals.empty()) if (!mCurrentModals.empty())
mCurrentModals.top()->exit(); {
if (!mCurrentModals.top()->exit())
if (mCurrentModals.empty()) return;
MyGUI::InputManager::getInstance().setKeyFocusWidget(mSaveKeyFocus); mCurrentModals.top()->setVisible(false);
}
} }
void WindowManager::addCurrentModal(WindowModal *input) void WindowManager::addCurrentModal(WindowModal *input)

Loading…
Cancel
Save