From b68f9d6a2861ab9fe8e9a3185e64e83086d16070 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 11 Aug 2012 17:30:55 +0200 Subject: [PATCH 1/2] Issue #107: MechanicsManager is accessed only through the interface class from now on --- apps/openmw/CMakeLists.txt | 4 +- apps/openmw/engine.cpp | 2 +- apps/openmw/mwbase/environment.cpp | 7 +- apps/openmw/mwbase/environment.hpp | 14 ++-- apps/openmw/mwbase/mechanicsmanager.hpp | 77 +++++++++++++++++++ apps/openmw/mwclass/creature.cpp | 4 +- apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwdialogue/dialoguemanagerimp.hpp | 4 +- apps/openmw/mwgui/charactercreation.cpp | 1 + apps/openmw/mwgui/charactercreation.hpp | 1 - apps/openmw/mwgui/stats_window.cpp | 3 +- apps/openmw/mwgui/window_manager.cpp | 2 +- ...icsmanager.cpp => mechanicsmanagerimp.cpp} | 2 +- ...icsmanager.hpp => mechanicsmanagerimp.hpp} | 35 ++++----- apps/openmw/mwworld/scene.cpp | 5 +- apps/openmw/mwworld/worldimp.cpp | 9 +-- 16 files changed, 120 insertions(+), 52 deletions(-) create mode 100644 apps/openmw/mwbase/mechanicsmanager.hpp rename apps/openmw/mwmechanics/{mechanicsmanager.cpp => mechanicsmanagerimp.cpp} (99%) rename apps/openmw/mwmechanics/{mechanicsmanager.hpp => mechanicsmanagerimp.hpp} (60%) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 172c6a4948..f4454a216c 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -60,12 +60,12 @@ add_openmw_dir (mwclass ) add_openmw_dir (mwmechanics - mechanicsmanager stat creaturestats magiceffects movement actors drawstate spells + mechanicsmanagerimp stat creaturestats magiceffects movement actors drawstate spells activespells npcstats ) add_openmw_dir (mwbase - environment world scriptmanager dialoguemanager journal soundmanager + environment world scriptmanager dialoguemanager journal soundmanager mechanicsmanager ) # Main executable diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 2467f91d13..98fee43841 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -32,7 +32,7 @@ #include "mwdialogue/dialoguemanagerimp.hpp" #include "mwdialogue/journalimp.hpp" -#include "mwmechanics/mechanicsmanager.hpp" +#include "mwmechanics/mechanicsmanagerimp.hpp" void OMW::Engine::executeLocalScripts() diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index 7d109b000c..f75c3588fc 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -5,13 +5,12 @@ #include "../mwinput/inputmanager.hpp" -#include "../mwmechanics/mechanicsmanager.hpp" - #include "world.hpp" #include "scriptmanager.hpp" #include "dialoguemanager.hpp" #include "journal.hpp" #include "soundmanager.hpp" +#include "mechanicsmanager.hpp" MWBase::Environment *MWBase::Environment::sThis = 0; @@ -49,7 +48,7 @@ void MWBase::Environment::setWindowManager (MWGui::WindowManager *windowManager) mWindowManager = windowManager; } -void MWBase::Environment::setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager) +void MWBase::Environment::setMechanicsManager (MechanicsManager *mechanicsManager) { mMechanicsManager = mechanicsManager; } @@ -98,7 +97,7 @@ MWGui::WindowManager *MWBase::Environment::getWindowManager() const return mWindowManager; } -MWMechanics::MechanicsManager *MWBase::Environment::getMechanicsManager() const +MWBase::MechanicsManager *MWBase::Environment::getMechanicsManager() const { assert (mMechanicsManager); return mMechanicsManager; diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index d03267c25f..f2e7249d3e 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -6,11 +6,6 @@ namespace MWGui class WindowManager; } -namespace MWMechanics -{ - class MechanicsManager; -} - namespace MWInput { struct MWInputManager; @@ -23,6 +18,7 @@ namespace MWBase class DialogueManager; class Journal; class SoundManager; + class MechanicsManager; /// \brief Central hub for mw-subsystems /// @@ -38,7 +34,7 @@ namespace MWBase SoundManager *mSoundManager; ScriptManager *mScriptManager; MWGui::WindowManager *mWindowManager; - MWMechanics::MechanicsManager *mMechanicsManager; + MechanicsManager *mMechanicsManager; DialogueManager *mDialogueManager; Journal *mJournal; MWInput::MWInputManager *mInputManager; @@ -64,7 +60,7 @@ namespace MWBase void setWindowManager (MWGui::WindowManager *windowManager); - void setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager); + void setMechanicsManager (MechanicsManager *mechanicsManager); void setDialogueManager (DialogueManager *dialogueManager); @@ -79,11 +75,11 @@ namespace MWBase SoundManager *getSoundManager() const; - MWBase::ScriptManager *getScriptManager() const; + ScriptManager *getScriptManager() const; MWGui::WindowManager *getWindowManager() const; - MWMechanics::MechanicsManager *getMechanicsManager() const; + MechanicsManager *getMechanicsManager() const; DialogueManager *getDialogueManager() const; diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp new file mode 100644 index 0000000000..c5f1847af1 --- /dev/null +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -0,0 +1,77 @@ +#ifndef GAME_MWBASE_MECHANICSMANAGER_H +#define GAME_MWBASE_MECHANICSMANAGER_H + +#include +#include + +namespace Ogre +{ + class Vector3; +} + +namespace ESM +{ + struct Class; +} + +namespace MWWorld +{ + class Ptr; + class CellStore; +} + +namespace MWBase +{ + /// \brief Interface for game mechanics manager (implemented in MWMechanics) + class MechanicsManager + { + MechanicsManager (const MechanicsManager&); + ///< not implemented + + MechanicsManager& operator= (const MechanicsManager&); + ///< not implemented + + public: + + MechanicsManager() {} + + virtual ~MechanicsManager() {} + + virtual void addActor (const MWWorld::Ptr& ptr) = 0; + ///< Register an actor for stats management + + virtual void removeActor (const MWWorld::Ptr& ptr) = 0; + ///< Deregister an actor for stats management + + virtual void dropActors (const MWWorld::CellStore *cellStore) = 0; + ///< Deregister all actors in the given cell. + + virtual void watchActor (const MWWorld::Ptr& ptr) = 0; + ///< On each update look for changes in a previously registered actor and update the + /// GUI accordingly. + + virtual void update (std::vector >& movement, + float duration, bool paused) = 0; + ///< Update actor stats and store desired velocity vectors in \a movement + /// + /// \param paused In game type does not currently advance (this usually means some GUI + /// component is up). + + virtual void setPlayerName (const std::string& name) = 0; + ///< Set player name. + + virtual void setPlayerRace (const std::string& id, bool male) = 0; + ///< Set player race. + + virtual void setPlayerBirthsign (const std::string& id) = 0; + ///< Set player birthsign. + + virtual void setPlayerClass (const std::string& id) = 0; + ///< Set player class to stock class. + + virtual void setPlayerClass (const ESM::Class& class_) = 0; + ///< Set player class to custom class. + }; +} + +#endif diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 0f3141f5c6..57301e1a25 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -4,10 +4,10 @@ #include #include "../mwmechanics/creaturestats.hpp" -#include "../mwmechanics/mechanicsmanager.hpp" #include "../mwmechanics/magiceffects.hpp" #include "../mwbase/environment.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" @@ -104,7 +104,7 @@ namespace MWClass if (!model.empty()) { return "meshes\\" + model; } - return ""; + return ""; } std::string Creature::getName (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 81c0c85f55..30173701ec 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -11,11 +11,11 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/movement.hpp" -#include "../mwmechanics/mechanicsmanager.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index 985d255735..e3e9fd7529 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -1,6 +1,8 @@ #ifndef GAME_MWDIALOG_DIALOGUEMANAGERIMP_H #define GAME_MWDIALOG_DIALOGUEMANAGERIMP_H +#include "../mwbase/dialoguemanager.hpp" + #include #include @@ -8,8 +10,6 @@ #include "../mwscript/interpretercontext.hpp" #include -#include "../mwbase/dialoguemanager.hpp" - #include "../mwworld/ptr.hpp" #include diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index c0081544b0..fd3a7872e3 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -10,6 +10,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/soundmanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" namespace { diff --git a/apps/openmw/mwgui/charactercreation.hpp b/apps/openmw/mwgui/charactercreation.hpp index e9c90877e6..1fd67bff7b 100644 --- a/apps/openmw/mwgui/charactercreation.hpp +++ b/apps/openmw/mwgui/charactercreation.hpp @@ -7,7 +7,6 @@ #include "../mwbase/world.hpp" -#include "../mwmechanics/mechanicsmanager.hpp" #include "../mwmechanics/stat.hpp" namespace MWGui diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 190d195945..3f5162bfba 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -8,11 +8,12 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/player.hpp" #include "../mwworld/class.hpp" -#include "../mwmechanics/mechanicsmanager.hpp" +#include "../mwmechanics/npcstats.hpp" #include "window_manager.hpp" #include "tooltips.hpp" diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 659af04470..45aee089cd 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -21,10 +21,10 @@ #include "alchemywindow.hpp" #include "spellwindow.hpp" -#include "../mwmechanics/mechanicsmanager.hpp" #include "../mwinput/inputmanager.hpp" #include "../mwbase/environment.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/cellstore.hpp" diff --git a/apps/openmw/mwmechanics/mechanicsmanager.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp similarity index 99% rename from apps/openmw/mwmechanics/mechanicsmanager.cpp rename to apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index fe5485d615..5ad67dde46 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1,5 +1,5 @@ -#include "mechanicsmanager.hpp" +#include "mechanicsmanagerimp.hpp" #include diff --git a/apps/openmw/mwmechanics/mechanicsmanager.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp similarity index 60% rename from apps/openmw/mwmechanics/mechanicsmanager.hpp rename to apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index 97bb369fda..d5fd3b6f2f 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -1,8 +1,7 @@ -#ifndef GAME_MWMECHANICS_MECHANICSMANAGER_H -#define GAME_MWMECHANICS_MECHANICSMANAGER_H +#ifndef GAME_MWMECHANICS_MECHANICSMANAGERIMP_H +#define GAME_MWMECHANICS_MECHANICSMANAGERIMP_H -#include -#include +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/ptr.hpp" @@ -22,7 +21,7 @@ namespace MWWorld namespace MWMechanics { - class MechanicsManager + class MechanicsManager : public MWBase::MechanicsManager { MWWorld::Ptr mWatched; CreatureStats mWatchedCreature; @@ -38,43 +37,41 @@ namespace MWMechanics public: - MechanicsManager (); + MechanicsManager(); - void configureGUI(); - - void addActor (const MWWorld::Ptr& ptr); + virtual void addActor (const MWWorld::Ptr& ptr); ///< Register an actor for stats management - void removeActor (const MWWorld::Ptr& ptr); + virtual void removeActor (const MWWorld::Ptr& ptr); ///< Deregister an actor for stats management - void dropActors (const MWWorld::CellStore *cellStore); + virtual void dropActors (const MWWorld::CellStore *cellStore); ///< Deregister all actors in the given cell. - void watchActor (const MWWorld::Ptr& ptr); + virtual void watchActor (const MWWorld::Ptr& ptr); ///< On each update look for changes in a previously registered actor and update the /// GUI accordingly. - void update (std::vector >& movement, float duration, - bool paused); + virtual void update (std::vector >& movement, + float duration, bool paused); ///< Update actor stats and store desired velocity vectors in \a movement /// /// \param paused In game type does not currently advance (this usually means some GUI /// component is up). - void setPlayerName (const std::string& name); + virtual void setPlayerName (const std::string& name); ///< Set player name. - void setPlayerRace (const std::string& id, bool male); + virtual void setPlayerRace (const std::string& id, bool male); ///< Set player race. - void setPlayerBirthsign (const std::string& id); + virtual void setPlayerBirthsign (const std::string& id); ///< Set player birthsign. - void setPlayerClass (const std::string& id); + virtual void setPlayerClass (const std::string& id); ///< Set player class to stock class. - void setPlayerClass (const ESM::Class& class_); + virtual void setPlayerClass (const ESM::Class& class_); ///< Set player class to custom class. }; } diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index ec557e35c7..9318fd6f13 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -3,8 +3,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" /// FIXME #include "../mwbase/soundmanager.hpp" - -#include "../mwmechanics/mechanicsmanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwgui/window_manager.hpp" @@ -154,7 +153,7 @@ namespace MWWorld } world->getPlayer().setCell(cell); - MWMechanics::MechanicsManager *mechMgr = + MWBase::MechanicsManager *mechMgr = MWBase::Environment::get().getMechanicsManager(); mechMgr->addActor(player); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index d9fbc5b77d..3a9547a445 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -5,12 +5,11 @@ #include "../mwbase/environment.hpp" #include "../mwbase/soundmanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwrender/sky.hpp" #include "../mwrender/player.hpp" -#include "../mwmechanics/mechanicsmanager.hpp" - #include "../mwgui/window_manager.hpp" #include "player.hpp" @@ -575,7 +574,7 @@ namespace MWWorld mRendering->moveObjectToCell(copy, vec, currCell); if (MWWorld::Class::get(ptr).isActor()) { - MWMechanics::MechanicsManager *mechMgr = + MWBase::MechanicsManager *mechMgr = MWBase::Environment::get().getMechanicsManager(); mechMgr->removeActor(ptr); @@ -604,11 +603,11 @@ namespace MWWorld if (cell->isExterior()) { int cellX, cellY; positionToIndex(x, y, cellX, cellY); - + cell = getExterior(cellX, cellY); } moveObject(ptr, *cell, x, y, z); - + return cell != ptr.getCell(); } From 0231533d05eaf715031cdfc155c1e2045aa6c630 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 11 Aug 2012 17:53:39 +0200 Subject: [PATCH 2/2] Issue #107: InputManager is accessed only through the interface class from now on --- apps/openmw/CMakeLists.txt | 3 +- apps/openmw/engine.cpp | 2 +- apps/openmw/mwbase/environment.cpp | 7 ++-- apps/openmw/mwbase/environment.hpp | 12 ++---- apps/openmw/mwbase/inputmanager.hpp | 37 +++++++++++++++++++ apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 1 - apps/openmw/mwgui/bookwindow.cpp | 2 - apps/openmw/mwgui/container.cpp | 2 - apps/openmw/mwgui/scrollwindow.cpp | 2 - apps/openmw/mwgui/settingswindow.cpp | 3 +- apps/openmw/mwgui/window_manager.cpp | 3 +- .../{inputmanager.cpp => inputmanagerimp.cpp} | 6 +-- .../{inputmanager.hpp => inputmanagerimp.hpp} | 20 +++++----- apps/openmw/mwrender/renderingmanager.cpp | 2 +- apps/openmw/mwscript/controlextensions.cpp | 10 +---- apps/openmw/mwscript/guiextensions.cpp | 1 - apps/openmw/mwscript/interpretercontext.cpp | 2 - 17 files changed, 65 insertions(+), 50 deletions(-) create mode 100644 apps/openmw/mwbase/inputmanager.hpp rename apps/openmw/mwinput/{inputmanager.cpp => inputmanagerimp.cpp} (98%) rename apps/openmw/mwinput/{inputmanager.hpp => inputmanagerimp.hpp} (62%) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index f4454a216c..7bd7f1882e 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -20,7 +20,7 @@ add_openmw_dir (mwrender ) add_openmw_dir (mwinput - inputmanager + inputmanagerimp mouselookevent ) @@ -66,6 +66,7 @@ add_openmw_dir (mwmechanics add_openmw_dir (mwbase environment world scriptmanager dialoguemanager journal soundmanager mechanicsmanager + inputmanager ) # Main executable diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 98fee43841..c484c22ea2 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -13,7 +13,7 @@ #include #include -#include "mwinput/inputmanager.hpp" +#include "mwinput/inputmanagerimp.hpp" #include "mwgui/window_manager.hpp" #include "mwgui/cursorreplace.hpp" diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index f75c3588fc..28e71fcf0c 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -3,14 +3,13 @@ #include -#include "../mwinput/inputmanager.hpp" - #include "world.hpp" #include "scriptmanager.hpp" #include "dialoguemanager.hpp" #include "journal.hpp" #include "soundmanager.hpp" #include "mechanicsmanager.hpp" +#include "inputmanager.hpp" MWBase::Environment *MWBase::Environment::sThis = 0; @@ -63,7 +62,7 @@ void MWBase::Environment::setJournal (Journal *journal) mJournal = journal; } -void MWBase::Environment::setInputManager (MWInput::MWInputManager *inputManager) +void MWBase::Environment::setInputManager (InputManager *inputManager) { mInputManager = inputManager; } @@ -115,7 +114,7 @@ MWBase::Journal *MWBase::Environment::getJournal() const return mJournal; } -MWInput::MWInputManager *MWBase::Environment::getInputManager() const +MWBase::InputManager *MWBase::Environment::getInputManager() const { assert (mInputManager); return mInputManager; diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index f2e7249d3e..4a21b57a4e 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -6,11 +6,6 @@ namespace MWGui class WindowManager; } -namespace MWInput -{ - struct MWInputManager; -} - namespace MWBase { class World; @@ -19,6 +14,7 @@ namespace MWBase class Journal; class SoundManager; class MechanicsManager; + class InputManager; /// \brief Central hub for mw-subsystems /// @@ -37,7 +33,7 @@ namespace MWBase MechanicsManager *mMechanicsManager; DialogueManager *mDialogueManager; Journal *mJournal; - MWInput::MWInputManager *mInputManager; + InputManager *mInputManager; float mFrameDuration; Environment (const Environment&); @@ -66,7 +62,7 @@ namespace MWBase void setJournal (Journal *journal); - void setInputManager (MWInput::MWInputManager *inputManager); + void setInputManager (InputManager *inputManager); void setFrameDuration (float duration); ///< Set length of current frame in seconds. @@ -85,7 +81,7 @@ namespace MWBase Journal *getJournal() const; - MWInput::MWInputManager *getInputManager() const; + InputManager *getInputManager() const; float getFrameDuration() const; diff --git a/apps/openmw/mwbase/inputmanager.hpp b/apps/openmw/mwbase/inputmanager.hpp new file mode 100644 index 0000000000..d865bfb0ec --- /dev/null +++ b/apps/openmw/mwbase/inputmanager.hpp @@ -0,0 +1,37 @@ +#ifndef GAME_MWBASE_INPUTMANAGER_H +#define GAME_MWBASE_INPUTMANAGER_H + +#include + +#include + +namespace MWBase +{ + /// \brief Interface for input manager (implemented in MWInput) + class InputManager + { + InputManager (const InputManager&); + ///< not implemented + + InputManager& operator= (const InputManager&); + ///< not implemented + + public: + + InputManager() {} + + virtual ~InputManager() {} + + virtual void update() = 0; + + virtual void changeInputMode(bool guiMode) = 0; + + virtual void processChangedSettings(const Settings::CategorySettingVector& changed) = 0; + + virtual void setDragDrop(bool dragDrop) = 0; + + virtual void toggleControlSwitch (const std::string& sw, bool value) = 0; + }; +} + +#endif diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 644da49e27..251577d3bf 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -19,7 +19,6 @@ #include "../mwworld/player.hpp" #include "../mwworld/containerstore.hpp" -#include "../mwinput/inputmanager.hpp" #include "../mwgui/dialogue.hpp" #include "../mwgui/window_manager.hpp" diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index 19a5e93985..92f0226ed1 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -6,8 +6,6 @@ #include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" -#include "../mwinput/inputmanager.hpp" - #include "../mwworld/actiontake.hpp" #include "../mwworld/player.hpp" diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 66dea08497..89cd102339 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -19,8 +19,6 @@ #include "../mwclass/container.hpp" -#include "../mwinput/inputmanager.hpp" - #include "window_manager.hpp" #include "widgets.hpp" #include "countdialog.hpp" diff --git a/apps/openmw/mwgui/scrollwindow.cpp b/apps/openmw/mwgui/scrollwindow.cpp index 67a02e53b4..fb2239c6da 100644 --- a/apps/openmw/mwgui/scrollwindow.cpp +++ b/apps/openmw/mwgui/scrollwindow.cpp @@ -4,8 +4,6 @@ #include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" -#include "../mwinput/inputmanager.hpp" - #include "../mwworld/actiontake.hpp" #include "../mwworld/player.hpp" diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index d1e1f7095e..06177aaa8d 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -13,11 +13,10 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" +#include "../mwbase/inputmanager.hpp" #include "../mwrender/renderingmanager.hpp" -#include "../mwinput/inputmanager.hpp" - #include "window_manager.hpp" #include "confirmationdialog.hpp" diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 45aee089cd..b4eaaacf49 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -21,10 +21,9 @@ #include "alchemywindow.hpp" #include "spellwindow.hpp" -#include "../mwinput/inputmanager.hpp" - #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" +#include "../mwbase/inputmanager.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/cellstore.hpp" diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp similarity index 98% rename from apps/openmw/mwinput/inputmanager.cpp rename to apps/openmw/mwinput/inputmanagerimp.cpp index e29e3c2683..d53e67d485 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -1,4 +1,4 @@ -#include "inputmanager.hpp" +#include "inputmanagerimp.hpp" #include @@ -501,8 +501,8 @@ private: impl->adjustMouseRegion(Settings::Manager::getInt("resolution x", "Video"), Settings::Manager::getInt("resolution y", "Video")); } - void MWInputManager::toggleControlSwitch(std::string sw, bool value) + void MWInputManager::toggleControlSwitch (const std::string& sw, bool value) { - impl->toggleControlSwitch(sw, value); + impl->toggleControlSwitch(sw, value); } } diff --git a/apps/openmw/mwinput/inputmanager.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp similarity index 62% rename from apps/openmw/mwinput/inputmanager.hpp rename to apps/openmw/mwinput/inputmanagerimp.hpp index 2486f82d67..862c4fd207 100644 --- a/apps/openmw/mwinput/inputmanager.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -1,10 +1,12 @@ -#ifndef _MWINPUT_MWINPUTMANAGER_H -#define _MWINPUT_MWINPUTMANAGER_H +#ifndef _MWINPUT_MWINPUTMANAGERIMP_H +#define _MWINPUT_MWINPUTMANAGERIMP_H #include "../mwgui/mode.hpp" #include +#include "../mwbase/inputmanager.hpp" + namespace OEngine { namespace Render @@ -38,7 +40,7 @@ namespace MWInput This class is just an interface. All the messy details are in inputmanager.cpp. */ - struct MWInputManager + struct MWInputManager : public MWBase::InputManager { InputImpl *impl; @@ -48,17 +50,17 @@ namespace MWInput MWGui::WindowManager &_windows, bool debug, OMW::Engine& engine); - ~MWInputManager(); + virtual ~MWInputManager(); - void update(); + virtual void update(); - void changeInputMode(bool guiMode); + virtual void changeInputMode(bool guiMode); - void processChangedSettings(const Settings::CategorySettingVector& changed); + virtual void processChangedSettings(const Settings::CategorySettingVector& changed); - void setDragDrop(bool dragDrop); + virtual void setDragDrop(bool dragDrop); - void toggleControlSwitch(std::string sw, bool value); + virtual void toggleControlSwitch (const std::string& sw, bool value); }; } #endif diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 8719557ca3..590c177097 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -22,12 +22,12 @@ #include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone #include "../mwbase/environment.hpp" +#include "../mwbase/inputmanager.hpp" // FIXME #include "../mwworld/ptr.hpp" #include "../mwworld/player.hpp" #include "../mwgui/window_manager.hpp" // FIXME -#include "../mwinput/inputmanager.hpp" // FIXME #include "shadows.hpp" #include "localmap.hpp" diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index 084698c5b5..bd14e7b8dd 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -8,19 +8,16 @@ #include #include "../mwbase/environment.hpp" +#include "../mwbase/inputmanager.hpp" #include "../mwworld/player.hpp" #include "../mwworld/class.hpp" #include "../mwmechanics/npcstats.hpp" -#include "../mwinput/inputmanager.hpp" - #include "interpretercontext.hpp" #include "ref.hpp" -#include - namespace MWScript { namespace Control @@ -41,11 +38,6 @@ namespace MWScript MWBase::Environment::get() .getInputManager() ->toggleControlSwitch(mControl, mEnable); - - if (mEnable) - std::cout << "enable: " << mControl << std::endl; - else - std::cout << "disable: " << mControl << std::endl; } }; diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 8e5897298b..3d14692d9a 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -10,7 +10,6 @@ #include "../mwbase/environment.hpp" #include "../mwgui/window_manager.hpp" -#include "../mwinput/inputmanager.hpp" #include "interpretercontext.hpp" diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 327eed9136..131d7865b5 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -15,8 +15,6 @@ #include "../mwgui/window_manager.hpp" -#include "../mwinput/inputmanager.hpp" - #include "locals.hpp" #include "globalscripts.hpp"