Esc button exits all non-modal GUI windows

deque
Digmaster 11 years ago
parent 7697b9e868
commit e3e51324a4

@ -234,14 +234,19 @@ namespace MWBase
virtual void addVisitedLocation(const std::string& name, int x, int y) = 0; virtual void addVisitedLocation(const std::string& name, int x, int y) = 0;
/// Hides dialog and schedules dialog to be deleted.
virtual void removeDialog(OEngine::GUI::Layout* dialog) = 0; virtual void removeDialog(OEngine::GUI::Layout* dialog) = 0;
///< Hides dialog and schedules dialog to be deleted.
///Gracefully attempts to exit the topmost GUI mode
/** No guarentee of actually closing the window **/
virtual void exitCurrentGuiMode() = 0;
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) = 0; virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible) = 0;
virtual void staticMessageBox(const std::string& message) = 0; virtual void staticMessageBox(const std::string& message) = 0;
virtual void removeStaticMessageBox() = 0; virtual void removeStaticMessageBox() = 0;
/// returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
virtual int readPressedButton() = 0; virtual int readPressedButton() = 0;
///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
virtual void onFrame (float frameDuration) = 0; virtual void onFrame (float frameDuration) = 0;

@ -66,10 +66,7 @@ namespace MWGui
void AlchemyWindow::onCancelButtonClicked(MyGUI::Widget* _sender) void AlchemyWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {
mAlchemy.clear(); exit();
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Alchemy);
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Inventory);
} }
void AlchemyWindow::onCreateButtonClicked(MyGUI::Widget* _sender) void AlchemyWindow::onCreateButtonClicked(MyGUI::Widget* _sender)
@ -159,6 +156,12 @@ 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);

@ -19,6 +19,7 @@ namespace MWGui
AlchemyWindow(); AlchemyWindow();
virtual void open(); virtual void open();
virtual void exit();
private: private:
ItemView* mItemView; ItemView* mItemView;

@ -114,6 +114,14 @@ namespace MWGui
setTakeButtonShow(true); setTakeButtonShow(true);
} }
void BookWindow::exit()
{
// no 3d sounds because the object could be in a container.
MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0);
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Book);
}
void BookWindow::setTakeButtonShow(bool show) void BookWindow::setTakeButtonShow(bool show)
{ {
mTakeButtonShow = show; mTakeButtonShow = show;
@ -128,10 +136,7 @@ namespace MWGui
void BookWindow::onCloseButtonClicked (MyGUI::Widget* sender) void BookWindow::onCloseButtonClicked (MyGUI::Widget* sender)
{ {
// no 3d sounds because the object could be in a container. exit();
MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0);
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Book);
} }
void BookWindow::onTakeButtonClicked (MyGUI::Widget* sender) void BookWindow::onTakeButtonClicked (MyGUI::Widget* sender)

@ -14,6 +14,8 @@ namespace MWGui
public: public:
BookWindow(); BookWindow();
virtual void exit();
void open(MWWorld::Ptr book); void open(MWWorld::Ptr book);
void setTakeButtonShow(bool show); void setTakeButtonShow(bool show);
void nextPage(); void nextPage();

@ -118,6 +118,11 @@ void CompanionWindow::updateEncumbranceBar()
} }
void CompanionWindow::onCloseButtonClicked(MyGUI::Widget* _sender) void CompanionWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
{
exit();
}
void CompanionWindow::exit()
{ {
if (mPtr.getTypeName() == typeid(ESM::NPC).name() && mPtr.getClass().getNpcStats(mPtr).getProfit() < 0) if (mPtr.getTypeName() == typeid(ESM::NPC).name() && mPtr.getClass().getNpcStats(mPtr).getProfit() < 0)
{ {

@ -18,6 +18,8 @@ namespace MWGui
public: public:
CompanionWindow(DragAndDrop* dragAndDrop, MessageBoxManager* manager); CompanionWindow(DragAndDrop* dragAndDrop, MessageBoxManager* manager);
virtual void exit();
void open(const MWWorld::Ptr& npc); void open(const MWWorld::Ptr& npc);
void onFrame (); void onFrame ();

@ -143,6 +143,11 @@ 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);

@ -21,86 +21,83 @@
namespace MWGui namespace MWGui
{ {
class Console : public WindowBase, private Compiler::ErrorHandler, public ReferenceInterface class Console : public WindowBase, private Compiler::ErrorHandler, public ReferenceInterface
{ {
private: public:
/// Set the implicit object for script execution
void setSelectedObject(const MWWorld::Ptr& object);
Compiler::Extensions mExtensions; MyGUI::EditBox* mCommandLine;
MWScript::CompilerContext mCompilerContext; MyGUI::EditBox* mHistory;
std::vector<std::string> mNames;
bool mConsoleOnlyScripts;
bool compile (const std::string& cmd, Compiler::Output& output); typedef std::list<std::string> StringList;
/// Report error to the user. // History of previous entered commands
virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type); StringList mCommandHistory;
StringList::iterator mCurrent;
std::string mEditString;
/// Report a file related error Console(int w, int h, bool consoleOnlyScripts);
virtual void report (const std::string& message, Type type);
void listNames(); virtual void open();
///< Write all valid identifiers and keywords into mNames and sort them. virtual void close();
/// \note If mNames is not empty, this function is a no-op.
/// \note The list may contain duplicates (if a name is a keyword and an identifier at the same
/// time).
public: virtual void exit();
void setSelectedObject(const MWWorld::Ptr& object); void setFont(const std::string &fntName);
///< Set the implicit object for script execution
protected: void onResChange(int width, int height);
virtual void onReferenceUnavailable(); void clearHistory();
// Print a message to the console. Messages may contain color
// code, eg. "#FFFFFF this is white".
void print(const std::string &msg);
public: // These are pre-colored versions that you should use.
MyGUI::EditBox* mCommandLine;
MyGUI::EditBox* mHistory;
typedef std::list<std::string> StringList; /// Output from successful console command
void printOK(const std::string &msg);
// History of previous entered commands /// Error message
StringList mCommandHistory; void printError(const std::string &msg);
StringList::iterator mCurrent;
std::string mEditString;
Console(int w, int h, bool consoleOnlyScripts); void execute (const std::string& command);
virtual void open(); void executeFile (const std::string& path);
virtual void close();
void setFont(const std::string &fntName); protected:
void onResChange(int width, int height); virtual void onReferenceUnavailable();
void clearHistory(); private:
// Print a message to the console. Messages may contain color void keyPress(MyGUI::Widget* _sender,
// code, eg. "#FFFFFF this is white". MyGUI::KeyCode key,
void print(const std::string &msg); MyGUI::Char _char);
// These are pre-colored versions that you should use. void acceptCommand(MyGUI::EditBox* _sender);
/// Output from successful console command std::string complete( std::string input, std::vector<std::string> &matches );
void printOK(const std::string &msg);
/// Error message Compiler::Extensions mExtensions;
void printError(const std::string &msg); MWScript::CompilerContext mCompilerContext;
std::vector<std::string> mNames;
bool mConsoleOnlyScripts;
void execute (const std::string& command); bool compile (const std::string& cmd, Compiler::Output& output);
void executeFile (const std::string& path); /// Report error to the user.
virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type);
private: /// Report a file related error
virtual void report (const std::string& message, Type type);
void keyPress(MyGUI::Widget* _sender, /// Write all valid identifiers and keywords into mNames and sort them.
MyGUI::KeyCode key, /// \note If mNames is not empty, this function is a no-op.
MyGUI::Char _char); /// \note The list may contain duplicates (if a name is a keyword and an identifier at the same
/// time).
void acceptCommand(MyGUI::EditBox* _sender); void listNames();
std::string complete( std::string input, std::vector<std::string> &matches );
}; };
} }
#endif #endif

@ -263,7 +263,7 @@ namespace MWGui
} }
} }
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender) void ContainerWindow::exit()
{ {
if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop) if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop)
{ {
@ -271,6 +271,11 @@ namespace MWGui
} }
} }
void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
{
exit();
}
void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender) void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender)
{ {
if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop) if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop)

@ -54,6 +54,8 @@ namespace MWGui
void open(const MWWorld::Ptr& container, bool loot=false); void open(const MWWorld::Ptr& container, bool loot=false);
virtual void close(); virtual void close();
virtual void exit();
private: private:
DragAndDrop* mDragAndDrop; DragAndDrop* mDragAndDrop;

@ -264,6 +264,13 @@ namespace MWGui
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize); static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
} }
void DialogueWindow::exit()
{
if (!mEnabled || MWBase::Environment::get().getDialogueManager()->isInChoice())
return;
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
}
void DialogueWindow::onWindowResize(MyGUI::Window* _sender) void DialogueWindow::onWindowResize(MyGUI::Window* _sender)
{ {
mTopicsList->adjustSize(); mTopicsList->adjustSize();
@ -281,9 +288,7 @@ namespace MWGui
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
{ {
if (!mEnabled || MWBase::Environment::get().getDialogueManager()->isInChoice()) exit();
return;
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
} }
void DialogueWindow::onSelectTopic(const std::string& topic, int id) void DialogueWindow::onSelectTopic(const std::string& topic, int id)

@ -103,6 +103,8 @@ namespace MWGui
public: public:
DialogueWindow(); DialogueWindow();
virtual void exit();
// Events // Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;

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

@ -19,6 +19,9 @@ namespace MWGui
virtual ~EnchantingDialog(); virtual ~EnchantingDialog();
virtual void open(); virtual void open();
virtual void exit();
void startEnchanting(MWWorld::Ptr actor); void startEnchanting(MWWorld::Ptr actor);
void startSelfEnchanting(MWWorld::Ptr soulgem); void startSelfEnchanting(MWWorld::Ptr soulgem);

@ -110,6 +110,11 @@ void MerchantRepair::open()
center(); center();
} }
void MerchantRepair::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_MerchantRepair);
}
void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender) void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender)
{ {
// repair // repair
@ -128,7 +133,7 @@ void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender)
void MerchantRepair::onOkButtonClick(MyGUI::Widget *sender) void MerchantRepair::onOkButtonClick(MyGUI::Widget *sender)
{ {
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_MerchantRepair); exit();
} }
} }

@ -16,6 +16,8 @@ public:
virtual void open(); virtual void open();
virtual void exit();
void startRepair(const MWWorld::Ptr& actor); void startRepair(const MWWorld::Ptr& actor);
private: private:

@ -57,6 +57,11 @@ namespace MWGui
} }
} }
void QuickKeysMenu::exit()
{
mAssignDialog->setVisible (false);
}
void QuickKeysMenu::clear() void QuickKeysMenu::clear()
{ {
for (int i=0; i<10; ++i) for (int i=0; i<10; ++i)
@ -146,7 +151,7 @@ namespace MWGui
void QuickKeysMenu::onCancelButtonClicked(MyGUI::Widget* sender) void QuickKeysMenu::onCancelButtonClicked(MyGUI::Widget* sender)
{ {
mAssignDialog->setVisible (false); exit();
} }
void QuickKeysMenu::onAssignItem(MWWorld::Ptr item) void QuickKeysMenu::onAssignItem(MWWorld::Ptr item)

@ -18,6 +18,7 @@ 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);

@ -38,6 +38,11 @@ void Recharge::open()
center(); center();
} }
void Recharge::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Recharge);
}
void Recharge::start (const MWWorld::Ptr &item) void Recharge::start (const MWWorld::Ptr &item)
{ {
std::string path = std::string("icons\\"); std::string path = std::string("icons\\");
@ -128,7 +133,7 @@ void Recharge::updateView()
void Recharge::onCancel(MyGUI::Widget *sender) void Recharge::onCancel(MyGUI::Widget *sender)
{ {
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Recharge); exit();
} }
void Recharge::onItemClicked(MyGUI::Widget *sender) void Recharge::onItemClicked(MyGUI::Widget *sender)

@ -15,6 +15,8 @@ public:
virtual void open(); virtual void open();
virtual void exit();
void start (const MWWorld::Ptr& gem); void start (const MWWorld::Ptr& gem);
protected: protected:

@ -35,6 +35,11 @@ void Repair::open()
center(); center();
} }
void Repair::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Repair);
}
void Repair::startRepairItem(const MWWorld::Ptr &item) void Repair::startRepairItem(const MWWorld::Ptr &item)
{ {
mRepair.setTool(item); mRepair.setTool(item);
@ -134,7 +139,7 @@ void Repair::updateRepairView()
void Repair::onCancel(MyGUI::Widget *sender) void Repair::onCancel(MyGUI::Widget *sender)
{ {
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Repair); exit();
} }
void Repair::onRepairItem(MyGUI::Widget *sender) void Repair::onRepairItem(MyGUI::Widget *sender)

@ -15,6 +15,8 @@ public:
virtual void open(); virtual void open();
virtual void exit();
void startRepairItem (const MWWorld::Ptr& item); void startRepairItem (const MWWorld::Ptr& item);
protected: protected:

@ -67,6 +67,13 @@ namespace MWGui
setTakeButtonShow(true); setTakeButtonShow(true);
} }
void ScrollWindow::exit()
{
MWBase::Environment::get().getSoundManager()->playSound ("scroll", 1.0, 1.0);
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Scroll);
}
void ScrollWindow::setTakeButtonShow(bool show) void ScrollWindow::setTakeButtonShow(bool show)
{ {
mTakeButtonShow = show; mTakeButtonShow = show;
@ -81,9 +88,7 @@ namespace MWGui
void ScrollWindow::onCloseButtonClicked (MyGUI::Widget* _sender) void ScrollWindow::onCloseButtonClicked (MyGUI::Widget* _sender)
{ {
MWBase::Environment::get().getSoundManager()->playSound ("scroll", 1.0, 1.0); exit();
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Scroll);
} }
void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender) void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender)

@ -14,6 +14,7 @@ namespace MWGui
ScrollWindow (); ScrollWindow ();
void open (MWWorld::Ptr scroll); void open (MWWorld::Ptr scroll);
virtual void exit();
void setTakeButtonShow(bool show); void setTakeButtonShow(bool show);
void setInventoryAllowed(bool allowed); void setInventoryAllowed(bool allowed);

@ -242,7 +242,7 @@ namespace MWGui
void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender) void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender)
{ {
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Settings); exit();
} }
void SettingsWindow::onResolutionSelected(MyGUI::ListBox* _sender, size_t index) void SettingsWindow::onResolutionSelected(MyGUI::ListBox* _sender, size_t index)
@ -510,4 +510,9 @@ namespace MWGui
{ {
updateControlsBox (); updateControlsBox ();
} }
void SettingsWindow::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Settings);
}
} }

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

@ -33,6 +33,11 @@ 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);
}
void SpellBuyingWindow::addSpell(const std::string& spellId) void SpellBuyingWindow::addSpell(const std::string& spellId)
{ {
const MWWorld::ESMStore &store = const MWWorld::ESMStore &store =
@ -132,7 +137,7 @@ namespace MWGui
void SpellBuyingWindow::onCancelButtonClicked(MyGUI::Widget* _sender) void SpellBuyingWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_SpellBuying); exit();
} }
void SpellBuyingWindow::updateLabels() void SpellBuyingWindow::updateLabels()

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

@ -136,6 +136,13 @@ namespace MWGui
return mPtr.getClass().getServices(mPtr); return mPtr.getClass().getServices(mPtr);
} }
void TradeWindow::exit()
{
mTradeModel->abort();
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel()->abort();
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Barter);
}
void TradeWindow::onItemSelected (int index) void TradeWindow::onItemSelected (int index)
{ {
const ItemStack& item = mSortModel->getItem(index); const ItemStack& item = mSortModel->getItem(index);
@ -375,9 +382,7 @@ namespace MWGui
void TradeWindow::onCancelButtonClicked(MyGUI::Widget* _sender) void TradeWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {
mTradeModel->abort(); exit();
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel()->abort();
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Barter);
} }
void TradeWindow::onMaxSaleButtonClicked(MyGUI::Widget* _sender) void TradeWindow::onMaxSaleButtonClicked(MyGUI::Widget* _sender)

@ -35,6 +35,8 @@ namespace MWGui
int getMerchantServices(); int getMerchantServices();
virtual void exit();
private: private:
ItemView* mItemView; ItemView* mItemView;

@ -35,6 +35,11 @@ namespace MWGui
center(); center();
} }
void TrainingWindow::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Training);
}
void TrainingWindow::startTraining (MWWorld::Ptr actor) void TrainingWindow::startTraining (MWWorld::Ptr actor)
{ {
mPtr = actor; mPtr = actor;
@ -107,7 +112,7 @@ namespace MWGui
void TrainingWindow::onCancelButtonClicked (MyGUI::Widget *sender) void TrainingWindow::onCancelButtonClicked (MyGUI::Widget *sender)
{ {
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Training); exit();
} }
void TrainingWindow::onTrainingSelected (MyGUI::Widget *sender) void TrainingWindow::onTrainingSelected (MyGUI::Widget *sender)

@ -14,6 +14,8 @@ namespace MWGui
virtual void open(); virtual void open();
virtual void exit();
void startTraining(MWWorld::Ptr actor); void startTraining(MWWorld::Ptr actor);
void onFrame(float dt); void onFrame(float dt);

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

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

@ -69,6 +69,11 @@ namespace MWGui
mProgressBar.setVisible (false); mProgressBar.setVisible (false);
} }
void WaitDialog::exit()
{
MWBase::Environment::get().getWindowManager()->popGuiMode();
}
void WaitDialog::open() void WaitDialog::open()
{ {
if (!MWBase::Environment::get().getWindowManager ()->getRestEnabled ()) if (!MWBase::Environment::get().getWindowManager ()->getRestEnabled ())
@ -160,7 +165,7 @@ namespace MWGui
void WaitDialog::onCancelButtonClicked(MyGUI::Widget* sender) void WaitDialog::onCancelButtonClicked(MyGUI::Widget* sender)
{ {
MWBase::Environment::get().getWindowManager()->popGuiMode (); exit();
} }
void WaitDialog::onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position) void WaitDialog::onHourSliderChangedPosition(MyGUI::ScrollBar* sender, size_t position)

@ -28,6 +28,8 @@ namespace MWGui
virtual void open(); virtual void open();
virtual void exit();
void onFrame(float dt); void onFrame(float dt);
void bedActivated() { setCanRest(true); } void bedActivated() { setCanRest(true); }

@ -21,8 +21,13 @@ namespace MWGui
// Events // Events
typedef MyGUI::delegates::CMultiDelegate1<WindowBase*> EventHandle_WindowBase; typedef MyGUI::delegates::CMultiDelegate1<WindowBase*> EventHandle_WindowBase;
///Unhides the window
virtual void open() {} virtual void open() {}
///Hides the window
virtual void close () {} virtual void close () {}
///Gracefully exits the window
virtual void exit() {}
///Sets the visibility of the window
virtual void setVisible(bool visible); virtual void setVisible(bool visible);
void center(); void center();

@ -23,6 +23,8 @@
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "../mwsound/soundmanagerimp.hpp"
#include "console.hpp" #include "console.hpp"
#include "journalwindow.hpp" #include "journalwindow.hpp"
#include "journalviewmodel.hpp" #include "journalviewmodel.hpp"
@ -666,6 +668,96 @@ namespace MWGui
mGarbageDialogs.push_back(dialog); mGarbageDialogs.push_back(dialog);
} }
void WindowManager::exitCurrentGuiMode() {
switch(mGuiModes.back()) {
case GM_QuickKeysMenu:
mQuickKeysMenu->exit();
break;
case GM_MainMenu:
removeGuiMode(GM_MainMenu); //Simple way to remove it
break;
case GM_Settings:
mSettingsWindow->exit();
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_Levelup:
mLevelupDialog->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:
MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0);
removeGuiMode(GM_Journal); //Simple way to remove it
break;
default:
// Unsupported mode, switch back to game
break;
}
}
void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons, enum MWGui::ShowInDialogueMode showInDialogueMode) void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons, enum MWGui::ShowInDialogueMode showInDialogueMode)
{ {
if (buttons.empty()) { if (buttons.empty()) {

@ -132,10 +132,10 @@ namespace MWGui
virtual void forceHide(MWGui::GuiWindow wnd); virtual void forceHide(MWGui::GuiWindow wnd);
virtual void unsetForceHide(MWGui::GuiWindow wnd); virtual void unsetForceHide(MWGui::GuiWindow wnd);
// Disallow all inventory mode windows /// Disallow all inventory mode windows
virtual void disallowAll(); virtual void disallowAll();
// Allow one or more windows /// Allow one or more windows
virtual void allow(GuiWindow wnd); virtual void allow(GuiWindow wnd);
virtual bool isAllowed(GuiWindow wnd) const; virtual bool isAllowed(GuiWindow wnd) const;
@ -225,7 +225,11 @@ namespace MWGui
virtual void addVisitedLocation(const std::string& name, int x, int y); virtual void addVisitedLocation(const std::string& name, int x, int y);
virtual void removeDialog(OEngine::GUI::Layout* dialog); ///< Hides dialog and schedules dialog to be deleted. ///Hides dialog and schedules dialog to be deleted.
virtual void removeDialog(OEngine::GUI::Layout* dialog);
///Gracefully attempts to exit the topmost GUI mode
virtual void exitCurrentGuiMode();
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible); virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons = std::vector<std::string>(), enum MWGui::ShowInDialogueMode showInDialogueMode = MWGui::ShowInDialogueMode_IfPossible);
virtual void staticMessageBox(const std::string& message); virtual void staticMessageBox(const std::string& message);

@ -28,6 +28,8 @@
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include "../mwdialogue/dialoguemanagerimp.hpp"
using namespace ICS; using namespace ICS;
namespace namespace
@ -633,19 +635,20 @@ namespace MWInput
void InputManager::toggleMainMenu() void InputManager::toggleMainMenu()
{ {
if (MyGUI::InputManager::getInstance ().isModalAny()) // TODO: Find a way to send an exit command to current Modal Widget
if (MyGUI::InputManager::getInstance().isModalAny())
return; return;
if (MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_MainMenu)) if(!MWBase::Environment::get().getWindowManager()->isGuiMode()) //No open GUIs, open up the MainMenu
{
MWBase::Environment::get().getWindowManager()->popGuiMode();
MWBase::Environment::get().getSoundManager()->resumeSounds (MWBase::SoundManager::Play_TypeSfx);
}
else
{ {
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu); MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
MWBase::Environment::get().getSoundManager()->pauseSounds (MWBase::SoundManager::Play_TypeSfx); MWBase::Environment::get().getSoundManager()->pauseSounds (MWBase::SoundManager::Play_TypeSfx);
} }
else //Close current GUI
{
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
MWBase::Environment::get().getSoundManager()->resumeSounds (MWBase::SoundManager::Play_TypeSfx);
}
} }
void InputManager::quickLoad() { void InputManager::quickLoad() {
@ -761,8 +764,7 @@ namespace MWInput
} }
else if(MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Journal) else if(MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Journal)
{ {
MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0); MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
MWBase::Environment::get().getWindowManager()->popGuiMode();
} }
// .. but don't touch any other mode. // .. but don't touch any other mode.
} }

Loading…
Cancel
Save