1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

Merge branch 'decouple' of https://github.com/zinnschlag/openmw into inputsystem

This commit is contained in:
scrawl 2012-08-12 15:45:32 +02:00
commit 12a5bd1208
28 changed files with 185 additions and 102 deletions

View File

@ -20,7 +20,7 @@ add_openmw_dir (mwrender
)
add_openmw_dir (mwinput
inputmanager
inputmanagerimp
mouselookevent
)
@ -60,12 +60,13 @@ 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
inputmanager
)
# Main executable

View File

@ -13,7 +13,7 @@
#include <components/nifbullet/bullet_nif_loader.hpp>
#include <components/nifogre/ogre_nif_loader.hpp>
#include "mwinput/inputmanager.hpp"
#include "mwinput/inputmanagerimp.hpp"
#include "mwgui/window_manager.hpp"
#include "mwgui/cursorreplace.hpp"
@ -32,7 +32,7 @@
#include "mwdialogue/dialoguemanagerimp.hpp"
#include "mwdialogue/journalimp.hpp"
#include "mwmechanics/mechanicsmanager.hpp"
#include "mwmechanics/mechanicsmanagerimp.hpp"
void OMW::Engine::executeLocalScripts()

View File

@ -3,15 +3,13 @@
#include <cassert>
#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"
#include "inputmanager.hpp"
MWBase::Environment *MWBase::Environment::sThis = 0;
@ -49,7 +47,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;
}
@ -64,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;
}
@ -98,7 +96,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;
@ -116,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;

View File

@ -6,16 +6,6 @@ namespace MWGui
class WindowManager;
}
namespace MWMechanics
{
class MechanicsManager;
}
namespace MWInput
{
struct MWInputManager;
}
namespace MWBase
{
class World;
@ -23,6 +13,8 @@ namespace MWBase
class DialogueManager;
class Journal;
class SoundManager;
class MechanicsManager;
class InputManager;
/// \brief Central hub for mw-subsystems
///
@ -38,10 +30,10 @@ namespace MWBase
SoundManager *mSoundManager;
ScriptManager *mScriptManager;
MWGui::WindowManager *mWindowManager;
MWMechanics::MechanicsManager *mMechanicsManager;
MechanicsManager *mMechanicsManager;
DialogueManager *mDialogueManager;
Journal *mJournal;
MWInput::MWInputManager *mInputManager;
InputManager *mInputManager;
float mFrameDuration;
Environment (const Environment&);
@ -64,13 +56,13 @@ namespace MWBase
void setWindowManager (MWGui::WindowManager *windowManager);
void setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager);
void setMechanicsManager (MechanicsManager *mechanicsManager);
void setDialogueManager (DialogueManager *dialogueManager);
void setJournal (Journal *journal);
void setInputManager (MWInput::MWInputManager *inputManager);
void setInputManager (InputManager *inputManager);
void setFrameDuration (float duration);
///< Set length of current frame in seconds.
@ -79,17 +71,17 @@ 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;
Journal *getJournal() const;
MWInput::MWInputManager *getInputManager() const;
InputManager *getInputManager() const;
float getFrameDuration() const;

View File

@ -0,0 +1,37 @@
#ifndef GAME_MWBASE_INPUTMANAGER_H
#define GAME_MWBASE_INPUTMANAGER_H
#include <string>
#include <components/settings/settings.hpp>
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

View File

@ -0,0 +1,77 @@
#ifndef GAME_MWBASE_MECHANICSMANAGER_H
#define GAME_MWBASE_MECHANICSMANAGER_H
#include <string>
#include <vector>
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<std::pair<std::string, Ogre::Vector3> >& 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

View File

@ -4,10 +4,10 @@
#include <components/esm/loadcrea.hpp>
#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

View File

@ -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"

View File

@ -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"

View File

@ -1,6 +1,8 @@
#ifndef GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
#define GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
#include "../mwbase/dialoguemanager.hpp"
#include <components/esm/loadinfo.hpp>
#include <components/compiler/streamerrorhandler.hpp>
@ -8,8 +10,6 @@
#include "../mwscript/interpretercontext.hpp"
#include <components/compiler/output.hpp>
#include "../mwbase/dialoguemanager.hpp"
#include "../mwworld/ptr.hpp"
#include <map>

View File

@ -6,8 +6,6 @@
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwinput/inputmanager.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/player.hpp"

View File

@ -10,6 +10,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
namespace
{

View File

@ -7,7 +7,6 @@
#include "../mwbase/world.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwmechanics/stat.hpp"
namespace MWGui

View File

@ -19,8 +19,6 @@
#include "../mwclass/container.hpp"
#include "../mwinput/inputmanager.hpp"
#include "window_manager.hpp"
#include "widgets.hpp"
#include "countdialog.hpp"

View File

@ -4,8 +4,6 @@
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwinput/inputmanager.hpp"
#include "../mwworld/actiontake.hpp"
#include "../mwworld/player.hpp"

View File

@ -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"

View File

@ -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"

View File

@ -21,10 +21,9 @@
#include "alchemywindow.hpp"
#include "spellwindow.hpp"
#include "../mwmechanics/mechanicsmanager.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"

View File

@ -1,4 +1,4 @@
#include "inputmanager.hpp"
#include "inputmanagerimp.hpp"
#include <OgreRoot.h>
@ -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);
}
}

View File

@ -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 <components/settings/settings.hpp>
#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

View File

@ -1,5 +1,5 @@
#include "mechanicsmanager.hpp"
#include "mechanicsmanagerimp.hpp"
#include <components/esm_store/store.hpp>

View File

@ -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 <vector>
#include <string>
#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<std::pair<std::string, Ogre::Vector3> >& movement, float duration,
bool paused);
virtual void update (std::vector<std::pair<std::string, Ogre::Vector3> >& 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.
};
}

View File

@ -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"

View File

@ -8,19 +8,16 @@
#include <components/interpreter/opcodes.hpp>
#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 <iostream>
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;
}
};

View File

@ -10,7 +10,6 @@
#include "../mwbase/environment.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwinput/inputmanager.hpp"
#include "interpretercontext.hpp"

View File

@ -15,8 +15,6 @@
#include "../mwgui/window_manager.hpp"
#include "../mwinput/inputmanager.hpp"
#include "locals.hpp"
#include "globalscripts.hpp"

View File

@ -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"
@ -157,7 +156,7 @@ namespace MWWorld
world->rotateObject(player, x, y, z);
}
MWMechanics::MechanicsManager *mechMgr =
MWBase::MechanicsManager *mechMgr =
MWBase::Environment::get().getMechanicsManager();
mechMgr->addActor(player);

View File

@ -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"
@ -577,7 +576,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);
@ -606,11 +605,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();
}