merged by branches together, starting with alchemy window

Merge branch 'guimode_stacking' into next

Conflicts:
	apps/openmw/mwgui/mode.hpp
actorid
scrawl 13 years ago
commit 51b8a76a68

@ -27,8 +27,8 @@ add_openmw_dir (mwgui
text_input widgets race class birth review window_manager console dialogue text_input widgets race class birth review window_manager console dialogue
dialogue_history window_base stats_window messagebox journalwindow charactercreation dialogue_history window_base stats_window messagebox journalwindow charactercreation
map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list
formatting itemwidget inventorywindow container hud countdialog tradewindow settingswindow formatting inventorywindow container hud countdialog tradewindow settingswindow
confirmationdialog confirmationdialog alchemywindow
) )
add_openmw_dir (mwdialogue add_openmw_dir (mwdialogue
@ -50,7 +50,7 @@ add_openmw_dir (mwworld
refdata world physicssystem scene globals class action nullaction actionteleport refdata world physicssystem scene globals class action nullaction actionteleport
containerstore actiontalk actiontake manualref player cellfunctors containerstore actiontalk actiontake manualref player cellfunctors
cells localscripts customdata weather inventorystore ptr actionopen actionread cells localscripts customdata weather inventorystore ptr actionopen actionread
actionequip timestamp actionequip timestamp actionalchemy
) )
add_openmw_dir (mwclass add_openmw_dir (mwclass

@ -105,7 +105,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
// frame. // frame.
// passing of time // passing of time
if (MWBase::Environment::get().getWindowManager()->getMode()==MWGui::GM_Game) if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
MWBase::Environment::get().getWorld()->advanceTime ( MWBase::Environment::get().getWorld()->advanceTime (
mEnvironment.getFrameDuration()*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600); mEnvironment.getFrameDuration()*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600);
@ -116,9 +116,9 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
// update actors // update actors
std::vector<std::pair<std::string, Ogre::Vector3> > movement; std::vector<std::pair<std::string, Ogre::Vector3> > movement;
MWBase::Environment::get().getMechanicsManager()->update (movement, mEnvironment.getFrameDuration(), MWBase::Environment::get().getMechanicsManager()->update (movement, mEnvironment.getFrameDuration(),
MWBase::Environment::get().getWindowManager()->getMode()!=MWGui::GM_Game); MWBase::Environment::get().getWindowManager()->isGuiMode());
if (MWBase::Environment::get().getWindowManager()->getMode()==MWGui::GM_Game) if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration()); MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration());
// update world // update world
@ -421,7 +421,7 @@ void OMW::Engine::go()
void OMW::Engine::activate() void OMW::Engine::activate()
{ {
if (MWBase::Environment::get().getWindowManager()->getMode()!=MWGui::GM_Game) if (MWBase::Environment::get().getWindowManager()->isGuiMode())
return; return;
std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle(); std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle();

@ -9,6 +9,7 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/actionalchemy.hpp"
#include "../mwworld/world.hpp" #include "../mwworld/world.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
@ -140,4 +141,10 @@ namespace MWClass
return info; return info;
} }
boost::shared_ptr<MWWorld::Action> Apparatus::use (const MWWorld::Ptr& ptr) const
{
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionAlchemy());
}
} }

@ -44,6 +44,10 @@ namespace MWClass
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const; virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
///< Return name of inventory icon. ///< Return name of inventory icon.
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
const;
///< Generate action for using via inventory menu
}; };
} }

@ -635,7 +635,7 @@ namespace MWDialogue
actorKnownTopics.clear(); actorKnownTopics.clear();
//initialise the GUI //initialise the GUI
MWBase::Environment::get().getInputManager()->setGuiMode(MWGui::GM_Dialogue); MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Dialogue);
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->startDialogue(actor, MWWorld::Class::get (actor).getName (actor)); win->startDialogue(actor, MWWorld::Class::get (actor).getName (actor));
@ -843,7 +843,7 @@ namespace MWDialogue
void DialogueManager::goodbyeSelected() void DialogueManager::goodbyeSelected()
{ {
MWBase::Environment::get().getInputManager()->setGuiMode(MWGui::GM_Game); MWBase::Environment::get().getWindowManager()->popGuiMode();
} }
void DialogueManager::questionAnswered(std::string answere) void DialogueManager::questionAnswered(std::string answere)

@ -0,0 +1,10 @@
#include "alchemywindow.hpp"
namespace MWGui
{
AlchemyWindow::AlchemyWindow(WindowManager& parWindowManager)
: WindowBase("openmw_alchemy_window_layout.xml", parWindowManager)
{
center();
}
}

@ -0,0 +1,15 @@
#ifndef MWGUI_ALCHEMY_H
#define MWGUI_ALCHEMY_H
#include "window_base.hpp"
namespace MWGui
{
class AlchemyWindow : public WindowBase
{
public:
AlchemyWindow(WindowManager& parWindowManager);
};
}
#endif

@ -1,13 +1,14 @@
#include "bookwindow.hpp" #include "bookwindow.hpp"
#include "formatting.hpp" #include <boost/lexical_cast.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwinput/inputmanager.hpp" #include "../mwinput/inputmanager.hpp"
#include "../mwsound/soundmanager.hpp" #include "../mwsound/soundmanager.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include <boost/lexical_cast.hpp> #include "formatting.hpp"
#include "window_manager.hpp"
using namespace MWGui; using namespace MWGui;
@ -91,7 +92,7 @@ void BookWindow::onCloseButtonClicked (MyGUI::Widget* _sender)
// no 3d sounds because the object could be in a container. // 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().getSoundManager()->playSound ("book close", 1.0, 1.0);
MWBase::Environment::get().getInputManager()->setGuiMode(MWGui::GM_Game); mWindowManager.popGuiMode();
} }
void BookWindow::onTakeButtonClicked (MyGUI::Widget* _sender) void BookWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
@ -101,7 +102,7 @@ void BookWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
MWWorld::ActionTake take(mBook); MWWorld::ActionTake take(mBook);
take.execute(); take.execute();
MWBase::Environment::get().getInputManager()->setGuiMode (GM_Game); mWindowManager.popGuiMode();
} }
void BookWindow::onNextPageButtonClicked (MyGUI::Widget* _sender) void BookWindow::onNextPageButtonClicked (MyGUI::Widget* _sender)

@ -110,7 +110,6 @@ using namespace MWGui;
CharacterCreation::CharacterCreation(WindowManager* _wm) CharacterCreation::CharacterCreation(WindowManager* _wm)
: mNameDialog(0) : mNameDialog(0)
, mRaceDialog(0) , mRaceDialog(0)
, mDialogueWindow(0)
, mClassChoiceDialog(0) , mClassChoiceDialog(0)
, mGenerateClassQuestionDialog(0) , mGenerateClassQuestionDialog(0)
, mGenerateClassResultDialog(0) , mGenerateClassResultDialog(0)
@ -253,7 +252,7 @@ void CharacterCreation::onReviewDialogDone(WindowBase* parWindow)
if (mReviewDialog) if (mReviewDialog)
mWM->removeDialog(mReviewDialog); mWM->removeDialog(mReviewDialog);
mWM->setGuiMode(GM_Game); mWM->popGuiMode();
} }
void CharacterCreation::onReviewDialogBack() void CharacterCreation::onReviewDialogBack()
@ -261,7 +260,7 @@ void CharacterCreation::onReviewDialogBack()
if (mReviewDialog) if (mReviewDialog)
mWM->removeDialog(mReviewDialog); mWM->removeDialog(mReviewDialog);
mWM->setGuiMode(GM_Birth); mWM->pushGuiMode(GM_Birth);
} }
void CharacterCreation::onReviewActivateDialog(int parDialog) void CharacterCreation::onReviewActivateDialog(int parDialog)
@ -270,19 +269,21 @@ void CharacterCreation::onReviewActivateDialog(int parDialog)
mWM->removeDialog(mReviewDialog); mWM->removeDialog(mReviewDialog);
mCreationStage = CSE_ReviewNext; mCreationStage = CSE_ReviewNext;
mWM->popGuiMode();
switch(parDialog) switch(parDialog)
{ {
case ReviewDialog::NAME_DIALOG: case ReviewDialog::NAME_DIALOG:
mWM->setGuiMode(GM_Name); mWM->pushGuiMode(GM_Name);
break; break;
case ReviewDialog::RACE_DIALOG: case ReviewDialog::RACE_DIALOG:
mWM->setGuiMode(GM_Race); mWM->pushGuiMode(GM_Race);
break; break;
case ReviewDialog::CLASS_DIALOG: case ReviewDialog::CLASS_DIALOG:
mWM->setGuiMode(GM_Class); mWM->pushGuiMode(GM_Class);
break; break;
case ReviewDialog::BIRTHSIGN_DIALOG: case ReviewDialog::BIRTHSIGN_DIALOG:
mWM->setGuiMode(GM_Birth); mWM->pushGuiMode(GM_Birth);
}; };
} }
@ -304,13 +305,19 @@ void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow)
//TODO This bit gets repeated a few times; wrap it in a function //TODO This bit gets repeated a few times; wrap it in a function
if (mCreationStage == CSE_ReviewNext) if (mCreationStage == CSE_ReviewNext)
mWM->setGuiMode(GM_Review); {
mWM->popGuiMode();
mWM->pushGuiMode(GM_Review);
}
else if (mCreationStage >= CSE_ClassChosen) else if (mCreationStage >= CSE_ClassChosen)
mWM->setGuiMode(GM_Birth); {
mWM->popGuiMode();
mWM->pushGuiMode(GM_Birth);
}
else else
{ {
mCreationStage = CSE_ClassChosen; mCreationStage = CSE_ClassChosen;
mWM->setGuiMode(GM_Game); mWM->popGuiMode();
} }
} }
@ -324,7 +331,8 @@ void CharacterCreation::onPickClassDialogBack()
mWM->removeDialog(mPickClassDialog); mWM->removeDialog(mPickClassDialog);
} }
mWM->setGuiMode(GM_Class); mWM->popGuiMode();
mWM->pushGuiMode(GM_Class);
} }
void CharacterCreation::onClassChoice(int _index) void CharacterCreation::onClassChoice(int _index)
@ -334,19 +342,21 @@ void CharacterCreation::onClassChoice(int _index)
mWM->removeDialog(mClassChoiceDialog); mWM->removeDialog(mClassChoiceDialog);
} }
mWM->popGuiMode();
switch(_index) switch(_index)
{ {
case ClassChoiceDialog::Class_Generate: case ClassChoiceDialog::Class_Generate:
mWM->setGuiMode(GM_ClassGenerate); mWM->pushGuiMode(GM_ClassGenerate);
break; break;
case ClassChoiceDialog::Class_Pick: case ClassChoiceDialog::Class_Pick:
mWM->setGuiMode(GM_ClassPick); mWM->pushGuiMode(GM_ClassPick);
break; break;
case ClassChoiceDialog::Class_Create: case ClassChoiceDialog::Class_Create:
mWM->setGuiMode(GM_ClassCreate); mWM->pushGuiMode(GM_ClassCreate);
break; break;
case ClassChoiceDialog::Class_Back: case ClassChoiceDialog::Class_Back:
mWM->setGuiMode(GM_Race); mWM->pushGuiMode(GM_Race);
break; break;
}; };
@ -363,13 +373,19 @@ void CharacterCreation::onNameDialogDone(WindowBase* parWindow)
} }
if (mCreationStage == CSE_ReviewNext) if (mCreationStage == CSE_ReviewNext)
mWM->setGuiMode(GM_Review); {
mWM->popGuiMode();
mWM->pushGuiMode(GM_Review);
}
else if (mCreationStage >= CSE_NameChosen) else if (mCreationStage >= CSE_NameChosen)
mWM->setGuiMode(GM_Race); {
mWM->popGuiMode();
mWM->pushGuiMode(GM_Race);
}
else else
{ {
mCreationStage = CSE_NameChosen; mCreationStage = CSE_NameChosen;
mWM->setGuiMode(GM_Game); mWM->popGuiMode();
} }
} }
@ -383,7 +399,8 @@ void CharacterCreation::onRaceDialogBack()
mWM->removeDialog(mRaceDialog); mWM->removeDialog(mRaceDialog);
} }
mWM->setGuiMode(GM_Name); mWM->popGuiMode();
mWM->pushGuiMode(GM_Name);
} }
void CharacterCreation::onRaceDialogDone(WindowBase* parWindow) void CharacterCreation::onRaceDialogDone(WindowBase* parWindow)
@ -398,13 +415,19 @@ void CharacterCreation::onRaceDialogDone(WindowBase* parWindow)
} }
if (mCreationStage == CSE_ReviewNext) if (mCreationStage == CSE_ReviewNext)
mWM->setGuiMode(GM_Review); {
else if(mCreationStage >= CSE_RaceChosen) mWM->popGuiMode();
mWM->setGuiMode(GM_Class); mWM->pushGuiMode(GM_Review);
}
else if (mCreationStage >= CSE_NameChosen)
{
mWM->popGuiMode();
mWM->pushGuiMode(GM_Class);
}
else else
{ {
mCreationStage = CSE_RaceChosen; mCreationStage = CSE_NameChosen;
mWM->setGuiMode(GM_Game); mWM->popGuiMode();
} }
} }
@ -419,11 +442,14 @@ void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow)
} }
if (mCreationStage >= CSE_BirthSignChosen) if (mCreationStage >= CSE_BirthSignChosen)
mWM->setGuiMode(GM_Review); {
mWM->popGuiMode();
mWM->pushGuiMode(GM_Review);
}
else else
{ {
mCreationStage = CSE_BirthSignChosen; mCreationStage = CSE_BirthSignChosen;
mWM->setGuiMode(GM_Game); mWM->popGuiMode();
} }
} }
@ -435,7 +461,8 @@ void CharacterCreation::onBirthSignDialogBack()
mWM->removeDialog(mBirthSignDialog); mWM->removeDialog(mBirthSignDialog);
} }
mWM->setGuiMode(GM_Class); mWM->popGuiMode();
mWM->pushGuiMode(GM_Class);
} }
void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow) void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
@ -470,13 +497,19 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
} }
if (mCreationStage == CSE_ReviewNext) if (mCreationStage == CSE_ReviewNext)
mWM->setGuiMode(GM_Review); {
mWM->popGuiMode();
mWM->pushGuiMode(GM_Review);
}
else if (mCreationStage >= CSE_ClassChosen) else if (mCreationStage >= CSE_ClassChosen)
mWM->setGuiMode(GM_Birth); {
mWM->popGuiMode();
mWM->pushGuiMode(GM_Birth);
}
else else
{ {
mCreationStage = CSE_ClassChosen; mCreationStage = CSE_ClassChosen;
mWM->setGuiMode(GM_Game); mWM->popGuiMode();
} }
} }
@ -485,7 +518,8 @@ void CharacterCreation::onCreateClassDialogBack()
if (mCreateClassDialog) if (mCreateClassDialog)
mWM->removeDialog(mCreateClassDialog); mWM->removeDialog(mCreateClassDialog);
mWM->setGuiMode(GM_Class); mWM->popGuiMode();
mWM->pushGuiMode(GM_Class);
} }
void CharacterCreation::onClassQuestionChosen(int _index) void CharacterCreation::onClassQuestionChosen(int _index)
@ -496,7 +530,8 @@ void CharacterCreation::onClassQuestionChosen(int _index)
mWM->removeDialog(mGenerateClassQuestionDialog); mWM->removeDialog(mGenerateClassQuestionDialog);
if (_index < 0 || _index >= 3) if (_index < 0 || _index >= 3)
{ {
mWM->setGuiMode(GM_Class); mWM->popGuiMode();
mWM->pushGuiMode(GM_Class);
return; return;
} }
@ -581,7 +616,8 @@ void CharacterCreation::showClassQuestionDialog()
if (mGenerateClassStep > sGenerateClassSteps.size()) if (mGenerateClassStep > sGenerateClassSteps.size())
{ {
mWM->setGuiMode(GM_Class); mWM->popGuiMode();
mWM->pushGuiMode(GM_Class);
return; return;
} }
@ -610,7 +646,8 @@ void CharacterCreation::onGenerateClassBack()
mWM->removeDialog(mGenerateClassResultDialog); mWM->removeDialog(mGenerateClassResultDialog);
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
mWM->setGuiMode(GM_Class); mWM->popGuiMode();
mWM->pushGuiMode(GM_Class);
} }
void CharacterCreation::onGenerateClassDone(WindowBase* parWindow) void CharacterCreation::onGenerateClassDone(WindowBase* parWindow)
@ -620,13 +657,19 @@ void CharacterCreation::onGenerateClassDone(WindowBase* parWindow)
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
if (mCreationStage == CSE_ReviewNext) if (mCreationStage == CSE_ReviewNext)
mWM->setGuiMode(GM_Review); {
mWM->popGuiMode();
mWM->pushGuiMode(GM_Review);
}
else if (mCreationStage >= CSE_ClassChosen) else if (mCreationStage >= CSE_ClassChosen)
mWM->setGuiMode(GM_Birth); {
mWM->popGuiMode();
mWM->pushGuiMode(GM_Birth);
}
else else
{ {
mCreationStage = CSE_ClassChosen; mCreationStage = CSE_ClassChosen;
mWM->setGuiMode(GM_Game); mWM->popGuiMode();
} }
} }
@ -634,7 +677,6 @@ CharacterCreation::~CharacterCreation()
{ {
delete mNameDialog; delete mNameDialog;
delete mRaceDialog; delete mRaceDialog;
delete mDialogueWindow;
delete mClassChoiceDialog; delete mClassChoiceDialog;
delete mGenerateClassQuestionDialog; delete mGenerateClassQuestionDialog;
delete mGenerateClassResultDialog; delete mGenerateClassResultDialog;

@ -46,7 +46,6 @@ namespace MWGui
//Dialogs //Dialogs
TextInputDialog* mNameDialog; TextInputDialog* mNameDialog;
RaceDialog* mRaceDialog; RaceDialog* mRaceDialog;
DialogueWindow* mDialogueWindow;
ClassChoiceDialog* mClassChoiceDialog; ClassChoiceDialog* mClassChoiceDialog;
InfoBoxDialog* mGenerateClassQuestionDialog; InfoBoxDialog* mGenerateClassQuestionDialog;
GenerateClassResultDialog* mGenerateClassResultDialog; GenerateClassResultDialog* mGenerateClassResultDialog;

@ -636,7 +636,7 @@ void ContainerWindow::onCloseButtonClicked(MyGUI::Widget* _sender)
{ {
if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop) if(mDragAndDrop == NULL || !mDragAndDrop->mIsOnDragAndDrop)
{ {
MWBase::Environment::get().getWindowManager()->setGuiMode(GM_Game); MWBase::Environment::get().getWindowManager()->popGuiMode();
} }
} }
@ -667,6 +667,6 @@ void ContainerWindow::onTakeAllButtonClicked(MyGUI::Widget* _sender)
containerStore.clear(); containerStore.clear();
MWBase::Environment::get().getWindowManager()->setGuiMode(GM_Game); MWBase::Environment::get().getWindowManager()->popGuiMode();
} }
} }

@ -112,15 +112,6 @@ void DialogueWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel)
history->setVScrollPosition(history->getVScrollPosition() - _rel*0.3); history->setVScrollPosition(history->getVScrollPosition() - _rel*0.3);
} }
void DialogueWindow::open()
{
topicsList->clear();
pTopicsText.clear();
history->eraseText(0,history->getTextLength());
updateOptions();
setVisible(true);
}
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
{ {
MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
@ -133,7 +124,7 @@ void DialogueWindow::onSelectTopic(std::string topic)
if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str) if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str)
{ {
/// \todo check if the player is allowed to trade with this actor (e.g. faction rank high enough)? /// \todo check if the player is allowed to trade with this actor (e.g. faction rank high enough)?
mWindowManager.setGuiMode(GM_Barter); mWindowManager.pushGuiMode(GM_Barter);
mWindowManager.getTradeWindow()->startTrade(mActor); mWindowManager.getTradeWindow()->startTrade(mActor);
} }
@ -147,6 +138,11 @@ void DialogueWindow::startDialogue(MWWorld::Ptr actor, std::string npcName)
mActor = actor; mActor = actor;
topicsList->setEnabled(true); topicsList->setEnabled(true);
setTitle(npcName); setTitle(npcName);
topicsList->clear();
pTopicsText.clear();
history->eraseText(0,history->getTextLength());
updateOptions();
} }
void DialogueWindow::setKeywords(std::list<std::string> keyWords) void DialogueWindow::setKeywords(std::list<std::string> keyWords)

@ -30,8 +30,6 @@ namespace MWGui
public: public:
DialogueWindow(WindowManager& parWindowManager); DialogueWindow(WindowManager& parWindowManager);
void open();
// Events // Events
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;

@ -58,7 +58,7 @@ void MessageBoxManager::onFrame (float frameDuration)
if(mInterMessageBoxe != NULL && mInterMessageBoxe->mMarkedToDelete) { if(mInterMessageBoxe != NULL && mInterMessageBoxe->mMarkedToDelete) {
delete mInterMessageBoxe; delete mInterMessageBoxe;
mInterMessageBoxe = NULL; mInterMessageBoxe = NULL;
mWindowManager->setNextMode(GM_Game); mWindowManager->popGuiMode();
} }
} }

@ -5,7 +5,6 @@ namespace MWGui
{ {
enum GuiMode enum GuiMode
{ {
GM_Game, // Game mode, only HUD
GM_Settings, // Settings window GM_Settings, // Settings window
GM_Inventory, // Inventory mode GM_Inventory, // Inventory mode
GM_Container, GM_Container,
@ -16,6 +15,7 @@ namespace MWGui
GM_Scroll, // Read scroll GM_Scroll, // Read scroll
GM_Book, // Read book GM_Book, // Read book
GM_Alchemy, // Make potions
GM_Dialogue, // NPC interaction GM_Dialogue, // NPC interaction
GM_Barter, GM_Barter,

@ -1,12 +1,13 @@
#include "scrollwindow.hpp" #include "scrollwindow.hpp"
#include "formatting.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwinput/inputmanager.hpp" #include "../mwinput/inputmanager.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwsound/soundmanager.hpp" #include "../mwsound/soundmanager.hpp"
#include "formatting.hpp"
#include "window_manager.hpp"
using namespace MWGui; using namespace MWGui;
ScrollWindow::ScrollWindow (WindowManager& parWindowManager) : ScrollWindow::ScrollWindow (WindowManager& parWindowManager) :
@ -55,7 +56,7 @@ void ScrollWindow::onCloseButtonClicked (MyGUI::Widget* _sender)
{ {
MWBase::Environment::get().getSoundManager()->playSound ("scroll", 1.0, 1.0); MWBase::Environment::get().getSoundManager()->playSound ("scroll", 1.0, 1.0);
MWBase::Environment::get().getInputManager()->setGuiMode (GM_Game); mWindowManager.popGuiMode();
} }
void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender) void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
@ -65,5 +66,5 @@ void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
MWWorld::ActionTake take(mScroll); MWWorld::ActionTake take(mScroll);
take.execute(); take.execute();
MWBase::Environment::get().getInputManager()->setGuiMode (GM_Game); mWindowManager.popGuiMode();
} }

@ -96,7 +96,7 @@ namespace MWGui
void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender) void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender)
{ {
mWindowManager.setGuiMode(GM_Game); mWindowManager.popGuiMode();
} }
void SettingsWindow::onResolutionSelected(MyGUI::ListBox* _sender, size_t index) void SettingsWindow::onResolutionSelected(MyGUI::ListBox* _sender, size_t index)

@ -210,7 +210,7 @@ namespace MWGui
std::string sound = "Item Gold Up"; std::string sound = "Item Gold Up";
MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
mWindowManager.setGuiMode(GM_Game); mWindowManager.popGuiMode();
} }
void TradeWindow::onCancelButtonClicked(MyGUI::Widget* _sender) void TradeWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
@ -220,7 +220,7 @@ namespace MWGui
// now gimme back my stuff! // now gimme back my stuff!
mWindowManager.getInventoryWindow()->returnBoughtItems(MWWorld::Class::get(mContainer).getContainerStore(mContainer)); mWindowManager.getInventoryWindow()->returnBoughtItems(MWWorld::Class::get(mContainer).getContainerStore(mContainer));
mWindowManager.setGuiMode(GM_Game); mWindowManager.popGuiMode();
} }
void TradeWindow::updateLabels() void TradeWindow::updateLabels()

@ -18,6 +18,7 @@
#include "tradewindow.hpp" #include "tradewindow.hpp"
#include "settingswindow.hpp" #include "settingswindow.hpp"
#include "confirmationdialog.hpp" #include "confirmationdialog.hpp"
#include "alchemywindow.hpp"
#include "../mwmechanics/mechanicsmanager.hpp" #include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwinput/inputmanager.hpp" #include "../mwinput/inputmanager.hpp"
@ -54,6 +55,7 @@ WindowManager::WindowManager(
, mTradeWindow(NULL) , mTradeWindow(NULL)
, mSettingsWindow(NULL) , mSettingsWindow(NULL)
, mConfirmationDialog(NULL) , mConfirmationDialog(NULL)
, mAlchemyWindow(NULL)
, mCharGen(NULL) , mCharGen(NULL)
, playerClass() , playerClass()
, playerName() , playerName()
@ -66,9 +68,6 @@ WindowManager::WindowManager(
, playerMagicka() , playerMagicka()
, playerFatigue() , playerFatigue()
, gui(NULL) , gui(NULL)
, mode(GM_Game)
, nextMode(GM_Game)
, needModeChange(false)
, garbageDialogs() , garbageDialogs()
, shown(GW_ALL) , shown(GW_ALL)
, allowed(newGame ? GW_None : GW_ALL) , allowed(newGame ? GW_None : GW_ALL)
@ -124,6 +123,7 @@ WindowManager::WindowManager(
mCountDialog = new CountDialog(*this); mCountDialog = new CountDialog(*this);
mSettingsWindow = new SettingsWindow(*this); mSettingsWindow = new SettingsWindow(*this);
mConfirmationDialog = new ConfirmationDialog(*this); mConfirmationDialog = new ConfirmationDialog(*this);
mAlchemyWindow = new AlchemyWindow(*this);
// The HUD is always on // The HUD is always on
hud->setVisible(true); hud->setVisible(true);
@ -166,6 +166,7 @@ WindowManager::~WindowManager()
delete mTradeWindow; delete mTradeWindow;
delete mSettingsWindow; delete mSettingsWindow;
delete mConfirmationDialog; delete mConfirmationDialog;
delete mAlchemyWindow;
cleanupGarbage(); cleanupGarbage();
} }
@ -186,12 +187,6 @@ void WindowManager::cleanupGarbage()
void WindowManager::update() void WindowManager::update()
{ {
cleanupGarbage(); cleanupGarbage();
if (needModeChange)
{
needModeChange = false;
MWBase::Environment::get().getInputManager()->setGuiMode(nextMode);
nextMode = GM_Game;
}
if (showFPSLevel > 0) if (showFPSLevel > 0)
{ {
hud->setFPS(mFPS); hud->setFPS(mFPS);
@ -200,17 +195,6 @@ void WindowManager::update()
} }
} }
void WindowManager::setNextMode(GuiMode newMode)
{
nextMode = newMode;
needModeChange = true;
}
void WindowManager::setGuiMode(GuiMode newMode)
{
MWBase::Environment::get().getInputManager()->setGuiMode(newMode);
}
void WindowManager::updateVisible() void WindowManager::updateVisible()
{ {
// Start out by hiding everything except the HUD // Start out by hiding everything except the HUD
@ -226,19 +210,25 @@ void WindowManager::updateVisible()
mBookWindow->setVisible(false); mBookWindow->setVisible(false);
mTradeWindow->setVisible(false); mTradeWindow->setVisible(false);
mSettingsWindow->setVisible(false); mSettingsWindow->setVisible(false);
mAlchemyWindow->setVisible(false);
// Mouse is visible whenever we're not in game mode // Mouse is visible whenever we're not in game mode
MyGUI::PointerManager::getInstance().setVisible(isGuiMode()); MyGUI::PointerManager::getInstance().setVisible(isGuiMode());
if (mode == GM_Game) bool gameMode = !isGuiMode();
if (gameMode)
mToolTips->enterGameMode(); mToolTips->enterGameMode();
else else
mToolTips->enterGuiMode(); mToolTips->enterGuiMode();
// If in game mode, don't show anything.
if (gameMode)
return;
GuiMode mode = mGuiModes.back();
switch(mode) { switch(mode) {
case GM_Game:
// If in game mode, don't show anything.
break;
case GM_MainMenu: case GM_MainMenu:
menu->setVisible(true); menu->setVisible(true);
break; break;
@ -254,6 +244,9 @@ void WindowManager::updateVisible()
case GM_Book: case GM_Book:
mBookWindow->setVisible(true); mBookWindow->setVisible(true);
break; break;
case GM_Alchemy:
mAlchemyWindow->setVisible(true);
break;
case GM_Name: case GM_Name:
case GM_Race: case GM_Race:
case GM_Class: case GM_Class:
@ -285,7 +278,7 @@ void WindowManager::updateVisible()
mInventoryWindow->openInventory(); mInventoryWindow->openInventory();
break; break;
case GM_Dialogue: case GM_Dialogue:
mDialogueWindow->open(); mDialogueWindow->setVisible(true);
break; break;
case GM_Barter: case GM_Barter:
mInventoryWindow->setVisible(true); mInventoryWindow->setVisible(true);
@ -293,9 +286,6 @@ void WindowManager::updateVisible()
mTradeWindow->setVisible(true); mTradeWindow->setVisible(true);
break; break;
case GM_InterMessageBox: case GM_InterMessageBox:
if(!mMessageBoxManager->isInteractiveMessageBox()) {
setGuiMode(GM_Game);
}
break; break;
case GM_Journal: case GM_Journal:
mJournal->setVisible(true); mJournal->setVisible(true);
@ -303,9 +293,6 @@ void WindowManager::updateVisible()
break; break;
default: default:
// Unsupported mode, switch back to game // Unsupported mode, switch back to game
// Note: The call will eventually end up this method again but
// will stop at the check if mode is GM_Game.
setGuiMode(GM_Game);
break; break;
} }
} }
@ -439,7 +426,7 @@ void WindowManager::messageBox (const std::string& message, const std::vector<st
else else
{ {
mMessageBoxManager->createInteractiveMessageBox(message, buttons); mMessageBoxManager->createInteractiveMessageBox(message, buttons);
setGuiMode(GM_InterMessageBox); pushGuiMode(GM_InterMessageBox);
} }
} }
@ -464,7 +451,7 @@ void WindowManager::onDialogueWindowBye()
//removeDialog(dialogueWindow); //removeDialog(dialogueWindow);
mDialogueWindow->setVisible(false); mDialogueWindow->setVisible(false);
} }
setGuiMode(GM_Game); popGuiMode();
} }
void WindowManager::onFrame (float frameDuration) void WindowManager::onFrame (float frameDuration)
@ -608,3 +595,27 @@ void WindowManager::processChangedSettings(const Settings::CategorySettingVector
{ {
hud->setFpsLevel(Settings::Manager::getInt("fps", "HUD")); hud->setFpsLevel(Settings::Manager::getInt("fps", "HUD"));
} }
void WindowManager::pushGuiMode(GuiMode mode)
{
if (mode==GM_Inventory && allowed==GW_None)
return;
mGuiModes.push_back(mode);
bool gameMode = !isGuiMode();
MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode);
updateVisible();
}
void WindowManager::popGuiMode()
{
if (mGuiModes.size())
mGuiModes.pop_back();
bool gameMode = !isGuiMode();
MWBase::Environment::get().getInputManager()->changeInputMode(!gameMode);
updateVisible();
}

@ -80,6 +80,7 @@ namespace MWGui
class TradeWindow; class TradeWindow;
class SettingsWindow; class SettingsWindow;
class ConfirmationDialog; class ConfirmationDialog;
class AlchemyWindow;
struct ClassPoint struct ClassPoint
{ {
@ -99,8 +100,6 @@ namespace MWGui
WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string logpath); WindowManager(const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string logpath);
virtual ~WindowManager(); virtual ~WindowManager();
void setGuiMode(GuiMode newMode);
/** /**
* Should be called each frame to update windows/gui elements. * Should be called each frame to update windows/gui elements.
* This could mean updating sizes of gui elements or opening * This could mean updating sizes of gui elements or opening
@ -108,19 +107,17 @@ namespace MWGui
*/ */
void update(); void update();
void setMode(GuiMode newMode) void pushGuiMode(GuiMode mode);
{ void popGuiMode();
if (newMode==GM_Inventory && allowed==GW_None)
return;
mode = newMode; GuiMode getMode() const
updateVisible(); {
if (mGuiModes.empty())
throw std::runtime_error ("getMode() called, but there is no active mode");
return mGuiModes.back();
} }
void setNextMode(GuiMode newMode);
GuiMode getMode() const { return mode; }
bool isGuiMode() const { return getMode() != GM_Game; } // Everything that is not game mode is considered "gui mode" bool isGuiMode() const { return !mGuiModes.empty(); }
// Disallow all inventory mode windows // Disallow all inventory mode windows
void disallowAll() void disallowAll()
@ -235,6 +232,7 @@ namespace MWGui
TradeWindow* mTradeWindow; TradeWindow* mTradeWindow;
SettingsWindow* mSettingsWindow; SettingsWindow* mSettingsWindow;
ConfirmationDialog* mConfirmationDialog; ConfirmationDialog* mConfirmationDialog;
AlchemyWindow* mAlchemyWindow;
CharacterCreation* mCharGen; CharacterCreation* mCharGen;
@ -249,9 +247,7 @@ namespace MWGui
MyGUI::Gui *gui; // Gui MyGUI::Gui *gui; // Gui
GuiMode mode; // Current gui mode std::vector<GuiMode> mGuiModes;
GuiMode nextMode; // Next mode to activate in update()
bool needModeChange; //Whether a mode change is needed in update() [will use nextMode]
std::vector<OEngine::GUI::Layout*> garbageDialogs; std::vector<OEngine::GUI::Layout*> garbageDialogs;
void cleanupGarbage(); void cleanupGarbage();

@ -140,28 +140,27 @@ namespace MWInput
if (mDragDrop) if (mDragDrop)
return; return;
MWGui::GuiMode mode = windows.getMode(); if (!windows.isGuiMode() || windows.getMode() != MWGui::GM_Settings)
if (mode != MWGui::GM_Settings) windows.pushGuiMode(MWGui::GM_Settings);
setGuiMode(MWGui::GM_Settings);
} }
/* toggleInventory() is called when the user presses the button to toggle the inventory screen. */ /* toggleInventory() is called when the user presses the button to toggle the inventory screen. */
void toggleInventory() void toggleInventory()
{ {
using namespace MWGui; using namespace MWGui;
if (mDragDrop) if (mDragDrop)
return; return;
GuiMode mode = windows.getMode(); bool gameMode = !windows.isGuiMode();
// Toggle between game mode and inventory mode // Toggle between game mode and inventory mode
if(mode == GM_Game) if(gameMode)
setGuiMode(GM_Inventory); windows.pushGuiMode(GM_Inventory);
else if(mode == GM_Inventory) else if(windows.getMode() == GM_Inventory)
setGuiMode(GM_Game); windows.popGuiMode();
// .. but don't touch any other mode. // .. but don't touch any other mode.
} }
// Toggle console // Toggle console
@ -172,28 +171,33 @@ namespace MWInput
if (mDragDrop) if (mDragDrop)
return; return;
GuiMode mode = windows.getMode(); bool gameMode = !windows.isGuiMode();
// Switch to console mode no matter what mode we are currently // Switch to console mode no matter what mode we are currently
// in, except of course if we are already in console mode // in, except of course if we are already in console mode
if(mode == GM_Console) if (!gameMode)
setGuiMode(GM_Game); {
else setGuiMode(GM_Console); if (windows.getMode() == GM_Console)
windows.popGuiMode();
else
windows.pushGuiMode(GM_Console);
}
else
windows.pushGuiMode(GM_Console);
} }
void toggleJournal() void toggleJournal()
{ {
using namespace MWGui; using namespace MWGui;
GuiMode mode = windows.getMode(); // Toggle between game mode and journal mode
bool gameMode = !windows.isGuiMode();
// Toggle between game mode and journal mode if(gameMode)
if(mode == GM_Game) windows.pushGuiMode(GM_Journal);
setGuiMode(GM_Journal); else if(windows.getMode() == GM_Journal)
else if(mode == GM_Journal) windows.popGuiMode();
setGuiMode(GM_Game); // .. but don't touch any other mode.
// .. but don't touch any other mode.
} }
void activate() void activate()
@ -287,8 +291,7 @@ namespace MWInput
lst->add(guiEvents,Event::EV_ALL); lst->add(guiEvents,Event::EV_ALL);
} }
// Start out in game mode changeInputMode(false);
setGuiMode(MWGui::GM_Game);
/********************************** /**********************************
Key binding section Key binding section
@ -353,6 +356,7 @@ namespace MWInput
windows.update(); windows.update();
// Disable movement in Gui mode // Disable movement in Gui mode
if (windows.isGuiMode()) return; if (windows.isGuiMode()) return;
// Configure player movement according to keyboard input. Actual movement will // Configure player movement according to keyboard input. Actual movement will
@ -393,14 +397,10 @@ namespace MWInput
// Switch between gui modes. Besides controlling the Gui windows // Switch between gui modes. Besides controlling the Gui windows
// this also makes sure input is directed to the right place // this also makes sure input is directed to the right place
void setGuiMode(MWGui::GuiMode mode) void changeInputMode(bool guiMode)
{ {
// Tell the GUI what to show (this also takes care of the mouse
// pointer)
windows.setMode(mode);
// Are we in GUI mode now? // Are we in GUI mode now?
if(windows.isGuiMode()) if(guiMode)
{ {
// Disable mouse look // Disable mouse look
mouse->setCamera(NULL); mouse->setCamera(NULL);
@ -436,11 +436,6 @@ namespace MWInput
delete impl; delete impl;
} }
void MWInputManager::setGuiMode(MWGui::GuiMode mode)
{
impl->setGuiMode(mode);
}
void MWInputManager::update() void MWInputManager::update()
{ {
impl->update(); impl->update();
@ -450,4 +445,9 @@ namespace MWInput
{ {
impl->setDragDrop(dragDrop); impl->setDragDrop(dragDrop);
} }
void MWInputManager::changeInputMode(bool guiMode)
{
impl->changeInputMode(guiMode);
}
} }

@ -50,9 +50,9 @@ namespace MWInput
void update(); void update();
void setDragDrop(bool dragDrop); void changeInputMode(bool guiMode);
void setGuiMode(MWGui::GuiMode mode); void setDragDrop(bool dragDrop);
}; };
} }
#endif #endif

@ -44,7 +44,7 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
MWBase::Environment::get().getInputManager()->setGuiMode(mDialogue); MWBase::Environment::get().getWindowManager()->pushGuiMode(mDialogue);
} }
}; };

@ -0,0 +1,13 @@
#include "actionalchemy.hpp"
#include "../mwbase/environment.hpp"
#include "../mwgui/window_manager.hpp"
namespace MWWorld
{
void ActionAlchemy::execute()
{
MWBase::Environment::get().getWindowManager()->popGuiMode();
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Alchemy);
}
}

@ -0,0 +1,15 @@
#ifndef GAME_MWWORLD_ACTIONALCHEMY_H
#define GAME_MWWORLD_ACTIONALCHEMY_H
#include "action.hpp"
namespace MWWorld
{
class ActionAlchemy : public Action
{
public:
virtual void execute ();
};
}
#endif

@ -16,7 +16,7 @@ namespace MWWorld
void ActionOpen::execute () void ActionOpen::execute ()
{ {
MWBase::Environment::get().getWindowManager()->setGuiMode(MWGui::GM_Container); MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container);
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(mContainer); MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(mContainer);
} }
} }

@ -18,12 +18,12 @@ namespace MWWorld
if (ref->base->data.isScroll) if (ref->base->data.isScroll)
{ {
MWBase::Environment::get().getWindowManager()->setGuiMode(MWGui::GM_Scroll); MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Scroll);
MWBase::Environment::get().getWindowManager()->getScrollWindow()->open(mObject); MWBase::Environment::get().getWindowManager()->getScrollWindow()->open(mObject);
} }
else else
{ {
MWBase::Environment::get().getWindowManager()->setGuiMode(MWGui::GM_Book); MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Book);
MWBase::Environment::get().getWindowManager()->getBookWindow()->open(mObject); MWBase::Environment::get().getWindowManager()->getBookWindow()->open(mObject);
} }
} }

@ -59,6 +59,7 @@ configure_file("${SDIR}/openmw_count_window_layout.xml" "${DDIR}/openmw_count_wi
configure_file("${SDIR}/openmw_trade_window_layout.xml" "${DDIR}/openmw_trade_window_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_trade_window_layout.xml" "${DDIR}/openmw_trade_window_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_settings_window_layout.xml" "${DDIR}/openmw_settings_window_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_settings_window_layout.xml" "${DDIR}/openmw_settings_window_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_confirmation_dialog_layout.xml" "${DDIR}/openmw_confirmation_dialog_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_confirmation_dialog_layout.xml" "${DDIR}/openmw_confirmation_dialog_layout.xml" COPYONLY)
configure_file("${SDIR}/openmw_alchemy_window_layout.xml" "${DDIR}/openmw_alchemy_window_layout.xml" COPYONLY)
configure_file("${SDIR}/atlas1.cfg" "${DDIR}/atlas1.cfg" COPYONLY) configure_file("${SDIR}/atlas1.cfg" "${DDIR}/atlas1.cfg" COPYONLY)
configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY) configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY)
configure_file("${SDIR}/EBGaramond-Regular.ttf" "${DDIR}/EBGaramond-Regular.ttf" COPYONLY) configure_file("${SDIR}/EBGaramond-Regular.ttf" "${DDIR}/EBGaramond-Regular.ttf" COPYONLY)

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 600 500" name="_Main">
</Widget>
</MyGUI>
Loading…
Cancel
Save