1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-05 18:45:34 +00:00

Merge remote branch 'star/master' into movement

This commit is contained in:
Marc Zinnschlag 2011-01-18 15:15:00 +01:00
commit eb5e4427c1
5 changed files with 134 additions and 14 deletions

View file

@ -48,6 +48,26 @@ namespace MWInput
A_Activate, A_Activate,
A_Use, //Use weapon, spell, etc.
A_Jump,
A_AutoMove, //Toggle Auto-move forward
A_Rest, //Rest
A_Journal, //Journal
A_Weapon, //Draw/Sheath weapon
A_Spell, //Ready/Unready Casting
A_AlwaysRun, //Toggle Always Run
A_CycleSpellLeft, //cycling through spells
A_CycleSpellRight,
A_CycleWeaponLeft,//Cycling through weapons
A_CycleWeaponRight,
A_ToggleSneak, //Toggles Sneak, add Push-Sneak later
A_ToggleWalk, //Toggle Walking/Running
A_QuickSave,
A_QuickLoad,
A_QuickMenu,
A_GameMenu,
A_LAST // Marker for the last item A_LAST // Marker for the last item
}; };
@ -68,11 +88,14 @@ namespace MWInput
// Count screenshots. // Count screenshots.
int shotCount; int shotCount;
/* InputImpl Methods */
// Write screenshot to file. // Write screenshot to file.
void screenshot() void screenshot()
{ {
// Find the first unused filename.
// // Find the first unused filename with a do-while
char buf[50]; char buf[50];
do do
{ {
@ -82,8 +105,8 @@ namespace MWInput
ogre.screenshot(buf); ogre.screenshot(buf);
} }
// 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;
@ -118,6 +141,21 @@ namespace MWInput
mEngine.activate(); mEngine.activate();
} }
void toggleAutoMove()
{
if (player.getAutoMove() == false)
{
player.setAutoMove(true);
} else {
player.setAutoMove(false);
}
}
void toggleWalking()
{
player.setisWalking(true);
}
// Exit program now button (which is disabled in GUI mode) // Exit program now button (which is disabled in GUI mode)
void exitNow() void exitNow()
{ {
@ -159,7 +197,10 @@ namespace MWInput
"Toggle console"); "Toggle console");
disp->funcs.bind(A_Activate, boost::bind(&InputImpl::activate, this), disp->funcs.bind(A_Activate, boost::bind(&InputImpl::activate, this),
"Activate"); "Activate");
disp->funcs.bind(A_AutoMove, boost::bind(&InputImpl::toggleAutoMove, this),
"Auto Move");
disp->funcs.bind(A_ToggleWalk, boost::bind(&InputImpl::toggleWalking, this),
"Toggle Walk/Run");
// Add the exit listener // Add the exit listener
ogre.getRoot()->addFrameListener(&exit); ogre.getRoot()->addFrameListener(&exit);
@ -195,6 +236,7 @@ namespace MWInput
**********************************/ **********************************/
// Key bindings for keypress events // Key bindings for keypress events
// NOTE: These keys do not require constant polling - use in conjuction with variables in loops.
disp->bind(A_Quit, KC_Q); disp->bind(A_Quit, KC_Q);
disp->bind(A_Quit, KC_ESCAPE); disp->bind(A_Quit, KC_ESCAPE);
@ -202,8 +244,12 @@ namespace MWInput
disp->bind(A_Inventory, KC_I); disp->bind(A_Inventory, KC_I);
disp->bind(A_Console, KC_F1); disp->bind(A_Console, KC_F1);
disp->bind(A_Activate, KC_SPACE); disp->bind(A_Activate, KC_SPACE);
disp->bind(A_AutoMove, KC_Z);
disp->bind(A_ToggleSneak, KC_X);
disp->bind(A_ToggleWalk, KC_C);
// Key bindings for polled keys // Key bindings for polled keys
// NOTE: These keys are constantly being polled. Only add keys that must be checked each frame.
// Arrow keys // Arrow keys
poller.bind(A_MoveLeft, KC_LEFT); poller.bind(A_MoveLeft, KC_LEFT);
@ -222,7 +268,7 @@ namespace MWInput
poller.bind(A_MoveDown, KC_LCONTROL); poller.bind(A_MoveDown, KC_LCONTROL);
} }
// Used to check for movement keys //NOTE: Used to check for movement keys
bool frameStarted(const Ogre::FrameEvent &evt) bool frameStarted(const Ogre::FrameEvent &evt)
{ {
// Tell OIS to handle all input events // Tell OIS to handle all input events
@ -239,13 +285,40 @@ namespace MWInput
// Disable movement in Gui mode // Disable movement in Gui mode
if(windows.isGuiMode()) return true; if(windows.isGuiMode()) return true;
float speed = 300 * evt.timeSinceLastFrame; float speed = 300 * evt.timeSinceLastFrame; //placeholder player speed?
//float TESTwalkSpeed = 100 * evt.timeSinceLastFrame; //How about another?
float moveX = 0, moveY = 0, moveZ = 0; float moveX = 0, moveY = 0, moveZ = 0;
if(poller.isDown(A_MoveLeft)) moveX -= speed; //execute Automove - condition checked in function
if(poller.isDown(A_MoveRight)) moveX += speed; player.executeAutoMove((float)evt.timeSinceLastFrame); //or since last frame?
if(poller.isDown(A_MoveForward)) moveZ -= speed;
if(poller.isDown(A_MoveBackward)) moveZ += speed; //Poll and execute movement keys - will disable automove if pressed.
if(poller.isDown(A_MoveLeft))
{
player.setAutoMove(false);
moveX -= speed;
}
if(poller.isDown(A_MoveRight))
{
player.setAutoMove(false);
moveX += speed;
}
if(poller.isDown(A_MoveForward))
{
player.setAutoMove(false);
moveZ -= speed;
}
if(poller.isDown(A_MoveBackward))
{
player.setAutoMove(false);
moveZ += speed;
}
// TODO: These should be enabled for floating modes (like // TODO: These should be enabled for floating modes (like
// swimming and levitation) and disabled for everything else. // swimming and levitation) and disabled for everything else.
@ -288,6 +361,7 @@ namespace MWInput
} }
}; };
/***CONSTRUCTOR***/
MWInputManager::MWInputManager(OEngine::Render::OgreRenderer &ogre, MWInputManager::MWInputManager(OEngine::Render::OgreRenderer &ogre,
MWWorld::Player &player, MWWorld::Player &player,
MWGui::WindowManager &windows, MWGui::WindowManager &windows,
@ -297,6 +371,7 @@ namespace MWInput
impl = new InputImpl(ogre,player,windows,debug, engine); impl = new InputImpl(ogre,player,windows,debug, engine);
} }
/***DESTRUCTOR***/
MWInputManager::~MWInputManager() MWInputManager::~MWInputManager()
{ {
delete impl; delete impl;

View file

@ -16,6 +16,8 @@ namespace MWWorld
mRace = player->race; mRace = player->race;
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0; mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
mClass = new ESM::Class (*world.getStore().classes.find (player->cls)); mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
mAutoMove = false;
misWalking = false;
} }
Player::~Player() Player::~Player()
@ -61,4 +63,5 @@ namespace MWWorld
delete mClass; delete mClass;
mClass = new_class; mClass = new_class;
} }
} }

View file

@ -31,6 +31,9 @@ namespace MWWorld
ESM::Class *mClass; ESM::Class *mClass;
bool mCollisionMode; bool mCollisionMode;
bool mAutoMove;
bool misWalking; //Testing...
public: public:
Player(MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world); Player(MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world);
@ -108,6 +111,45 @@ namespace MWWorld
{ {
mCollisionMode = !mCollisionMode; mCollisionMode = !mCollisionMode;
} }
bool getAutoMove()
{
return mAutoMove;
}
void setAutoMove(bool setMe)
{
mAutoMove = setMe;
}
//NOTE: we don't have speed being calculated yet, so for now this function only requires a frame duration.
/// <param name="duration">float value representing time since last call</param>
void executeAutoMove(float duration)
{
float X_Val = 0.0f;
float Y_Val = 0.0f;
float Z_Val = 300.0f * duration * -1.0f;
if (mAutoMove == true)
{
//if player is running
//Make player go at full speed
moveRel(X_Val, Y_Val, Z_Val);
//else go forward at walk speed.
}
}
bool getisWalking()
{
return misWalking;
}
void setisWalking(bool setMe)
{
misWalking = setMe;
}
}; };
} }
#endif #endif

@ -1 +1 @@
Subproject commit 12e5c8d704b959c78a62931b2360d18092b82c3d Subproject commit 7345f2307f3ce6682a4044b98a811fac2cb7c4f0

@ -1 +1 @@
Subproject commit 7185eab18c29a0a5e03e44690d6bd8ece7e3792b Subproject commit 377e7d71ceea5a1ca166b8df9a03a5b68df83bc5