Added support to close modal windows with Esc

deque
Digmaster 11 years ago
parent e0d55116a4
commit e0356cf89d

@ -57,6 +57,7 @@ namespace MWGui
class InventoryWindow;
class ContainerWindow;
class DialogueWindow;
class WindowModal;
enum ShowInDialogueMode {
ShowInDialogueMode_IfPossible,
@ -314,6 +315,14 @@ namespace MWBase
/// Does the current stack of GUI-windows permit saving?
virtual bool isSavingAllowed() const = 0;
/// Returns the current Modal
/** Used to send exit command to active Modal when Esc is pressed **/
virtual MWGui::WindowModal* getCurrentModal() const = 0;
/// Sets the current Modal
/** Used to send exit command to active Modal when Esc is pressed **/
virtual void setCurrentModal(MWGui::WindowModal* input) = 0;
};
}

@ -28,13 +28,18 @@ namespace MWGui
center();
}
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
void ConfirmationDialog::exit()
{
eventCancelClicked();
setVisible(false);
}
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
{
exit();
}
void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender)
{
eventOkClicked();

@ -10,6 +10,7 @@ namespace MWGui
public:
ConfirmationDialog();
void open(const std::string& message);
virtual void exit();
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;

@ -51,7 +51,7 @@ namespace MWGui
void PersuasionDialog::onCancel(MyGUI::Widget *sender)
{
setVisible(false);
exit();
}
void PersuasionDialog::onPersuade(MyGUI::Widget *sender)
@ -87,6 +87,11 @@ namespace MWGui
mGoldLabel->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold));
}
void PersuasionDialog::exit()
{
setVisible(false);
}
// --------------------------------------------------------------------------------------------------
Response::Response(const std::string &text, const std::string &title)

@ -34,6 +34,7 @@ namespace MWGui
PersuasionDialog();
virtual void open();
virtual void exit();
private:
MyGUI::Button* mCancelButton;

@ -159,6 +159,11 @@ namespace MWGui
}
void SaveGameDialog::exit()
{
setVisible(false);
}
void SaveGameDialog::setLoadOrSave(bool load)
{
mSaving = !load;
@ -177,7 +182,7 @@ namespace MWGui
void SaveGameDialog::onCancelButtonClicked(MyGUI::Widget *sender)
{
setVisible(false);
exit();
}
void SaveGameDialog::onConfirmationGiven()

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

@ -75,6 +75,15 @@ namespace MWGui
center();
}
void EditEffectDialog::exit()
{
setVisible(false);
if(mEditing)
eventEffectModified(mOldEffect);
else
eventEffectRemoved(mEffect);
}
void EditEffectDialog::newEffect (const ESM::MagicEffect *effect)
{
setMagicEffect(effect);
@ -222,11 +231,7 @@ namespace MWGui
void EditEffectDialog::onCancelButtonClicked (MyGUI::Widget* sender)
{
setVisible(false);
if(mEditing)
eventEffectModified(mOldEffect);
else
eventEffectRemoved(mEffect);
exit();
}
void EditEffectDialog::setSkill (int skill)
@ -313,7 +318,7 @@ namespace MWGui
void SpellCreationDialog::onCancelButtonClicked (MyGUI::Widget* sender)
{
MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_SpellCreation);
exit();
}
void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender)
@ -367,6 +372,11 @@ namespace MWGui
center();
}
void SpellCreationDialog::exit()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_SpellCreation);
}
void SpellCreationDialog::onReferenceUnavailable ()
{
MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Dialogue);

@ -18,6 +18,7 @@ namespace MWGui
EditEffectDialog();
virtual void open();
virtual void exit();
void setSkill(int skill);
void setAttribute(int attribute);
@ -127,6 +128,7 @@ namespace MWGui
SpellCreationDialog();
virtual void open();
virtual void exit();
void startSpellMaking(MWWorld::Ptr actor);

@ -2,6 +2,8 @@
#include "../mwbase/windowmanager.hpp"
#include "container.hpp"
#include "../mwbase/environment.hpp"
#include "../mwgui/windowmanagerimp.hpp"
using namespace MWGui;
@ -45,11 +47,18 @@ WindowModal::WindowModal(const std::string& parLayout)
void WindowModal::open()
{
MyGUI::InputManager::getInstance ().addWidgetModal (mMainWidget);
MWBase::Environment::get().getWindowManager()->setCurrentModal(this); //Set so we can escape it if needed
}
void WindowModal::close()
{
MyGUI::InputManager::getInstance ().removeWidgetModal (mMainWidget);
MWBase::Environment::get().getWindowManager()->setCurrentModal(NULL);
}
void WindowModal::exit()
{
close();
}
NoDrop::NoDrop(DragAndDrop *drag, MyGUI::Widget *widget)

@ -47,6 +47,7 @@ namespace MWGui
WindowModal(const std::string& parLayout);
virtual void open();
virtual void close();
virtual void exit();
};
/// A window that cannot be the target of a drag&drop action.

@ -136,6 +136,7 @@ namespace MWGui
, mFPS(0.0f)
, mTriangleCount(0)
, mBatchCount(0)
, currentModal(NULL)
{
// Set up the GUI system
mGuiManager = new OEngine::GUI::MyGUIManager(mRendering->getWindow(), mRendering->getScene(), false, logpath);

@ -82,6 +82,7 @@ namespace MWGui
class Recharge;
class CompanionWindow;
class VideoWidget;
class WindowModal;
class WindowManager : public MWBase::WindowManager
{
@ -302,6 +303,14 @@ namespace MWGui
/// Does the current stack of GUI-windows permit saving?
virtual bool isSavingAllowed() const;
/// Returns the current Modal
/** Used to send exit command to active Modal when Esc is pressed **/
virtual WindowModal* getCurrentModal() const {return currentModal;}
/// Sets the current Modal
/** Used to send exit command to active Modal when Esc is pressed **/
virtual void setCurrentModal(WindowModal* input) {currentModal = input;}
private:
bool mConsoleOnlyScripts;
@ -311,6 +320,8 @@ namespace MWGui
std::string mSelectedSpell;
WindowModal* currentModal;
OEngine::GUI::MyGUIManager *mGuiManager;
OEngine::Render::OgreRenderer *mRendering;
HUD *mHud;

@ -30,6 +30,8 @@
#include "../mwdialogue/dialoguemanagerimp.hpp"
#include "../mwgui/windowbase.hpp"
using namespace ICS;
namespace
@ -635,9 +637,10 @@ namespace MWInput
void InputManager::toggleMainMenu()
{
// TODO: Find a way to send an exit command to current Modal Widget
if (MyGUI::InputManager::getInstance().isModalAny())
if (MyGUI::InputManager::getInstance().isModalAny()) {
MWBase::Environment::get().getWindowManager()->getCurrentModal()->exit();
return;
}
if(!MWBase::Environment::get().getWindowManager()->isGuiMode()) //No open GUIs, open up the MainMenu
{

Loading…
Cancel
Save