forked from mirror/openmw-tes3mp
Added support to close modal windows with Esc
This commit is contained in:
parent
e0d55116a4
commit
e0356cf89d
14 changed files with 76 additions and 11 deletions
|
@ -57,6 +57,7 @@ namespace MWGui
|
||||||
class InventoryWindow;
|
class InventoryWindow;
|
||||||
class ContainerWindow;
|
class ContainerWindow;
|
||||||
class DialogueWindow;
|
class DialogueWindow;
|
||||||
|
class WindowModal;
|
||||||
|
|
||||||
enum ShowInDialogueMode {
|
enum ShowInDialogueMode {
|
||||||
ShowInDialogueMode_IfPossible,
|
ShowInDialogueMode_IfPossible,
|
||||||
|
@ -314,6 +315,14 @@ namespace MWBase
|
||||||
|
|
||||||
/// Does the current stack of GUI-windows permit saving?
|
/// Does the current stack of GUI-windows permit saving?
|
||||||
virtual bool isSavingAllowed() const = 0;
|
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();
|
center();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
|
void ConfirmationDialog::exit()
|
||||||
{
|
{
|
||||||
eventCancelClicked();
|
eventCancelClicked();
|
||||||
|
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||||
|
{
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender)
|
void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventOkClicked();
|
eventOkClicked();
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace MWGui
|
||||||
public:
|
public:
|
||||||
ConfirmationDialog();
|
ConfirmationDialog();
|
||||||
void open(const std::string& message);
|
void open(const std::string& message);
|
||||||
|
virtual void exit();
|
||||||
|
|
||||||
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace MWGui
|
||||||
|
|
||||||
void PersuasionDialog::onCancel(MyGUI::Widget *sender)
|
void PersuasionDialog::onCancel(MyGUI::Widget *sender)
|
||||||
{
|
{
|
||||||
setVisible(false);
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PersuasionDialog::onPersuade(MyGUI::Widget *sender)
|
void PersuasionDialog::onPersuade(MyGUI::Widget *sender)
|
||||||
|
@ -87,6 +87,11 @@ namespace MWGui
|
||||||
mGoldLabel->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold));
|
mGoldLabel->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PersuasionDialog::exit()
|
||||||
|
{
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
Response::Response(const std::string &text, const std::string &title)
|
Response::Response(const std::string &text, const std::string &title)
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace MWGui
|
||||||
PersuasionDialog();
|
PersuasionDialog();
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
virtual void exit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MyGUI::Button* mCancelButton;
|
MyGUI::Button* mCancelButton;
|
||||||
|
|
|
@ -159,6 +159,11 @@ namespace MWGui
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SaveGameDialog::exit()
|
||||||
|
{
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
void SaveGameDialog::setLoadOrSave(bool load)
|
void SaveGameDialog::setLoadOrSave(bool load)
|
||||||
{
|
{
|
||||||
mSaving = !load;
|
mSaving = !load;
|
||||||
|
@ -177,7 +182,7 @@ namespace MWGui
|
||||||
|
|
||||||
void SaveGameDialog::onCancelButtonClicked(MyGUI::Widget *sender)
|
void SaveGameDialog::onCancelButtonClicked(MyGUI::Widget *sender)
|
||||||
{
|
{
|
||||||
setVisible(false);
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveGameDialog::onConfirmationGiven()
|
void SaveGameDialog::onConfirmationGiven()
|
||||||
|
|
|
@ -19,6 +19,8 @@ namespace MWGui
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
|
||||||
|
virtual void exit();
|
||||||
|
|
||||||
void setLoadOrSave(bool load);
|
void setLoadOrSave(bool load);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -75,6 +75,15 @@ namespace MWGui
|
||||||
center();
|
center();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditEffectDialog::exit()
|
||||||
|
{
|
||||||
|
setVisible(false);
|
||||||
|
if(mEditing)
|
||||||
|
eventEffectModified(mOldEffect);
|
||||||
|
else
|
||||||
|
eventEffectRemoved(mEffect);
|
||||||
|
}
|
||||||
|
|
||||||
void EditEffectDialog::newEffect (const ESM::MagicEffect *effect)
|
void EditEffectDialog::newEffect (const ESM::MagicEffect *effect)
|
||||||
{
|
{
|
||||||
setMagicEffect(effect);
|
setMagicEffect(effect);
|
||||||
|
@ -222,11 +231,7 @@ namespace MWGui
|
||||||
|
|
||||||
void EditEffectDialog::onCancelButtonClicked (MyGUI::Widget* sender)
|
void EditEffectDialog::onCancelButtonClicked (MyGUI::Widget* sender)
|
||||||
{
|
{
|
||||||
setVisible(false);
|
exit();
|
||||||
if(mEditing)
|
|
||||||
eventEffectModified(mOldEffect);
|
|
||||||
else
|
|
||||||
eventEffectRemoved(mEffect);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditEffectDialog::setSkill (int skill)
|
void EditEffectDialog::setSkill (int skill)
|
||||||
|
@ -313,7 +318,7 @@ namespace MWGui
|
||||||
|
|
||||||
void SpellCreationDialog::onCancelButtonClicked (MyGUI::Widget* sender)
|
void SpellCreationDialog::onCancelButtonClicked (MyGUI::Widget* sender)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->removeGuiMode (MWGui::GM_SpellCreation);
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender)
|
void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender)
|
||||||
|
@ -367,6 +372,11 @@ 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);
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace MWGui
|
||||||
EditEffectDialog();
|
EditEffectDialog();
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
virtual void exit();
|
||||||
|
|
||||||
void setSkill(int skill);
|
void setSkill(int skill);
|
||||||
void setAttribute(int attribute);
|
void setAttribute(int attribute);
|
||||||
|
@ -127,6 +128,7 @@ namespace MWGui
|
||||||
SpellCreationDialog();
|
SpellCreationDialog();
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
virtual void exit();
|
||||||
|
|
||||||
void startSpellMaking(MWWorld::Ptr actor);
|
void startSpellMaking(MWWorld::Ptr actor);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "container.hpp"
|
#include "container.hpp"
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwgui/windowmanagerimp.hpp"
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
|
@ -45,11 +47,18 @@ WindowModal::WindowModal(const std::string& parLayout)
|
||||||
void WindowModal::open()
|
void WindowModal::open()
|
||||||
{
|
{
|
||||||
MyGUI::InputManager::getInstance ().addWidgetModal (mMainWidget);
|
MyGUI::InputManager::getInstance ().addWidgetModal (mMainWidget);
|
||||||
|
MWBase::Environment::get().getWindowManager()->setCurrentModal(this); //Set so we can escape it if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowModal::close()
|
void WindowModal::close()
|
||||||
{
|
{
|
||||||
MyGUI::InputManager::getInstance ().removeWidgetModal (mMainWidget);
|
MyGUI::InputManager::getInstance ().removeWidgetModal (mMainWidget);
|
||||||
|
MWBase::Environment::get().getWindowManager()->setCurrentModal(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowModal::exit()
|
||||||
|
{
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
NoDrop::NoDrop(DragAndDrop *drag, MyGUI::Widget *widget)
|
NoDrop::NoDrop(DragAndDrop *drag, MyGUI::Widget *widget)
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace MWGui
|
||||||
WindowModal(const std::string& parLayout);
|
WindowModal(const std::string& parLayout);
|
||||||
virtual void open();
|
virtual void open();
|
||||||
virtual void close();
|
virtual void close();
|
||||||
|
virtual void exit();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A window that cannot be the target of a drag&drop action.
|
/// A window that cannot be the target of a drag&drop action.
|
||||||
|
|
|
@ -136,6 +136,7 @@ namespace MWGui
|
||||||
, mFPS(0.0f)
|
, mFPS(0.0f)
|
||||||
, mTriangleCount(0)
|
, mTriangleCount(0)
|
||||||
, mBatchCount(0)
|
, mBatchCount(0)
|
||||||
|
, currentModal(NULL)
|
||||||
{
|
{
|
||||||
// Set up the GUI system
|
// Set up the GUI system
|
||||||
mGuiManager = new OEngine::GUI::MyGUIManager(mRendering->getWindow(), mRendering->getScene(), false, logpath);
|
mGuiManager = new OEngine::GUI::MyGUIManager(mRendering->getWindow(), mRendering->getScene(), false, logpath);
|
||||||
|
|
|
@ -82,6 +82,7 @@ namespace MWGui
|
||||||
class Recharge;
|
class Recharge;
|
||||||
class CompanionWindow;
|
class CompanionWindow;
|
||||||
class VideoWidget;
|
class VideoWidget;
|
||||||
|
class WindowModal;
|
||||||
|
|
||||||
class WindowManager : public MWBase::WindowManager
|
class WindowManager : public MWBase::WindowManager
|
||||||
{
|
{
|
||||||
|
@ -302,6 +303,14 @@ namespace MWGui
|
||||||
/// Does the current stack of GUI-windows permit saving?
|
/// Does the current stack of GUI-windows permit saving?
|
||||||
virtual bool isSavingAllowed() const;
|
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:
|
private:
|
||||||
bool mConsoleOnlyScripts;
|
bool mConsoleOnlyScripts;
|
||||||
|
|
||||||
|
@ -311,6 +320,8 @@ namespace MWGui
|
||||||
|
|
||||||
std::string mSelectedSpell;
|
std::string mSelectedSpell;
|
||||||
|
|
||||||
|
WindowModal* currentModal;
|
||||||
|
|
||||||
OEngine::GUI::MyGUIManager *mGuiManager;
|
OEngine::GUI::MyGUIManager *mGuiManager;
|
||||||
OEngine::Render::OgreRenderer *mRendering;
|
OEngine::Render::OgreRenderer *mRendering;
|
||||||
HUD *mHud;
|
HUD *mHud;
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
|
|
||||||
#include "../mwdialogue/dialoguemanagerimp.hpp"
|
#include "../mwdialogue/dialoguemanagerimp.hpp"
|
||||||
|
|
||||||
|
#include "../mwgui/windowbase.hpp"
|
||||||
|
|
||||||
using namespace ICS;
|
using namespace ICS;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -635,9 +637,10 @@ namespace MWInput
|
||||||
|
|
||||||
void InputManager::toggleMainMenu()
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!MWBase::Environment::get().getWindowManager()->isGuiMode()) //No open GUIs, open up the MainMenu
|
if(!MWBase::Environment::get().getWindowManager()->isGuiMode()) //No open GUIs, open up the MainMenu
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue