diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index 3721d1043..bd27de029 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -65,6 +65,8 @@ namespace MWInput A_QuickLoad, A_QuickMenu, A_GameMenu, + A_ToggleWeapon, + A_ToggleSpell, A_LAST // Marker for the last item }; @@ -86,6 +88,38 @@ namespace MWInput /* InputImpl Methods */ + void toggleSpell() + { + DrawState state = player.getDrawState(); + if(state == DrawState_Weapon || state == DrawState_Nothing) + { + player.setDrawState(DrawState_Spell); + std::cout << "Player has now readied his hands for spellcasting!\n"; + } + else + { + player.setDrawState(DrawState_Nothing); + std::cout << "Player does not have any kind of attack ready now.\n"; + } + + } + + void toggleWeapon() + { + DrawState state = player.getDrawState(); + if(state == DrawState_Spell || state == DrawState_Nothing) + { + player.setDrawState(DrawState_Weapon); + std::cout << "Player is now drawing his weapon.\n"; + } + else + { + player.setDrawState(DrawState_Nothing); + std::cout << "Player does not have any kind of attack ready now.\n"; + } + + } + void screenshot() { mEngine.screenshot(); @@ -197,7 +231,10 @@ namespace MWInput "Auto Move"); disp->funcs.bind(A_ToggleWalk, boost::bind(&InputImpl::toggleWalking, this), "Toggle Walk/Run"); - + disp->funcs.bind(A_ToggleWeapon,boost::bind(&InputImpl::toggleWeapon,this), + "Draw Weapon"); + disp->funcs.bind(A_ToggleSpell,boost::bind(&InputImpl::toggleSpell,this), + "Ready hands"); // Add the exit listener ogre.getRoot()->addFrameListener(&exit); @@ -242,6 +279,8 @@ namespace MWInput disp->bind(A_AutoMove, KC_Z); disp->bind(A_ToggleSneak, KC_X); disp->bind(A_ToggleWalk, KC_C); + disp->bind(A_ToggleWeapon,KC_F); + disp->bind(A_ToggleSpell,KC_R); // Key bindings for polled keys // NOTE: These keys are constantly being polled. Only add keys that must be checked each frame. diff --git a/apps/openmw/mwmechanics/drawstate.hpp b/apps/openmw/mwmechanics/drawstate.hpp new file mode 100644 index 000000000..ded25f8d5 --- /dev/null +++ b/apps/openmw/mwmechanics/drawstate.hpp @@ -0,0 +1,11 @@ +#ifndef GAME_MWMECHANICS_DRAWSTATE_H +#define GAME_MWMECHANICS_DRAWSTATE_H + +enum DrawState +{ + DrawState_Weapon = 0, + DrawState_Spell = 1, + DrawState_Nothing = 2, +}; + +#endif diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index aeb5f56d5..7c5d37972 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -4,13 +4,13 @@ #include #include "stat.hpp" +#include "drawstate.hpp" namespace MWMechanics { /// \brief Additional stats for NPCs /// /// For non-NPC-specific stats, see the CreatureStats struct. - struct NpcStats { // NPCs other than the player can only have one faction. But for the sake of consistency @@ -24,9 +24,10 @@ namespace MWMechanics bool mRun; bool mSneak; bool mCombat; + DrawState mDrawState; NpcStats() : mForceRun (false), mForceSneak (false), mRun (false), mSneak (false), - mCombat (false) {} + mCombat (false) , mDrawState(DrawState_Nothing) {} }; } diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index d3a0a34ae..d49b98d0f 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -26,7 +26,9 @@ namespace MWWorld { } - void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const{ + + void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + { } diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 5bfb82138..d24780ec1 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -4,6 +4,7 @@ #include "../mwrender/player.hpp" #include "../mwmechanics/movement.hpp" +#include "../mwmechanics/npcstats.hpp" #include "world.hpp" #include "class.hpp" @@ -48,6 +49,12 @@ namespace MWWorld mClass = new_class; } + void Player::setDrawState(const DrawState& value) + { + MWWorld::Ptr ptr = getPlayer(); + MWWorld::Class::get(ptr).getNpcStats(ptr).mDrawState = value; + } + void Player::setAutoMove (bool enable) { MWWorld::Ptr ptr = getPlayer(); @@ -89,4 +96,10 @@ namespace MWWorld MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Run, !running); } + + DrawState Player::getDrawState() + { + MWWorld::Ptr ptr = getPlayer(); + return MWWorld::Class::get(ptr).getNpcStats(ptr).mDrawState; + } } diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index 01c71da43..8dcd9fcc6 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -8,6 +8,8 @@ #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" +#include "../mwmechanics/drawstate.hpp" + namespace MWRender { class Player; @@ -18,7 +20,7 @@ namespace MWWorld class World; /// \brief NPC object representing the player and additional player data - class Player + class Player { ESMS::LiveCellRef mPlayer; MWWorld::Ptr::CellStore *mCellStore; @@ -31,7 +33,6 @@ namespace MWWorld ESM::Class *mClass; bool mAutoMove; int mForwardBackward; - public: Player(MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world); @@ -76,6 +77,8 @@ namespace MWWorld void setClass (const ESM::Class& class_); + void setDrawState(const DrawState& state); + std::string getName() const { return mName; @@ -106,6 +109,8 @@ namespace MWWorld return mAutoMove; } + DrawState getDrawState(); + void setAutoMove (bool enable); void setLeftRight (int value);