From 6d346933db21946c68ab96b1105b1ea6f61f9b8e Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 10 Mar 2012 17:45:34 -0500 Subject: [PATCH 001/109] gus's changes --- apps/openmw/mwworld/weather.cpp | 8 ++++++++ apps/openmw/mwworld/weather.hpp | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 059b0ec1e..90afc4e78 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -21,6 +21,14 @@ const std::string WeatherGlobals::mThunderSoundID0 = "Thunder0"; const std::string WeatherGlobals::mThunderSoundID1 = "Thunder1"; const std::string WeatherGlobals::mThunderSoundID2 = "Thunder2"; const std::string WeatherGlobals::mThunderSoundID3 = "Thunder3"; +const float WeatherGlobals::mSunriseTime = 8; +const float WeatherGlobals::mSunsetTime = 18; +const float WeatherGlobals::mSunriseDuration = 2; +const float WeatherGlobals::mSunsetDuration = 2; +const float WeatherGlobals::mWeatherUpdateTime = 20.f; +const float WeatherGlobals::mThunderFrequency = .4; +const float WeatherGlobals::mThunderThreshold = 0.6; +const float WeatherGlobals::mThunderSoundDelay = 0.25; WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environment* env) : mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0), diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index 7a719252b..9353f7cd1 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -95,18 +95,18 @@ namespace MWWorld Script Color=255,20,20 */ - static const float mSunriseTime = 8; - static const float mSunsetTime = 18; - static const float mSunriseDuration = 2; - static const float mSunsetDuration = 2; + static const float mSunriseTime; + static const float mSunsetTime; + static const float mSunriseDuration; + static const float mSunsetDuration; - static const float mWeatherUpdateTime = 20.f; + static const float mWeatherUpdateTime; // morrowind sets these per-weather, but since they are only used by 'thunderstorm' // weather setting anyway, we can just as well set them globally - static const float mThunderFrequency = .4; - static const float mThunderThreshold = 0.6; - static const float mThunderSoundDelay = 0.25; + static const float mThunderFrequency; + static const float mThunderThreshold; + static const float mThunderSoundDelay; static const std::string mThunderSoundID0; static const std::string mThunderSoundID1; static const std::string mThunderSoundID2; From 2b3e75718c1bbe8f4408dfa85fb9c07faac15eac Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Mon, 19 Mar 2012 20:03:48 -0400 Subject: [PATCH 002/109] Updating everything --- apps/openmw/mwworld/physicssystem.cpp | 56 ++++++++++++++++++++++----- apps/openmw/mwworld/physicssystem.hpp | 2 + libs/openengine/bullet/trace.cpp | 4 +- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index bb2f9f8a9..11a43c7d3 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -13,6 +13,7 @@ #include "OgreTextureManager.h" + using namespace Ogre; namespace MWWorld { @@ -20,9 +21,11 @@ namespace MWWorld PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend) : mRender(_rend), mEngine(0), mFreeFly (true) { + playerphysics = new playerMove; // Create physics. shapeLoader is deleted by the physic engine NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader(); mEngine = new OEngine::Physic::PhysicEngine(shapeLoader); + playerphysics->mEngine = mEngine; } PhysicsSystem::~PhysicsSystem() @@ -68,55 +71,90 @@ namespace MWWorld { //set the DebugRenderingMode. To disable it,set it to 0 //eng->setDebugRenderingMode(1); - + + //set the walkdirection to 0 (no movement) for every actor) for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) { OEngine::Physic::PhysicActor* act = it->second; act->setWalkDirection(btVector3(0,0,0)); } - + playerMove::playercmd& pm_ref = playerphysics->cmd; + + pm_ref.rightmove = 0; + pm_ref.forwardmove = 0; + pm_ref.upmove = 0; + //playerphysics->ps.move_type = PM_NOCLIP; for (std::vector >::const_iterator iter (actors.begin()); iter!=actors.end(); ++iter) { OEngine::Physic::PhysicActor* act = mEngine->getCharacter(iter->first); - + //if(iter->first == "player") + // std::cout << "This is player\n"; //dirty stuff to get the camera orientation. Must be changed! Ogre::SceneNode *sceneNode = mRender.getScene()->getSceneNode (iter->first); Ogre::Vector3 dir; Ogre::Node* yawNode = sceneNode->getChildIterator().getNext(); Ogre::Node* pitchNode = yawNode->getChildIterator().getNext(); + Ogre::Quaternion yawQuat = yawNode->getOrientation(); + Ogre::Quaternion pitchQuat = pitchNode->getOrientation(); + Ogre::Quaternion both = yawQuat * pitchQuat; + + playerphysics->ps.viewangles.x = 0; + playerphysics->ps.viewangles.z = 0; + playerphysics->ps.viewangles.y = both.getYaw().valueDegrees() *-1 + 90; + //playerphysics->ps.viewangles.z = both.getPitch().valueDegrees(); + + if(mFreeFly) { - Ogre::Quaternion yawQuat = yawNode->getOrientation(); - Ogre::Quaternion pitchQuat = pitchNode->getOrientation(); + Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); + pm_ref.rightmove = -dir1.x; + pm_ref.forwardmove = dir1.z; + + + + //std::cout << "Current angle" << yawQuat.getYaw().valueDegrees() - 90<< "\n"; + //playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees(); + //std::cout << "Pitch: " << yawQuat.getPitch() << "Yaw:" << yawQuat.getYaw() << "Roll: " << yawQuat.getRoll() << "\n"; dir = 0.07*(yawQuat*pitchQuat*dir1); } else { Ogre::Quaternion quat = yawNode->getOrientation(); Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); + pm_ref.rightmove = -dir1.x; + pm_ref.forwardmove = dir1.z; + dir = 0.025*(quat*dir1); } + Pmove(playerphysics); //set the walk direction act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y)); } - mEngine->stepSimulation(duration); - + //mEngine->stepSimulation(duration); + Pmove(playerphysics); std::vector< std::pair > response; for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) { btVector3 newPos = it->second->getPosition(); + Ogre::Vector3 coord(newPos.x(), newPos.y(), newPos.z()); - + if(it->first == "player"){ + + coord = playerphysics->ps.origin; + //std::cout << "Coord" << coord << "\n"; + coord = Ogre::Vector3(coord.x, coord.z, coord.y); //x, z, -y + + } response.push_back(std::pair(it->first, coord)); } + return response; } - void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh, const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position) { diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index 78cbde083..4fc8bee36 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -5,6 +5,7 @@ #include #include #include "ptr.hpp" +#include namespace MWWorld { @@ -49,6 +50,7 @@ namespace MWWorld OEngine::Render::OgreRenderer &mRender; OEngine::Physic::PhysicEngine* mEngine; bool mFreeFly; + playerMove* playerphysics; PhysicsSystem (const PhysicsSystem&); PhysicsSystem& operator= (const PhysicsSystem&); diff --git a/libs/openengine/bullet/trace.cpp b/libs/openengine/bullet/trace.cpp index 6baec8c83..49e12064e 100644 --- a/libs/openengine/bullet/trace.cpp +++ b/libs/openengine/bullet/trace.cpp @@ -32,7 +32,7 @@ void newtrace(traceResults* const results, const Ogre::Vector3& start, const Ogr Ogre::Vector3 endReplace = startReplace; endReplace.y -= .25; - const bool hasHit = NewPhysicsTrace(&out, startReplace, endReplace, BBHalfExtents, Ogre::Vector3(0.0f, rotation, 0.0f), isInterior, enginePass); + const bool hasHit = NewPhysicsTrace(&out, start, end, BBHalfExtents, Ogre::Vector3(0.0f, rotation, 0.0f), isInterior, enginePass); if(hasHit) std::cout << "Has hit\n"; if (out.fraction < 0.001f) @@ -102,7 +102,7 @@ const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3& const btVector3 btend(end.x, end.y, end.z); const btQuaternion btrot(rotation.y, rotation.x, rotation.z); - const btBoxShape newshape(btVector3(1000, 1000, 1000) ); + const btBoxShape newshape(btVector3(BBHalfExtents.x, BBHalfExtents.y, BBHalfExtents.z)); const btTransform from(btrot, btstart); const btTransform to(btrot, btend); float x = from.getOrigin().getX(); From 18a139cd66dada5a42b93a7f26bb46c7929fa744 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 24 Mar 2012 22:03:08 -0400 Subject: [PATCH 003/109] adding up and down move buttons --- apps/openmw/mwclass/npc.cpp | 5 +- apps/openmw/mwinput/inputmanager.cpp | 16 + apps/openmw/mwmechanics/movement.hpp | 3 +- apps/openmw/mwrender/objects.cpp | 2 + apps/openmw/mwworld/physicssystem.cpp | 15 +- apps/openmw/mwworld/player.cpp | 9 + apps/openmw/mwworld/player.hpp | 1 + apps/openmw/physicssystem.cpp | 225 +++++++ libs/openengine/bullet/physic.cpp | 4 +- libs/openengine/bullet/pmove.cpp | 27 +- libs/openengine/bullet/pmove.h | 4 +- libs/openengine/bullet/trace.cpp | 4 +- libs/openengine/bullet/weather.cpp | 811 ++++++++++++++++++++++++++ libs/openengine/bullet/weather.hpp | 272 +++++++++ 14 files changed, 1374 insertions(+), 24 deletions(-) create mode 100644 apps/openmw/physicssystem.cpp create mode 100644 libs/openengine/bullet/weather.cpp create mode 100644 libs/openengine/bullet/weather.hpp diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 83a94d27d..522fce3a3 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -269,8 +269,9 @@ namespace MWClass { Ogre::Vector3 vector (0, 0, 0); - vector.x = - getMovementSettings (ptr).mLeftRight * 200; - vector.y = getMovementSettings (ptr).mForwardBackward * 200; + vector.x = - getMovementSettings (ptr).mLeftRight * 127; + vector.y = getMovementSettings (ptr).mForwardBackward * 127; + vector.z = getMovementSettings(ptr).mUpDown * 127; if (getStance (ptr, Run, false)) vector *= 2; diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index 88534ddda..074f8a906 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -60,6 +60,7 @@ namespace MWInput A_CycleWeaponRight, A_ToggleSneak, //Toggles Sneak, add Push-Sneak later A_ToggleWalk, //Toggle Walking/Running + A_Crouch, A_QuickSave, A_QuickLoad, @@ -259,6 +260,9 @@ namespace MWInput poller.bind(A_MoveRight, KC_D); poller.bind(A_MoveForward, KC_W); poller.bind(A_MoveBackward, KC_S); + + poller.bind(A_Jump, KC_E); + poller.bind(A_Crouch, KC_LCONTROL); } //NOTE: Used to check for movement keys @@ -306,6 +310,18 @@ namespace MWInput else player.setForwardBackward (0); + if (poller.isDown(A_Jump)) + { + + player.setUpDown (1); + } + else if (poller.isDown(A_Crouch)) + { + player.setUpDown (-1); + } + else + player.setUpDown (0); + return true; } diff --git a/apps/openmw/mwmechanics/movement.hpp b/apps/openmw/mwmechanics/movement.hpp index a555ac010..11eb83151 100644 --- a/apps/openmw/mwmechanics/movement.hpp +++ b/apps/openmw/mwmechanics/movement.hpp @@ -8,8 +8,9 @@ namespace MWMechanics { signed char mLeftRight; // 1: wants to move left, -1: wants to move right signed char mForwardBackward; // 1:wants to move forward, -1: wants to move backward + signed char mUpDown; - Movement() : mLeftRight (0), mForwardBackward (0) {} + Movement() : mLeftRight (0), mForwardBackward (0), mUpDown(0) {} }; } diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 717064ada..0d19a3013 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -56,8 +56,10 @@ void Objects::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_) Ogre::SceneNode* insert = cellnode->createChildSceneNode(); const float *f = ptr.getRefData().getPosition().pos; + insert->setPosition(f[0], f[1], f[2]); insert->setScale(ptr.getCellRef().scale, ptr.getCellRef().scale, ptr.getCellRef().scale); + // Convert MW rotation to a quaternion: f = ptr.getCellRef().pos.rot; diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 11a43c7d3..d54f4696a 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -103,7 +103,7 @@ namespace MWWorld playerphysics->ps.viewangles.x = 0; playerphysics->ps.viewangles.z = 0; - playerphysics->ps.viewangles.y = both.getYaw().valueDegrees() *-1 + 90; + playerphysics->ps.viewangles.y = both.getYaw().valueDegrees() *-1 + 90; //playerphysics->ps.viewangles.z = both.getPitch().valueDegrees(); @@ -113,6 +113,7 @@ namespace MWWorld Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); pm_ref.rightmove = -dir1.x; pm_ref.forwardmove = dir1.z; + pm_ref.upmove = dir1.y; @@ -127,6 +128,7 @@ namespace MWWorld Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); pm_ref.rightmove = -dir1.x; pm_ref.forwardmove = dir1.z; + pm_ref.upmove = dir.y; dir = 0.025*(quat*dir1); } @@ -135,7 +137,7 @@ namespace MWWorld //set the walk direction act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y)); } - //mEngine->stepSimulation(duration); + mEngine->stepSimulation(duration); Pmove(playerphysics); std::vector< std::pair > response; for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) @@ -147,7 +149,7 @@ namespace MWWorld coord = playerphysics->ps.origin; //std::cout << "Coord" << coord << "\n"; - coord = Ogre::Vector3(coord.x, coord.z, coord.y); //x, z, -y + //coord = Ogre::Vector3(coord.x, coord.z, coord.y); //x, z, -y } response.push_back(std::pair(it->first, coord)); @@ -218,6 +220,10 @@ namespace MWWorld bool PhysicsSystem::toggleCollisionMode() { + if(playerphysics->ps.move_type==PM_NOCLIP) + playerphysics->ps.move_type=PM_NORMAL; + else + playerphysics->ps.move_type=PM_NOCLIP; for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) { if (it->first=="player") @@ -248,7 +254,10 @@ namespace MWWorld } void PhysicsSystem::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string model){ + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); + Ogre::Vector3 objPos = node->getPosition(); + addObject (node->getName(), model, node->getOrientation(), node->getScale().x, node->getPosition()); } diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 5bfb82138..884a72c3a 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -80,6 +80,14 @@ namespace MWWorld MWWorld::Class::get (ptr).getMovementSettings (ptr).mForwardBackward = value; } + void Player::setUpDown(int value) + { + MWWorld::Ptr ptr = getPlayer(); + + + + MWWorld::Class::get (ptr).getMovementSettings (ptr).mUpDown = value; + } void Player::toggleRunning() { @@ -89,4 +97,5 @@ namespace MWWorld MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Run, !running); } + } diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index 01c71da43..da74fe6de 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -111,6 +111,7 @@ namespace MWWorld void setLeftRight (int value); void setForwardBackward (int value); + void setUpDown(int value); void toggleRunning(); }; diff --git a/apps/openmw/physicssystem.cpp b/apps/openmw/physicssystem.cpp new file mode 100644 index 000000000..a07358f8e --- /dev/null +++ b/apps/openmw/physicssystem.cpp @@ -0,0 +1,225 @@ +#include + +#include "physicssystem.hpp" +#include "../mwworld/ptr.hpp" +#include "../mwworld/world.hpp" // FIXME +#include + +#include "OgreRoot.h" +#include "OgreRenderWindow.h" +#include "OgreSceneManager.h" +#include "OgreViewport.h" +#include "OgreCamera.h" +#include "OgreTextureManager.h" + + +using namespace Ogre; +namespace MWWorld +{ + + PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend) : + mRender(_rend), mEngine(0), mFreeFly (true) + { + // Create physics. shapeLoader is deleted by the physic engine + NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader(); + mEngine = new OEngine::Physic::PhysicEngine(shapeLoader); + } + + PhysicsSystem::~PhysicsSystem() + { + delete mEngine; + + } + OEngine::Physic::PhysicEngine* PhysicsSystem::getEngine() + { + return mEngine; + } + + std::pair PhysicsSystem::getFacedHandle (MWWorld::World& world) + { + std::string handle = ""; + + //get a ray pointing to the center of the viewport + Ray centerRay = mRender.getCamera()->getCameraToViewportRay( + mRender.getViewport()->getWidth()/2, + mRender.getViewport()->getHeight()/2); + //let's avoid the capsule shape of the player. + centerRay.setOrigin(centerRay.getOrigin() + 20*centerRay.getDirection()); + btVector3 from(centerRay.getOrigin().x,-centerRay.getOrigin().z,centerRay.getOrigin().y); + btVector3 to(centerRay.getPoint(500).x,-centerRay.getPoint(500).z,centerRay.getPoint(500).y); + + return mEngine->rayTest(from,to); + } + + bool PhysicsSystem::castRay(const Vector3& from, const Vector3& to) + { + btVector3 _from, _to; + _from = btVector3(from.x, from.y, from.z); + _to = btVector3(to.x, to.y, to.z); + + std::pair result = mEngine->rayTest(_from, _to); + + return !(result.first == ""); + } + + + std::vector< std::pair > PhysicsSystem::doPhysics (float duration, + const std::vector >& actors) + { + //set the DebugRenderingMode. To disable it,set it to 0 + //eng->setDebugRenderingMode(1); + + //set the walkdirection to 0 (no movement) for every actor) + for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) + { + OEngine::Physic::PhysicActor* act = it->second; + act->setWalkDirection(btVector3(0,0,0)); + } + + for (std::vector >::const_iterator iter (actors.begin()); + iter!=actors.end(); ++iter) + { + OEngine::Physic::PhysicActor* act = mEngine->getCharacter(iter->first); + + //dirty stuff to get the camera orientation. Must be changed! + + Ogre::SceneNode *sceneNode = mRender.getScene()->getSceneNode (iter->first); + Ogre::Vector3 dir; + Ogre::Node* yawNode = sceneNode->getChildIterator().getNext(); + Ogre::Node* pitchNode = yawNode->getChildIterator().getNext(); + if(mFreeFly) + { + Ogre::Quaternion yawQuat = yawNode->getOrientation(); + Ogre::Quaternion pitchQuat = pitchNode->getOrientation(); + Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); + dir = 0.07*(yawQuat*pitchQuat*dir1); + } + else + { + Ogre::Quaternion quat = yawNode->getOrientation(); + Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); + dir = 0.025*(quat*dir1); + } + + //set the walk direction + act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y)); + } + mEngine->stepSimulation(duration); + + std::vector< std::pair > response; + for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) + { + btVector3 newPos = it->second->getPosition(); + Ogre::Vector3 coord(newPos.x(), newPos.y(), newPos.z()); + + response.push_back(std::pair(it->first, coord)); + } + return response; + } + + void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh, + const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position) + { + OEngine::Physic::RigidBody* body = mEngine->createRigidBody(mesh,handle,scale); + mEngine->addRigidBody(body); + btTransform tr; + tr.setOrigin(btVector3(position.x,position.y,position.z)); + std::cout << "Position object:" << position << "\n"; + tr.setRotation(btQuaternion(rotation.x,rotation.y,rotation.z,rotation.w)); + body->setWorldTransform(tr); + } + + void PhysicsSystem::addActor (const std::string& handle, const std::string& mesh, + const Ogre::Vector3& position) + { + //TODO:optimize this. Searching the std::map isn't very efficient i think. + mEngine->addCharacter(handle); + OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle); + act->setPosition(btVector3(position.x,position.y,position.z)); + } + + void PhysicsSystem::removeObject (const std::string& handle) + { + //TODO:check if actor??? + mEngine->removeCharacter(handle); + mEngine->removeRigidBody(handle); + mEngine->deleteRigidBody(handle); + } + + void PhysicsSystem::moveObject (const std::string& handle, const Ogre::Vector3& position) + { + if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle)) + { + // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow + // start positions others than 0, 0, 0 + btTransform tr = body->getWorldTransform(); + tr.setOrigin(btVector3(position.x,position.y,position.z)); + body->setWorldTransform(tr); + } + if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle)) + { + // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow + // start positions others than 0, 0, 0 + act->setPosition(btVector3(position.x,position.y,position.z)); + } + } + + void PhysicsSystem::rotateObject (const std::string& handle, const Ogre::Quaternion& rotation) + { + if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle)) + { + // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow + // start positions others than 0, 0, 0 + act->setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)); + } + } + + void PhysicsSystem::scaleObject (const std::string& handle, float scale) + { + + } + + bool PhysicsSystem::toggleCollisionMode() + { + for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) + { + if (it->first=="player") + { + OEngine::Physic::PhysicActor* act = it->second; + + bool cmode = act->getCollisionMode(); + if(cmode) + { + act->enableCollisions(false); + act->setGravity(0.); + act->setVerticalVelocity(0); + mFreeFly = true; + return false; + } + else + { + mFreeFly = false; + act->enableCollisions(true); + act->setGravity(4.); + act->setVerticalVelocity(0); + return true; + } + } + } + + throw std::logic_error ("can't find player"); + } + + void PhysicsSystem::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string model){ + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); + addObject (node->getName(), model, node->getOrientation(), + node->getScale().x, node->getPosition()); + } + + void PhysicsSystem::insertActorPhysics(const MWWorld::Ptr& ptr, const std::string model){ + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); + // std::cout << "Adding node with name" << node->getName(); + addActor (node->getName(), model, node->getPosition()); + } + +} diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 07bad3053..911f6279b 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -156,10 +156,10 @@ namespace Physic solver = new btSequentialImpulseConstraintSolver; //TODO: memory leak? - btOverlappingPairCache* pairCache = new btSortedOverlappingPairCache(); + //btOverlappingPairCache* pairCache = new btSortedOverlappingPairCache(); //pairCache->setInternalGhostPairCallback( new btGhostPairCallback() ); - broadphase = new btDbvtBroadphase(pairCache); + broadphase = new btDbvtBroadphase(); // The world. dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration); diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 45fe84f4f..71c15fe45 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -786,7 +786,7 @@ static void PM_WaterMove( playerMove* const pm ) wishvel = pml.forward * scale * pm->cmd.forwardmove + pml.right * scale * pm->cmd.rightmove; //wishvel[2] += scale * pm->cmd.upmove; - wishvel.y += pm->cmd.upmove * scale; + wishvel.z += pm->cmd.upmove * scale; } //VectorCopy (wishvel, wishdir); @@ -1094,21 +1094,22 @@ void AngleVectors( const Ogre::Vector3& angles, Ogre::Vector3* const forward, Og if (forward) { forward->x = cp * cy; - forward->z = cp * sy; - forward->y = -sp; + forward->y = cp * sy; + forward->z = -sp; } if (right) { right->x = (-1 * sr * sp * cy + -1 * cr * -sy); - right->z = (-1 * sr * sp * sy + -1 * cr * cy); - right->y = 0.0f;//-1 * sp * cp; + right->y = (-1 * sr * sp * sy + -1 * cr * cy); + right->z = 0.0f;//-1 * sp * cp; } if (up) { - up->x = (cr * sp * cy + -sr * -sy); - up->z = (cr * sp * sy + -sr * cy); - up->y = cr * cp; + up->x =(cr * sp * cy + -sr * -sy); + up->y=(cr * sp * sy + -sr * cy); + up->z = cr * cp; } + } void PM_GroundTraceMissed() @@ -1356,7 +1357,7 @@ static void PM_CrashLand( void ) static void PM_GroundTrace( void ) { - std::cout << "Ground trace\n"; + //std::cout << "Ground trace\n"; Ogre::Vector3 point; traceResults trace; @@ -1578,9 +1579,12 @@ static void PM_NoclipMove( void ) //for (i=0 ; i<3 ; i++) //wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove; + std::cout << "Forward" << pml.forward << "\n"; + std::cout << "Right" << pml.right << "\n"; + std::cout << "Up" << pml.up << "\n"; wishvel = pml.forward * fmove + pml.right * smove; //wishvel[2] += pm->cmd.upmove; - wishvel.y += pm->cmd.upmove; + wishvel.z += pm->cmd.upmove; //VectorCopy (wishvel, wishdir); wishdir = wishvel; @@ -1720,7 +1724,6 @@ void PM_SetWaterLevel( playerMove* const pm ) void PmoveSingle (playerMove* const pmove) { - std::cout << "Pmove single\n"; //pm = pmove; // Aedra doesn't support Q3-style VM traps D: //while(1); @@ -1944,7 +1947,7 @@ void PmoveSingle (playerMove* const pmove) else { // airborne - std::cout << "AIRMOVE\n"; + //std::cout << "AIRMOVE\n"; PM_AirMove(); //bprintf("AirMove\n"); } diff --git a/libs/openengine/bullet/pmove.h b/libs/openengine/bullet/pmove.h index e90cc3b35..5dfd18f6d 100644 --- a/libs/openengine/bullet/pmove.h +++ b/libs/openengine/bullet/pmove.h @@ -90,9 +90,9 @@ struct playerMove { struct playerStruct { - playerStruct() : gravity(50.0f), speed(320.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NORMAL), pm_time(0) + playerStruct() : gravity(50.0f), speed(320.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0) { - origin = Ogre::Vector3(733.164f,1000.0f, 839.432f); + origin = Ogre::Vector3(733.164f,900.0f, 839.432f); velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f); viewangles = Ogre::Vector3(0.0f, 0.0f, 0.0f); diff --git a/libs/openengine/bullet/trace.cpp b/libs/openengine/bullet/trace.cpp index 49e12064e..57d071f17 100644 --- a/libs/openengine/bullet/trace.cpp +++ b/libs/openengine/bullet/trace.cpp @@ -112,8 +112,8 @@ const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3& float y2 = to.getOrigin().getY(); float z2 = to.getOrigin().getZ(); - std::cout << "BtFrom: " << x << "," << y << "," << z << "\n"; - std::cout << "BtTo: " << x2 << "," << y2 << "," << z2 << "\n"; + //std::cout << "BtFrom: " << x << "," << y << "," << z << "\n"; + //std::cout << "BtTo: " << x2 << "," << y2 << "," << z2 << "\n"; //std::cout << "BtTo: " << to.getOrigin().getX() << "," << to.getOrigin().getY() << "," << to.getOrigin().getZ() << "\n"; diff --git a/libs/openengine/bullet/weather.cpp b/libs/openengine/bullet/weather.cpp new file mode 100644 index 000000000..90afc4e78 --- /dev/null +++ b/libs/openengine/bullet/weather.cpp @@ -0,0 +1,811 @@ +#include "weather.hpp" +#include "world.hpp" +#include "player.hpp" + +#include "../mwrender/renderingmanager.hpp" +#include "../mwsound/soundmanager.hpp" + +#include +#include +#include + +#include + +using namespace Ogre; +using namespace MWWorld; +using namespace MWSound; + +#define lerp(x, y) (x * (1-factor) + y * factor) + +const std::string WeatherGlobals::mThunderSoundID0 = "Thunder0"; +const std::string WeatherGlobals::mThunderSoundID1 = "Thunder1"; +const std::string WeatherGlobals::mThunderSoundID2 = "Thunder2"; +const std::string WeatherGlobals::mThunderSoundID3 = "Thunder3"; +const float WeatherGlobals::mSunriseTime = 8; +const float WeatherGlobals::mSunsetTime = 18; +const float WeatherGlobals::mSunriseDuration = 2; +const float WeatherGlobals::mSunsetDuration = 2; +const float WeatherGlobals::mWeatherUpdateTime = 20.f; +const float WeatherGlobals::mThunderFrequency = .4; +const float WeatherGlobals::mThunderThreshold = 0.6; +const float WeatherGlobals::mThunderSoundDelay = 0.25; + +WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environment* env) : + mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0), + mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0) +{ + mRendering = rendering; + mEnvironment = env; + + #define clr(r,g,b) ColourValue(r/255.f, g/255.f, b/255.f) + + /// \todo read these from Morrowind.ini + Weather clear; + clear.mCloudTexture = "tx_sky_clear.dds"; + clear.mCloudsMaximumPercent = 1.0; + clear.mTransitionDelta = 0.015; + clear.mSkySunriseColor = clr(118, 141, 164); + clear.mSkyDayColor = clr(95, 135, 203); + clear.mSkySunsetColor = clr(56, 89, 129); + clear.mSkyNightColor = clr(9, 10, 11); + clear.mFogSunriseColor = clr(255, 189, 157); + clear.mFogDayColor = clr(206, 227, 255); + clear.mFogSunsetColor = clr(255, 189, 157); + clear.mFogNightColor = clr(9, 10, 11); + clear.mAmbientSunriseColor = clr(47, 66, 96); + clear.mAmbientDayColor = clr(137, 140, 160); + clear.mAmbientSunsetColor = clr(68, 75, 96); + clear.mAmbientNightColor = clr(32, 35, 42); + clear.mSunSunriseColor = clr(242, 159, 99); + clear.mSunDayColor = clr(255, 252, 238); + clear.mSunSunsetColor = clr(255, 115, 79); + clear.mSunNightColor = clr(59, 97, 176); + clear.mSunDiscSunsetColor = clr(255, 189, 157); + clear.mLandFogDayDepth = 0.69; + clear.mLandFogNightDepth = 0.69; + clear.mWindSpeed = 0.1; + clear.mCloudSpeed = 1.25; + clear.mGlareView = 1.0; + mWeatherSettings["clear"] = clear; + + Weather cloudy; + cloudy.mCloudTexture = "tx_sky_cloudy.dds"; + cloudy.mCloudsMaximumPercent = 1.0; + cloudy.mTransitionDelta = 0.015; + cloudy.mSkySunriseColor = clr(126, 158, 173); + cloudy.mSkyDayColor = clr(117, 160, 215); + cloudy.mSkySunsetColor = clr(111, 114, 159); + cloudy.mSkyNightColor = clr(9, 10, 11); + cloudy.mFogSunriseColor = clr(255, 207, 149); + cloudy.mFogDayColor = clr(245, 235, 224); + cloudy.mFogSunsetColor = clr(255, 155, 106); + cloudy.mFogNightColor = clr(9, 10, 11); + cloudy.mAmbientSunriseColor = clr(66, 74, 87); + cloudy.mAmbientDayColor = clr(137, 145, 160); + cloudy.mAmbientSunsetColor = clr(71, 80, 92); + cloudy.mAmbientNightColor = clr(32, 39, 54); + cloudy.mSunSunriseColor = clr(241, 177, 99); + cloudy.mSunDayColor = clr(255, 236, 221); + cloudy.mSunSunsetColor = clr(255, 89, 00); + cloudy.mSunNightColor = clr(77, 91, 124); + cloudy.mSunDiscSunsetColor = clr(255, 202, 179); + cloudy.mLandFogDayDepth = 0.72; + cloudy.mLandFogNightDepth = 0.72; + cloudy.mWindSpeed = 0.2; + cloudy.mCloudSpeed = 2; + cloudy.mGlareView = 1.0; + mWeatherSettings["cloudy"] = cloudy; + + Weather foggy; + foggy.mCloudTexture = "tx_sky_foggy.dds"; + foggy.mCloudsMaximumPercent = 1.0; + foggy.mTransitionDelta = 0.015; + foggy.mSkySunriseColor = clr(197, 190, 180); + foggy.mSkyDayColor = clr(184, 211, 228); + foggy.mSkySunsetColor = clr(142, 159, 176); + foggy.mSkyNightColor = clr(18, 23, 28); + foggy.mFogSunriseColor = clr(173, 164, 148); + foggy.mFogDayColor = clr(150, 187, 209); + foggy.mFogSunsetColor = clr(113, 135, 157); + foggy.mFogNightColor = clr(19, 24, 29); + foggy.mAmbientSunriseColor = clr(48, 43, 37); + foggy.mAmbientDayColor = clr(92, 109, 120); + foggy.mAmbientSunsetColor = clr(28, 33, 39); + foggy.mAmbientNightColor = clr(28, 33, 39); + foggy.mSunSunriseColor = clr(177, 162, 137); + foggy.mSunDayColor = clr(111, 131, 151); + foggy.mSunSunsetColor = clr(125, 157, 189); + foggy.mSunNightColor = clr(81, 100, 119); + foggy.mSunDiscSunsetColor = clr(223, 223, 223); + foggy.mLandFogDayDepth = 1.0; + foggy.mLandFogNightDepth = 1.9; + foggy.mWindSpeed = 0; + foggy.mCloudSpeed = 1.25; + foggy.mGlareView = 0.25; + mWeatherSettings["foggy"] = foggy; + + Weather thunderstorm; + thunderstorm.mCloudTexture = "tx_sky_thunder.dds"; + thunderstorm.mCloudsMaximumPercent = 0.66; + thunderstorm.mTransitionDelta = 0.03; + thunderstorm.mSkySunriseColor = clr(35, 36, 39); + thunderstorm.mSkyDayColor = clr(97, 104, 115); + thunderstorm.mSkySunsetColor = clr(35, 36, 39); + thunderstorm.mSkyNightColor = clr(19, 20, 22); + thunderstorm.mFogSunriseColor = clr(70, 74, 85); + thunderstorm.mFogDayColor = clr(97, 104, 115); + thunderstorm.mFogSunsetColor = clr(70, 74, 85); + thunderstorm.mFogNightColor = clr(19, 20, 22); + thunderstorm.mAmbientSunriseColor = clr(54, 54, 54); + thunderstorm.mAmbientDayColor = clr(90, 90, 90); + thunderstorm.mAmbientSunsetColor = clr(54, 54, 54); + thunderstorm.mAmbientNightColor = clr(49, 51, 54); + thunderstorm.mSunSunriseColor = clr(91, 99, 122); + thunderstorm.mSunDayColor = clr(138, 144, 155); + thunderstorm.mSunSunsetColor = clr(96, 101, 117); + thunderstorm.mSunNightColor = clr(55, 76, 110); + thunderstorm.mSunDiscSunsetColor = clr(128, 128, 128); + thunderstorm.mLandFogDayDepth = 1; + thunderstorm.mLandFogNightDepth = 1.15; + thunderstorm.mWindSpeed = 0.5; + thunderstorm.mCloudSpeed = 3; + thunderstorm.mGlareView = 0; + thunderstorm.mRainLoopSoundID = "rain heavy"; + mWeatherSettings["thunderstorm"] = thunderstorm; + + Weather rain; + rain.mCloudTexture = "tx_sky_rainy.dds"; + rain.mCloudsMaximumPercent = 0.66; + rain.mTransitionDelta = 0.015; + rain.mSkySunriseColor = clr(71, 74, 75); + rain.mSkyDayColor = clr(116, 120, 122); + rain.mSkySunsetColor = clr(73, 73, 73); + rain.mSkyNightColor = clr(24, 25, 26); + rain.mFogSunriseColor = clr(71, 74, 75); + rain.mFogDayColor = clr(116, 120, 122); + rain.mFogSunsetColor = clr(73, 73, 73); + rain.mFogNightColor = clr(24, 25, 26); + rain.mAmbientSunriseColor = clr(97, 90, 88); + rain.mAmbientDayColor = clr(105, 110, 113); + rain.mAmbientSunsetColor = clr(88, 97, 97); + rain.mAmbientNightColor = clr(50, 55, 67); + rain.mSunSunriseColor = clr(131, 122, 120); + rain.mSunDayColor = clr(149, 157, 170); + rain.mSunSunsetColor = clr(120, 126, 131); + rain.mSunNightColor = clr(50, 62, 101); + rain.mSunDiscSunsetColor = clr(128, 128, 128); + rain.mLandFogDayDepth = 0.8; + rain.mLandFogNightDepth = 0.8; + rain.mWindSpeed = 0.3; + rain.mCloudSpeed = 2; + rain.mGlareView = 0; + rain.mRainLoopSoundID = "rain"; + mWeatherSettings["rain"] = rain; + + Weather overcast; + overcast.mCloudTexture = "tx_sky_overcast.dds"; + overcast.mCloudsMaximumPercent = 1.0; + overcast.mTransitionDelta = 0.015; + overcast.mSkySunriseColor = clr(91, 99, 106); + overcast.mSkyDayColor = clr(143, 146, 149); + overcast.mSkySunsetColor = clr(108, 115, 121); + overcast.mSkyNightColor = clr(19, 22, 25); + overcast.mFogSunriseColor = clr(91, 99, 106); + overcast.mFogDayColor = clr(143, 146, 149); + overcast.mFogSunsetColor = clr(108, 115, 121); + overcast.mFogNightColor = clr(19, 22, 25); + overcast.mAmbientSunriseColor = clr(84, 88, 92); + overcast.mAmbientDayColor = clr(93, 96, 105); + overcast.mAmbientSunsetColor = clr(83, 77, 75); + overcast.mAmbientNightColor = clr(57, 60, 66); + overcast.mSunSunriseColor = clr(87, 125, 163); + overcast.mSunDayColor = clr(163, 169, 183); + overcast.mSunSunsetColor = clr(85, 103, 157); + overcast.mSunNightColor = clr(32, 54, 100); + overcast.mSunDiscSunsetColor = clr(128, 128, 128); + overcast.mLandFogDayDepth = 0.7; + overcast.mLandFogNightDepth = 0.7; + overcast.mWindSpeed = 0.2; + overcast.mCloudSpeed = 1.5; + overcast.mGlareView = 0; + mWeatherSettings["overcast"] = overcast; + + Weather ashstorm; + ashstorm.mCloudTexture = "tx_sky_ashstorm.dds"; + ashstorm.mCloudsMaximumPercent = 1.0; + ashstorm.mTransitionDelta = 0.035; + ashstorm.mSkySunriseColor = clr(91, 56, 51); + ashstorm.mSkyDayColor = clr(124, 73, 58); + ashstorm.mSkySunsetColor = clr(106, 55, 40); + ashstorm.mSkyNightColor = clr(20, 21, 22); + ashstorm.mFogSunriseColor = clr(91, 56, 51); + ashstorm.mFogDayColor = clr(124, 73, 58); + ashstorm.mFogSunsetColor = clr(106, 55, 40); + ashstorm.mFogNightColor = clr(20, 21, 22); + ashstorm.mAmbientSunriseColor = clr(52, 42, 37); + ashstorm.mAmbientDayColor = clr(75, 49, 41); + ashstorm.mAmbientSunsetColor = clr(48, 39, 35); + ashstorm.mAmbientNightColor = clr(36, 42, 49); + ashstorm.mSunSunriseColor = clr(184, 91, 71); + ashstorm.mSunDayColor = clr(228, 139, 114); + ashstorm.mSunSunsetColor = clr(185, 86, 57); + ashstorm.mSunNightColor = clr(54, 66, 74); + ashstorm.mSunDiscSunsetColor = clr(128, 128, 128); + ashstorm.mLandFogDayDepth = 1.1; + ashstorm.mLandFogNightDepth = 1.2; + ashstorm.mWindSpeed = 0.8; + ashstorm.mCloudSpeed = 7; + ashstorm.mGlareView = 0; + ashstorm.mAmbientLoopSoundID = "ashstorm"; + mWeatherSettings["ashstorm"] = ashstorm; + + Weather blight; + blight.mCloudTexture = "tx_sky_blight.dds"; + blight.mCloudsMaximumPercent = 1.0; + blight.mTransitionDelta = 0.04; + blight.mSkySunriseColor = clr(90, 35, 35); + blight.mSkyDayColor = clr(90, 35, 35); + blight.mSkySunsetColor = clr(92, 33, 33); + blight.mSkyNightColor = clr(44, 14, 14); + blight.mFogSunriseColor = clr(90, 35, 35); + blight.mFogDayColor = clr(128, 19, 19); + blight.mFogSunsetColor = clr(92, 33, 33); + blight.mFogNightColor = clr(44, 14, 14); + blight.mAmbientSunriseColor = clr(61, 40, 40); + blight.mAmbientDayColor = clr(79, 54, 54); + blight.mAmbientSunsetColor = clr(61, 40, 40); + blight.mAmbientNightColor = clr(56, 58, 62); + blight.mSunSunriseColor = clr(180, 78, 78); + blight.mSunDayColor = clr(224, 84, 84); + blight.mSunSunsetColor = clr(180, 78, 78); + blight.mSunNightColor = clr(61, 91, 143); + blight.mSunDiscSunsetColor = clr(128, 128, 128); + blight.mLandFogDayDepth = 1.1; + blight.mLandFogNightDepth = 1.2; + blight.mWindSpeed = 0.9; + blight.mCloudSpeed = 9; + blight.mGlareView = 0; + blight.mAmbientLoopSoundID = "blight"; + mWeatherSettings["blight"] = blight; + + Weather snow; + snow.mCloudTexture = "tx_bm_sky_snow.dds"; + snow.mCloudsMaximumPercent = 1.0; + snow.mTransitionDelta = 0.014; + snow.mSkySunriseColor = clr(196, 91, 91); + snow.mSkyDayColor = clr(153, 158, 166); + snow.mSkySunsetColor = clr(96, 115, 134); + snow.mSkyNightColor = clr(31, 35, 39); + snow.mFogSunriseColor = clr(106, 91, 91); + snow.mFogDayColor = clr(153, 158, 166); + snow.mFogSunsetColor = clr(96, 115, 134); + snow.mFogNightColor = clr(31, 35, 39); + snow.mAmbientSunriseColor = clr(92, 84, 84); + snow.mAmbientDayColor = clr(93, 96, 105); + snow.mAmbientSunsetColor = clr(70, 79, 87); + snow.mAmbientNightColor = clr(49, 58, 68); + snow.mSunSunriseColor = clr(141, 109, 109); + snow.mSunDayColor = clr(163, 169, 183); + snow.mSunSunsetColor = clr(101, 121, 141); + snow.mSunNightColor = clr(55, 66, 77); + snow.mSunDiscSunsetColor = clr(128, 128, 128); + snow.mLandFogDayDepth = 1.0; + snow.mLandFogNightDepth = 1.2; + snow.mWindSpeed = 0; + snow.mCloudSpeed = 1.5; + snow.mGlareView = 0; + mWeatherSettings["snow"] = snow; + + Weather blizzard; + blizzard.mCloudTexture = "tx_bm_sky_blizzard.dds"; + blizzard.mCloudsMaximumPercent = 1.0; + blizzard.mTransitionDelta = 0.030; + blizzard.mSkySunriseColor = clr(91, 99, 106); + blizzard.mSkyDayColor = clr(121, 133, 145); + blizzard.mSkySunsetColor = clr(108, 115, 121); + blizzard.mSkyNightColor = clr(27, 29, 31); + blizzard.mFogSunriseColor = clr(91, 99, 106); + blizzard.mFogDayColor = clr(121, 133, 145); + blizzard.mFogSunsetColor = clr(108, 115, 121); + blizzard.mFogNightColor = clr(21, 24, 28); + blizzard.mAmbientSunriseColor = clr(84, 88, 92); + blizzard.mAmbientDayColor = clr(93, 96, 105); + blizzard.mAmbientSunsetColor = clr(83, 77, 75); + blizzard.mAmbientNightColor = clr(53, 62, 70); + blizzard.mSunSunriseColor = clr(114, 128, 146); + blizzard.mSunDayColor = clr(163, 169, 183); + blizzard.mSunSunsetColor = clr(106, 114, 136); + blizzard.mSunNightColor = clr(57, 66, 74); + blizzard.mSunDiscSunsetColor = clr(128, 128, 128); + blizzard.mLandFogDayDepth = 2.8; + blizzard.mLandFogNightDepth = 3.0; + blizzard.mWindSpeed = 0.9; + blizzard.mCloudSpeed = 7.5; + blizzard.mGlareView = 0; + blizzard.mAmbientLoopSoundID = "BM Blizzard"; + mWeatherSettings["blizzard"] = blizzard; +} + +void WeatherManager::setWeather(const String& weather, bool instant) +{ + if (instant || mFirstUpdate) + { + mNextWeather = ""; + mCurrentWeather = weather; + mFirstUpdate = false; + } + else + { + if (mNextWeather != "") + { + // transition more than 50% finished? + if (mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60) <= 0.5) + mCurrentWeather = mNextWeather; + } + + mNextWeather = weather; + mRemainingTransitionTime = mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60; + } +} + +WeatherResult WeatherManager::getResult(const String& weather) +{ + const Weather& current = mWeatherSettings[weather]; + WeatherResult result; + + result.mCloudTexture = current.mCloudTexture; + result.mCloudBlendFactor = 0; + result.mCloudOpacity = current.mCloudsMaximumPercent; + result.mWindSpeed = current.mWindSpeed; + result.mCloudSpeed = current.mCloudSpeed; + result.mGlareView = current.mGlareView; + result.mAmbientLoopSoundID = current.mAmbientLoopSoundID; + result.mSunColor = current.mSunDiscSunsetColor; + + const float fade_duration = current.mTransitionDelta * 24.f; + + result.mNight = (mHour < 6.f+fade_duration || mHour > 20.f-fade_duration); + + result.mFogDepth = result.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth; + + // night + if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) + || mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration)) + { + result.mFogColor = current.mFogNightColor; + result.mAmbientColor = current.mAmbientNightColor; + result.mSunColor = current.mSunNightColor; + result.mSkyColor = current.mSkyNightColor; + result.mNightFade = 1.f; + } + + // sunrise + else if (mHour >= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) && mHour <= WeatherGlobals::mSunriseTime) + { + if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration)) + { + // fade in + float advance = (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration)-mHour; + float factor = (advance / fade_duration); + result.mFogColor = lerp(current.mFogSunriseColor, current.mFogNightColor); + result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientNightColor); + result.mSunColor = lerp(current.mSunSunriseColor, current.mSunNightColor); + result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyNightColor); + result.mNightFade = factor; + } + else if (mHour >= (WeatherGlobals::mSunriseTime-fade_duration)) + { + // fade out + float advance = mHour-(WeatherGlobals::mSunriseTime-fade_duration); + float factor = advance / fade_duration; + result.mFogColor = lerp(current.mFogSunriseColor, current.mFogDayColor); + result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientDayColor); + result.mSunColor = lerp(current.mSunSunriseColor, current.mSunDayColor); + result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyDayColor); + } + else + { + result.mFogColor = current.mFogSunriseColor; + result.mAmbientColor = current.mAmbientSunriseColor; + result.mSunColor = current.mSunSunriseColor; + result.mSkyColor = current.mSkySunriseColor; + } + } + + // day + else if (mHour >= (WeatherGlobals::mSunriseTime) && mHour <= (WeatherGlobals::mSunsetTime)) + { + result.mFogColor = current.mFogDayColor; + result.mAmbientColor = current.mAmbientDayColor; + result.mSunColor = current.mSunDayColor; + result.mSkyColor = current.mSkyDayColor; + } + + // sunset + else if (mHour >= (WeatherGlobals::mSunsetTime) && mHour <= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration)) + { + if (mHour <= (WeatherGlobals::mSunsetTime+fade_duration)) + { + // fade in + float advance = (WeatherGlobals::mSunsetTime+fade_duration)-mHour; + float factor = (advance / fade_duration); + result.mFogColor = lerp(current.mFogSunsetColor, current.mFogDayColor); + result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientDayColor); + result.mSunColor = lerp(current.mSunSunsetColor, current.mSunDayColor); + result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyDayColor); + } + else if (mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration)) + { + // fade out + float advance = mHour-(WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration); + float factor = advance / fade_duration; + result.mFogColor = lerp(current.mFogSunsetColor, current.mFogNightColor); + result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientNightColor); + result.mSunColor = lerp(current.mSunSunsetColor, current.mSunNightColor); + result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyNightColor); + result.mNightFade = factor; + } + else + { + result.mFogColor = current.mFogSunsetColor; + result.mAmbientColor = current.mAmbientSunsetColor; + result.mSunColor = current.mSunSunsetColor; + result.mSkyColor = current.mSkySunsetColor; + } + } + + return result; +} + +WeatherResult WeatherManager::transition(float factor) +{ + const WeatherResult& current = getResult(mCurrentWeather); + const WeatherResult& other = getResult(mNextWeather); + WeatherResult result; + + result.mCloudTexture = current.mCloudTexture; + result.mNextCloudTexture = other.mCloudTexture; + result.mCloudBlendFactor = factor; + + result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); + result.mFogColor = lerp(current.mFogColor, other.mFogColor); + result.mSunColor = lerp(current.mSunColor, other.mSunColor); + result.mSkyColor = lerp(current.mSkyColor, other.mSkyColor); + + result.mAmbientColor = lerp(current.mAmbientColor, other.mAmbientColor); + result.mSunDiscColor = lerp(current.mSunDiscColor, other.mSunDiscColor); + result.mFogDepth = lerp(current.mFogDepth, other.mFogDepth); + result.mWindSpeed = lerp(current.mWindSpeed, other.mWindSpeed); + result.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed); + result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); + result.mGlareView = lerp(current.mGlareView, other.mGlareView); + + result.mNight = current.mNight; + + // sound change behaviour: + // if 'other' has a new sound, switch to it after 1/2 of the transition length + if (other.mAmbientLoopSoundID != "") + result.mAmbientLoopSoundID = factor>0.5 ? other.mAmbientLoopSoundID : current.mAmbientLoopSoundID; + // if 'current' has a sound and 'other' does not have a sound, turn off the sound immediately + else if (current.mAmbientLoopSoundID != "") + result.mAmbientLoopSoundID = ""; + + return result; +} + +void WeatherManager::update(float duration) +{ + mWeatherUpdateTime -= duration; + if (mEnvironment->mWorld->isCellExterior() || mEnvironment->mWorld->isCellQuasiExterior()) + { + std::string regionstr = mEnvironment->mWorld->getPlayer().getPlayer().getCell()->cell->region; + boost::algorithm::to_lower(regionstr); + + if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion) + { + mCurrentRegion = regionstr; + mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*60.f; + + std::string weather; + + if (mRegionOverrides.find(regionstr) != mRegionOverrides.end()) + weather = mRegionOverrides[regionstr]; + else + { + // get weather probabilities for the current region + const ESM::Region *region = mEnvironment->mWorld->getStore().regions.find (regionstr); + + float clear = region->data.clear/255.f; + float cloudy = region->data.cloudy/255.f; + float foggy = region->data.foggy/255.f; + float overcast = region->data.overcast/255.f; + float rain = region->data.rain/255.f; + float thunder = region->data.thunder/255.f; + float ash = region->data.ash/255.f; + float blight = region->data.blight/255.f; + float snow = region->data.a/255.f; + float blizzard = region->data.b/255.f; + + // re-scale to 100 percent + const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight+snow+blizzard; + + srand(time(NULL)); + float random = ((rand()%100)/100.f) * total; + + if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) + weather = "blizzard"; + else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear) + weather = "snow"; + else if (random >= ash+thunder+rain+overcast+foggy+cloudy+clear) + weather = "blight"; + else if (random >= thunder+rain+overcast+foggy+cloudy+clear) + weather = "ashstorm"; + else if (random >= rain+overcast+foggy+cloudy+clear) + weather = "thunderstorm"; + else if (random >= overcast+foggy+cloudy+clear) + weather = "rain"; + else if (random >= foggy+cloudy+clear) + weather = "overcast"; + else if (random >= cloudy+clear) + weather = "foggy"; + else if (random >= clear) + weather = "cloudy"; + else + weather = "clear"; + } + + setWeather(weather, false); + /* + std::cout << "roll result: " << random << std::endl; + + std::cout << regionstr << " weather probabilities: " << clear << " " << cloudy << " " << foggy << " " + << overcast << " " << rain << " " << thunder << " " << ash << " " << blight << " " << snow << " " + << blizzard << std::endl; + + std::cout << "New weather : " << weather << std::endl; + */ + } + + WeatherResult result; + + if (mNextWeather != "") + { + mRemainingTransitionTime -= duration; + if (mRemainingTransitionTime < 0) + { + mCurrentWeather = mNextWeather; + mNextWeather = ""; + } + } + + if (mNextWeather != "") + result = transition(1-(mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60))); + else + result = getResult(mCurrentWeather); + + mRendering->configureFog(result.mFogDepth, result.mFogColor); + + // disable sun during night + if (mHour >= WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration + || mHour <= WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) + mRendering->getSkyManager()->sunDisable(); + else + { + // during day, calculate sun angle + float height = 1-std::abs(((mHour-13)/7.f)); + int facing = mHour > 13.f ? 1 : -1; + Vector3 final( + (1-height)*facing, + (1-height)*facing, + height); + mRendering->setSunDirection(final); + + mRendering->getSkyManager()->sunEnable(); + } + + // moon calculations + float night; + if (mHour >= 14) + night = mHour-14; + else if (mHour <= 10) + night = mHour+10; + else + night = 0; + + night /= 20.f; + + if (night != 0) + { + float moonHeight = 1-std::abs((night-0.5)*2); + int facing = (mHour > 0.f && mHour<12.f) ? 1 : -1; + Vector3 masser( + (1-moonHeight)*facing, + (1-moonHeight)*facing, + moonHeight); + + Vector3 secunda( + (1-moonHeight)*facing*0.8, + (1-moonHeight)*facing*1.25, + moonHeight); + + mRendering->getSkyManager()->setMasserDirection(masser); + mRendering->getSkyManager()->setSecundaDirection(secunda); + mRendering->getSkyManager()->masserEnable(); + mRendering->getSkyManager()->secundaEnable(); + + float hour_fade; + if (mHour >= 7.f && mHour <= 14.f) + hour_fade = 1-(mHour-7)/3.f; + else if (mHour >= 14 && mHour <= 15.f) + hour_fade = mHour-14; + else + hour_fade = 1; + + float secunda_angle_fade; + float masser_angle_fade; + float angle = moonHeight*90.f; + + if (angle >= 30 && angle <= 50) + secunda_angle_fade = (angle-30)/20.f; + else if (angle <30) + secunda_angle_fade = 0.f; + else + secunda_angle_fade = 1.f; + + if (angle >= 40 && angle <= 50) + masser_angle_fade = (angle-40)/10.f; + else if (angle <40) + masser_angle_fade = 0.f; + else + masser_angle_fade = 1.f; + + masser_angle_fade *= hour_fade; + secunda_angle_fade *= hour_fade; + + mRendering->getSkyManager()->setMasserFade(masser_angle_fade); + mRendering->getSkyManager()->setSecundaFade(secunda_angle_fade); + } + else + { + mRendering->getSkyManager()->masserDisable(); + mRendering->getSkyManager()->secundaDisable(); + } + + if (mCurrentWeather == "thunderstorm" && mNextWeather == "") + { + if (mThunderFlash > 0) + { + // play the sound after a delay + mThunderSoundDelay -= duration; + if (mThunderSoundDelay <= 0) + { + // pick a random sound + int sound = rand() % 4; + std::string soundname; + if (sound == 0) soundname = WeatherGlobals::mThunderSoundID0; + else if (sound == 1) soundname = WeatherGlobals::mThunderSoundID1; + else if (sound == 2) soundname = WeatherGlobals::mThunderSoundID2; + else if (sound == 3) soundname = WeatherGlobals::mThunderSoundID3; + mEnvironment->mSoundManager->playSound(soundname, 1.0, 1.0); + mThunderSoundDelay = 1000; + } + + mThunderFlash -= duration; + if (mThunderFlash > 0) + mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold ); + else + { + srand(time(NULL)); + mThunderChanceNeeded = rand() % 100; + mThunderChance = 0; + mRendering->getSkyManager()->setThunder( 0.f ); + } + } + else + { + // no thunder active + mThunderChance += duration*4; // chance increases by 4 percent every second + if (mThunderChance >= mThunderChanceNeeded) + { + mThunderFlash = WeatherGlobals::mThunderThreshold; + + mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold ); + + mThunderSoundDelay = WeatherGlobals::mThunderSoundDelay; + } + } + } + else + mRendering->getSkyManager()->setThunder(0.f); + + mRendering->setAmbientColour(result.mAmbientColor); + mRendering->sunEnable(); + mRendering->setSunColour(result.mSunColor); + + mRendering->getSkyManager()->setWeather(result); + } + else + { + mRendering->sunDisable(); + mRendering->skyDisable(); + mRendering->getSkyManager()->setThunder(0.f); + } +} + +void WeatherManager::setHour(const float hour) +{ + // accelerate a bit for testing + /* + mHour += 0.005; + + if (mHour >= 24.f) mHour = 0.f; + + std::cout << "hour " << mHour << std::endl; + */ + + mHour = hour; +} + +void WeatherManager::setDate(const int day, const int month) +{ + mDay = day; + mMonth = month; +} + +unsigned int WeatherManager::getWeatherID() const +{ + // Source: http://www.uesp.net/wiki/Tes3Mod:GetCurrentWeather + + if (mCurrentWeather == "clear") + return 0; + else if (mCurrentWeather == "cloudy") + return 1; + else if (mCurrentWeather == "foggy") + return 2; + else if (mCurrentWeather == "overcast") + return 3; + else if (mCurrentWeather == "rain") + return 4; + else if (mCurrentWeather == "thunderstorm") + return 5; + else if (mCurrentWeather == "ashstorm") + return 6; + else if (mCurrentWeather == "blight") + return 7; + else if (mCurrentWeather == "snow") + return 8; + else if (mCurrentWeather == "blizzard") + return 9; + + else + return 0; +} + +void WeatherManager::changeWeather(const std::string& region, const unsigned int id) +{ + std::string weather; + if (id==0) + weather = "clear"; + else if (id==1) + weather = "cloudy"; + else if (id==2) + weather = "foggy"; + else if (id==3) + weather = "overcast"; + else if (id==4) + weather = "rain"; + else if (id==5) + weather = "thunderstorm"; + else if (id==6) + weather = "ashstorm"; + else if (id==7) + weather = "blight"; + else if (id==8) + weather = "snow"; + else if (id==9) + weather = "blizzard"; + else + weather = "clear"; + + mRegionOverrides[region] = weather; +} diff --git a/libs/openengine/bullet/weather.hpp b/libs/openengine/bullet/weather.hpp new file mode 100644 index 000000000..9353f7cd1 --- /dev/null +++ b/libs/openengine/bullet/weather.hpp @@ -0,0 +1,272 @@ +#ifndef GAME_MWWORLD_WEATHER_H +#define GAME_MWWORLD_WEATHER_H + +#include +#include + +namespace MWRender +{ + class RenderingManager; +} + +namespace MWWorld +{ + class Environment; + + /// Global weather manager properties (according to INI) + struct WeatherGlobals + { + /* + [Weather] + EnvReduceColor=255,255,255,255 + LerpCloseColor=037,046,048,255 + BumpFadeColor=230,239,255,255 + AlphaReduce=0.35 + Minimum Time Between Environmental Sounds=1.0 + Maximum Time Between Environmental Sounds=5.0 + Sun Glare Fader Max=0.5 + Sun Glare Fader Angle Max=30.0 + Sun Glare Fader Color=222,095,039 + Timescale Clouds=0 + Precip Gravity=575 + Hours Between Weather Changes=20 + Rain Ripples=1 + Rain Ripple Radius=1024 + Rain Ripples Per Drop=1 + Rain Ripple Scale=0.3 + Rain Ripple Speed=1.0 + Fog Depth Change Speed=3 + Sunrise Time=6 + Sunset Time=18 + Sunrise Duration=2 + Sunset Duration=2 + Sky Pre-Sunrise Time=.5 + Sky Post-Sunrise Time=1 + Sky Pre-Sunset Time=1.5 + Sky Post-Sunset Time=.5 + Ambient Pre-Sunrise Time=.5 + Ambient Post-Sunrise Time=2 + Ambient Pre-Sunset Time=1 + Ambient Post-Sunset Time=1.25 + Fog Pre-Sunrise Time=.5 + Fog Post-Sunrise Time=1 + Fog Pre-Sunset Time=2 + Fog Post-Sunset Time=1 + Sun Pre-Sunrise Time=0 + Sun Post-Sunrise Time=0 + Sun Pre-Sunset Time=1 + Sun Post-Sunset Time=1.25 + Stars Post-Sunset Start=1 + Stars Pre-Sunrise Finish=2 + Stars Fading Duration=2 + Snow Ripples=0 + Snow Ripple Radius=1024 + Snow Ripples Per Flake=1 + Snow Ripple Scale=0.3 + Snow Ripple Speed=1.0 + Snow Gravity Scale=0.1 + Snow High Kill=700 + Snow Low Kill=150 + + + [Moons] + Masser Size=94 + Masser Fade In Start=14 + Masser Fade In Finish=15 + Masser Fade Out Start=7 + Masser Fade Out Finish=10 + Masser Axis Offset=35 + Masser Speed=.5 + Masser Daily Increment=1 + Masser Fade Start Angle=50 + Masser Fade End Angle=40 + Masser Moon Shadow Early Fade Angle=0.5 + Secunda Size=40 + Secunda Fade In Start=14 + Secunda Fade In Finish=15 + Secunda Fade Out Start=7 + Secunda Fade Out Finish=10 + Secunda Axis Offset=50 + Secunda Speed=.6 + Secunda Daily Increment=1.2 + Secunda Fade Start Angle=50 + Secunda Fade End Angle=30 + Secunda Moon Shadow Early Fade Angle=0.5 + Script Color=255,20,20 + */ + + static const float mSunriseTime; + static const float mSunsetTime; + static const float mSunriseDuration; + static const float mSunsetDuration; + + static const float mWeatherUpdateTime; + + // morrowind sets these per-weather, but since they are only used by 'thunderstorm' + // weather setting anyway, we can just as well set them globally + static const float mThunderFrequency; + static const float mThunderThreshold; + static const float mThunderSoundDelay; + static const std::string mThunderSoundID0; + static const std::string mThunderSoundID1; + static const std::string mThunderSoundID2; + static const std::string mThunderSoundID3; + }; + + /// Defines the actual weather that results from weather setting (see below), time of day and weather transition + struct WeatherResult + { + Ogre::String mCloudTexture; + Ogre::String mNextCloudTexture; + float mCloudBlendFactor; + + Ogre::ColourValue mFogColor; + + Ogre::ColourValue mAmbientColor; + + Ogre::ColourValue mSkyColor; + + Ogre::ColourValue mSunColor; + + Ogre::ColourValue mSunDiscColor; + + float mFogDepth; + + float mWindSpeed; + + float mCloudSpeed; + + float mCloudOpacity; + + float mGlareView; + + bool mNight; // use night skybox + float mNightFade; // fading factor for night skybox + + Ogre::String mAmbientLoopSoundID; + }; + + + /// Defines a single weather setting (according to INI) + struct Weather + { + Ogre::String mCloudTexture; + + // Sky (atmosphere) colors + Ogre::ColourValue mSkySunriseColor, + mSkyDayColor, + mSkySunsetColor, + mSkyNightColor; + + // Fog colors + Ogre::ColourValue mFogSunriseColor, + mFogDayColor, + mFogSunsetColor, + mFogNightColor; + + // Ambient lighting colors + Ogre::ColourValue mAmbientSunriseColor, + mAmbientDayColor, + mAmbientSunsetColor, + mAmbientNightColor; + + // Sun (directional) lighting colors + Ogre::ColourValue mSunSunriseColor, + mSunDayColor, + mSunSunsetColor, + mSunNightColor; + + // Fog depth/density + float mLandFogDayDepth, + mLandFogNightDepth; + + // Color modulation for the sun itself during sunset (not completely sure) + Ogre::ColourValue mSunDiscSunsetColor; + + // Duration of weather transition (in days) + float mTransitionDelta; + + // No idea what this one is used for? + float mWindSpeed; + + // Cloud animation speed multiplier + float mCloudSpeed; + + // Multiplier for clouds transparency + float mCloudsMaximumPercent; + + // Value between 0 and 1, defines the strength of the sun glare effect + float mGlareView; + + // Sound effect + // This is used for Blight, Ashstorm and Blizzard (Bloodmoon) + Ogre::String mAmbientLoopSoundID; + + // Rain sound effect + Ogre::String mRainLoopSoundID; + + /// \todo disease chance + }; + + /// + /// Interface for weather settings + /// + class WeatherManager + { + public: + WeatherManager(MWRender::RenderingManager*, MWWorld::Environment*); + + /** + * Change the weather in the specified region + * @param region that should be changed + * @param ID of the weather setting to shift to + */ + void changeWeather(const std::string& region, const unsigned int id); + + /** + * Per-frame update + * @param duration + */ + void update(float duration); + + void setHour(const float hour); + + void setDate(const int day, const int month); + + unsigned int getWeatherID() const; + + private: + float mHour; + int mDay, mMonth; + + MWRender::RenderingManager* mRendering; + MWWorld::Environment* mEnvironment; + + std::map mWeatherSettings; + + std::map mRegionOverrides; + + Ogre::String mCurrentWeather; + Ogre::String mNextWeather; + + std::string mCurrentRegion; + + bool mFirstUpdate; + + float mWeatherUpdateTime; + + float mRemainingTransitionTime; + + float mThunderFlash; + float mThunderChance; + float mThunderChanceNeeded; + float mThunderSoundDelay; + + WeatherResult transition(const float factor); + WeatherResult getResult(const Ogre::String& weather); + + void setWeather(const Ogre::String& weather, bool instant=false); + }; +} + +#endif // GAME_MWWORLD_WEATHER_H From e4251be5299c7114a9b3f9053b5bb35706062453 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 25 Mar 2012 15:16:02 -0400 Subject: [PATCH 004/109] Down gravity --- apps/openmw/mwworld/physicssystem.cpp | 1 + libs/openengine/bullet/pmove.cpp | 75 +-- libs/openengine/bullet/trace.cpp | 10 +- libs/openengine/bullet/weather.cpp | 811 -------------------------- libs/openengine/bullet/weather.hpp | 272 --------- 5 files changed, 46 insertions(+), 1123 deletions(-) delete mode 100644 libs/openengine/bullet/weather.cpp delete mode 100644 libs/openengine/bullet/weather.hpp diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index d54f4696a..15d2d3f9f 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -148,6 +148,7 @@ namespace MWWorld if(it->first == "player"){ coord = playerphysics->ps.origin; + //std::cout << "ZCoord: " << coord.z << "\n"; //std::cout << "Coord" << coord << "\n"; //coord = Ogre::Vector3(coord.x, coord.z, coord.y); //x, z, -y diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 71c15fe45..8dd01ef19 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -178,7 +178,7 @@ bool PM_SlideMove( bool gravity ) float into; Ogre::Vector3 endVelocity; Ogre::Vector3 endClipVelocity; - + std::cout << "Slide move\n"; numbumps = 4; // primal_velocity = pm->ps->velocity @@ -191,14 +191,14 @@ bool PM_SlideMove( bool gravity ) //VectorCopy( pm->ps->velocity, endVelocity ); endVelocity = pm->ps.velocity; //endVelocity[2] -= pm->ps->gravity * pml.frametime; - endVelocity.y -= pm->ps.gravity * pml.frametime; + endVelocity.z -= pm->ps.gravity * pml.frametime; // pm->ps->velocity = avg(pm->ps->velocity.z, endVelocity.z) //pm->ps->velocity[2] = ( pm->ps->velocity[2] + endVelocity[2] ) * 0.5; - pm->ps.velocity.y= (pm->ps.velocity.y + endVelocity.y) * 0.5f; + pm->ps.velocity.z= (pm->ps.velocity.z + endVelocity.z) * 0.5f; //primal_velocity[2] = endVelocity[2]; - primal_velocity.y = endVelocity.y; + primal_velocity.z = endVelocity.z; if ( pml.groundPlane ) // slide along the ground plane @@ -239,7 +239,7 @@ bool PM_SlideMove( bool gravity ) { // entity is completely trapped in another solid //pm->ps->velocity[2] = 0; // don't build up falling damage, but allow sideways acceleration - pm->ps.velocity.y = 0; + pm->ps.velocity.z = 0; return true; } @@ -427,10 +427,11 @@ int PM_StepSlideMove( bool gravity ) if ( PM_SlideMove( gravity ) == false ) return 1; // we got exactly where we wanted to go first try + std::cout << "Step Slide move\n"; // down = start_o - vec3(0, 0, STEPSIZE) //VectorCopy(start_o, down); down = start_o; - down.y -= STEPSIZE; + down.z -= STEPSIZE; //pm->trace (&trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask); //tracefunc(&trace, start_o, down, , 0, pml.scene); @@ -439,11 +440,11 @@ int PM_StepSlideMove( bool gravity ) // up = vec3(0, 0, 1) //VectorSet(up, 0, 0, 1); - up = Ogre::Vector3(0.0f, 1.0f, 0.0f); + up = Ogre::Vector3(0.0f, 0.0f, 1.0f); // never step up when you still have up velocity //if ( pm->ps->velocity[2] > 0 && (trace.fraction == 1.0 || DotProduct(trace.plane.normal, up) < 0.7)) - if (pm->ps.velocity.y > 0 && ( + if (pm->ps.velocity.z > 0 && ( trace.fraction == 1.0 || trace.planenormal.dotProduct(up) < 0.7 ) ) return 2; @@ -460,7 +461,7 @@ int PM_StepSlideMove( bool gravity ) //VectorCopy (start_o, up); up = start_o; //up[2] += STEPSIZE; - up.y += STEPSIZE; + up.z += STEPSIZE; // test the player position if they were a stepheight higher //pm->trace (&trace, start_o, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask); @@ -475,7 +476,7 @@ int PM_StepSlideMove( bool gravity ) } //stepSize = trace.endpos[2] - start_o[2]; - stepSize = trace.endpos.y - start_o.y; + stepSize = trace.endpos.z - start_o.z; // try slidemove from this position //VectorCopy (trace.endpos, pm->ps->origin); // pm->ps->origin = trace.endpos @@ -491,7 +492,7 @@ int PM_StepSlideMove( bool gravity ) //VectorCopy (pm->ps->origin, down); down = pm->ps.origin; //down[2] -= stepSize; - down.y -= stepSize; + down.z -= stepSize; //pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask); @@ -510,7 +511,7 @@ int PM_StepSlideMove( bool gravity ) float delta; //delta = pm->ps->origin[2] - start_o[2]; - delta = pm->ps.origin.y - start_o.y; + delta = pm->ps.origin.z - start_o.z; if ( delta > 2 ) { if (gravity) @@ -541,6 +542,7 @@ int PM_StepSlideMove( bool gravity ) void PM_Friction(void) { + std::cout << "Friction\n"; Ogre::Vector3 vec; float* vel; float speed, newspeed, control; @@ -554,14 +556,14 @@ void PM_Friction(void) if ( pml.walking ) //vec[2] = 0; // ignore slope movement - vec.y = 0; + vec.z = 0; //speed = VectorLength(vec); speed = vec.length(); if (speed < 1) { vel[0] = 0; - vel[2] = 0; // allow sinking underwater + vel[1] = 0; // allow sinking underwater // FIXME: still have z friction underwater? //bprintf("Static friction (vec = [%f, %f, %f]) (vec.length = %f)\n", vec.x, vec.y, vec.z, speed); return; @@ -636,6 +638,7 @@ static void PM_Accelerate( Ogre::Vector3& wishdir, float wishspeed, float accel { // int i; float addspeed, accelspeed, currentspeed; + std::cout << "Accelerate\n"; // currentspeed = pm->ps->velocity dot wishdir //currentspeed = DotProduct (pm->ps->velocity, wishdir); @@ -681,7 +684,7 @@ static bool PM_CheckJump(void) //pm->ps->pm_flags |= PMF_JUMP_HELD; pm->ps.groundEntityNum = ENTITYNUM_NONE; - pm->ps.velocity.y = JUMP_VELOCITY; + pm->ps.velocity.z = JUMP_VELOCITY; //PM_AddEvent( EV_JUMP ); /*if ( pm->cmd.forwardmove >= 0 ) @@ -776,8 +779,8 @@ static void PM_WaterMove( playerMove* const pm ) wishvel[2] = -60; // sink towards bottom */ wishvel.x = 0; - wishvel.y = -60; - wishvel.z = 0; + wishvel.z = -60; + wishvel.y = 0; } else { @@ -834,6 +837,7 @@ static void PM_WalkMove( playerMove* const pmove ) playerMove::playercmd cmd; float accelerate; float vel; + std::cout << "Walking\n"; if ( pm->ps.waterlevel > 2 && //DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) pml.forward.dotProduct(pml.groundTrace.planenormal) > 0.0f) @@ -937,10 +941,10 @@ static void PM_WalkMove( playerMove* const pmove ) // project moves down to flat plane //pml.forward[2] = 0; - pml.forward.y = 0; + pml.forward.z = 0; //pml.right[2] = 0; - pml.right.y = 0; + pml.right.z = 0; // project the forward and right directions onto the ground plane PM_ClipVelocity (pml.forward, pml.groundTrace.planenormal, pml.forward, OVERCLIP ); @@ -1035,7 +1039,7 @@ void PM_UpdateViewAngles( playerMove::playerStruct* const ps, playerMove::player { short temp; int i; - + std::cout << "Updating viewangles\n"; //while(1); //if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPINTERMISSION) @@ -1128,7 +1132,7 @@ void PM_GroundTraceMissed() //VectorCopy( pm->ps->origin, point ); point = pm->ps.origin; //point[2] -= 64; - point.y -= 64; + point.z -= 64; //pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); //tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, -64.0f, 0.0f), 0, pml.traceObj); @@ -1188,7 +1192,7 @@ static bool PM_CorrectAllSolid(traceResults* const trace) point[1] = pm->ps->origin[1]; point[2] = pm->ps->origin[2] - 0.25;*/ point = pm->ps.origin; - point.y -= 0.25f; + point.z -= 0.25f; //pm->trace (trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); //tracefunc(trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, -0.25f, 0.0f), 0, pml.traceObj); @@ -1215,7 +1219,7 @@ static void PM_CrashLand( void ) float vel, acc; float t; float a, b, c, den; - + std::cout << "Crash land\n"; // decide which landing animation to use /*if ( pm->ps->pm_flags & PMF_BACKWARDS_JUMP ) PM_ForceLegsAnim( LEGS_LANDB ); @@ -1227,10 +1231,10 @@ static void PM_CrashLand( void ) // calculate the exact velocity on landing //dist = pm->ps->origin[2] - pml.previous_origin[2]; - dist = pm->ps.origin.y - pml.previous_origin.y; + dist = pm->ps.origin.z - pml.previous_origin.z; //vel = pml.previous_velocity[2]; - vel = pml.previous_velocity.y; + vel = pml.previous_velocity.z; //acc = -pm->ps->gravity; acc = -pm->ps.gravity; @@ -1294,7 +1298,7 @@ static void PM_CrashLand( void ) const float waterHeight = pm->waterHeight; const float waterHeightSplash = waterHeight + halfExtents.y; - if (pm->ps.origin.y < waterHeightSplash) + if (pm->ps.origin.z < waterHeightSplash) { splashSound = true; } @@ -1357,7 +1361,7 @@ static void PM_CrashLand( void ) static void PM_GroundTrace( void ) { - //std::cout << "Ground trace\n"; + std::cout << "Ground trace\n"; Ogre::Vector3 point; traceResults trace; @@ -1365,7 +1369,7 @@ static void PM_GroundTrace( void ) point[1] = pm->ps->origin[1]; point[2] = pm->ps->origin[2] - 0.25;*/ point = pm->ps.origin; - point.y -= 0.25f; + point.z -= 0.25f; //pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); //tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, -0.25f, 0.0f), 0, pml.traceObj); @@ -1392,7 +1396,7 @@ static void PM_GroundTrace( void ) // check if getting thrown off the ground //if ( pm->ps->velocity[2] > 0 && DotProduct( pm->ps->velocity, trace.plane.normal ) > 10 ) - if (pm->ps.velocity.y > 0 && pm->ps.velocity.dotProduct(trace.planenormal) > 10.0f) + if (pm->ps.velocity.z > 0 && pm->ps.velocity.dotProduct(trace.planenormal) > 10.0f) { //if ( pm->debugLevel ) //Com_Printf("%i:kickoff\n", c_pmove); @@ -1417,7 +1421,7 @@ static void PM_GroundTrace( void ) // slopes that are too steep will not be considered onground //if ( trace.plane.normal[2] < MIN_WALK_NORMAL ) - if (trace.planenormal.y < MIN_WALK_NORMAL) + if (trace.planenormal.z < MIN_WALK_NORMAL) { //if ( pm->debugLevel ) //Com_Printf("%i:steep\n", c_pmove); @@ -1451,7 +1455,7 @@ static void PM_GroundTrace( void ) // don't do landing time if we were just going down a slope //if ( pml.previous_velocity[2] < -200 ) - if (pml.previous_velocity.y < -200) + if (pml.previous_velocity.z < -200) { // don't allow another jump for a little while //pm->ps->pm_flags |= PMF_TIME_LAND; @@ -1469,6 +1473,7 @@ static void PM_GroundTrace( void ) static void PM_AirMove() { + std::cout << "Air move\n"; //int i; Ogre::Vector3 wishvel; float fmove, smove; @@ -1490,7 +1495,7 @@ static void PM_AirMove() // project moves down to flat plane //pml.forward[2] = 0; - pml.forward.y = 0; + pml.forward.y = 0; //Z or Y? //pml.right[2] = 0; pml.right.y = 0; //VectorNormalize (pml.forward); @@ -1503,7 +1508,7 @@ static void PM_AirMove() wishvel = pml.forward * fmove + pml.right * smove; //wishvel[2] = 0; - wishvel.y = 0; + wishvel.z = 0; //VectorCopy (wishvel, wishdir); wishdir = wishvel; @@ -1659,7 +1664,7 @@ static void PM_FlyMove( void ) wishvel = pml.forward * scale * pm->cmd.forwardmove + pml.right * scale * pm->cmd.rightmove; //wishvel[2] += scale * pm->cmd.upmove; - wishvel.y += /*6.35f * */pm->cmd.upmove * scale; + wishvel.z += /*6.35f * */pm->cmd.upmove * scale; } //VectorCopy (wishvel, wishdir); @@ -1939,7 +1944,7 @@ void PmoveSingle (playerMove* const pmove) PM_WaterMove(pmove); else if ( pml.walking ) { - std::cout << "WALKING\n"; + // walking on ground PM_WalkMove(pmove); //bprintf("WalkMove\n"); diff --git a/libs/openengine/bullet/trace.cpp b/libs/openengine/bullet/trace.cpp index 57d071f17..8f2423c24 100644 --- a/libs/openengine/bullet/trace.cpp +++ b/libs/openengine/bullet/trace.cpp @@ -28,11 +28,11 @@ void newtrace(traceResults* const results, const Ogre::Vector3& start, const Ogr NewPhysTraceResults out; //std::cout << "Starting trace\n"; - Ogre::Vector3 startReplace = Ogre::Vector3(650,950, 45); - Ogre::Vector3 endReplace = startReplace; - endReplace.y -= .25; + //Ogre::Vector3 startReplace = Ogre::Vector3(650,950, 45); + //Ogre::Vector3 endReplace = startReplace; + //endReplace.z -= .25; - const bool hasHit = NewPhysicsTrace(&out, start, end, BBHalfExtents, Ogre::Vector3(0.0f, rotation, 0.0f), isInterior, enginePass); + const bool hasHit = NewPhysicsTrace(&out, start, end, BBHalfExtents, Ogre::Vector3(0.0f, 0.0f, rotation), isInterior, enginePass); if(hasHit) std::cout << "Has hit\n"; if (out.fraction < 0.001f) @@ -65,7 +65,7 @@ void newtrace(traceResults* const results, const Ogre::Vector3& start, const Ogr if (!hasHit) { results->endpos = end; - results->planenormal = Ogre::Vector3(0.0f, 1.0f, 0.0f); + results->planenormal = Ogre::Vector3(0.0f, 0.0f, 1.0f); results->entityNum = ENTITYNUM_NONE; results->fraction = 1.0f; } diff --git a/libs/openengine/bullet/weather.cpp b/libs/openengine/bullet/weather.cpp deleted file mode 100644 index 90afc4e78..000000000 --- a/libs/openengine/bullet/weather.cpp +++ /dev/null @@ -1,811 +0,0 @@ -#include "weather.hpp" -#include "world.hpp" -#include "player.hpp" - -#include "../mwrender/renderingmanager.hpp" -#include "../mwsound/soundmanager.hpp" - -#include -#include -#include - -#include - -using namespace Ogre; -using namespace MWWorld; -using namespace MWSound; - -#define lerp(x, y) (x * (1-factor) + y * factor) - -const std::string WeatherGlobals::mThunderSoundID0 = "Thunder0"; -const std::string WeatherGlobals::mThunderSoundID1 = "Thunder1"; -const std::string WeatherGlobals::mThunderSoundID2 = "Thunder2"; -const std::string WeatherGlobals::mThunderSoundID3 = "Thunder3"; -const float WeatherGlobals::mSunriseTime = 8; -const float WeatherGlobals::mSunsetTime = 18; -const float WeatherGlobals::mSunriseDuration = 2; -const float WeatherGlobals::mSunsetDuration = 2; -const float WeatherGlobals::mWeatherUpdateTime = 20.f; -const float WeatherGlobals::mThunderFrequency = .4; -const float WeatherGlobals::mThunderThreshold = 0.6; -const float WeatherGlobals::mThunderSoundDelay = 0.25; - -WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environment* env) : - mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0), - mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0) -{ - mRendering = rendering; - mEnvironment = env; - - #define clr(r,g,b) ColourValue(r/255.f, g/255.f, b/255.f) - - /// \todo read these from Morrowind.ini - Weather clear; - clear.mCloudTexture = "tx_sky_clear.dds"; - clear.mCloudsMaximumPercent = 1.0; - clear.mTransitionDelta = 0.015; - clear.mSkySunriseColor = clr(118, 141, 164); - clear.mSkyDayColor = clr(95, 135, 203); - clear.mSkySunsetColor = clr(56, 89, 129); - clear.mSkyNightColor = clr(9, 10, 11); - clear.mFogSunriseColor = clr(255, 189, 157); - clear.mFogDayColor = clr(206, 227, 255); - clear.mFogSunsetColor = clr(255, 189, 157); - clear.mFogNightColor = clr(9, 10, 11); - clear.mAmbientSunriseColor = clr(47, 66, 96); - clear.mAmbientDayColor = clr(137, 140, 160); - clear.mAmbientSunsetColor = clr(68, 75, 96); - clear.mAmbientNightColor = clr(32, 35, 42); - clear.mSunSunriseColor = clr(242, 159, 99); - clear.mSunDayColor = clr(255, 252, 238); - clear.mSunSunsetColor = clr(255, 115, 79); - clear.mSunNightColor = clr(59, 97, 176); - clear.mSunDiscSunsetColor = clr(255, 189, 157); - clear.mLandFogDayDepth = 0.69; - clear.mLandFogNightDepth = 0.69; - clear.mWindSpeed = 0.1; - clear.mCloudSpeed = 1.25; - clear.mGlareView = 1.0; - mWeatherSettings["clear"] = clear; - - Weather cloudy; - cloudy.mCloudTexture = "tx_sky_cloudy.dds"; - cloudy.mCloudsMaximumPercent = 1.0; - cloudy.mTransitionDelta = 0.015; - cloudy.mSkySunriseColor = clr(126, 158, 173); - cloudy.mSkyDayColor = clr(117, 160, 215); - cloudy.mSkySunsetColor = clr(111, 114, 159); - cloudy.mSkyNightColor = clr(9, 10, 11); - cloudy.mFogSunriseColor = clr(255, 207, 149); - cloudy.mFogDayColor = clr(245, 235, 224); - cloudy.mFogSunsetColor = clr(255, 155, 106); - cloudy.mFogNightColor = clr(9, 10, 11); - cloudy.mAmbientSunriseColor = clr(66, 74, 87); - cloudy.mAmbientDayColor = clr(137, 145, 160); - cloudy.mAmbientSunsetColor = clr(71, 80, 92); - cloudy.mAmbientNightColor = clr(32, 39, 54); - cloudy.mSunSunriseColor = clr(241, 177, 99); - cloudy.mSunDayColor = clr(255, 236, 221); - cloudy.mSunSunsetColor = clr(255, 89, 00); - cloudy.mSunNightColor = clr(77, 91, 124); - cloudy.mSunDiscSunsetColor = clr(255, 202, 179); - cloudy.mLandFogDayDepth = 0.72; - cloudy.mLandFogNightDepth = 0.72; - cloudy.mWindSpeed = 0.2; - cloudy.mCloudSpeed = 2; - cloudy.mGlareView = 1.0; - mWeatherSettings["cloudy"] = cloudy; - - Weather foggy; - foggy.mCloudTexture = "tx_sky_foggy.dds"; - foggy.mCloudsMaximumPercent = 1.0; - foggy.mTransitionDelta = 0.015; - foggy.mSkySunriseColor = clr(197, 190, 180); - foggy.mSkyDayColor = clr(184, 211, 228); - foggy.mSkySunsetColor = clr(142, 159, 176); - foggy.mSkyNightColor = clr(18, 23, 28); - foggy.mFogSunriseColor = clr(173, 164, 148); - foggy.mFogDayColor = clr(150, 187, 209); - foggy.mFogSunsetColor = clr(113, 135, 157); - foggy.mFogNightColor = clr(19, 24, 29); - foggy.mAmbientSunriseColor = clr(48, 43, 37); - foggy.mAmbientDayColor = clr(92, 109, 120); - foggy.mAmbientSunsetColor = clr(28, 33, 39); - foggy.mAmbientNightColor = clr(28, 33, 39); - foggy.mSunSunriseColor = clr(177, 162, 137); - foggy.mSunDayColor = clr(111, 131, 151); - foggy.mSunSunsetColor = clr(125, 157, 189); - foggy.mSunNightColor = clr(81, 100, 119); - foggy.mSunDiscSunsetColor = clr(223, 223, 223); - foggy.mLandFogDayDepth = 1.0; - foggy.mLandFogNightDepth = 1.9; - foggy.mWindSpeed = 0; - foggy.mCloudSpeed = 1.25; - foggy.mGlareView = 0.25; - mWeatherSettings["foggy"] = foggy; - - Weather thunderstorm; - thunderstorm.mCloudTexture = "tx_sky_thunder.dds"; - thunderstorm.mCloudsMaximumPercent = 0.66; - thunderstorm.mTransitionDelta = 0.03; - thunderstorm.mSkySunriseColor = clr(35, 36, 39); - thunderstorm.mSkyDayColor = clr(97, 104, 115); - thunderstorm.mSkySunsetColor = clr(35, 36, 39); - thunderstorm.mSkyNightColor = clr(19, 20, 22); - thunderstorm.mFogSunriseColor = clr(70, 74, 85); - thunderstorm.mFogDayColor = clr(97, 104, 115); - thunderstorm.mFogSunsetColor = clr(70, 74, 85); - thunderstorm.mFogNightColor = clr(19, 20, 22); - thunderstorm.mAmbientSunriseColor = clr(54, 54, 54); - thunderstorm.mAmbientDayColor = clr(90, 90, 90); - thunderstorm.mAmbientSunsetColor = clr(54, 54, 54); - thunderstorm.mAmbientNightColor = clr(49, 51, 54); - thunderstorm.mSunSunriseColor = clr(91, 99, 122); - thunderstorm.mSunDayColor = clr(138, 144, 155); - thunderstorm.mSunSunsetColor = clr(96, 101, 117); - thunderstorm.mSunNightColor = clr(55, 76, 110); - thunderstorm.mSunDiscSunsetColor = clr(128, 128, 128); - thunderstorm.mLandFogDayDepth = 1; - thunderstorm.mLandFogNightDepth = 1.15; - thunderstorm.mWindSpeed = 0.5; - thunderstorm.mCloudSpeed = 3; - thunderstorm.mGlareView = 0; - thunderstorm.mRainLoopSoundID = "rain heavy"; - mWeatherSettings["thunderstorm"] = thunderstorm; - - Weather rain; - rain.mCloudTexture = "tx_sky_rainy.dds"; - rain.mCloudsMaximumPercent = 0.66; - rain.mTransitionDelta = 0.015; - rain.mSkySunriseColor = clr(71, 74, 75); - rain.mSkyDayColor = clr(116, 120, 122); - rain.mSkySunsetColor = clr(73, 73, 73); - rain.mSkyNightColor = clr(24, 25, 26); - rain.mFogSunriseColor = clr(71, 74, 75); - rain.mFogDayColor = clr(116, 120, 122); - rain.mFogSunsetColor = clr(73, 73, 73); - rain.mFogNightColor = clr(24, 25, 26); - rain.mAmbientSunriseColor = clr(97, 90, 88); - rain.mAmbientDayColor = clr(105, 110, 113); - rain.mAmbientSunsetColor = clr(88, 97, 97); - rain.mAmbientNightColor = clr(50, 55, 67); - rain.mSunSunriseColor = clr(131, 122, 120); - rain.mSunDayColor = clr(149, 157, 170); - rain.mSunSunsetColor = clr(120, 126, 131); - rain.mSunNightColor = clr(50, 62, 101); - rain.mSunDiscSunsetColor = clr(128, 128, 128); - rain.mLandFogDayDepth = 0.8; - rain.mLandFogNightDepth = 0.8; - rain.mWindSpeed = 0.3; - rain.mCloudSpeed = 2; - rain.mGlareView = 0; - rain.mRainLoopSoundID = "rain"; - mWeatherSettings["rain"] = rain; - - Weather overcast; - overcast.mCloudTexture = "tx_sky_overcast.dds"; - overcast.mCloudsMaximumPercent = 1.0; - overcast.mTransitionDelta = 0.015; - overcast.mSkySunriseColor = clr(91, 99, 106); - overcast.mSkyDayColor = clr(143, 146, 149); - overcast.mSkySunsetColor = clr(108, 115, 121); - overcast.mSkyNightColor = clr(19, 22, 25); - overcast.mFogSunriseColor = clr(91, 99, 106); - overcast.mFogDayColor = clr(143, 146, 149); - overcast.mFogSunsetColor = clr(108, 115, 121); - overcast.mFogNightColor = clr(19, 22, 25); - overcast.mAmbientSunriseColor = clr(84, 88, 92); - overcast.mAmbientDayColor = clr(93, 96, 105); - overcast.mAmbientSunsetColor = clr(83, 77, 75); - overcast.mAmbientNightColor = clr(57, 60, 66); - overcast.mSunSunriseColor = clr(87, 125, 163); - overcast.mSunDayColor = clr(163, 169, 183); - overcast.mSunSunsetColor = clr(85, 103, 157); - overcast.mSunNightColor = clr(32, 54, 100); - overcast.mSunDiscSunsetColor = clr(128, 128, 128); - overcast.mLandFogDayDepth = 0.7; - overcast.mLandFogNightDepth = 0.7; - overcast.mWindSpeed = 0.2; - overcast.mCloudSpeed = 1.5; - overcast.mGlareView = 0; - mWeatherSettings["overcast"] = overcast; - - Weather ashstorm; - ashstorm.mCloudTexture = "tx_sky_ashstorm.dds"; - ashstorm.mCloudsMaximumPercent = 1.0; - ashstorm.mTransitionDelta = 0.035; - ashstorm.mSkySunriseColor = clr(91, 56, 51); - ashstorm.mSkyDayColor = clr(124, 73, 58); - ashstorm.mSkySunsetColor = clr(106, 55, 40); - ashstorm.mSkyNightColor = clr(20, 21, 22); - ashstorm.mFogSunriseColor = clr(91, 56, 51); - ashstorm.mFogDayColor = clr(124, 73, 58); - ashstorm.mFogSunsetColor = clr(106, 55, 40); - ashstorm.mFogNightColor = clr(20, 21, 22); - ashstorm.mAmbientSunriseColor = clr(52, 42, 37); - ashstorm.mAmbientDayColor = clr(75, 49, 41); - ashstorm.mAmbientSunsetColor = clr(48, 39, 35); - ashstorm.mAmbientNightColor = clr(36, 42, 49); - ashstorm.mSunSunriseColor = clr(184, 91, 71); - ashstorm.mSunDayColor = clr(228, 139, 114); - ashstorm.mSunSunsetColor = clr(185, 86, 57); - ashstorm.mSunNightColor = clr(54, 66, 74); - ashstorm.mSunDiscSunsetColor = clr(128, 128, 128); - ashstorm.mLandFogDayDepth = 1.1; - ashstorm.mLandFogNightDepth = 1.2; - ashstorm.mWindSpeed = 0.8; - ashstorm.mCloudSpeed = 7; - ashstorm.mGlareView = 0; - ashstorm.mAmbientLoopSoundID = "ashstorm"; - mWeatherSettings["ashstorm"] = ashstorm; - - Weather blight; - blight.mCloudTexture = "tx_sky_blight.dds"; - blight.mCloudsMaximumPercent = 1.0; - blight.mTransitionDelta = 0.04; - blight.mSkySunriseColor = clr(90, 35, 35); - blight.mSkyDayColor = clr(90, 35, 35); - blight.mSkySunsetColor = clr(92, 33, 33); - blight.mSkyNightColor = clr(44, 14, 14); - blight.mFogSunriseColor = clr(90, 35, 35); - blight.mFogDayColor = clr(128, 19, 19); - blight.mFogSunsetColor = clr(92, 33, 33); - blight.mFogNightColor = clr(44, 14, 14); - blight.mAmbientSunriseColor = clr(61, 40, 40); - blight.mAmbientDayColor = clr(79, 54, 54); - blight.mAmbientSunsetColor = clr(61, 40, 40); - blight.mAmbientNightColor = clr(56, 58, 62); - blight.mSunSunriseColor = clr(180, 78, 78); - blight.mSunDayColor = clr(224, 84, 84); - blight.mSunSunsetColor = clr(180, 78, 78); - blight.mSunNightColor = clr(61, 91, 143); - blight.mSunDiscSunsetColor = clr(128, 128, 128); - blight.mLandFogDayDepth = 1.1; - blight.mLandFogNightDepth = 1.2; - blight.mWindSpeed = 0.9; - blight.mCloudSpeed = 9; - blight.mGlareView = 0; - blight.mAmbientLoopSoundID = "blight"; - mWeatherSettings["blight"] = blight; - - Weather snow; - snow.mCloudTexture = "tx_bm_sky_snow.dds"; - snow.mCloudsMaximumPercent = 1.0; - snow.mTransitionDelta = 0.014; - snow.mSkySunriseColor = clr(196, 91, 91); - snow.mSkyDayColor = clr(153, 158, 166); - snow.mSkySunsetColor = clr(96, 115, 134); - snow.mSkyNightColor = clr(31, 35, 39); - snow.mFogSunriseColor = clr(106, 91, 91); - snow.mFogDayColor = clr(153, 158, 166); - snow.mFogSunsetColor = clr(96, 115, 134); - snow.mFogNightColor = clr(31, 35, 39); - snow.mAmbientSunriseColor = clr(92, 84, 84); - snow.mAmbientDayColor = clr(93, 96, 105); - snow.mAmbientSunsetColor = clr(70, 79, 87); - snow.mAmbientNightColor = clr(49, 58, 68); - snow.mSunSunriseColor = clr(141, 109, 109); - snow.mSunDayColor = clr(163, 169, 183); - snow.mSunSunsetColor = clr(101, 121, 141); - snow.mSunNightColor = clr(55, 66, 77); - snow.mSunDiscSunsetColor = clr(128, 128, 128); - snow.mLandFogDayDepth = 1.0; - snow.mLandFogNightDepth = 1.2; - snow.mWindSpeed = 0; - snow.mCloudSpeed = 1.5; - snow.mGlareView = 0; - mWeatherSettings["snow"] = snow; - - Weather blizzard; - blizzard.mCloudTexture = "tx_bm_sky_blizzard.dds"; - blizzard.mCloudsMaximumPercent = 1.0; - blizzard.mTransitionDelta = 0.030; - blizzard.mSkySunriseColor = clr(91, 99, 106); - blizzard.mSkyDayColor = clr(121, 133, 145); - blizzard.mSkySunsetColor = clr(108, 115, 121); - blizzard.mSkyNightColor = clr(27, 29, 31); - blizzard.mFogSunriseColor = clr(91, 99, 106); - blizzard.mFogDayColor = clr(121, 133, 145); - blizzard.mFogSunsetColor = clr(108, 115, 121); - blizzard.mFogNightColor = clr(21, 24, 28); - blizzard.mAmbientSunriseColor = clr(84, 88, 92); - blizzard.mAmbientDayColor = clr(93, 96, 105); - blizzard.mAmbientSunsetColor = clr(83, 77, 75); - blizzard.mAmbientNightColor = clr(53, 62, 70); - blizzard.mSunSunriseColor = clr(114, 128, 146); - blizzard.mSunDayColor = clr(163, 169, 183); - blizzard.mSunSunsetColor = clr(106, 114, 136); - blizzard.mSunNightColor = clr(57, 66, 74); - blizzard.mSunDiscSunsetColor = clr(128, 128, 128); - blizzard.mLandFogDayDepth = 2.8; - blizzard.mLandFogNightDepth = 3.0; - blizzard.mWindSpeed = 0.9; - blizzard.mCloudSpeed = 7.5; - blizzard.mGlareView = 0; - blizzard.mAmbientLoopSoundID = "BM Blizzard"; - mWeatherSettings["blizzard"] = blizzard; -} - -void WeatherManager::setWeather(const String& weather, bool instant) -{ - if (instant || mFirstUpdate) - { - mNextWeather = ""; - mCurrentWeather = weather; - mFirstUpdate = false; - } - else - { - if (mNextWeather != "") - { - // transition more than 50% finished? - if (mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60) <= 0.5) - mCurrentWeather = mNextWeather; - } - - mNextWeather = weather; - mRemainingTransitionTime = mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60; - } -} - -WeatherResult WeatherManager::getResult(const String& weather) -{ - const Weather& current = mWeatherSettings[weather]; - WeatherResult result; - - result.mCloudTexture = current.mCloudTexture; - result.mCloudBlendFactor = 0; - result.mCloudOpacity = current.mCloudsMaximumPercent; - result.mWindSpeed = current.mWindSpeed; - result.mCloudSpeed = current.mCloudSpeed; - result.mGlareView = current.mGlareView; - result.mAmbientLoopSoundID = current.mAmbientLoopSoundID; - result.mSunColor = current.mSunDiscSunsetColor; - - const float fade_duration = current.mTransitionDelta * 24.f; - - result.mNight = (mHour < 6.f+fade_duration || mHour > 20.f-fade_duration); - - result.mFogDepth = result.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth; - - // night - if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) - || mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration)) - { - result.mFogColor = current.mFogNightColor; - result.mAmbientColor = current.mAmbientNightColor; - result.mSunColor = current.mSunNightColor; - result.mSkyColor = current.mSkyNightColor; - result.mNightFade = 1.f; - } - - // sunrise - else if (mHour >= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) && mHour <= WeatherGlobals::mSunriseTime) - { - if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration)) - { - // fade in - float advance = (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration)-mHour; - float factor = (advance / fade_duration); - result.mFogColor = lerp(current.mFogSunriseColor, current.mFogNightColor); - result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientNightColor); - result.mSunColor = lerp(current.mSunSunriseColor, current.mSunNightColor); - result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyNightColor); - result.mNightFade = factor; - } - else if (mHour >= (WeatherGlobals::mSunriseTime-fade_duration)) - { - // fade out - float advance = mHour-(WeatherGlobals::mSunriseTime-fade_duration); - float factor = advance / fade_duration; - result.mFogColor = lerp(current.mFogSunriseColor, current.mFogDayColor); - result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientDayColor); - result.mSunColor = lerp(current.mSunSunriseColor, current.mSunDayColor); - result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyDayColor); - } - else - { - result.mFogColor = current.mFogSunriseColor; - result.mAmbientColor = current.mAmbientSunriseColor; - result.mSunColor = current.mSunSunriseColor; - result.mSkyColor = current.mSkySunriseColor; - } - } - - // day - else if (mHour >= (WeatherGlobals::mSunriseTime) && mHour <= (WeatherGlobals::mSunsetTime)) - { - result.mFogColor = current.mFogDayColor; - result.mAmbientColor = current.mAmbientDayColor; - result.mSunColor = current.mSunDayColor; - result.mSkyColor = current.mSkyDayColor; - } - - // sunset - else if (mHour >= (WeatherGlobals::mSunsetTime) && mHour <= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration)) - { - if (mHour <= (WeatherGlobals::mSunsetTime+fade_duration)) - { - // fade in - float advance = (WeatherGlobals::mSunsetTime+fade_duration)-mHour; - float factor = (advance / fade_duration); - result.mFogColor = lerp(current.mFogSunsetColor, current.mFogDayColor); - result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientDayColor); - result.mSunColor = lerp(current.mSunSunsetColor, current.mSunDayColor); - result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyDayColor); - } - else if (mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration)) - { - // fade out - float advance = mHour-(WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration); - float factor = advance / fade_duration; - result.mFogColor = lerp(current.mFogSunsetColor, current.mFogNightColor); - result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientNightColor); - result.mSunColor = lerp(current.mSunSunsetColor, current.mSunNightColor); - result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyNightColor); - result.mNightFade = factor; - } - else - { - result.mFogColor = current.mFogSunsetColor; - result.mAmbientColor = current.mAmbientSunsetColor; - result.mSunColor = current.mSunSunsetColor; - result.mSkyColor = current.mSkySunsetColor; - } - } - - return result; -} - -WeatherResult WeatherManager::transition(float factor) -{ - const WeatherResult& current = getResult(mCurrentWeather); - const WeatherResult& other = getResult(mNextWeather); - WeatherResult result; - - result.mCloudTexture = current.mCloudTexture; - result.mNextCloudTexture = other.mCloudTexture; - result.mCloudBlendFactor = factor; - - result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); - result.mFogColor = lerp(current.mFogColor, other.mFogColor); - result.mSunColor = lerp(current.mSunColor, other.mSunColor); - result.mSkyColor = lerp(current.mSkyColor, other.mSkyColor); - - result.mAmbientColor = lerp(current.mAmbientColor, other.mAmbientColor); - result.mSunDiscColor = lerp(current.mSunDiscColor, other.mSunDiscColor); - result.mFogDepth = lerp(current.mFogDepth, other.mFogDepth); - result.mWindSpeed = lerp(current.mWindSpeed, other.mWindSpeed); - result.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed); - result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); - result.mGlareView = lerp(current.mGlareView, other.mGlareView); - - result.mNight = current.mNight; - - // sound change behaviour: - // if 'other' has a new sound, switch to it after 1/2 of the transition length - if (other.mAmbientLoopSoundID != "") - result.mAmbientLoopSoundID = factor>0.5 ? other.mAmbientLoopSoundID : current.mAmbientLoopSoundID; - // if 'current' has a sound and 'other' does not have a sound, turn off the sound immediately - else if (current.mAmbientLoopSoundID != "") - result.mAmbientLoopSoundID = ""; - - return result; -} - -void WeatherManager::update(float duration) -{ - mWeatherUpdateTime -= duration; - if (mEnvironment->mWorld->isCellExterior() || mEnvironment->mWorld->isCellQuasiExterior()) - { - std::string regionstr = mEnvironment->mWorld->getPlayer().getPlayer().getCell()->cell->region; - boost::algorithm::to_lower(regionstr); - - if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion) - { - mCurrentRegion = regionstr; - mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*60.f; - - std::string weather; - - if (mRegionOverrides.find(regionstr) != mRegionOverrides.end()) - weather = mRegionOverrides[regionstr]; - else - { - // get weather probabilities for the current region - const ESM::Region *region = mEnvironment->mWorld->getStore().regions.find (regionstr); - - float clear = region->data.clear/255.f; - float cloudy = region->data.cloudy/255.f; - float foggy = region->data.foggy/255.f; - float overcast = region->data.overcast/255.f; - float rain = region->data.rain/255.f; - float thunder = region->data.thunder/255.f; - float ash = region->data.ash/255.f; - float blight = region->data.blight/255.f; - float snow = region->data.a/255.f; - float blizzard = region->data.b/255.f; - - // re-scale to 100 percent - const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight+snow+blizzard; - - srand(time(NULL)); - float random = ((rand()%100)/100.f) * total; - - if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) - weather = "blizzard"; - else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear) - weather = "snow"; - else if (random >= ash+thunder+rain+overcast+foggy+cloudy+clear) - weather = "blight"; - else if (random >= thunder+rain+overcast+foggy+cloudy+clear) - weather = "ashstorm"; - else if (random >= rain+overcast+foggy+cloudy+clear) - weather = "thunderstorm"; - else if (random >= overcast+foggy+cloudy+clear) - weather = "rain"; - else if (random >= foggy+cloudy+clear) - weather = "overcast"; - else if (random >= cloudy+clear) - weather = "foggy"; - else if (random >= clear) - weather = "cloudy"; - else - weather = "clear"; - } - - setWeather(weather, false); - /* - std::cout << "roll result: " << random << std::endl; - - std::cout << regionstr << " weather probabilities: " << clear << " " << cloudy << " " << foggy << " " - << overcast << " " << rain << " " << thunder << " " << ash << " " << blight << " " << snow << " " - << blizzard << std::endl; - - std::cout << "New weather : " << weather << std::endl; - */ - } - - WeatherResult result; - - if (mNextWeather != "") - { - mRemainingTransitionTime -= duration; - if (mRemainingTransitionTime < 0) - { - mCurrentWeather = mNextWeather; - mNextWeather = ""; - } - } - - if (mNextWeather != "") - result = transition(1-(mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60))); - else - result = getResult(mCurrentWeather); - - mRendering->configureFog(result.mFogDepth, result.mFogColor); - - // disable sun during night - if (mHour >= WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration - || mHour <= WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) - mRendering->getSkyManager()->sunDisable(); - else - { - // during day, calculate sun angle - float height = 1-std::abs(((mHour-13)/7.f)); - int facing = mHour > 13.f ? 1 : -1; - Vector3 final( - (1-height)*facing, - (1-height)*facing, - height); - mRendering->setSunDirection(final); - - mRendering->getSkyManager()->sunEnable(); - } - - // moon calculations - float night; - if (mHour >= 14) - night = mHour-14; - else if (mHour <= 10) - night = mHour+10; - else - night = 0; - - night /= 20.f; - - if (night != 0) - { - float moonHeight = 1-std::abs((night-0.5)*2); - int facing = (mHour > 0.f && mHour<12.f) ? 1 : -1; - Vector3 masser( - (1-moonHeight)*facing, - (1-moonHeight)*facing, - moonHeight); - - Vector3 secunda( - (1-moonHeight)*facing*0.8, - (1-moonHeight)*facing*1.25, - moonHeight); - - mRendering->getSkyManager()->setMasserDirection(masser); - mRendering->getSkyManager()->setSecundaDirection(secunda); - mRendering->getSkyManager()->masserEnable(); - mRendering->getSkyManager()->secundaEnable(); - - float hour_fade; - if (mHour >= 7.f && mHour <= 14.f) - hour_fade = 1-(mHour-7)/3.f; - else if (mHour >= 14 && mHour <= 15.f) - hour_fade = mHour-14; - else - hour_fade = 1; - - float secunda_angle_fade; - float masser_angle_fade; - float angle = moonHeight*90.f; - - if (angle >= 30 && angle <= 50) - secunda_angle_fade = (angle-30)/20.f; - else if (angle <30) - secunda_angle_fade = 0.f; - else - secunda_angle_fade = 1.f; - - if (angle >= 40 && angle <= 50) - masser_angle_fade = (angle-40)/10.f; - else if (angle <40) - masser_angle_fade = 0.f; - else - masser_angle_fade = 1.f; - - masser_angle_fade *= hour_fade; - secunda_angle_fade *= hour_fade; - - mRendering->getSkyManager()->setMasserFade(masser_angle_fade); - mRendering->getSkyManager()->setSecundaFade(secunda_angle_fade); - } - else - { - mRendering->getSkyManager()->masserDisable(); - mRendering->getSkyManager()->secundaDisable(); - } - - if (mCurrentWeather == "thunderstorm" && mNextWeather == "") - { - if (mThunderFlash > 0) - { - // play the sound after a delay - mThunderSoundDelay -= duration; - if (mThunderSoundDelay <= 0) - { - // pick a random sound - int sound = rand() % 4; - std::string soundname; - if (sound == 0) soundname = WeatherGlobals::mThunderSoundID0; - else if (sound == 1) soundname = WeatherGlobals::mThunderSoundID1; - else if (sound == 2) soundname = WeatherGlobals::mThunderSoundID2; - else if (sound == 3) soundname = WeatherGlobals::mThunderSoundID3; - mEnvironment->mSoundManager->playSound(soundname, 1.0, 1.0); - mThunderSoundDelay = 1000; - } - - mThunderFlash -= duration; - if (mThunderFlash > 0) - mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold ); - else - { - srand(time(NULL)); - mThunderChanceNeeded = rand() % 100; - mThunderChance = 0; - mRendering->getSkyManager()->setThunder( 0.f ); - } - } - else - { - // no thunder active - mThunderChance += duration*4; // chance increases by 4 percent every second - if (mThunderChance >= mThunderChanceNeeded) - { - mThunderFlash = WeatherGlobals::mThunderThreshold; - - mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold ); - - mThunderSoundDelay = WeatherGlobals::mThunderSoundDelay; - } - } - } - else - mRendering->getSkyManager()->setThunder(0.f); - - mRendering->setAmbientColour(result.mAmbientColor); - mRendering->sunEnable(); - mRendering->setSunColour(result.mSunColor); - - mRendering->getSkyManager()->setWeather(result); - } - else - { - mRendering->sunDisable(); - mRendering->skyDisable(); - mRendering->getSkyManager()->setThunder(0.f); - } -} - -void WeatherManager::setHour(const float hour) -{ - // accelerate a bit for testing - /* - mHour += 0.005; - - if (mHour >= 24.f) mHour = 0.f; - - std::cout << "hour " << mHour << std::endl; - */ - - mHour = hour; -} - -void WeatherManager::setDate(const int day, const int month) -{ - mDay = day; - mMonth = month; -} - -unsigned int WeatherManager::getWeatherID() const -{ - // Source: http://www.uesp.net/wiki/Tes3Mod:GetCurrentWeather - - if (mCurrentWeather == "clear") - return 0; - else if (mCurrentWeather == "cloudy") - return 1; - else if (mCurrentWeather == "foggy") - return 2; - else if (mCurrentWeather == "overcast") - return 3; - else if (mCurrentWeather == "rain") - return 4; - else if (mCurrentWeather == "thunderstorm") - return 5; - else if (mCurrentWeather == "ashstorm") - return 6; - else if (mCurrentWeather == "blight") - return 7; - else if (mCurrentWeather == "snow") - return 8; - else if (mCurrentWeather == "blizzard") - return 9; - - else - return 0; -} - -void WeatherManager::changeWeather(const std::string& region, const unsigned int id) -{ - std::string weather; - if (id==0) - weather = "clear"; - else if (id==1) - weather = "cloudy"; - else if (id==2) - weather = "foggy"; - else if (id==3) - weather = "overcast"; - else if (id==4) - weather = "rain"; - else if (id==5) - weather = "thunderstorm"; - else if (id==6) - weather = "ashstorm"; - else if (id==7) - weather = "blight"; - else if (id==8) - weather = "snow"; - else if (id==9) - weather = "blizzard"; - else - weather = "clear"; - - mRegionOverrides[region] = weather; -} diff --git a/libs/openengine/bullet/weather.hpp b/libs/openengine/bullet/weather.hpp deleted file mode 100644 index 9353f7cd1..000000000 --- a/libs/openengine/bullet/weather.hpp +++ /dev/null @@ -1,272 +0,0 @@ -#ifndef GAME_MWWORLD_WEATHER_H -#define GAME_MWWORLD_WEATHER_H - -#include -#include - -namespace MWRender -{ - class RenderingManager; -} - -namespace MWWorld -{ - class Environment; - - /// Global weather manager properties (according to INI) - struct WeatherGlobals - { - /* - [Weather] - EnvReduceColor=255,255,255,255 - LerpCloseColor=037,046,048,255 - BumpFadeColor=230,239,255,255 - AlphaReduce=0.35 - Minimum Time Between Environmental Sounds=1.0 - Maximum Time Between Environmental Sounds=5.0 - Sun Glare Fader Max=0.5 - Sun Glare Fader Angle Max=30.0 - Sun Glare Fader Color=222,095,039 - Timescale Clouds=0 - Precip Gravity=575 - Hours Between Weather Changes=20 - Rain Ripples=1 - Rain Ripple Radius=1024 - Rain Ripples Per Drop=1 - Rain Ripple Scale=0.3 - Rain Ripple Speed=1.0 - Fog Depth Change Speed=3 - Sunrise Time=6 - Sunset Time=18 - Sunrise Duration=2 - Sunset Duration=2 - Sky Pre-Sunrise Time=.5 - Sky Post-Sunrise Time=1 - Sky Pre-Sunset Time=1.5 - Sky Post-Sunset Time=.5 - Ambient Pre-Sunrise Time=.5 - Ambient Post-Sunrise Time=2 - Ambient Pre-Sunset Time=1 - Ambient Post-Sunset Time=1.25 - Fog Pre-Sunrise Time=.5 - Fog Post-Sunrise Time=1 - Fog Pre-Sunset Time=2 - Fog Post-Sunset Time=1 - Sun Pre-Sunrise Time=0 - Sun Post-Sunrise Time=0 - Sun Pre-Sunset Time=1 - Sun Post-Sunset Time=1.25 - Stars Post-Sunset Start=1 - Stars Pre-Sunrise Finish=2 - Stars Fading Duration=2 - Snow Ripples=0 - Snow Ripple Radius=1024 - Snow Ripples Per Flake=1 - Snow Ripple Scale=0.3 - Snow Ripple Speed=1.0 - Snow Gravity Scale=0.1 - Snow High Kill=700 - Snow Low Kill=150 - - - [Moons] - Masser Size=94 - Masser Fade In Start=14 - Masser Fade In Finish=15 - Masser Fade Out Start=7 - Masser Fade Out Finish=10 - Masser Axis Offset=35 - Masser Speed=.5 - Masser Daily Increment=1 - Masser Fade Start Angle=50 - Masser Fade End Angle=40 - Masser Moon Shadow Early Fade Angle=0.5 - Secunda Size=40 - Secunda Fade In Start=14 - Secunda Fade In Finish=15 - Secunda Fade Out Start=7 - Secunda Fade Out Finish=10 - Secunda Axis Offset=50 - Secunda Speed=.6 - Secunda Daily Increment=1.2 - Secunda Fade Start Angle=50 - Secunda Fade End Angle=30 - Secunda Moon Shadow Early Fade Angle=0.5 - Script Color=255,20,20 - */ - - static const float mSunriseTime; - static const float mSunsetTime; - static const float mSunriseDuration; - static const float mSunsetDuration; - - static const float mWeatherUpdateTime; - - // morrowind sets these per-weather, but since they are only used by 'thunderstorm' - // weather setting anyway, we can just as well set them globally - static const float mThunderFrequency; - static const float mThunderThreshold; - static const float mThunderSoundDelay; - static const std::string mThunderSoundID0; - static const std::string mThunderSoundID1; - static const std::string mThunderSoundID2; - static const std::string mThunderSoundID3; - }; - - /// Defines the actual weather that results from weather setting (see below), time of day and weather transition - struct WeatherResult - { - Ogre::String mCloudTexture; - Ogre::String mNextCloudTexture; - float mCloudBlendFactor; - - Ogre::ColourValue mFogColor; - - Ogre::ColourValue mAmbientColor; - - Ogre::ColourValue mSkyColor; - - Ogre::ColourValue mSunColor; - - Ogre::ColourValue mSunDiscColor; - - float mFogDepth; - - float mWindSpeed; - - float mCloudSpeed; - - float mCloudOpacity; - - float mGlareView; - - bool mNight; // use night skybox - float mNightFade; // fading factor for night skybox - - Ogre::String mAmbientLoopSoundID; - }; - - - /// Defines a single weather setting (according to INI) - struct Weather - { - Ogre::String mCloudTexture; - - // Sky (atmosphere) colors - Ogre::ColourValue mSkySunriseColor, - mSkyDayColor, - mSkySunsetColor, - mSkyNightColor; - - // Fog colors - Ogre::ColourValue mFogSunriseColor, - mFogDayColor, - mFogSunsetColor, - mFogNightColor; - - // Ambient lighting colors - Ogre::ColourValue mAmbientSunriseColor, - mAmbientDayColor, - mAmbientSunsetColor, - mAmbientNightColor; - - // Sun (directional) lighting colors - Ogre::ColourValue mSunSunriseColor, - mSunDayColor, - mSunSunsetColor, - mSunNightColor; - - // Fog depth/density - float mLandFogDayDepth, - mLandFogNightDepth; - - // Color modulation for the sun itself during sunset (not completely sure) - Ogre::ColourValue mSunDiscSunsetColor; - - // Duration of weather transition (in days) - float mTransitionDelta; - - // No idea what this one is used for? - float mWindSpeed; - - // Cloud animation speed multiplier - float mCloudSpeed; - - // Multiplier for clouds transparency - float mCloudsMaximumPercent; - - // Value between 0 and 1, defines the strength of the sun glare effect - float mGlareView; - - // Sound effect - // This is used for Blight, Ashstorm and Blizzard (Bloodmoon) - Ogre::String mAmbientLoopSoundID; - - // Rain sound effect - Ogre::String mRainLoopSoundID; - - /// \todo disease chance - }; - - /// - /// Interface for weather settings - /// - class WeatherManager - { - public: - WeatherManager(MWRender::RenderingManager*, MWWorld::Environment*); - - /** - * Change the weather in the specified region - * @param region that should be changed - * @param ID of the weather setting to shift to - */ - void changeWeather(const std::string& region, const unsigned int id); - - /** - * Per-frame update - * @param duration - */ - void update(float duration); - - void setHour(const float hour); - - void setDate(const int day, const int month); - - unsigned int getWeatherID() const; - - private: - float mHour; - int mDay, mMonth; - - MWRender::RenderingManager* mRendering; - MWWorld::Environment* mEnvironment; - - std::map mWeatherSettings; - - std::map mRegionOverrides; - - Ogre::String mCurrentWeather; - Ogre::String mNextWeather; - - std::string mCurrentRegion; - - bool mFirstUpdate; - - float mWeatherUpdateTime; - - float mRemainingTransitionTime; - - float mThunderFlash; - float mThunderChance; - float mThunderChanceNeeded; - float mThunderSoundDelay; - - WeatherResult transition(const float factor); - WeatherResult getResult(const Ogre::String& weather); - - void setWeather(const Ogre::String& weather, bool instant=false); - }; -} - -#endif // GAME_MWWORLD_WEATHER_H From 318355f1be3fa5f14abe34d39a3b76b063b5b9a3 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Mon, 26 Mar 2012 21:35:20 -0400 Subject: [PATCH 005/109] Bouncy effect gone --- libs/openengine/bullet/pmove.cpp | 48 ++++++++++++++++++++++---------- libs/openengine/bullet/trace.cpp | 4 +-- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 8dd01ef19..d8880a49f 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -178,7 +178,7 @@ bool PM_SlideMove( bool gravity ) float into; Ogre::Vector3 endVelocity; Ogre::Vector3 endClipVelocity; - std::cout << "Slide move\n"; + std::cout << "Slide move" << pm->ps.velocity << "\n"; numbumps = 4; // primal_velocity = pm->ps->velocity @@ -415,6 +415,7 @@ int PM_StepSlideMove( bool gravity ) // vec3_t delta, delta2; Ogre::Vector3 up, down; float stepSize; + std::cout << "Step Slide move" << pm->ps.velocity << "\n"; // start_o = pm->ps->origin //VectorCopy (pm->ps->origin, start_o); @@ -427,7 +428,7 @@ int PM_StepSlideMove( bool gravity ) if ( PM_SlideMove( gravity ) == false ) return 1; // we got exactly where we wanted to go first try - std::cout << "Step Slide move\n"; + // down = start_o - vec3(0, 0, STEPSIZE) //VectorCopy(start_o, down); down = start_o; @@ -711,7 +712,7 @@ static void PM_WaterMove( playerMove* const pm ) Ogre::Vector3 wishdir; float scale; float vel; - + std::cout << "Water moving"; /*if ( PM_CheckWaterJump() ) { PM_WaterJumpMove(); @@ -837,7 +838,7 @@ static void PM_WalkMove( playerMove* const pmove ) playerMove::playercmd cmd; float accelerate; float vel; - std::cout << "Walking\n"; + std::cout << "Walking" << pm->ps.velocity << "\n"; if ( pm->ps.waterlevel > 2 && //DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) pml.forward.dotProduct(pml.groundTrace.planenormal) > 0.0f) @@ -927,6 +928,7 @@ static void PM_WalkMove( playerMove* const pmove ) PM_Friction (); + std::cout << "After friction" << pm->ps.velocity << "\n"; //bprintf("vel: (%f, %f, %f)\n", pm->ps.velocity.x, pm->ps.velocity.y, pm->ps.velocity.z); @@ -945,20 +947,28 @@ static void PM_WalkMove( playerMove* const pmove ) //pml.right[2] = 0; pml.right.z = 0; + //std::cout << "Further down" << pm->ps.velocity << "\n"; + // project the forward and right directions onto the ground plane PM_ClipVelocity (pml.forward, pml.groundTrace.planenormal, pml.forward, OVERCLIP ); PM_ClipVelocity (pml.right, pml.groundTrace.planenormal, pml.right, OVERCLIP ); + std::cout << "Clip velocity" << pm->ps.velocity << "\n"; // - //VectorNormalize (pml.forward); - pml.forward = pml.forward.normalise(); - pml.right = pml.right.normalise(); + + VectorNormalize (pml.forward); + VectorNormalize (pml.right); + //pml.forward = pml.forward.normalise(); + //pml.right = pml.right.normalise(); + std::cout << "forward2" << pml.forward << "\n"; + std::cout << "right2" << pml.right << "\n"; // wishvel = (pml.forward * fmove) + (pml.right * smove); //for ( i = 0 ; i < 3 ; i++ ) //wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove; wishvel = pml.forward * fmove + pml.right * smove; + std::cout << "WishVel" << wishvel << "\n"; //bprintf("f: (%f, %f, %f), s: (%f, %f, %f)\n", fmove, smove); @@ -971,7 +981,9 @@ static void PM_WalkMove( playerMove* const pmove ) wishdir = wishvel; wishspeed = VectorNormalize(wishdir); + std::cout << "Wishspeed: " << wishspeed << "\n"; wishspeed *= scale; + std::cout << "Wishspeed scaled:" << wishspeed << "\n"; // clamp the speed lower if ducking if ( pm->cmd.ducking ) @@ -998,6 +1010,7 @@ static void PM_WalkMove( playerMove* const pmove ) PM_Accelerate (wishdir, wishspeed, accelerate); + std::cout << "Velocityafter: " << pm->ps.velocity << "\n"; //Com_Printf("velocity = %1.1f %1.1f %1.1f\n", pm->ps->velocity[0], pm->ps->velocity[1], pm->ps->velocity[2]); //Com_Printf("velocity1 = %1.1f\n", VectorLength(pm->ps->velocity)); @@ -1012,15 +1025,18 @@ static void PM_WalkMove( playerMove* const pmove ) //vel = VectorLength(pm->ps->velocity); vel = pm->ps.velocity.length(); + std::cout << "The length" << vel << "\n"; // slide along the ground plane PM_ClipVelocity (pm->ps.velocity, pml.groundTrace.planenormal, pm->ps.velocity, OVERCLIP ); + std::cout << "Velocity clipped" << pm->ps.velocity << "\n"; // don't decrease velocity when going up or down a slope - //VectorNormalize(pm->ps->velocity); - pm->ps.velocity = pm->ps.velocity.normalise(); + VectorNormalize(pm->ps.velocity); + //pm->ps.velocity = pm->ps.velocity.normalise(); + std::cout << "Final:" << pm->ps.velocity << "\n"; //VectorScale(pm->ps->velocity, vel, pm->ps->velocity); pm->ps.velocity = pm->ps.velocity * vel; @@ -1032,6 +1048,7 @@ static void PM_WalkMove( playerMove* const pmove ) PM_StepSlideMove( false ); //Com_Printf("velocity2 = %1.1f\n", VectorLength(pm->ps->velocity)); + std::cout << "Walk2" << pm->ps.velocity << "\n"; } @@ -1361,7 +1378,7 @@ static void PM_CrashLand( void ) static void PM_GroundTrace( void ) { - std::cout << "Ground trace\n"; + std::cout << "Ground trace" << pm->ps.velocity << "\n"; Ogre::Vector3 point; traceResults trace; @@ -1467,13 +1484,13 @@ static void PM_GroundTrace( void ) // don't reset the z velocity for slopes // pm->ps->velocity[2] = 0; - + std::cout << "Ground trace2" << pm->ps.velocity << "\n"; //PM_AddTouchEnt( trace.entityNum ); } static void PM_AirMove() { - std::cout << "Air move\n"; + std::cout << "Air move " << pm->ps.velocity << "\n"; //int i; Ogre::Vector3 wishvel; float fmove, smove; @@ -1495,9 +1512,9 @@ static void PM_AirMove() // project moves down to flat plane //pml.forward[2] = 0; - pml.forward.y = 0; //Z or Y? + pml.forward.z = 0; //Z or Y? //pml.right[2] = 0; - pml.right.y = 0; + pml.right.z = 0; //VectorNormalize (pml.forward); pml.forward = Ogre::Vector3(pml.forward.normalise()); pml.right = Ogre::Vector3(pml.right.normalise()); @@ -1535,8 +1552,9 @@ static void PM_AirMove() else PM_SlideMove ( qtrue ); #endif*/ - + /*bprintf("%i ", */PM_StepSlideMove ( true )/* )*/; + std::cout << "Velocity 2 " << pm->ps.velocity << "\n"; } static void PM_NoclipMove( void ) diff --git a/libs/openengine/bullet/trace.cpp b/libs/openengine/bullet/trace.cpp index 8f2423c24..18a668e55 100644 --- a/libs/openengine/bullet/trace.cpp +++ b/libs/openengine/bullet/trace.cpp @@ -32,7 +32,7 @@ void newtrace(traceResults* const results, const Ogre::Vector3& start, const Ogr //Ogre::Vector3 endReplace = startReplace; //endReplace.z -= .25; - const bool hasHit = NewPhysicsTrace(&out, start, end, BBHalfExtents, Ogre::Vector3(0.0f, 0.0f, rotation), isInterior, enginePass); + const bool hasHit = NewPhysicsTrace(&out, start, end, BBHalfExtents, Ogre::Vector3(0.0f, rotation, 0.0f), isInterior, enginePass); if(hasHit) std::cout << "Has hit\n"; if (out.fraction < 0.001f) @@ -100,7 +100,7 @@ const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3& const btVector3 btstart(start.x, start.y, start.z); const btVector3 btend(end.x, end.y, end.z); - const btQuaternion btrot(rotation.y, rotation.x, rotation.z); + const btQuaternion btrot(rotation.y, rotation.x, rotation.z); //y, x, z const btBoxShape newshape(btVector3(BBHalfExtents.x, BBHalfExtents.y, BBHalfExtents.z)); const btTransform from(btrot, btstart); From b9fabce9c4654f99c3b3bc8e296e64e35b13639d Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Tue, 27 Mar 2012 20:17:54 -0400 Subject: [PATCH 006/109] Awesome, working --- apps/openmw/mwclass/npc.cpp | 4 +- apps/openmw/mwworld/physicssystem.cpp | 7 ++- libs/openengine/bullet/pmove.cpp | 67 +++++++++++++-------------- libs/openengine/bullet/pmove.h | 2 +- libs/openengine/bullet/trace.cpp | 8 ++-- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 522fce3a3..8bb394129 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -273,8 +273,8 @@ namespace MWClass vector.y = getMovementSettings (ptr).mForwardBackward * 127; vector.z = getMovementSettings(ptr).mUpDown * 127; - if (getStance (ptr, Run, false)) - vector *= 2; + //if (getStance (ptr, Run, false)) + // vector *= 2; return vector; } diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 15d2d3f9f..fdcee417f 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -116,7 +116,6 @@ namespace MWWorld pm_ref.upmove = dir1.y; - //std::cout << "Current angle" << yawQuat.getYaw().valueDegrees() - 90<< "\n"; //playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees(); //std::cout << "Pitch: " << yawQuat.getPitch() << "Yaw:" << yawQuat.getYaw() << "Roll: " << yawQuat.getRoll() << "\n"; @@ -124,11 +123,15 @@ namespace MWWorld } else { + Ogre::Quaternion quat = yawNode->getOrientation(); Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); + pm_ref.rightmove = -dir1.x; pm_ref.forwardmove = dir1.z; - pm_ref.upmove = dir.y; + pm_ref.upmove = dir1.y; + + dir = 0.025*(quat*dir1); } diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index d8880a49f..8fb72aa1f 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -93,6 +93,7 @@ static inline void PM_ClipVelocity(const Ogre::Vector3& in, const Ogre::Vector3& { change = normal[i]*backoff; out[i] = in[i] - change; + }*/ float changex = normal.x * backoff; out.x = in.x - changex; @@ -178,7 +179,7 @@ bool PM_SlideMove( bool gravity ) float into; Ogre::Vector3 endVelocity; Ogre::Vector3 endClipVelocity; - std::cout << "Slide move" << pm->ps.velocity << "\n"; + numbumps = 4; // primal_velocity = pm->ps->velocity @@ -415,7 +416,7 @@ int PM_StepSlideMove( bool gravity ) // vec3_t delta, delta2; Ogre::Vector3 up, down; float stepSize; - std::cout << "Step Slide move" << pm->ps.velocity << "\n"; + // start_o = pm->ps->origin //VectorCopy (pm->ps->origin, start_o); @@ -543,7 +544,7 @@ int PM_StepSlideMove( bool gravity ) void PM_Friction(void) { - std::cout << "Friction\n"; + Ogre::Vector3 vec; float* vel; float speed, newspeed, control; @@ -639,7 +640,6 @@ static void PM_Accelerate( Ogre::Vector3& wishdir, float wishspeed, float accel { // int i; float addspeed, accelspeed, currentspeed; - std::cout << "Accelerate\n"; // currentspeed = pm->ps->velocity dot wishdir //currentspeed = DotProduct (pm->ps->velocity, wishdir); @@ -712,7 +712,7 @@ static void PM_WaterMove( playerMove* const pm ) Ogre::Vector3 wishdir; float scale; float vel; - std::cout << "Water moving"; + /*if ( PM_CheckWaterJump() ) { PM_WaterJumpMove(); @@ -838,7 +838,7 @@ static void PM_WalkMove( playerMove* const pmove ) playerMove::playercmd cmd; float accelerate; float vel; - std::cout << "Walking" << pm->ps.velocity << "\n"; + if ( pm->ps.waterlevel > 2 && //DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) pml.forward.dotProduct(pml.groundTrace.planenormal) > 0.0f) @@ -851,6 +851,7 @@ static void PM_WalkMove( playerMove* const pmove ) if ( PM_CheckJump () ) { + // jumped away if ( pm->ps.waterlevel > 1 ) PM_WaterMove(pmove); @@ -928,12 +929,13 @@ static void PM_WalkMove( playerMove* const pmove ) PM_Friction (); - std::cout << "After friction" << pm->ps.velocity << "\n"; + //bprintf("vel: (%f, %f, %f)\n", pm->ps.velocity.x, pm->ps.velocity.y, pm->ps.velocity.z); fmove = pm->cmd.forwardmove; smove = pm->cmd.rightmove; + cmd = pm->cmd; scale = PM_CmdScale( &cmd ); @@ -953,22 +955,23 @@ static void PM_WalkMove( playerMove* const pmove ) // project the forward and right directions onto the ground plane PM_ClipVelocity (pml.forward, pml.groundTrace.planenormal, pml.forward, OVERCLIP ); PM_ClipVelocity (pml.right, pml.groundTrace.planenormal, pml.right, OVERCLIP ); - std::cout << "Clip velocity" << pm->ps.velocity << "\n"; + //std::cout << "Clip velocity" << pm->ps.velocity << "\n"; // VectorNormalize (pml.forward); VectorNormalize (pml.right); //pml.forward = pml.forward.normalise(); //pml.right = pml.right.normalise(); - std::cout << "forward2" << pml.forward << "\n"; - std::cout << "right2" << pml.right << "\n"; + //std::cout << "forward2" << pml.forward << "\n"; + //std::cout << "right2" << pml.right << "\n"; // wishvel = (pml.forward * fmove) + (pml.right * smove); //for ( i = 0 ; i < 3 ; i++ ) //wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove; wishvel = pml.forward * fmove + pml.right * smove; - std::cout << "WishVel" << wishvel << "\n"; + + //bprintf("f: (%f, %f, %f), s: (%f, %f, %f)\n", fmove, smove); @@ -981,9 +984,9 @@ static void PM_WalkMove( playerMove* const pmove ) wishdir = wishvel; wishspeed = VectorNormalize(wishdir); - std::cout << "Wishspeed: " << wishspeed << "\n"; + //std::cout << "Wishspeed: " << wishspeed << "\n"; wishspeed *= scale; - std::cout << "Wishspeed scaled:" << wishspeed << "\n"; + //std::cout << "Wishspeed scaled:" << wishspeed << "\n"; // clamp the speed lower if ducking if ( pm->cmd.ducking ) @@ -1010,7 +1013,7 @@ static void PM_WalkMove( playerMove* const pmove ) PM_Accelerate (wishdir, wishspeed, accelerate); - std::cout << "Velocityafter: " << pm->ps.velocity << "\n"; + //std::cout << "Velocityafter: " << pm->ps.velocity << "\n"; //Com_Printf("velocity = %1.1f %1.1f %1.1f\n", pm->ps->velocity[0], pm->ps->velocity[1], pm->ps->velocity[2]); //Com_Printf("velocity1 = %1.1f\n", VectorLength(pm->ps->velocity)); @@ -1025,18 +1028,18 @@ static void PM_WalkMove( playerMove* const pmove ) //vel = VectorLength(pm->ps->velocity); vel = pm->ps.velocity.length(); - std::cout << "The length" << vel << "\n"; + //std::cout << "The length" << vel << "\n"; // slide along the ground plane PM_ClipVelocity (pm->ps.velocity, pml.groundTrace.planenormal, pm->ps.velocity, OVERCLIP ); - std::cout << "Velocity clipped" << pm->ps.velocity << "\n"; + //std::cout << "Velocity clipped" << pm->ps.velocity << "\n"; // don't decrease velocity when going up or down a slope VectorNormalize(pm->ps.velocity); //pm->ps.velocity = pm->ps.velocity.normalise(); - std::cout << "Final:" << pm->ps.velocity << "\n"; + //std::cout << "Final:" << pm->ps.velocity << "\n"; //VectorScale(pm->ps->velocity, vel, pm->ps->velocity); pm->ps.velocity = pm->ps.velocity * vel; @@ -1048,7 +1051,7 @@ static void PM_WalkMove( playerMove* const pmove ) PM_StepSlideMove( false ); //Com_Printf("velocity2 = %1.1f\n", VectorLength(pm->ps->velocity)); - std::cout << "Walk2" << pm->ps.velocity << "\n"; + } @@ -1056,7 +1059,7 @@ void PM_UpdateViewAngles( playerMove::playerStruct* const ps, playerMove::player { short temp; int i; - std::cout << "Updating viewangles\n"; + //while(1); //if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPINTERMISSION) @@ -1178,7 +1181,6 @@ static bool PM_CorrectAllSolid(traceResults* const trace) { int i, j, k; Ogre::Vector3 point; - std::cout << "Correct all solid\n"; //if ( pm->debugLevel ) //Com_Printf("%i:allsolid\n", c_pmove); @@ -1236,7 +1238,7 @@ static void PM_CrashLand( void ) float vel, acc; float t; float a, b, c, den; - std::cout << "Crash land\n"; + // decide which landing animation to use /*if ( pm->ps->pm_flags & PMF_BACKWARDS_JUMP ) PM_ForceLegsAnim( LEGS_LANDB ); @@ -1378,7 +1380,6 @@ static void PM_CrashLand( void ) static void PM_GroundTrace( void ) { - std::cout << "Ground trace" << pm->ps.velocity << "\n"; Ogre::Vector3 point; traceResults trace; @@ -1484,13 +1485,12 @@ static void PM_GroundTrace( void ) // don't reset the z velocity for slopes // pm->ps->velocity[2] = 0; - std::cout << "Ground trace2" << pm->ps.velocity << "\n"; + //PM_AddTouchEnt( trace.entityNum ); } static void PM_AirMove() { - std::cout << "Air move " << pm->ps.velocity << "\n"; //int i; Ogre::Vector3 wishvel; float fmove, smove; @@ -1516,8 +1516,8 @@ static void PM_AirMove() //pml.right[2] = 0; pml.right.z = 0; //VectorNormalize (pml.forward); - pml.forward = Ogre::Vector3(pml.forward.normalise()); - pml.right = Ogre::Vector3(pml.right.normalise()); + VectorNormalize(pml.forward); + VectorNormalize(pml.right); //VectorNormalize (pml.right); //for ( i = 0 ; i < 2 ; i++ ) @@ -1554,7 +1554,6 @@ static void PM_AirMove() #endif*/ /*bprintf("%i ", */PM_StepSlideMove ( true )/* )*/; - std::cout << "Velocity 2 " << pm->ps.velocity << "\n"; } static void PM_NoclipMove( void ) @@ -1602,9 +1601,7 @@ static void PM_NoclipMove( void ) //for (i=0 ; i<3 ; i++) //wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove; - std::cout << "Forward" << pml.forward << "\n"; - std::cout << "Right" << pml.right << "\n"; - std::cout << "Up" << pml.up << "\n"; + wishvel = pml.forward * fmove + pml.right * smove; //wishvel[2] += pm->cmd.upmove; wishvel.z += pm->cmd.upmove; @@ -1614,6 +1611,7 @@ static void PM_NoclipMove( void ) wishspeed = VectorNormalize(wishdir); wishspeed *= scale; + PM_Accelerate( wishdir, wishspeed, pm_accelerate ); // move @@ -1747,6 +1745,7 @@ void PM_SetWaterLevel( playerMove* const pm ) void PmoveSingle (playerMove* const pmove) { + //pm = pmove; // Aedra doesn't support Q3-style VM traps D: //while(1); @@ -1898,7 +1897,7 @@ void PmoveSingle (playerMove* const pmove) if ( pm->ps.move_type == PM_SPECTATOR ) { - std::cout << "SPECTATOR\n"; + //PM_CheckDuck (); PM_FlyMove (); PM_DropTimers (); @@ -1907,20 +1906,19 @@ void PmoveSingle (playerMove* const pmove) if ( pm->ps.move_type == PM_NOCLIP ) { - std::cout << "NOCLIP\n"; + PM_NoclipMove (); PM_DropTimers (); return; } if (pm->ps.move_type == PM_FREEZE){ - std::cout << "FREEZE\n"; + return; // no movement at all } if ( pm->ps.move_type == PM_INTERMISSION || pm->ps.move_type == PM_SPINTERMISSION){ - std::cout << "INTERMISSION\n"; return; // no movement at all } @@ -2006,6 +2004,7 @@ void Ext_UpdateViewAngles(playerMove* const pm) void Pmove (playerMove* const pmove) { + int fmove = pmove->cmd.forwardmove; pm = pmove; int finalTime; diff --git a/libs/openengine/bullet/pmove.h b/libs/openengine/bullet/pmove.h index 5dfd18f6d..30572a92a 100644 --- a/libs/openengine/bullet/pmove.h +++ b/libs/openengine/bullet/pmove.h @@ -90,7 +90,7 @@ struct playerMove { struct playerStruct { - playerStruct() : gravity(50.0f), speed(320.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0) + playerStruct() : gravity(800.0f), speed(320.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0) { origin = Ogre::Vector3(733.164f,900.0f, 839.432f); velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f); diff --git a/libs/openengine/bullet/trace.cpp b/libs/openengine/bullet/trace.cpp index 18a668e55..ca68a5d5c 100644 --- a/libs/openengine/bullet/trace.cpp +++ b/libs/openengine/bullet/trace.cpp @@ -32,9 +32,8 @@ void newtrace(traceResults* const results, const Ogre::Vector3& start, const Ogr //Ogre::Vector3 endReplace = startReplace; //endReplace.z -= .25; - const bool hasHit = NewPhysicsTrace(&out, start, end, BBHalfExtents, Ogre::Vector3(0.0f, rotation, 0.0f), isInterior, enginePass); - if(hasHit) - std::cout << "Has hit\n"; + const bool hasHit = NewPhysicsTrace(&out, start, end, BBHalfExtents, Ogre::Vector3(0.0f, 0.0, rotation), isInterior, enginePass); + if (out.fraction < 0.001f) results->startsolid = true; else @@ -180,8 +179,7 @@ const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3& const bool hasHit = newTraceCallback.hasHit(); - if(hasHit) - std::cout << "HIT\n"; + return hasHit; From c5f044eb0df83cb1b550bf3e3559d2f7621b7637 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 28 Mar 2012 22:46:29 +0200 Subject: [PATCH 007/109] fixed compilation --- apps/openmw/mwworld/scene.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 79e7d565d..205d66cd7 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -112,9 +112,12 @@ namespace MWWorld float worldsize = ESM::Land::REAL_SIZE; if (!(cell->cell->data.flags & ESM::Cell::Interior)) - mPhysics->addHeightField (cell->land[1][1]->landData->heights, + { + ESM::Land* land = mWorld->getStore().lands.search(cell->cell->data.gridX,cell->cell->data.gridY); + mPhysics->addHeightField (land->landData->heights, cell->cell->data.gridX, cell->cell->data.gridY, 0, ( worldsize/(verts-1) ), verts); + } mRendering.configureAmbient(*cell); mRendering.requestMap(cell); From 57299571d5a1d76ce8666e1d7df6f7721d0c0d15 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Mon, 2 Apr 2012 22:08:46 -0400 Subject: [PATCH 008/109] Preparing for clothes/armor --- apps/openmw/mwclass/npc.cpp | 2 + apps/openmw/mwrender/npcanimation.cpp | 19 +- apps/openmw/mwrender/occlusionquery.cpp | 46 +- apps/openmw/mwrender/occlusionquery.hpp | 8 + apps/openmw/mwworld/physicssystem.cpp | 34 +- apps/openmw/mwworld/physicssystem.hpp | 3 +- apps/openmw/mwworld/weather.cpp | 34 +- apps/openmw/mwworld/world.cpp | 60 +- apps/openmw/mwworld/world.hpp | 18 +- components/bsa/bsa_archive.cpp | 6 +- components/nifogre/ogre_nif_loader.cpp | 14 +- libs/openengine/bullet/pmove.cpp | 2042 ----------------------- libs/openengine/bullet/pmove.h | 197 --- libs/openengine/bullet/trace.cpp | 188 --- 14 files changed, 169 insertions(+), 2502 deletions(-) delete mode 100644 libs/openengine/bullet/pmove.cpp delete mode 100644 libs/openengine/bullet/pmove.h delete mode 100644 libs/openengine/bullet/trace.cpp diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 83a94d27d..94bcbb31f 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -93,7 +93,9 @@ namespace MWClass void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { + std::cout << "Inserting NPC\n"; renderingInterface.getActors().insertNPC(ptr); + } void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index c6fe023d6..a4fd15b74 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -14,6 +14,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O ESMS::LiveCellRef *ref = ptr.get(); + //Part selection on last character of the file string // " Tri Chest // * Tri Tail @@ -65,6 +66,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O NifOgre::NIFLoader::load(smodel); base = mRend.getScene()->createEntity(smodel); + base->setSkipAnimationStateUpdate(true); //Magical line of code, this makes the bones //stay in the same place when we skipanim, or open a gui window @@ -82,6 +84,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O } textmappings = NIFLoader::getSingletonPtr()->getTextIndices(smodel); insert->attachObject(base); + if(female) insert->scale(race->data.height.female, race->data.height.female, race->data.height.female); @@ -124,6 +127,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O insertBoundedPart("meshes\\" + upperleg->model, "Right Upper Leg"); } + if(foot){ if(bodyRaceID.compare("b_n_khajiit_m_") == 0) { @@ -190,28 +194,29 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O insertBoundedPart("meshes\\" + hair->model, "Head"); if (chest){ - insertFreePart("meshes\\" + chest->model, ">\"", insert); + insertFreePart("meshes\\" + chest->model, ":\"", insert); } if (handr){ - insertFreePart("meshes\\" + handr->model , ">?", insert); + insertFreePart("meshes\\" + handr->model , ":?", insert); } if (handl){ - insertFreePart("meshes\\" + handl->model, ">>", insert); + insertFreePart("meshes\\" + handl->model, ":>", insert); } if(tail){ - insertFreePart("meshes\\" + tail->model, ">*", insert); + insertFreePart("meshes\\" + tail->model, ":*", insert); } if(feet){ std::string num = getUniqueID(feet->model); - insertFreePart("meshes\\" + feet->model,"><", insert); - insertFreePart("meshes\\" + feet->model,">:", insert); + insertFreePart("meshes\\" + feet->model,":<", insert); + insertFreePart("meshes\\" + feet->model,"::", insert); } //originalpos = insert->_getWorldAABB().getCenter(); //originalscenenode = insert->getPosition(); + } Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){ @@ -262,7 +267,7 @@ void NpcAnimation::runAnimation(float timepassed){ time = startTime + (time - stopTime); } - handleAnimationTransforms(); + handleAnimationTransforms(); std::vector*>::iterator shapepartsiter = shapeparts.begin(); std::vector::iterator entitypartsiter = entityparts.begin(); diff --git a/apps/openmw/mwrender/occlusionquery.cpp b/apps/openmw/mwrender/occlusionquery.cpp index 29cfe33fe..781b522b6 100644 --- a/apps/openmw/mwrender/occlusionquery.cpp +++ b/apps/openmw/mwrender/occlusionquery.cpp @@ -5,13 +5,14 @@ #include #include #include +#include using namespace MWRender; using namespace Ogre; OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNode* sunNode) : mSunTotalAreaQuery(0), mSunVisibleAreaQuery(0), mSingleObjectQuery(0), mActiveQuery(0), - mDoQuery(0), mSunVisibility(0), mQuerySingleObjectStarted(false), mTestResult(false), + mDoQuery(0), mSunVisibility(0), mQuerySingleObjectStarted(false), mTestResult(false), mQuerySingleObjectRequested(false), mWasVisible(false), mObjectWasVisible(false), mDoQuery2(false), mBBNode(0) { @@ -84,7 +85,6 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod mRendering->getScene()->addRenderObjectListener(this); mRendering->getScene()->addRenderQueueListener(this); mDoQuery = true; - mDoQuery2 = true; } OcclusionQuery::~OcclusionQuery() @@ -100,7 +100,7 @@ bool OcclusionQuery::supported() return mSupported; } -void OcclusionQuery::notifyRenderSingleObject(Renderable* rend, const Pass* pass, const AutoParamDataSource* source, +void OcclusionQuery::notifyRenderSingleObject(Renderable* rend, const Pass* pass, const AutoParamDataSource* source, const LightList* pLightList, bool suppressRenderStateChanges) { // The following code activates and deactivates the occlusion queries @@ -134,7 +134,7 @@ void OcclusionQuery::notifyRenderSingleObject(Renderable* rend, const Pass* pass mActiveQuery = mSingleObjectQuery; mObjectWasVisible = true; } - + if (mActiveQuery != NULL) mActiveQuery->beginOcclusionQuery(); } @@ -195,7 +195,6 @@ void OcclusionQuery::update(float duration) // Stop occlusion queries until we get their information // (may not happen on the same frame they are requested in) mDoQuery = false; - mDoQuery2 = false; if (!mSunTotalAreaQuery->isStillOutstanding() && !mSunVisibleAreaQuery->isStillOutstanding() @@ -264,3 +263,40 @@ bool OcclusionQuery::getTestResult() return mTestResult; } + +bool OcclusionQuery::isPotentialOccluder(Ogre::SceneNode* node) +{ + bool result = false; + for (unsigned int i=0; i < node->numAttachedObjects(); ++i) + { + MovableObject* ob = node->getAttachedObject(i); + std::string type = ob->getMovableType(); + if (type == "Entity") + { + Entity* ent = static_cast(ob); + for (unsigned int j=0; j < ent->getNumSubEntities(); ++j) + { + // if any sub entity has a material with depth write off, + // consider the object as not an occluder + MaterialPtr mat = ent->getSubEntity(j)->getMaterial(); + + Material::TechniqueIterator techIt = mat->getTechniqueIterator(); + while (techIt.hasMoreElements()) + { + Technique* tech = techIt.getNext(); + Technique::PassIterator passIt = tech->getPassIterator(); + while (passIt.hasMoreElements()) + { + Pass* pass = passIt.getNext(); + + if (pass->getDepthWriteEnabled() == false) + return false; + else + result = true; + } + } + } + } + } + return result; +} diff --git a/apps/openmw/mwrender/occlusionquery.hpp b/apps/openmw/mwrender/occlusionquery.hpp index b655c8e46..c76fcccd0 100644 --- a/apps/openmw/mwrender/occlusionquery.hpp +++ b/apps/openmw/mwrender/occlusionquery.hpp @@ -46,6 +46,14 @@ namespace MWRender */ bool occlusionTestPending(); + /** + * Checks if the objects held by this scenenode + * can be considered as potential occluders + * (which might not be the case when transparency is involved) + * @param Scene node + */ + bool isPotentialOccluder(Ogre::SceneNode* node); + /** * @return true if the object tested in the last request was occluded */ diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 71e12e369..ed96f47d6 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -21,11 +21,11 @@ namespace MWWorld PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend) : mRender(_rend), mEngine(0), mFreeFly (true) { - playerphysics = new playerMove; + // Create physics. shapeLoader is deleted by the physic engine NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader(); mEngine = new OEngine::Physic::PhysicEngine(shapeLoader); - playerphysics->mEngine = mEngine; + } PhysicsSystem::~PhysicsSystem() @@ -101,11 +101,9 @@ namespace MWWorld OEngine::Physic::PhysicActor* act = it->second; act->setWalkDirection(btVector3(0,0,0)); } - playerMove::playercmd& pm_ref = playerphysics->cmd; - pm_ref.rightmove = 0; - pm_ref.forwardmove = 0; - pm_ref.upmove = 0; + + //playerphysics->ps.move_type = PM_NOCLIP; for (std::vector >::const_iterator iter (actors.begin()); iter!=actors.end(); ++iter) @@ -123,9 +121,7 @@ namespace MWWorld Ogre::Quaternion pitchQuat = pitchNode->getOrientation(); Ogre::Quaternion both = yawQuat * pitchQuat; - playerphysics->ps.viewangles.x = 0; - playerphysics->ps.viewangles.z = 0; - playerphysics->ps.viewangles.y = both.getYaw().valueDegrees() *-1 + 90; + //playerphysics->ps.viewangles.z = both.getPitch().valueDegrees(); @@ -133,8 +129,7 @@ namespace MWWorld { Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); - pm_ref.rightmove = -dir1.x; - pm_ref.forwardmove = dir1.z; + @@ -147,31 +142,24 @@ namespace MWWorld { Ogre::Quaternion quat = yawNode->getOrientation(); Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); - pm_ref.rightmove = -dir1.x; - pm_ref.forwardmove = dir1.z; + dir = 0.025*(quat*dir1); } - Pmove(playerphysics); + //set the walk direction act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y)); } - //mEngine->stepSimulation(duration); - Pmove(playerphysics); + mEngine->stepSimulation(duration); + std::vector< std::pair > response; for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) { btVector3 newPos = it->second->getPosition(); Ogre::Vector3 coord(newPos.x(), newPos.y(), newPos.z()); - if(it->first == "player"){ - - coord = playerphysics->ps.origin; - //std::cout << "Coord" << coord << "\n"; - coord = Ogre::Vector3(coord.x, coord.z, coord.y); //x, z, -y - - } + response.push_back(std::pair(it->first, coord)); } diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index a2dea2492..b88ff23b1 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -5,7 +5,6 @@ #include #include #include "ptr.hpp" -#include namespace MWWorld { @@ -54,7 +53,7 @@ namespace MWWorld OEngine::Render::OgreRenderer &mRender; OEngine::Physic::PhysicEngine* mEngine; bool mFreeFly; - playerMove* playerphysics; + PhysicsSystem (const PhysicsSystem&); PhysicsSystem& operator= (const PhysicsSystem&); diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 37b97dd27..1972d8d5b 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -31,7 +31,7 @@ const float WeatherGlobals::mThunderFrequency = .4; const float WeatherGlobals::mThunderThreshold = 0.6; const float WeatherGlobals::mThunderSoundDelay = 0.25; -WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environment* env) : +WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::Environment* env) : mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0), mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0) { @@ -268,8 +268,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environmen blight.mGlareView = 0; blight.mAmbientLoopSoundID = "blight"; mWeatherSettings["blight"] = blight; - - /* + Weather snow; snow.mCloudTexture = "tx_bm_sky_snow.dds"; snow.mCloudsMaximumPercent = 1.0; @@ -326,7 +325,6 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environmen blizzard.mGlareView = 0; blizzard.mAmbientLoopSoundID = "BM Blizzard"; mWeatherSettings["blizzard"] = blizzard; - */ } void WeatherManager::setWeather(const String& weather, bool instant) @@ -508,32 +506,32 @@ void WeatherManager::update(float duration) float thunder = region->data.thunder/255.f; float ash = region->data.ash/255.f; float blight = region->data.blight/255.f; - //float snow = region->data.a/255.f; - //float blizzard = region->data.b/255.f; + float snow = region->data.a/255.f; + float blizzard = region->data.b/255.f; // re-scale to 100 percent - const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight;//+snow+blizzard; + const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight+snow+blizzard; srand(time(NULL)); float random = ((rand()%100)/100.f) * total; - //if (random > snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) - // weather = "blizzard"; - //else if (random > blight+ash+thunder+rain+overcast+foggy+cloudy+clear) - // weather = "snow"; - /*else*/ if (random > ash+thunder+rain+overcast+foggy+cloudy+clear) + if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) + weather = "blizzard"; + else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear) + weather = "snow"; + else if (random >= ash+thunder+rain+overcast+foggy+cloudy+clear) weather = "blight"; - else if (random > thunder+rain+overcast+foggy+cloudy+clear) + else if (random >= thunder+rain+overcast+foggy+cloudy+clear) weather = "ashstorm"; - else if (random > rain+overcast+foggy+cloudy+clear) + else if (random >= rain+overcast+foggy+cloudy+clear) weather = "thunderstorm"; - else if (random > overcast+foggy+cloudy+clear) + else if (random >= overcast+foggy+cloudy+clear) weather = "rain"; - else if (random > foggy+cloudy+clear) + else if (random >= foggy+cloudy+clear) weather = "overcast"; - else if (random > cloudy+clear) + else if (random >= cloudy+clear) weather = "foggy"; - else if (random > clear) + else if (random >= clear) weather = "cloudy"; else weather = "clear"; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index a48cc7e72..a7252353d 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -543,7 +543,7 @@ namespace MWWorld if (ptr==mPlayer->getPlayer()) { //std::cout << "X:" << ptr.getRefData().getPosition().pos[0] << " Z: " << ptr.getRefData().getPosition().pos[1] << "\n"; - + Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); if (currentCell) { @@ -750,15 +750,16 @@ namespace MWWorld // figure out which object we want to test against std::vector < std::pair < float, std::string > > results = mPhysics->getFacedObjects(); - // ignore the player - for (std::vector < std::pair < float, std::string > >::iterator it = results.begin(); - it != results.end(); ++it) + // ignore the player and other things we're not interested in + std::vector < std::pair < float, std::string > >::iterator it = results.begin(); + while (it != results.end()) { - if ( (*it).second == mPlayer->getPlayer().getRefData().getHandle() ) + if ( getPtrViaHandle((*it).second) == mPlayer->getPlayer() ) { - results.erase(it); - break; + it = results.erase(it); } + else + ++it; } if (results.size() == 0) @@ -774,6 +775,10 @@ namespace MWWorld btVector3 p = mPhysics->getRayPoint(results.front().first); Ogre::Vector3 pos(p.x(), p.z(), -p.y()); Ogre::SceneNode* node = mFaced1.getRefData().getBaseNode(); + + //std::cout << "Num facing 1 : " << mFaced1Name << std::endl; + //std::cout << "Type 1 " << mFaced1.getTypeName() << std::endl; + query->occlusionTest(pos, node); } else @@ -786,8 +791,33 @@ namespace MWWorld btVector3 p = mPhysics->getRayPoint(results[1].first); Ogre::Vector3 pos(p.x(), p.z(), -p.y()); - Ogre::SceneNode* node = mFaced2.getRefData().getBaseNode(); - query->occlusionTest(pos, node); + Ogre::SceneNode* node1 = mFaced1.getRefData().getBaseNode(); + Ogre::SceneNode* node2 = mFaced2.getRefData().getBaseNode(); + + // no need to test if the first node is not occluder + if (!query->isPotentialOccluder(node1) && (mFaced1.getTypeName().find("Static") == std::string::npos)) + { + mFacedHandle = mFaced1Name; + //std::cout << "node1 Not an occluder" << std::endl; + return; + } + + // no need to test if the second object is static (thus cannot be activated) + if (mFaced2.getTypeName().find("Static") != std::string::npos) + { + mFacedHandle = mFaced1Name; + return; + } + + // work around door problems + if (mFaced1.getTypeName().find("Static") != std::string::npos + && mFaced2.getTypeName().find("Door") != std::string::npos) + { + mFacedHandle = mFaced2Name; + return; + } + + query->occlusionTest(pos, node2); } } } @@ -834,6 +864,18 @@ namespace MWWorld return mRendering->getFader(); } + Ogre::Vector2 World::getNorthVector(Ptr::CellStore* cell) + { + ESMS::CellRefList statics = cell->statics; + ESMS::LiveCellRef* ref = statics.find("northmarker"); + if (!ref) + return Vector2(0, 1); + Ogre::SceneNode* node = ref->mData.getBaseNode(); + Vector3 dir = node->_getDerivedOrientation().yAxis(); + Vector2 d = Vector2(dir.x, dir.z); + return d; + } + void World::setWaterHeight(const float height) { mRendering->setWaterHeight(height); diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 7f8b7e861..92540f82b 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -63,13 +63,14 @@ namespace MWWorld enum RenderMode { Render_CollisionDebug, - Render_Wireframe + Render_Wireframe, + Render_Pathgrid }; private: MWRender::RenderingManager* mRendering; - + MWWorld::WeatherManager* mWeatherManager; MWWorld::Scene *mWorldScene; @@ -112,7 +113,7 @@ namespace MWWorld Environment& environment, const std::string& encoding); ~World(); - + OEngine::Render::Fader* getFader(); Ptr::CellStore *getExterior (int x, int y); @@ -121,7 +122,7 @@ namespace MWWorld void setWaterHeight(const float height); void toggleWater(); - + void adjustSky(); MWWorld::Player& getPlayer(); @@ -134,10 +135,13 @@ namespace MWWorld bool hasCellChanged() const; ///< Has the player moved to a different cell, since the last frame? - + bool isCellExterior() const; bool isCellQuasiExterior() const; + Ogre::Vector2 getNorthVector(Ptr::CellStore* cell); + ///< get north vector (OGRE coordinates) for given interior cell + Globals::Data& getGlobalVariable (const std::string& name); Globals::Data getGlobalVariable (const std::string& name) const; @@ -172,9 +176,9 @@ namespace MWWorld bool toggleSky(); ///< \return Resulting mode - + void changeWeather(const std::string& region, const unsigned int id); - + int getCurrentWeather() const; int getMasserPhase() const; diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 0e3563b26..fa197d960 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -79,7 +79,7 @@ class DirArchive: public Ogre::FileSystemArchive { passed = filename.substr(0, filename.length() - 2); } - if(filename.at(filename.length() - 2) == '>') + if(filename.at(filename.length() - 2) == '>' || filename.at(filename.length() - 2) == ':') passed = filename.substr(0, filename.length() - 6); copy = passed; } @@ -232,7 +232,7 @@ public: { passed = filename.substr(0, filename.length() - 2); } - if(filename.at(filename.length() - 2) == '>') + if(filename.at(filename.length() - 2) == '>' || filename.at(filename.length() - 2) == ':') passed = filename.substr(0, filename.length() - 6); // Open the file StreamPtr strm = narc->getFile(passed.c_str()); @@ -254,7 +254,7 @@ bool exists(const String& filename) { { passed = filename.substr(0, filename.length() - 2); } - if(filename.at(filename.length() - 2) == '>') + if(filename.at(filename.length() - 2) == '>' || filename.at(filename.length() - 2) == ':') passed = filename.substr(0, filename.length() - 6); return arc.exists(passed.c_str()); diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 2ab6ae621..616dd1daf 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -1296,6 +1296,7 @@ void NIFLoader::loadResource(Resource *resource) char suffix = name.at(name.length() - 2); bool addAnim = true; bool hasAnim = false; + bool linkSkeleton = true; //bool baddin = false; bNiTri = true; if(name == "meshes\\base_anim.nif" || name == "meshes\\base_animkna.nif") @@ -1326,6 +1327,17 @@ void NIFLoader::loadResource(Resource *resource) addAnim = false; } + else if(suffix == ':') + { + //baddin = true; + linkSkeleton = false; + bNiTri = true; + std::string sub = name.substr(name.length() - 6, 4); + + if(sub.compare("0000") != 0) + addAnim = false; + + } switch(name.at(name.length() - 1)) { @@ -1464,7 +1476,7 @@ void NIFLoader::loadResource(Resource *resource) } //Don't link on npc parts to eliminate redundant skeletons //Will have to be changed later slightly for robes/skirts - if(triname == "") + if(linkSkeleton) mesh->_notifySkeleton(mSkel); } } diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp deleted file mode 100644 index 45fe84f4f..000000000 --- a/libs/openengine/bullet/pmove.cpp +++ /dev/null @@ -1,2042 +0,0 @@ -/* -This source file is a *modified* version of bg_pmove.c from the Quake 3 Arena source code, -which was released under the GNU GPL (v2) in 2005. -Quake 3 Arena is copyright (C) 1999-2005 Id Software, Inc. -*/ - - -#include "pmove.h" - - - -//#include "bprintf.h" - -//#include "..\..\ESMParser\ESMParser\CELL.h" - -//#include "GameTime.h" - -//#include "Object.h" - -//#include "Sound.h" - -//#include "..\..\ESMParser\ESMParser\SNDG.h" -//#include "..\..\ESMParser\ESMParser\SOUN.h" - -#include - -//SceneInstance* global_lastscene = NULL; - -// Forward declaration: -void PM_AirMove(); - -static playerMove* pm = NULL; - -//extern std::map ExtCellLookup; - -static struct playermoveLocal -{ - playermoveLocal() : frametime(1.0f / 20.0f), groundPlane(true), walking(true), msec(50) - { - forward = Ogre::Vector3(0.0f, 0.0f, 0.0f); - right = Ogre::Vector3(0.0f, 0.0f, 0.0f); - up = Ogre::Vector3(0.0f, 0.0f, 0.0f); - - previous_origin = Ogre::Vector3(0.0f, 0.0f, 0.0f); - previous_velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f); - } - - traceResults groundTrace; - - //SceneInstance* scene; - - float frametime; // in seconds (usually something like 0.01f) - float impactSpeed; - - Ogre::Vector3 forward; - Ogre::Vector3 right; - Ogre::Vector3 up; - - int msec; - - Ogre::Vector3 previous_origin, previous_velocity; - - int previous_waterlevel; // the waterlevel before this pmove - - bool groundPlane; // if we're standing on a groundplane this frame - - bool walking; - int waterHeight; - bool hasWater; - bool isInterior; - //Object* traceObj; - -} pml; - -static inline void PM_ClipVelocity(const Ogre::Vector3& in, const Ogre::Vector3& normal, Ogre::Vector3& out, const float overbounce) -{ - float backoff; - //float change; - //int i; - - // backoff = in dot normal - //backoff = DotProduct (in, normal); - backoff = in.dotProduct(normal); - - if ( backoff < 0 ) - backoff *= overbounce; - else - backoff /= overbounce; - - // change = normal * backoff - // out = in - change - /*for ( i=0 ; i<3 ; i++ ) - { - change = normal[i]*backoff; - out[i] = in[i] - change; - }*/ - float changex = normal.x * backoff; - out.x = in.x - changex; - float changey = normal.y * backoff; - out.y = in.y - changey; - float changez = normal.z * backoff; - out.z = in.z - changez; -} - -float VectorNormalize2( const Ogre::Vector3& v, Ogre::Vector3& out) -{ - float length, ilength; - - length = v.x * v.x+ v.y * v.y + v.z * v.z; - length = sqrt(length); - - if (length) - { -#ifndef Q3_VM // bk0101022 - FPE related -// assert( ((Q_fabs(v[0])!=0.0f) || (Q_fabs(v[1])!=0.0f) || (Q_fabs(v[2])!=0.0f)) ); -#endif - ilength = 1 / length; - out.x= v.x * ilength; - out.y = v.y * ilength; - out.z = v.z * ilength; - } else - { -#ifndef Q3_VM // bk0101022 - FPE related -// assert( ((Q_fabs(v[0])==0.0f) && (Q_fabs(v[1])==0.0f) && (Q_fabs(v[2])==0.0f)) ); -#endif - //VectorClear( out ); - out.x = 0; out.y = 0; out.z = 0; - } - - return length; - -} - - -float VectorNormalize(Ogre::Vector3& out) -{ - float length, ilength; - - length = out.x * out.x + out.y * out.y + out.z * out.z; - length = sqrt(length); - - if (length) - { -#ifndef Q3_VM // bk0101022 - FPE related -// assert( ((Q_fabs(v[0])!=0.0f) || (Q_fabs(v[1])!=0.0f) || (Q_fabs(v[2])!=0.0f)) ); -#endif - ilength = 1 / length; - out.x = out.x * ilength; - out.y = out.y * ilength; - out.z = out.z * ilength; - } - - return length; - -} - -/* -================== -PM_SlideMove - -Returns qtrue if the velocity was clipped in some way -================== -*/ - -bool PM_SlideMove( bool gravity ) -{ - int bumpcount, numbumps; - Ogre::Vector3 dir; - float d; - int numplanes; - Ogre::Vector3 planes[MAX_CLIP_PLANES]; - Ogre::Vector3 primal_velocity; - Ogre::Vector3 clipVelocity; - int i, j, k; - struct traceResults trace; - Ogre::Vector3 end; - float time_left; - float into; - Ogre::Vector3 endVelocity; - Ogre::Vector3 endClipVelocity; - - numbumps = 4; - - // primal_velocity = pm->ps->velocity - //VectorCopy (pm->ps->velocity, primal_velocity); - primal_velocity = pm->ps.velocity; - - if ( gravity ) - { - // endVelocity = pm->ps->velocity - vec3(0, 0, pm->ps->gravity * pml.frametime) - //VectorCopy( pm->ps->velocity, endVelocity ); - endVelocity = pm->ps.velocity; - //endVelocity[2] -= pm->ps->gravity * pml.frametime; - endVelocity.y -= pm->ps.gravity * pml.frametime; - - // pm->ps->velocity = avg(pm->ps->velocity.z, endVelocity.z) - //pm->ps->velocity[2] = ( pm->ps->velocity[2] + endVelocity[2] ) * 0.5; - pm->ps.velocity.y= (pm->ps.velocity.y + endVelocity.y) * 0.5f; - - //primal_velocity[2] = endVelocity[2]; - primal_velocity.y = endVelocity.y; - - if ( pml.groundPlane ) - // slide along the ground plane - //PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP ); - PM_ClipVelocity(pm->ps.velocity, pml.groundTrace.planenormal, pm->ps.velocity, OVERCLIP); - } - - time_left = pml.frametime; - - // never turn against the ground plane - if ( pml.groundPlane ) - { - numplanes = 1; - - // planes[0] = pml.groundTrace.plane.normal - //VectorCopy( pml.groundTrace.plane.normal, planes[0] ); - planes[0] = pml.groundTrace.planenormal; - } else - numplanes = 0; - - // never turn against original velocity - VectorNormalize2( pm->ps.velocity, planes[numplanes] ); - numplanes++; - - for ( bumpcount = 0; bumpcount < numbumps; bumpcount++ ) - { - - // calculate position we are trying to move to - //VectorMA( pm->ps->origin, time_left, pm->ps->velocity, end ); - end = pm->ps.origin + pm->ps.velocity * time_left; - - // see if we can make it there - //pm->trace ( &trace, pm->ps->origin, pm->mins, pm->maxs, end, pm->ps->clientNum, pm->tracemask); - //tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&(end), *(const D3DXVECTOR3* const)&(pm->ps.velocity), 0, pml.traceObj); - newtrace(&trace, pm->ps.origin, end, halfExtents, Ogre::Math::DegreesToRadians (pm->ps.viewangles.y), pm->isInterior, pm->mEngine); - - if (trace.allsolid) - { - // entity is completely trapped in another solid - //pm->ps->velocity[2] = 0; // don't build up falling damage, but allow sideways acceleration - pm->ps.velocity.y = 0; - return true; - } - - if (trace.fraction > 0) - // actually covered some distance - //VectorCopy (trace.endpos, pm->ps->origin); - pm->ps.origin = trace.endpos; - - if (trace.fraction == 1) - break; // moved the entire distance - - // save entity for contact8 - //PM_AddTouchEnt( trace.entityNum ); - - time_left -= time_left * trace.fraction; - - if (numplanes >= MAX_CLIP_PLANES) - { - // this shouldn't really happen - //VectorClear( pm->ps->velocity ); - pm->ps.velocity = Ogre::Vector3(0,0,0); - return true; - } - - // - // if this is the same plane we hit before, nudge velocity - // out along it, which fixes some epsilon issues with - // non-axial planes - // - for ( i = 0 ; i < numplanes ; i++ ) - { - if (trace.planenormal.dotProduct(planes[i]) > 0.99) //OGRE::VECTOR3 ? - //if ( DotProduct( trace.plane.normal, planes[i] ) > 0.99 ) - { - // pm->ps->velocity += (trace.plane.normal + pm->ps->velocity) - //VectorAdd( trace.plane.normal, pm->ps->velocity, pm->ps->velocity ); - pm->ps.velocity = (trace.planenormal + pm->ps.velocity); - break; - } - } - - if ( i < numplanes ) - continue; - - //VectorCopy (trace.plane.normal, planes[numplanes]); - planes[numplanes] = trace.planenormal; - numplanes++; - - // - // modify velocity so it parallels all of the clip planes - // - - // find a plane that it enters - for ( i = 0 ; i < numplanes ; i++ ) - { - //into = DotProduct( pm->ps->velocity, planes[i] ); - into = pm->ps.velocity.dotProduct(planes[i]); - if ( into >= 0.1 ) - continue; // move doesn't interact with the plane - - // see how hard we are hitting things - if ( -into > pml.impactSpeed ) - pml.impactSpeed = -into; - - // slide along the plane - //PM_ClipVelocity (pm->ps->velocity, planes[i], clipVelocity, OVERCLIP ); - PM_ClipVelocity(pm->ps.velocity, planes[i], clipVelocity, OVERCLIP); - - // slide along the plane - PM_ClipVelocity (endVelocity, planes[i], endClipVelocity, OVERCLIP ); - - // see if there is a second plane that the new move enters - for ( j = 0 ; j < numplanes ; j++ ) - { - if ( j == i ) - continue; - - if (clipVelocity.dotProduct(planes[j]) >= 0.1) - //if ( DotProduct( clipVelocity, planes[j] ) >= 0.1 ) - continue; // move doesn't interact with the plane - - // try clipping the move to the plane - PM_ClipVelocity( clipVelocity, planes[j], clipVelocity, OVERCLIP ); - PM_ClipVelocity( endClipVelocity, planes[j], endClipVelocity, OVERCLIP ); - - // see if it goes back into the first clip plane - if (clipVelocity.dotProduct(planes[i]) >= 0) - //if ( DotProduct( clipVelocity, planes[i] ) >= 0 ) - continue; - - - // slide the original velocity along the crease - //dProduct (planes[i], planes[j], dir); - dir = planes[i].crossProduct(planes[j]) ; - - //VectorNormalize( dir ); - //D3DXVec3Normalize( (D3DXVECTOR3* const)&dir, (const D3DXVECTOR3* const)&dir); - VectorNormalize(dir); - - //d = DotProduct( dir, pm->ps->velocity ); - d = dir.dotProduct(pm->ps.velocity); - - //VectorScale( dir, d, clipVelocity ); - clipVelocity = dir * d; - - //CrossProduct (planes[i], planes[j], dir); - dir = planes[i].crossProduct(planes[j]) ; - - - //VectorNormalize( dir ); - //D3DXVec3Normalize( (D3DXVECTOR3* const)&dir, (const D3DXVECTOR3* const)&dir); - VectorNormalize(dir); - - //d = DotProduct( dir, endVelocity ); - d = dir.dotProduct(endVelocity); - - //VectorScale( dir, d, endClipVelocity ); - endClipVelocity = dir * d; - - // see if there is a third plane the the new move enters - for ( k = 0 ; k < numplanes ; k++ ) - { - if ( k == i || k == j ) - continue; - - if (clipVelocity.dotProduct(planes[k]) >= 0.1) - //if ( DotProduct( clipVelocity, planes[k] ) >= 0.1 ) - continue; // move doesn't interact with the plane - - // stop dead at a tripple plane interaction - //VectorClear( pm->ps->velocity ); - printf("Stop dead at a triple plane interaction\n"); - pm->ps.velocity = Ogre::Vector3(0,0,0); - return true; - } - } - - // if we have fixed all interactions, try another move - //VectorCopy( clipVelocity, pm->ps->velocity ); - pm->ps.velocity = clipVelocity; - - //VectorCopy( endClipVelocity, endVelocity ); - endVelocity = endClipVelocity; - break; - } - } - - if ( gravity ) - //VectorCopy( endVelocity, pm->ps->velocity ); - pm->ps.velocity = endVelocity; - - // don't change velocity if in a timer (FIXME: is this correct?) - if ( pm->ps.pm_time ) - //VectorCopy( primal_velocity, pm->ps->velocity ); - pm->ps.velocity = primal_velocity; - - //return ( (qboolean)(bumpcount != 0) ); - return bumpcount != 0; -} - -/* -================== -PM_StepSlideMove - -================== -*/ -int PM_StepSlideMove( bool gravity ) -{ - Ogre::Vector3 start_o, start_v; - Ogre::Vector3 down_o, down_v; - traceResults trace; -// float down_dist, up_dist; -// vec3_t delta, delta2; - Ogre::Vector3 up, down; - float stepSize; - - // start_o = pm->ps->origin - //VectorCopy (pm->ps->origin, start_o); - start_o = pm->ps.origin; - - // start_v = pm->ps->velocity - //VectorCopy (pm->ps->velocity, start_v); - start_v = pm->ps.velocity; - - if ( PM_SlideMove( gravity ) == false ) - return 1; // we got exactly where we wanted to go first try - - // down = start_o - vec3(0, 0, STEPSIZE) - //VectorCopy(start_o, down); - down = start_o; - down.y -= STEPSIZE; - - //pm->trace (&trace, start_o, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask); - //tracefunc(&trace, start_o, down, , 0, pml.scene); - //tracefunc(&trace, *(const D3DXVECTOR3* const)&start_o, *(const D3DXVECTOR3* const)&down, D3DXVECTOR3(0.0f, -STEPSIZE, 0.0f), 0, pml.traceObj); - newtrace(&trace, start_o, down, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine); - - // up = vec3(0, 0, 1) - //VectorSet(up, 0, 0, 1); - up = Ogre::Vector3(0.0f, 1.0f, 0.0f); - - // never step up when you still have up velocity - //if ( pm->ps->velocity[2] > 0 && (trace.fraction == 1.0 || DotProduct(trace.plane.normal, up) < 0.7)) - if (pm->ps.velocity.y > 0 && ( - trace.fraction == 1.0 || trace.planenormal.dotProduct(up) < 0.7 - ) ) - return 2; - - // down_o = pm->ps->origin - //VectorCopy (pm->ps->origin, down_o); - down_o = pm->ps.origin; - - // down_v = pm->ps->velocity - //VectorCopy (pm->ps->velocity, down_v); - down_v = pm->ps.velocity; - - // up = start_o + vec3(0, 0, STEPSIZE) - //VectorCopy (start_o, up); - up = start_o; - //up[2] += STEPSIZE; - up.y += STEPSIZE; - - // test the player position if they were a stepheight higher - //pm->trace (&trace, start_o, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask); - //tracefunc(&trace, *(const D3DXVECTOR3* const)&start_o, *(const D3DXVECTOR3* const)&up, D3DXVECTOR3(0.0f, STEPSIZE, 0.0f), 0, pml.traceObj); - newtrace(&trace, start_o, up, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine); - if ( trace.allsolid ) - { - //if ( pm->debugLevel ) - //Com_Printf("%i:bend can't step\n", c_pmove); - //bprintf("bend can't step\n"); - return 3; // can't step up - } - - //stepSize = trace.endpos[2] - start_o[2]; - stepSize = trace.endpos.y - start_o.y; - - // try slidemove from this position - //VectorCopy (trace.endpos, pm->ps->origin); // pm->ps->origin = trace.endpos - pm->ps.origin = trace.endpos; - //VectorCopy (start_v, pm->ps->velocity); // pm->ps->velocity = start_v - pm->ps.velocity = start_v; - - PM_SlideMove( gravity ); - - // push down the final amount - - // down = pm->ps->origin - vec3(0, 0, stepSize) - //VectorCopy (pm->ps->origin, down); - down = pm->ps.origin; - //down[2] -= stepSize; - down.y -= stepSize; - - - //pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask); - //tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&down, D3DXVECTOR3(0.0f, -STEPSIZE, 0.0f), 0, pml.traceObj); - newtrace(&trace, pm->ps.origin, down, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine); - if ( !trace.allsolid ) - //VectorCopy (trace.endpos, pm->ps->origin); - pm->ps.origin = trace.endpos; - - if ( trace.fraction < 1.0 ) - //PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity, OVERCLIP ); - PM_ClipVelocity(pm->ps.velocity, trace.planenormal, pm->ps.velocity, OVERCLIP); - - { - // use the step move - float delta; - - //delta = pm->ps->origin[2] - start_o[2]; - delta = pm->ps.origin.y - start_o.y; - if ( delta > 2 ) - { - if (gravity) - printf("g on: %f ", delta); - else - printf("g off: %f ", delta); - - if ( delta < 7 ) - printf("stepped 3 < x < 7\n"); - //PM_AddEvent( EV_STEP_4 ); - else if ( delta < 11 ) - printf("stepped 7 < x < 11\n"); - //PM_AddEvent( EV_STEP_8 ); - else if ( delta < 15 ) - printf("stepped 11 < x < 15\n"); - //PM_AddEvent( EV_STEP_12 ); - else - printf("stepped 15+\n"); - //PM_AddEvent( EV_STEP_16 ); - - } - /*if ( pm->debugLevel ) - Com_Printf("%i:stepped\n", c_pmove);*/ - } - - return 4; -} - -void PM_Friction(void) -{ - Ogre::Vector3 vec; - float* vel; - float speed, newspeed, control; - float drop; - - vel = &(pm->ps.velocity.x); - - // vec = vel - //VectorCopy( vel, vec ); - vec = pm->ps.velocity; - - if ( pml.walking ) - //vec[2] = 0; // ignore slope movement - vec.y = 0; - - //speed = VectorLength(vec); - speed = vec.length(); - if (speed < 1) - { - vel[0] = 0; - vel[2] = 0; // allow sinking underwater - // FIXME: still have z friction underwater? - //bprintf("Static friction (vec = [%f, %f, %f]) (vec.length = %f)\n", vec.x, vec.y, vec.z, speed); - return; - } - - drop = 0; - - // apply ground friction - if ( pm->ps.waterlevel <= 1 ) - { - if ( pml.walking )//&& !(pml.groundTrace.surfaceFlags & SURF_SLICK) ) - { - // if getting knocked back, no friction - //if ( ! (pm->ps->pm_flags & PMF_TIME_KNOCKBACK) ) - { - control = (speed < pm_stopspeed) ? pm_stopspeed : speed; - drop += control * pm_friction * pml.frametime; - } - } - } - - // apply water friction even if just wading - if ( pm->ps.waterlevel ) - drop += speed * pm_waterfriction * pm->ps.waterlevel * pml.frametime; - - // apply flying friction - /*if ( pm->ps->powerups[PW_FLIGHT]) - drop += speed * pm_flightfriction * pml.frametime; - - if ( pm->ps->pm_type == PM_SPECTATOR) - drop += speed * pm_spectatorfriction * pml.frametime;*/ - if (pm->ps.move_type == PM_SPECTATOR) - drop += speed * pm_flightfriction * pml.frametime; - - // scale the velocity - newspeed = speed - drop; - if (newspeed < 0) - newspeed = 0; - - newspeed /= speed; - - // vel *= newspeed - vel[0] = vel[0] * newspeed; - vel[1] = vel[1] * newspeed; - vel[2] = vel[2] * newspeed; -} - -float PM_CmdScale(playerMove::playercmd* const cmd) -{ - int max; - float total; - float scale; - - max = abs( cmd->forwardmove ); - if ( abs( cmd->rightmove ) > max ) - max = abs( cmd->rightmove ); - - if ( abs( cmd->upmove ) > max ) - max = abs( cmd->upmove ); - - if ( !max ) - return 0; - - total = sqrtf( (const float)(cmd->forwardmove * cmd->forwardmove - + cmd->rightmove * cmd->rightmove + cmd->upmove * cmd->upmove) ); - scale = (float)pm->ps.speed * max / ( 127.0f * total ); - - return scale; -} - -static void PM_Accelerate( Ogre::Vector3& wishdir, float wishspeed, float accel ) -{ -// int i; - float addspeed, accelspeed, currentspeed; - - // currentspeed = pm->ps->velocity dot wishdir - //currentspeed = DotProduct (pm->ps->velocity, wishdir); - currentspeed = pm->ps.velocity.dotProduct(wishdir); - - addspeed = wishspeed - currentspeed; - if (addspeed <= 0) - return; - - accelspeed = accel * pml.frametime * wishspeed; - - // Clamp accelspeed at addspeed - if (accelspeed > addspeed) - accelspeed = addspeed; - - // pm->ps->velocity += accelspeed * wishdir - //for (i=0 ; i<3 ; i++) - //pm->ps->velocity[i] += accelspeed * wishdir[i]; - pm->ps.velocity += (wishdir * accelspeed); -} - -static bool PM_CheckJump(void) -{ - //if ( pm->ps->pm_flags & PMF_RESPAWNED ) - //return qfalse; // don't allow jump until all buttons are up - - if ( pm->cmd.upmove < 10 ) - // not holding jump - return false; - - pm->cmd.upmove = 0; - - // must wait for jump to be released - /*if ( pm->ps->pm_flags & PMF_JUMP_HELD ) - { - // clear upmove so cmdscale doesn't lower running speed - pm->cmd.upmove = 0; - return false; - }*/ - - pml.groundPlane = false; // jumping away - pml.walking = false; - //pm->ps->pm_flags |= PMF_JUMP_HELD; - - pm->ps.groundEntityNum = ENTITYNUM_NONE; - pm->ps.velocity.y = JUMP_VELOCITY; - //PM_AddEvent( EV_JUMP ); - - /*if ( pm->cmd.forwardmove >= 0 ) - { - PM_ForceLegsAnim( LEGS_JUMP ); - pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; - } - else - { - PM_ForceLegsAnim( LEGS_JUMPB ); - pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; - }*/ - - return true; -} - -static void PM_WaterMove( playerMove* const pm ) -{ - //int i; - //vec3_t wishvel; - Ogre::Vector3 wishvel; - float wishspeed; - //vec3_t wishdir; - Ogre::Vector3 wishdir; - float scale; - float vel; - - /*if ( PM_CheckWaterJump() ) - { - PM_WaterJumpMove(); - return; - }*/ -#if 0 - // jump = head for surface - if ( pm->cmd.upmove >= 10 ) { - if (pm->ps->velocity[2] > -300) { - if ( pm->watertype == CONTENTS_WATER ) { - pm->ps->velocity[2] = 100; - } else if (pm->watertype == CONTENTS_SLIME) { - pm->ps->velocity[2] = 80; - } else { - pm->ps->velocity[2] = 50; - } - } - } -#endif - PM_Friction (); - - if (pm->cmd.forwardmove || pm->cmd.rightmove) - { - //NEEDS TO BE REWRITTEN FOR OGRE TIME--------------------------------------------------- - /* - static const TimeTicks footstep_duration = GetTimeFreq(); // make each splash last 1.0s - static TimeTicks lastStepTime = 0; - const TimeTicks thisStepTime = GetTimeQPC(); - static bool lastWasLeft = false; - if (thisStepTime > lastStepTime) - { - if (pm->cmd.ducking) - lastStepTime = thisStepTime + footstep_duration * 2; // splashes while ducking are twice as slow - else - lastStepTime = thisStepTime + footstep_duration; - - lastWasLeft = !lastWasLeft; - */ - //-----------------jhooks1 - - /* - namestruct defaultCreature; - const SNDG* const sndg = SNDG::GetFromMap(defaultCreature, lastWasLeft ? SNDG::r_swim : SNDG::l_swim); - if (sndg) - { - const namestruct& SOUNID = sndg->soundID; - const SOUN* const soun = SOUN::GetSound(SOUNID); - if (soun) - { - PlaySound2D(soun->soundFilename, soun->soundData->GetVolumeFloat() ); - } - }*/ - //Sound, ignore for now -- jhooks1 - //} - } - - scale = PM_CmdScale( &pm->cmd ); - // - // user intentions - // - if ( !scale ) - { - /*wishvel[0] = 0; - wishvel[1] = 0; - wishvel[2] = -60; // sink towards bottom - */ - wishvel.x = 0; - wishvel.y = -60; - wishvel.z = 0; - } - else - { - /*for (i=0 ; i<3 ; i++) - wishvel[i] = scale * pml.forward[i]*pm->cmd.forwardmove + scale * pml.right[i]*pm->cmd.rightmove;*/ - wishvel = pml.forward * scale * pm->cmd.forwardmove + pml.right * scale * pm->cmd.rightmove; - - //wishvel[2] += scale * pm->cmd.upmove; - wishvel.y += pm->cmd.upmove * scale; - } - - //VectorCopy (wishvel, wishdir); - wishdir = wishvel; - wishspeed = VectorNormalize(wishdir); - - if ( wishspeed > pm->ps.speed * pm_swimScale ) - wishspeed = pm->ps.speed * pm_swimScale; - - PM_Accelerate (wishdir, wishspeed, pm_wateraccelerate); - - // make sure we can go up slopes easily under water - //if ( pml.groundPlane && DotProduct( pm->ps->velocity, pml.groundTrace.plane.normal ) < 0 ) - if (pml.groundPlane && pm->ps.velocity.dotProduct(pml.groundTrace.planenormal) < 0.0f) - { - //vel = VectorLength(pm->ps->velocity); - vel = pm->ps.velocity.length(); - - // slide along the ground plane - //PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP ); - PM_ClipVelocity(pm->ps.velocity, pml.groundTrace.planenormal, pm->ps.velocity, OVERCLIP); - - VectorNormalize(pm->ps.velocity); - //VectorScale(pm->ps->velocity, vel, pm->ps->velocity); - pm->ps.velocity = pm->ps.velocity * vel; - } - - PM_SlideMove( false ); -} - -/* -=================== -PM_WalkMove - -=================== -*/ -static void PM_WalkMove( playerMove* const pmove ) -{ -// int i; - Ogre::Vector3 wishvel; - float fmove, smove; - Ogre::Vector3 wishdir; - float wishspeed; - float scale; - playerMove::playercmd cmd; - float accelerate; - float vel; - - if ( pm->ps.waterlevel > 2 && //DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) - pml.forward.dotProduct(pml.groundTrace.planenormal) > 0.0f) - { - // begin swimming - PM_WaterMove(pmove); - return; - } - - - if ( PM_CheckJump () ) - { - // jumped away - if ( pm->ps.waterlevel > 1 ) - PM_WaterMove(pmove); - else - PM_AirMove(); - printf("Jumped away\n"); - return; - } - - // Footsteps time - if (pmove->cmd.forwardmove || pmove->cmd.rightmove) - { - bool step_underwater = false; - //if (pmove->traceObj) - //{ - - - //jhooks1 - Water handling, deal with later - - - - if (pmove->hasWater) - { - if (pmove->hasWater ) - { - const float waterHeight = pmove->waterHeight; - const float waterSoundStepHeight = waterHeight + halfExtents.y; - if (pmove->ps.origin.y < waterSoundStepHeight) - step_underwater = true; - } - } - //} - - /* - static const TimeTicks footstep_duration = GetTimeFreq() / 2; // make each footstep last 500ms - static TimeTicks lastStepTime = 0; - const TimeTicks thisStepTime = GetTimeQPC(); - static bool lastWasLeft = false; - if (thisStepTime > lastStepTime) - { - if (pmove->cmd.ducking) - lastStepTime = thisStepTime + footstep_duration * 2; // footsteps while ducking are twice as slow - else - lastStepTime = thisStepTime + footstep_duration; - - lastWasLeft = !lastWasLeft; - */ - - if (step_underwater) - { - /* - const namestruct ns(lastWasLeft ? "FootWaterRight" : "FootWaterLeft"); - const SOUN* const soun = SOUN::GetSound(ns); - if (soun) - { - PlaySound2D(soun->soundFilename, soun->soundData->GetVolumeFloat() ); - }*/ - } - else - { - /* - namestruct defaultCreature; - const SNDG* const sndg = SNDG::GetFromMap(defaultCreature, lastWasLeft ? SNDG::r_foot : SNDG::l_foot); - if (sndg) - { - const namestruct& SOUNID = sndg->soundID; - const SOUN* const soun = SOUN::GetSound(SOUNID); - if (soun) - { - PlaySound2D(soun->soundFilename, soun->soundData->GetVolumeFloat() ); - } - }*/ - } - } - - - PM_Friction (); - - //bprintf("vel: (%f, %f, %f)\n", pm->ps.velocity.x, pm->ps.velocity.y, pm->ps.velocity.z); - - fmove = pm->cmd.forwardmove; - smove = pm->cmd.rightmove; - - cmd = pm->cmd; - scale = PM_CmdScale( &cmd ); - - // set the movementDir so clients can rotate the legs for strafing - //PM_SetMovementDir(); - - // project moves down to flat plane - //pml.forward[2] = 0; - pml.forward.y = 0; - - //pml.right[2] = 0; - pml.right.y = 0; - - // project the forward and right directions onto the ground plane - PM_ClipVelocity (pml.forward, pml.groundTrace.planenormal, pml.forward, OVERCLIP ); - PM_ClipVelocity (pml.right, pml.groundTrace.planenormal, pml.right, OVERCLIP ); - // - //VectorNormalize (pml.forward); - pml.forward = pml.forward.normalise(); - pml.right = pml.right.normalise(); - - - // wishvel = (pml.forward * fmove) + (pml.right * smove); - //for ( i = 0 ; i < 3 ; i++ ) - //wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove; - wishvel = pml.forward * fmove + pml.right * smove; - //bprintf("f: (%f, %f, %f), s: (%f, %f, %f)\n", fmove, smove); - - - // when going up or down slopes the wish velocity should Not be zero -// wishvel[2] = 0; - - // wishdir = wishvel - //VectorCopy (wishvel, wishdir); - //wishvel = wishdir; - wishdir = wishvel; - - wishspeed = VectorNormalize(wishdir); - wishspeed *= scale; - - // clamp the speed lower if ducking - if ( pm->cmd.ducking ) - if ( wishspeed > pm->ps.speed * pm_duckScale ) - wishspeed = pm->ps.speed * pm_duckScale; - - // clamp the speed lower if wading or walking on the bottom - if ( pm->ps.waterlevel ) - { - float waterScale; - - waterScale = pm->ps.waterlevel / 3.0f; - waterScale = 1.0f - ( 1.0f - pm_swimScale ) * waterScale; - if ( wishspeed > pm->ps.speed * waterScale ) - wishspeed = pm->ps.speed * waterScale; - } - - // when a player gets hit, they temporarily lose - // full control, which allows them to be moved a bit - //if ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) - //accelerate = pm_airaccelerate; - //else - accelerate = pm_accelerate; - - - PM_Accelerate (wishdir, wishspeed, accelerate); - - //Com_Printf("velocity = %1.1f %1.1f %1.1f\n", pm->ps->velocity[0], pm->ps->velocity[1], pm->ps->velocity[2]); - //Com_Printf("velocity1 = %1.1f\n", VectorLength(pm->ps->velocity)); - - //if ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) - //pm->ps->velocity[2] -= pm->ps->gravity * pml.frametime; - //else - //{ - // don't reset the z velocity for slopes -// pm->ps->velocity[2] = 0; - //} - - //vel = VectorLength(pm->ps->velocity); - vel = pm->ps.velocity.length(); - - // slide along the ground plane - PM_ClipVelocity (pm->ps.velocity, pml.groundTrace.planenormal, - pm->ps.velocity, OVERCLIP ); - - // don't decrease velocity when going up or down a slope - //VectorNormalize(pm->ps->velocity); - pm->ps.velocity = pm->ps.velocity.normalise(); - - //VectorScale(pm->ps->velocity, vel, pm->ps->velocity); - pm->ps.velocity = pm->ps.velocity * vel; - - // don't do anything if standing still - //if (!pm->ps->velocity[0] && !pm->ps->velocity[1]) - if (!pm->ps.velocity.x && !pm->ps.velocity.z) - return; - - PM_StepSlideMove( false ); - - //Com_Printf("velocity2 = %1.1f\n", VectorLength(pm->ps->velocity)); - -} - -void PM_UpdateViewAngles( playerMove::playerStruct* const ps, playerMove::playercmd* const cmd ) -{ - short temp; - int i; - - //while(1); - - //if ( ps->pm_type == PM_INTERMISSION || ps->pm_type == PM_SPINTERMISSION) - //return; // no view changes at all - - //if ( ps->pm_type != PM_SPECTATOR && ps->stats[STAT_HEALTH] <= 0 ) - //return; // no view changes at all - - // circularly clamp the angles with deltas - //bprintf("View angles: %i, %i, %i\n", cmd->angles[0], cmd->angles[1], cmd->angles[2]); - for (i = 0 ; i < 3 ; i++) - { - temp = cmd->angles[i];// + ps->delta_angles[i]; - //if ( i == PITCH ) - { - // don't let the player look up or down more than 90 degrees - /*if ( temp > 16000 ) - { - ps->delta_angles[i] = 16000 - cmd->angles[i]; - temp = 16000; - } - else if ( temp < -16000 ) - { - ps->delta_angles[i] = -16000 - cmd->angles[i]; - temp = -16000; - }*/ - } - (&(ps->viewangles.x) )[i] = SHORT2ANGLE(temp); - //cmd->angles[i] += ps->delta_angles[i]; - } - //ps->delta_angles[0] = ps->delta_angles[1] = ps->delta_angles[2] = 0; - -} - -void AngleVectors( const Ogre::Vector3& angles, Ogre::Vector3* const forward, Ogre::Vector3* const right, Ogre::Vector3* const up) -{ - float angle; - static float sr, sp, sy, cr, cp, cy; - // static to help MS compiler fp bugs - - //angle = angles[YAW] * (M_PI*2 / 360); - angle = angles.x * (M_PI * 2.0f / 360.0f); - sp = sinf(angle); - cp = cosf(angle); - - //angle = angles[PITCH] * (M_PI*2 / 360); - angle = angles.y * (-M_PI * 2.0f / 360.0f); - sy = sinf(angle); - cy = cosf(angle); - - //angle = angles[ROLL] * (M_PI*2 / 360); - angle = angles.z * (M_PI * 2.0f / 360.0f); - sr = sinf(angle); - cr = cosf(angle); - - if (forward) - { - forward->x = cp * cy; - forward->z = cp * sy; - forward->y = -sp; - } - if (right) - { - right->x = (-1 * sr * sp * cy + -1 * cr * -sy); - right->z = (-1 * sr * sp * sy + -1 * cr * cy); - right->y = 0.0f;//-1 * sp * cp; - } - if (up) - { - up->x = (cr * sp * cy + -sr * -sy); - up->z = (cr * sp * sy + -sr * cy); - up->y = cr * cp; - } -} - -void PM_GroundTraceMissed() -{ - traceResults trace; - Ogre::Vector3 point; - - if ( pm->ps.groundEntityNum != ENTITYNUM_NONE ) - { - // we just transitioned into freefall - //if ( pm->debugLevel ) - //Com_Printf("%i:lift\n", c_pmove); - - // if they aren't in a jumping animation and the ground is a ways away, force into it - // if we didn't do the trace, the player would be backflipping down staircases - //VectorCopy( pm->ps->origin, point ); - point = pm->ps.origin; - //point[2] -= 64; - point.y -= 64; - - //pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); - //tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, -64.0f, 0.0f), 0, pml.traceObj); - newtrace(&trace, pm->ps.origin, point, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine); - if ( trace.fraction == 1.0 ) - { - if ( pm->cmd.forwardmove >= 0 ) - { - //PM_ForceLegsAnim( LEGS_JUMP ); - //pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; - } - else - { - //PM_ForceLegsAnim( LEGS_JUMPB ); - //pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; - } - } - } - - pm->ps.groundEntityNum = ENTITYNUM_NONE; - pml.groundPlane = false; - pml.walking = false; -} - -static bool PM_CorrectAllSolid(traceResults* const trace) -{ - int i, j, k; - Ogre::Vector3 point; - std::cout << "Correct all solid\n"; - - //if ( pm->debugLevel ) - //Com_Printf("%i:allsolid\n", c_pmove); - //bprintf("allsolid\n"); - - // jitter around - for (i = -1; i <= 1; i++) - { - for (j = -1; j <= 1; j++) - { - for (k = -1; k <= 1; k++) - { - //VectorCopy(pm->ps->origin, point); - point = pm->ps.origin; - - /*point[0] += (float) i; - point[1] += (float) j; - point[2] += (float) k;*/ - point += Ogre::Vector3( (const float)i, (const float)j, (const float)k); - - //pm->trace (trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); - //tracefunc(trace, *(const D3DXVECTOR3* const)&point, *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, 0.0f, 0.0f), 0, pml.traceObj); - newtrace(trace, point, point, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine); - - if ( !trace->allsolid ) - { - /*point[0] = pm->ps->origin[0]; - point[1] = pm->ps->origin[1]; - point[2] = pm->ps->origin[2] - 0.25;*/ - point = pm->ps.origin; - point.y -= 0.25f; - - //pm->trace (trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); - //tracefunc(trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, -0.25f, 0.0f), 0, pml.traceObj); - newtrace(trace, pm->ps.origin, point, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine); - pml.groundTrace = *trace; - return true; - } - } - } - } - - //pm->ps->groundEntityNum = ENTITYNUM_NONE; - pm->ps.groundEntityNum = ENTITYNUM_NONE; - pml.groundPlane = false; - pml.walking = false; - - return false; -} - -static void PM_CrashLand( void ) -{ - float delta; - float dist ; - float vel, acc; - float t; - float a, b, c, den; - - // decide which landing animation to use - /*if ( pm->ps->pm_flags & PMF_BACKWARDS_JUMP ) - PM_ForceLegsAnim( LEGS_LANDB ); - else - PM_ForceLegsAnim( LEGS_LAND ); - - pm->ps->legsTimer = TIMER_LAND;*/ - - // calculate the exact velocity on landing - //dist = pm->ps->origin[2] - pml.previous_origin[2]; - - dist = pm->ps.origin.y - pml.previous_origin.y; - - //vel = pml.previous_velocity[2]; - vel = pml.previous_velocity.y; - - //acc = -pm->ps->gravity; - acc = -pm->ps.gravity; - - a = acc / 2; - b = vel; - c = -dist; - - den = b * b - 4 * a * c; - if ( den < 0 ) - return; - - t = (-b - sqrtf( den ) ) / ( 2 * a ); - - delta = vel + t * acc; - delta = delta * delta * 0.0001f; - - // ducking while falling doubles damage - /*if ( pm->ps->pm_flags & PMF_DUCKED ) - delta *= 2;*/ - if (pm->cmd.upmove < -20) - delta *= 2; - - // never take falling damage if completely underwater - if ( pm->ps.waterlevel == 3 ) - return; - - // reduce falling damage if there is standing water - if ( pm->ps.waterlevel == 2 ) - delta *= 0.25; - if ( pm->ps.waterlevel == 1 ) - delta *= 0.5; - - if ( delta < 1 ) - return; - - if (delta > 60) - printf("Far crashland: %f\n", delta); - else if (delta > 40) - printf("Medium crashland: %f\n", delta); - else if (delta > 4) - printf("Short crashland: %f\n", delta); - - if (delta > 60) - { - /* - static const namestruct healthDamage("Health Damage"); - const SOUN* const soun = SOUN::GetSound(healthDamage); - if (soun) - { - PlaySound2D(soun->soundFilename, soun->soundData->GetVolumeFloat() ); - }*/ - } - - if (delta > 3) // We need at least a short crashland to proc the sound effects: - { - bool splashSound = false; - - if (pm->hasWater) - { - - const float waterHeight = pm->waterHeight; - const float waterHeightSplash = waterHeight + halfExtents.y; - if (pm->ps.origin.y < waterHeightSplash) - { - splashSound = true; - } - - } - - - if (splashSound) - { - //Change this later----------------------------------- - /* - const namestruct ns("DefaultLandWater"); - const SOUN* const soun = SOUN::GetSound(ns); - if (soun) - { - PlaySound2D(soun->soundFilename, soun->soundDatga->GetVolumeFloat() ); - }*/ - } - else - { - //Change this later--------------------------------- - /* - namestruct defaultCreature; - const SNDG* const sndg = SNDG::GetFromMap(defaultCreature, SNDG::land); - if (sndg) - { - const namestruct& SOUNID = sndg->soundID; - const SOUN* const soun = SOUN::GetSound(SOUNID); - if (soun) - { - PlaySound2D(soun->soundFilename, soun->soundData->GetVolumeFloat() ); - } - }*/ - } - } - - // create a local entity event to play the sound - - // SURF_NODAMAGE is used for bounce pads where you don't ever - // want to take damage or play a crunch sound - //if ( !(pml.groundTrace.surfaceFlags & SURF_NODAMAGE) ) - { - /*if ( delta > 60 ) - PM_AddEvent( EV_FALL_FAR ); - else if ( delta > 40 ) - { - // this is a pain grunt, so don't play it if dead - if ( pm->ps->stats[STAT_HEALTH] > 0 ) - PM_AddEvent( EV_FALL_MEDIUM ); - } - else if ( delta > 7 ) - PM_AddEvent( EV_FALL_SHORT ); - else - PM_AddEvent( PM_FootstepForSurface() );*/ - } - - // start footstep cycle over - //pm->ps->bobCycle = 0; -} - -static void PM_GroundTrace( void ) -{ - std::cout << "Ground trace\n"; - Ogre::Vector3 point; - traceResults trace; - - /*point[0] = pm->ps->origin[0]; - point[1] = pm->ps->origin[1]; - point[2] = pm->ps->origin[2] - 0.25;*/ - point = pm->ps.origin; - point.y -= 0.25f; - - //pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); - //tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, -0.25f, 0.0f), 0, pml.traceObj); - newtrace(&trace, pm->ps.origin, point, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine); - pml.groundTrace = trace; - - // do something corrective if the trace starts in a solid... - if ( trace.allsolid ) { - //std::cout << "ALL SOLID\n"; - if ( !PM_CorrectAllSolid(&trace) ){ - //std::cout << "Returning after correct all solid\n"; - return; - } - } - - // if the trace didn't hit anything, we are in free fall - if ( trace.fraction == 1.0 ) - { - PM_GroundTraceMissed(); - pml.groundPlane = false; - pml.walking = false; - return; - } - - // check if getting thrown off the ground - //if ( pm->ps->velocity[2] > 0 && DotProduct( pm->ps->velocity, trace.plane.normal ) > 10 ) - if (pm->ps.velocity.y > 0 && pm->ps.velocity.dotProduct(trace.planenormal) > 10.0f) - { - //if ( pm->debugLevel ) - //Com_Printf("%i:kickoff\n", c_pmove); - - // go into jump animation - /*if ( pm->cmd.forwardmove >= 0 ) - { - PM_ForceLegsAnim( LEGS_JUMP ); - pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; - } - else - { - PM_ForceLegsAnim( LEGS_JUMPB ); - pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; - }*/ - - pm->ps.groundEntityNum = ENTITYNUM_NONE; - pml.groundPlane = false; - pml.walking = false; - return; - } - - // slopes that are too steep will not be considered onground - //if ( trace.plane.normal[2] < MIN_WALK_NORMAL ) - if (trace.planenormal.y < MIN_WALK_NORMAL) - { - //if ( pm->debugLevel ) - //Com_Printf("%i:steep\n", c_pmove); - - // FIXME: if they can't slide down the slope, let them - // walk (sharp crevices) - pm->ps.groundEntityNum = ENTITYNUM_NONE; - pml.groundPlane = true; - pml.walking = false; - return; - } - - pml.groundPlane = true; - pml.walking = true; - - // hitting solid ground will end a waterjump - /*if (pm->ps.pm_flags & PMF_TIME_WATERJUMP) - { - pm->ps->pm_flags &= ~(PMF_TIME_WATERJUMP | PMF_TIME_LAND); - pm->ps->pm_time = 0; - }*/ - - if ( pm->ps.groundEntityNum == ENTITYNUM_NONE ) - { - // just hit the ground - /*if ( pm->debugLevel ) - Com_Printf("%i:Land\n", c_pmove);*/ - //bprintf("Land\n"); - - PM_CrashLand(); - - // don't do landing time if we were just going down a slope - //if ( pml.previous_velocity[2] < -200 ) - if (pml.previous_velocity.y < -200) - { - // don't allow another jump for a little while - //pm->ps->pm_flags |= PMF_TIME_LAND; - pm->ps.pm_time = 250; - } - } - - pm->ps.groundEntityNum = trace.entityNum; - - // don't reset the z velocity for slopes -// pm->ps->velocity[2] = 0; - - //PM_AddTouchEnt( trace.entityNum ); -} - -static void PM_AirMove() -{ - //int i; - Ogre::Vector3 wishvel; - float fmove, smove; - Ogre::Vector3 wishdir; - float wishspeed; - float scale; - playerMove::playercmd cmd; - - PM_Friction(); - - fmove = pm->cmd.forwardmove; - smove = pm->cmd.rightmove; - - cmd = pm->cmd; - scale = PM_CmdScale( &cmd ); - - // set the movementDir so clients can rotate the legs for strafing - //PM_SetMovementDir(); - - // project moves down to flat plane - //pml.forward[2] = 0; - pml.forward.y = 0; - //pml.right[2] = 0; - pml.right.y = 0; - //VectorNormalize (pml.forward); - pml.forward = Ogre::Vector3(pml.forward.normalise()); - pml.right = Ogre::Vector3(pml.right.normalise()); - //VectorNormalize (pml.right); - - //for ( i = 0 ; i < 2 ; i++ ) - //wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove; - wishvel = pml.forward * fmove + pml.right * smove; - - //wishvel[2] = 0; - wishvel.y = 0; - - //VectorCopy (wishvel, wishdir); - wishdir = wishvel; - //wishspeed = VectorNormalize(wishdir); - wishspeed = VectorNormalize(wishdir); - - wishspeed *= scale; - - // not on ground, so little effect on velocity - PM_Accelerate (wishdir, wishspeed, pm_airaccelerate); - - // we may have a ground plane that is very steep, even - // though we don't have a groundentity - // slide along the steep plane - if ( pml.groundPlane ) - PM_ClipVelocity (pm->ps.velocity, pml.groundTrace.planenormal, pm->ps.velocity, OVERCLIP ); - -/*#if 0 - //ZOID: If we are on the grapple, try stair-stepping - //this allows a player to use the grapple to pull himself - //over a ledge - if (pm->ps->pm_flags & PMF_GRAPPLE_PULL) - PM_StepSlideMove ( qtrue ); - else - PM_SlideMove ( qtrue ); -#endif*/ - - /*bprintf("%i ", */PM_StepSlideMove ( true )/* )*/; -} - -static void PM_NoclipMove( void ) -{ - float speed, drop, friction, control, newspeed; -// int i; - Ogre::Vector3 wishvel; - float fmove, smove; - Ogre::Vector3 wishdir; - float wishspeed; - float scale; - - //pm->ps->viewheight = DEFAULT_VIEWHEIGHT; - - // friction - - //speed = VectorLength (pm->ps->velocity); - speed = pm->ps.velocity.length(); - if (speed < 1) - //VectorCopy (vec3_origin, pm->ps->velocity); - pm->ps.velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f); - else - { - drop = 0; - - friction = pm_friction * 1.5f; // extra friction - control = speed < pm_stopspeed ? pm_stopspeed : speed; - drop += control * friction * pml.frametime; - - // scale the velocity - newspeed = speed - drop; - if (newspeed < 0) - newspeed = 0; - newspeed /= speed; - - //VectorScale (pm->ps->velocity, newspeed, pm->ps->velocity); - pm->ps.velocity = pm->ps.velocity * newspeed; - } - - // accelerate - scale = PM_CmdScale( &pm->cmd ); - - fmove = pm->cmd.forwardmove; - smove = pm->cmd.rightmove; - - //for (i=0 ; i<3 ; i++) - //wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove; - wishvel = pml.forward * fmove + pml.right * smove; - //wishvel[2] += pm->cmd.upmove; - wishvel.y += pm->cmd.upmove; - - //VectorCopy (wishvel, wishdir); - wishdir = wishvel; - wishspeed = VectorNormalize(wishdir); - wishspeed *= scale; - - PM_Accelerate( wishdir, wishspeed, pm_accelerate ); - - // move - //VectorMA (pm->ps->origin, pml.frametime, pm->ps->velocity, pm->ps->origin); - pm->ps.origin = pm->ps.origin + pm->ps.velocity * pml.frametime; -} - -static void PM_DropTimers( void ) -{ - // drop misc timing counter - if ( pm->ps.pm_time ) - { - if ( pml.msec >= pm->ps.pm_time ) - { - //pm->ps->pm_flags &= ~PMF_ALL_TIMES; - pm->ps.pm_time = 0; - } - else - pm->ps.pm_time -= pml.msec; - } - - //bprintf("Time: %i\n", pm->ps.pm_time); - - // drop animation counter - /*if ( pm->ps->legsTimer > 0 ) - { - pm->ps->legsTimer -= pml.msec; - if ( pm->ps->legsTimer < 0 ) - pm->ps->legsTimer = 0; - } - - if ( pm->ps->torsoTimer > 0 ) - { - pm->ps->torsoTimer -= pml.msec; - if ( pm->ps->torsoTimer < 0 ) - pm->ps->torsoTimer = 0; - }*/ -} - -static void PM_FlyMove( void ) -{ - //int i; - Ogre::Vector3 wishvel; - float wishspeed; - Ogre::Vector3 wishdir; - float scale; - - // normal slowdown - PM_Friction (); - - scale = PM_CmdScale( &pm->cmd ); - // - // user intentions - // - if ( !scale ) - { - /*wishvel[0] = 0; - wishvel[1] = 0; - wishvel[2] = 0;*/ - wishvel = Ogre::Vector3(0,0,0); - } - else - { - //for (i=0 ; i<3 ; i++) - //wishvel[i] = scale * pml.forward[i]*pm->cmd.forwardmove + scale * pml.right[i]*pm->cmd.rightmove; - wishvel = pml.forward * scale * pm->cmd.forwardmove + pml.right * scale * pm->cmd.rightmove; - - //wishvel[2] += scale * pm->cmd.upmove; - wishvel.y += /*6.35f * */pm->cmd.upmove * scale; - } - - //VectorCopy (wishvel, wishdir); - wishdir = wishvel; - - //wishspeed = VectorNormalize(wishdir); - wishspeed = VectorNormalize(wishdir); - - PM_Accelerate (wishdir, wishspeed, pm_flyaccelerate); - - PM_StepSlideMove( false ); -} - - -void PM_SetWaterLevel( playerMove* const pm ) -{ - Ogre::Vector3 point; - //int cont; - int sample1; - int sample2; - - // - // get waterlevel, accounting for ducking - // - - pm->ps.waterlevel = WL_DRYLAND; - pm->ps.watertype = 0; - - /*point[0] = pm->ps->origin[0]; - point[1] = pm->ps->origin[1]; - point[2] = pm->ps->origin[2] + MINS_Z + 1; */ - point.x = pm->ps.origin.x; - point.y = pm->ps.origin.y + MINS_Z + 1; - point.z = pm->ps.origin.z; - - //cont = pm->pointcontents( point, pm->ps->clientNum ); - bool checkWater = (pml.hasWater && pml.waterHeight > point.y); - //if ( cont & MASK_WATER ) - if ( checkWater) - { - sample2 = /*pm->ps.viewheight*/DEFAULT_VIEWHEIGHT - MINS_Z; - sample1 = sample2 / 2; - - pm->ps.watertype = CONTENTS_WATER;//cont; - pm->ps.waterlevel = WL_ANKLE; - //point[2] = pm->ps->origin[2] + MINS_Z + sample1; - point.y = pm->ps.origin.y + MINS_Z + sample1; - //cont = pm->pointcontents (point, pm->ps->clientNum ); - //if ( cont & MASK_WATER ) - if (checkWater) - { - pm->ps.waterlevel = WL_WAIST; - //point[2] = pm->ps->origin[2] + MINS_Z + sample2; - point.y = pm->ps.origin.y + MINS_Z + sample2; - //cont = pm->pointcontents (point, pm->ps->clientNum ); - //if ( cont & MASK_WATER ) - if (checkWater ) - pm->ps.waterlevel = WL_UNDERWATER; - } - } -} - -void PmoveSingle (playerMove* const pmove) -{ - std::cout << "Pmove single\n"; - //pm = pmove; - - // Aedra doesn't support Q3-style VM traps D: //while(1); - - // this counter lets us debug movement problems with a journal - // by setting a conditional breakpoint fot the previous frame - //c_pmove++; - - // clear results - //pm->numtouch = 0; - pm->ps.watertype = 0; - pm->ps.waterlevel = WL_DRYLAND; - - //if ( pm->ps->stats[STAT_HEALTH] <= 0 ) - //pm->tracemask &= ~CONTENTS_BODY; // corpses can fly through bodies - - - // make sure walking button is clear if they are running, to avoid - // proxy no-footsteps cheats - //if ( abs( pm->cmd.forwardmove ) > 64 || abs( pm->cmd.rightmove ) > 64 ) - //pm->cmd.buttons &= ~BUTTON_WALKING; - - - // set the talk balloon flag - //if ( pm->cmd.buttons & BUTTON_TALK ) - //pm->ps->eFlags |= EF_TALK; - //else - //pm->ps->eFlags &= ~EF_TALK; - - // set the firing flag for continuous beam weapons - /*if ( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION - && ( pm->cmd.buttons & BUTTON_ATTACK ) && pm->ps->ammo[ pm->ps->weapon ] ) - pm->ps->eFlags |= EF_FIRING; - else - pm->ps->eFlags &= ~EF_FIRING;*/ - - // clear the respawned flag if attack and use are cleared - /*if ( pm->ps->stats[STAT_HEALTH] > 0 && - !( pm->cmd.buttons & (BUTTON_ATTACK | BUTTON_USE_HOLDABLE) ) ) - pm->ps->pm_flags &= ~PMF_RESPAWNED;*/ - - // if talk button is down, dissallow all other input - // this is to prevent any possible intercept proxy from - // adding fake talk balloons - /*if ( pmove->cmd.buttons & BUTTON_TALK ) - { - // keep the talk button set tho for when the cmd.serverTime > 66 msec - // and the same cmd is used multiple times in Pmove - pmove->cmd.buttons = BUTTON_TALK; - pmove->cmd.forwardmove = 0; - pmove->cmd.rightmove = 0; - pmove->cmd.upmove = 0; - }*/ - - // clear all pmove local vars - memset (&pml, 0, sizeof(pml) ); - - // Aedra-specific code: - //pml.scene = global_lastscene; - - - // End Aedra-specific code - pml.hasWater = pmove->hasWater; - pml.isInterior = pmove->isInterior; - pml.waterHeight = pmove->waterHeight; -#ifdef _DEBUG - if (!pml.traceObj) - __debugbreak(); - - if (!pml.traceObj->incellptr) - __debugbreak(); -#endif - - // determine the time - pml.msec = pmove->cmd.serverTime - pm->ps.commandTime; - if ( pml.msec < 1 ) - pml.msec = 1; - else if ( pml.msec > 200 ) - pml.msec = 200; - - //pm->ps->commandTime = pmove->cmd.serverTime; - - // Commented out as a hack - pm->ps.commandTime = pmove->cmd.serverTime; - - // Handle state change procs: - if (pm->cmd.activating != pm->cmd.lastActivatingState) - { - if (!pm->cmd.lastActivatingState && pm->cmd.activating) - pm->cmd.procActivating = playerMove::playercmd::KEYDOWN; - else - pm->cmd.procActivating = playerMove::playercmd::KEYUP; - } - else - { - pm->cmd.procActivating = playerMove::playercmd::NO_CHANGE; - } - pm->cmd.lastActivatingState = pm->cmd.activating; - - if (pm->cmd.dropping != pm->cmd.lastDroppingState) - { - if (!pm->cmd.lastDroppingState && pm->cmd.dropping) - pm->cmd.procDropping = playerMove::playercmd::KEYDOWN; - else - pm->cmd.procDropping = playerMove::playercmd::KEYUP; - } - else - { - pm->cmd.procDropping = playerMove::playercmd::NO_CHANGE; - } - pm->cmd.lastDroppingState = pm->cmd.dropping; - - // save old org in case we get stuck - //VectorCopy (pm->ps->origin, pml.previous_origin); - pml.previous_origin = pm->ps.origin; - - // Copy over the lastframe origin - pmove->ps.lastframe_origin = pmove->ps.origin; - - //pmove->ps.lastframe_origin = pmove->ps.origin; - - // save old velocity for crashlanding - //VectorCopy (pm->ps->velocity, pml.previous_velocity); - pml.previous_velocity = pm->ps.velocity; - - pml.frametime = pml.msec * 0.001f; - - // update the viewangles - //PM_UpdateViewAngles( &(pm->ps), &(pm->cmd) ); - - AngleVectors (pm->ps.viewangles, &(pml.forward), &(pml.right), &(pml.up) ); - - //if ( pm->cmd.upmove < 10 ) - // not holding jump - //pm->ps->pm_flags &= ~PMF_JUMP_HELD; - - // decide if backpedaling animations should be used - /*if ( pm->cmd.forwardmove < 0 ) - pm->ps->pm_flags |= PMF_BACKWARDS_RUN; - else if ( pm->cmd.forwardmove > 0 || ( pm->cmd.forwardmove == 0 && pm->cmd.rightmove ) ) - pm->ps->pm_flags &= ~PMF_BACKWARDS_RUN;*/ - - /*if ( pm->ps->pm_type >= PM_DEAD ) - { - pm->cmd.forwardmove = 0; - pm->cmd.rightmove = 0; - pm->cmd.upmove = 0; - }*/ - - if ( pm->ps.move_type == PM_SPECTATOR ) - { - std::cout << "SPECTATOR\n"; - //PM_CheckDuck (); - PM_FlyMove (); - PM_DropTimers (); - return; - } - - if ( pm->ps.move_type == PM_NOCLIP ) - { - std::cout << "NOCLIP\n"; - PM_NoclipMove (); - PM_DropTimers (); - return; - } - - if (pm->ps.move_type == PM_FREEZE){ - std::cout << "FREEZE\n"; - return; // no movement at all - - } - - if ( pm->ps.move_type == PM_INTERMISSION || pm->ps.move_type == PM_SPINTERMISSION){ - std::cout << "INTERMISSION\n"; - return; // no movement at all - } - - // set watertype, and waterlevel - PM_SetWaterLevel(pmove); - pml.previous_waterlevel = pmove->ps.waterlevel; - - // set mins, maxs, and viewheight - //PM_CheckDuck (); - - // set groundentity - PM_GroundTrace(); - - /*if ( pm->ps->pm_type == PM_DEAD ) - PM_DeadMove (); - - PM_DropTimers();*/ - - PM_DropTimers(); - -/*#ifdef MISSIONPACK - if ( pm->ps->powerups[PW_INVULNERABILITY] ) { - PM_InvulnerabilityMove(); - } else -#endif*/ - /*if ( pm->ps->powerups[PW_FLIGHT] ) - // flight powerup doesn't allow jump and has different friction - PM_FlyMove(); - else if (pm->ps->pm_flags & PMF_GRAPPLE_PULL) - { - PM_GrappleMove(); - // We can wiggle a bit - PM_AirMove(); - } - else if (pm->ps->pm_flags & PMF_TIME_WATERJUMP) - PM_WaterJumpMove();*/ - if ( pmove->ps.waterlevel > 1 ) - // swimming - PM_WaterMove(pmove); - else if ( pml.walking ) - { - std::cout << "WALKING\n"; - // walking on ground - PM_WalkMove(pmove); - //bprintf("WalkMove\n"); - } - else - { - // airborne - std::cout << "AIRMOVE\n"; - PM_AirMove(); - //bprintf("AirMove\n"); - } - - //PM_Animate(); - - // set groundentity, watertype, and waterlevel - PM_GroundTrace(); - PM_SetWaterLevel(pmove); - - // weapons - /*PM_Weapon(); - - // torso animation - PM_TorsoAnimation(); - - // footstep events / legs animations - PM_Footsteps(); - - // entering / leaving water splashes - PM_WaterEvents(); - - // snap some parts of playerstate to save network bandwidth - trap_SnapVector( pm->ps->velocity );*/ -} - -void Ext_UpdateViewAngles(playerMove* const pm) -{ - playerMove::playerStruct* const ps = &(pm->ps); - playerMove::playercmd* const cmd = &(pm->cmd); - PM_UpdateViewAngles(ps, cmd); -} - -void Pmove (playerMove* const pmove) -{ - pm = pmove; - - int finalTime; - - finalTime = pmove->cmd.serverTime; - - pmove->ps.commandTime = 40; - - if ( finalTime < pmove->ps.commandTime ) - return; // should not happen - - if ( finalTime > pmove->ps.commandTime + 1000 ) - pmove->ps.commandTime = finalTime - 1000; - - pmove->ps.pmove_framecount = (pmove->ps.pmove_framecount + 1) & ( (1 << PS_PMOVEFRAMECOUNTBITS) - 1); - - // chop the move up if it is too long, to prevent framerate - // dependent behavior - while ( pmove->ps.commandTime != finalTime ) - { - int msec; - - msec = finalTime - pmove->ps.commandTime; - - if ( pmove->pmove_fixed ) - if ( msec > pmove->pmove_msec ) - msec = pmove->pmove_msec; - else - if ( msec > 66 ) - msec = 66; - - pmove->cmd.serverTime = pmove->ps.commandTime + msec; - - if (pmove->isInterior) - { - PmoveSingle( pmove ); - } - else - { - PmoveSingle( pmove ); - /* - std::map::const_iterator it = ExtCellLookup.find(PositionToCell(pmove->ps.origin) ); - if (it != ExtCellLookup.end() ) - { - pmove->traceObj->incellptr = it->second; - }*/ - } - - //if ( pmove->ps->pm_flags & PMF_JUMP_HELD ) - //pmove->cmd.upmove = 20; - } - - //pmove->ps.last_compute_time = GetTimeQPC(); - //pmove->ps.lerp_multiplier = (pmove->ps.origin - pmove->ps.lastframe_origin);// * (1.000 / 31.0); - - //PM_CheckStuck(); - -} - - diff --git a/libs/openengine/bullet/pmove.h b/libs/openengine/bullet/pmove.h deleted file mode 100644 index e90cc3b35..000000000 --- a/libs/openengine/bullet/pmove.h +++ /dev/null @@ -1,197 +0,0 @@ -#ifndef OENGINE_BULLET_PMOVE_H -#define OENGINE_BULLET_PMOVE_H -/* -This source file is a *modified* version of various header files from the Quake 3 Arena source code, -which was released under the GNU GPL (v2) in 2005. -Quake 3 Arena is copyright (C) 1999-2005 Id Software, Inc. -*/ - -#include -#include -#include -#include "trace.h" -#include "physic.hpp" - - -//#include "GameMath.h" -//#include "GameTime.h" - -// Forwards-declare it! - -/*#ifndef COMPILING_PMOVE -#include "Scene.h" -extern SceneInstance* global_lastscene; -#endif*/ - -static const Ogre::Vector3 halfExtents(14.64f * 2, 14.24f * 2, 33.25f * 2); - -#define MAX_CLIP_PLANES 5 -#define OVERCLIP 1.001f -//#define STEPSIZE 18 // 18 is way too much -#define STEPSIZE (18 / 2) -#ifndef M_PI - #define M_PI 3.14159265358979323846f -#endif -#define YAW 0 -#define PITCH /*1*/2 -#define ROLL /*2*/1 -#define SHORT2ANGLE(x) ( (x) * (360.0f / 65536.0f) ) -#define ANGLE2SHORT(x) ( (const short)( (x) / (360.0f / 65536.0f) ) ) -#define GENTITYNUM_BITS 10 // don't need to send any more -#define MAX_GENTITIES (1 << GENTITYNUM_BITS) -#define ENTITYNUM_NONE (MAX_GENTITIES - 1) -#define ENTITYNUM_WORLD (MAX_GENTITIES - 2) -#define MIN_WALK_NORMAL 0.7f // can't walk on very steep slopes -#define JUMP_VELOCITY (270 * 1) -#define PS_PMOVEFRAMECOUNTBITS 6 -#define MINS_Z -24 -#define DEFAULT_VIEWHEIGHT 26 -#define CROUCH_VIEWHEIGHT 12 -#define DEAD_VIEWHEIGHT (-16) -#define CONTENTS_SOLID 1 // an eye is never valid in a solid -#define CONTENTS_LAVA 8 -#define CONTENTS_SLIME 16 -#define CONTENTS_WATER 32 -#define CONTENTS_FOG 64 -static const float pm_accelerate = 10.0f; -static const float pm_stopspeed = 100.0f; -static const float pm_friction = 6.0f; -static const float pm_flightfriction = 3.0f; -static const float pm_waterfriction = 1.0f; -static const float pm_airaccelerate = 1.0f; -static const float pm_swimScale = 0.50f; -static const float pm_duckScale = 0.25f; -static const float pm_flyaccelerate = 8.0f; -static const float pm_wateraccelerate = 4.0f; - -enum pmtype_t : unsigned char -{ - PM_NORMAL, // can accelerate and turn - PM_NOCLIP, // noclip movement - PM_SPECTATOR, // still run into walls - PM_DEAD, // no acceleration or turning, but free falling - PM_FREEZE, // stuck in place with no control - PM_INTERMISSION, // no movement or status bar - PM_SPINTERMISSION // no movement or status bar -}; - -enum waterlevel_t : unsigned char -{ - WL_DRYLAND = 0, - WL_ANKLE, - WL_WAIST, - WL_UNDERWATER -}; - - -//#include "bprintf.h" - -struct playerMove -{ - struct playerStruct - { - playerStruct() : gravity(50.0f), speed(320.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NORMAL), pm_time(0) - { - origin = Ogre::Vector3(733.164f,1000.0f, 839.432f); - velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f); - - viewangles = Ogre::Vector3(0.0f, 0.0f, 0.0f); - - delta_angles[0] = delta_angles[1] = delta_angles[2] = 0; - - lastframe_origin.x = lastframe_origin.y = lastframe_origin.z = 0; - lerp_multiplier.x = lerp_multiplier.y = lerp_multiplier.z = 0; - } - - inline void SpeedUp(void) - { - printf("speed up to: %f\n", speed); - speed *= 1.25f; - } - - inline void SpeedDown(void) - { - printf("speed down to %f\n", speed); - speed /= 1.25f; - } - - Ogre::Vector3 velocity; - Ogre::Vector3 origin; - float gravity; // default = 800 - float speed; // default = 320 - - int commandTime; // the time at which this command was issued (in milliseconds) - - int pm_time; - - Ogre::Vector3 viewangles; - - int groundEntityNum; - - int pmove_framecount; - - int watertype; - waterlevel_t waterlevel; - - signed short delta_angles[3]; - - pmtype_t move_type; - - float last_compute_time; - Ogre::Vector3 lastframe_origin; - Ogre::Vector3 lerp_multiplier; - } ps; - - struct playercmd - { - enum CMDstateChange - { - NO_CHANGE, - KEYDOWN, - KEYUP - }; - - playercmd() : forwardmove(0), rightmove(0), upmove(0), serverTime(50), ducking(false), - activating(false), lastActivatingState(false), procActivating(NO_CHANGE), - dropping(false), lastDroppingState(false), procDropping(NO_CHANGE) - { - angles[0] = angles[1] = angles[2] = 0; - } - - int serverTime; - - short angles[3]; - - signed char forwardmove; - signed char rightmove; - signed char upmove; - - bool ducking; - bool activating; // if the user is holding down the activate button - bool dropping; // if the user is dropping an item - - bool lastActivatingState; - bool lastDroppingState; - - CMDstateChange procActivating; - CMDstateChange procDropping; - } cmd; - - playerMove() : msec(50), pmove_fixed(false), pmove_msec(50), waterHeight(0), isInterior(true), hasWater(false) - { - } - - int msec; - int pmove_msec; - bool pmove_fixed; - int waterHeight; - bool hasWater; - bool isInterior; - //Object* traceObj; - OEngine::Physic::PhysicEngine* mEngine; -}; - -void Pmove (playerMove* const pmove); -void Ext_UpdateViewAngles(playerMove* const pm); -void AngleVectors( const Ogre::Vector3& angles, Ogre::Vector3* const forward, Ogre::Vector3* const right, Ogre::Vector3* const up) ; -#endif diff --git a/libs/openengine/bullet/trace.cpp b/libs/openengine/bullet/trace.cpp deleted file mode 100644 index 49e12064e..000000000 --- a/libs/openengine/bullet/trace.cpp +++ /dev/null @@ -1,188 +0,0 @@ - -#include "trace.h" - - - -#include - - - - - - - -void newtrace(traceResults* const results, const Ogre::Vector3& start, const Ogre::Vector3& end, const Ogre::Vector3& BBHalfExtents, const float rotation, bool isInterior, OEngine::Physic::PhysicEngine* enginePass) //Traceobj was a Aedra Object -{ - - //if (!traceobj) - // return; - - //if (!traceobj->incellptr) - // return; - - const Ogre::Vector3 rayDir = end - start; - - // Nudge starting point backwards - //const Position3D nudgestart = start + (rayDir * -0.1f); // by 10% (isn't that too much?) - //const Position3D nudgestart = start; - - NewPhysTraceResults out; - //std::cout << "Starting trace\n"; - Ogre::Vector3 startReplace = Ogre::Vector3(650,950, 45); - Ogre::Vector3 endReplace = startReplace; - endReplace.y -= .25; - - const bool hasHit = NewPhysicsTrace(&out, start, end, BBHalfExtents, Ogre::Vector3(0.0f, rotation, 0.0f), isInterior, enginePass); - if(hasHit) - std::cout << "Has hit\n"; - if (out.fraction < 0.001f) - results->startsolid = true; - else - results->startsolid = false; - - - //results->allsolid = out.startSolid; - - // If outside and underground, we're solid - /*if (isInterior) - { - const Ogre::Vector3 height = GetGroundPosition(start, CellCoords(traceCell->data->gridX, traceCell->data->gridY) ); - if (start.yPos - height.yPos < (-2.0f * BBHalfExtents.yPos) ) - { - results->allsolid = true; - } - else - results->allsolid = false; - }*/ - - // If inside and out of the tree, we're solid - //else - //{ - results->allsolid = out.startSolid; - //std::cout << "allsolid" << results->allsolid << "\n"; - //} - - if (!hasHit) - { - results->endpos = end; - results->planenormal = Ogre::Vector3(0.0f, 1.0f, 0.0f); - results->entityNum = ENTITYNUM_NONE; - results->fraction = 1.0f; - } - else - { - results->fraction = out.fraction; - results->planenormal = out.hitNormal; - results->endpos = rayDir * results->fraction + start; - results->entityNum = ENTITYNUM_WORLD; - /*bprintf("Start: (%f, %f, %f) End: (%f, %f, %f) TraceDir: (%f, %f, %f) HitNormal: (%f, %f, %f) Fraction: %f Hitpos: (%f, %f, %f) CompensatedHitpos: (%f, %f, %f)\n", - start.xPos, start.yPos, start.zPos, - end.xPos, end.yPos, end.zPos, - rayDir.xPos, rayDir.yPos, rayDir.zPos, - results->planenormal.xPos, results->planenormal.yPos, results->planenormal.zPos, results->fraction, - out.endPos.xPos, out.endPos.yPos, out.endPos.zPos, - results->endpos.xPos, results->endpos.yPos, results->endpos.zPos);*/ - } -} - - - -template -const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3& start, const Ogre::Vector3& end, - const Ogre::Vector3& BBHalfExtents, const Ogre::Vector3& rotation, bool isInterior, OEngine::Physic::PhysicEngine* enginePass) -{ - //if (!traceobj->incellptr) - // return false; - //if(enginePass->dynamicsWorld->getCollisionObjectArray().at(60)->getCollisionShape()->isConvex()) - // std::cout << "It's convex\n"; - - - - const btVector3 btstart(start.x, start.y, start.z); - const btVector3 btend(end.x, end.y, end.z); - const btQuaternion btrot(rotation.y, rotation.x, rotation.z); - - const btBoxShape newshape(btVector3(BBHalfExtents.x, BBHalfExtents.y, BBHalfExtents.z)); - const btTransform from(btrot, btstart); - const btTransform to(btrot, btend); - float x = from.getOrigin().getX(); - float y = from.getOrigin().getY(); - float z = from.getOrigin().getZ(); - float x2 = to.getOrigin().getX(); - float y2 = to.getOrigin().getY(); - float z2 = to.getOrigin().getZ(); - - std::cout << "BtFrom: " << x << "," << y << "," << z << "\n"; - std::cout << "BtTo: " << x2 << "," << y2 << "," << z2 << "\n"; - //std::cout << "BtTo: " << to.getOrigin().getX() << "," << to.getOrigin().getY() << "," << to.getOrigin().getZ() << "\n"; - - - btCollisionWorld::ClosestConvexResultCallback - newTraceCallback(btstart, btend); - - newTraceCallback.m_collisionFilterMask = (traceType == collisionWorldTrace) ? Only_Collision : Only_Pickup; - - - enginePass->dynamicsWorld->convexSweepTest(&newshape, from, to, newTraceCallback); - //newTraceCallback. - - - //std::cout << "NUM: " << enginePass->dynamicsWorld->getNumCollisionObjects() << "\n"; - - // Copy the hit data over to our trace results struct: - out->fraction = newTraceCallback.m_closestHitFraction; - - Ogre::Vector3& outhitnormal = out->hitNormal; - const btVector3& tracehitnormal = newTraceCallback.m_hitNormalWorld; - - outhitnormal.x = tracehitnormal.x(); - outhitnormal.y = tracehitnormal.y(); - outhitnormal.z = tracehitnormal.z(); - - Ogre::Vector3& outhitpos = out->endPos; - const btVector3& tracehitpos = newTraceCallback.m_hitPointWorld; - - outhitpos.x = tracehitpos.x(); - outhitpos.y = tracehitpos.y(); - outhitpos.z= tracehitpos.z(); - - // StartSolid test: - { - out->startSolid = false; - //btCollisionObject collision; - //collision.setCollisionShape(const_cast(&newshape) ); - - //CustomContactCallback crb; - - //world.world->contactTest(&collision, crb); - //out->startSolid = crb.hit; - - // If outside and underground, we're solid - if (!isInterior) //Check if we are interior - { - } - - // If inside and out of the tree, we're solid - else - { - btVector3 aabbMin, aabbMax; - enginePass->broadphase->getBroadphaseAabb(aabbMin, aabbMax); - //std::cout << "AABBMIN" << aabbMin.getX() <<"," <startSolid = false; - } - } - } - - const bool hasHit = newTraceCallback.hasHit(); - - if(hasHit) - std::cout << "HIT\n"; - - - return hasHit; -} From ca4de0606ea0a4b57b8b718229768d33019cd7e5 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 4 Apr 2012 23:23:24 -0400 Subject: [PATCH 009/109] Some planning --- apps/openmw/mwrender/npcanimation.hpp | 34 ++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index e2071957c..e524878cc 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -15,7 +15,39 @@ namespace MWRender{ class NpcAnimation: public Animation{ - +private: + + int mStateID; + //Free Parts + Ogre::Entity* chest; std::vector* chestShapes; + Ogre::Entity* skirt; std::vector* skirtShapes; + Ogre::Entity* rhand; std::vector* rhandShapes; + Ogre::Entity* lhand; std::vector* lhandShapes; + Ogre::Entity* tail; std::vector* tailShapes; + Ogre::Entity* lBeastFoot; std::vector* lBeastFootShapes; + Ogre::Entity* rBeastFoot; std::vector* rBeastFootShapes; + + //Bounded Parts + Ogre::Entity* lclavicle; + Ogre::Entity* rclavicle; + Ogre::Entity* rupperArm; + Ogre::Entity* lupperArm; + Ogre::Entity* rUpperLeg; + Ogre::Entity* lUpperLeg; + Ogre::Entity* lForearm; + Ogre::Entity* rForearm; + Ogre::Entity* lWrist; + Ogre::Entity* rWrist; + Ogre::Entity* rKnee; + Ogre::Entity* lKnee; + Ogre::Entity* neck; + Ogre::Entity* rAnkle; + Ogre::Entity* lAnkle; + Ogre::Entity* groin; + Ogre::Entity* lfoot; + Ogre::Entity* rfoot; + Ogre::Entity* hair; + Ogre::Entity* head; public: From ebab98a8a0f919049a6fd7c2997387c29f580be0 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 7 Apr 2012 22:02:20 -0400 Subject: [PATCH 010/109] Restructuring things --- CMakeLists.txt | 5 +- apps/openmw/mwclass/npc.cpp | 5 +- apps/openmw/mwrender/actors.cpp | 4 +- apps/openmw/mwrender/actors.hpp | 2 +- apps/openmw/mwrender/animation.cpp | 11 +- apps/openmw/mwrender/animation.hpp | 4 +- apps/openmw/mwrender/npcanimation.cpp | 182 ++++++++++++++------------ apps/openmw/mwrender/npcanimation.hpp | 21 ++- 8 files changed, 121 insertions(+), 113 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce5d84684..60eadc49a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,10 +114,7 @@ set(OENGINE_BULLET ${LIBDIR}/openengine/bullet/physic.hpp ${LIBDIR}/openengine/bullet/BulletShapeLoader.cpp ${LIBDIR}/openengine/bullet/BulletShapeLoader.h - ${LIBDIR}/openengine/bullet/pmove.h - ${LIBDIR}/openengine/bullet/pmove.cpp - ${LIBDIR}/openengine/bullet/trace.h - ${LIBDIR}/openengine/bullet/trace.cpp + ) set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_BULLET}) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 94bcbb31f..c78a7501f 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -93,8 +93,9 @@ namespace MWClass void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - std::cout << "Inserting NPC\n"; - renderingInterface.getActors().insertNPC(ptr); + + + renderingInterface.getActors().insertNPC(ptr, getInventoryStore(ptr)); } diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index 6eb4a182b..5034e72b3 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -20,10 +20,10 @@ Actors::~Actors(){ void Actors::setMwRoot(Ogre::SceneNode* root){ mMwRoot = root; } -void Actors::insertNPC(const MWWorld::Ptr& ptr){ +void Actors::insertNPC(const MWWorld::Ptr& ptr, MWWorld::InventoryStore& inv){ insertBegin(ptr, true, true); - NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mEnvironment, mRend); + NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mEnvironment, mRend, inv); mAllActors[ptr] = anim; } diff --git a/apps/openmw/mwrender/actors.hpp b/apps/openmw/mwrender/actors.hpp index d49c6e0f8..66c98c541 100644 --- a/apps/openmw/mwrender/actors.hpp +++ b/apps/openmw/mwrender/actors.hpp @@ -34,7 +34,7 @@ namespace MWRender{ void setMwRoot(Ogre::SceneNode* root); void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); void insertCreature (const MWWorld::Ptr& ptr); - void insertNPC(const MWWorld::Ptr& ptr); + void insertNPC(const MWWorld::Ptr& ptr, MWWorld::InventoryStore& inv); bool deleteObject (const MWWorld::Ptr& ptr); ///< \return found? diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index fb710443b..d0019154e 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -9,7 +9,6 @@ namespace MWRender{ , mRend(_rend) , mEnvironment(_env) , vecRotPos() - , shapeparts() , time(0.0f) , startTime(0.0f) , stopTime(0.0f) @@ -19,7 +18,6 @@ namespace MWRender{ , shapeNumber(0) , shapeIndexI() , shapes(NULL) - , entityparts() , transformations(NULL) , textmappings(NULL) , base(NULL) @@ -430,14 +428,7 @@ namespace MWRender{ //base->_updateAnimation(); //base->_notifyMoved(); - for(unsigned int i = 0; i < entityparts.size(); i++){ - //Ogre::SkeletonInstance* skel = entityparts[i]->getSkeleton(); - - //Ogre::Bone* b = skel->getRootBone(); - //b->setOrientation(Ogre::Real(.3),Ogre::Real(.3),Ogre::Real(.3), Ogre::Real(.3));//This is a trick - - //entityparts[i]->getAllAnimationStates()->_notifyDirty(); - } + std::vector::iterator iter; diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 7692c7128..98f0e7487 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -31,7 +31,7 @@ class Animation{ - std::vector* > shapeparts; //All the NiTriShape data that we need for animating an npc + float time; float startTime; @@ -48,7 +48,7 @@ class Animation{ //Ogre::SkeletonInstance* skel; std::vector* shapes; //All the NiTriShapeData for a creature - std::vector entityparts; + std::vector* transformations; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index a4fd15b74..30c28bb79 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -2,6 +2,7 @@ #include "../mwworld/world.hpp" + using namespace Ogre; using namespace NifOgre; namespace MWRender{ @@ -10,11 +11,12 @@ NpcAnimation::~NpcAnimation(){ } -NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){ +NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv){ ESMS::LiveCellRef *ref = ptr.get(); - - + Ogre::Entity* blank = 0; + std::vector* blankshape = 0; + chest = std::make_pair(blank, blankshape); //Part selection on last character of the file string // " Tri Chest // * Tri Tail @@ -95,85 +97,85 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O std::string hairModel = "meshes\\" + mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; - const ESM::BodyPart *chest = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); + const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); const ESM::BodyPart *upperleg = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); - const ESM::BodyPart *groin = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); + const ESM::BodyPart *groinpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); const ESM::BodyPart *arml = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); //We need two - const ESM::BodyPart *neck = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck"); + const ESM::BodyPart *neckpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck"); const ESM::BodyPart *knee = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); const ESM::BodyPart *ankle = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); const ESM::BodyPart *foot = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); - const ESM::BodyPart *feet = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); - const ESM::BodyPart *tail = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); - const ESM::BodyPart *wristl = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); //We need two - const ESM::BodyPart *forearml = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); //We need two - const ESM::BodyPart *handl = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand"); //We need two - const ESM::BodyPart *hair = mEnvironment.mWorld->getStore().bodyParts.search(hairID); - const ESM::BodyPart *head = mEnvironment.mWorld->getStore().bodyParts.search(headID); + const ESM::BodyPart *feetpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); + const ESM::BodyPart *tailpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); + const ESM::BodyPart *wristlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); //We need two + const ESM::BodyPart *forearmlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); //We need two + const ESM::BodyPart *handlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand"); //We need two + const ESM::BodyPart *hairpart = mEnvironment.mWorld->getStore().bodyParts.search(hairID); + const ESM::BodyPart *headpart = mEnvironment.mWorld->getStore().bodyParts.search(headID); if(bodyRaceID == "b_n_argonian_f_") - forearml = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); //We need two - if(!handl) - handl = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands"); + forearmlpart = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); //We need two + if(!handlpart) + handlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands"); //const ESM::BodyPart* claviclel = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "clavicle"); //const ESM::BodyPart* clavicler = claviclel; - const ESM::BodyPart* handr = handl; - const ESM::BodyPart* forearmr = forearml; - const ESM::BodyPart* wristr = wristl; + const ESM::BodyPart* handrpart = handlpart; + const ESM::BodyPart* forearmr = forearmlpart; + const ESM::BodyPart* wristrpart = wristlpart; const ESM::BodyPart* armr = arml; if(upperleg){ - insertBoundedPart("meshes\\" + upperleg->model + "*|", "Left Upper Leg"); - insertBoundedPart("meshes\\" + upperleg->model, "Right Upper Leg"); + lUpperLeg = insertBoundedPart("meshes\\" + upperleg->model + "*|", "Left Upper Leg"); + rUpperLeg = insertBoundedPart("meshes\\" + upperleg->model, "Right Upper Leg"); } if(foot){ if(bodyRaceID.compare("b_n_khajiit_m_") == 0) { - feet = foot; + feetpart = foot; } else { - insertBoundedPart("meshes\\" + foot->model, "Right Foot"); - insertBoundedPart("meshes\\" + foot->model + "*|", "Left Foot"); + rfoot = insertBoundedPart("meshes\\" + foot->model, "Right Foot"); + lfoot = insertBoundedPart("meshes\\" + foot->model + "*|", "Left Foot"); } } - if(groin){ - insertBoundedPart("meshes\\" + groin->model, "Groin"); + if(groinpart){ + groin = insertBoundedPart("meshes\\" + groinpart->model, "Groin"); } if(knee) { - insertBoundedPart("meshes\\" + knee->model + "*|", "Left Knee"); //e - insertBoundedPart("meshes\\" + knee->model, "Right Knee"); //e + lKnee = insertBoundedPart("meshes\\" + knee->model + "*|", "Left Knee"); //e + rKnee = insertBoundedPart("meshes\\" + knee->model, "Right Knee"); //e } if(ankle){ - insertBoundedPart("meshes\\" + ankle->model + "*|", "Left Ankle"); //Ogre::Quaternion(Ogre::Radian(3.14 / 4), Ogre::Vector3(1, 0, 0)),blank); //1,0,0, blank); - insertBoundedPart("meshes\\" + ankle->model, "Right Ankle"); + lAnkle = insertBoundedPart("meshes\\" + ankle->model + "*|", "Left Ankle"); //Ogre::Quaternion(Ogre::Radian(3.14 / 4), Ogre::Vector3(1, 0, 0)),blank); //1,0,0, blank); + rAnkle = insertBoundedPart("meshes\\" + ankle->model, "Right Ankle"); } if (armr){ - insertBoundedPart("meshes\\" + armr->model, "Right Upper Arm"); + rupperArm = insertBoundedPart("meshes\\" + armr->model, "Right Upper Arm"); } if(arml){ - insertBoundedPart("meshes\\" + arml->model + "*|", "Left Upper Arm"); + lupperArm = insertBoundedPart("meshes\\" + arml->model + "*|", "Left Upper Arm"); } if (forearmr) { - insertBoundedPart("meshes\\" + forearmr->model, "Right Forearm"); + rForearm = insertBoundedPart("meshes\\" + forearmr->model, "Right Forearm"); } - if(forearml) - insertBoundedPart("meshes\\" + forearml->model + "*|", "Left Forearm"); + if(forearmlpart) + lForearm = insertBoundedPart("meshes\\" + forearmlpart->model + "*|", "Left Forearm"); - if (wristr) + if (wristrpart) { - insertBoundedPart("meshes\\" + wristr->model, "Right Wrist"); + rWrist = insertBoundedPart("meshes\\" + wristrpart->model, "Right Wrist"); } - if(wristl) - insertBoundedPart("meshes\\" + wristl->model + "*|", "Left Wrist"); + if(wristlpart) + lWrist = insertBoundedPart("meshes\\" + wristlpart->model + "*|", "Left Wrist"); @@ -184,35 +186,35 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O if(clavicler) insertBoundedPart("meshes\\" + clavicler->model , "Right Clavicle", base);*/ - if(neck) + if(neckpart) { - insertBoundedPart("meshes\\" + neck->model, "Neck"); + neck = insertBoundedPart("meshes\\" + neckpart->model, "Neck"); } - if(head) - insertBoundedPart("meshes\\" + head->model, "Head"); - if(hair) - insertBoundedPart("meshes\\" + hair->model, "Head"); + if(headpart) + head = insertBoundedPart("meshes\\" + headpart->model, "Head"); + if(hairpart) + hair = insertBoundedPart("meshes\\" + hairpart->model, "Head"); - if (chest){ - insertFreePart("meshes\\" + chest->model, ":\"", insert); + if (chestPart){ + chest = insertFreePart("meshes\\" + chestPart->model, ":\""); } - if (handr){ - insertFreePart("meshes\\" + handr->model , ":?", insert); + if (handrpart){ + rhand = insertFreePart("meshes\\" + handrpart->model , ":?"); } - if (handl){ - insertFreePart("meshes\\" + handl->model, ":>", insert); + if (handlpart){ + lhand = insertFreePart("meshes\\" + handlpart->model, ":>"); } - if(tail){ - insertFreePart("meshes\\" + tail->model, ":*", insert); + if(tailpart){ + tail = insertFreePart("meshes\\" + tailpart->model, ":*"); } - if(feet){ - std::string num = getUniqueID(feet->model); - insertFreePart("meshes\\" + feet->model,":<", insert); - insertFreePart("meshes\\" + feet->model,"::", insert); + if(feetpart){ + + lBeastFoot = insertFreePart("meshes\\" + feetpart->model,"::"); + rBeastFoot = insertFreePart("meshes\\" + feetpart->model,":<"); } //originalpos = insert->_getWorldAABB().getCenter(); //originalscenenode = insert->getPosition(); @@ -222,34 +224,38 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){ NIFLoader::load(mesh); - Entity* ent = mRend.getScene()->createEntity(mesh); + Ogre::Entity* part = mRend.getScene()->createEntity(mesh); - base->attachObjectToBone(bonename, ent); - return ent; + base->attachObjectToBone(bonename, part); + return part; } -void NpcAnimation::insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert){ +std::pair*> NpcAnimation::insertFreePart(const std::string &mesh, const std::string suffix){ + std::string meshNumbered = mesh + getUniqueID(mesh + suffix) + suffix; NIFLoader::load(meshNumbered); - Ogre::Entity* ent = mRend.getScene()->createEntity(meshNumbered); + Ogre::Entity* part = mRend.getScene()->createEntity(meshNumbered); - insert->attachObject(ent); - entityparts.push_back(ent); - shapes = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix)); - if(shapes){ - shapeparts.push_back(shapes); - handleShapes(shapes, ent, base->getSkeleton()); + insert->attachObject(part); + + std::vector* shape = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix)); + if(shape){ + + handleShapes(shape, part, base->getSkeleton()); } - - + std::pair*> pair = std::make_pair(part, shape); + return pair; } void NpcAnimation::runAnimation(float timepassed){ - + + mStateID = inv.getStateId(); + + //1. Add the amount of time passed to time //2. Handle the animation transforms dependent on time @@ -269,21 +275,25 @@ void NpcAnimation::runAnimation(float timepassed){ handleAnimationTransforms(); - std::vector*>::iterator shapepartsiter = shapeparts.begin(); - std::vector::iterator entitypartsiter = entityparts.begin(); - while(shapepartsiter != shapeparts.end()) - { + vecRotPos.clear(); - std::vector* shapes = *shapepartsiter; - Ogre::Entity* theentity = *entitypartsiter; - - - handleShapes(shapes, theentity, base->getSkeleton()); - shapepartsiter++; - entitypartsiter++; - } - - } - + + /* + if(lBeastFoot) + handleShapes(lBeastFootShapes, lBeastFoot, base->getSkeleton()); + if(rBeastFoot) + handleShapes(rBeastFootShapes, rBeastFoot, base->getSkeleton()); + if(chest) + handleShapes(chestShapes, chest, base->getSkeleton()); + if(tail) + handleShapes(tailShapes, tail, base->getSkeleton()); + if(skirt) + handleShapes(skirtShapes, skirt, base->getSkeleton()); + if(lhand) + handleShapes(lhandShapes, lhand, base->getSkeleton()); + if(rhand) + handleShapes(rhandShapes, rhand, base->getSkeleton()); + */ } } +} \ No newline at end of file diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index e524878cc..a95ce8526 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -6,26 +6,34 @@ #include #include #include +#include #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/environment.hpp" #include "components/nifogre/ogre_nif_loader.hpp" +#include "../mwworld/inventorystore.hpp" namespace MWRender{ class NpcAnimation: public Animation{ private: - + MWWorld::InventoryStore& inv; int mStateID; //Free Parts - Ogre::Entity* chest; std::vector* chestShapes; - Ogre::Entity* skirt; std::vector* skirtShapes; + std::pair*> chest; + std::pair*> skirt; + std::pair*> lhand; + std::pair*> rhand; + std::pair*> tail; + std::pair*> lBeastFoot; + std::pair*> rBeastFoot; + /*Ogre::Entity* skirt; std::vector* skirtShapes; Ogre::Entity* rhand; std::vector* rhandShapes; Ogre::Entity* lhand; std::vector* lhandShapes; Ogre::Entity* tail; std::vector* tailShapes; Ogre::Entity* lBeastFoot; std::vector* lBeastFootShapes; - Ogre::Entity* rBeastFoot; std::vector* rBeastFootShapes; + Ogre::Entity* rBeastFoot; std::vector* rBeastFootShapes;*/ //Bounded Parts Ogre::Entity* lclavicle; @@ -48,13 +56,14 @@ private: Ogre::Entity* rfoot; Ogre::Entity* hair; Ogre::Entity* head; + Ogre::SceneNode* insert; public: - NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend); + NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); virtual ~NpcAnimation(); Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename); - void insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert); + std::pair*> insertFreePart(const std::string &mesh, const std::string suffix); virtual void runAnimation(float timepassed); }; From bc636f036ce6c10470625e33bc3e2e762989ab96 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 8 Apr 2012 18:25:50 +0200 Subject: [PATCH 011/109] made it compile --- libs/openengine/bullet/pmove.cpp | 2 +- libs/openengine/bullet/trace.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 8fb72aa1f..dcb2e9f9b 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -1489,7 +1489,7 @@ static void PM_GroundTrace( void ) //PM_AddTouchEnt( trace.entityNum ); } -static void PM_AirMove() +void PM_AirMove() { //int i; Ogre::Vector3 wishvel; diff --git a/libs/openengine/bullet/trace.h b/libs/openengine/bullet/trace.h index 025673ab7..fb666b6eb 100644 --- a/libs/openengine/bullet/trace.h +++ b/libs/openengine/bullet/trace.h @@ -53,10 +53,10 @@ struct traceResults template const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3& start, const Ogre::Vector3& end, const Ogre::Vector3& BBExtents, const Ogre::Vector3& rotation, bool isInterior, OEngine::Physic::PhysicEngine* enginePass); -template const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3& start, const Ogre::Vector3& end, const Ogre::Vector3& BBExtents, const Ogre::Vector3& rotation, bool isInterior, OEngine::Physic::PhysicEngine* enginePass); -template const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3& start, const Ogre::Vector3& end, const Ogre::Vector3& BBExtents, const Ogre::Vector3& rotation, bool isInterior, OEngine::Physic::PhysicEngine* enginePass); +//template const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3& start, const Ogre::Vector3& end, const Ogre::Vector3& BBExtents, const Ogre::Vector3& rotation, bool isInterior, OEngine::Physic::PhysicEngine* enginePass); +//template const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3& start, const Ogre::Vector3& end, const Ogre::Vector3& BBExtents, const Ogre::Vector3& rotation, bool isInterior, OEngine::Physic::PhysicEngine* enginePass); void newtrace(traceResults* const results, const Ogre::Vector3& start, const Ogre::Vector3& end, const Ogre::Vector3& BBExtents, const float rotation, bool isInterior, OEngine::Physic::PhysicEngine* enginePass); -#endif \ No newline at end of file +#endif From 6bdfdf379b46c7d2d009c5f1fb691d094597357f Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 8 Apr 2012 17:27:56 -0400 Subject: [PATCH 012/109] Trying iterators --- apps/openmw/mwrender/npcanimation.cpp | 79 +++++++++++++++++---------- apps/openmw/mwrender/npcanimation.hpp | 10 +++- 2 files changed, 59 insertions(+), 30 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 30c28bb79..ea00919c6 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -11,12 +11,18 @@ NpcAnimation::~NpcAnimation(){ } -NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv){ +NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)){ ESMS::LiveCellRef *ref = ptr.get(); Ogre::Entity* blank = 0; std::vector* blankshape = 0; chest = std::make_pair(blank, blankshape); + tail = std::make_pair(blank, blankshape); + lBeastFoot = std::make_pair(blank, blankshape); + rBeastFoot = std::make_pair(blank, blankshape); + rhand = std::make_pair(blank, blankshape); + lhand = std::make_pair(blank, blankshape); + skirt = std::make_pair(blank, blankshape); //Part selection on last character of the file string // " Tri Chest // * Tri Tail @@ -35,18 +41,18 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O // vector = Ogre::Vector3(1,1,-1); - std::string hairID = ref->base->hair; - std::string headID = ref->base->head; - std::string npcName = ref->base->name; + hairID = ref->base->hair; + headID = ref->base->head; + npcName = ref->base->name; //ESMStore::Races r = const ESM::Race* race = mEnvironment.mWorld->getStore().races.find(ref->base->race); - std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); + bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2); bool female = tolower(secondtolast) == 'f'; std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower); - bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; + isBeast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; /*std::cout << "Race: " << ref->base->race ; if(female){ @@ -59,7 +65,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O std::string smodel = "meshes\\base_anim.nif"; - if(beast) + if(isBeast) smodel = "meshes\\base_animkna.nif"; insert = ptr.getRefData().getBaseNode(); @@ -92,11 +98,26 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O insert->scale(race->data.height.female, race->data.height.female, race->data.height.female); else insert->scale(race->data.height.male, race->data.height.male, race->data.height.male); - std::string headModel = "meshes\\" + + updateParts(); + +} + +void NpcAnimation::updateParts(){ + std::string headModel = "meshes\\" + mEnvironment.mWorld->getStore().bodyParts.find(headID)->model; std::string hairModel = "meshes\\" + mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; + + //inv.getSlot(MWWorld::InventoryStore::Slot_Robe); + + robe = inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass); + if(robe == inv.end()) + std::cout << "No part\n"; + else + std::cout << "yes part\n"; + + const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); const ESM::BodyPart *upperleg = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); const ESM::BodyPart *groinpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); @@ -216,9 +237,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O lBeastFoot = insertFreePart("meshes\\" + feetpart->model,"::"); rBeastFoot = insertFreePart("meshes\\" + feetpart->model,":<"); } - //originalpos = insert->_getWorldAABB().getCenter(); - //originalscenenode = insert->getPosition(); - + //originalpos = insert->_getWorl } Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){ @@ -252,8 +271,10 @@ std::pair*> NpcAnimation::insert void NpcAnimation::runAnimation(float timepassed){ - - mStateID = inv.getStateId(); + if(mStateID != inv.getStateId()){ + mStateID = inv.getStateId(); + updateParts(); + } //1. Add the amount of time passed to time @@ -278,22 +299,22 @@ void NpcAnimation::runAnimation(float timepassed){ vecRotPos.clear(); - /* - if(lBeastFoot) - handleShapes(lBeastFootShapes, lBeastFoot, base->getSkeleton()); - if(rBeastFoot) - handleShapes(rBeastFootShapes, rBeastFoot, base->getSkeleton()); - if(chest) - handleShapes(chestShapes, chest, base->getSkeleton()); - if(tail) - handleShapes(tailShapes, tail, base->getSkeleton()); - if(skirt) - handleShapes(skirtShapes, skirt, base->getSkeleton()); - if(lhand) - handleShapes(lhandShapes, lhand, base->getSkeleton()); - if(rhand) - handleShapes(rhandShapes, rhand, base->getSkeleton()); - */ + + if(lBeastFoot.first) + handleShapes(lBeastFoot.second, lBeastFoot.first, base->getSkeleton()); + if(rBeastFoot.first) + handleShapes(rBeastFoot.second, rBeastFoot.first, base->getSkeleton()); + if(chest.first) + handleShapes(chest.second, chest.first, base->getSkeleton()); + if(tail.first) + handleShapes(tail.second, tail.first, base->getSkeleton()); + if(skirt.first) + handleShapes(skirt.second, skirt.first, base->getSkeleton()); + if(lhand.first) + handleShapes(lhand.second, lhand.first, base->getSkeleton()); + if(rhand.first) + handleShapes(rhand.second, rhand.first, base->getSkeleton()); + } } } \ No newline at end of file diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index a95ce8526..aae97db2a 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -13,6 +13,8 @@ #include "../mwworld/environment.hpp" #include "components/nifogre/ogre_nif_loader.hpp" #include "../mwworld/inventorystore.hpp" +#include "../mwclass/npc.hpp" +#include "../mwworld/containerstore.hpp" namespace MWRender{ @@ -57,7 +59,12 @@ private: Ogre::Entity* hair; Ogre::Entity* head; Ogre::SceneNode* insert; - + bool isBeast; + std::string headID; + std::string hairID; + std::string npcName; + std::string bodyRaceID; + MWWorld::ContainerStoreIterator robe; public: NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); @@ -65,6 +72,7 @@ private: Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename); std::pair*> insertFreePart(const std::string &mesh, const std::string suffix); virtual void runAnimation(float timepassed); + void updateParts(); }; } From 80afcb2eac55b8c9b13c660c858cadbe6b7e8586 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 8 Apr 2012 20:44:44 -0400 Subject: [PATCH 013/109] small change --- apps/openmw/mwrender/npcanimation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index f7877d2ad..4b3c23e64 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -295,7 +295,7 @@ void NpcAnimation::runAnimation(float timepassed){ if(mStateID != inv.getStateId()){ std::cout << "StateID" < Date: Mon, 9 Apr 2012 00:51:10 -0400 Subject: [PATCH 014/109] one more change --- apps/openmw/mwrender/npcanimation.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 4b3c23e64..8097afdbf 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -134,8 +134,10 @@ void NpcAnimation::updateParts(){ //inv.getSlot(MWWorld::InventoryStore::Slot_Robe); - //MWWorld::ContainerStoreIterator robe = inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass); - //if(robe == inv.end()) + MWWorld::ContainerStoreIterator robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe); + + + // ; @@ -295,6 +297,7 @@ void NpcAnimation::runAnimation(float timepassed){ if(mStateID != inv.getStateId()){ std::cout << "StateID" < Date: Wed, 11 Apr 2012 20:16:22 -0400 Subject: [PATCH 015/109] Getting started with a new branch --- apps/openmw/mwrender/npcanimation.cpp | 173 ++++++------------------- apps/openmw/mwrender/npcanimation.hpp | 15 ++- apps/openmw/mwworld/inventorystore.cpp | 2 +- components/esm/loadarmo.cpp | 1 + components/esm/loadclot.cpp | 1 + 5 files changed, 53 insertions(+), 139 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 8097afdbf..f04ac7609 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -12,7 +12,7 @@ NpcAnimation::~NpcAnimation(){ } -NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv){ +NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)){ ESMS::LiveCellRef *ref = ptr.get(); Ogre::Entity* blank = 0; @@ -121,6 +121,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O insert->scale(race->data.height.female, race->data.height.female, race->data.height.female); else insert->scale(race->data.height.male, race->data.height.male, race->data.height.male); + std::cout << "Inv" << inv.getStateId() << "\n"; updateParts(); } @@ -133,134 +134,43 @@ void NpcAnimation::updateParts(){ mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; //inv.getSlot(MWWorld::InventoryStore::Slot_Robe); - - MWWorld::ContainerStoreIterator robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe); - - - - // ; - - - const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); - const ESM::BodyPart *upperleg = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); - const ESM::BodyPart *groinpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); - const ESM::BodyPart *arml = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); //We need two - const ESM::BodyPart *neckpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck"); - const ESM::BodyPart *knee = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); - const ESM::BodyPart *ankle = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); - const ESM::BodyPart *foot = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); - const ESM::BodyPart *feetpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); - const ESM::BodyPart *tailpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); - const ESM::BodyPart *wristlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); //We need two - const ESM::BodyPart *forearmlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); //We need two - const ESM::BodyPart *handlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand"); //We need two - const ESM::BodyPart *hairpart = mEnvironment.mWorld->getStore().bodyParts.search(hairID); - const ESM::BodyPart *headpart = mEnvironment.mWorld->getStore().bodyParts.search(headID); - if(bodyRaceID == "b_n_argonian_f_") - forearmlpart = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); //We need two - if(!handlpart) - handlpart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands"); - //const ESM::BodyPart* claviclel = environment.mWorld->getStore().bodyParts.search (bodyRaceID + "clavicle"); - //const ESM::BodyPart* clavicler = claviclel; - const ESM::BodyPart* handrpart = handlpart; - const ESM::BodyPart* forearmr = forearmlpart; - const ESM::BodyPart* wristrpart = wristlpart; - const ESM::BodyPart* armr = arml; - - - if(upperleg){ - lUpperLeg = insertBoundedPart("meshes\\" + upperleg->model + "*|", "Left Upper Leg"); - rUpperLeg = insertBoundedPart("meshes\\" + upperleg->model, "Right Upper Leg"); - - } - - if(foot){ - if(bodyRaceID.compare("b_n_khajiit_m_") == 0) - { - feetpart = foot; - } - else - { - rfoot = insertBoundedPart("meshes\\" + foot->model, "Right Foot"); - lfoot = insertBoundedPart("meshes\\" + foot->model + "*|", "Left Foot"); - } - } - if(groinpart){ - groin = insertBoundedPart("meshes\\" + groinpart->model, "Groin"); - } - if(knee) - { - lKnee = insertBoundedPart("meshes\\" + knee->model + "*|", "Left Knee"); //e - rKnee = insertBoundedPart("meshes\\" + knee->model, "Right Knee"); //e - - } - if(ankle){ - - lAnkle = insertBoundedPart("meshes\\" + ankle->model + "*|", "Left Ankle"); //Ogre::Quaternion(Ogre::Radian(3.14 / 4), Ogre::Vector3(1, 0, 0)),blank); //1,0,0, blank); - rAnkle = insertBoundedPart("meshes\\" + ankle->model, "Right Ankle"); - } - if (armr){ - rupperArm = insertBoundedPart("meshes\\" + armr->model, "Right Upper Arm"); - } - if(arml){ - lupperArm = insertBoundedPart("meshes\\" + arml->model + "*|", "Left Upper Arm"); - } - - if (forearmr) - { - rForearm = insertBoundedPart("meshes\\" + forearmr->model, "Right Forearm"); - } - if(forearmlpart) - lForearm = insertBoundedPart("meshes\\" + forearmlpart->model + "*|", "Left Forearm"); - - if (wristrpart) - { - rWrist = insertBoundedPart("meshes\\" + wristrpart->model, "Right Wrist"); - } - - if(wristlpart) - lWrist = insertBoundedPart("meshes\\" + wristlpart->model + "*|", "Left Wrist"); - - - - - - /*if(claviclel) - insertBoundedPart("meshes\\" + claviclel->model + "*|", "Left Clavicle", base); - if(clavicler) - insertBoundedPart("meshes\\" + clavicler->model , "Right Clavicle", base);*/ - - if(neckpart) - { - neck = insertBoundedPart("meshes\\" + neckpart->model, "Neck"); - } - if(headpart) - head = insertBoundedPart("meshes\\" + headpart->model, "Head"); - if(hairpart) - hair = insertBoundedPart("meshes\\" + hairpart->model, "Head"); - - if (chestPart){ - chest = insertFreePart("meshes\\" + chestPart->model, ":\""); - - - } - if (handrpart){ - rhand = insertFreePart("meshes\\" + handrpart->model , ":?"); - - } - if (handlpart){ - lhand = insertFreePart("meshes\\" + handlpart->model, ":>"); - - } - if(tailpart){ - tail = insertFreePart("meshes\\" + tailpart->model, ":*"); - } - if(feetpart){ + if(robe != inv.getSlot(MWWorld::InventoryStore::Slot_Robe)){ + //A robe was added or removed + if(chest.first) + { + insert->detachObject(chest.first); chest.first = 0; + } + robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe); + if(robe != inv.end()) + { + MWWorld::Ptr ptr = *robe; - lBeastFoot = insertFreePart("meshes\\" + feetpart->model,"::"); - rBeastFoot = insertFreePart("meshes\\" + feetpart->model,":<"); + const ESM::Clothing *clothes = (ptr.get())->base; + std::vector parts = clothes->parts.parts; + for(int i = 0; i < parts.size(); i++) + { + ESM::PartReference part = parts[i]; + if(part.part == ESM::PRT_Cuirass) + { + const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); + chest = insertFreePart("meshes\\" + bodypart->model, ":\""); + } + } + } + + } + if(robe == inv.end() ){ + //if(inv.getSlot(MWWorld::InventoryStore::Cuirass) != inv.end()) + if(chest.first == 0){ + const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); + chest = insertFreePart("meshes\\" + chestPart->model, ":\""); + } + } - //originalpos = insert->_getWorl + + + + } Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::string bonename){ @@ -295,13 +205,14 @@ std::pair*> NpcAnimation::insert void NpcAnimation::runAnimation(float timepassed){ - if(mStateID != inv.getStateId()){ - std::cout << "StateID" < .2){ + timeToChange = 0; + + updateParts(); } - + timeToChange += timepassed; //1. Add the amount of time passed to time diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index e90bea5c9..02b161b99 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -15,6 +15,7 @@ #include "../mwworld/inventorystore.hpp" #include "../mwclass/npc.hpp" #include "../mwworld/containerstore.hpp" +#include "components/esm/loadarmo.hpp" namespace MWRender{ @@ -30,12 +31,11 @@ private: std::pair*> tail; std::pair*> lBeastFoot; std::pair*> rBeastFoot; - /*Ogre::Entity* skirt; std::vector* skirtShapes; - Ogre::Entity* rhand; std::vector* rhandShapes; - Ogre::Entity* lhand; std::vector* lhandShapes; - Ogre::Entity* tail; std::vector* tailShapes; - Ogre::Entity* lBeastFoot; std::vector* lBeastFootShapes; - Ogre::Entity* rBeastFoot; std::vector* rBeastFootShapes;*/ + + int partslots[27]; //Each part slot is taken by clothing, armor, or is empty + + + //Bounded Parts Ogre::Entity* lclavicle; @@ -64,7 +64,8 @@ private: std::string hairID; std::string npcName; std::string bodyRaceID; - + float timeToChange; + MWWorld::ContainerStoreIterator robe; public: NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 650418201..230f7d69a 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -72,7 +72,7 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite /// \todo restack item previously in this slot (if required) /// \todo unstack item pointed to by iterator if required) - + mSlots[slot] = iterator; flagAsModified(); diff --git a/components/esm/loadarmo.cpp b/components/esm/loadarmo.cpp index ddc25e176..8b559b10f 100644 --- a/components/esm/loadarmo.cpp +++ b/components/esm/loadarmo.cpp @@ -11,6 +11,7 @@ void PartReferenceList::load(ESMReader &esm) esm.getHT(pr.part); // The INDX byte pr.male = esm.getHNOString("BNAM"); pr.female = esm.getHNOString("CNAM"); + parts.push_back(pr); } } diff --git a/components/esm/loadclot.cpp b/components/esm/loadclot.cpp index 1d6c9d4a1..16fd0598c 100644 --- a/components/esm/loadclot.cpp +++ b/components/esm/loadclot.cpp @@ -13,6 +13,7 @@ void Clothing::load(ESMReader &esm) icon = esm.getHNOString("ITEX"); parts.load(esm); + enchant = esm.getHNOString("ENAM"); } From a885f3e9422646e1212d0b0344ed4205918b63ed Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Thu, 12 Apr 2012 20:40:11 -0400 Subject: [PATCH 016/109] Remove part function --- apps/openmw/mwrender/npcanimation.cpp | 158 +++++++++++++++++++++++++- apps/openmw/mwrender/npcanimation.hpp | 5 +- 2 files changed, 161 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index f04ac7609..520cc12bb 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -12,11 +12,32 @@ NpcAnimation::~NpcAnimation(){ } -NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)){ +NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), + robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), + lclavicle(0), + rclavicle(0), + rupperArm(0), + lupperArm(0), + rUpperLeg(0), + lUpperLeg(0), + lForearm(0), + rForearm(0), + lWrist(0), + rWrist(0), + rKnee(0), + lKnee(0), + neck(0), + rAnkle(0), + lAnkle(0), + groin(0), + lfoot(0), + rfoot(0) + { ESMS::LiveCellRef *ref = ptr.get(); Ogre::Entity* blank = 0; std::vector* blankshape = 0; + zero = std::make_pair(blank, blankshape); chest = std::make_pair(blank, blankshape); tail = std::make_pair(blank, blankshape); lBeastFoot = std::make_pair(blank, blankshape); @@ -24,6 +45,12 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O rhand = std::make_pair(blank, blankshape); lhand = std::make_pair(blank, blankshape); skirt = std::make_pair(blank, blankshape); + for (int init = 0; init < 27; init++){ + partslots[init] = -1; //each slot is empty + partpriorities[init] = 0; + } + + //Part selection on last character of the file string // " Tri Chest // * Tri Tail @@ -254,4 +281,133 @@ void NpcAnimation::runAnimation(float timepassed){ } } + +void NpcAnimation::removeIndividualPart(int type){ + partpriorities[type] = 0; + partslots[type] = -1; + + if(type == ESM::PRT_Head && head){ //0 + base->detachObjectFromBone(head); + head = 0; + } + else if(type == ESM::PRT_Hair && hair){//1 + base->detachObjectFromBone(hair); + hair = 0; + } + else if(type == ESM::PRT_Neck && neck){//2 + base->detachObjectFromBone(neck); + neck = 0; + } + else if(type == ESM::PRT_Cuirass && chest.first){//3 + insert->detachObject(chest.first); + chest = zero; + } + else if(type == ESM::PRT_Groin && groin){//4 + base->detachObjectFromBone(groin); + groin = 0; + } + else if(type == ESM::PRT_Skirt && skirt.first){//5 + insert->detachObject(skirt.first); + skirt = zero; + } + else if(type == ESM::PRT_RHand && rhand.first){//6 + insert->detachObject(rhand.first); + rhand = zero; + } + else if(type == ESM::PRT_LHand && lhand.first){//7 + insert->detachObject(lhand.first); + lhand = zero; + } + else if(type == ESM::PRT_RWrist && rWrist){//8 + base->detachObjectFromBone(rWrist); + rWrist = 0; + } + else if(type == ESM::PRT_LWrist && lWrist){//9 + base->detachObjectFromBone(lWrist); + lWrist = 0; + } + else if(type == ESM::PRT_Shield){//10 + + } + else if(type == ESM::PRT_RForearm && rForearm){//11 + base->detachObjectFromBone(rForearm); + rForearm = 0; + } + else if(type == ESM::PRT_LForearm && lForearm){//12 + base->detachObjectFromBone(lForearm); + lForearm = 0; + } + else if(type == ESM::PRT_RUpperarm && rupperArm){//13 + base->detachObjectFromBone(rupperArm); + rupperArm = 0; + } + else if(type == ESM::PRT_LUpperarm && lupperArm){//14 + base->detachObjectFromBone(lupperArm); + lupperArm = 0; + } + else if(type == ESM::PRT_RFoot){ //15 + if(rfoot){ + base->detachObjectFromBone(rfoot); + rfoot = 0; + } + else if(rBeastFoot.first){ + insert->detachObject(rBeastFoot.first); + rBeastFoot = zero; + } + } + else if(type == ESM::PRT_LFoot){ //16 + if(lfoot){ + base->detachObjectFromBone(lfoot); + lfoot = 0; + } + else if(lBeastFoot.first){ + insert->detachObject(lBeastFoot.first); + lBeastFoot = zero; + } + } + else if(type == ESM::PRT_RAnkle && rAnkle){ //17 + base->detachObjectFromBone(rAnkle); + rAnkle = 0; + } + else if(type == ESM::PRT_LAnkle && lAnkle){ //18 + base->detachObjectFromBone(lAnkle); + lAnkle = 0; + } + else if(type == ESM::PRT_RKnee && rKnee){ //19 + base->detachObjectFromBone(rKnee); + rKnee = 0; + } + else if(type == ESM::PRT_LKnee && lKnee){ //20 + base->detachObjectFromBone(lKnee); + lKnee = 0; + } + else if(type == ESM::PRT_RLeg && rUpperLeg){ //21 + base->detachObjectFromBone(rAnkle); + rUpperLeg = 0; + } + else if(type == ESM::PRT_LLeg && lUpperLeg){ //22 + base->detachObjectFromBone(lUpperLeg); + lUpperLeg = 0; + } + else if(type == ESM::PRT_RPauldron && rclavicle){ //23 + base->detachObjectFromBone(rclavicle); + rclavicle = 0; + } + else if(type == ESM::PRT_LPauldron && lclavicle){ //24 + base->detachObjectFromBone(lclavicle); + lclavicle = 0; + } + else if(type == ESM::PRT_Weapon){ //25 + + } + else if(type == ESM::PRT_Tail && tail.first){ //26 + insert->detachObject(tail.first); + tail = zero; + } + + + + + } + } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 02b161b99..eecb598df 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -33,7 +33,8 @@ private: std::pair*> rBeastFoot; int partslots[27]; //Each part slot is taken by clothing, armor, or is empty - + int partpriorities[27]; + std::pair*> zero; @@ -58,6 +59,7 @@ private: Ogre::Entity* rfoot; Ogre::Entity* hair; Ogre::Entity* head; + Ogre::SceneNode* insert; bool isBeast; std::string headID; @@ -74,6 +76,7 @@ private: std::pair*> insertFreePart(const std::string &mesh, const std::string suffix); virtual void runAnimation(float timepassed); void updateParts(); + void removeIndividualPart(int type); }; } From 1f566fc93a66e1cfc7b2516e9937dd88c53c3e40 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Thu, 12 Apr 2012 20:59:30 -0400 Subject: [PATCH 017/109] Another remove function --- apps/openmw/mwrender/npcanimation.cpp | 9 +++++++++ apps/openmw/mwrender/npcanimation.hpp | 1 + 2 files changed, 10 insertions(+) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 520cc12bb..0b546bf13 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -410,4 +410,13 @@ void NpcAnimation::removeIndividualPart(int type){ } + void NpcAnimation::removePartGroup(int group){ + for(int i = 0; i < 27; i++){ + if(partslots[i] == group){ + removeIndividualPart(i); + } + } + } } + + diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index eecb598df..0b4442e3a 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -77,6 +77,7 @@ private: virtual void runAnimation(float timepassed); void updateParts(); void removeIndividualPart(int type); + void removePartGroup(int group); }; } From e869433b07c0e30cbd73affeb64b8d551484d7b6 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Thu, 12 Apr 2012 22:16:02 -0400 Subject: [PATCH 018/109] Add or replace individual parts --- apps/openmw/mwrender/npcanimation.cpp | 100 +++++++++++++++++++++++++- apps/openmw/mwrender/npcanimation.hpp | 1 + 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 0b546bf13..37e3573f8 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -382,7 +382,7 @@ void NpcAnimation::removeIndividualPart(int type){ lKnee = 0; } else if(type == ESM::PRT_RLeg && rUpperLeg){ //21 - base->detachObjectFromBone(rAnkle); + base->detachObjectFromBone(rUpperLeg); rUpperLeg = 0; } else if(type == ESM::PRT_LLeg && lUpperLeg){ //22 @@ -417,6 +417,104 @@ void NpcAnimation::removeIndividualPart(int type){ } } } + bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh){ + if(priority >= partpriorities[type]){ + removeIndividualPart(type); + partslots[type] = group; + switch(type){ + case ESM::PRT_Head: //0 + head = insertBoundedPart(mesh, "Head"); + break; + case ESM::PRT_Hair: //1 + hair = insertBoundedPart(mesh, "Head"); + break; + case ESM::PRT_Neck: //2 + neck = insertBoundedPart(mesh, "Neck"); + break; + case ESM::PRT_Cuirass: //3 + chest = insertFreePart(mesh, ":\""); + break; + case ESM::PRT_Groin: //4 + neck = insertBoundedPart(mesh, "Groin"); + break; + case ESM::PRT_Skirt: //5 + skirt = insertFreePart(mesh, ":|"); + break; + case ESM::PRT_RHand: //6 + rhand = insertFreePart(mesh, ":?"); + break; + case ESM::PRT_LHand: //7 + lhand = insertFreePart(mesh, ":>"); + break; + case ESM::PRT_RWrist: //8 + rWrist = insertBoundedPart(mesh, "Right Wrist"); + break; + case ESM::PRT_LWrist: //9 + lWrist = insertBoundedPart(mesh + "*|", "Left Wrist"); + break; + case ESM::PRT_Shield: //10 + break; + case ESM::PRT_RForearm: //11 + rForearm = insertBoundedPart(mesh, "Right Forearm"); + break; + case ESM::PRT_LForearm: //12 + lForearm = insertBoundedPart(mesh + "*|", "Left Forearm"); + break; + case ESM::PRT_RUpperarm: //13 + rupperArm = insertBoundedPart(mesh, "Right Upper Arm"); + break; + case ESM::PRT_LUpperarm: //14 + lupperArm = insertBoundedPart(mesh + "*|", "Left Upper Arm"); + break; + case ESM::PRT_RFoot: //15 + if(isBeast) + rBeastFoot = insertFreePart(mesh, ":<"); + else + rfoot = insertBoundedPart(mesh, "Right Foot"); + break; + case ESM::PRT_LFoot: //16 + if(isBeast) + lBeastFoot = insertFreePart(mesh, "::"); + else + lfoot = insertBoundedPart(mesh + "*|", "Left Foot"); + break; + + case ESM::PRT_RAnkle: //17 + rAnkle = insertBoundedPart(mesh , "Right Ankle"); + break; + case ESM::PRT_LAnkle: //18 + lAnkle = insertBoundedPart(mesh + "*|", "Left Ankle"); + break; + case ESM::PRT_RKnee: //19 + rKnee = insertBoundedPart(mesh , "Right Knee"); + break; + case ESM::PRT_LKnee: //20 + lKnee = insertBoundedPart(mesh + "*|", "Left Knee"); + break; + case ESM::PRT_RLeg: //21 + rUpperLeg = insertBoundedPart(mesh, "Right Upper Leg"); + break; + case ESM::PRT_LLeg: //22 + lUpperLeg = insertBoundedPart(mesh + "*|", "Left Upper Leg"); + break; + case ESM::PRT_RPauldron: //23 + rclavicle = insertBoundedPart(mesh , "Right Clavicle"); + break; + case ESM::PRT_LPauldron: //24 + lclavicle = insertBoundedPart(mesh + "*|", "Left Clavicle"); + break; + case ESM::PRT_Weapon: //25 + break; + case ESM::PRT_Tail: //26 + tail = insertFreePart(mesh, ":*"); + break; + + + } + return true; + } + return false; + } } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 0b4442e3a..e5858e38c 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -78,6 +78,7 @@ private: void updateParts(); void removeIndividualPart(int type); void removePartGroup(int group); + bool addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh); }; } From 7551926afd698109527cd76888bbb8a8f567750e Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Fri, 13 Apr 2012 23:25:15 -0400 Subject: [PATCH 019/109] Adding helmets --- apps/openmw/mwrender/npcanimation.cpp | 56 +++++++++++++++++++-------- apps/openmw/mwrender/npcanimation.hpp | 1 + 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 37e3573f8..34dbb0862 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -13,7 +13,7 @@ NpcAnimation::~NpcAnimation(){ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), - robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), + robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), helmet(inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)), lclavicle(0), rclavicle(0), rupperArm(0), @@ -160,13 +160,12 @@ void NpcAnimation::updateParts(){ std::string hairModel = "meshes\\" + mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; + + //inv.getSlot(MWWorld::InventoryStore::Slot_Robe); if(robe != inv.getSlot(MWWorld::InventoryStore::Slot_Robe)){ //A robe was added or removed - if(chest.first) - { - insert->detachObject(chest.first); chest.first = 0; - } + removePartGroup(MWWorld::InventoryStore::Slot_Robe); robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe); if(robe != inv.end()) { @@ -177,23 +176,47 @@ void NpcAnimation::updateParts(){ for(int i = 0; i < parts.size(); i++) { ESM::PartReference part = parts[i]; - if(part.part == ESM::PRT_Cuirass) - { + const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); - chest = insertFreePart("meshes\\" + bodypart->model, ":\""); - } + if(bodypart) + addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Robe,5,"meshes\\" + bodypart->model); + } } } - if(robe == inv.end() ){ - //if(inv.getSlot(MWWorld::InventoryStore::Cuirass) != inv.end()) - if(chest.first == 0){ - const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); - chest = insertFreePart("meshes\\" + chestPart->model, ":\""); + if(helmet != inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)){ + helmet = inv.getSlot(MWWorld::InventoryStore::Slot_Helmet); + removePartGroup(MWWorld::InventoryStore::Slot_Helmet); + removeIndividualPart(ESM::PRT_Hair); + if(helmet != inv.end()){ + const ESM::Armor *armor = (helmet->get())->base; + std::vector parts = armor->parts.parts; + for(int i = 0; i < parts.size(); i++) + { + ESM::PartReference part = parts[i]; + + const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); + if(bodypart) + addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Helmet,3,"meshes\\" + bodypart->model); + + } } - + } + + if(partpriorities[ESM::PRT_Cuirass] < 1){ + const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); + if(chestPart) + addOrReplaceIndividualPart(ESM::PRT_Cuirass, -1,1,"meshes\\" + chestPart->model); + } + if(partpriorities[ESM::PRT_Head] < 1){ + addOrReplaceIndividualPart(ESM::PRT_Head, -1,1,headModel); + } + if(partpriorities[ESM::PRT_Hair] < 1 && partpriorities[ESM::PRT_Head] <= 1){ + addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1,hairModel); + } + @@ -418,9 +441,10 @@ void NpcAnimation::removeIndividualPart(int type){ } } bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh){ - if(priority >= partpriorities[type]){ + if(priority > partpriorities[type]){ removeIndividualPart(type); partslots[type] = group; + partpriorities[type] = priority; switch(type){ case ESM::PRT_Head: //0 head = insertBoundedPart(mesh, "Head"); diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index e5858e38c..b3d9b3c4a 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -68,6 +68,7 @@ private: std::string bodyRaceID; float timeToChange; MWWorld::ContainerStoreIterator robe; + MWWorld::ContainerStoreIterator helmet; public: NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); From cac662ca981dc0cdb19872f4c40e46b97bf7b365 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 14 Apr 2012 17:47:44 +0200 Subject: [PATCH 020/109] basic tooltips --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/engine.cpp | 16 +++---- apps/openmw/mwgui/tooltips.cpp | 63 ++++++++++++++++++++++++++++ apps/openmw/mwgui/tooltips.hpp | 30 +++++++++++++ apps/openmw/mwgui/window_manager.cpp | 10 +++++ apps/openmw/mwgui/window_manager.hpp | 2 + files/mygui/CMakeLists.txt | 1 + files/mygui/openmw_tooltips.xml | 21 ++++++++++ 8 files changed, 136 insertions(+), 9 deletions(-) create mode 100644 apps/openmw/mwgui/tooltips.cpp create mode 100644 apps/openmw/mwgui/tooltips.hpp create mode 100644 files/mygui/openmw_tooltips.xml diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index c4b3776ed..a37dbf7af 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -25,7 +25,7 @@ add_openmw_dir (mwinput add_openmw_dir (mwgui layouts text_input widgets race class birth review window_manager console dialogue dialogue_history window_base stats_window messagebox journalwindow charactercreation - map_window window_pinnable_base cursorreplace + map_window window_pinnable_base cursorreplace tooltips ) add_openmw_dir (mwdialogue diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 2d3c872dd..36a2cb645 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -133,14 +133,6 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) if (mUseSound) mEnvironment.mSoundManager->update (evt.timeSinceLastFrame); - // update GUI - Ogre::RenderWindow* window = mOgre->getWindow(); - mEnvironment.mWindowManager->wmUpdateFps(window->getLastFPS(), - window->getTriangleCount(), - window->getBatchCount()); - - mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration); - // global scripts mEnvironment.mGlobalScripts->run (mEnvironment); @@ -171,6 +163,14 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) // update world mEnvironment.mWorld->update (evt.timeSinceLastFrame); + // update GUI + Ogre::RenderWindow* window = mOgre->getWindow(); + mEnvironment.mWindowManager->wmUpdateFps(window->getLastFPS(), + window->getTriangleCount(), + window->getBatchCount()); + + mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration); + // report focus object (for debugging) if (mReportFocus) updateFocusReport (mEnvironment.mFrameDuration); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp new file mode 100644 index 000000000..d7c61c51a --- /dev/null +++ b/apps/openmw/mwgui/tooltips.cpp @@ -0,0 +1,63 @@ +#include "tooltips.hpp" + +using namespace MWGui; +using namespace MyGUI; + +ToolTips::ToolTips() : + Layout("openmw_tooltips.xml") + , mGameMode(true) +{ + getWidget(mTextToolTip, "TextToolTip"); + getWidget(mTextToolTipBox, "TextToolTipBox"); + getWidget(mDynamicToolTipBox, "DynamicToolTipBox"); + + mDynamicToolTipBox->setVisible(false); + + // turn off mouse focus so that getMouseFocusWidget returns the correct widget, + // even if the mouse is over the tooltip + mDynamicToolTipBox->setNeedMouseFocus(false); + mTextToolTipBox->setNeedMouseFocus(false); + mTextToolTip->setNeedMouseFocus(false); + mMainWidget->setNeedMouseFocus(false); +} + +void ToolTips::onFrame(float frameDuration) +{ + /// \todo Store a MWWorld::Ptr in the widget user data, retrieve it here and construct a tooltip dynamically + + const IntSize &viewSize = RenderManager::getInstance().getViewSize(); + + Widget* focus = InputManager::getInstance().getMouseFocusWidget(); + if (focus == 0) return; + + // this the maximum width of the tooltip before it starts word-wrapping + setCoord(0, 0, 300, 300); + + mTextToolTip->setCaption("Focused: " + focus->getName() + "\nType: " + focus->getTypeName()); + const IntSize &textSize = mTextToolTip->getTextSize(); + + IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24); + + IntSize size = textSize + IntSize(12, 12); + // make the tooltip stay completely in the viewport + if ((tooltipPosition.left + size.width) > viewSize.width) + { + tooltipPosition.left = viewSize.width - size.width; + } + if ((tooltipPosition.top + size.height) > viewSize.height) + { + tooltipPosition.top = viewSize.height - size.height; + } + + setCoord(tooltipPosition.left, tooltipPosition.top, size.width, size.height); +} + +void ToolTips::enterGameMode() +{ + mGameMode = true; +} + +void ToolTips::enterGuiMode() +{ + mGameMode = false; +} diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp new file mode 100644 index 000000000..aa929ff51 --- /dev/null +++ b/apps/openmw/mwgui/tooltips.hpp @@ -0,0 +1,30 @@ + +#ifndef MWGUI_TOOLTIPS_H +#define MWGUI_TOOLTIPS_H + +#include + +namespace MWGui +{ + class ToolTips : public OEngine::GUI::Layout + { + public: + ToolTips(); + + void onFrame(float frameDuration); + + void enterGameMode(); + void enterGuiMode(); + + void adjustScreen(int screenWidth, int screenHeight); + + private: + MyGUI::EditBox* mTextToolTip; + MyGUI::Widget* mTextToolTipBox; + + MyGUI::Widget* mDynamicToolTipBox; + + bool mGameMode; + }; +} +#endif diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 34d62ba08..1ef5cae42 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -7,6 +7,7 @@ #include "map_window.hpp" #include "stats_window.hpp" #include "messagebox.hpp" +#include "tooltips.hpp" #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwinput/inputmanager.hpp" @@ -31,6 +32,7 @@ WindowManager::WindowManager(MWWorld::Environment& environment, , map(NULL) , menu(NULL) , stats(NULL) + , mToolTips(NULL) , mMessageBoxManager(NULL) , console(NULL) , mJournal(NULL) @@ -80,6 +82,7 @@ WindowManager::WindowManager(MWWorld::Environment& environment, mJournal = new JournalWindow(*this); mMessageBoxManager = new MessageBoxManager(this); dialogueWindow = new DialogueWindow(*this,environment); + mToolTips = new ToolTips(); // The HUD is always on hud->setVisible(true); @@ -118,6 +121,7 @@ WindowManager::~WindowManager() delete stats; delete mJournal; delete dialogueWindow; + delete mToolTips; delete mCharGen; @@ -183,6 +187,11 @@ void WindowManager::updateVisible() // Mouse is visible whenever we're not in game mode MyGUI::PointerManager::getInstance().setVisible(isGuiMode()); + if (mode == GM_Game) + mToolTips->enterGameMode(); + else + mToolTips->enterGuiMode(); + switch(mode) { case GM_Game: // If in game mode, don't show anything. @@ -408,6 +417,7 @@ void WindowManager::onDialogueWindowBye() void WindowManager::onFrame (float frameDuration) { mMessageBoxManager->onFrame(frameDuration); + mToolTips->onFrame(frameDuration); } const ESMS::ESMStore& WindowManager::getStore() const diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 2b53560ba..1cbd8f6a6 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -62,6 +62,7 @@ namespace MWGui class Console; class JournalWindow; class CharacterCreation; + class ToolTips; class TextInputDialog; class InfoBoxDialog; @@ -196,6 +197,7 @@ namespace MWGui HUD *hud; MapWindow *map; MainMenu *menu; + ToolTips *mToolTips; StatsWindow *stats; MessageBoxManager *mMessageBoxManager; Console *console; diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index e3a7b9999..49055d2ed 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -50,6 +50,7 @@ configure_file("${SDIR}/openmw_messagebox_layout.xml" "${DDIR}/openmw_messagebox configure_file("${SDIR}/openmw_interactive_messagebox_layout.xml" "${DDIR}/openmw_interactive_messagebox_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_journal_layout.xml" "${DDIR}/openmw_journal_layout.xml" COPYONLY) configure_file("${SDIR}/openmw_journal_skin.xml" "${DDIR}/openmw_journal_skin.xml" COPYONLY) +configure_file("${SDIR}/openmw_tooltips.xml" "${DDIR}/openmw_tooltips.xml" COPYONLY) configure_file("${SDIR}/smallbars.png" "${DDIR}/smallbars.png" COPYONLY) configure_file("${SDIR}/transparent.png" "${DDIR}/transparent.png" COPYONLY) configure_file("${SDIR}/EBGaramond-Regular.ttf" "${DDIR}/EBGaramond-Regular.ttf" COPYONLY) diff --git a/files/mygui/openmw_tooltips.xml b/files/mygui/openmw_tooltips.xml new file mode 100644 index 000000000..76df7b9a7 --- /dev/null +++ b/files/mygui/openmw_tooltips.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + From 5d4ad4cd810501e09f2b6550fb4e28204ebe8223 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 14 Apr 2012 16:44:46 -0400 Subject: [PATCH 021/109] Shirts and Cuirasses --- apps/openmw/mwclass/clothing.cpp | 2 +- apps/openmw/mwrender/npcanimation.cpp | 68 ++++++++++++++++++++++----- apps/openmw/mwrender/npcanimation.hpp | 2 + 3 files changed, 60 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 1fbc11c63..672a2b60a 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -89,7 +89,7 @@ namespace MWClass static const int sMapping[size][2] = { - { ESM::Clothing::Shirt, MWWorld::InventoryStore::Slot_Cuirass }, + { ESM::Clothing::Shirt, MWWorld::InventoryStore::Slot_Shirt }, { ESM::Clothing::Belt, MWWorld::InventoryStore::Slot_Belt }, { ESM::Clothing::Robe, MWWorld::InventoryStore::Slot_Robe }, { ESM::Clothing::Pants, MWWorld::InventoryStore::Slot_Pants }, diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 34dbb0862..08c53f39d 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -13,7 +13,8 @@ NpcAnimation::~NpcAnimation(){ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), - robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), helmet(inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)), + robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), helmet(inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)), shirt(inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)), + cuirass(inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)), lclavicle(0), rclavicle(0), rupperArm(0), @@ -159,7 +160,7 @@ void NpcAnimation::updateParts(){ std::string hairModel = "meshes\\" + mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; - + bool apparelChanged = false; //inv.getSlot(MWWorld::InventoryStore::Slot_Robe); @@ -167,7 +168,31 @@ void NpcAnimation::updateParts(){ //A robe was added or removed removePartGroup(MWWorld::InventoryStore::Slot_Robe); robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe); - if(robe != inv.end()) + apparelChanged = true; + + + } + if(helmet != inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)){ + apparelChanged = true; + helmet = inv.getSlot(MWWorld::InventoryStore::Slot_Helmet); + removePartGroup(MWWorld::InventoryStore::Slot_Helmet); + + } + if(cuirass != inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)){ + cuirass = inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass); + removePartGroup(MWWorld::InventoryStore::Slot_Cuirass); + apparelChanged = true; + + } + if(shirt != inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)){ + shirt = inv.getSlot(MWWorld::InventoryStore::Slot_Shirt); + removePartGroup(MWWorld::InventoryStore::Slot_Shirt); + apparelChanged = true; + + } + + if(apparelChanged){ + if(robe != inv.end()) { MWWorld::Ptr ptr = *robe; @@ -183,13 +208,9 @@ void NpcAnimation::updateParts(){ } } - - } - if(helmet != inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)){ - helmet = inv.getSlot(MWWorld::InventoryStore::Slot_Helmet); - removePartGroup(MWWorld::InventoryStore::Slot_Helmet); - removeIndividualPart(ESM::PRT_Hair); - if(helmet != inv.end()){ + + if(helmet != inv.end()){ + removeIndividualPart(ESM::PRT_Hair); const ESM::Armor *armor = (helmet->get())->base; std::vector parts = armor->parts.parts; for(int i = 0; i < parts.size(); i++) @@ -202,7 +223,32 @@ void NpcAnimation::updateParts(){ } } - + if(cuirass != inv.end()){ + const ESM::Armor *armor = (cuirass->get())->base; + std::vector parts = armor->parts.parts; + for(int i = 0; i < parts.size(); i++) + { + ESM::PartReference part = parts[i]; + + const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); + if(bodypart) + addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Cuirass,3,"meshes\\" + bodypart->model); + + } + } + if(shirt != inv.end()){ + const ESM::Clothing *clothes = (shirt->get())->base; + std::vector parts = clothes->parts.parts; + for(int i = 0; i < parts.size(); i++) + { + ESM::PartReference part = parts[i]; + + const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); + if(bodypart) + addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Shirt,2,"meshes\\" + bodypart->model); + + } + } } if(partpriorities[ESM::PRT_Cuirass] < 1){ diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index b3d9b3c4a..377560222 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -69,6 +69,8 @@ private: float timeToChange; MWWorld::ContainerStoreIterator robe; MWWorld::ContainerStoreIterator helmet; + MWWorld::ContainerStoreIterator shirt; + MWWorld::ContainerStoreIterator cuirass; public: NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); From e5becb1f50dc79b14a5f587629516ee216ab6f95 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 14 Apr 2012 18:58:52 -0400 Subject: [PATCH 022/109] Group add function;Greaves --- apps/openmw/mwrender/npcanimation.cpp | 81 ++++++++++++++------------- apps/openmw/mwrender/npcanimation.hpp | 6 +- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 08c53f39d..bacee7f2d 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -14,7 +14,7 @@ NpcAnimation::~NpcAnimation(){ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), helmet(inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)), shirt(inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)), - cuirass(inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)), + cuirass(inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)), greaves(inv.getSlot(MWWorld::InventoryStore::Slot_Greaves)), lclavicle(0), rclavicle(0), rupperArm(0), @@ -79,7 +79,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); char secondtolast = bodyRaceID.at(bodyRaceID.length() - 2); - bool female = tolower(secondtolast) == 'f'; + isFemale = tolower(secondtolast) == 'f'; std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower); isBeast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_"; @@ -145,7 +145,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O insert->attachObject(base); - if(female) + if(isFemale) insert->scale(race->data.height.female, race->data.height.female, race->data.height.female); else insert->scale(race->data.height.male, race->data.height.male, race->data.height.male); @@ -183,6 +183,12 @@ void NpcAnimation::updateParts(){ removePartGroup(MWWorld::InventoryStore::Slot_Cuirass); apparelChanged = true; + } + if(greaves != inv.getSlot(MWWorld::InventoryStore::Slot_Greaves)){ + cuirass = inv.getSlot(MWWorld::InventoryStore::Slot_Greaves); + removePartGroup(MWWorld::InventoryStore::Slot_Greaves); + apparelChanged = true; + } if(shirt != inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)){ shirt = inv.getSlot(MWWorld::InventoryStore::Slot_Shirt); @@ -198,56 +204,32 @@ void NpcAnimation::updateParts(){ const ESM::Clothing *clothes = (ptr.get())->base; std::vector parts = clothes->parts.parts; - for(int i = 0; i < parts.size(); i++) - { - ESM::PartReference part = parts[i]; - - const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); - if(bodypart) - addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Robe,5,"meshes\\" + bodypart->model); - - } + addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts); } if(helmet != inv.end()){ removeIndividualPart(ESM::PRT_Hair); const ESM::Armor *armor = (helmet->get())->base; std::vector parts = armor->parts.parts; - for(int i = 0; i < parts.size(); i++) - { - ESM::PartReference part = parts[i]; - - const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); - if(bodypart) - addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Helmet,3,"meshes\\" + bodypart->model); - - } + addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts); + } if(cuirass != inv.end()){ const ESM::Armor *armor = (cuirass->get())->base; std::vector parts = armor->parts.parts; - for(int i = 0; i < parts.size(); i++) - { - ESM::PartReference part = parts[i]; - - const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); - if(bodypart) - addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Cuirass,3,"meshes\\" + bodypart->model); - - } + addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts); + + } + if(greaves != inv.end()){ + const ESM::Armor *armor = (greaves->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); + } if(shirt != inv.end()){ const ESM::Clothing *clothes = (shirt->get())->base; std::vector parts = clothes->parts.parts; - for(int i = 0; i < parts.size(); i++) - { - ESM::PartReference part = parts[i]; - - const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); - if(bodypart) - addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Shirt,2,"meshes\\" + bodypart->model); - - } + addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); } } @@ -299,6 +281,8 @@ std::pair*> NpcAnimation::insert } + + void NpcAnimation::runAnimation(float timepassed){ if(timeToChange > .2){ @@ -585,6 +569,25 @@ void NpcAnimation::removeIndividualPart(int type){ } return false; } + + void NpcAnimation::addPartGroup(int group, int priority, std::vector& parts){ + for(int i = 0; i < parts.size(); i++) + { + ESM::PartReference part = parts[i]; + + + const ESM::BodyPart *bodypart = 0; + + if(isFemale) + bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.female); + if(!bodypart) + bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); + + if(bodypart) + addOrReplaceIndividualPart(part.part, group,priority,"meshes\\" + bodypart->model); + + } + } } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 377560222..545634e1f 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -62,6 +62,7 @@ private: Ogre::SceneNode* insert; bool isBeast; + bool isFemale; std::string headID; std::string hairID; std::string npcName; @@ -71,6 +72,7 @@ private: MWWorld::ContainerStoreIterator helmet; MWWorld::ContainerStoreIterator shirt; MWWorld::ContainerStoreIterator cuirass; + MWWorld::ContainerStoreIterator greaves; public: NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); @@ -80,8 +82,10 @@ private: virtual void runAnimation(float timepassed); void updateParts(); void removeIndividualPart(int type); - void removePartGroup(int group); + bool addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh); + void removePartGroup(int group); + void addPartGroup(int group, int priority, std::vector& parts); }; } From 940a90e3baac2f924bcd1fba0de672c9b74a2717 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 14 Apr 2012 19:21:14 -0400 Subject: [PATCH 023/109] Pauldrons --- apps/openmw/mwrender/npcanimation.cpp | 26 +++++++++++++++++++++++++- apps/openmw/mwrender/npcanimation.hpp | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index bacee7f2d..5adb9914d 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -15,6 +15,7 @@ NpcAnimation::~NpcAnimation(){ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), helmet(inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)), shirt(inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)), cuirass(inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)), greaves(inv.getSlot(MWWorld::InventoryStore::Slot_Greaves)), + leftpauldron(inv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron)), rightpauldron(inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron)), lclavicle(0), rclavicle(0), rupperArm(0), @@ -185,9 +186,20 @@ void NpcAnimation::updateParts(){ } if(greaves != inv.getSlot(MWWorld::InventoryStore::Slot_Greaves)){ - cuirass = inv.getSlot(MWWorld::InventoryStore::Slot_Greaves); + greaves = inv.getSlot(MWWorld::InventoryStore::Slot_Greaves); removePartGroup(MWWorld::InventoryStore::Slot_Greaves); apparelChanged = true; + } + if(leftpauldron != inv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron)){ + leftpauldron = inv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron); + removePartGroup(MWWorld::InventoryStore::Slot_LeftPauldron); + apparelChanged = true; + + } + if(rightpauldron != inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron)){ + leftpauldron = inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron); + removePartGroup(MWWorld::InventoryStore::Slot_RightPauldron); + apparelChanged = true; } if(shirt != inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)){ @@ -225,6 +237,18 @@ void NpcAnimation::updateParts(){ std::vector parts = armor->parts.parts; addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); + } + if(leftpauldron != inv.end()){ + const ESM::Armor *armor = (leftpauldron->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts); + + } + if(rightpauldron != inv.end()){ + const ESM::Armor *armor = (rightpauldron->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); + } if(shirt != inv.end()){ const ESM::Clothing *clothes = (shirt->get())->base; diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 545634e1f..7785ffc1a 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -73,6 +73,8 @@ private: MWWorld::ContainerStoreIterator shirt; MWWorld::ContainerStoreIterator cuirass; MWWorld::ContainerStoreIterator greaves; + MWWorld::ContainerStoreIterator leftpauldron; + MWWorld::ContainerStoreIterator rightpauldron; public: NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); From 5e1ac0cca1c8a20095da079065b2fad0aa443fbe Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 14 Apr 2012 20:32:46 -0400 Subject: [PATCH 024/109] Gloves, Gauntlets, Boots, Shoes --- apps/openmw/mwrender/npcanimation.cpp | 71 ++++++++++++++++++++++++++- apps/openmw/mwrender/npcanimation.hpp | 4 ++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 5adb9914d..3a9525949 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -16,6 +16,9 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), helmet(inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)), shirt(inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)), cuirass(inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)), greaves(inv.getSlot(MWWorld::InventoryStore::Slot_Greaves)), leftpauldron(inv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron)), rightpauldron(inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron)), + boots(inv.getSlot(MWWorld::InventoryStore::Slot_Boots)), + leftglove(inv.getSlot(MWWorld::InventoryStore::Slot_LeftGauntlet)), rightglove(inv.getSlot(MWWorld::InventoryStore::Slot_RightGauntlet)), + pants(inv.getSlot(MWWorld::InventoryStore::Slot_Pants)), lclavicle(0), rclavicle(0), rupperArm(0), @@ -197,10 +200,28 @@ void NpcAnimation::updateParts(){ } if(rightpauldron != inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron)){ - leftpauldron = inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron); + rightpauldron = inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron); removePartGroup(MWWorld::InventoryStore::Slot_RightPauldron); apparelChanged = true; + } + if(boots != inv.getSlot(MWWorld::InventoryStore::Slot_Boots)){ + boots = inv.getSlot(MWWorld::InventoryStore::Slot_Boots); + removePartGroup(MWWorld::InventoryStore::Slot_Boots); + apparelChanged = true; + + } + if(leftglove != inv.getSlot(MWWorld::InventoryStore::Slot_LeftGauntlet)){ + leftglove = inv.getSlot(MWWorld::InventoryStore::Slot_LeftGauntlet); + removePartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet); + apparelChanged = true; + + } + if(rightglove != inv.getSlot(MWWorld::InventoryStore::Slot_RightGauntlet)){ + rightglove = inv.getSlot(MWWorld::InventoryStore::Slot_RightGauntlet); + removePartGroup(MWWorld::InventoryStore::Slot_RightGauntlet); + apparelChanged = true; + } if(shirt != inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)){ shirt = inv.getSlot(MWWorld::InventoryStore::Slot_Shirt); @@ -210,6 +231,7 @@ void NpcAnimation::updateParts(){ } if(apparelChanged){ + std::cout << "Modifying stuff\n"; if(robe != inv.end()) { MWWorld::Ptr ptr = *robe; @@ -238,6 +260,7 @@ void NpcAnimation::updateParts(){ addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); } + if(leftpauldron != inv.end()){ const ESM::Armor *armor = (leftpauldron->get())->base; std::vector parts = armor->parts.parts; @@ -250,6 +273,52 @@ void NpcAnimation::updateParts(){ addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); } + if(boots != inv.end()){ + + if(boots->getTypeName() == "struct ESM::Clothing"){ + const ESM::Clothing *clothes = (boots->get())->base; + std::vector parts = clothes->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts); + } + else + { + const ESM::Armor *armor = (boots->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts); + } + + } + if(leftglove != inv.end()){ + + if(leftglove->getTypeName() == "struct ESM::Clothing"){ + const ESM::Clothing *clothes = (leftglove->get())->base; + std::vector parts = clothes->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts); + } + else + { + const ESM::Armor *armor = (leftglove->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts); + } + + } + if(rightglove != inv.end()){ + + if(rightglove->getTypeName() == "struct ESM::Clothing"){ + const ESM::Clothing *clothes = (rightglove->get())->base; + std::vector parts = clothes->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts); + } + else + { + const ESM::Armor *armor = (rightglove->get())->base; + std::vector parts = armor->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts); + } + + } + if(shirt != inv.end()){ const ESM::Clothing *clothes = (shirt->get())->base; std::vector parts = clothes->parts.parts; diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 7785ffc1a..255989d28 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -75,6 +75,10 @@ private: MWWorld::ContainerStoreIterator greaves; MWWorld::ContainerStoreIterator leftpauldron; MWWorld::ContainerStoreIterator rightpauldron; + MWWorld::ContainerStoreIterator boots; + MWWorld::ContainerStoreIterator pants; + MWWorld::ContainerStoreIterator leftglove; + MWWorld::ContainerStoreIterator rightglove; public: NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); From 85ac658cacb03ef53455e57ea7b97f41bbab5c36 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 14 Apr 2012 22:52:05 -0400 Subject: [PATCH 025/109] Adding tons of skin body parts --- apps/openmw/mwrender/npcanimation.cpp | 137 ++++++++++++++++++++++++-- 1 file changed, 130 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 3a9525949..bc134581d 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -205,7 +205,7 @@ void NpcAnimation::updateParts(){ apparelChanged = true; } - if(boots != inv.getSlot(MWWorld::InventoryStore::Slot_Boots)){ + if(!isBeast && boots != inv.getSlot(MWWorld::InventoryStore::Slot_Boots)){ boots = inv.getSlot(MWWorld::InventoryStore::Slot_Boots); removePartGroup(MWWorld::InventoryStore::Slot_Boots); apparelChanged = true; @@ -228,6 +228,12 @@ void NpcAnimation::updateParts(){ removePartGroup(MWWorld::InventoryStore::Slot_Shirt); apparelChanged = true; + } + if(pants != inv.getSlot(MWWorld::InventoryStore::Slot_Pants)){ + pants = inv.getSlot(MWWorld::InventoryStore::Slot_Pants); + removePartGroup(MWWorld::InventoryStore::Slot_Pants); + apparelChanged = true; + } if(apparelChanged){ @@ -273,7 +279,7 @@ void NpcAnimation::updateParts(){ addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); } - if(boots != inv.end()){ + if(!isBeast && boots != inv.end()){ if(boots->getTypeName() == "struct ESM::Clothing"){ const ESM::Clothing *clothes = (boots->get())->base; @@ -324,19 +330,136 @@ void NpcAnimation::updateParts(){ std::vector parts = clothes->parts.parts; addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); } + if(pants != inv.end()){ + const ESM::Clothing *clothes = (pants->get())->base; + std::vector parts = clothes->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts); + } } - if(partpriorities[ESM::PRT_Cuirass] < 1){ - const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); - if(chestPart) - addOrReplaceIndividualPart(ESM::PRT_Cuirass, -1,1,"meshes\\" + chestPart->model); - } if(partpriorities[ESM::PRT_Head] < 1){ addOrReplaceIndividualPart(ESM::PRT_Head, -1,1,headModel); } if(partpriorities[ESM::PRT_Hair] < 1 && partpriorities[ESM::PRT_Head] <= 1){ addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1,hairModel); } + if(partpriorities[ESM::PRT_Neck] < 1){ + const ESM::BodyPart *neckPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck"); + if(neckPart) + addOrReplaceIndividualPart(ESM::PRT_Neck, -1,1,"meshes\\" + neckPart->model); + } + if(partpriorities[ESM::PRT_Cuirass] < 1){ + const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); + if(chestPart) + addOrReplaceIndividualPart(ESM::PRT_Cuirass, -1,1,"meshes\\" + chestPart->model); + } + + if(partpriorities[ESM::PRT_Groin] < 1){ + const ESM::BodyPart *groinPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); + if(groinPart) + addOrReplaceIndividualPart(ESM::PRT_Groin, -1,1,"meshes\\" + groinPart->model); + } + if(partpriorities[ESM::PRT_RHand] < 1){ + const ESM::BodyPart *handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand"); + if(!handPart) + handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands"); + if(handPart) + addOrReplaceIndividualPart(ESM::PRT_RHand, -1,1,"meshes\\" + handPart->model); + } + if(partpriorities[ESM::PRT_LHand] < 1){ + const ESM::BodyPart *handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand"); + if(!handPart) + handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands"); + if(handPart) + addOrReplaceIndividualPart(ESM::PRT_LHand, -1,1,"meshes\\" + handPart->model); + } + + if(partpriorities[ESM::PRT_RWrist] < 1){ + const ESM::BodyPart *wristPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); + if(wristPart) + addOrReplaceIndividualPart(ESM::PRT_RWrist, -1,1,"meshes\\" + wristPart->model); + } + if(partpriorities[ESM::PRT_LWrist] < 1){ + const ESM::BodyPart *wristPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); + if(wristPart) + addOrReplaceIndividualPart(ESM::PRT_LWrist, -1,1,"meshes\\" + wristPart->model); + } + if(partpriorities[ESM::PRT_RForearm] < 1){ + const ESM::BodyPart *forearmPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); + if(bodyRaceID == "b_n_argonian_f_") + forearmPart = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); + if(forearmPart) + addOrReplaceIndividualPart(ESM::PRT_RForearm, -1,1,"meshes\\" + forearmPart->model); + } + if(partpriorities[ESM::PRT_LForearm] < 1){ + const ESM::BodyPart *forearmPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); + if(bodyRaceID == "b_n_argonian_f_") + forearmPart = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); + if(forearmPart) + addOrReplaceIndividualPart(ESM::PRT_LForearm, -1,1,"meshes\\" + forearmPart->model); + } + if(partpriorities[ESM::PRT_RUpperarm] < 1){ + const ESM::BodyPart *armPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); + if(armPart) + addOrReplaceIndividualPart(ESM::PRT_RUpperarm, -1,1,"meshes\\" + armPart->model); + } + if(partpriorities[ESM::PRT_LUpperarm] < 1){ + const ESM::BodyPart *armPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); + if(armPart) + addOrReplaceIndividualPart(ESM::PRT_LUpperarm, -1,1,"meshes\\" + armPart->model); + } + if(partpriorities[ESM::PRT_RFoot] < 1){ + const ESM::BodyPart *footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); + if(isBeast) + footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); + if(footPart) + addOrReplaceIndividualPart(ESM::PRT_RFoot, -1,1,"meshes\\" + footPart->model); + } + if(partpriorities[ESM::PRT_LFoot] < 1){ + const ESM::BodyPart *footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); + if(isBeast) + footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); + if(footPart) + addOrReplaceIndividualPart(ESM::PRT_LFoot, -1,1,"meshes\\" + footPart->model); + } + if(partpriorities[ESM::PRT_RAnkle] < 1){ + const ESM::BodyPart *anklePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); + if(anklePart) + addOrReplaceIndividualPart(ESM::PRT_RAnkle, -1,1,"meshes\\" + anklePart->model); + } + if(partpriorities[ESM::PRT_LAnkle] < 1){ + const ESM::BodyPart *anklePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); + if(anklePart) + addOrReplaceIndividualPart(ESM::PRT_LAnkle, -1,1,"meshes\\" + anklePart->model); + } + if(partpriorities[ESM::PRT_RKnee] < 1){ + const ESM::BodyPart *kneePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); + if(kneePart) + addOrReplaceIndividualPart(ESM::PRT_RKnee, -1,1,"meshes\\" + kneePart->model); + } + if(partpriorities[ESM::PRT_LKnee] < 1){ + const ESM::BodyPart *kneePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); + if(kneePart) + addOrReplaceIndividualPart(ESM::PRT_LKnee, -1,1,"meshes\\" + kneePart->model); + } + if(partpriorities[ESM::PRT_RLeg] < 1){ + const ESM::BodyPart *legPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); + if(legPart) + addOrReplaceIndividualPart(ESM::PRT_RLeg, -1,1,"meshes\\" + legPart->model); + } + if(partpriorities[ESM::PRT_LLeg] < 1){ + const ESM::BodyPart *legPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); + if(legPart) + addOrReplaceIndividualPart(ESM::PRT_LLeg, -1,1,"meshes\\" + legPart->model); + } + if(partpriorities[ESM::PRT_Tail] < 1){ + const ESM::BodyPart *tailPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); + if(tailPart) + addOrReplaceIndividualPart(ESM::PRT_Tail, -1,1,"meshes\\" + tailPart->model); + } + + + From d37bc9cba8d6d9bd9afe07dd48c5981171b812fe Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 15 Apr 2012 17:10:08 +0200 Subject: [PATCH 026/109] basic mouse-over info for in-game objects --- apps/openmw/mwgui/tooltips.cpp | 412 +++++++++++++++++++++++++-- apps/openmw/mwgui/tooltips.hpp | 6 + apps/openmw/mwgui/window_manager.cpp | 5 + apps/openmw/mwgui/window_manager.hpp | 2 + apps/openmw/mwrender/shadows.cpp | 5 +- apps/openmw/mwworld/world.cpp | 12 + files/mygui/openmw_tooltips.xml | 10 +- 7 files changed, 426 insertions(+), 26 deletions(-) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index d7c61c51a..7f45bdbdd 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -6,6 +6,7 @@ using namespace MyGUI; ToolTips::ToolTips() : Layout("openmw_tooltips.xml") , mGameMode(true) + , mFocusChanged(true) { getWidget(mTextToolTip, "TextToolTip"); getWidget(mTextToolTipBox, "TextToolTipBox"); @@ -27,29 +28,389 @@ void ToolTips::onFrame(float frameDuration) const IntSize &viewSize = RenderManager::getInstance().getViewSize(); - Widget* focus = InputManager::getInstance().getMouseFocusWidget(); - if (focus == 0) return; - - // this the maximum width of the tooltip before it starts word-wrapping - setCoord(0, 0, 300, 300); - - mTextToolTip->setCaption("Focused: " + focus->getName() + "\nType: " + focus->getTypeName()); - const IntSize &textSize = mTextToolTip->getTextSize(); - - IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24); - - IntSize size = textSize + IntSize(12, 12); - // make the tooltip stay completely in the viewport - if ((tooltipPosition.left + size.width) > viewSize.width) + if (!mGameMode) { - tooltipPosition.left = viewSize.width - size.width; - } - if ((tooltipPosition.top + size.height) > viewSize.height) - { - tooltipPosition.top = viewSize.height - size.height; - } + mDynamicToolTipBox->setVisible(false); - setCoord(tooltipPosition.left, tooltipPosition.top, size.width, size.height); + Widget* focus = InputManager::getInstance().getMouseFocusWidget(); + if (focus == 0) return; + + // this the maximum width of the tooltip before it starts word-wrapping + setCoord(0, 0, 300, 300); + + mTextToolTip->setCaption("Focused: " + focus->getName() + "\nType: " + focus->getTypeName()); + const IntSize &textSize = mTextToolTip->getTextSize(); + + IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24); + + IntSize size = textSize + IntSize(12, 12); + // make the tooltip stay completely in the viewport + if ((tooltipPosition.left + size.width) > viewSize.width) + { + tooltipPosition.left = viewSize.width - size.width; + } + if ((tooltipPosition.top + size.height) > viewSize.height) + { + tooltipPosition.top = viewSize.height - size.height; + } + + setCoord(tooltipPosition.left, tooltipPosition.top, size.width, size.height); + } + else + { + mTextToolTipBox->setVisible(false); + + if (!mFocusObject.isEmpty()) + { + if (mFocusChanged) + { + for (size_t i=0; igetChildCount(); ++i) + { + mDynamicToolTipBox->_destroyChildWidget(mDynamicToolTipBox->getChildAt(i)); + } + + // this the maximum width of the tooltip before it starts word-wrapping + setCoord(0, 0, 300, 300); + + IntSize tooltipSize; + + /// \todo Not sure about levelled lists (ESM::CreateLevList and ESM::ItemLevList). I think + /// they are supposed to spawn a concrete object (Creature or item of any type), so + /// the player wouldn't encounter them and we don't have to handle them here. + + // -------------------- Door ------------------------------- + if (mFocusObject.getTypeName() == typeid(ESM::Door).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setProperty("MultiLine", "true"); + + std::string caption = ref->base->name; + /// \todo If destCell is empty, the teleport target is an exterior cell. In that case we + /// need to fetch that cell (via target position) and retrieve the region name. + if (ref->ref.teleport && (ref->ref.destCell != "")) + { + caption += "\n-"; + caption += "\n"+ref->ref.destCell; + } + box->setCaption(caption); + + /// \todo Lock level, trap (retrieve GMST) + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- NPC ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::NPC).name()) + { + /// \todo We don't want tooltips for NPCs in combat mode. + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Creature ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Creature).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- CreatureLevList ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Creature).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Container ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Container).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo Lock level, trap (retrieve GMST) + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Potion ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Potion).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Apparatus ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Apparatus).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Armor ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Armor).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo weight, armor value, value, durability.. + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Book ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Book).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Clothing ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Clothing).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Ingredient ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Ingredient).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Light ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Light).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(ref->base->name != ""); + } + + // -------------------- Tool ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Tool).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Miscellaneous ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Miscellaneous).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Probe ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Probe).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Repair ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Repair).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Weapon ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Weapon).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(true); + } + + // -------------------- Activator ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Activator).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setCaption(ref->base->name); + + /// \todo + + tooltipSize = box->getTextSize() + IntSize(12,12); + + mDynamicToolTipBox->setVisible(ref->base->name != ""); + } + + else + { + // object without tooltip + mDynamicToolTipBox->setVisible(false); + } + + // adjust tooltip size to fit its content, position it above the crosshair + /// \todo Slide the tooltip along the bounding box of the focused object (like in Morrowind) + setCoord(viewSize.width/2 - (tooltipSize.width)/2.f, + viewSize.height/2 - (tooltipSize.height) - 32, + tooltipSize.width, + tooltipSize.height); + } + mFocusChanged = false; + } + else + mDynamicToolTipBox->setVisible(false); + } } void ToolTips::enterGameMode() @@ -61,3 +422,12 @@ void ToolTips::enterGuiMode() { mGameMode = false; } + +void ToolTips::setFocusObject(const MWWorld::Ptr& focus) +{ + if (focus != mFocusObject) + { + mFocusObject = focus; + mFocusChanged = true; + } +} diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index aa929ff51..3052abb7a 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -3,6 +3,7 @@ #define MWGUI_TOOLTIPS_H #include +#include "../mwworld/ptr.hpp" namespace MWGui { @@ -16,6 +17,8 @@ namespace MWGui void enterGameMode(); void enterGuiMode(); + void setFocusObject(const MWWorld::Ptr& focus); + void adjustScreen(int screenWidth, int screenHeight); private: @@ -24,6 +27,9 @@ namespace MWGui MyGUI::Widget* mDynamicToolTipBox; + MWWorld::Ptr mFocusObject; + bool mFocusChanged; + bool mGameMode; }; } diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 1ef5cae42..909be0ac2 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -492,3 +492,8 @@ int WindowManager::toggleFps() Settings::Manager::setInt("fps", "HUD", showFPSLevel); return showFPSLevel; } + +void WindowManager::setFocusObject(const MWWorld::Ptr& focus) +{ + mToolTips->setFocusObject(focus); +} diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 1cbd8f6a6..d5f0683b8 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -158,6 +158,8 @@ namespace MWGui void setPlayerPos(const float x, const float y); ///< set player position in map space void setPlayerDir(const float x, const float y); ///< set player view direction in map space + void setFocusObject(const MWWorld::Ptr& focus); + void toggleFogOfWar(); int toggleFps(); diff --git a/apps/openmw/mwrender/shadows.cpp b/apps/openmw/mwrender/shadows.cpp index bf5602f43..9a4ae7243 100644 --- a/apps/openmw/mwrender/shadows.cpp +++ b/apps/openmw/mwrender/shadows.cpp @@ -66,7 +66,10 @@ void Shadows::recreate() if (split) { mPSSMSetup = new PSSMShadowCameraSetup(); - mPSSMSetup->setSplitPadding(5); + + // Make sure to keep this in sync with the camera's near clip distance! + mPSSMSetup->setSplitPadding(mRendering->getCamera()->getNearClipDistance()); + mPSSMSetup->calculateSplitPoints(3, mRendering->getCamera()->getNearClipDistance(), mShadowFar); const Real adjustFactors[3] = {64, 64, 64}; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 1c64039d4..4719a25cf 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -13,6 +13,7 @@ #include "../mwsound/soundmanager.hpp" +#include "../mwgui/window_manager.hpp" #include "ptr.hpp" #include "environment.hpp" @@ -737,6 +738,17 @@ namespace MWWorld mWeatherManager->update (duration); + // inform the GUI about focused object + try + { + mEnvironment.mWindowManager->setFocusObject(getPtrViaHandle(mFacedHandle)); + } + catch (std::runtime_error&) + { + MWWorld::Ptr null; + mEnvironment.mWindowManager->setFocusObject(null); + } + if (!mRendering->occlusionQuerySupported()) { // cast a ray from player to sun to detect if the sun is visible diff --git a/files/mygui/openmw_tooltips.xml b/files/mygui/openmw_tooltips.xml index 76df7b9a7..26fc1eeab 100644 --- a/files/mygui/openmw_tooltips.xml +++ b/files/mygui/openmw_tooltips.xml @@ -1,11 +1,12 @@ - + - - + + + @@ -13,7 +14,8 @@ - + + From 1b5d327f7e7ec8d94c7c25baee11cd4252db74be Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 15 Apr 2012 18:56:46 +0200 Subject: [PATCH 027/109] Fixed OS X build with static MyGUI --- cmake/FindFreetype.cmake | 69 ++++++++++++++++++++++++++++++++ cmake/FindMyGUI.cmake | 86 ++++++++++++++++++++++++---------------- 2 files changed, 121 insertions(+), 34 deletions(-) create mode 100644 cmake/FindFreetype.cmake diff --git a/cmake/FindFreetype.cmake b/cmake/FindFreetype.cmake new file mode 100644 index 000000000..fc36d548e --- /dev/null +++ b/cmake/FindFreetype.cmake @@ -0,0 +1,69 @@ +#------------------------------------------------------------------- +# This file is part of the CMake build system for OGRE +# (Object-oriented Graphics Rendering Engine) +# For the latest info, see http://www.ogre3d.org/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + +# - Try to find FreeType +# Once done, this will define +# +# FREETYPE_FOUND - system has FreeType +# FREETYPE_INCLUDE_DIRS - the FreeType include directories +# FREETYPE_LIBRARIES - link these to use FreeType + +include(FindPkgMacros) +findpkg_begin(FREETYPE) + +# Get path, convert backslashes as ${ENV_${var}} +getenv_path(FREETYPE_HOME) + +# construct search paths +set(FREETYPE_PREFIX_PATH ${FREETYPE_HOME} ${ENV_FREETYPE_HOME}) +create_search_paths(FREETYPE) +# redo search if prefix path changed +clear_if_changed(FREETYPE_PREFIX_PATH + FREETYPE_LIBRARY_FWK + FREETYPE_LIBRARY_REL + FREETYPE_LIBRARY_DBG + FREETYPE_INCLUDE_DIR +) + +set(FREETYPE_LIBRARY_NAMES freetype2311 freetype239 freetype238 freetype235 freetype219 freetype) +get_debug_names(FREETYPE_LIBRARY_NAMES) + +use_pkgconfig(FREETYPE_PKGC freetype2) + +# prefer static library over framework +set(CMAKE_FIND_FRAMEWORK "LAST") + +message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") +findpkg_framework(FREETYPE) +message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") + +find_path(FREETYPE_INCLUDE_DIR NAMES freetype/freetype.h HINTS ${FREETYPE_INC_SEARCH_PATH} ${FREETYPE_PKGC_INCLUDE_DIRS} PATH_SUFFIXES freetype2) +find_path(FREETYPE_FT2BUILD_INCLUDE_DIR NAMES ft2build.h HINTS ${FREETYPE_INC_SEARCH_PATH} ${FREETYPE_PKGC_INCLUDE_DIRS}) + +if (SYMBIAN) +set(ORIGINAL_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}) +set(CMAKE_PREFIX_PATH ${CMAKE_SYSYEM_OUT_DIR}) +message(STATUS "Lib will be searched in Symbian out dir: ${CMAKE_SYSYEM_OUT_DIR}") +endif (SYMBIAN) +find_library(FREETYPE_LIBRARY_REL NAMES ${FREETYPE_LIBRARY_NAMES} HINTS ${FREETYPE_LIB_SEARCH_PATH} ${FREETYPE_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel) +find_library(FREETYPE_LIBRARY_DBG NAMES ${FREETYPE_LIBRARY_NAMES_DBG} HINTS ${FREETYPE_LIB_SEARCH_PATH} ${FREETYPE_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug) +if (SYMBIAN) +set(CMAKE_PREFIX_PATH ${ORIGINAL_CMAKE_PREFIX_PATH}) +endif (SYMBIAN) + +make_library_set(FREETYPE_LIBRARY) + +findpkg_finish(FREETYPE) +mark_as_advanced(FREETYPE_FT2BUILD_INCLUDE_DIR) +if (NOT FREETYPE_FT2BUILD_INCLUDE_DIR STREQUAL FREETYPE_INCLUDE_DIR) + set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS} ${FREETYPE_FT2BUILD_INCLUDE_DIR}) +endif () + +# Reset framework finding +set(CMAKE_FIND_FRAMEWORK "FIRST") diff --git a/cmake/FindMyGUI.cmake b/cmake/FindMyGUI.cmake index 6731d584c..dbcf8f11c 100644 --- a/cmake/FindMyGUI.cmake +++ b/cmake/FindMyGUI.cmake @@ -82,37 +82,49 @@ findpkg_finish ( "MYGUI" ) ELSE (WIN32) #Unix CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR) FIND_PACKAGE(PkgConfig) - IF(MYGUI_STATIC) - PKG_SEARCH_MODULE(MYGUI MYGUIStatic MyGUIStatic) - IF (MYGUI_INCLUDE_DIRS) - SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS}) - SET(MYGUI_LIB_DIR ${MYGUI_LIBDIR}) - SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "") - SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") - ELSE (MYGUI_INCLUDE_DIRS) - FIND_PATH(MYGUI_INCLUDE_DIRS MyGUI.h PATHS /usr/local/include /usr/include PATH_SUFFIXES MyGUI MYGUI) - FIND_LIBRARY(MYGUI_LIBRARIES myguistatic PATHS /usr/lib /usr/local/lib) - SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") - SET(MYGUI_LIB_DIR ${MYGUI_LIBRARIES}) - STRING(REGEX REPLACE "(.*)/.*" "\\1" MYGUI_LIB_DIR "${MYGUI_LIB_DIR}") - STRING(REGEX REPLACE ".*/" "" MYGUI_LIBRARIES "${MYGUI_LIBRARIES}") - ENDIF (MYGUI_INCLUDE_DIRS) - ELSE(MYGUI_STATIC) - PKG_SEARCH_MODULE(MYGUI MYGUI MyGUI) - IF (MYGUI_INCLUDE_DIRS) - SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS}) - SET(MYGUI_LIB_DIR ${MYGUI_LIBDIR}) - SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "") - SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") - ELSE (MYGUI_INCLUDE_DIRS) - FIND_PATH(MYGUI_INCLUDE_DIRS MyGUI.h PATHS /usr/local/include /usr/include PATH_SUFFIXES MyGUI MYGUI) - FIND_LIBRARY(MYGUI_LIBRARIES mygui PATHS /usr/lib /usr/local/lib) - SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") - SET(MYGUI_LIB_DIR ${MYGUI_LIBRARIES}) - STRING(REGEX REPLACE "(.*)/.*" "\\1" MYGUI_LIB_DIR "${MYGUI_LIB_DIR}") - STRING(REGEX REPLACE ".*/" "" MYGUI_LIBRARIES "${MYGUI_LIBRARIES}") - ENDIF (MYGUI_INCLUDE_DIRS) - ENDIF(MYGUI_STATIC) + IF(MYGUI_STATIC) + # don't use pkgconfig on OS X, find freetype & append it's libs to resulting MYGUI_LIBRARIES + IF (NOT APPLE) + PKG_SEARCH_MODULE(MYGUI MYGUIStatic MyGUIStatic) + IF (MYGUI_INCLUDE_DIRS) + SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS}) + SET(MYGUI_LIB_DIR ${MYGUI_LIBDIR}) + SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "") + SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") + ELSE (MYGUI_INCLUDE_DIRS) + FIND_PATH(MYGUI_INCLUDE_DIRS MyGUI.h PATHS /usr/local/include /usr/include PATH_SUFFIXES MyGUI MYGUI) + FIND_LIBRARY(MYGUI_LIBRARIES myguistatic PATHS /usr/lib /usr/local/lib) + SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") + SET(MYGUI_LIB_DIR ${MYGUI_LIBRARIES}) + STRING(REGEX REPLACE "(.*)/.*" "\\1" MYGUI_LIB_DIR "${MYGUI_LIB_DIR}") + STRING(REGEX REPLACE ".*/" "" MYGUI_LIBRARIES "${MYGUI_LIBRARIES}") + ENDIF (MYGUI_INCLUDE_DIRS) + ELSE (NOT APPLE) + SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${MYGUI_DEPENDENCIES_DIR} ${OGRE_DEPENDENCIES_DIR}) + FIND_PACKAGE(freetype) + FIND_PATH(MYGUI_INCLUDE_DIRS MyGUI.h PATHS /usr/local/include /usr/include PATH_SUFFIXES MyGUI MYGUI) + FIND_LIBRARY(MYGUI_LIBRARIES MyGUIEngineStatic PATHS /usr/lib /usr/local/lib) + SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") + SET(MYGUI_LIB_DIR ${MYGUI_LIBRARIES}) + STRING(REGEX REPLACE "(.*)/.*" "\\1" MYGUI_LIB_DIR "${MYGUI_LIB_DIR}") + STRING(REGEX REPLACE ".*/" "" MYGUI_LIBRARIES "${MYGUI_LIBRARIES}") + ENDIF (NOT APPLE) + ELSE(MYGUI_STATIC) + PKG_SEARCH_MODULE(MYGUI MYGUI MyGUI) + IF (MYGUI_INCLUDE_DIRS) + SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS}) + SET(MYGUI_LIB_DIR ${MYGUI_LIBDIR}) + SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "") + SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") + ELSE (MYGUI_INCLUDE_DIRS) + FIND_PATH(MYGUI_INCLUDE_DIRS MyGUI.h PATHS /usr/local/include /usr/include PATH_SUFFIXES MyGUI MYGUI) + FIND_LIBRARY(MYGUI_LIBRARIES mygui PATHS /usr/lib /usr/local/lib) + SET(MYGUI_PLATFORM_LIBRARIES "MyGUI.OgrePlatform") + SET(MYGUI_LIB_DIR ${MYGUI_LIBRARIES}) + STRING(REGEX REPLACE "(.*)/.*" "\\1" MYGUI_LIB_DIR "${MYGUI_LIB_DIR}") + STRING(REGEX REPLACE ".*/" "" MYGUI_LIBRARIES "${MYGUI_LIBRARIES}") + ENDIF (MYGUI_INCLUDE_DIRS) + ENDIF(MYGUI_STATIC) ENDIF (WIN32) #Do some preparation @@ -120,17 +132,23 @@ SEPARATE_ARGUMENTS(MYGUI_INCLUDE_DIRS) SEPARATE_ARGUMENTS(MYGUI_LIBRARIES) SEPARATE_ARGUMENTS(MYGUI_PLATFORM_LIBRARIES) +SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} ${FREETYPE_LIBRARIES}) + SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS} CACHE PATH "") SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "") SET(MYGUI_PLATFORM_LIBRARIES ${MYGUI_PLATFORM_LIBRARIES} CACHE STRING "") SET(MYGUI_LIB_DIR ${MYGUI_LIB_DIR} CACHE PATH "") -IF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES) +IF (NOT APPLE OR NOT MYGUI_STATIC) # we need freetype libs only on OS X for static build, for other cases just make it TRUE + SET(FREETYPE_LIBRARIES TRUE) +ENDIF (NOT APPLE OR NOT MYGUI_STATIC) + +IF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES AND FREETYPE_LIBRARIES) SET(MYGUI_FOUND TRUE) -ENDIF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES) +ENDIF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES AND FREETYPE_LIBRARIES) IF (MYGUI_FOUND) -MARK_AS_ADVANCED(MYGUI_LIB_DIR) + MARK_AS_ADVANCED(MYGUI_LIB_DIR) IF (NOT MYGUI_FIND_QUIETLY) MESSAGE(STATUS " libraries : ${MYGUI_LIBRARIES} from ${MYGUI_LIB_DIR}") MESSAGE(STATUS " includes : ${MYGUI_INCLUDE_DIRS}") From bc8bb9c57ead538e4568f629b68b40863804c0be Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 15 Apr 2012 14:22:55 -0400 Subject: [PATCH 028/109] Reserve; skirts --- apps/openmw/mwrender/animation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index d0019154e..5755418e2 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -303,8 +303,8 @@ namespace MWRender{ for(; boneSequenceIter != boneSequence.end(); boneSequenceIter++) { - if(creaturemodel->getSkeleton()->hasBone(*boneSequenceIter)){ - Ogre::Bone *bonePtr = creaturemodel->getSkeleton()->getBone(*boneSequenceIter); + if(skel->hasBone(*boneSequenceIter)){ + Ogre::Bone *bonePtr = skel->getBone(*boneSequenceIter); // Computes C = B + AxC*scale transmult = transmult + rotmult * bonePtr->getPosition(); rotmult = rotmult * bonePtr->getOrientation(); From 705d4c6d54f94bad23fdf07efedc5842f73322de Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 15 Apr 2012 21:14:14 +0200 Subject: [PATCH 029/109] mostly complete --- apps/openmw/mwgui/stats_window.cpp | 16 +- apps/openmw/mwgui/stats_window.hpp | 2 +- apps/openmw/mwgui/tooltips.cpp | 720 ++++++++++++++------------- apps/openmw/mwgui/tooltips.hpp | 24 +- apps/openmw/mwgui/window_manager.cpp | 2 +- files/mygui/openmw_tooltips.xml | 2 +- 6 files changed, 406 insertions(+), 360 deletions(-) diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 675e5141f..23f93cd1b 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -251,14 +251,18 @@ void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, My coord2.top += lineHeight; } -MyGUI::TextBox* StatsWindow::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) +MyGUI::TextBox* StatsWindow::addValueItem(const std::string text, const std::string& tooltip, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { MyGUI::TextBox *skillNameWidget, *skillValueWidget; skillNameWidget = skillClientWidget->createWidget("SandText", coord1, MyGUI::Align::Default); skillNameWidget->setCaption(text); + skillNameWidget->setUserString("ToolTipType", "Text"); + skillNameWidget->setUserString("ToolTipText", tooltip); skillValueWidget = skillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Default); + skillValueWidget->setUserString("ToolTipType", "Text"); + skillValueWidget->setUserString("ToolTipText", tooltip); setStyledText(skillValueWidget, style, value); skillWidgets.push_back(skillNameWidget); @@ -310,7 +314,7 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, style = CS_Super; else if (modified < base) style = CS_Sub; - MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast(static_cast(modified)), style, coord1, coord2); + MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), "", boost::lexical_cast(static_cast(modified)), style, coord1, coord2); skillWidgetMap[skillId] = widget; } } @@ -369,8 +373,12 @@ void StatsWindow::updateSkillArea() if (!skillWidgets.empty()) addSeparator(coord1, coord2); - addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"), boost::lexical_cast(static_cast(reputation)), CS_Normal, coord1, coord2); - addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"), boost::lexical_cast(static_cast(bounty)), CS_Normal, coord1, coord2); + addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"), + mWindowManager.getGameSettingString("sSkillsMenuReputationHelp", ""), + boost::lexical_cast(static_cast(reputation)), CS_Normal, coord1, coord2); + addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"), + mWindowManager.getGameSettingString("sCrimeHelp", ""), + boost::lexical_cast(static_cast(bounty)), CS_Normal, coord1, coord2); clientHeight = coord1.top; updateScroller(); diff --git a/apps/openmw/mwgui/stats_window.hpp b/apps/openmw/mwgui/stats_window.hpp index f2731e545..1ce3db98d 100644 --- a/apps/openmw/mwgui/stats_window.hpp +++ b/apps/openmw/mwgui/stats_window.hpp @@ -53,7 +53,7 @@ namespace MWGui void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); - MyGUI::TextBox* addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); + MyGUI::TextBox* addValueItem(const std::string text, const std::string& tooltip, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void updateScroller(); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 7f45bdbdd..4c435e3bf 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -1,12 +1,15 @@ #include "tooltips.hpp" +#include "window_manager.hpp" + +#include using namespace MWGui; using namespace MyGUI; -ToolTips::ToolTips() : +ToolTips::ToolTips(WindowManager* windowManager) : Layout("openmw_tooltips.xml") , mGameMode(true) - , mFocusChanged(true) + , mWindowManager(windowManager) { getWidget(mTextToolTip, "TextToolTip"); getWidget(mTextToolTipBox, "TextToolTipBox"); @@ -31,19 +34,32 @@ void ToolTips::onFrame(float frameDuration) if (!mGameMode) { mDynamicToolTipBox->setVisible(false); + mTextToolTipBox->setVisible(true); Widget* focus = InputManager::getInstance().getMouseFocusWidget(); - if (focus == 0) return; + if (focus == 0) + { + mTextToolTipBox->setVisible(false); + return; + } + + std::string type = focus->getUserString("ToolTipType"); + std::string text = focus->getUserString("ToolTipText"); + if (type == "" || text == "") + { + mTextToolTipBox->setVisible(false); + return; + } // this the maximum width of the tooltip before it starts word-wrapping setCoord(0, 0, 300, 300); - mTextToolTip->setCaption("Focused: " + focus->getName() + "\nType: " + focus->getTypeName()); + mTextToolTip->setCaption(text); const IntSize &textSize = mTextToolTip->getTextSize(); IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24); - IntSize size = textSize + IntSize(12, 12); + IntSize size = textSize + IntSize(6, 6); // make the tooltip stay completely in the viewport if ((tooltipPosition.left + size.width) > viewSize.width) { @@ -62,351 +78,16 @@ void ToolTips::onFrame(float frameDuration) if (!mFocusObject.isEmpty()) { - if (mFocusChanged) - { - for (size_t i=0; igetChildCount(); ++i) - { - mDynamicToolTipBox->_destroyChildWidget(mDynamicToolTipBox->getChildAt(i)); - } + IntSize tooltipSize = getToolTipViaPtr(); - // this the maximum width of the tooltip before it starts word-wrapping - setCoord(0, 0, 300, 300); + tooltipSize += IntSize(6,6); // padding, adjust for skin - IntSize tooltipSize; - - /// \todo Not sure about levelled lists (ESM::CreateLevList and ESM::ItemLevList). I think - /// they are supposed to spawn a concrete object (Creature or item of any type), so - /// the player wouldn't encounter them and we don't have to handle them here. - - // -------------------- Door ------------------------------- - if (mFocusObject.getTypeName() == typeid(ESM::Door).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setProperty("MultiLine", "true"); - - std::string caption = ref->base->name; - /// \todo If destCell is empty, the teleport target is an exterior cell. In that case we - /// need to fetch that cell (via target position) and retrieve the region name. - if (ref->ref.teleport && (ref->ref.destCell != "")) - { - caption += "\n-"; - caption += "\n"+ref->ref.destCell; - } - box->setCaption(caption); - - /// \todo Lock level, trap (retrieve GMST) - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- NPC ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::NPC).name()) - { - /// \todo We don't want tooltips for NPCs in combat mode. - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Creature ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Creature).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- CreatureLevList ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Creature).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Container ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Container).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo Lock level, trap (retrieve GMST) - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Potion ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Potion).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Apparatus ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Apparatus).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Armor ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Armor).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo weight, armor value, value, durability.. - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Book ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Book).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Clothing ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Clothing).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Ingredient ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Ingredient).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Light ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Light).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(ref->base->name != ""); - } - - // -------------------- Tool ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Tool).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Miscellaneous ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Miscellaneous).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Probe ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Probe).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Repair ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Repair).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Weapon ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Weapon).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(true); - } - - // -------------------- Activator ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Activator).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - EditBox* box = mDynamicToolTipBox->createWidget("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setCaption(ref->base->name); - - /// \todo - - tooltipSize = box->getTextSize() + IntSize(12,12); - - mDynamicToolTipBox->setVisible(ref->base->name != ""); - } - - else - { - // object without tooltip - mDynamicToolTipBox->setVisible(false); - } - - // adjust tooltip size to fit its content, position it above the crosshair - /// \todo Slide the tooltip along the bounding box of the focused object (like in Morrowind) - setCoord(viewSize.width/2 - (tooltipSize.width)/2.f, - viewSize.height/2 - (tooltipSize.height) - 32, - tooltipSize.width, - tooltipSize.height); - } - mFocusChanged = false; + // adjust tooltip size to fit its content, position it above the crosshair + /// \todo Slide the tooltip along the bounding box of the focused object (like in Morrowind) + setCoord(viewSize.width/2 - (tooltipSize.width)/2.f, + viewSize.height/2 - (tooltipSize.height) - 32, + tooltipSize.width, + tooltipSize.height); } else mDynamicToolTipBox->setVisible(false); @@ -425,9 +106,346 @@ void ToolTips::enterGuiMode() void ToolTips::setFocusObject(const MWWorld::Ptr& focus) { - if (focus != mFocusObject) + mFocusObject = focus; +} + +IntSize ToolTips::getToolTipViaPtr () +{ + /// \todo we are destroying/creating the tooltip widgets every frame here, + /// because the tooltip might change (e.g. when trap is activated) + /// is there maybe a better way (listener when the object changes)? + for (size_t i=0; igetChildCount(); ++i) { - mFocusObject = focus; - mFocusChanged = true; + mDynamicToolTipBox->_destroyChildWidget(mDynamicToolTipBox->getChildAt(i)); + } + + // this the maximum width of the tooltip before it starts word-wrapping + setCoord(0, 0, 300, 300); + + IntSize tooltipSize; + + // -------------------- Door ------------------------------- + if (mFocusObject.getTypeName() == typeid(ESM::Door).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + std::string text; + /// \todo If destCell is empty, the teleport target is an exterior cell. In that case we + /// need to fetch that cell (via target position) and retrieve the region name. + if (ref->ref.teleport && (ref->ref.destCell != "")) + { + text += "\n" + mWindowManager->getGameSettingString("sTo", "to"); + text += "\n"+ref->ref.destCell; + } + + if (ref->ref.lockLevel > 0) + text += "\n" + mWindowManager->getGameSettingString("sLockLevel", "Lock") + ": " + toString(ref->ref.lockLevel); + if (ref->ref.trap != "") + text += "\n" + mWindowManager->getGameSettingString("sTrapped", "Trapped!"); + + tooltipSize = createToolTip(ref->base->name, text); + } + + // -------------------- NPC ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::NPC).name()) + { + /// \todo We don't want tooltips for NPCs in combat mode. + ESMS::LiveCellRef* ref = mFocusObject.get(); + + tooltipSize = createToolTip(ref->base->name, ""); + } + + // -------------------- Creature ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Creature).name()) + { + /// \todo We don't want tooltips for Creatures in combat mode. + ESMS::LiveCellRef* ref = mFocusObject.get(); + + tooltipSize = createToolTip(ref->base->name, ""); + } + + // -------------------- Container ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Container).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + std::string text; + + if (ref->ref.lockLevel > 0) + text += "\n" + mWindowManager->getGameSettingString("sLockLevel", "Lock") + ": " + toString(ref->ref.lockLevel); + if (ref->ref.trap != "") + text += "\n" + mWindowManager->getGameSettingString("sTrapped", "Trapped!"); + + tooltipSize = createToolTip(ref->base->name, text); + } + + // -------------------- Potion ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Potion).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + /// \todo magic effects + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + } + + // -------------------- Apparatus ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Apparatus).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality); + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + } + + // -------------------- Armor ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Armor).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + /// \todo magic effects, armor type (medium/light/heavy) + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sArmorRating", "Armor Rating") + ": " + toString(ref->base->data.armor); + + /// \todo where is the current armor health stored? + //text += "\n" + mWindowManager->getGameSettingString("sCondition", "Condition") + ": " + toString(ref->base->data.health); + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + } + + // -------------------- Book ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Book).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + } + + // -------------------- Clothing ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Clothing).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + /// \todo magic effects + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + } + + // -------------------- Ingredient ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Ingredient).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + /// \todo magic effects + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + } + + // -------------------- Light ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Light).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + } + + // -------------------- Tool ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Tool).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses); + text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality); + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + } + + // -------------------- Miscellaneous ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Miscellaneous).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + } + + // -------------------- Probe ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Probe).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses); + text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality); + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + } + + // -------------------- Repair ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Repair).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses); + text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality); + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + } + + // -------------------- Weapon ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Weapon).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + /// \todo weapon damage, magic effects, health (condition) + + std::string text; + text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); + text += getValueString(ref->base->data.value); + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, ""); + } + + // -------------------- Activator ------------------------------- + else if (mFocusObject.getTypeName() == typeid(ESM::Activator).name()) + { + ESMS::LiveCellRef* ref = mFocusObject.get(); + + tooltipSize = createToolTip(ref->base->name, ""); + } + + else + { + // object without tooltip + mDynamicToolTipBox->setVisible(false); + } + + return tooltipSize; +} + +void ToolTips::findImageExtension(std::string& image) +{ + int len = image.size(); + if (len < 4) return; + + if (!Ogre::ResourceGroupManager::getSingleton().resourceExists(Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, image)) + { + // Change texture extension to .dds + image[len-3] = 'd'; + image[len-2] = 'd'; + image[len-1] = 's'; } } + +IntSize ToolTips::createImageToolTip(const std::string& caption, const std::string& image, const std::string& text) +{ + // remove the first newline (easier this way) + std::string realText = text; + if (realText.size() > 0) + realText.erase(0, 1); + + std::string realImage = "icons\\" + image; + findImageExtension(realImage); + + const int imageSize = 32; + + EditBox* captionWidget = mDynamicToolTipBox->createWidget("NormalText", IntCoord(0, 0, 300, 300), Align::Left | Align::Top, "ToolTipCaption"); + captionWidget->setProperty("Static", "true"); + captionWidget->setCaption(caption); + EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", IntCoord(0, imageSize, 300, 262), Align::Stretch, "ToolTipText"); + textWidget->setProperty("Static", "true"); + textWidget->setProperty("MultiLine", "true"); + textWidget->setCaption(realText); + textWidget->setTextAlign(Align::HCenter); + + IntSize captionSize = captionWidget->getTextSize(); + IntSize textSize = textWidget->getTextSize(); + + captionSize += IntSize(imageSize, 0); // adjust for image + IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width), ((realText != "") ? textSize.height : 0) + imageSize ); + + ImageBox* imageWidget = mDynamicToolTipBox->createWidget("ImageBox", + IntCoord((totalSize.width - captionSize.width)/2, 0, imageSize, imageSize), + Align::Left | Align::Top, "ToolTipImage"); + imageWidget->setImageTexture(realImage); + + captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize, (32-captionSize.height)/2, captionSize.width-imageSize, captionSize.height); + + mDynamicToolTipBox->setVisible(caption != ""); + + return totalSize; +} + +IntSize ToolTips::createToolTip(const std::string& caption, const std::string& text) +{ + // remove the first newline (easier this way) + std::string realText = text; + if (realText.size() > 0) + realText.erase(0, 1); + + EditBox* box = mDynamicToolTipBox->createWidget("NormalText", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setProperty("MultiLine", "true"); + box->setCaption(caption + (realText != "" ? "\n#BF9959" + realText : "")); + + mDynamicToolTipBox->setVisible(caption != ""); + + return box->getTextSize(); +} + +std::string ToolTips::toString(const float value) +{ + std::ostringstream stream; + stream << std::setprecision(3) << value; + return stream.str(); +} + +std::string ToolTips::toString(const int value) +{ + std::ostringstream stream; + stream << value; + return stream.str(); +} + +std::string ToolTips::getValueString(const int value) +{ + if (value == 0) + return ""; + else + return "\n" + mWindowManager->getGameSettingString("sValue", "Value") + ": " + toString(value); +} diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index 3052abb7a..cb1af7349 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -7,10 +7,12 @@ namespace MWGui { + class WindowManager; + class ToolTips : public OEngine::GUI::Layout { public: - ToolTips(); + ToolTips(WindowManager* windowManager); void onFrame(float frameDuration); @@ -27,8 +29,26 @@ namespace MWGui MyGUI::Widget* mDynamicToolTipBox; + WindowManager* mWindowManager; + MWWorld::Ptr mFocusObject; - bool mFocusChanged; + + void findImageExtension(std::string& image); + + MyGUI::IntSize getToolTipViaPtr (); + ///< @return requested tooltip size + + MyGUI::IntSize createImageToolTip(const std::string& caption, const std::string& image, const std::string& text); + ///< @return requested tooltip size + + MyGUI::IntSize createToolTip(const std::string& caption, const std::string& text); + ///< @return requested tooltip size + + std::string getValueString(const int value); + ///< get "Value: X" string or "" if value is 0 + + std::string toString(const float value); + std::string toString(const int value); bool mGameMode; }; diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 909be0ac2..8ed2050cc 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -82,7 +82,7 @@ WindowManager::WindowManager(MWWorld::Environment& environment, mJournal = new JournalWindow(*this); mMessageBoxManager = new MessageBoxManager(this); dialogueWindow = new DialogueWindow(*this,environment); - mToolTips = new ToolTips(); + mToolTips = new ToolTips(this); // The HUD is always on hud->setVisible(true); diff --git a/files/mygui/openmw_tooltips.xml b/files/mygui/openmw_tooltips.xml index 26fc1eeab..1d55bd12f 100644 --- a/files/mygui/openmw_tooltips.xml +++ b/files/mygui/openmw_tooltips.xml @@ -6,7 +6,7 @@ - + From 65c9cf565c70c4c49cbe484df96811c6e214fb28 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 15 Apr 2012 15:16:48 -0400 Subject: [PATCH 030/109] Skirt and robe part blanking --- apps/openmw/mwrender/npcanimation.cpp | 78 +++++++++++++++++++-------- apps/openmw/mwrender/npcanimation.hpp | 7 ++- 2 files changed, 61 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index bc134581d..2f8763549 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -13,12 +13,12 @@ NpcAnimation::~NpcAnimation(){ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), - robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), helmet(inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)), shirt(inv.getSlot(MWWorld::InventoryStore::Slot_Shirt)), - cuirass(inv.getSlot(MWWorld::InventoryStore::Slot_Cuirass)), greaves(inv.getSlot(MWWorld::InventoryStore::Slot_Greaves)), - leftpauldron(inv.getSlot(MWWorld::InventoryStore::Slot_LeftPauldron)), rightpauldron(inv.getSlot(MWWorld::InventoryStore::Slot_RightPauldron)), - boots(inv.getSlot(MWWorld::InventoryStore::Slot_Boots)), - leftglove(inv.getSlot(MWWorld::InventoryStore::Slot_LeftGauntlet)), rightglove(inv.getSlot(MWWorld::InventoryStore::Slot_RightGauntlet)), - pants(inv.getSlot(MWWorld::InventoryStore::Slot_Pants)), + robe(inv.end()), helmet(inv.end()), shirt(inv.end()), + cuirass(inv.end()), greaves(inv.end()), + leftpauldron(inv.end()), rightpauldron(inv.end()), + boots(inv.end()), + leftglove(inv.end()), rightglove(inv.end()), skirtiter(inv.end()), + pants(inv.end()), lclavicle(0), rclavicle(0), rupperArm(0), @@ -74,8 +74,13 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O // vector = Ogre::Vector3(1,1,-1); - hairID = ref->base->hair; - headID = ref->base->head; + std::string hairID = ref->base->hair; + std::string headID = ref->base->head; + headModel = "meshes\\" + + mEnvironment.mWorld->getStore().bodyParts.find(headID)->model; + + hairModel = "meshes\\" + + mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; npcName = ref->base->name; //ESMStore::Races r = const ESM::Race* race = mEnvironment.mWorld->getStore().races.find(ref->base->race); @@ -159,11 +164,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O } void NpcAnimation::updateParts(){ - std::string headModel = "meshes\\" + - mEnvironment.mWorld->getStore().bodyParts.find(headID)->model; - - std::string hairModel = "meshes\\" + - mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; + bool apparelChanged = false; @@ -173,8 +174,12 @@ void NpcAnimation::updateParts(){ removePartGroup(MWWorld::InventoryStore::Slot_Robe); robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe); apparelChanged = true; - - + } + if(skirtiter != inv.getSlot(MWWorld::InventoryStore::Slot_Skirt)){ + //A robe was added or removed + removePartGroup(MWWorld::InventoryStore::Slot_Skirt); + skirtiter = inv.getSlot(MWWorld::InventoryStore::Slot_Skirt); + apparelChanged = true; } if(helmet != inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)){ apparelChanged = true; @@ -237,7 +242,6 @@ void NpcAnimation::updateParts(){ } if(apparelChanged){ - std::cout << "Modifying stuff\n"; if(robe != inv.end()) { MWWorld::Ptr ptr = *robe; @@ -245,6 +249,29 @@ void NpcAnimation::updateParts(){ const ESM::Clothing *clothes = (ptr.get())->base; std::vector parts = clothes->parts.parts; addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts); + reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_Skirt, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_RLeg, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_RUpperarm, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_LUpperarm, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_RKnee, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_LKnee, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_RForearm, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_LForearm, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_RPauldron, MWWorld::InventoryStore::Slot_Robe, 5); + reserveIndividualPart(ESM::PRT_LPauldron, MWWorld::InventoryStore::Slot_Robe, 5); + } + if(skirtiter != inv.end()) + { + MWWorld::Ptr ptr = *skirtiter; + + const ESM::Clothing *clothes = (ptr.get())->base; + std::vector parts = clothes->parts.parts; + addPartGroup(MWWorld::InventoryStore::Slot_Skirt, 4, parts); + reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Skirt, 4); + reserveIndividualPart(ESM::PRT_RLeg, MWWorld::InventoryStore::Slot_Skirt, 4); + reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Skirt, 4); } if(helmet != inv.end()){ @@ -489,7 +516,6 @@ std::pair*> NpcAnimation::insert std::vector* shape = ((NIFLoader::getSingletonPtr())->getShapes(mesh + "0000" + suffix)); if(shape){ - handleShapes(shape, part, base->getSkeleton()); } std::pair*> pair = std::make_pair(part, shape); @@ -541,8 +567,9 @@ void NpcAnimation::runAnimation(float timepassed){ handleShapes(chest.second, chest.first, base->getSkeleton()); if(tail.first) handleShapes(tail.second, tail.first, base->getSkeleton()); - if(skirt.first) + if(skirt.first){ handleShapes(skirt.second, skirt.first, base->getSkeleton()); + } if(lhand.first) handleShapes(lhand.second, lhand.first, base->getSkeleton()); if(rhand.first) @@ -677,6 +704,14 @@ void NpcAnimation::removeIndividualPart(int type){ + } + + void NpcAnimation::reserveIndividualPart(int type, int group, int priority){ + if(priority > partpriorities[type]){ + removeIndividualPart(type); + partpriorities[type] = priority; + partslots[type] = group; + } } void NpcAnimation::removePartGroup(int group){ @@ -705,7 +740,7 @@ void NpcAnimation::removeIndividualPart(int type){ chest = insertFreePart(mesh, ":\""); break; case ESM::PRT_Groin: //4 - neck = insertBoundedPart(mesh, "Groin"); + groin = insertBoundedPart(mesh, "Groin"); break; case ESM::PRT_Skirt: //5 skirt = insertFreePart(mesh, ":|"); @@ -791,16 +826,15 @@ void NpcAnimation::removeIndividualPart(int type){ { ESM::PartReference part = parts[i]; - const ESM::BodyPart *bodypart = 0; - if(isFemale) bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.female); if(!bodypart) bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); - if(bodypart) addOrReplaceIndividualPart(part.part, group,priority,"meshes\\" + bodypart->model); + else + reserveIndividualPart(part.part, group, priority); } } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 255989d28..c7c22ad55 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -63,8 +63,8 @@ private: Ogre::SceneNode* insert; bool isBeast; bool isFemale; - std::string headID; - std::string hairID; + std::string headModel; + std::string hairModel; std::string npcName; std::string bodyRaceID; float timeToChange; @@ -79,6 +79,7 @@ private: MWWorld::ContainerStoreIterator pants; MWWorld::ContainerStoreIterator leftglove; MWWorld::ContainerStoreIterator rightglove; + MWWorld::ContainerStoreIterator skirtiter; public: NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); @@ -88,10 +89,12 @@ private: virtual void runAnimation(float timepassed); void updateParts(); void removeIndividualPart(int type); + void reserveIndividualPart(int type, int group, int priority); bool addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh); void removePartGroup(int group); void addPartGroup(int group, int priority, std::vector& parts); + }; } From 677a907528f9e5fbcecabc2a4489efb119e950c5 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sun, 15 Apr 2012 21:37:33 +0200 Subject: [PATCH 031/109] fixed comment --- cmake/FindMyGUI.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindMyGUI.cmake b/cmake/FindMyGUI.cmake index dbcf8f11c..c79ee5998 100644 --- a/cmake/FindMyGUI.cmake +++ b/cmake/FindMyGUI.cmake @@ -139,7 +139,7 @@ SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "") SET(MYGUI_PLATFORM_LIBRARIES ${MYGUI_PLATFORM_LIBRARIES} CACHE STRING "") SET(MYGUI_LIB_DIR ${MYGUI_LIB_DIR} CACHE PATH "") -IF (NOT APPLE OR NOT MYGUI_STATIC) # we need freetype libs only on OS X for static build, for other cases just make it TRUE +IF (NOT APPLE OR NOT MYGUI_STATIC) # we need explicit freetype libs only on OS X for static build, for other cases just make it TRUE SET(FREETYPE_LIBRARIES TRUE) ENDIF (NOT APPLE OR NOT MYGUI_STATIC) From 5d9648d6457b5b3e812fbfadb4c4a24a093a6f9c Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 15 Apr 2012 22:00:28 +0200 Subject: [PATCH 032/109] fix const reference --- apps/openmw/mwgui/stats_window.cpp | 2 +- apps/openmw/mwgui/stats_window.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 23f93cd1b..374672883 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -251,7 +251,7 @@ void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, My coord2.top += lineHeight; } -MyGUI::TextBox* StatsWindow::addValueItem(const std::string text, const std::string& tooltip, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) +MyGUI::TextBox* StatsWindow::addValueItem(const std::string& text, const std::string& tooltip, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { MyGUI::TextBox *skillNameWidget, *skillValueWidget; diff --git a/apps/openmw/mwgui/stats_window.hpp b/apps/openmw/mwgui/stats_window.hpp index 1ce3db98d..66655a055 100644 --- a/apps/openmw/mwgui/stats_window.hpp +++ b/apps/openmw/mwgui/stats_window.hpp @@ -53,7 +53,7 @@ namespace MWGui void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); - MyGUI::TextBox* addValueItem(const std::string text, const std::string& tooltip, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); + MyGUI::TextBox* addValueItem(const std::string& text, const std::string& tooltip, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void updateScroller(); From 268b7cd6fc3a5f9e6281ba6627be735a461a8665 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 15 Apr 2012 22:05:33 +0200 Subject: [PATCH 033/109] replaced typename checks --- apps/openmw/mwrender/npcanimation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 9cc3c26f6..0f25a1ff4 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -308,12 +308,12 @@ void NpcAnimation::updateParts(){ } if(!isBeast && boots != inv.end()){ - if(boots->getTypeName() == "struct ESM::Clothing"){ + if(boots->getTypeName() == typeid(ESM::Clothing).name()){ const ESM::Clothing *clothes = (boots->get())->base; std::vector parts = clothes->parts.parts; addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts); } - else + else if(boots->getTypeName() == typeid(ESM::Armor).name()) { const ESM::Armor *armor = (boots->get())->base; std::vector parts = armor->parts.parts; @@ -323,7 +323,7 @@ void NpcAnimation::updateParts(){ } if(leftglove != inv.end()){ - if(leftglove->getTypeName() == "struct ESM::Clothing"){ + if(leftglove->getTypeName() == typeid(ESM::Clothing).name()){ const ESM::Clothing *clothes = (leftglove->get())->base; std::vector parts = clothes->parts.parts; addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts); @@ -338,7 +338,7 @@ void NpcAnimation::updateParts(){ } if(rightglove != inv.end()){ - if(rightglove->getTypeName() == "struct ESM::Clothing"){ + if(rightglove->getTypeName() == typeid(ESM::Clothing).name()){ const ESM::Clothing *clothes = (rightglove->get())->base; std::vector parts = clothes->parts.parts; addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts); From 10398723d877b6ce1b6469fc470dbd96b9a1b236 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 15 Apr 2012 22:44:38 +0200 Subject: [PATCH 034/109] use different image pixel format --- libs/openengine/ogre/imagerotate.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/openengine/ogre/imagerotate.cpp b/libs/openengine/ogre/imagerotate.cpp index 1147559d6..11fd5eea6 100644 --- a/libs/openengine/ogre/imagerotate.cpp +++ b/libs/openengine/ogre/imagerotate.cpp @@ -54,7 +54,7 @@ void ImageRotate::rotate(const std::string& sourceImage, const std::string& dest TEX_TYPE_2D, width, height, 0, - PF_A8R8G8B8, + PF_FLOAT16_RGBA, TU_RENDERTARGET); RenderTarget* rtt = destTexture->getBuffer()->getRenderTarget(); @@ -63,7 +63,6 @@ void ImageRotate::rotate(const std::string& sourceImage, const std::string& dest vp->setOverlaysEnabled(false); vp->setShadowsEnabled(false); vp->setBackgroundColour(ColourValue(0,0,0,0)); - vp->setClearEveryFrame(true, FBT_DEPTH); rtt->update(); From b76fd249c7272350015fff07a9936cfa94448cb2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 15 Apr 2012 23:18:34 +0200 Subject: [PATCH 035/109] updated changelog; bumped version number --- CMakeLists.txt | 6 +++--- readme.txt | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 713cfa3e2..f1325c784 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ include (OpenMWMacros) # Version set (OPENMW_VERSION_MAJOR 0) -set (OPENMW_VERSION_MINOR 13) +set (OPENMW_VERSION_MINOR 14) set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") @@ -122,7 +122,7 @@ set(OENGINE_BULLET ${LIBDIR}/openengine/bullet/physic.hpp ${LIBDIR}/openengine/bullet/BulletShapeLoader.cpp ${LIBDIR}/openengine/bullet/BulletShapeLoader.h - + ) set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_BULLET}) @@ -361,7 +361,7 @@ if(WIN32) INSTALL(FILES ${files} DESTINATION ".") INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg") INSTALL(FILES - "${OpenMW_SOURCE_DIR}/readme.txt" + "${OpenMW_SOURCE_DIR}/readme.txt" "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION ".") INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ".") diff --git a/readme.txt b/readme.txt index e1c24ab52..52c4e11a2 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ OpenMW: A reimplementation of The Elder Scrolls III: Morrowind OpenMW is an attempt at recreating the engine for the popular role-playing game Morrowind by Bethesda Softworks. You need to own and install the original game for OpenMW to work. -Version: 0.13.0 +Version: 0.14.0 License: GPL (see GPL3.txt for more information) Website: http://www.openmw.org @@ -64,8 +64,6 @@ Allowed options: --start arg (=Beshara) set initial cell --master arg master file(s) --plugin arg plugin file(s) - --fps [=arg(=1)] (=0) fps counter detail (0 = off, 1 = fps counter - , 2 = full detail) --anim-verbose [=arg(=1)] (=0) output animation indices files --debug [=arg(=1)] (=0) debug mode --nosound [=arg(=1)] (=0) disable all sounds @@ -90,6 +88,7 @@ Allowed options: win1252 - Western European (Latin) alphabet, used by default --report-focus [=arg(=1)] (=0) write name of focussed object to cout + --fallback arg fallback values CREDITS @@ -134,6 +133,36 @@ Thanks to Kevin Ryan for kindly providing us with the icon used for the Data Fil CHANGELOG +0.14.0 + +Bug #1: Meshes rendered with wrong orientation +Bug #6/Task #220: Picking up small objects doesn't always work +Bug #127: tcg doesn't work +Bug #178: Compablity problems with Ogre 1.8.0 RC 1 +Bug #211: Wireframe mode (toggleWireframe command) should not apply to Console & other UI +Bug #227: Terrain crashes when moving away from predefined cells +Bug #229: On OS X Launcher cannot launch game if path to binary contains spaces +Bug #235: TGA texture loading problem +Bug #246: wireframe mode does not work in water +Feature #8/#232: Water Rendering +Feature #13: Terrain Rendering +Feature #37: Render Path Grid +Feature #66: Factions +Feature #77: Local Map +Feature #78: Compass/Mini-Map +Feature #97: Render Clothing/Armour +Feature #121: Window Pinning +Feature #205: Auto equip +Feature #217: Contiainer should track changes to its content +Feature #221: NPC Dialogue Window Enhancements +Feature #233: Game settings manager +Feature #240: Spell List and selected spell (no GUI yet) +Feature #243: Draw State +Task #113: Morrowind.ini Importer +Task #215: Refactor the sound code +Task #216: Update MyGUI + + 0.13.0 Bug #145: Fixed sound problems after cell change From 194ecf274c09140ffd0afa73b9ac359efc0ef15c Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 00:16:35 +0200 Subject: [PATCH 036/109] attribute tooltips --- apps/openmw/mwgui/stats_window.cpp | 97 ++++++++++++++++++++++++++++++ apps/openmw/mwgui/stats_window.hpp | 2 + apps/openmw/mwgui/tooltips.cpp | 83 +++++++++++++++---------- apps/openmw/mwgui/tooltips.hpp | 8 +-- files/mygui/openmw_tooltips.xml | 10 --- 5 files changed, 153 insertions(+), 47 deletions(-) diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 374672883..cf279faf7 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -72,6 +72,8 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager) MyGUI::WindowPtr t = static_cast(mMainWidget); t->eventWindowChangeCoord += MyGUI::newDelegate(this, &StatsWindow::onWindowResize); + + setupToolTips(); } void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) @@ -394,3 +396,98 @@ void StatsWindow::onPinToggled() { mWindowManager.setHMSVisibility(!mPinned); } + +void StatsWindow::setupToolTips() +{ + + const ESMS::ESMStore &store = mWindowManager.getStore(); + MyGUI::Widget* widget; + + getWidget(widget, "Attrib1"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeStrength")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sStrDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_strength.dds"); + getWidget(widget, "AttribVal1"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeStrength")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sStrDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_strength.dds"); + + getWidget(widget, "Attrib2"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeIntelligence")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sIntDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_int.dds"); + getWidget(widget, "AttribVal2"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeIntelligence")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sIntDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_int.dds"); + + getWidget(widget, "Attrib3"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeWillpower")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sWilDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_wilpower.dds"); + getWidget(widget, "AttribVal3"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeWillpower")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sWilDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_wilpower.dds"); + + getWidget(widget, "Attrib4"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeAgility")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sAgiDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_agility.dds"); + getWidget(widget, "AttribVal4"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeAgility")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sAgiDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_agility.dds"); + + getWidget(widget, "Attrib5"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeSpeed")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sSpdDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_speed.dds"); + getWidget(widget, "AttribVal5"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeSpeed")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sSpdDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_speed.dds"); + + getWidget(widget, "Attrib6"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeEndurance")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sEndDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_endurance.dds"); + getWidget(widget, "AttribVal6"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeEndurance")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sEndDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_endurance.dds"); + + getWidget(widget, "Attrib7"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributePersonality")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sPerDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_personality.dds"); + getWidget(widget, "AttribVal7"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributePersonality")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sPerDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_personality.dds"); + + getWidget(widget, "Attrib8"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeLuck")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sLucDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_luck.dds"); + getWidget(widget, "AttribVal8"); + widget->setUserString("ToolTipType", "ImageCaptionText"); + widget->setUserString("ToolTipCaption", store.gameSettings.find ("sAttributeLuck")->str); + widget->setUserString("ToolTipText", store.gameSettings.find ("sLucDesc")->str); + widget->setUserString("ToolTipImage", "k\\attribute_luck.dds"); +} diff --git a/apps/openmw/mwgui/stats_window.hpp b/apps/openmw/mwgui/stats_window.hpp index 66655a055..075c08dd3 100644 --- a/apps/openmw/mwgui/stats_window.hpp +++ b/apps/openmw/mwgui/stats_window.hpp @@ -57,6 +57,8 @@ namespace MWGui void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void updateScroller(); + void setupToolTips(); + void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos); void onWindowResize(MyGUI::Window* window); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 4c435e3bf..4dcb1cda7 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -11,8 +11,6 @@ ToolTips::ToolTips(WindowManager* windowManager) : , mGameMode(true) , mWindowManager(windowManager) { - getWidget(mTextToolTip, "TextToolTip"); - getWidget(mTextToolTipBox, "TextToolTipBox"); getWidget(mDynamicToolTipBox, "DynamicToolTipBox"); mDynamicToolTipBox->setVisible(false); @@ -20,8 +18,6 @@ ToolTips::ToolTips(WindowManager* windowManager) : // turn off mouse focus so that getMouseFocusWidget returns the correct widget, // even if the mouse is over the tooltip mDynamicToolTipBox->setNeedMouseFocus(false); - mTextToolTipBox->setNeedMouseFocus(false); - mTextToolTip->setNeedMouseFocus(false); mMainWidget->setNeedMouseFocus(false); } @@ -29,37 +25,54 @@ void ToolTips::onFrame(float frameDuration) { /// \todo Store a MWWorld::Ptr in the widget user data, retrieve it here and construct a tooltip dynamically + /// \todo we are destroying/creating the tooltip widgets every frame here, + /// because the tooltip might change (e.g. when trap is activated) + /// is there maybe a better way (listener when the object changes)? + for (size_t i=0; igetChildCount(); ++i) + { + mDynamicToolTipBox->_destroyChildWidget(mDynamicToolTipBox->getChildAt(i)); + } + const IntSize &viewSize = RenderManager::getInstance().getViewSize(); if (!mGameMode) { - mDynamicToolTipBox->setVisible(false); - mTextToolTipBox->setVisible(true); - Widget* focus = InputManager::getInstance().getMouseFocusWidget(); if (focus == 0) { - mTextToolTipBox->setVisible(false); - return; - } - - std::string type = focus->getUserString("ToolTipType"); - std::string text = focus->getUserString("ToolTipText"); - if (type == "" || text == "") - { - mTextToolTipBox->setVisible(false); + mDynamicToolTipBox->setVisible(false); return; } // this the maximum width of the tooltip before it starts word-wrapping setCoord(0, 0, 300, 300); - mTextToolTip->setCaption(text); - const IntSize &textSize = mTextToolTip->getTextSize(); + IntSize tooltipSize; + + std::string type = focus->getUserString("ToolTipType"); + std::string text = focus->getUserString("ToolTipText"); + if (type == "") + { + mDynamicToolTipBox->setVisible(false); + return; + } + else if (type == "Text") + tooltipSize = createToolTip(text); + else if (type == "CaptionText") + { + std::string caption = focus->getUserString("ToolTipCaption"); + tooltipSize = createToolTip(caption, text); + } + else if (type == "ImageCaptionText") + { + std::string caption = focus->getUserString("ToolTipCaption"); + std::string image = focus->getUserString("ToolTipImage"); + tooltipSize = createImageToolTip(caption, image, text); + } IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24); - IntSize size = textSize + IntSize(6, 6); + IntSize size = tooltipSize + IntSize(6, 6); // make the tooltip stay completely in the viewport if ((tooltipPosition.left + size.width) > viewSize.width) { @@ -74,8 +87,6 @@ void ToolTips::onFrame(float frameDuration) } else { - mTextToolTipBox->setVisible(false); - if (!mFocusObject.isEmpty()) { IntSize tooltipSize = getToolTipViaPtr(); @@ -111,14 +122,6 @@ void ToolTips::setFocusObject(const MWWorld::Ptr& focus) IntSize ToolTips::getToolTipViaPtr () { - /// \todo we are destroying/creating the tooltip widgets every frame here, - /// because the tooltip might change (e.g. when trap is activated) - /// is there maybe a better way (listener when the object changes)? - for (size_t i=0; igetChildCount(); ++i) - { - mDynamicToolTipBox->_destroyChildWidget(mDynamicToolTipBox->getChildAt(i)); - } - // this the maximum width of the tooltip before it starts word-wrapping setCoord(0, 0, 300, 300); @@ -337,7 +340,7 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, ""); + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); } // -------------------- Activator ------------------------------- @@ -375,7 +378,7 @@ IntSize ToolTips::createImageToolTip(const std::string& caption, const std::stri { // remove the first newline (easier this way) std::string realText = text; - if (realText.size() > 0) + if (realText.size() > 0 && realText[0] == '\n') realText.erase(0, 1); std::string realImage = "icons\\" + image; @@ -389,6 +392,7 @@ IntSize ToolTips::createImageToolTip(const std::string& caption, const std::stri EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", IntCoord(0, imageSize, 300, 262), Align::Stretch, "ToolTipText"); textWidget->setProperty("Static", "true"); textWidget->setProperty("MultiLine", "true"); + textWidget->setProperty("WordWrap", "true"); textWidget->setCaption(realText); textWidget->setTextAlign(Align::HCenter); @@ -414,13 +418,14 @@ IntSize ToolTips::createToolTip(const std::string& caption, const std::string& t { // remove the first newline (easier this way) std::string realText = text; - if (realText.size() > 0) + if (realText.size() > 0 && realText[0] == '\n') realText.erase(0, 1); EditBox* box = mDynamicToolTipBox->createWidget("NormalText", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); box->setTextAlign(Align::HCenter); box->setProperty("Static", "true"); box->setProperty("MultiLine", "true"); + box->setProperty("WordWrap", "true"); box->setCaption(caption + (realText != "" ? "\n#BF9959" + realText : "")); mDynamicToolTipBox->setVisible(caption != ""); @@ -428,6 +433,20 @@ IntSize ToolTips::createToolTip(const std::string& caption, const std::string& t return box->getTextSize(); } +IntSize ToolTips::createToolTip(const std::string& text) +{ + EditBox* box = mDynamicToolTipBox->createWidget("SandText", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); + box->setTextAlign(Align::HCenter); + box->setProperty("Static", "true"); + box->setProperty("MultiLine", "true"); + box->setProperty("WordWrap", "true"); + box->setCaption(text); + + mDynamicToolTipBox->setVisible(text != ""); + + return box->getTextSize(); +} + std::string ToolTips::toString(const float value) { std::ostringstream stream; diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index cb1af7349..7a2dded11 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -21,12 +21,7 @@ namespace MWGui void setFocusObject(const MWWorld::Ptr& focus); - void adjustScreen(int screenWidth, int screenHeight); - private: - MyGUI::EditBox* mTextToolTip; - MyGUI::Widget* mTextToolTipBox; - MyGUI::Widget* mDynamicToolTipBox; WindowManager* mWindowManager; @@ -44,6 +39,9 @@ namespace MWGui MyGUI::IntSize createToolTip(const std::string& caption, const std::string& text); ///< @return requested tooltip size + MyGUI::IntSize createToolTip(const std::string& text); + ///< @return requested tooltip size + std::string getValueString(const int value); ///< get "Value: X" string or "" if value is 0 diff --git a/files/mygui/openmw_tooltips.xml b/files/mygui/openmw_tooltips.xml index 1d55bd12f..2d5a5da9f 100644 --- a/files/mygui/openmw_tooltips.xml +++ b/files/mygui/openmw_tooltips.xml @@ -3,16 +3,6 @@ - - - - - - - - - - From 0c9c2537784f8209c4cfc81ee169e498571792c3 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sun, 15 Apr 2012 22:49:17 -0400 Subject: [PATCH 037/109] Fix for some types of boots --- apps/openmw/mwrender/npcanimation.cpp | 77 ++++++++++++++++++--------- apps/openmw/mwrender/npcanimation.hpp | 5 +- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 2f8763549..4105606a9 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -45,8 +45,8 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O zero = std::make_pair(blank, blankshape); chest = std::make_pair(blank, blankshape); tail = std::make_pair(blank, blankshape); - lBeastFoot = std::make_pair(blank, blankshape); - rBeastFoot = std::make_pair(blank, blankshape); + lFreeFoot = std::make_pair(blank, blankshape); + rFreeFoot = std::make_pair(blank, blankshape); rhand = std::make_pair(blank, blankshape); lhand = std::make_pair(blank, blankshape); skirt = std::make_pair(blank, blankshape); @@ -82,6 +82,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O hairModel = "meshes\\" + mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; npcName = ref->base->name; + //ESMStore::Races r = const ESM::Race* race = mEnvironment.mWorld->getStore().races.find(ref->base->race); @@ -242,6 +243,7 @@ void NpcAnimation::updateParts(){ } if(apparelChanged){ + if(robe != inv.end()) { MWWorld::Ptr ptr = *robe; @@ -308,12 +310,12 @@ void NpcAnimation::updateParts(){ } if(!isBeast && boots != inv.end()){ - if(boots->getTypeName() == "struct ESM::Clothing"){ + if(boots->getTypeName() == typeid(ESM::Clothing).name()){ const ESM::Clothing *clothes = (boots->get())->base; std::vector parts = clothes->parts.parts; addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts); } - else + else if(boots->getTypeName() == typeid(ESM::Armor).name()) { const ESM::Armor *armor = (boots->get())->base; std::vector parts = armor->parts.parts; @@ -323,7 +325,7 @@ void NpcAnimation::updateParts(){ } if(leftglove != inv.end()){ - if(leftglove->getTypeName() == "struct ESM::Clothing"){ + if(leftglove->getTypeName() == typeid(ESM::Clothing).name()){ const ESM::Clothing *clothes = (leftglove->get())->base; std::vector parts = clothes->parts.parts; addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts); @@ -338,7 +340,7 @@ void NpcAnimation::updateParts(){ } if(rightglove != inv.end()){ - if(rightglove->getTypeName() == "struct ESM::Clothing"){ + if(rightglove->getTypeName() == typeid(ESM::Clothing).name()){ const ESM::Clothing *clothes = (rightglove->get())->base; std::vector parts = clothes->parts.parts; addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts); @@ -501,6 +503,33 @@ Ogre::Entity* NpcAnimation::insertBoundedPart(const std::string &mesh, std::stri base->attachObjectToBone(bonename, part); return part; +} +void NpcAnimation::insertFootPart(int type, const std::string &mesh){ + std::string meshAndSuffix = mesh; + if(type == ESM::PRT_LFoot) + meshAndSuffix += "*|"; + NIFLoader::load(meshAndSuffix); + Ogre::Entity* part = mRend.getScene()->createEntity(meshAndSuffix); + std::vector* shape = ((NIFLoader::getSingletonPtr())->getShapes(meshAndSuffix)); + if(shape == 0){ + if(type == ESM::PRT_LFoot){ + base->attachObjectToBone("Left Foot", part); + lfoot = part; + } + else if (type == ESM::PRT_RFoot){ + base->attachObjectToBone("Right Foot", part); + rfoot = part; + } + } + else{ + if(type == ESM::PRT_LFoot) + lFreeFoot = insertFreePart(mesh, "::"); + else if (type == ESM::PRT_RFoot) + rFreeFoot = insertFreePart(mesh, ":<"); + } + + + } std::pair*> NpcAnimation::insertFreePart(const std::string &mesh, const std::string suffix){ @@ -559,10 +588,10 @@ void NpcAnimation::runAnimation(float timepassed){ vecRotPos.clear(); - if(lBeastFoot.first) - handleShapes(lBeastFoot.second, lBeastFoot.first, base->getSkeleton()); - if(rBeastFoot.first) - handleShapes(rBeastFoot.second, rBeastFoot.first, base->getSkeleton()); + if(lFreeFoot.first) + handleShapes(lFreeFoot.second, lFreeFoot.first, base->getSkeleton()); + if(rFreeFoot.first) + handleShapes(rFreeFoot.second, rFreeFoot.first, base->getSkeleton()); if(chest.first) handleShapes(chest.second, chest.first, base->getSkeleton()); if(tail.first) @@ -646,9 +675,9 @@ void NpcAnimation::removeIndividualPart(int type){ base->detachObjectFromBone(rfoot); rfoot = 0; } - else if(rBeastFoot.first){ - insert->detachObject(rBeastFoot.first); - rBeastFoot = zero; + else if(rFreeFoot.first){ + insert->detachObject(rFreeFoot.first); + rFreeFoot = zero; } } else if(type == ESM::PRT_LFoot){ //16 @@ -656,9 +685,9 @@ void NpcAnimation::removeIndividualPart(int type){ base->detachObjectFromBone(lfoot); lfoot = 0; } - else if(lBeastFoot.first){ - insert->detachObject(lBeastFoot.first); - lBeastFoot = zero; + else if(lFreeFoot.first){ + insert->detachObject(lFreeFoot.first); + lFreeFoot = zero; } } else if(type == ESM::PRT_RAnkle && rAnkle){ //17 @@ -772,16 +801,10 @@ void NpcAnimation::removeIndividualPart(int type){ lupperArm = insertBoundedPart(mesh + "*|", "Left Upper Arm"); break; case ESM::PRT_RFoot: //15 - if(isBeast) - rBeastFoot = insertFreePart(mesh, ":<"); - else - rfoot = insertBoundedPart(mesh, "Right Foot"); + insertFootPart(type, mesh); break; case ESM::PRT_LFoot: //16 - if(isBeast) - lBeastFoot = insertFreePart(mesh, "::"); - else - lfoot = insertBoundedPart(mesh + "*|", "Left Foot"); + insertFootPart(type, mesh); break; case ESM::PRT_RAnkle: //17 @@ -827,13 +850,15 @@ void NpcAnimation::removeIndividualPart(int type){ ESM::PartReference part = parts[i]; const ESM::BodyPart *bodypart = 0; + if(isFemale) bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.female); if(!bodypart) bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); - if(bodypart) + if(bodypart){ addOrReplaceIndividualPart(part.part, group,priority,"meshes\\" + bodypart->model); - else + } + else reserveIndividualPart(part.part, group, priority); } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index c7c22ad55..352b54bec 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -29,8 +29,8 @@ private: std::pair*> lhand; std::pair*> rhand; std::pair*> tail; - std::pair*> lBeastFoot; - std::pair*> rBeastFoot; + std::pair*> lFreeFoot; + std::pair*> rFreeFoot; int partslots[27]; //Each part slot is taken by clothing, armor, or is empty int partpriorities[27]; @@ -86,6 +86,7 @@ private: virtual ~NpcAnimation(); Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename); std::pair*> insertFreePart(const std::string &mesh, const std::string suffix); + void insertFootPart(int type, const std::string &mesh); virtual void runAnimation(float timepassed); void updateParts(); void removeIndividualPart(int type); From f5ab127a39dd06a3b94ae5a9b839f255069f1b0c Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 15:00:44 +0200 Subject: [PATCH 038/109] toggleFullHelp --- apps/openmw/mwgui/tooltips.cpp | 114 ++++++++++++++++++++----- apps/openmw/mwgui/tooltips.hpp | 6 +- apps/openmw/mwgui/window_manager.cpp | 5 ++ apps/openmw/mwgui/window_manager.hpp | 1 + apps/openmw/mwscript/docs/vmformat.txt | 3 +- apps/openmw/mwscript/guiextensions.cpp | 21 ++++- 6 files changed, 128 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 4dcb1cda7..25361ffcc 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -10,6 +10,7 @@ ToolTips::ToolTips(WindowManager* windowManager) : Layout("openmw_tooltips.xml") , mGameMode(true) , mWindowManager(windowManager) + , mFullHelp(false) { getWidget(mDynamicToolTipBox, "DynamicToolTipBox"); @@ -67,7 +68,9 @@ void ToolTips::onFrame(float frameDuration) { std::string caption = focus->getUserString("ToolTipCaption"); std::string image = focus->getUserString("ToolTipImage"); - tooltipSize = createImageToolTip(caption, image, text); + std::string sizeString = focus->getUserString("ToolTipImageSize"); + int size = (sizeString != "" ? boost::lexical_cast(sizeString) : 32); + tooltipSize = createImageToolTip(caption, image, size, text); } IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24); @@ -179,6 +182,11 @@ IntSize ToolTips::getToolTipViaPtr () if (ref->ref.trap != "") text += "\n" + mWindowManager->getGameSettingString("sTrapped", "Trapped!"); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + tooltipSize = createToolTip(ref->base->name, text); } @@ -192,7 +200,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Apparatus ------------------------------- @@ -205,7 +218,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Armor ------------------------------- @@ -222,7 +240,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Book ------------------------------- @@ -234,7 +257,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Clothing ------------------------------- @@ -247,7 +275,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Ingredient ------------------------------- @@ -260,7 +293,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Light ------------------------------- @@ -272,7 +310,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Tool ------------------------------- @@ -286,7 +329,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Miscellaneous ------------------------------- @@ -298,7 +346,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Probe ------------------------------- @@ -312,7 +365,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Repair ------------------------------- @@ -326,7 +384,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Weapon ------------------------------- @@ -340,7 +403,12 @@ IntSize ToolTips::getToolTipViaPtr () text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); text += getValueString(ref->base->data.value); - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text); + if (mFullHelp) { + text += "\n Owner: " + ref->ref.owner; + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); } // -------------------- Activator ------------------------------- @@ -348,7 +416,12 @@ IntSize ToolTips::getToolTipViaPtr () { ESMS::LiveCellRef* ref = mFocusObject.get(); - tooltipSize = createToolTip(ref->base->name, ""); + std::string text; + if (mFullHelp) { + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createToolTip(ref->base->name, text); } else @@ -374,7 +447,7 @@ void ToolTips::findImageExtension(std::string& image) } } -IntSize ToolTips::createImageToolTip(const std::string& caption, const std::string& image, const std::string& text) +IntSize ToolTips::createImageToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text) { // remove the first newline (easier this way) std::string realText = text; @@ -384,12 +457,10 @@ IntSize ToolTips::createImageToolTip(const std::string& caption, const std::stri std::string realImage = "icons\\" + image; findImageExtension(realImage); - const int imageSize = 32; - EditBox* captionWidget = mDynamicToolTipBox->createWidget("NormalText", IntCoord(0, 0, 300, 300), Align::Left | Align::Top, "ToolTipCaption"); captionWidget->setProperty("Static", "true"); captionWidget->setCaption(caption); - EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", IntCoord(0, imageSize, 300, 262), Align::Stretch, "ToolTipText"); + EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", IntCoord(0, imageSize, 300, 300-imageSize), Align::Stretch, "ToolTipText"); textWidget->setProperty("Static", "true"); textWidget->setProperty("MultiLine", "true"); textWidget->setProperty("WordWrap", "true"); @@ -407,7 +478,7 @@ IntSize ToolTips::createImageToolTip(const std::string& caption, const std::stri Align::Left | Align::Top, "ToolTipImage"); imageWidget->setImageTexture(realImage); - captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize, (32-captionSize.height)/2, captionSize.width-imageSize, captionSize.height); + captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize, (imageSize-captionSize.height)/2, captionSize.width-imageSize, captionSize.height); mDynamicToolTipBox->setVisible(caption != ""); @@ -468,3 +539,8 @@ std::string ToolTips::getValueString(const int value) else return "\n" + mWindowManager->getGameSettingString("sValue", "Value") + ": " + toString(value); } + +void ToolTips::toggleFullHelp() +{ + mFullHelp = !mFullHelp; +} diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index 7a2dded11..f546f3976 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -19,6 +19,8 @@ namespace MWGui void enterGameMode(); void enterGuiMode(); + void toggleFullHelp(); ///< show extra info in item tooltips (owner, script) + void setFocusObject(const MWWorld::Ptr& focus); private: @@ -33,7 +35,7 @@ namespace MWGui MyGUI::IntSize getToolTipViaPtr (); ///< @return requested tooltip size - MyGUI::IntSize createImageToolTip(const std::string& caption, const std::string& image, const std::string& text); + MyGUI::IntSize createImageToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text); ///< @return requested tooltip size MyGUI::IntSize createToolTip(const std::string& caption, const std::string& text); @@ -49,6 +51,8 @@ namespace MWGui std::string toString(const int value); bool mGameMode; + + bool mFullHelp; }; } #endif diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 8ed2050cc..b18ee4e43 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -497,3 +497,8 @@ void WindowManager::setFocusObject(const MWWorld::Ptr& focus) { mToolTips->setFocusObject(focus); } + +void WindowManager::toggleFullHelp() +{ + mToolTips->toggleFullHelp(); +} diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index d5f0683b8..d76d15dd4 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -161,6 +161,7 @@ namespace MWGui void setFocusObject(const MWWorld::Ptr& focus); void toggleFogOfWar(); + void toggleFullHelp(); ///< show extra info in item tooltips (owner, script) int toggleFps(); ///< toggle fps display @return resulting fps level diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 58960aac4..378b2412a 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -144,4 +144,5 @@ op 0x200014d: ModDisposition op 0x200014e: ModDisposition, explicit reference op 0x200014f: ForceGreeting op 0x2000150: ForceGreeting, explicit reference -opcodes 0x2000151-0x3ffffff unused +op 0x2000151: ToggleFullHelp +opcodes 0x2000152-0x3ffffff unused diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 426378efc..f7be161d6 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -80,6 +80,19 @@ namespace MWScript } }; + class OpToggleFullHelp : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + InterpreterContext& context = + static_cast (runtime.getContext()); + + context.getEnvironment().mWindowManager->toggleFullHelp(); + } + }; + const int opcodeEnableBirthMenu = 0x200000e; const int opcodeEnableClassMenu = 0x200000f; const int opcodeEnableNameMenu = 0x2000010; @@ -93,6 +106,7 @@ namespace MWScript const int opcodeShowRestMenu = 0x2000018; const int opcodeGetButtonPressed = 0x2000137; const int opcodeToggleFogOfWar = 0x2000145; + const int opcodeToggleFullHelp = 0x2000151; void registerExtensions (Compiler::Extensions& extensions) { @@ -101,7 +115,7 @@ namespace MWScript extensions.registerInstruction ("enablenamemenu", "", opcodeEnableNameMenu); extensions.registerInstruction ("enableracemenu", "", opcodeEnableRaceMenu); extensions.registerInstruction ("enablestatsreviewmenu", "", - opcodeEnableStatsReviewMenu); +opcodeEnableStatsReviewMenu); extensions.registerInstruction ("enableinventorymenu", "", opcodeEnableInventoryMenu); extensions.registerInstruction ("enablemagicmenu", "", opcodeEnableMagicMenu); @@ -117,6 +131,9 @@ namespace MWScript extensions.registerInstruction ("togglefogofwar", "", opcodeToggleFogOfWar); extensions.registerInstruction ("tfow", "", opcodeToggleFogOfWar); + + extensions.registerInstruction ("togglefullhelp", "", opcodeToggleFullHelp); + extensions.registerInstruction ("tfh", "", opcodeToggleFullHelp); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -154,6 +171,8 @@ namespace MWScript interpreter.installSegment5 (opcodeGetButtonPressed, new OpGetButtonPressed); interpreter.installSegment5 (opcodeToggleFogOfWar, new OpToggleFogOfWar); + + interpreter.installSegment5 (opcodeToggleFullHelp, new OpToggleFullHelp); } } } From 582d7ab2133585fbe42dbcb2b49ffa6eabe72eb7 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Mon, 16 Apr 2012 15:27:57 +0200 Subject: [PATCH 039/109] building & packaging improvements for OS X --- CMakeLists.txt | 111 +++++++++++++++++++++++++----------------- files/plugins.cfg.mac | 10 ++-- 2 files changed, 71 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1325c784..692aa6e51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,16 +210,16 @@ include_directories("." link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR} ${MYGUI_LIB_DIR}) -if(APPLE) +if (APPLE) # List used Ogre plugins - SET(USED_OGRE_PLUGINS "RenderSystem_GL" - "Plugin_OctreeSceneManager" - "Plugin_CgProgramManager" - "Plugin_ParticleFX") -endif(APPLE) + SET(USED_OGRE_PLUGINS ${OGRE_RenderSystem_GL_LIBRARY_REL} + ${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL} + ${OGRE_Plugin_CgProgramManager_LIBRARY_REL} + ${OGRE_Plugin_ParticleFX_LIBRARY_REL}) +endif (APPLE) -add_subdirectory( files/) -add_subdirectory( files/mygui ) +add_subdirectory(files/) +add_subdirectory(files/mygui) # Specify build paths @@ -256,34 +256,50 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") endif() if (APPLE) + # prepare plugins + if (${CMAKE_BUILD_TYPE} MATCHES "Release") + set(OPENMW_RELEASE_BUILD TRUE) + endif() + if (${CMAKE_BUILD_TYPE} MATCHES "RelWithDebugInfo") + set(OPENMW_RELEASE_BUILD TRUE) + endif() + + if (${OGRE_PLUGIN_DIR_REL}}) + set(OGRE_PLUGINS_REL_FOUND TRUE) + endif () + + if (${OGRE_PLUGIN_DIR_DBG}) + set(OGRE_PLUGINS_DBG_FOUND TRUE) + endif () + + if (${OPENMW_RELEASE_BUILD} AND ${OGRE_PLUGINS_REL_FOUND}) + set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL}) + else () + set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG}) + endif () + + if (NOT ${OPENMW_RELEASE_BUILD} AND ${OGRE_PLUGINS_DBG_FOUND}) + set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG}) + else() + set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL}) + endif() + + set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/") + configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.mac "${OpenMW_BINARY_DIR}/plugins.cfg") + set(OGRE_PLUGIN_DIR_2 ${OGRE_PLUGIN_DIR}) + set(OGRE_PLUGIN_DIR "") + configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.mac + "${OpenMW_BINARY_DIR}/plugins.cfg.install") + set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_2}) + configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist "${APP_BUNDLE_DIR}/Contents/Info.plist") configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns "${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY) - - # prepare plugins - if (${CMAKE_BUILD_TYPE} MATCHES "Release") - set(OPENMW_RELEASE_BUILD 1) - endif() - if (${CMAKE_BUILD_TYPE} MATCHES "RelWithDebugInfo") - set(OPENMW_RELEASE_BUILD 1) - endif() - - if (${OPENMW_RELEASE_BUILD}) - set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL}) - else() - set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG}) - endif() - - foreach(plugin ${USED_OGRE_PLUGINS}) - configure_file("${OGRE_PLUGIN_DIR}/${plugin}.dylib" - "${APP_BUNDLE_DIR}/Contents/Plugins/${plugin}.dylib" - COPYONLY) - endforeach() endif (APPLE) @@ -521,10 +537,12 @@ if (APPLE) install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) - - install(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) + install(FILES "${OpenMW_BINARY_DIR}/plugins.cfg.install" RENAME "plugins.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) install(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) + install(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) + install(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) + set(CPACK_GENERATOR "DragNDrop") set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION}) set(CPACK_PACKAGE_VERSION_MAJOR ${OPENMW_VERSION_MAJOR}) @@ -533,22 +551,25 @@ if (APPLE) set(APPS "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}") set(PLUGINS "") + set(ABSOLUTE_PLUGINS "") - # Scan Plugins dir for *.dylibs - set(PLUGIN_SEARCH_ROOT "${APP_BUNDLE_DIR}/Contents/Plugins") - file(GLOB_RECURSE ALL_PLUGINS "${PLUGIN_SEARCH_ROOT}/*.dylib") + foreach (PLUGIN ${USED_OGRE_PLUGINS}) + get_filename_component(PLUGIN_ABS ${PLUGIN} REALPATH) + set(ABSOLUTE_PLUGINS ${PLUGIN_ABS} ${ABSOLUTE_PLUGINS}) + endforeach () set(PLUGIN_INSTALL_BASE "\${CMAKE_INSTALL_PREFIX}/${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins") - foreach(PLUGIN ${ALL_PLUGINS}) - string(REPLACE "${PLUGIN_SEARCH_ROOT}/" "" PLUGIN_RELATIVE "${PLUGIN}") + install(FILES ${ABSOLUTE_PLUGINS} DESTINATION "${INSTALL_SUBDIR}/${APP_BUNDLE_NAME}/Contents/Plugins" COMPONENT Runtime) + foreach (PLUGIN ${ABSOLUTE_PLUGINS}) + get_filename_component(PLUGIN_RELATIVE ${PLUGIN} NAME) set(PLUGINS ${PLUGINS} "${PLUGIN_INSTALL_BASE}/${PLUGIN_RELATIVE}") - endforeach() + endforeach () #For now, search unresolved dependencies only in default system paths, so if you put unresolveable (i.e. with @executable_path in id name) lib or framework somewhere else, it would fail set(DIRS "") # Overriding item resolving during installation, it needed if - # some library already has be "fixed up", i.e. its id name contains @executable_path, + # some library already has been "fixed up", i.e. its id name contains @executable_path, # but library is not embedded in bundle. For example, it's Ogre.framework from Ogre SDK. # Current implementation of GetPrerequsities/BundleUtilities doesn't handle that case. # @@ -568,15 +589,20 @@ if (APPLE) get_filename_component(fname \"\${item}\" NAME_WE) find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} /Library/Frameworks) if (ri) - message(STATUS \"found \${ri} for \${item}\") string(REGEX REPLACE \"^.*/Frameworks/.*\\\\.framework\" \"\" item_part \${item}) set(ri \"\${ri}\${item_part}\") set(\${resolved_item_var} \${ri} PARENT_SCOPE) set(\${resolved_var} 1 PARENT_SCOPE) - set(OPENMW_RESOLVED_ITEMS \${_OPENMW_RESOLVED_ITEMS} \${ri}) endif() else() # code path for standard (non-framework) libs (ogre & qt pugins) + get_filename_component(fname \"\${item}\" NAME_WE) + string(REGEX REPLACE \"^lib\" \"\" fname \${fname}) + find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} /usr/lib /usr/local/lib) + if (ri) + set(\${resolved_item_var} \${ri} PARENT_SCOPE) + set(\${resolved_var} 1 PARENT_SCOPE) + endif () endif() endif() endfunction(gp_resolve_item_override) @@ -586,10 +612,5 @@ if (APPLE) include(BundleUtilities) fixup_bundle(\"${APPS}\" \"${PLUGINS}\" \"${DIRS}\") " COMPONENT Runtime) - -include(CPack) - -set(CMAKE_EXE_LINKER_FLAGS "-arch i386") -set(CMAKE_CXX_FLAGS "-arch i386") - + include(CPack) endif (APPLE) diff --git a/files/plugins.cfg.mac b/files/plugins.cfg.mac index 0c16bddaf..322070832 100644 --- a/files/plugins.cfg.mac +++ b/files/plugins.cfg.mac @@ -1,12 +1,12 @@ # Defines plugins to load # Define plugin folder -PluginFolder= +PluginFolder=${OGRE_PLUGIN_DIR} # Define plugins -Plugin=RenderSystem_GL.dylib -Plugin=Plugin_ParticleFX.dylib -Plugin=Plugin_OctreeSceneManager.dylib -Plugin=Plugin_CgProgramManager +Plugin=RenderSystem_GL.1.8.0 +Plugin=Plugin_ParticleFX.1.8.0 +Plugin=Plugin_OctreeSceneManager.1.8.0 +Plugin=Plugin_CgProgramManager.1.8.0 From b3dc1931a947b03a0895bb854eff3fd4d4e5fb25 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 15:48:01 +0200 Subject: [PATCH 040/109] general GUI refactoring, part 1 --- apps/openmw/mwgui/review.cpp | 37 ++++++++++------------- apps/openmw/mwgui/review.hpp | 9 +----- apps/openmw/mwgui/stats_window.cpp | 47 +++++++++++++----------------- apps/openmw/mwgui/stats_window.hpp | 9 +----- files/mygui/openmw_button.skin.xml | 10 +++---- files/mygui/openmw_edit.skin.xml | 4 +-- files/mygui/openmw_list.skin.xml | 10 +++---- libs/openengine/gui/layout.hpp | 14 +++++++++ 8 files changed, 64 insertions(+), 76 deletions(-) diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index cb0d9969c..dbd832580 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -28,21 +28,25 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager) getWidget(nameWidget, "NameText"); getWidget(button, "NameButton"); button->setCaption(mWindowManager.getGameSettingString("sName", "")); + adjustButtonSize(button); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);; getWidget(raceWidget, "RaceText"); getWidget(button, "RaceButton"); button->setCaption(mWindowManager.getGameSettingString("sRace", "")); + adjustButtonSize(button); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);; getWidget(classWidget, "ClassText"); getWidget(button, "ClassButton"); button->setCaption(mWindowManager.getGameSettingString("sClass", "")); + adjustButtonSize(button); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);; getWidget(birthSignWidget, "SignText"); getWidget(button, "SignButton"); button->setCaption(mWindowManager.getGameSettingString("sBirthSign", "")); + adjustButtonSize(button); button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);; // Setup dynamic stats @@ -181,13 +185,14 @@ void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanic { float modified = value.getModified(), base = value.getBase(); std::string text = boost::lexical_cast(std::floor(modified)); - ColorStyle style = CS_Normal; + std::string state = "normal"; if (modified > base) - style = CS_Super; + state = "increased"; else if (modified < base) - style = CS_Sub; + state = "decreased"; - setStyledText(widget, style, text); + widget->setCaption(text); + widget->_setWidgetState(state); } } @@ -210,17 +215,6 @@ void ReviewDialog::configureSkills(const std::vector& major, const std::vec } } -void ReviewDialog::setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value) -{ - widget->setCaption(value); - if (style == CS_Super) - widget->setTextColour(MyGUI::Colour(0, 1, 0)); - else if (style == CS_Sub) - widget->setTextColour(MyGUI::Colour(1, 0, 0)); - else - widget->setTextColour(MyGUI::Colour(1, 1, 1)); -} - void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { MyGUI::ImageBox* separator = skillClientWidget->createWidget("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); @@ -240,7 +234,7 @@ void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, M coord2.top += lineHeight; } -MyGUI::TextBox* ReviewDialog::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) +MyGUI::TextBox* ReviewDialog::addValueItem(const std::string text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { MyGUI::TextBox* skillNameWidget; MyGUI::TextBox* skillValueWidget; @@ -249,7 +243,8 @@ MyGUI::TextBox* ReviewDialog::addValueItem(const std::string text, const std::st skillNameWidget->setCaption(text); skillValueWidget = skillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Default); - setStyledText(skillValueWidget, style, value); + skillValueWidget->setCaption(value); + skillValueWidget->_setWidgetState(state); skillWidgets.push_back(skillNameWidget); skillWidgets.push_back(skillValueWidget); @@ -295,12 +290,12 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId float base = stat.getBase(); float modified = stat.getModified(); - ColorStyle style = CS_Normal; + std::string state = "normal"; if (modified > base) - style = CS_Super; + state = "increased"; else if (modified < base) - style = CS_Sub; - MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast(static_cast(modified)), style, coord1, coord2); + state = "decreased"; + MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast(static_cast(modified)), state, coord1, coord2); skillWidgetMap[skillId] = widget; } } diff --git a/apps/openmw/mwgui/review.hpp b/apps/openmw/mwgui/review.hpp index 588c1b6b5..76ca5a2d7 100644 --- a/apps/openmw/mwgui/review.hpp +++ b/apps/openmw/mwgui/review.hpp @@ -69,17 +69,10 @@ namespace MWGui void onBirthSignClicked(MyGUI::Widget* _sender); private: - enum ColorStyle - { - CS_Sub, - CS_Normal, - CS_Super - }; - void setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value); void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); - MyGUI::TextBox* addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); + MyGUI::TextBox* addValueItem(const std::string text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void updateScroller(); void updateSkillArea(); diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index cf279faf7..42194740f 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -113,17 +113,6 @@ void StatsWindow::setPlayerName(const std::string& playerName) static_cast(mMainWidget)->setCaption(playerName); } -void StatsWindow::setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value) -{ - widget->setCaption(value); - if (style == CS_Super) - widget->setTextColour(MyGUI::Colour(0, 1, 0)); - else if (style == CS_Sub) - widget->setTextColour(MyGUI::Colour(1, 0, 0)); - else - widget->setTextColour(MyGUI::Colour(1, 1, 1)); -} - void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat& value) { static const char *ids[] = @@ -140,12 +129,15 @@ void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat& valueString << value.getModified(); setText (id, valueString.str()); + MyGUI::TextBox* box; + getWidget(box, id); + if (value.getModified()>value.getBase()) - setTextColor (id, 0, 1, 0); + box->_setWidgetState("increased"); else if (value.getModified()_setWidgetState("decreased"); else - setTextColor (id, 1, 1, 1); + box->_setWidgetState("normal"); break; } @@ -195,13 +187,14 @@ void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechani { float modified = value.getModified(), base = value.getBase(); std::string text = boost::lexical_cast(std::floor(modified)); - ColorStyle style = CS_Normal; + std::string state = "normal"; if (modified > base) - style = CS_Super; + state = "increased"; else if (modified < base) - style = CS_Sub; + state = "decreased"; - setStyledText(widget, style, text); + widget->setCaption(text); + widget->_setWidgetState(state); } } @@ -253,7 +246,7 @@ void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, My coord2.top += lineHeight; } -MyGUI::TextBox* StatsWindow::addValueItem(const std::string& text, const std::string& tooltip, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) +MyGUI::TextBox* StatsWindow::addValueItem(const std::string& text, const std::string& tooltip, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { MyGUI::TextBox *skillNameWidget, *skillValueWidget; @@ -265,7 +258,8 @@ MyGUI::TextBox* StatsWindow::addValueItem(const std::string& text, const std::st skillValueWidget = skillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Default); skillValueWidget->setUserString("ToolTipType", "Text"); skillValueWidget->setUserString("ToolTipText", tooltip); - setStyledText(skillValueWidget, style, value); + skillValueWidget->setCaption(value); + skillValueWidget->_setWidgetState(state); skillWidgets.push_back(skillNameWidget); skillWidgets.push_back(skillValueWidget); @@ -311,12 +305,13 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, float base = stat.getBase(); float modified = stat.getModified(); - ColorStyle style = CS_Normal; + std::string state = "normal"; if (modified > base) - style = CS_Super; + state = "increased"; else if (modified < base) - style = CS_Sub; - MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), "", boost::lexical_cast(static_cast(modified)), style, coord1, coord2); + state = "decreased"; + MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), "", + boost::lexical_cast(static_cast(modified)), state, coord1, coord2); skillWidgetMap[skillId] = widget; } } @@ -377,10 +372,10 @@ void StatsWindow::updateSkillArea() addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"), mWindowManager.getGameSettingString("sSkillsMenuReputationHelp", ""), - boost::lexical_cast(static_cast(reputation)), CS_Normal, coord1, coord2); + boost::lexical_cast(static_cast(reputation)), "normal", coord1, coord2); addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"), mWindowManager.getGameSettingString("sCrimeHelp", ""), - boost::lexical_cast(static_cast(bounty)), CS_Normal, coord1, coord2); + boost::lexical_cast(static_cast(bounty)), "normal", coord1, coord2); clientHeight = coord1.top; updateScroller(); diff --git a/apps/openmw/mwgui/stats_window.hpp b/apps/openmw/mwgui/stats_window.hpp index 075c08dd3..ecbc82894 100644 --- a/apps/openmw/mwgui/stats_window.hpp +++ b/apps/openmw/mwgui/stats_window.hpp @@ -43,17 +43,10 @@ namespace MWGui void updateSkillArea(); private: - enum ColorStyle - { - CS_Sub, - CS_Normal, - CS_Super - }; - void setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value); void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); - MyGUI::TextBox* addValueItem(const std::string& text, const std::string& tooltip, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); + MyGUI::TextBox* addValueItem(const std::string& text, const std::string& tooltip, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void updateScroller(); diff --git a/files/mygui/openmw_button.skin.xml b/files/mygui/openmw_button.skin.xml index 1c6893026..b88e99406 100644 --- a/files/mygui/openmw_button.skin.xml +++ b/files/mygui/openmw_button.skin.xml @@ -47,7 +47,6 @@ - @@ -59,11 +58,10 @@ - - - - - + + + + diff --git a/files/mygui/openmw_edit.skin.xml b/files/mygui/openmw_edit.skin.xml index a86317d62..02fee4b17 100644 --- a/files/mygui/openmw_edit.skin.xml +++ b/files/mygui/openmw_edit.skin.xml @@ -13,7 +13,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/files/mygui/openmw_list.skin.xml b/files/mygui/openmw_list.skin.xml index 0ac8e03ba..5ec975a1b 100644 --- a/files/mygui/openmw_list.skin.xml +++ b/files/mygui/openmw_list.skin.xml @@ -180,10 +180,10 @@ - - - - + + + + @@ -219,7 +219,7 @@ - <_BasisSkin type="MainSkin" offset = "0 0 0 0" align = "ALIGN_LEFT ALIGN_TOP"/> + diff --git a/libs/openengine/gui/layout.hpp b/libs/openengine/gui/layout.hpp index 05a23e8ae..b95dcc4a5 100644 --- a/libs/openengine/gui/layout.hpp +++ b/libs/openengine/gui/layout.hpp @@ -115,6 +115,13 @@ namespace GUI static_cast(pt)->setCaption(caption); } + void setState(const std::string& widget, const std::string& state) + { + MyGUI::Widget* pt; + getWidget(pt, widget); + pt->_setWidgetState(state); + } + void setTextColor(const std::string& name, float r, float g, float b) { MyGUI::Widget* pt; @@ -131,6 +138,13 @@ namespace GUI pt->setImageTexture(imgName); } + void adjustButtonSize(MyGUI::Button* button) + { + // adjust size of button to fit its text + MyGUI::IntSize size = button->getTextSize(); + button->setSize(size.width + 24, button->getSize().height); + } + protected: MyGUI::Widget* mMainWidget; From 0c739825f25003047d77aec781924b2c0086f129 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Mon, 16 Apr 2012 15:57:50 +0200 Subject: [PATCH 041/109] another fix --- CMakeLists.txt | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 692aa6e51..40347898b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,14 +256,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") endif() if (APPLE) - # prepare plugins - if (${CMAKE_BUILD_TYPE} MATCHES "Release") - set(OPENMW_RELEASE_BUILD TRUE) - endif() - if (${CMAKE_BUILD_TYPE} MATCHES "RelWithDebugInfo") - set(OPENMW_RELEASE_BUILD TRUE) - endif() - if (${OGRE_PLUGIN_DIR_REL}}) set(OGRE_PLUGINS_REL_FOUND TRUE) endif () @@ -272,17 +264,11 @@ if (APPLE) set(OGRE_PLUGINS_DBG_FOUND TRUE) endif () - if (${OPENMW_RELEASE_BUILD} AND ${OGRE_PLUGINS_REL_FOUND}) + if (${OGRE_PLUGINS_REL_FOUND}) set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL}) else () set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG}) endif () - - if (NOT ${OPENMW_RELEASE_BUILD} AND ${OGRE_PLUGINS_DBG_FOUND}) - set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG}) - else() - set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL}) - endif() set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/") @@ -587,7 +573,7 @@ if (APPLE) if (item MATCHES \"Frameworks\") # if it is a framework # get last segment of path get_filename_component(fname \"\${item}\" NAME_WE) - find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} /Library/Frameworks) + find_library(ri NAMES \${fname} PATHS \${exepath} \${dirs} \${CMAKE_SYSTEM_FRAMEWORK_PATH}) if (ri) string(REGEX REPLACE \"^.*/Frameworks/.*\\\\.framework\" \"\" item_part \${item}) set(ri \"\${ri}\${item_part}\") From 14377ba789ee001503a6441cd713d08b55db0d76 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 17:30:57 +0200 Subject: [PATCH 042/109] window caption fix --- apps/openmw/mwgui/stats_window.cpp | 1 + libs/openengine/gui/layout.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 42194740f..b007fc1d4 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -111,6 +111,7 @@ void StatsWindow::setBar(const std::string& name, const std::string& tname, int void StatsWindow::setPlayerName(const std::string& playerName) { static_cast(mMainWidget)->setCaption(playerName); + adjustWindowCaption(); } void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat& value) diff --git a/libs/openengine/gui/layout.hpp b/libs/openengine/gui/layout.hpp index b95dcc4a5..bda8935af 100644 --- a/libs/openengine/gui/layout.hpp +++ b/libs/openengine/gui/layout.hpp @@ -85,7 +85,7 @@ namespace GUI // adjust the size of the window caption so that all text is visible // NOTE: this assumes that mMainWidget is of type Window. MyGUI::TextBox* box = static_cast(mMainWidget)->getCaptionWidget(); - box->setSize(box->getTextSize().width + 48, box->getSize().height); + box->setSize(box->getTextSize().width + 24, box->getSize().height); // in order to trigger alignment updates, we need to update the parent // mygui doesn't provide a proper way of doing this, so we are just changing size From 424a90aa92fd766db35316b3fafe6be7342951f7 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 17:46:54 +0200 Subject: [PATCH 043/109] back & ok button caption --- apps/openmw/mwgui/birth.cpp | 2 ++ apps/openmw/mwgui/class.cpp | 2 ++ apps/openmw/mwgui/race.cpp | 5 ++--- apps/openmw/mwgui/review.cpp | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index e9c15fab4..100356e28 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -28,10 +28,12 @@ BirthDialog::BirthDialog(WindowManager& parWindowManager) // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); + backButton->setCaption(mWindowManager.getGameSettingString("sBack", "")); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); + okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked); updateBirths(); diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 75e534b42..791e24f2a 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -29,10 +29,12 @@ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowMan // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); + backButton->setCaption(mWindowManager.getGameSettingString("sBack", "")); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); + okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked); } diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 880c0bc52..9a84f551c 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -72,10 +72,12 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager) // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); + backButton->setCaption(mWindowManager.getGameSettingString("sBack", "")); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); + okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked); updateRaces(); @@ -94,15 +96,12 @@ void RaceDialog::setNextButtonShow(bool shown) // TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system. if (shown) { - okButton->setCaption("Next"); - // Adjust back button when next is shown backButton->setCoord(MyGUI::IntCoord(471 - 18, 397, 53, 23)); okButton->setCoord(MyGUI::IntCoord(532 - 18, 397, 42 + 18, 23)); } else { - okButton->setCaption("OK"); backButton->setCoord(MyGUI::IntCoord(471, 397, 53, 23)); okButton->setCoord(MyGUI::IntCoord(532, 397, 42, 23)); } diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index dbd832580..f531fe536 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -93,10 +93,12 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager) // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); + backButton->setCaption(mWindowManager.getGameSettingString("sBack", "")); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); + okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onOkClicked); } From cfa37b0e7721ee17e98f08ee3b9588783a27271c Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 19:14:05 +0200 Subject: [PATCH 044/109] fix another bunch of gui stuff, some strings were untranslated and buttons were not resized to fit their text --- apps/openmw/mwgui/birth.cpp | 22 ++---- apps/openmw/mwgui/class.cpp | 73 +++++++++---------- apps/openmw/mwgui/map_window.cpp | 8 +- apps/openmw/mwgui/race.cpp | 19 ++--- apps/openmw/mwgui/review.cpp | 6 +- apps/openmw/mwgui/text_input.cpp | 16 ++-- apps/openmw/mwgui/tooltips.hpp | 12 +++ ...w_chargen_generate_class_result_layout.xml | 12 +-- files/mygui/openmw_text.skin.xml | 6 +- 9 files changed, 92 insertions(+), 82 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 100356e28..44c165743 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -25,7 +25,6 @@ BirthDialog::BirthDialog(WindowManager& parWindowManager) birthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); birthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); - // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); backButton->setCaption(mWindowManager.getGameSettingString("sBack", "")); @@ -48,21 +47,16 @@ void BirthDialog::setNextButtonShow(bool shown) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - // TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system. if (shown) - { - okButton->setCaption("Next"); - - // Adjust back button when next is shown - backButton->setCoord(MyGUI::IntCoord(375 - 18, 340, 53, 23)); - okButton->setCoord(MyGUI::IntCoord(431 - 18, 340, 42 + 18, 23)); - } + okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else - { - okButton->setCaption("OK"); - backButton->setCoord(MyGUI::IntCoord(375, 340, 53, 23)); - okButton->setCoord(MyGUI::IntCoord(431, 340, 42, 23)); - } + okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); + + int okButtonWidth = okButton->getTextSize().width + 24; + int backButtonWidth = backButton->getTextSize().width + 24; + + okButton->setCoord(473 - okButtonWidth, 340, okButtonWidth, 23); + backButton->setCoord(473 - okButtonWidth - backButtonWidth - 6, 340, backButtonWidth, 23); } void BirthDialog::open() diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 791e24f2a..9f1fc5d2a 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -26,7 +26,6 @@ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowMan getWidget(classImage, "ClassImage"); getWidget(className, "ClassName"); - // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); backButton->setCaption(mWindowManager.getGameSettingString("sBack", "")); @@ -36,6 +35,11 @@ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowMan getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked); + + int okButtonWidth = okButton->getTextSize().width + 24; + int backButtonWidth = backButton->getTextSize().width + 24; + okButton->setCoord(315 - okButtonWidth, 219, okButtonWidth, 23); + backButton->setCoord(315 - okButtonWidth - backButtonWidth - 6, 219, backButtonWidth, 23); } void GenerateClassResultDialog::open() @@ -104,7 +108,6 @@ PickClassDialog::PickClassDialog(WindowManager& parWindowManager) getWidget(classImage, "ClassImage"); - // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onBackClicked); @@ -125,21 +128,16 @@ void PickClassDialog::setNextButtonShow(bool shown) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - // TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system. if (shown) - { - okButton->setCaption("Next"); - - // Adjust back button when next is shown - backButton->setCoord(MyGUI::IntCoord(382 - 18, 265, 53, 23)); - okButton->setCoord(MyGUI::IntCoord(434 - 18, 265, 42 + 18, 23)); - } + okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else - { - okButton->setCaption("OK"); - backButton->setCoord(MyGUI::IntCoord(382, 265, 53, 23)); - okButton->setCoord(MyGUI::IntCoord(434, 265, 42, 23)); - } + okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); + + int okButtonWidth = okButton->getTextSize().width + 24; + int backButtonWidth = backButton->getTextSize().width + 24; + + okButton->setCoord(476 - okButtonWidth, 265, okButtonWidth, 23); + backButton->setCoord(476 - okButtonWidth - backButtonWidth - 6, 265, backButtonWidth, 23); } void PickClassDialog::open() @@ -425,9 +423,9 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager) // Make sure the edit box has focus MyGUI::InputManager::getInstance().setKeyFocusWidget(editName); - // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr descriptionButton; getWidget(descriptionButton, "DescriptionButton"); + descriptionButton->setCaption(mWindowManager.getGameSettingString("sCreateClassMenu1", "")); descriptionButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionClicked); MyGUI::ButtonPtr backButton; @@ -509,32 +507,27 @@ std::vector CreateClassDialog::getMinorSkills() const void CreateClassDialog::setNextButtonShow(bool shown) { - MyGUI::ButtonPtr descriptionButton; - getWidget(descriptionButton, "DescriptionButton"); - MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - // TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system. - if (shown) - { - okButton->setCaption("Next"); + MyGUI::ButtonPtr descriptionButton; + getWidget(descriptionButton, "DescriptionButton"); - // Adjust back button when next is shown - descriptionButton->setCoord(MyGUI::IntCoord(207 - 18, 158, 143, 23)); - backButton->setCoord(MyGUI::IntCoord(356 - 18, 158, 53, 23)); - okButton->setCoord(MyGUI::IntCoord(417 - 18, 158, 42 + 18, 23)); - } + if (shown) + okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else - { - okButton->setCaption("OK"); - descriptionButton->setCoord(MyGUI::IntCoord(207, 158, 143, 23)); - backButton->setCoord(MyGUI::IntCoord(356, 158, 53, 23)); - okButton->setCoord(MyGUI::IntCoord(417, 158, 42, 23)); - } + okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); + + int okButtonWidth = okButton->getTextSize().width + 24; + int backButtonWidth = backButton->getTextSize().width + 24; + int descriptionButtonWidth = descriptionButton->getTextSize().width + 24; + + okButton->setCoord(459 - okButtonWidth, 158, okButtonWidth, 23); + backButton->setCoord(459 - okButtonWidth - backButtonWidth - 6, 158, backButtonWidth, 23); + descriptionButton->setCoord(459 - okButtonWidth - backButtonWidth - descriptionButtonWidth - 12, 158, descriptionButtonWidth, 23); } void CreateClassDialog::open() @@ -681,11 +674,12 @@ SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowM specialization2->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specializationId = ESM::Class::Combat; - // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked); + int buttonWidth = cancelButton->getTextSize().width + 24; + cancelButton->setCoord(216 - buttonWidth, 90, buttonWidth, 21); } // widget controls @@ -730,11 +724,12 @@ SelectAttributeDialog::SelectAttributeDialog(WindowManager& parWindowManager) attribute->eventClicked += MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked); } - // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked); + int buttonWidth = cancelButton->getTextSize().width + 24; + cancelButton->setCoord(186 - buttonWidth, 180, buttonWidth, 21); } // widget controls @@ -819,11 +814,12 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager) } } - // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr cancelButton; getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked); + int buttonWidth = cancelButton->getTextSize().width + 24; + cancelButton->setCoord(447 - buttonWidth, 218, buttonWidth, 21); } // widget controls @@ -849,11 +845,12 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager) getWidget(textEdit, "TextEdit"); - // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked); okButton->setCaption(mWindowManager.getGameSettingString("sInputMenu1", "")); + int buttonWidth = okButton->getTextSize().width + 24; + okButton->setCoord(234 - buttonWidth, 214, buttonWidth, 24); // Make sure the edit box has focus MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); diff --git a/apps/openmw/mwgui/map_window.cpp b/apps/openmw/mwgui/map_window.cpp index 0e9d57c3c..e0c828fdc 100644 --- a/apps/openmw/mwgui/map_window.cpp +++ b/apps/openmw/mwgui/map_window.cpp @@ -29,6 +29,9 @@ MapWindow::MapWindow(WindowManager& parWindowManager) : getWidget(mButton, "WorldButton"); mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked); + mButton->setCaption(mWindowManager.getGameSettingString("sWorld", "")); + int width = mButton->getTextSize().width + 24; + mButton->setCoord(mMainWidget->getSize().width - width - 22, mMainWidget->getSize().height - 64, width, 22); MyGUI::Button* eventbox; getWidget(eventbox, "EventBox"); @@ -97,7 +100,10 @@ void MapWindow::onWorldButtonClicked(MyGUI::Widget* _sender) mGlobalMap->setVisible(mGlobal); mLocalMap->setVisible(!mGlobal); - mButton->setCaption( mGlobal ? "Local" : "World" ); + mButton->setCaption( mGlobal ? mWindowManager.getGameSettingString("sWorld", "") : + mWindowManager.getGameSettingString("sLocal", "")); + int width = mButton->getTextSize().width + 24; + mButton->setCoord(mMainWidget->getSize().width - width - 22, mMainWidget->getSize().height - 64, width, 22); } void MapWindow::onPinToggled() diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 9a84f551c..275759c9f 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -69,7 +69,6 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager) setText("SpellPowerT", mWindowManager.getGameSettingString("sRaceMenu7", "Specials")); getWidget(spellPowerList, "SpellPowerList"); - // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); backButton->setCaption(mWindowManager.getGameSettingString("sBack", "")); @@ -93,18 +92,16 @@ void RaceDialog::setNextButtonShow(bool shown) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - // TODO: All hardcoded coords for buttons are temporary, will be replaced with a dynamic system. if (shown) - { - // Adjust back button when next is shown - backButton->setCoord(MyGUI::IntCoord(471 - 18, 397, 53, 23)); - okButton->setCoord(MyGUI::IntCoord(532 - 18, 397, 42 + 18, 23)); - } + okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else - { - backButton->setCoord(MyGUI::IntCoord(471, 397, 53, 23)); - okButton->setCoord(MyGUI::IntCoord(532, 397, 42, 23)); - } + okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); + + int okButtonWidth = okButton->getTextSize().width + 24; + int backButtonWidth = backButton->getTextSize().width + 24; + + okButton->setCoord(574 - okButtonWidth, 397, okButtonWidth, 23); + backButton->setCoord(574 - okButtonWidth - backButtonWidth - 6, 397, backButtonWidth, 23); } void RaceDialog::open() diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index f531fe536..7dfe514de 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -90,7 +90,6 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager) static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ReviewDialog::onWindowResize); - // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); backButton->setCaption(mWindowManager.getGameSettingString("sBack", "")); @@ -100,6 +99,11 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager) getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onOkClicked); + + int backButtonWidth = backButton->getTextSize().width + 24; + int okButtonWidth = okButton->getTextSize().width + 24; + okButton->setCoord(502 - okButtonWidth, 372, okButtonWidth, 23); + backButton->setCoord(502 - okButtonWidth - backButtonWidth - 6, 372, backButtonWidth, 23); } void ReviewDialog::open() diff --git a/apps/openmw/mwgui/text_input.cpp b/apps/openmw/mwgui/text_input.cpp index 8ac07e766..7d84a9b9f 100644 --- a/apps/openmw/mwgui/text_input.cpp +++ b/apps/openmw/mwgui/text_input.cpp @@ -12,7 +12,6 @@ TextInputDialog::TextInputDialog(WindowManager& parWindowManager) getWidget(textEdit, "TextEdit"); textEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted); - // TODO: These buttons should be managed by a Dialog class MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked); @@ -25,16 +24,15 @@ void TextInputDialog::setNextButtonShow(bool shown) { MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); + if (shown) - { - okButton->setCaption("Next"); - okButton->setCoord(MyGUI::IntCoord(264 - 18, 60, 42 + 18, 23)); - } + okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else - { - okButton->setCaption("OK"); - okButton->setCoord(MyGUI::IntCoord(264, 60, 42, 23)); - } + okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); + + int okButtonWidth = okButton->getTextSize().width + 24; + + okButton->setCoord(306 - okButtonWidth, 60, okButtonWidth, 23); } void TextInputDialog::setTextLabel(const std::string &label) diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index f546f3976..a3447eb44 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -9,6 +9,18 @@ namespace MWGui { class WindowManager; + // Info about tooltip that is supplied by the MWWorld::Class object + // Not used yet, but it will replace the if-else-if blocks in tooltips.cpp + struct ToolTipInfo + { + public: + std::string caption; + std::string text; + std::string image; + + /// \todo enchantments (armor, cloth, weapons), magic effects (potions, ingredients) + }; + class ToolTips : public OEngine::GUI::Layout { public: diff --git a/files/mygui/openmw_chargen_generate_class_result_layout.xml b/files/mygui/openmw_chargen_generate_class_result_layout.xml index 7ec926eb0..26ebe17e1 100644 --- a/files/mygui/openmw_chargen_generate_class_result_layout.xml +++ b/files/mygui/openmw_chargen_generate_class_result_layout.xml @@ -1,27 +1,29 @@ - + - + + + - + - + - + diff --git a/files/mygui/openmw_text.skin.xml b/files/mygui/openmw_text.skin.xml index 6ae14c558..9f87c93b3 100644 --- a/files/mygui/openmw_text.skin.xml +++ b/files/mygui/openmw_text.skin.xml @@ -94,19 +94,19 @@ - + - + - + From f1b80c6ff7441f7e1b91d6e3c1b166c275dbdedc Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 19:23:24 +0200 Subject: [PATCH 045/109] fixed text input box --- files/mygui/openmw_text_input_layout.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/mygui/openmw_text_input_layout.xml b/files/mygui/openmw_text_input_layout.xml index 6a7ad27f0..c8f76b257 100644 --- a/files/mygui/openmw_text_input_layout.xml +++ b/files/mygui/openmw_text_input_layout.xml @@ -4,10 +4,10 @@ - + - + From 53b48196f953c388546899d4f209a92809e324db Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 19:30:52 +0200 Subject: [PATCH 046/109] add interface for tooltips to MWWorld::Class --- apps/openmw/mwworld/class.cpp | 10 ++++++++++ apps/openmw/mwworld/class.hpp | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index d49b98d0f..c886f2348 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -173,4 +173,14 @@ namespace MWWorld { throw std::runtime_error ("class does not have an down sound"); } + + MWGui::ToolTipInfo Class::getToolTipInfo (const Ptr& ptr) + { + throw std::runtime_error ("class does not have a tool tip"); + } + + bool Class::hasToolTip (const Ptr& ptr) + { + return false; + } } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index e474e9b92..5441b874d 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -12,6 +12,7 @@ #include "physicssystem.hpp" #include "../mwrender/renderinginterface.hpp" +#include "../mwgui/tooltips.hpp" namespace Ogre { @@ -86,6 +87,12 @@ namespace MWWorld ///< Return creature stats or throw an exception, if class does not have creature stats /// (default implementation: throw an exceoption) + virtual bool hasToolTip (const Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const Ptr& ptr) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual MWMechanics::NpcStats& getNpcStats (const Ptr& ptr) const; ///< Return NPC stats or throw an exception, if class does not have NPC stats /// (default implementation: throw an exceoption) From 282f37b1b71e04ad51cddc35ac924d2435bd6265 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 19:34:46 +0200 Subject: [PATCH 047/109] fix compilation --- apps/openmw/mwworld/class.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index c886f2348..10368901b 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -174,12 +174,12 @@ namespace MWWorld throw std::runtime_error ("class does not have an down sound"); } - MWGui::ToolTipInfo Class::getToolTipInfo (const Ptr& ptr) + MWGui::ToolTipInfo Class::getToolTipInfo (const Ptr& ptr) const { throw std::runtime_error ("class does not have a tool tip"); } - bool Class::hasToolTip (const Ptr& ptr) + bool Class::hasToolTip (const Ptr& ptr) const { return false; } From c4825cdb4300391cb84963abdc63c3e9f35df9fb Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 20:20:18 +0200 Subject: [PATCH 048/109] fixed gold pickup sound for international MW versions, fix npc tooltip --- apps/openmw/mwclass/misc.cpp | 5 +++-- apps/openmw/mwgui/tooltips.cpp | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 84099caaa..596344042 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -7,6 +7,7 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" +#include "../mwworld/world.hpp" #include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -90,7 +91,7 @@ namespace MWClass ESMS::LiveCellRef *ref = ptr.get(); - if (ref->base->name =="Gold") + if (ref->base->name == environment.mWorld->getStore().gameSettings.search("sGold")->str) { return std::string("Item Gold Up"); } @@ -102,7 +103,7 @@ namespace MWClass ESMS::LiveCellRef *ref = ptr.get(); - if (ref->base->name =="Gold") + if (ref->base->name == environment.mWorld->getStore().gameSettings.search("sGold")->str) { return std::string("Item Gold Down"); } diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 25361ffcc..ce3174168 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -158,7 +158,12 @@ IntSize ToolTips::getToolTipViaPtr () /// \todo We don't want tooltips for NPCs in combat mode. ESMS::LiveCellRef* ref = mFocusObject.get(); - tooltipSize = createToolTip(ref->base->name, ""); + std::string text; + if (mFullHelp) { + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createToolTip(ref->base->name, text); } // -------------------- Creature ------------------------------- @@ -167,7 +172,12 @@ IntSize ToolTips::getToolTipViaPtr () /// \todo We don't want tooltips for Creatures in combat mode. ESMS::LiveCellRef* ref = mFocusObject.get(); - tooltipSize = createToolTip(ref->base->name, ""); + std::string text; + if (mFullHelp) { + text += "\n Script: " + ref->base->script; + } + + tooltipSize = createToolTip(ref->base->name, text); } // -------------------- Container ------------------------------- From 13b67faf2f38c3692db617c4d31d6f1c33ed3d74 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 20:39:41 +0200 Subject: [PATCH 049/109] adding more safety checks --- apps/openmw/mwrender/renderingmanager.cpp | 5 +++-- files/settings-default.cfg | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index c1462807f..a35560848 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -54,9 +54,10 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const // disable unsupported effects const RenderSystemCapabilities* caps = Root::getSingleton().getRenderSystem()->getCapabilities(); - if (caps->getNumMultiRenderTargets() < 2) + if (caps->getNumMultiRenderTargets() < 2 || !Settings::Manager::getBool("shaders", "Objects")) Settings::Manager::setBool("shader", "Water", false); - if (!caps->isShaderProfileSupported("fp40") && !caps->isShaderProfileSupported("ps_4_0")) + if ( !(caps->isShaderProfileSupported("fp40") || caps->isShaderProfileSupported("ps_4_0")) + || !Settings::Manager::getBool("shaders", "Objects")) Settings::Manager::setBool("enabled", "Shadows", false); // note that the order is important here diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 553a82e49..e4a0c020a 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -86,6 +86,7 @@ num lights = 8 [Water] # Enable this to get fancy-looking water with reflections and refractions +# Only available if object shaders are on # All the settings below have no effect if this is false shader = true From cdd4d83d9e4a73ba10e83ee3ae93662783f39056 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 16 Apr 2012 22:58:16 +0200 Subject: [PATCH 050/109] moved the tooltip info to the appropriate MWWorld::Class classes --- apps/openmw/mwclass/activator.cpp | 27 ++- apps/openmw/mwclass/activator.hpp | 6 + apps/openmw/mwclass/apparatus.cpp | 35 +++ apps/openmw/mwclass/apparatus.hpp | 6 + apps/openmw/mwclass/armor.cpp | 49 ++++ apps/openmw/mwclass/armor.hpp | 6 + apps/openmw/mwclass/book.cpp | 35 +++ apps/openmw/mwclass/book.hpp | 6 + apps/openmw/mwclass/clothing.cpp | 36 +++ apps/openmw/mwclass/clothing.hpp | 6 + apps/openmw/mwclass/container.cpp | 36 +++ apps/openmw/mwclass/container.hpp | 6 + apps/openmw/mwclass/creature.cpp | 25 ++ apps/openmw/mwclass/creature.hpp | 6 + apps/openmw/mwclass/door.cpp | 42 ++++ apps/openmw/mwclass/door.hpp | 6 + apps/openmw/mwclass/ingredient.cpp | 36 +++ apps/openmw/mwclass/ingredient.hpp | 6 + apps/openmw/mwclass/light.cpp | 36 +++ apps/openmw/mwclass/light.hpp | 6 + apps/openmw/mwclass/lockpick.cpp | 39 +++ apps/openmw/mwclass/lockpick.hpp | 6 + apps/openmw/mwclass/misc.cpp | 42 ++++ apps/openmw/mwclass/misc.hpp | 6 + apps/openmw/mwclass/npc.cpp | 25 ++ apps/openmw/mwclass/npc.hpp | 6 + apps/openmw/mwclass/potion.cpp | 36 +++ apps/openmw/mwclass/potion.hpp | 6 + apps/openmw/mwclass/probe.cpp | 39 +++ apps/openmw/mwclass/probe.hpp | 6 + apps/openmw/mwclass/repair.cpp | 39 +++ apps/openmw/mwclass/repair.hpp | 6 + apps/openmw/mwclass/weapon.cpp | 41 ++++ apps/openmw/mwclass/weapon.hpp | 6 + apps/openmw/mwgui/tooltips.cpp | 343 +++------------------------ apps/openmw/mwgui/tooltips.hpp | 19 +- apps/openmw/mwgui/window_manager.cpp | 5 + apps/openmw/mwgui/window_manager.hpp | 1 + apps/openmw/mwworld/class.cpp | 2 +- apps/openmw/mwworld/class.hpp | 2 +- 40 files changed, 769 insertions(+), 323 deletions(-) diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 6749a2bfd..1f6badce9 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -7,7 +7,8 @@ #include #include "../mwworld/ptr.hpp" - +#include "../mwworld/environment.hpp" +#include "../mwgui/window_manager.hpp" namespace MWClass { @@ -63,4 +64,28 @@ namespace MWClass registerClass (typeid (ESM::Activator).name(), instance); } + + bool Activator::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + + std::string text; + if (environment.mWindowManager->getFullHelp()) + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/activator.hpp b/apps/openmw/mwclass/activator.hpp index 08be8a5ff..e5d826e58 100644 --- a/apps/openmw/mwclass/activator.hpp +++ b/apps/openmw/mwclass/activator.hpp @@ -18,6 +18,12 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 90db40b5a..16e5d8f6e 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -8,9 +8,13 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" #include "../mwrender/objects.hpp" +#include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" + #include "../mwsound/soundmanager.hpp" namespace MWClass @@ -94,4 +98,35 @@ namespace MWClass { return std::string("Item Apparatus Down"); } + + bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + text += "\n" + environment.mWorld->getStore().gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality); + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/apparatus.hpp b/apps/openmw/mwclass/apparatus.hpp index 861610f6c..d942ac0cb 100644 --- a/apps/openmw/mwclass/apparatus.hpp +++ b/apps/openmw/mwclass/apparatus.hpp @@ -28,6 +28,12 @@ namespace MWClass virtual int getValue (const MWWorld::Ptr& ptr) const; ///< Return trade value of the object. Throws an exception, if the object can't be traded. + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + static void registerSelf(); virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 8e1f81136..dd343b25d 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -16,6 +16,8 @@ #include "../mwrender/objects.hpp" +#include "../mwgui/window_manager.hpp" + #include "../mwsound/soundmanager.hpp" namespace MWClass @@ -196,4 +198,51 @@ namespace MWClass else return std::string("Item Armor Heavy Down"); } + + bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + + // get armor type string (light/medium/heavy) + int armorType = getEquipmentSkill(ptr, environment); + std::string typeText; + if (armorType == ESM::Skill::LightArmor) + typeText = environment.mWorld->getStore().gameSettings.search("sLight")->str; + else if (armorType == ESM::Skill::MediumArmor) + typeText = environment.mWorld->getStore().gameSettings.search("sMedium")->str; + else + typeText = environment.mWorld->getStore().gameSettings.search("sHeavy")->str; + + text += "\n" + environment.mWorld->getStore().gameSettings.search("sArmorRating")->str + ": " + MWGui::ToolTips::toString(ref->base->data.armor); + + /// \todo store the current armor health somewhere + text += "\n" + environment.mWorld->getStore().gameSettings.search("sCondition")->str + ": " + MWGui::ToolTips::toString(ref->base->data.health); + + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight) + " (" + typeText + ")"; + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index de5ca3983..36366db73 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -40,6 +40,12 @@ namespace MWClass /// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// no such skill. + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual int getValue (const MWWorld::Ptr& ptr) const; ///< Return trade value of the object. Throws an exception, if the object can't be traded. diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 9069d9476..f60f87936 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -8,9 +8,12 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" #include "../mwrender/objects.hpp" +#include "../mwgui/window_manager.hpp" + #include "../mwsound/soundmanager.hpp" namespace MWClass @@ -96,4 +99,36 @@ namespace MWClass { return std::string("Item Book Down"); } + + bool Book::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index 4738187cd..8ed99db91 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -25,6 +25,12 @@ namespace MWClass virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual int getValue (const MWWorld::Ptr& ptr) const; ///< Return trade value of the object. Throws an exception, if the object can't be traded. diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 672a2b60a..6835ad2ed 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -9,6 +9,10 @@ #include "../mwworld/actiontake.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" +#include "../mwworld/world.hpp" + +#include "../mwgui/tooltips.hpp" +#include "../mwgui/window_manager.hpp" #include "../mwrender/objects.hpp" @@ -161,4 +165,36 @@ namespace MWClass } return std::string("Item Clothes Down"); } + + bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index 97e09012d..04bab0edc 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -34,6 +34,12 @@ namespace MWClass /// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// no such skill. + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual int getValue (const MWWorld::Ptr& ptr) const; ///< Return trade value of the object. Throws an exception, if the object can't be traded. diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 29b3331ba..23c640dc9 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -10,6 +10,10 @@ #include "../mwworld/containerstore.hpp" #include "../mwworld/customdata.hpp" #include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" + +#include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" @@ -137,4 +141,36 @@ namespace MWClass registerClass (typeid (ESM::Container).name(), instance); } + + bool Container::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + + std::string text; + if (ref->ref.lockLevel > 0) + text += "\n" + environment.mWorld->getStore().gameSettings.search("sLockLevel")->str + ": " + MWGui::ToolTips::toString(ref->ref.lockLevel); + if (ref->ref.trap != "") + text += "\n" + environment.mWorld->getStore().gameSettings.search("sTrapped")->str; + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 387714176..3ff40c917 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -24,6 +24,12 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const; ///< Return container store diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 7270fd22b..8d5a53969 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -12,6 +12,8 @@ #include "../mwworld/customdata.hpp" #include "../mwworld/containerstore.hpp" +#include "../mwgui/window_manager.hpp" + namespace { struct CustomData : public MWWorld::CustomData @@ -140,4 +142,27 @@ namespace MWClass registerClass (typeid (ESM::Creature).name(), instance); } + + bool Creature::hasToolTip (const MWWorld::Ptr& ptr) const + { + /// \todo We don't want tooltips for Creatures in combat mode. + + return true; + } + + MWGui::ToolTipInfo Creature::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + + std::string text; + if (environment.mWindowManager->getFullHelp()) + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index 8eb45e838..61d9267f9 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -32,6 +32,12 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const; ///< Return creature stats diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 9d6c6a78d..e06fdecda 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -12,6 +12,9 @@ #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" +#include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" + #include "../mwrender/objects.hpp" #include "../mwsound/soundmanager.hpp" @@ -142,4 +145,43 @@ namespace MWClass registerClass (typeid (ESM::Door).name(), instance); } + + bool Door::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + + std::string text; + + /// \todo If destCell is empty, the teleport target is an exterior cell. In that case we + /// need to fetch that cell (via target position) and retrieve the region name. + if (ref->ref.teleport && (ref->ref.destCell != "")) + { + text += "\n" + environment.mWorld->getStore().gameSettings.search("sTo")->str; + text += "\n"+ref->ref.destCell; + } + + if (ref->ref.lockLevel > 0) + text += "\n" + environment.mWorld->getStore().gameSettings.search("sLockLevel")->str + ": " + MWGui::ToolTips::toString(ref->ref.lockLevel); + if (ref->ref.trap != "") + text += "\n" + environment.mWorld->getStore().gameSettings.search("sTrapped")->str; + + if (environment.mWindowManager->getFullHelp()) + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index aecb4224c..c7b7f5d8c 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -22,6 +22,12 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual void lock (const MWWorld::Ptr& ptr, int lockLevel) const; ///< Lock object diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 9707e79a8..a22f5c60a 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -8,6 +8,10 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" + +#include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" @@ -92,4 +96,36 @@ namespace MWClass { return std::string("Item Ingredient Down"); } + + bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index 2d7717672..ba241c2f3 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -22,6 +22,12 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index f67dd4cf0..c01017aaf 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -10,6 +10,10 @@ #include "../mwworld/nullaction.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" +#include "../mwworld/world.hpp" + +#include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" #include "../mwsound/soundmanager.hpp" @@ -134,4 +138,36 @@ namespace MWClass { return std::string("Item Misc Down"); } + + bool Light::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index bde252c28..347e55190 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -23,6 +23,12 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index 76bc3948f..36a097bab 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -9,6 +9,9 @@ #include "../mwworld/actiontake.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" +#include "../mwworld/world.hpp" +#include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" @@ -105,4 +108,40 @@ namespace MWClass { return std::string("Item Lockpick Down"); } + + bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + + /// \todo store remaining uses somewhere + + text += "\n" + environment.mWorld->getStore().gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses); + text += "\n" + environment.mWorld->getStore().gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality); + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index 1b56234af..8b5f658f5 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -22,6 +22,12 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 596344042..8cd2554a1 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -10,10 +10,15 @@ #include "../mwworld/world.hpp" #include "../mwworld/environment.hpp" +#include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" + #include "../mwrender/objects.hpp" #include "../mwsound/soundmanager.hpp" +#include + namespace MWClass { void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -109,4 +114,41 @@ namespace MWClass } return std::string("Item Misc Down"); } + + bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + + if (ref->base->name == environment.mWorld->getStore().gameSettings.search("sGold")->str) + info.caption += " (" + boost::lexical_cast(ref->base->data.value) + ")"; + else + { + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + } + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index fc002280c..dda8a352e 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -22,6 +22,12 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c053ad130..7f78d53f3 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -19,6 +19,8 @@ #include "../mwworld/inventorystore.hpp" #include "../mwworld/customdata.hpp" +#include "../mwgui/window_manager.hpp" + namespace { const Ogre::Radian kOgrePi (Ogre::Math::PI); @@ -299,4 +301,27 @@ namespace MWClass std::cout << "class npc:" << typeid (ESM::NPC).name(); registerClass (typeid (ESM::NPC).name(), instance); } + + bool Npc::hasToolTip (const MWWorld::Ptr& ptr) const + { + /// \todo We don't want tooltips for NPCs in combat mode. + + return true; + } + + MWGui::ToolTipInfo Npc::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + + std::string text; + if (environment.mWindowManager->getFullHelp()) + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index f210eda5f..46eccf26a 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -38,6 +38,12 @@ namespace MWClass virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const; ///< Return container store + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual MWWorld::InventoryStore& getInventoryStore (const MWWorld::Ptr& ptr) const; ///< Return inventory store diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 642211df3..2936afd19 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -8,6 +8,10 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" + +#include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" @@ -94,4 +98,36 @@ namespace MWClass { return std::string("Item Potion Down"); } + + bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 7d3017937..7b98fd897 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -22,6 +22,12 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 923c29ee6..c70368642 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -9,6 +9,9 @@ #include "../mwworld/actiontake.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" +#include "../mwworld/world.hpp" +#include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" @@ -104,4 +107,40 @@ namespace MWClass { return std::string("Item Probe Down"); } + + bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + + /// \todo store remaining uses somewhere + + text += "\n" + environment.mWorld->getStore().gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses); + text += "\n" + environment.mWorld->getStore().gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality); + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index 232b52364..e454279a1 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -22,6 +22,12 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index d6433f5df..2befdaac9 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -8,6 +8,9 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" +#include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" @@ -94,4 +97,40 @@ namespace MWClass { return std::string("Item Repair Down"); } + + bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Repair::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + + /// \todo store remaining uses somewhere + + text += "\n" + environment.mWorld->getStore().gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses); + text += "\n" + environment.mWorld->getStore().gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality); + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/repair.hpp b/apps/openmw/mwclass/repair.hpp index 0a9d9c253..2b8eba2f4 100644 --- a/apps/openmw/mwclass/repair.hpp +++ b/apps/openmw/mwclass/repair.hpp @@ -22,6 +22,12 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 7790e6a80..1fb871572 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -9,6 +9,10 @@ #include "../mwworld/actiontake.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" +#include "../mwworld/world.hpp" + +#include "../mwgui/window_manager.hpp" +#include "../mwgui/tooltips.hpp" #include "../mwrender/objects.hpp" @@ -245,4 +249,41 @@ namespace MWClass return std::string("Item Misc Down"); } + + bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + return (ref->base->name != ""); + } + + MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + { + ESMS::LiveCellRef *ref = + ptr.get(); + + MWGui::ToolTipInfo info; + info.caption = ref->base->name; + info.icon = ref->base->icon; + + std::string text; + + /// \todo weapon type, damage + + /// \todo store the current weapon health somewhere + text += "\n" + environment.mWorld->getStore().gameSettings.search("sCondition")->str + ": " + MWGui::ToolTips::toString(ref->base->data.health); + + text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); + text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + + if (environment.mWindowManager->getFullHelp()) { + text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); + } + + info.text = text; + + return info; + } } diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index 505c45645..1956ec1a9 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -22,6 +22,12 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation + virtual bool hasToolTip (const MWWorld::Ptr& ptr) const; + ///< @return true if this object has a tooltip when focused (default implementation: false) + + virtual MWGui::ToolTipInfo getToolTipInfo (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. + virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const; ///< \return Item health data available? diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index ce3174168..345ed847b 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -1,6 +1,8 @@ #include "tooltips.hpp" #include "window_manager.hpp" +#include "../mwworld/class.hpp" + #include using namespace MWGui; @@ -130,314 +132,24 @@ IntSize ToolTips::getToolTipViaPtr () IntSize tooltipSize; - // -------------------- Door ------------------------------- - if (mFocusObject.getTypeName() == typeid(ESM::Door).name()) + const MWWorld::Class& object = MWWorld::Class::get (mFocusObject); + if (!object.hasToolTip(mFocusObject)) { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - /// \todo If destCell is empty, the teleport target is an exterior cell. In that case we - /// need to fetch that cell (via target position) and retrieve the region name. - if (ref->ref.teleport && (ref->ref.destCell != "")) - { - text += "\n" + mWindowManager->getGameSettingString("sTo", "to"); - text += "\n"+ref->ref.destCell; - } - - if (ref->ref.lockLevel > 0) - text += "\n" + mWindowManager->getGameSettingString("sLockLevel", "Lock") + ": " + toString(ref->ref.lockLevel); - if (ref->ref.trap != "") - text += "\n" + mWindowManager->getGameSettingString("sTrapped", "Trapped!"); - - tooltipSize = createToolTip(ref->base->name, text); + mDynamicToolTipBox->setVisible(false); } - - // -------------------- NPC ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::NPC).name()) - { - /// \todo We don't want tooltips for NPCs in combat mode. - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - if (mFullHelp) { - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createToolTip(ref->base->name, text); - } - - // -------------------- Creature ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Creature).name()) - { - /// \todo We don't want tooltips for Creatures in combat mode. - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - if (mFullHelp) { - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createToolTip(ref->base->name, text); - } - - // -------------------- Container ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Container).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - - if (ref->ref.lockLevel > 0) - text += "\n" + mWindowManager->getGameSettingString("sLockLevel", "Lock") + ": " + toString(ref->ref.lockLevel); - if (ref->ref.trap != "") - text += "\n" + mWindowManager->getGameSettingString("sTrapped", "Trapped!"); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createToolTip(ref->base->name, text); - } - - // -------------------- Potion ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Potion).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - /// \todo magic effects - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Apparatus ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Apparatus).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality); - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Armor ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Armor).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - /// \todo magic effects, armor type (medium/light/heavy) - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sArmorRating", "Armor Rating") + ": " + toString(ref->base->data.armor); - - /// \todo where is the current armor health stored? - //text += "\n" + mWindowManager->getGameSettingString("sCondition", "Condition") + ": " + toString(ref->base->data.health); - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Book ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Book).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Clothing ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Clothing).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - /// \todo magic effects - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Ingredient ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Ingredient).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - /// \todo magic effects - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Light ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Light).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Tool ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Tool).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses); - text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality); - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Miscellaneous ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Miscellaneous).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Probe ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Probe).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses); - text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality); - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Repair ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Repair).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses); - text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality); - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Weapon ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Weapon).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - /// \todo weapon damage, magic effects, health (condition) - - std::string text; - text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight); - text += getValueString(ref->base->data.value); - - if (mFullHelp) { - text += "\n Owner: " + ref->ref.owner; - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, 32, text); - } - - // -------------------- Activator ------------------------------- - else if (mFocusObject.getTypeName() == typeid(ESM::Activator).name()) - { - ESMS::LiveCellRef* ref = mFocusObject.get(); - - std::string text; - if (mFullHelp) { - text += "\n Script: " + ref->base->script; - } - - tooltipSize = createToolTip(ref->base->name, text); - } - else { - // object without tooltip - mDynamicToolTipBox->setVisible(false); + mDynamicToolTipBox->setVisible(true); + + ToolTipInfo info = object.getToolTipInfo(mFocusObject, mWindowManager->getEnvironment()); + if (info.icon == "") + { + tooltipSize= createToolTip(info.caption, info.text); + } + else + { + tooltipSize = createImageToolTip(info.caption, info.icon, 32, info.text); + } } return tooltipSize; @@ -490,8 +202,6 @@ IntSize ToolTips::createImageToolTip(const std::string& caption, const std::stri captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize, (imageSize-captionSize.height)/2, captionSize.width-imageSize, captionSize.height); - mDynamicToolTipBox->setVisible(caption != ""); - return totalSize; } @@ -509,8 +219,6 @@ IntSize ToolTips::createToolTip(const std::string& caption, const std::string& t box->setProperty("WordWrap", "true"); box->setCaption(caption + (realText != "" ? "\n#BF9959" + realText : "")); - mDynamicToolTipBox->setVisible(caption != ""); - return box->getTextSize(); } @@ -523,8 +231,6 @@ IntSize ToolTips::createToolTip(const std::string& text) box->setProperty("WordWrap", "true"); box->setCaption(text); - mDynamicToolTipBox->setVisible(text != ""); - return box->getTextSize(); } @@ -542,15 +248,28 @@ std::string ToolTips::toString(const int value) return stream.str(); } -std::string ToolTips::getValueString(const int value) +std::string ToolTips::getValueString(const int value, const std::string& prefix) { if (value == 0) return ""; else - return "\n" + mWindowManager->getGameSettingString("sValue", "Value") + ": " + toString(value); + return "\n" + prefix + ": " + toString(value); +} + +std::string ToolTips::getMiscString(const std::string& text, const std::string& prefix) +{ + if (text == "") + return ""; + else + return "\n" + prefix + ": " + text; } void ToolTips::toggleFullHelp() { mFullHelp = !mFullHelp; } + +bool ToolTips::getFullHelp() const +{ + return mFullHelp; +} diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index a3447eb44..46aab3876 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -10,13 +10,12 @@ namespace MWGui class WindowManager; // Info about tooltip that is supplied by the MWWorld::Class object - // Not used yet, but it will replace the if-else-if blocks in tooltips.cpp struct ToolTipInfo { public: std::string caption; std::string text; - std::string image; + std::string icon; /// \todo enchantments (armor, cloth, weapons), magic effects (potions, ingredients) }; @@ -32,9 +31,19 @@ namespace MWGui void enterGuiMode(); void toggleFullHelp(); ///< show extra info in item tooltips (owner, script) + bool getFullHelp() const; void setFocusObject(const MWWorld::Ptr& focus); + static std::string getValueString(const int value, const std::string& prefix); + ///< @return "prefix: value" or "" if value is 0 + + static std::string getMiscString(const std::string& text, const std::string& prefix); + ///< @return "prefix: text" or "" if text is empty + + static std::string toString(const float value); + static std::string toString(const int value); + private: MyGUI::Widget* mDynamicToolTipBox; @@ -56,12 +65,6 @@ namespace MWGui MyGUI::IntSize createToolTip(const std::string& text); ///< @return requested tooltip size - std::string getValueString(const int value); - ///< get "Value: X" string or "" if value is 0 - - std::string toString(const float value); - std::string toString(const int value); - bool mGameMode; bool mFullHelp; diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index b18ee4e43..f49bcfaf8 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -502,3 +502,8 @@ void WindowManager::toggleFullHelp() { mToolTips->toggleFullHelp(); } + +bool WindowManager::getFullHelp() const +{ + return mToolTips->getFullHelp(); +} diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index d76d15dd4..1b1eff1dc 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -162,6 +162,7 @@ namespace MWGui void toggleFogOfWar(); void toggleFullHelp(); ///< show extra info in item tooltips (owner, script) + bool getFullHelp() const; int toggleFps(); ///< toggle fps display @return resulting fps level diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 10368901b..aaf19963d 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -174,7 +174,7 @@ namespace MWWorld throw std::runtime_error ("class does not have an down sound"); } - MWGui::ToolTipInfo Class::getToolTipInfo (const Ptr& ptr) const + MWGui::ToolTipInfo Class::getToolTipInfo (const Ptr& ptr, MWWorld::Environment& environment) const { throw std::runtime_error ("class does not have a tool tip"); } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 5441b874d..1b7b8b66a 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -90,7 +90,7 @@ namespace MWWorld virtual bool hasToolTip (const Ptr& ptr) const; ///< @return true if this object has a tooltip when focused (default implementation: false) - virtual MWGui::ToolTipInfo getToolTipInfo (const Ptr& ptr) const; + virtual MWGui::ToolTipInfo getToolTipInfo (const Ptr& ptr, MWWorld::Environment& environment) const; ///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip. virtual MWMechanics::NpcStats& getNpcStats (const Ptr& ptr) const; From 950378ff65d0a715c871abf080d5e6a9bbe6fa4e Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Mon, 16 Apr 2012 17:25:55 -0400 Subject: [PATCH 051/109] Khajiit male foot fix --- apps/openmw/mwrender/npcanimation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 4105606a9..9292c857e 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -439,14 +439,14 @@ void NpcAnimation::updateParts(){ } if(partpriorities[ESM::PRT_RFoot] < 1){ const ESM::BodyPart *footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); - if(isBeast) + if(isBeast && !footPart) footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); if(footPart) addOrReplaceIndividualPart(ESM::PRT_RFoot, -1,1,"meshes\\" + footPart->model); } if(partpriorities[ESM::PRT_LFoot] < 1){ const ESM::BodyPart *footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); - if(isBeast) + if(isBeast && !footPart) footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); if(footPart) addOrReplaceIndividualPart(ESM::PRT_LFoot, -1,1,"meshes\\" + footPart->model); From a11c4da16c3688d8a4760c7f866e8edc518614f2 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 17 Apr 2012 14:22:03 +0200 Subject: [PATCH 052/109] vertex colour tweak --- apps/openmw/mwrender/shaderhelper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/shaderhelper.cpp b/apps/openmw/mwrender/shaderhelper.cpp index 5354251f8..1d29be2b8 100644 --- a/apps/openmw/mwrender/shaderhelper.cpp +++ b/apps/openmw/mwrender/shaderhelper.cpp @@ -256,9 +256,9 @@ void ShaderHelper::createShader(const bool mrt, const bool shadows, const bool s } outStream << - " float3 lightingFinal = lightColour.xyz * diffuse.xyz * vertexColour.xyz + ambient.xyz * lightAmbient.xyz + emissive.xyz; \n" + " float3 lightingFinal = lightColour.xyz * diffuse.xyz + ambient.xyz * lightAmbient.xyz + emissive.xyz; \n" " float fogValue = saturate((iDepth - fogParams.y) * fogParams.w); \n" - " oColor.xyz = lerp(lightingFinal * tex.xyz, fogColour.xyz, fogValue); \n" + " oColor.xyz = lerp(lightingFinal * tex.xyz * vertexColour.xyz, fogColour.xyz, fogValue); \n" " oColor.a = tex.a * diffuse.a * vertexColour.a; \n"; if (mrt) outStream << From c044fadcc303ad9f5621a75a21bc54770844e5df Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 17 Apr 2012 15:31:16 +0200 Subject: [PATCH 053/109] show weapon type & damage in the tooltip --- apps/openmw/mwclass/weapon.cpp | 53 ++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 1fb871572..d2ea92126 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -269,10 +269,59 @@ namespace MWClass std::string text; - /// \todo weapon type, damage + // weapon type & damage. arrows / bolts don't have his info. + if (ref->base->data.type < 12) + { + text += "\n" + environment.mWorld->getStore().gameSettings.search("sType")->str + " "; + + std::map > mapping; + mapping[ESM::Weapon::ShortBladeOneHand] = std::make_pair("sSkillShortblade", "sOneHanded"); + mapping[ESM::Weapon::LongBladeOneHand] = std::make_pair("sSkillLongblade", "sOneHanded"); + mapping[ESM::Weapon::LongBladeTwoHand] = std::make_pair("sSkillLongblade", "sTwoHanded"); + mapping[ESM::Weapon::BluntOneHand] = std::make_pair("sSkillBluntweapon", "sOneHanded"); + mapping[ESM::Weapon::BluntTwoClose] = std::make_pair("sSkillBluntweapon", "sTwoHanded"); + mapping[ESM::Weapon::BluntTwoWide] = std::make_pair("sSkillBluntweapon", "sTwoHanded"); + mapping[ESM::Weapon::SpearTwoWide] = std::make_pair("sSkillSpear", "sTwoHanded"); + mapping[ESM::Weapon::AxeOneHand] = std::make_pair("sSkillAxe", "sOneHanded"); + mapping[ESM::Weapon::AxeTwoHand] = std::make_pair("sSkillAxe", "sTwoHanded"); + mapping[ESM::Weapon::MarksmanBow] = std::make_pair("sSkillMarksman", ""); + mapping[ESM::Weapon::MarksmanCrossbow] = std::make_pair("sSkillMarksman", ""); + mapping[ESM::Weapon::MarksmanThrown] = std::make_pair("sSkillMarksman", ""); + + std::string type = mapping[ref->base->data.type].first; + std::string oneOrTwoHanded = mapping[ref->base->data.type].second; + + text += environment.mWorld->getStore().gameSettings.search(type)->str + + ((oneOrTwoHanded != "") ? ", " + environment.mWorld->getStore().gameSettings.search(oneOrTwoHanded)->str : ""); + + // weapon damage + if (ref->base->data.type >= 9) + { + // marksman + text += "\n" + environment.mWorld->getStore().gameSettings.search("sAttack")->str + ": " + + MWGui::ToolTips::toString(static_cast(ref->base->data.chop[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->base->data.chop[1])); + } + else + { + // Chop + text += "\n" + environment.mWorld->getStore().gameSettings.search("sChop")->str + ": " + + MWGui::ToolTips::toString(static_cast(ref->base->data.chop[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->base->data.chop[1])); + // Slash + text += "\n" + environment.mWorld->getStore().gameSettings.search("sSlash")->str + ": " + + MWGui::ToolTips::toString(static_cast(ref->base->data.slash[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->base->data.slash[1])); + // Thrust + text += "\n" + environment.mWorld->getStore().gameSettings.search("sThrust")->str + ": " + + MWGui::ToolTips::toString(static_cast(ref->base->data.thrust[0])) + + " - " + MWGui::ToolTips::toString(static_cast(ref->base->data.thrust[1])); + } + } /// \todo store the current weapon health somewhere - text += "\n" + environment.mWorld->getStore().gameSettings.search("sCondition")->str + ": " + MWGui::ToolTips::toString(ref->base->data.health); + if (ref->base->data.type < 11) // thrown weapons and arrows/bolts don't have health, only quantity + text += "\n" + environment.mWorld->getStore().gameSettings.search("sCondition")->str + ": " + MWGui::ToolTips::toString(ref->base->data.health); text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); From c2fdacc84fc5f1a3f69a9e2f1c74ff875f9d6d8b Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 17 Apr 2012 15:51:02 +0200 Subject: [PATCH 054/109] show the creature name for soul gems (if any) --- apps/openmw/mwclass/misc.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 8cd2554a1..222ac1b78 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -132,6 +132,12 @@ namespace MWClass info.caption = ref->base->name; info.icon = ref->base->icon; + if (ref->ref.soul != "") + { + const ESM::Creature *creature = environment.mWorld->getStore().creatures.search(ref->ref.soul); + info.caption += " (" + creature->name + ")"; + } + std::string text; if (ref->base->name == environment.mWorld->getStore().gameSettings.search("sGold")->str) From 8eb06363449bb638882b77ff28c0ce19901bcda0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 17 Apr 2012 16:00:13 +0200 Subject: [PATCH 055/109] restored gui-mode tooltips --- apps/openmw/mwgui/tooltips.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 345ed847b..fd44c7d9b 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -89,6 +89,7 @@ void ToolTips::onFrame(float frameDuration) } setCoord(tooltipPosition.left, tooltipPosition.top, size.width, size.height); + mDynamicToolTipBox->setVisible(true); } else { From 94993b515c7abade56d4885d46ea305ea42c7947 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 17 Apr 2012 16:49:28 +0200 Subject: [PATCH 056/109] clean up and tooltip padding --- apps/openmw/mwgui/tooltips.cpp | 100 +++++++++++++++------------------ apps/openmw/mwgui/tooltips.hpp | 8 +-- 2 files changed, 45 insertions(+), 63 deletions(-) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index fd44c7d9b..ab766dc56 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -47,9 +47,6 @@ void ToolTips::onFrame(float frameDuration) return; } - // this the maximum width of the tooltip before it starts word-wrapping - setCoord(0, 0, 300, 300); - IntSize tooltipSize; std::string type = focus->getUserString("ToolTipType"); @@ -60,11 +57,11 @@ void ToolTips::onFrame(float frameDuration) return; } else if (type == "Text") - tooltipSize = createToolTip(text); + tooltipSize = createToolTip(text, "", 0, ""); else if (type == "CaptionText") { std::string caption = focus->getUserString("ToolTipCaption"); - tooltipSize = createToolTip(caption, text); + tooltipSize = createToolTip(caption, "", 0, text); } else if (type == "ImageCaptionText") { @@ -72,23 +69,22 @@ void ToolTips::onFrame(float frameDuration) std::string image = focus->getUserString("ToolTipImage"); std::string sizeString = focus->getUserString("ToolTipImageSize"); int size = (sizeString != "" ? boost::lexical_cast(sizeString) : 32); - tooltipSize = createImageToolTip(caption, image, size, text); + tooltipSize = createToolTip(caption, image, size, text); } IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24); - IntSize size = tooltipSize + IntSize(6, 6); // make the tooltip stay completely in the viewport - if ((tooltipPosition.left + size.width) > viewSize.width) + if ((tooltipPosition.left + tooltipSize.width) > viewSize.width) { - tooltipPosition.left = viewSize.width - size.width; + tooltipPosition.left = viewSize.width - tooltipSize.width; } - if ((tooltipPosition.top + size.height) > viewSize.height) + if ((tooltipPosition.top + tooltipSize.height) > viewSize.height) { - tooltipPosition.top = viewSize.height - size.height; + tooltipPosition.top = viewSize.height - tooltipSize.height; } - setCoord(tooltipPosition.left, tooltipPosition.top, size.width, size.height); + setCoord(tooltipPosition.left, tooltipPosition.top, tooltipSize.width, tooltipSize.height); mDynamicToolTipBox->setVisible(true); } else @@ -97,8 +93,6 @@ void ToolTips::onFrame(float frameDuration) { IntSize tooltipSize = getToolTipViaPtr(); - tooltipSize += IntSize(6,6); // padding, adjust for skin - // adjust tooltip size to fit its content, position it above the crosshair /// \todo Slide the tooltip along the bounding box of the focused object (like in Morrowind) setCoord(viewSize.width/2 - (tooltipSize.width)/2.f, @@ -145,11 +139,11 @@ IntSize ToolTips::getToolTipViaPtr () ToolTipInfo info = object.getToolTipInfo(mFocusObject, mWindowManager->getEnvironment()); if (info.icon == "") { - tooltipSize= createToolTip(info.caption, info.text); + tooltipSize = createToolTip(info.caption, "", 0, info.text); } else { - tooltipSize = createImageToolTip(info.caption, info.icon, 32, info.text); + tooltipSize = createToolTip(info.caption, info.icon, 32, info.text); } } @@ -170,71 +164,65 @@ void ToolTips::findImageExtension(std::string& image) } } -IntSize ToolTips::createImageToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text) +IntSize ToolTips::createToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text) { // remove the first newline (easier this way) std::string realText = text; if (realText.size() > 0 && realText[0] == '\n') realText.erase(0, 1); + // this the maximum width of the tooltip before it starts word-wrapping + setCoord(0, 0, 300, 300); + + const IntPoint padding(8, 8); + + const int imageCaptionHPadding = 8; + const int imageCaptionVPadding = 4; + std::string realImage = "icons\\" + image; findImageExtension(realImage); EditBox* captionWidget = mDynamicToolTipBox->createWidget("NormalText", IntCoord(0, 0, 300, 300), Align::Left | Align::Top, "ToolTipCaption"); captionWidget->setProperty("Static", "true"); captionWidget->setCaption(caption); - EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", IntCoord(0, imageSize, 300, 300-imageSize), Align::Stretch, "ToolTipText"); + IntSize captionSize = captionWidget->getTextSize(); + + int captionHeight = std::max(captionSize.height, imageSize); + + EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", IntCoord(0, captionHeight+imageCaptionVPadding, 300, 300-captionHeight-imageCaptionVPadding), Align::Stretch, "ToolTipText"); textWidget->setProperty("Static", "true"); textWidget->setProperty("MultiLine", "true"); textWidget->setProperty("WordWrap", "true"); textWidget->setCaption(realText); - textWidget->setTextAlign(Align::HCenter); - - IntSize captionSize = captionWidget->getTextSize(); + textWidget->setTextAlign(Align::HCenter | Align::Top); IntSize textSize = textWidget->getTextSize(); captionSize += IntSize(imageSize, 0); // adjust for image - IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width), ((realText != "") ? textSize.height : 0) + imageSize ); + IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width + ((image != "") ? imageCaptionHPadding : 0)), + ((realText != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight ); - ImageBox* imageWidget = mDynamicToolTipBox->createWidget("ImageBox", - IntCoord((totalSize.width - captionSize.width)/2, 0, imageSize, imageSize), - Align::Left | Align::Top, "ToolTipImage"); - imageWidget->setImageTexture(realImage); + if (image != "") + { + ImageBox* imageWidget = mDynamicToolTipBox->createWidget("ImageBox", + IntCoord((totalSize.width - captionSize.width - imageCaptionHPadding)/2, 0, imageSize, imageSize), + Align::Left | Align::Top, "ToolTipImage"); + imageWidget->setImageTexture(realImage); + imageWidget->setPosition (imageWidget->getPosition() + padding); + } - captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize, (imageSize-captionSize.height)/2, captionSize.width-imageSize, captionSize.height); + captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize, + (captionHeight-captionSize.height)/2, + captionSize.width-imageSize, + captionSize.height); + + captionWidget->setPosition (captionWidget->getPosition() + padding); + textWidget->setPosition (textWidget->getPosition() + IntPoint(0, padding.top)); // only apply vertical padding, the horizontal works automatically due to Align::HCenter + + totalSize += IntSize(padding.left*2, padding.top*2); return totalSize; } -IntSize ToolTips::createToolTip(const std::string& caption, const std::string& text) -{ - // remove the first newline (easier this way) - std::string realText = text; - if (realText.size() > 0 && realText[0] == '\n') - realText.erase(0, 1); - - EditBox* box = mDynamicToolTipBox->createWidget("NormalText", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setProperty("MultiLine", "true"); - box->setProperty("WordWrap", "true"); - box->setCaption(caption + (realText != "" ? "\n#BF9959" + realText : "")); - - return box->getTextSize(); -} - -IntSize ToolTips::createToolTip(const std::string& text) -{ - EditBox* box = mDynamicToolTipBox->createWidget("SandText", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); - box->setTextAlign(Align::HCenter); - box->setProperty("Static", "true"); - box->setProperty("MultiLine", "true"); - box->setProperty("WordWrap", "true"); - box->setCaption(text); - - return box->getTextSize(); -} - std::string ToolTips::toString(const float value) { std::ostringstream stream; diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index 46aab3876..d84a1093b 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -56,13 +56,7 @@ namespace MWGui MyGUI::IntSize getToolTipViaPtr (); ///< @return requested tooltip size - MyGUI::IntSize createImageToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text); - ///< @return requested tooltip size - - MyGUI::IntSize createToolTip(const std::string& caption, const std::string& text); - ///< @return requested tooltip size - - MyGUI::IntSize createToolTip(const std::string& text); + MyGUI::IntSize createToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text); ///< @return requested tooltip size bool mGameMode; From 2e57cf5730ed326d45f1c828d158bb6bb408d1c7 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 17 Apr 2012 18:47:51 +0200 Subject: [PATCH 057/109] fixed the tooltip for doors leading to exteriors, fixed map window cell name --- apps/openmw/mwclass/door.cpp | 26 ++++++++++++++++++++++---- apps/openmw/mwgui/window_manager.cpp | 5 ++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index e06fdecda..794d57d1c 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -164,12 +164,30 @@ namespace MWClass std::string text; - /// \todo If destCell is empty, the teleport target is an exterior cell. In that case we - /// need to fetch that cell (via target position) and retrieve the region name. - if (ref->ref.teleport && (ref->ref.destCell != "")) + if (ref->ref.teleport) { + std::string dest; + if (ref->ref.destCell != "") + { + // door leads to an interior, use interior name as tooltip + dest = ref->ref.destCell; + } + else + { + // door leads to exterior, use cell name (if any), otherwise translated region name + int x,y; + environment.mWorld->positionToIndex (ref->ref.doorDest.pos[0], ref->ref.doorDest.pos[1], x, y); + const ESM::Cell* cell = environment.mWorld->getStore().cells.findExt(x,y); + if (cell->name != "") + dest = cell->name; + else + { + const ESM::Region* region = environment.mWorld->getStore().regions.search(cell->region); + dest = region->name; + } + } text += "\n" + environment.mWorld->getStore().gameSettings.search("sTo")->str; - text += "\n"+ref->ref.destCell; + text += "\n"+dest; } if (ref->ref.lockLevel > 0) diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index f49bcfaf8..0188a15b3 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -433,7 +433,10 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) if (cell->cell->name != "") name = cell->cell->name; else - name = cell->cell->region; + { + const ESM::Region* region = environment.mWorld->getStore().regions.search(cell->cell->region); + name = region->name; + } map->setCellName( name ); From 8231cab5996dc31f12efda82bfeecd156ec1f6f3 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 17 Apr 2012 23:47:50 +0200 Subject: [PATCH 058/109] correct case for dialogue topics --- apps/openmw/mwdialogue/dialoguemanager.cpp | 16 ++--- apps/openmw/mwgui/dialogue.cpp | 10 ++++ components/esm_store/reclists.hpp | 69 ++++++++++++++++++++++ components/esm_store/store.cpp | 10 ++-- components/esm_store/store.hpp | 6 +- 5 files changed, 94 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 90f0c0231..3188136b3 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -549,10 +549,10 @@ namespace MWDialogue mCompilerContext.setExtensions (&extensions); mDialogueMap.clear(); actorKnownTopics.clear(); - ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { - mDialogueMap[it->first] = it->second; + mDialogueMap[toLower(it->first)] = it->second; } } @@ -602,8 +602,8 @@ namespace MWDialogue //greeting bool greetingFound = false; //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; if(ndialogue.type == ESM::Dialogue::Greeting) @@ -702,8 +702,8 @@ namespace MWDialogue mChoice = -1; actorKnownTopics.clear(); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - for(ESMS::RecListT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; if(ndialogue.type == ESM::Dialogue::Topic) @@ -713,7 +713,7 @@ namespace MWDialogue { if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { - actorKnownTopics.push_back(it->first); + actorKnownTopics.push_back(toLower(it->first)); //does the player know the topic? if(knownTopics.find(toLower(it->first)) != knownTopics.end()) { diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index ac6681e27..fc7a36382 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -183,6 +183,16 @@ void DialogueWindow::addText(std::string text) void DialogueWindow::addTitle(std::string text) { + // This is called from the dialogue manager, so text is + // case-smashed - thus we have to retrieve the correct case + // of the text through the topic list. + for (size_t i=0; igetItemCount(); ++i) + { + std::string item = topicsList->getItemNameAt(i); + if (lower_string(item) == text) + text = item; + } + history->addDialogHeading(text); } diff --git a/components/esm_store/reclists.hpp b/components/esm_store/reclists.hpp index d7a4100aa..48bf050cd 100644 --- a/components/esm_store/reclists.hpp +++ b/components/esm_store/reclists.hpp @@ -90,6 +90,75 @@ namespace ESMS } }; + // Same as RecListT, but does not case-smash the IDs + // Note that lookups (search or find) are still case insensitive + template + struct RecListCaseT : RecList + { + virtual ~RecListCaseT() {} + + typedef std::map MapType; + + MapType list; + + // Load one object of this type + void load(ESMReader &esm, const std::string &id) + { + //std::string id2 = toLower (id); + + list[id].load(esm); + } + + // Find the given object ID, or return NULL if not found. + const X* search(const std::string &id) const + { + std::string id2 = toLower (id); + + for (typename MapType::const_iterator iter = list.begin(); + iter != list.end(); ++iter) + { + if (toLower(iter->first) == id2) + return &iter->second; + } + + return NULL; + } + + // non-const version + X* search(const std::string &id) + { + std::string id2 = toLower (id); + + for (typename MapType::iterator iter = list.begin(); + iter != list.end(); ++iter) + { + if (toLower(iter->first) == id2) + return &iter->second; + } + + return NULL; + } + + // Find the given object ID (throws an exception if not found) + const X* find(const std::string &id) const + { + const X *object = search (id); + + if (!object) + throw std::runtime_error ("object " + id + " not found"); + + return object; + } + + int getSize() { return list.size(); } + + virtual void listIdentifier (std::vector& identifier) const + { + for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) + identifier.push_back (iter->first); + } + }; + /// Modified version of RecListT for records, that need to store their own ID template struct RecListWithIDT : RecList diff --git a/components/esm_store/store.cpp b/components/esm_store/store.cpp index 2b5b977aa..c676601e5 100644 --- a/components/esm_store/store.cpp +++ b/components/esm_store/store.cpp @@ -71,15 +71,13 @@ void ESMStore::load(ESMReader &esm) if (n.val==ESM::REC_DIAL) { - RecListT& recList = static_cast& > (*it->second); + RecListCaseT& recList = static_cast& > (*it->second); - id = recList.toLower (id); + ESM::Dialogue* d = recList.search (id); - RecListT::MapType::iterator iter = recList.list.find (id); + assert (d != NULL); - assert (iter!=recList.list.end()); - - dialogue = &iter->second; + dialogue = d; } else dialogue = 0; diff --git a/components/esm_store/store.hpp b/components/esm_store/store.hpp index 857682089..507196a86 100644 --- a/components/esm_store/store.hpp +++ b/components/esm_store/store.hpp @@ -40,9 +40,9 @@ namespace ESMS RecListT clothes; RecListT contChange; RecListT containers; - RecListWithIDT creatures; + RecListWithIDT creatures; RecListT creaChange; - RecListT dialogs; + RecListCaseT dialogs; RecListT doors; RecListT enchants; RecListT factions; @@ -53,7 +53,7 @@ namespace ESMS RecListT lights; RecListT lockpicks; RecListT miscItems; - RecListWithIDT npcs; + RecListWithIDT npcs; RecListT npcChange; RecListT probes; RecListT races; From 046ef39c4a6f756f167147d34f112057c6c9914f Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 18 Apr 2012 01:10:00 +0200 Subject: [PATCH 059/109] use camera-relative rendering to prevent precision artifacts when moving far from (0,0,0) --- apps/openmw/mwrender/renderingmanager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index a35560848..3082cf0d7 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -52,6 +52,10 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const // Load resources ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); + // Due to the huge world size of MW, we'll want camera-relative rendering. + // This prevents precision artifacts when moving very far from the origin. + mRendering.getScene()->setCameraRelativeRendering(true); + // disable unsupported effects const RenderSystemCapabilities* caps = Root::getSingleton().getRenderSystem()->getCapabilities(); if (caps->getNumMultiRenderTargets() < 2 || !Settings::Manager::getBool("shaders", "Objects")) From 5f9056c45d06fadd12a77be438c3eab930e25ecb Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Tue, 17 Apr 2012 20:31:36 -0400 Subject: [PATCH 060/109] Better no clip --- apps/openmw/mwworld/physicssystem.cpp | 7 ++++--- libs/openengine/bullet/pmove.cpp | 4 +++- libs/openengine/bullet/pmove.h | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 29c65b411..98c15e338 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -127,11 +127,11 @@ namespace MWWorld Ogre::Quaternion pitchQuat = pitchNode->getOrientation(); Ogre::Quaternion both = yawQuat * pitchQuat; - playerphysics->ps.viewangles.x = 0; + playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees(); playerphysics->ps.viewangles.z = 0; - playerphysics->ps.viewangles.y = both.getYaw().valueDegrees() *-1 + 90; + playerphysics->ps.viewangles.y = yawQuat.getYaw().valueDegrees() *-1 + 90; - //playerphysics->ps.viewangles.z = both.getPitch().valueDegrees(); + if(mFreeFly) @@ -259,6 +259,7 @@ namespace MWWorld { if(playerphysics->ps.move_type==PM_NOCLIP) playerphysics->ps.move_type=PM_NORMAL; + else playerphysics->ps.move_type=PM_NOCLIP; for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 8fb72aa1f..86d069273 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -632,6 +632,8 @@ float PM_CmdScale(playerMove::playercmd* const cmd) total = sqrtf( (const float)(cmd->forwardmove * cmd->forwardmove + cmd->rightmove * cmd->rightmove + cmd->upmove * cmd->upmove) ); scale = (float)pm->ps.speed * max / ( 127.0f * total ); + if(pm->ps.move_type == PM_NOCLIP) + scale *= 2; return scale; } @@ -1125,7 +1127,7 @@ void AngleVectors( const Ogre::Vector3& angles, Ogre::Vector3* const forward, Og { right->x = (-1 * sr * sp * cy + -1 * cr * -sy); right->y = (-1 * sr * sp * sy + -1 * cr * cy); - right->z = 0.0f;//-1 * sp * cp; + right->z = 0; } if (up) { diff --git a/libs/openengine/bullet/pmove.h b/libs/openengine/bullet/pmove.h index 30572a92a..304572b02 100644 --- a/libs/openengine/bullet/pmove.h +++ b/libs/openengine/bullet/pmove.h @@ -55,7 +55,7 @@ static const Ogre::Vector3 halfExtents(14.64f * 2, 14.24f * 2, 33.25f * 2); #define CONTENTS_FOG 64 static const float pm_accelerate = 10.0f; static const float pm_stopspeed = 100.0f; -static const float pm_friction = 6.0f; +static const float pm_friction = 12.0f; static const float pm_flightfriction = 3.0f; static const float pm_waterfriction = 1.0f; static const float pm_airaccelerate = 1.0f; @@ -90,7 +90,7 @@ struct playerMove { struct playerStruct { - playerStruct() : gravity(800.0f), speed(320.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0) + playerStruct() : gravity(800.0f), speed(480.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0) { origin = Ogre::Vector3(733.164f,900.0f, 839.432f); velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f); From 4d07ae7fe031dad3019b8c7d837fc4059a3ffee9 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 18 Apr 2012 00:13:38 -0400 Subject: [PATCH 061/109] Swimming working --- apps/openmw/mwworld/physicssystem.cpp | 7 +++++++ apps/openmw/mwworld/physicssystem.hpp | 2 ++ apps/openmw/mwworld/scene.cpp | 2 ++ libs/openengine/bullet/pmove.cpp | 10 +++++----- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 98c15e338..d224385ae 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -67,6 +67,13 @@ namespace MWWorld return mEngine->rayTest2(from,to); } + void PhysicsSystem::setCurrentWater(bool hasWater, int waterHeight){ + playerphysics->hasWater = hasWater; + if(hasWater){ + playerphysics->waterHeight = waterHeight; + } + + } btVector3 PhysicsSystem::getRayPoint(float extent) { diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index fb15a1486..2d73cab27 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -49,6 +49,8 @@ namespace MWWorld void insertActorPhysics(const MWWorld::Ptr&, std::string model); OEngine::Physic::PhysicEngine* getEngine(); + + void setCurrentWater(bool hasWater, int waterHeight); private: OEngine::Render::OgreRenderer &mRender; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 2123b4799..5244d53f8 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -117,6 +117,8 @@ namespace MWWorld void Scene::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position, bool adjustPlayerPos) { + bool hasWater = cell->cell->data.flags & cell->cell->HasWater; + mPhysics->setCurrentWater(hasWater, cell->cell->water); if (adjustPlayerPos) mWorld->getPlayer().setPos (position.pos[0], position.pos[1], position.pos[2]); diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 86d069273..214a7e598 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -1715,11 +1715,11 @@ void PM_SetWaterLevel( playerMove* const pm ) point[1] = pm->ps->origin[1]; point[2] = pm->ps->origin[2] + MINS_Z + 1; */ point.x = pm->ps.origin.x; - point.y = pm->ps.origin.y + MINS_Z + 1; - point.z = pm->ps.origin.z; + point.y = pm->ps.origin.y; + point.z = pm->ps.origin.z + MINS_Z + 1; //cont = pm->pointcontents( point, pm->ps->clientNum ); - bool checkWater = (pml.hasWater && pml.waterHeight > point.y); + bool checkWater = (pml.hasWater && pml.waterHeight > point.z); //if ( cont & MASK_WATER ) if ( checkWater) { @@ -1729,14 +1729,14 @@ void PM_SetWaterLevel( playerMove* const pm ) pm->ps.watertype = CONTENTS_WATER;//cont; pm->ps.waterlevel = WL_ANKLE; //point[2] = pm->ps->origin[2] + MINS_Z + sample1; - point.y = pm->ps.origin.y + MINS_Z + sample1; + point.z = pm->ps.origin.z + MINS_Z + sample1; //cont = pm->pointcontents (point, pm->ps->clientNum ); //if ( cont & MASK_WATER ) if (checkWater) { pm->ps.waterlevel = WL_WAIST; //point[2] = pm->ps->origin[2] + MINS_Z + sample2; - point.y = pm->ps.origin.y + MINS_Z + sample2; + point.z = pm->ps.origin.z + MINS_Z + sample2; //cont = pm->pointcontents (point, pm->ps->clientNum ); //if ( cont & MASK_WATER ) if (checkWater ) From d568b27b9272ca46670b59ffba4b85336d79cb76 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 18 Apr 2012 16:53:56 +0200 Subject: [PATCH 062/109] spell widget i18n improvements (used e.g. in birth menu) --- apps/openmw/mwclass/weapon.cpp | 30 +++++++++++++++++++++++ apps/openmw/mwgui/tooltips.cpp | 44 +++++++++++++++++++--------------- apps/openmw/mwgui/tooltips.hpp | 14 +++++++++-- apps/openmw/mwgui/widgets.cpp | 20 +++++++++++----- 4 files changed, 81 insertions(+), 27 deletions(-) diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index d2ea92126..bfb5074b0 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -326,6 +326,36 @@ namespace MWClass text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str); + // this should be going into a custom mygui widget MWEnchantment + /* + // enchantments + if (ref->base->enchant != "") + { + const ESM::Enchantment* enchant = environment.mWorld->getStore().enchants.search(ref->base->enchant); + if (enchant->data.type == ESM::Enchantment::CastOnce) + text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastOnce")->str; + else if (enchant->data.type == ESM::Enchantment::WhenStrikes) + text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastWhenStrikes")->str; + else if (enchant->data.type == ESM::Enchantment::WhenUsed) + text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastWhenUsed")->str; + else if (enchant->data.type == ESM::Enchantment::ConstantEffect) + text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastConstant")->str; + + if (enchant->data.type == ESM::Enchantment::WhenStrikes + || enchant->data.type == ESM::Enchantment::WhenUsed) + { + /// \todo store the current enchantment charge somewhere + // info.currentCharge = enchant->data.charge; + //info.totalCharge = enchant->data.charge; + } + } + */ + if (ref->base->enchant != "") + { + const ESM::Enchantment* enchant = environment.mWorld->getStore().enchants.search(ref->base->enchant); + info.enchant = enchant; + } + if (environment.mWindowManager->getFullHelp()) { text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index ab766dc56..5c69cedb6 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -51,26 +51,35 @@ void ToolTips::onFrame(float frameDuration) std::string type = focus->getUserString("ToolTipType"); std::string text = focus->getUserString("ToolTipText"); + + ToolTipInfo info; + if (type == "") { mDynamicToolTipBox->setVisible(false); return; - } + } else if (type == "Text") - tooltipSize = createToolTip(text, "", 0, ""); + { + info.caption = text; + } else if (type == "CaptionText") { std::string caption = focus->getUserString("ToolTipCaption"); - tooltipSize = createToolTip(caption, "", 0, text); + info.caption = caption; + info.text = text; } else if (type == "ImageCaptionText") { std::string caption = focus->getUserString("ToolTipCaption"); std::string image = focus->getUserString("ToolTipImage"); std::string sizeString = focus->getUserString("ToolTipImageSize"); - int size = (sizeString != "" ? boost::lexical_cast(sizeString) : 32); - tooltipSize = createToolTip(caption, image, size, text); + + info.text = text; + info.caption = caption; + info.icon = image; } + tooltipSize = createToolTip(info); IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24); @@ -137,14 +146,7 @@ IntSize ToolTips::getToolTipViaPtr () mDynamicToolTipBox->setVisible(true); ToolTipInfo info = object.getToolTipInfo(mFocusObject, mWindowManager->getEnvironment()); - if (info.icon == "") - { - tooltipSize = createToolTip(info.caption, "", 0, info.text); - } - else - { - tooltipSize = createToolTip(info.caption, info.icon, 32, info.text); - } + tooltipSize = createToolTip(info); } return tooltipSize; @@ -164,12 +166,16 @@ void ToolTips::findImageExtension(std::string& image) } } -IntSize ToolTips::createToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text) +IntSize ToolTips::createToolTip(const ToolTipInfo& info) { + std::string caption = info.caption; + std::string image = info.icon; + int imageSize = (image != "") ? 32 : 0; + std::string text = info.text; + // remove the first newline (easier this way) - std::string realText = text; - if (realText.size() > 0 && realText[0] == '\n') - realText.erase(0, 1); + if (text.size() > 0 && text[0] == '\n') + text.erase(0, 1); // this the maximum width of the tooltip before it starts word-wrapping setCoord(0, 0, 300, 300); @@ -193,13 +199,13 @@ IntSize ToolTips::createToolTip(const std::string& caption, const std::string& i textWidget->setProperty("Static", "true"); textWidget->setProperty("MultiLine", "true"); textWidget->setProperty("WordWrap", "true"); - textWidget->setCaption(realText); + textWidget->setCaption(text); textWidget->setTextAlign(Align::HCenter | Align::Top); IntSize textSize = textWidget->getTextSize(); captionSize += IntSize(imageSize, 0); // adjust for image IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width + ((image != "") ? imageCaptionHPadding : 0)), - ((realText != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight ); + ((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight ); if (image != "") { diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index d84a1093b..c00faba86 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -13,11 +13,21 @@ namespace MWGui struct ToolTipInfo { public: + ToolTipInfo() : + enchant(0), + effects(0) + { + }; + std::string caption; std::string text; std::string icon; - /// \todo enchantments (armor, cloth, weapons), magic effects (potions, ingredients) + // enchantment (for cloth, armor, weapons) + const ESM::Enchantment* enchant; + + // effects (for potions, ingredients) + const ESM::EffectList* effects; }; class ToolTips : public OEngine::GUI::Layout @@ -56,7 +66,7 @@ namespace MWGui MyGUI::IntSize getToolTipViaPtr (); ///< @return requested tooltip size - MyGUI::IntSize createToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text); + MyGUI::IntSize createToolTip(const ToolTipInfo& info); ///< @return requested tooltip size bool mGameMode; diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 74603aaf1..c83383468 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -290,6 +290,12 @@ void MWSpellEffect::updateWidgets() { if (magicEffect) { + std::string pt = mWindowManager->getGameSettingString("spoint", ""); + std::string pts = mWindowManager->getGameSettingString("spoints", ""); + std::string to = " " + mWindowManager->getGameSettingString("sTo", "") + " "; + std::string sec = " " + mWindowManager->getGameSettingString("ssecond", ""); + std::string secs = " " + mWindowManager->getGameSettingString("sseconds", ""); + // TODO: Get name of effect from GMST std::string spellLine = ""; if (effect.skill >= 0 && effect.skill < ESM::Skill::Length) @@ -313,22 +319,24 @@ void MWSpellEffect::updateWidgets() if (effect.magnMin >= 0 || effect.magnMax >= 0) { if (effect.magnMin == effect.magnMax) - spellLine += " " + boost::lexical_cast(effect.magnMin) + " pts"; + spellLine += " " + boost::lexical_cast(effect.magnMin) + " " + ((effect.magnMin == 1) ? pt : pts); else { - spellLine += " " + boost::lexical_cast(effect.magnMin) + " to " + boost::lexical_cast(effect.magnMin) + " pts"; + spellLine += " " + boost::lexical_cast(effect.magnMin) + to + boost::lexical_cast(effect.magnMin) + " " + pts; } } if (effect.duration >= 0) { - spellLine += " for " + boost::lexical_cast(effect.duration) + " secs"; + spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast(effect.duration) + ((effect.duration == 1) ? sec : secs); } + + std::string on = mWindowManager->getGameSettingString("sonword", ""); if (effect.range == ESM::RT_Self) - spellLine += " on Self"; + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeSelf", ""); else if (effect.range == ESM::RT_Touch) - spellLine += " on Touch"; + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTouch", ""); else if (effect.range == ESM::RT_Target) - spellLine += " on Target"; + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTarget", ""); static_cast(textWidget)->setCaption(spellLine); } else From c7381d44917629cd804875c23ded7ab2d3cbd539 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 18 Apr 2012 18:09:30 +0200 Subject: [PATCH 063/109] adding widget MWEnchantment --- apps/openmw/mwgui/widgets.cpp | 44 +++++++++++++++++++++++++++++++++++ apps/openmw/mwgui/widgets.hpp | 29 ++++++++++++++++++++++- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index c83383468..568b31455 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -264,6 +264,50 @@ MWSpell::~MWSpell() { } +/* MWEnchantment */ + +MWEnchantment::MWEnchantment() + : mWindowManager(nullptr) +{ +} + +void MWEnchantment::setEnchantmentId(const std::string &enchantId) +{ + id = enchantId; + updateWidgets(); +} + +void MWEnchantment::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord) +{ + const ESMS::ESMStore &store = mWindowManager->getStore(); + const ESM::Enchantment *enchant = store.enchants.search(id); + MYGUI_ASSERT(enchant, "enchantment with id '" << id << "' not found"); + + MWSpellEffectPtr effect = nullptr; + std::vector::const_iterator end = enchant->effects.list.end(); + for (std::vector::const_iterator it = enchant->effects.list.begin(); it != end; ++it) + { + effect = creator->createWidget("MW_EffectImage", coord, MyGUI::Align::Default); + effect->setWindowManager(mWindowManager); + effect->setSpellEffect(*it); + effects.push_back(effect); + coord.top += effect->getHeight(); + } +} + +void MWEnchantment::updateWidgets() +{ +} + +void MWEnchantment::initialiseOverride() +{ + Base::initialiseOverride(); +} + +MWEnchantment::~MWEnchantment() +{ +} + /* MWSpellEffect */ MWSpellEffect::MWSpellEffect() diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index a7916285e..595ee83b6 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -126,7 +126,7 @@ namespace MWGui protected: virtual ~MWSpell(); - virtual void initialiseOverride(); + virtual void initialiseOverride(); private: void updateWidgets(); @@ -137,6 +137,33 @@ namespace MWGui }; typedef MWSpell* MWSpellPtr; + class MYGUI_EXPORT MWEnchantment : public Widget + { + MYGUI_RTTI_DERIVED( MWEnchantment ); + public: + MWEnchantment(); + + typedef MWMechanics::Stat EnchantmentValue; + + void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; } + void setEnchantmentId(const std::string &enchantId); + void createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord); + + const std::string &getSpellId() const { return id; } + + protected: + virtual ~MWEnchantment(); + + virtual void initialiseOverride(); + + private: + void updateWidgets(); + + WindowManager* mWindowManager; + std::string id; + }; + typedef MWEnchantment* MWEnchantmentPtr; + class MYGUI_EXPORT MWSpellEffect : public Widget { MYGUI_RTTI_DERIVED( MWSpellEffect ); From 4949576984cd791de0cc68c1013a15e14ad264a2 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 18 Apr 2012 19:03:26 +0200 Subject: [PATCH 064/109] disable some player controls in gui mode --- apps/openmw/mwinput/inputmanager.cpp | 48 +++++++++++++++------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index 9b5a9ae30..c2233f626 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -97,34 +97,36 @@ namespace MWInput 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"; - } + if (windows.isGuiMode()) return; + 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"; - } + if (windows.isGuiMode()) return; + 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() @@ -184,11 +186,13 @@ namespace MWInput void toggleAutoMove() { + if (windows.isGuiMode()) return; player.setAutoMove (!player.getAutoMove()); } void toggleWalking() { + if (windows.isGuiMode()) return; player.toggleRunning(); } From 4889902b9879aecdf45542b2d5584052de15cb9e Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 18 Apr 2012 21:18:53 +0200 Subject: [PATCH 065/109] magic effect widget improvements, read name of effect from GMST and don't show duration/target for constant effects --- apps/openmw/mwgui/birth.cpp | 2 +- apps/openmw/mwgui/widgets.cpp | 180 ++++++++++++++++++++++++++++--- apps/openmw/mwgui/widgets.hpp | 6 +- files/mygui/openmw_list.skin.xml | 4 + 4 files changed, 178 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 44c165743..046017204 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -202,7 +202,7 @@ void BirthDialog::updateSpells() MyGUI::IntCoord spellCoord = coord; spellCoord.height = 24; // TODO: This should be fetched from the skin somehow, or perhaps a widget in the layout as a template? - spellWidget->createEffectWidgets(spellItems, spellArea, spellCoord); + spellWidget->createEffectWidgets(spellItems, spellArea, spellCoord, category); coord.top = spellCoord.top; ++i; diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 568b31455..58cfee991 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -222,7 +222,7 @@ void MWSpell::setSpellId(const std::string &spellId) updateWidgets(); } -void MWSpell::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord) +void MWSpell::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, const int category) { const ESMS::ESMStore &store = mWindowManager->getStore(); const ESM::Spell *spell = store.spells.search(id); @@ -234,6 +234,7 @@ void MWSpell::createEffectWidgets(std::vector &effects, MyGUI: { effect = creator->createWidget("MW_EffectImage", coord, MyGUI::Align::Default); effect->setWindowManager(mWindowManager); + effect->setConstant(category == 0); effect->setSpellEffect(*it); effects.push_back(effect); coord.top += effect->getHeight(); @@ -340,8 +341,7 @@ void MWSpellEffect::updateWidgets() std::string sec = " " + mWindowManager->getGameSettingString("ssecond", ""); std::string secs = " " + mWindowManager->getGameSettingString("sseconds", ""); - // TODO: Get name of effect from GMST - std::string spellLine = ""; + std::string spellLine = effectIDToString(effect.effectID); if (effect.skill >= 0 && effect.skill < ESM::Skill::Length) { spellLine += " " + mWindowManager->getGameSettingString(ESM::Skill::sSkillNameIds[effect.skill], ""); @@ -369,18 +369,24 @@ void MWSpellEffect::updateWidgets() spellLine += " " + boost::lexical_cast(effect.magnMin) + to + boost::lexical_cast(effect.magnMin) + " " + pts; } } - if (effect.duration >= 0) + + // constant effects have no duration and no target + if (!mIsConstant) { - spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast(effect.duration) + ((effect.duration == 1) ? sec : secs); + if (effect.duration >= 0) + { + spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast(effect.duration) + ((effect.duration == 1) ? sec : secs); + } + + std::string on = mWindowManager->getGameSettingString("sonword", ""); + if (effect.range == ESM::RT_Self) + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeSelf", ""); + else if (effect.range == ESM::RT_Touch) + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTouch", ""); + else if (effect.range == ESM::RT_Target) + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTarget", ""); } - std::string on = mWindowManager->getGameSettingString("sonword", ""); - if (effect.range == ESM::RT_Self) - spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeSelf", ""); - else if (effect.range == ESM::RT_Touch) - spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTouch", ""); - else if (effect.range == ESM::RT_Target) - spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTarget", ""); static_cast(textWidget)->setCaption(spellLine); } else @@ -394,6 +400,156 @@ void MWSpellEffect::updateWidgets() } } +std::string MWSpellEffect::effectIDToString(const short effectID) +{ + // Map effect ID to GMST name + // http://www.uesp.net/morrow/hints/mweffects.shtml + std::map names; + names[85] ="sEffectAbsorbAttribute"; + names[88] ="sEffectAbsorbFatigue"; + names[86] ="sEffectAbsorbHealth"; + names[87] ="sEffectAbsorbSpellPoints"; + names[89] ="sEffectAbsorbSkill"; + names[63] ="sEffectAlmsiviIntervention"; + names[47] ="sEffectBlind"; + names[123] ="sEffectBoundBattleAxe"; + names[129] ="sEffectBoundBoots"; + names[127] ="sEffectBoundCuirass"; + names[120] ="sEffectBoundDagger"; + names[131] ="sEffectBoundGloves"; + names[128] ="sEffectBoundHelm"; + names[125] ="sEffectBoundLongbow"; + names[121] ="sEffectBoundLongsword"; + names[122] ="sEffectBoundMace"; + names[130] ="sEffectBoundShield"; + names[124] ="sEffectBoundSpear"; + names[7] ="sEffectBurden"; + names[50] ="sEffectCalmCreature"; + names[49] ="sEffectCalmHumanoid"; + names[40] ="sEffectChameleon"; + names[44] ="sEffectCharm"; + names[118] ="sEffectCommandCreatures"; + names[119] ="sEffectCommandHumanoids"; + names[132] ="sEffectCorpus"; // NB this typo. (bethesda made it) + names[70] ="sEffectCureBlightDisease"; + names[69] ="sEffectCureCommonDisease"; + names[71] ="sEffectCureCorprusDisease"; + names[73] ="sEffectCureParalyzation"; + names[72] ="sEffectCurePoison"; + names[22] ="sEffectDamageAttribute"; + names[25] ="sEffectDamageFatigue"; + names[23] ="sEffectDamageHealth"; + names[24] ="sEffectDamageMagicka"; + names[26] ="sEffectDamageSkill"; + names[54] ="sEffectDemoralizeCreature"; + names[53] ="sEffectDemoralizeHumanoid"; + names[64] ="sEffectDetectAnimal"; + names[65] ="sEffectDetectEnchantment"; + names[66] ="sEffectDetectKey"; + names[38] ="sEffectDisintegrateArmor"; + names[37] ="sEffectDisintegrateWeapon"; + names[57] ="sEffectDispel"; + names[62] ="sEffectDivineIntervention"; + names[17] ="sEffectDrainAttribute"; + names[20] ="sEffectDrainFatigue"; + names[18] ="sEffectDrainHealth"; + names[19] ="sEffectDrainSpellpoints"; + names[21] ="sEffectDrainSkill"; + names[8] ="sEffectFeather"; + names[14] ="sEffectFireDamage"; + names[4] ="sEffectFireShield"; + names[117] ="sEffectFortifyAttackBonus"; + names[79] ="sEffectFortifyAttribute"; + names[82] ="sEffectFortifyFatigue"; + names[80] ="sEffectFortifyHealth"; + names[81] ="sEffectFortifySpellpoints"; + names[84] ="sEffectFortifyMagickaMultiplier"; + names[83] ="sEffectFortifySkill"; + names[52] ="sEffectFrenzyCreature"; + names[51] ="sEffectFrenzyHumanoid"; + names[16] ="sEffectFrostDamage"; + names[6] ="sEffectFrostShield"; + names[39] ="sEffectInvisibility"; + names[9] ="sEffectJump"; + names[10] ="sEffectLevitate"; + names[41] ="sEffectLight"; + names[5] ="sEffectLightningShield"; + names[12] ="sEffectLock"; + names[60] ="sEffectMark"; + names[43] ="sEffectNightEye"; + names[13] ="sEffectOpen"; + names[45] ="sEffectParalyze"; + names[27] ="sEffectPoison"; + names[56] ="sEffectRallyCreature"; + names[55] ="sEffectRallyHumanoid"; + names[61] ="sEffectRecall"; + names[68] ="sEffectReflect"; + names[100] ="sEffectRemoveCurse"; + names[95] ="sEffectResistBlightDisease"; + names[94] ="sEffectResistCommonDisease"; + names[96] ="sEffectResistCorprusDisease"; + names[90] ="sEffectResistFire"; + names[91] ="sEffectResistFrost"; + names[93] ="sEffectResistMagicka"; + names[98] ="sEffectResistNormalWeapons"; + names[99] ="sEffectResistParalysis"; + names[97] ="sEffectResistPoison"; + names[92] ="sEffectResistShock"; + names[74] ="sEffectRestoreAttribute"; + names[77] ="sEffectRestoreFatigue"; + names[75] ="sEffectRestoreHealth"; + names[76] ="sEffectRestoreSpellPoints"; + names[78] ="sEffectRestoreSkill"; + names[42] ="sEffectSanctuary"; + names[3] ="sEffectShield"; + names[15] ="sEffectShockDamage"; + names[46] ="sEffectSilence"; + names[11] ="sEffectSlowFall"; + names[58] ="sEffectSoultrap"; + names[48] ="sEffectSound"; + names[67] ="sEffectSpellAbsorption"; + names[136] ="sEffectStuntedMagicka"; + names[106] ="sEffectSummonAncestralGhost"; + names[110] ="sEffectSummonBonelord"; + names[108] ="sEffectSummonLeastBonewalker"; + names[134] ="sEffectSummonCenturionSphere"; + names[103] ="sEffectSummonClannfear"; + names[104] ="sEffectSummonDaedroth"; + names[105] ="sEffectSummonDremora"; + names[114] ="sEffectSummonFlameAtronach"; + names[115] ="sEffectSummonFrostAtronach"; + names[113] ="sEffectSummonGoldenSaint"; + names[109] ="sEffectSummonGreaterBonewalker"; + names[112] ="sEffectSummonHunger"; + names[102] ="sEffectSummonScamp"; + names[107] ="sEffectSummonSkeletalMinion"; + names[116] ="sEffectSummonStormAtronach"; + names[111] ="sEffectSummonWingedTwilight"; + names[135] ="sEffectSunDamage"; + names[1] ="sEffectSwiftSwim"; + names[59] ="sEffectTelekinesis"; + names[101] ="sEffectTurnUndead"; + names[133] ="sEffectVampirism"; + names[0] ="sEffectWaterBreathing"; + names[2] ="sEffectWaterWalking"; + names[33] ="sEffectWeaknesstoBlightDisease"; + names[32] ="sEffectWeaknesstoCommonDisease"; + names[34] ="sEffectWeaknesstoCorprusDisease"; + names[28] ="sEffectWeaknesstoFire"; + names[29] ="sEffectWeaknesstoFrost"; + names[31] ="sEffectWeaknesstoMagicka"; + names[36] ="sEffectWeaknesstoNormalWeapons"; + names[35] ="sEffectWeaknesstoPoison"; + names[30] ="sEffectWeaknesstoShock"; + + assert(names.find(effectID) != names.end() && "Unimplemented effect type"); + std::string res = mWindowManager->getGameSettingString(names[effectID], ""); + if (res == "") + std::cout << "Warning: Unknown effect name " << names[effectID] << std::endl; + + return res; +} + MWSpellEffect::~MWSpellEffect() { } diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index 595ee83b6..8ac27795d 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -119,7 +119,7 @@ namespace MWGui void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; } void setSpellId(const std::string &id); - void createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord); + void createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, const int category); const std::string &getSpellId() const { return id; } @@ -174,6 +174,9 @@ namespace MWGui void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; } void setSpellEffect(SpellEffectValue value); + void setConstant(bool constant) { mIsConstant = constant; } + + std::string effectIDToString(const short effectID); const SpellEffectValue &getSpellEffect() const { return effect; } @@ -188,6 +191,7 @@ namespace MWGui WindowManager* mWindowManager; SpellEffectValue effect; + bool mIsConstant; // constant effect MyGUI::ImageBox* imageWidget; MyGUI::TextBox* textWidget; }; diff --git a/files/mygui/openmw_list.skin.xml b/files/mygui/openmw_list.skin.xml index 5ec975a1b..02075ad1a 100644 --- a/files/mygui/openmw_list.skin.xml +++ b/files/mygui/openmw_list.skin.xml @@ -184,6 +184,10 @@ + + + + From aa4a1b675fcc138c5b15f7d031846f2253b62f89 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 19 Apr 2012 01:08:26 +0200 Subject: [PATCH 066/109] fixed the sky reflection issue --- apps/openmw/mwrender/renderconst.hpp | 2 ++ apps/openmw/mwrender/renderingmanager.cpp | 2 ++ apps/openmw/mwrender/water.cpp | 44 ++++++++++++++++++----- apps/openmw/mwrender/water.hpp | 9 ++++- 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwrender/renderconst.hpp b/apps/openmw/mwrender/renderconst.hpp index 2c7f9e9ac..c4aa093c0 100644 --- a/apps/openmw/mwrender/renderconst.hpp +++ b/apps/openmw/mwrender/renderconst.hpp @@ -52,6 +52,8 @@ enum VisibilityFlags // Sun glare (not visible in reflection) RV_Glare = 128, + RV_OcclusionQuery = 256, + RV_Map = RV_Terrain + RV_Statics + RV_StaticsSmall + RV_Misc + RV_Water, /// \todo markers (normally hidden) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 3082cf0d7..581973811 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -225,6 +225,8 @@ void RenderingManager::update (float duration){ mLocalMap->updatePlayer( mRendering.getCamera()->getRealPosition(), mRendering.getCamera()->getRealOrientation() ); checkUnderwater(); + + mWater->update(); } void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){ if(store->cell->data.flags & store->cell->HasWater){ diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 71cf56dfd..445677808 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -11,7 +11,8 @@ namespace MWRender Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) : mCamera (camera), mViewport (camera->getViewport()), mSceneManager (camera->getSceneManager()), mIsUnderwater(false), mVisibilityFlags(0), - mReflectionTarget(0), mActive(1), mToggled(1) + mReflectionTarget(0), mActive(1), mToggled(1), + mReflectionRenderActive(false) { mSky = sky; @@ -81,6 +82,8 @@ Water::Water (Ogre::Camera *camera, SkyManager* sky, const ESM::Cell* cell) : mUnderwaterEffect = Settings::Manager::getBool("underwater effect", "Water"); + mSceneManager->addRenderQueueListener(this); + // ---------------------------------------------------------------------------------------------- // ---------------------------------- reflection debug overlay ---------------------------------- @@ -161,6 +164,7 @@ void Water::changeCell(const ESM::Cell* cell) void Water::setHeight(const float height) { mTop = height; + mWaterPlane = Plane(Vector3::UNIT_Y, height); mWaterNode->setPosition(0, height, 0); } @@ -220,17 +224,15 @@ void Water::preRenderTargetUpdate(const RenderTargetEvent& evt) mReflectionCamera->setFarClipDistance(mCamera->getFarClipDistance()); mReflectionCamera->setAspectRatio(mCamera->getAspectRatio()); mReflectionCamera->setFOVy(mCamera->getFOVy()); + mReflectionRenderActive = true; - // Some messy code to get the skybox to show up at all - // The problem here is that it gets clipped by the water plane - // Therefore scale it up a bit + /// \todo For some reason this camera is delayed for 1 frame, which causes ugly sky reflection behaviour.. + /// to circumvent this we just scale the sky up, so it's not that noticable Vector3 pos = mCamera->getRealPosition(); pos.y = mTop*2 - pos.y; mSky->setSkyPosition(pos); - mSky->scaleSky(mCamera->getFarClipDistance() / 1000.f); - - mReflectionCamera->enableCustomNearClipPlane(Plane(Vector3::UNIT_Y, mTop)); - mReflectionCamera->enableReflection(Plane(Vector3::UNIT_Y, mTop)); + mSky->scaleSky(mCamera->getFarClipDistance() / 5000.f); + mReflectionCamera->enableReflection(mWaterPlane); } } @@ -240,8 +242,9 @@ void Water::postRenderTargetUpdate(const RenderTargetEvent& evt) { mSky->resetSkyPosition(); mSky->scaleSky(1); - mReflectionCamera->disableCustomNearClipPlane(); mReflectionCamera->disableReflection(); + mReflectionCamera->disableCustomNearClipPlane(); + mReflectionRenderActive = false; } } @@ -290,4 +293,27 @@ void Water::updateVisible() mReflectionTarget->setActive(mToggled && mActive && !mIsUnderwater); } +void Water::renderQueueStarted (Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation) +{ + // We don't want the sky to get clipped by custom near clip plane (the water plane) + if (queueGroupId < 20 && mReflectionRenderActive) + { + mReflectionCamera->disableCustomNearClipPlane(); + Root::getSingleton().getRenderSystem()->_setProjectionMatrix(mReflectionCamera->getProjectionMatrixRS()); + } +} + +void Water::renderQueueEnded (Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation) +{ + if (queueGroupId < 20 && mReflectionRenderActive) + { + mReflectionCamera->enableCustomNearClipPlane(mWaterPlane); + Root::getSingleton().getRenderSystem()->_setProjectionMatrix(mReflectionCamera->getProjectionMatrixRS()); + } +} + +void Water::update() +{ +} + } // namespace diff --git a/apps/openmw/mwrender/water.hpp b/apps/openmw/mwrender/water.hpp index f14482e2b..c8b8d311e 100644 --- a/apps/openmw/mwrender/water.hpp +++ b/apps/openmw/mwrender/water.hpp @@ -11,7 +11,7 @@ namespace MWRender { class SkyManager; /// Water rendering - class Water : public Ogre::RenderTargetListener + class Water : public Ogre::RenderTargetListener, public Ogre::RenderQueueListener { static const int CELL_SIZE = 8192; Ogre::Camera *mCamera; @@ -27,11 +27,17 @@ namespace MWRender { bool mToggled; int mTop; + bool mReflectionRenderActive; + Ogre::Vector3 getSceneNodeCoordinates(int gridX, int gridY); protected: void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt); void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt); + + void renderQueueStarted (Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation); + void renderQueueEnded (Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation); + void updateVisible(); SkyManager* mSky; @@ -55,6 +61,7 @@ namespace MWRender { void setActive(bool active); void toggle(); + void update(); void setViewportBackground(const Ogre::ColourValue& bg); From fb0e649191270e9c4f4720c2a4983520cf01a632 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 19 Apr 2012 01:10:55 +0200 Subject: [PATCH 067/109] minor fix --- apps/openmw/mwrender/occlusionquery.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwrender/occlusionquery.cpp b/apps/openmw/mwrender/occlusionquery.cpp index 80b804dce..6d3f67de9 100644 --- a/apps/openmw/mwrender/occlusionquery.cpp +++ b/apps/openmw/mwrender/occlusionquery.cpp @@ -65,6 +65,7 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod mBBQueryTotal->createBillboard(Vector3::ZERO); mBBQueryTotal->setMaterialName("QueryTotalPixels"); mBBQueryTotal->setRenderQueueGroup(RQG_OcclusionQuery+1); + mBBQueryTotal->setVisibilityFlags(RV_OcclusionQuery); mBBNodeReal->attachObject(mBBQueryTotal); mBBQueryVisible = mRendering->getScene()->createBillboardSet(1); @@ -73,6 +74,7 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod mBBQueryVisible->createBillboard(Vector3::ZERO); mBBQueryVisible->setMaterialName("QueryVisiblePixels"); mBBQueryVisible->setRenderQueueGroup(RQG_OcclusionQuery+1); + mBBQueryVisible->setVisibilityFlags(RV_OcclusionQuery); mBBNodeReal->attachObject(mBBQueryVisible); mBBQuerySingleObject = mRendering->getScene()->createBillboardSet(1); @@ -82,6 +84,7 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod mBBQuerySingleObject->createBillboard(Vector3::ZERO); mBBQuerySingleObject->setMaterialName("QueryVisiblePixels"); mBBQuerySingleObject->setRenderQueueGroup(RQG_OcclusionQuery); + mBBQuerySingleObject->setVisibilityFlags(RV_OcclusionQuery); mObjectNode->attachObject(mBBQuerySingleObject); mRendering->getScene()->addRenderObjectListener(this); From 934caf7a2b7efca4f69e2cc3040be41ffe5a42aa Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 19 Apr 2012 01:16:41 +0200 Subject: [PATCH 068/109] removed --report-focus which is now useless --- apps/openmw/engine.cpp | 51 ------------------------------------------ apps/openmw/engine.hpp | 6 ----- apps/openmw/main.cpp | 4 ---- readme.txt | 1 - 4 files changed, 62 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 36a2cb645..77cb80b0d 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -72,47 +72,6 @@ void OMW::Engine::executeLocalScripts() localScripts.setIgnore (MWWorld::Ptr()); } -void OMW::Engine::updateFocusReport (float duration) -{ - - if ((mFocusTDiff += duration)>0.25) - { - mFocusTDiff = 0; - - std::string name; - - std::string handle = mEnvironment.mWorld->getFacedHandle(); - - if (!handle.empty()) - { - // the faced handle is not updated immediately, so on a cell change it might - // point to an object that doesn't exist anymore - // therefore, we are catching the "Unknown Ogre handle" exception that occurs in this case - try - { - MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle); - - if (!ptr.isEmpty()){ - name = MWWorld::Class::get (ptr).getName (ptr); - - } - } - catch (std::runtime_error& e) - {} - } - - if (name!=mFocusName) - { - mFocusName = name; - - if (mFocusName.empty()) - std::cout << "Unfocus" << std::endl; - else - std::cout << "Focus: " << name << std::endl; - } - } -} - void OMW::Engine::setAnimationVerbose(bool animverbose){ if(animverbose){ NifOgre::NIFLoader::getSingletonPtr()->setOutputAnimFiles(true); @@ -170,10 +129,6 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) window->getBatchCount()); mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration); - - // report focus object (for debugging) - if (mReportFocus) - updateFocusReport (mEnvironment.mFrameDuration); } catch (const std::exception& e) { @@ -191,7 +146,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) , mNewGame (false) , mUseSound (true) , mCompileAll (false) - , mReportFocus (false) , mFocusTDiff (0) , mScriptContext (0) , mFSStrict (false) @@ -303,11 +257,6 @@ void OMW::Engine::setNewGame(bool newGame) mNewGame = newGame; } -void OMW::Engine::setReportFocus (bool report) -{ - mReportFocus = report; -} - // Initialise and enter main loop. void OMW::Engine::go() diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 6eae20cc0..a95d4cb5c 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -73,7 +73,6 @@ namespace OMW bool mNewGame; bool mUseSound; bool mCompileAll; - bool mReportFocus; float mFocusTDiff; std::string mFocusName; std::map mFallbackMap; @@ -100,8 +99,6 @@ namespace OMW void executeLocalScripts(); - void updateFocusReport (float duration); - virtual bool frameRenderingQueued (const Ogre::FrameEvent& evt); public: @@ -144,9 +141,6 @@ namespace OMW /// Start as a new game. void setNewGame(bool newGame); - /// Write name of focussed object to cout - void setReportFocus (bool report); - /// Initialise and enter main loop. void go(); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index df52faab1..68aa12fb3 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -155,9 +155,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat "\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n" "\n\twin1252 - Western European (Latin) alphabet, used by default") - ("report-focus", bpo::value()->implicit_value(true) - ->default_value(false), "write name of focussed object to cout") - ("fallback", bpo::value()->default_value(FallbackMap(), "") ->multitoken()->composing(), "fallback values") @@ -265,7 +262,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat engine.setSoundUsage(!variables["nosound"].as()); engine.setScriptsVerbosity(variables["script-verbose"].as()); engine.setCompileAll(variables["script-all"].as()); - engine.setReportFocus(variables["report-focus"].as()); engine.setAnimationVerbose(variables["anim-verbose"].as()); engine.setFallbackValues(variables["fallback"].as().mMap); diff --git a/readme.txt b/readme.txt index 52c4e11a2..53f4a4c59 100644 --- a/readme.txt +++ b/readme.txt @@ -87,7 +87,6 @@ Allowed options: win1252 - Western European (Latin) alphabet, used by default - --report-focus [=arg(=1)] (=0) write name of focussed object to cout --fallback arg fallback values From 00260a24ce0c125582b48a1a2ca4d3457913cf5b Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Wed, 18 Apr 2012 21:28:25 -0400 Subject: [PATCH 069/109] Water corrections --- libs/openengine/bullet/pmove.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 214a7e598..7741d2f04 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -1730,6 +1730,7 @@ void PM_SetWaterLevel( playerMove* const pm ) pm->ps.waterlevel = WL_ANKLE; //point[2] = pm->ps->origin[2] + MINS_Z + sample1; point.z = pm->ps.origin.z + MINS_Z + sample1; + checkWater = (pml.hasWater && pml.waterHeight > point.z); //cont = pm->pointcontents (point, pm->ps->clientNum ); //if ( cont & MASK_WATER ) if (checkWater) @@ -1739,6 +1740,7 @@ void PM_SetWaterLevel( playerMove* const pm ) point.z = pm->ps.origin.z + MINS_Z + sample2; //cont = pm->pointcontents (point, pm->ps->clientNum ); //if ( cont & MASK_WATER ) + checkWater = (pml.hasWater && pml.waterHeight > point.z); if (checkWater ) pm->ps.waterlevel = WL_UNDERWATER; } From f7a03b39c4db9e50604520e8e552d8a97941a419 Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Thu, 19 Apr 2012 14:58:27 +0200 Subject: [PATCH 070/109] Some improvments for windows builds and installer --- CMakeLists.txt | 11 ++++++++--- files/openmw.bmp | Bin 0 -> 79926 bytes files/plugins.cfg.win32 | 10 +++++----- 3 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 files/openmw.bmp diff --git a/CMakeLists.txt b/CMakeLists.txt index 40347898b..f3ef797dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -359,12 +359,17 @@ if(DPKG_PROGRAM) endif(DPKG_PROGRAM) if(WIN32) - FILE(GLOB files "${OpenMW_BINARY_DIR}/Release/*.*") - INSTALL(FILES ${files} DESTINATION ".") + FILE(GLOB dll_files "${OpenMW_BINARY_DIR}/Release/*.dll") + INSTALL(FILES ${dll_files} DESTINATION ".") INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg") INSTALL(FILES + "${OpenMW_BINARY_DIR}/plugins.cfg" "${OpenMW_SOURCE_DIR}/readme.txt" + "${OpenMW_BINARY_DIR}/launcher.qss" "${OpenMW_BINARY_DIR}/settings-default.cfg" + "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" + "${OpenMW_BINARY_DIR}/Release/omwlauncher.exe" + "${OpenMW_BINARY_DIR}/Release/openmw.exe" DESTINATION ".") INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ".") @@ -390,7 +395,7 @@ if(WIN32) SET(CPACK_NSIS_INSTALLED_ICON_NAME "omwlauncher.exe") SET(CPACK_NSIS_MUI_ICON "${OpenMW_SOURCE_DIR}/apps/launcher/resources/images/openmw.ico") SET(CPACK_NSIS_MUI_UNIICON "${OpenMW_SOURCE_DIR}/apps/launcher/resources/images/openmw.ico") - # SET(CPACK_PACKAGE_ICON "${OpenMW_SOURCE_DIR}\\\\files\\\\openmw.bmp") + SET(CPACK_PACKAGE_ICON "${OpenMW_SOURCE_DIR}\\\\files\\\\openmw.bmp") SET(VCREDIST32 "${OpenMW_BINARY_DIR}/vcredist_x86.exe") if(EXISTS ${VCREDIST32}) diff --git a/files/openmw.bmp b/files/openmw.bmp new file mode 100644 index 0000000000000000000000000000000000000000..be3fd94ce7a55f272e285089fbe7f7966aeaead1 GIT binary patch literal 79926 zcmeFaWq4y*k~TQskKI4J&+g28-Lu`*R9)Cr)rFl!S&*5P%;YpPGcz+YGcz-j%(i5b zLAE8?mSoG!oKE}h>%2W$kL`3jT{Yjc&y4Pq<+{2$5GNwuh&XZ1x%%n;SKs`Pe>%9n z!he6kf4{~@dHnx>{L^pn7Z<*7`oI3^<$vUZfBGjvcnLWm_Q&pTmFAqRx`5$b@D1Lx;}5I^VVov@~m148@=bwJ30^K(FmpY!uh zSX0OWA%289AmqULIUvN(`FSU-Ddd0DAjFSQ2ZS6rKL>>PIX~}&HH91y;zy_hLJpjt148_qpLfEVLJkP=Bh&#Q z2hPs{A%4!!J7G;B2ZZ<$>VS{~=jVVBKj-J2u%?g$Li`AIK*)jfb3lln^YczvQ^)}! zeuO$8(n=dci;3LL}uTTW^ z{ihD{l=1)9`wE-{OG%zXfk;g{^7j-473d!+Ba}pIN2GI>E)Mr7=#G^2t9TB;pws2$ z<@x#fg@uK+wKX(ydX*zhfiP5AU0t1QAI*2u`n@V{S7CKC_w6$*f58yg!Zit6W#?Z07NC<>4RW-cx+^7(uY zhXW?F+3eAOzwmKm|lm2Q#Mp}x>RTxbUt@30c%9+HA^Q3hS0HMEKA-+TBE|0loV z@pzCjlmYO7Zk#9=QuWd1*eH8suzz@H2(_RXpy$N$Cq6{uD=RCgIN0CU+uhaQ*9Y!omcXGuTIOZ*Housj4n7t12t4 zEG?<7D66loYHq0S?dk->XJ%%Av?IC&{=@u_kB#8 z#^|S0+gh3^^$>A&MR{deNqI?ec}Y=OaS{GjmX+32lsDAXc6PL*DS-AAZvb%vsQd|D z6P;lgl9-;EO{e#w3LXl&{)ac94R)cQ-kVj^WbEP_pODnm)ipaidzk)z*vM-Y_{H!8 z(m^F`43Ebh=%YhU`8nCi32|OQVRk`L=D~5Mp^27}DfTfbHsOf|K4FF)!G_ijj`j{g z{(cFu(IrKN%}q^kPOy1^ADR;4=d}b$7KRiy*4H`w>4LVduZU%;Li0Qa}juIvn1RN(}Hc(0cCZJL{QPw=_2+YJj&v%VZb88@lLb zanou$LUYP}Q*zy7QyoL1t$jnxJOd4!eRUnY4V=9UTzxIPL+nH193xV^6Y`=`a(jAv z7v|@IJwa242Z*i_u#GW?6B~Qq)d`eRH=xwjG8ha%?r^cw??Kz-9LTJ+4e$QSDmQ=-O1J zt*P{E*bMC$uwG~|w!iW3GGy+GlnmYW&X%xnS2wYAba2YbNUN`}@9XP>X#_XnyTNNA zkj^e$uxoQ;ePD7Xd}zj;#(!2gDotG#qpjcX-o4Vi^;HV~UAPy8G$v_vtPbGcKERU{SGb&O!CQ9MUHqT2o zEs0jmJ*%9RZ(osbUz2QH5v%4u%XkEeTHZZ@@}1F<`-BMG6yJQCiY!U2c_@!P`O z+~g>W+T0kInQN9@tkKL9Yg+igF8f;r6Ln4P$e@5$N-c9_1g;*A<#7Cl`}z5~rp89A znjxvW$#?H4Xc(Fo7ZqU|1HC6z5ZZh&%U_tA;;=`0I!lU+Lz6RX!xH7%7bT0?qJ=E+ zB9>GoN1~EGlzPpOZr7Ya-=b7u-$i|Q2~B-#dq;Oq&wzk{;E<58h={Q07)Q@Q zlR}CyeNm;2FI_sO(J`k`J0Y9j{lznF1r@EN_&7>^9m2UI2J##u{BKnSS^|p$*A27H zVlf+PYocPJw7aIo+E?E;OS<+@+}G2sAV0siw->@YO z&Pt_J%N0>g+1pR!s=m~4dnBbC?(dzRl3Z3=g6R#7O6}?H!oQC8wx$M3X--x`T%2oZ zlU~oXO4ow<(3%}@+jL~>JKLDcVyf;Qo`v~&aK4xkl43@WXB^dk=VIUzbP+ZiC>mw6 zD~b!Hs@NiRb8i`hKbBEWjE{phlT&IS4TW)$>_RQXIRo?_--=ebmIdYJiKl5TZ$H$q zb8xJ$uftSc05+7wg)V>x#0W^L78m9{sp3mF@a5|!q{=v|&GVPM@-Ezxz~q)fp}^5W zRZt$aUL_h3Gd(rcSXU#_$X98e{l>5KtA}#Y5n(hM4OE>{QP3a;f|5`zvy$#7rTkm5 z)Hfw;b&SnwtE;$NF8rRLnEGuDBpDuiUtUV==s;PhYfVuRBZ; z_k#036H&LZv&U>|U|;|h!F_?Gf5GwpS8WQsf{eiDp5_Lvj>!kbQ*Uegi7RR3WM#r6 zA#6K7aBz5bW~QyVNvWQz-@hrDRH@a({=_s|R!uiACmU0F)H*H#Qtw+DDGy6I5*1v@ zTCP&llw$MZ7ser%CA3o#<9d2}PONx@0I1UhXFRjAR;F!UwPogUIqQQviq5WXl=}L^ zv#%qy4u1qCb2HQB4J}F~!;;nGGPRr!4MN0~G>Z!hkOBdK4;TKW?$3iCFcD~8TwLg< zwg=U=$#gG^xA4C-@qAjtR2kX1=#u{ZBRL;0&%%Oy7!Tw_V4~nyF+BKC2$j6>5kmr& z5Cb61nwFJq+R8O$ZCVYj7!IyEaCRk<>)yGe=;Ps5URDYx4%31v$L04+G2*{uJK#K{ zvt5nCF&NqV*d{?r&9ERZ2S|Y5I6hv8gEPubD=vT9x}w{^^^=Xie&_0q(ArO)nZ$+% zx3{+gjgZ}uig+?NJKNsUEJB$QtDcmtn^bC>Rqo#SP}S|RlyY`v#u)=J^gcE+;PE{G+{)?9H0XxUAMOYdro!JiGNz*Q8us-O5Tz;K7ie`A>>se-T#xuWST- zJA9#Qd^}D7IL7Yl(Qg_1wuJvj343W}&4Rq#6Y&EWKv@0l&4zVM#m=?wZNsnnXDPSM zDAw}cR`j*BvMMbpMiv30KhhB-GCwzmRUoORDP8KUY%N!|VM?WI{XIzw8EqqU2Q`3i zIZoS=CxAMW-mO>Bt3X}4<(GLqt@|_kK|hf86cJLYdyJ zOCeRC-k10E^Z>7+?t-cR>2%}Um)>lVImAdWDl=%GQfXb#9#~T8nzx@OuDK>&xGNnP z5P(!BTp0`}%99r;!6oo%xH){0-;#gH=eQ>;p2#dgn}Whe>K<e4)$A>b}IM3_*}}?7OuNQDpn7vw#^zacP|(Q+*CA6O-euf24{~>C{BV`y_h|E=k>*B?>JjN$-W8|Fn_09gX|ylJ4Sl?Q zFm1+!4ILe?D0qS{FcqgY)jumAM*{t(ccMzq`lI}=-#*my^>D+Y2<8h%C>PZIIXAD3 z9|Td;laqCg&DPWjncg*x;*PH!qNMvapXTkWtp3kjTsBTbM|lx3PD1M-bwYV zY{M+bn7OVsvToeJYBsofLBmx<8j(Oc)`gJ6L9<{Mlm<2lAK|-jA+#X>;szIJI)jP$?aAFlEMEwi&cE*I&k-ku(i0Xng? zLjHp;wzjt5VNZ8A()7>|-~p&OteQtyB=`tM!5m;j7Y5a_<^wIW@oA?P1-dq$;R35?Bni7mK%(0-3lqb=AErU-+o`&OF_%1 zs2~r)7?5@ts4wfzcC<8$RdF@j=T+OLrD`UgRgL{Y#?9H@rlz_YiMxNO48R75H4@X< zB~!-zDYfZ>UF6+T_M^7Nk8M)Kly&lQvM@kcB>@MH+<3%fGqj4F?VUvrj!=&(kj*%YnNda2>{+*FZXyu7>u0|O!>Ba>57a`W=b zt7`zR{((V+0bt@0+VBzbn_gHNW{rf?c?j_ad5f2dw6g?=1zM6T2KjcSHdw>cauc@{=q^j+q zvY~~eJ8TEoejI*y!o`%jyjG6B^MP5!eOc{-+#F1%!Dm6^Xb?Q%vRN@@4UbBv_2?^K ztD5TeF6uFN-g~HfMZ-#sx^O$O^|F+1d~7tflff<=Hsrv@%=9$!2Z}8->h1FyZF5)+ zm#-N5y|jaut8-ml9maJSZ-RaWHy{AsW2C<~pm9KFVDm;=<9A*u&)ViBX=@jwn=XhO zCdWk~5e47=s&+sF+*egS#gNKZtzrIX>!)7Puh+~q8(RMEpOXwXv1P`LyxubyDPHV)-I*Rh1kVi%bKw498+zWc+x)on7Z&|8S6pK z$eoIT$F+>>rTsT52Og9R$x%4+wOomk0g;S$v7ih&HND(|(%IRA9g|1I0G{sbZ1?l$ z{M*N@TShILxdxq++U*>J<{`b(0j-)|`O+S(8oG9Eze?qxc*BSSWlXQ0C6>|iEQ>Bt z#n7%}>9>xm)eaj_Ms%9TFKgL;drzEFTiwyslRGpX)y}Y~?N+Q}8V;>Qa+ksw(?P>? z!JIXxKE7!aOQ*0yJ}^z)!Z|aiU~+N-0zRE}AQc551x%C^3(K^7Hs1K|(N9n1ONt8M z#4xlY`T@JZjTGPMUQUU8ZqSF0<*Lcd{9q zcog6G(REQ(DKW$5ap^MFJ2G}I?w;81i){per9gtf5+)wltENGn)oSBQRq@P**QLwY zf4Z+7=;H~qg>{P~3>VZTZ$L8wiY{uKT`Bcm`Q*3$`PbvCL|SH5x|VLGQvWFD9N^`S zMI_kG!?-=%2=G5PGMwJpV@#dZD52eU3e&6^HEQEwaxPWU^S-!Iu)hzSKM;62dk?pH z#{1X654Z-D*VI!KM|MpZtCmfScf>SgJ2$Z5;CD|gt*vblWg>2Y%+A>N@nT>lOc9UG zil}LPHoT!bzG*SO>A=}?nJ2FK;ybtWr)tL7JCFDrCQ<-Ym^|#YudAxm>|W9AS=FSkYxJ$&j%j@3 zi9tk=Uu$bCcrGX`==AUn2DLapS6WR`Ea=y#&EB;3dt5dwQa>$HLf7OHe^qf%H?qJ= zI@WMN>hY#f9R`Kk*6P{NZ`8kh$2~?NrChb0chf0Wt&nEJ+Ijbo!zTvlzjnwoE;$vgU1zb!YF};C?q5UH=z(*K1$OiTaaS;qTHb+F3HEY&Q zo6{Gcg{R$jkCLWL-A!uy&NT3vl)9>q48Ty%C)e0FkTMnY^%fRC+zsMYA+ z-}L=|e@7)gG7R%3Bq3o?fLmm)$_w&i7@V{c6=V9;l|NsT`R<8ad`uMZ15_Lt8peg}0)On3;!g+U1v5jW@p@YC#E(rTJfqb=!=?A#A2dgr=ATvRv`$B6e1kK*_}T9}%g zD4?|IH}gyf*8V1=twdY6U($cUHeHcPeB)PqSxOt(Kah<99@j2ZpP8DfYHqiu@|@Y5 z7Zvpk+qve0OYdKieCQSDxj=j%X{KdliFG6>%!vp*PSV+*oE1M{G)|SYwRh^tmE1HKCvV^T3KGE(mFl6$2@pDrrZs4?w0ZR zhSBiaM`lrCiki7EXOoZ$xQV}<(b1~bb{Xb#qv3UlM&`!`ZVy;nUwIY0^-Rmu%BHNe z6jM(uV52ZR8|*Oza74*K2A;sP<69^(OaNz;mETA;YUkRGu008ezGUpC-ZlS~S-=NZ zMNIT{V`E}UOG}Znz(yFv<*>)NsVpxGj*2m5?|rK6_S+xsM}`I?^vBd04WetzyXe%8 zc=k-xI-yh0^1oeG!(0)$U4*+Z&oH0h8}#5r+DI;eLKHwsqK`&(E^d;qWU00Bokw@x zlQsNNL?t#V;#K%Tj;^7hQFnOvl27hu4;0dp65zm*uOpd&Q3JXi_0=+!9L=81D+W&T zC0(YBl~3%`Wr1Bk-KRaHqg%_!7O z%9gUMSvwEnT0XoZpA;93c^&w9qM!xiLQ~vPb`GUYyK6zUb@~&1S0&c|mtJKb$(V~$ zxKEqrJ`pnw4Dd&u=E&5GYyo1$oH?$XqDGz9uIRpF?PbT>P)cuj=ZB|K4xUbvFMc!+ zg6D*Of^3N66k^Wt)miZaHcfIkC0%{;eamuvtNJaRzbfcCur@`@N8gZkwze=WFZ+9n z@VIuqE?HpcP=8-|Tfg1tw)*gv=E$bz(7I;-%H61%cOGg*M}{Lm23DdYT$^ia)S(g4 zkqvRi`kiXVJDS#_BYSV@`F|m6?Cb4KrFNhs8TF#@87bLVU1=H|)*PAD;%wXwh`V9w zq0+bfrA7D!5%~Z=KL`>Y11bp14Q!B*gG($eEO4%9zhdO}r!TIDhlarF1Gi+?2TC?J znlm|{xK4oCHN)TlU5W>P{CG zt>YrYPs9&;M-mW`q}|Bo!>F?NuSujP#=|GT(~{hP^09{oW9vG^YB>_=P1kG!)q55- zih4e}qvYY~fg~aP_UOoPHlt7KMRO{kO^+I!z1_|mN>n(39=JmP(M zdmS5R;1*La5PVpUz%T@X2-&@5$OXGD^{q^r$DKL57xjE^+LLGSXHxTS@%1a#DjuEFkuzI1EkJP@N)Spk*mZl&y+vk zHH?akCb9hw=|LB0AK)2h^hZ!S)q9s^;>yJ1YAk9vt^=zdso7uAGK-Bk89xW=wXo3I z(rU}x5KE|h=bB`4Tr4~aX?+g9U0k4I!(~yg`}lMHqyq84L}%8(rDv0D8DRqt`YaZ>Rw=|5sC-#l%hCk8^H`dd1v$u8WpVVm{{p^XFe?Sln7AzW= zDX9MQZ_bLJ&5aFuPp@<5xH45*ZsO3$ zB(g@dUSH07$mF&?XG6AsLv~4+znI^qch7)`D+Q+^y za*&xK{#DfcioR!DL?}$oIq-wQ4iEPG4NiG*cOG~p{p8@SNt=CF!TpA;W@>U0wCadX z03L8eg9H8fWtFb|b01%Nnx38x=nAae-|@p;3|!m4Xdn8Km~LG3L2M)N1Fzy0z=OKz zj>{a*Z0W|f4DlSwCsOKKRU=OHMep(LPYmOKR5p)&h5rF3fuD}{cBg>_h1B{#-;_lr z7hoXg^arZXe&E&)Lb-79jHjBiA>LqbE~_XIATYzJ}g7;_}0 zrop^t!7x5gBe_7gY5r+MS2wEc5Qk51#2cx_V%71+d4ckI?XQKAs6b zkmBm{a${$=B6U(?c*kyh=do|hH&Nvtv&7wyf{&l+C&fpTX_=oxil8o}KEvl1wa`2U z_&Urr{joKL;Z1Sck`a6RuhvO-)Gc!VeK`z-;RQ2H7TcROpfa;K4!#M}PTGVn7Qllb`f?(TzgU8mCn^+I@qHJrl6 zHkW~UgSx)YA4|v=v>LWg+YK+dPwafC>2uZ4B`)&h`49SCT3n=dwA<4rRBML+a6>UB zGPJR=ku<}YnGMo=f~(u~d)BNP*_ZXKtVg$R1($s%svI8^iDPH*43Gs3HZlZw$$@q6 z?2XX+_wOkO1O>ypk_lz-3cF4-t0_i(8`ix`8Ut&RL)+N8_C#6*>z>E=Ivg1<_=bH$ zg%wri!&^2q?gK}Er$ypoaM=|xwXop8thi_m8dss6|DK$!t&?kYRVBDe+D){B(ZNFX z(K^C=x!&|e^Pni1%nn`J+y&DxMNNa8?98gtlGy4dkIC&X_1x7BOv_74e({aiXTlGd zxV$i5L+g?6o|C1oYO;4EqI2#fRqKsyUI?iAQ9>gRp#XR&-)pVf6V2HmP4rXk(WHtUGDguyp|V2^!%0&g>d?Fn=($Q=28;cx-f2 z$vi18hKwK3;A>H`v%Sq8VgwA$h0GHoQ7O+{g3ai2|NKBtTGuoqEd|>P4zE9wEt854 zy+pPRvm=C;P(FdF0|5(D{8Yxc2Y34`Bj-<^DJCW)^z?K?{HG8`wmCU5L1}0V8JG&B zvA%dLEuL6x&t5U=m@sc)M=TN_sTf|-uuh1MJaPVmesQR?lS*}I8`kUK{qd1@cyIs` z8&G}dJ=Q&e3j5x9C-xpzztw97EXTIrk+aq{G)HcO^zdi_7bH8>+a26Kq(NQyK-WXt z#JaS&2z-DD$mx4bRg=NkmQml5I(^xIx$~)0ikN~rHjk34Qm2gZz=4bmN7uDkj%7zHguY@UGefx3p*^-icXj(s9y<>KmzZ6mafj-s*({~6*@K*mEkt^C|GkolQ}c5>XoLO2Omyl-!m#q{kNlVv}bqOiX+b+B6_ek)>gU)2<+ zkN%s11~q{&BCNx$l&8pM@s5 zayLDATi^Ru-*FF*B8U&9On=gJNQ{dnS9Q?Q;ep`e>gq~Q7tNx$L#bu@t(!`Le!fVW zBa8v}5cwom*V~Q}p7gn&)J%O=37NF|cW*0(1^P8LHNl+%z+`KnggZV~Nomw!?B4N7 z`Qn~zW@-|mDMajm5Y8R=R5Ynlr}aB$4X|X#Ui;WJM@qwhJa_|u9VY3>J;1=~r@J>X z3_Io}{A0dJX}DE2`bT94Lvx$*($cop*7DL~g@MgW0R>-*spq7pAmK?)-Y_&!#U38Y z?C7=bnRm>oeCn5Az}R}6P<~lLGb$ni8>6suiq_I-(zW=&FXxkcayc1kzxYP%GvNn( zoSUAi>greGyf7W#cI9ozB^OGzv+X9If9sudQ%;vWXG=PSBMdsnN2m_Af7Z3OI(Bko z+b6|)mb93g60GOa3&bZrnIFo#Cq{=O3H$%yht0|v<{;C5uZ8`QfrHrSi{GgP+*P$r zjz91}&}qyv5rkkAX!(eSok$*;z({5<#z3Va(;qqdnhnqV^CK-OeJkJxF@RvCXbm_4 zC9vgCO6*mEOM%7+kVCeQVslgcrtzt^)%_bOX?2sv9i;3MOcc1V`|4ERrCu|`{_MF4Luek8-Erz z_x5zJdKm@51$DPJn%9n4^sb0mduydvy0JHYa7vO=*3Qj7h`Ufxz$@T@Kr%%FD}e$mZRo-JUMtmS^sib29*M}$o;u!4d_U#55gO}>-#O55Z24DT zOUbAkVorP*KWGG6i=e!_lZGX5>?A-U8-(Hc;Reym{1m@{#V=YSzBhFL?2*iY|LH!# z|GcE=V22w>?WK04GdT5ogiBJElC5h3e?4?&?P&sD5V^>y9jQX|))E-qKqtgxzc zB7Q&vydtBI9#+$CJwd$lSkuYX6DtiE0`^8^R@FH$*8Cas;&$F9?cJ)< zswyfDPgf2zguDlruy#~dOR*hU^`P_ABT|)_t51vQ-%IL+h6H0o5Zv&XEtPH>AJ4D6?+4(9D4V*lAEh5_WL6F2|=)i216;G z#*F1RB~2V%T(Lz4kcNDZ6LY>NXT{I_^mIjMp9FJ9pS$hI*%l2-mMEtgk8geHR|x!I ze=AJI@maz7Xgbig*_ry*HeD)Tf&E;Cy`|3F)*64VJWc$~H~Ujjt)$q44TYrtfhpp! z*--#=*d3~S{#H{_*t%(FAnp?rdoqIb-BaQdZqn5*X!;N%}fqjo^0 z(DLDCN&Hl@`DwHJw~RbLd!mocqp!jbqzflD+|w0BX9q14CNXK3RCTR8+0pyNb*s?# zuRL+IvyY34h%2p*+a^AccDyF1o{^ILD*PbG85tZ%Yw2*BBi<1;va)l+_Ex0eyIPwg zXv208XiAxkSC|`j`)N$=C0WC$h;TFouX4l$fT{z1ZEUscnKtU4eedG^pr9b^CC85V z{>~2X4z>wnL#t=WhP9>GyZDxpla7%I-o1t;|0Aq8%$ApSij~#c6)?W(-_WZWmaH|p zb-_LTwt^|%90;7iJK<1wX$uv?ee9d`{X_YT)MVr>0SvfD*2r*1ZKE%D+ak44EGpk= zhPdUQ`JI?Xd~_7bK)!$(Z)_~PuE}fS`R7`0@|p%k1^IBTcz&3SpL2gE{J7QKtXwR6^Tkr>7}x?U}qKJ^sENZ%384 zqcQPZic9>(A@OTT?X<*r$QT?%nJi$(%3`hpV~-vWlZQ632QP-R9I{ME2PZyq4KZe} z{pymmn2ILezk#V2Tp8>!Py|JX;mFU*%;hazRB?QwXkJxuVBsL4!)@Xo@muXEKXYOK znz85Sk2O!k4~n5{kTgK=t>_u3S>3ltEBH=c&8%ajbY=g(Q{+3MTHfxi`FVMGsb>kT zyOtpS`rYHJVzQWOpMoDIV=$$m!*!YXi;|szrG0*0ZgXQ}QFWc~&|Ki;o>D-JZdqI4 zJn^QYn}(iAaZw@O$cxb(rXS3K4nQOOJE4c0?^v+*5^ zz7<#IwoD7}S5j6+rk2=ggwv=x^OTmhQ09!+#OC{V6$1PNkQji4g4yb&QGIA5(QCvFHGRX;=ceO3Z>f80>l)z2 z0YEjx3VhB?@vB-pT*kNVhGc*LOeH-f36}SGpnF*QuXTS`{H!c3QaXD~`WK9uyUyGl zCI6@=*|plEJKu!WUXU_NiI0W+U=?1g?^hLu<(ua7Ydbm%CYJmrb__T>^25*N$96TQ zh!1pqZzy0FV;bBDX+;pfjkDQ744xvNkSnL%wQx+F-U(eN0(S`Sb;4?quv;YjmkCea z^T!$Ww_GAjgQ8@$3@xo}kn^aktA#Z}qy#}8j)_V9WK6E)tPmQ}sSh2zRr{8Hb4%m4 zxT2SbTR}kqrlEizE@bU-Dk(HFI&)&}GimdyN=CU@8#(5Rp(}{rDn|Kvi^O$3`_J#n z9L#@?#cz-|_AZSu7^T$i5)7f7a$Qn3xV67-lTh%B{KJoro$c-LzBMF~h6V@lo?9wG zynk2vvbZv`f+ymK)KT`(PT5=M$O2kw*I`j5oMpy1@8V1i029&{1 zB(#J5|GwiB95^l=Xe3hAx%EvBjO8cU%@;*9Vxpsvjc6z@F>2>Hj_o>(Zz;7e+%6k@ zL)_HV!n(e$78VMFI^GnXfZ@n(bhfpIc8)|%JP)jBQ7&xO8(e+!sez@PLv>XZj1;g3 z2n}>~hS7!sR)~)!^tCOWVE({i9DkzJ*1Ao-2x;k;^9)6f?nyrF&-XQgeZ9%0d}t9a zEPpk&wTBK)8aK1v{^oW>L^#fRz`Gt6_le}4@!^^912L?xu2Q>u%=;!4I4?qG3DbmZ zsmw~#S>jG??fc@U@loM`HOM++ucsHo*!VndX(!!rY+ZU}%YO2?;qPxk`+{U8jeBa9g!gkh3|L3?l>rhvbkvP~$(XWe%4x9^{OEEtn8GeU=LS^km$^9;(ZCd%Q9N9aKJXCet3)|e#*x9c}v7~ zL-((4K2A#f5BX~pfUr@EGd5aXPbpd1jcDt+^i<5LuC0b3)HBO||4dQW+&n8I1ECkD z#fWNJ2APEf@$R+zSH$E`@jp;Oyizc;nd-Mie5TNeQrDw6@l)rnaD2Lc=e{wVY})P5kJQilZFhKTHXHIJy8= z;c94Y?IB&m9!tcVUtDo?ajX1AH)5X^KRAob=<9RoWJ`^`@Zj%RWmieW4 zyr~!-9EbtKUS)y#MWk$&m9NmjXK9Q z%4xFc6te<~adCrt`=C=NCwl&Q-Y)ScN#n~ZP8rDw@Jq+>^D=&$%336D*hYNu>}dQ3 zzQLVx#>WttWlyaIbu(|vDk*1Fls+e{bDQ3LsHtjV3BQ5R5gLr(Y8F$GL1rL9ynRFL z%EQy*H|QUBXQnk$ZKjEDY$ES!So?ao`uO>K&JnR2#Mh6-E!bPSRNkLNEPULZu~!|T z5r+RNIU;68WrkGEpjGX9OU ziJ!lJadA;)L7p#T!lrFR-7nIiXF|Jo_HDgD4MQ_*e`MEl?)YZr@ILav?pTNyidM~CW{ zZ>a-QPVDBj9%A_tQ{JM!5u|!-=l1NU_N-_2omYrw+0Ad>Q;P@<#>xZKh_sRD@c=&q z<3US=avx95*wTEKc=Lwh_cErAHkRpWX>~OHoYTt7BVbvlgeERUM3z!Ws5ik*fSSQduQ~zIeOJy{?y^rp7DSY zZulUFHpUMeG?=#80KdEhu4l`l8Jd&+US%&d+lqhIAbfvXq@*= zN%tOFwy*C|i^@R!sa41L>uq@tFCT1Hf+-Y$7B|?Po!QbAiD6m?-IY*EO-V-3j=9{c zY{YSDPkC}y{D7yJlTfJLu``>gOGNf6aYe(>koQ85vGAsvkD7rgVk#u2z?4%uJIhxX z6>I~&w>zqfX*{(bw6N#DMEESeFzH{q>Xm(2QZqd@1p$&^{Lppe-$J{Y?lb%5?d*pp zwziAJ8;^8uDO*Q{;hp6zNCAPNxDbmYIKgjtBoA_9=ZT<&7nmj~#23DKQ`XVVz4qm* zBI$y_bl@kEyBxSkJPJ#{?dtC|z412+HokOU3A{sFSxah&YzUW3;$Q)r+ z*{+ya;KqOPzLJxPi8(TaNFE3>i-iKI}8U|D|!z6*(gN4qYGX3B|NEQL_jIgaP{B=- zBs2?oKxX4OXwcRb%G-*cdf`92AG<^R`ikgnm4o*)kuC@$MM(sZxf9EwtHiyC^aqx1 zHVecXlD>EupQD|1T3RaN9E9Mwpdxu$nUOh#dE3N$;?`pNX0V;;^hkJsHfN{!Z9IP6 z+TIVw-d~950zci|U9hY`EH*e}8ePm^D%~U$oqcZ`TG$TEmu?du8TenkC4p^V4Gk24 z2Lr(<&=fA%vaVs~3_*Mb1-dAE>ywdt&zh9OjAofOeLa7JFz^zwU8_1LB@xHvQ8&RegVYrjG<8GHh^M zf{Ji@*u>OWTkXbup^``aLPAeNP1U8Dp143ro7?-3t%PqAf0A?3G`A}$EC8dR8)%;# z1sXvToZ8$FIy7%UVSRW_0`IVBZf<&&V?1T-Cw_HS{Gc+(!uuU_o2gMNMD`+4FgW_a z+%fSvVOrYp)-5GZcUPpdVCFGe0re+#dHO?$XM)Quqcr&}?iw9|UiJ4cQKEkblc$aD6x%)|CDq^)035i9d)NJ=C&36-LSeEzj8k7% zXC`|tX>LDd=|$!$VbnbQtEOqH(_*9_hMCT^IR zl#D&5U>8)jx3e>jKAJMQtnclAPeCPgVl`rB;|r7M3s03|!h?ZTGLuV!2ctl1z)#1} zf&cm7neI*P)9?fSOixY}wRSjgH{fmFmoRm#X(`zt!t#p@bIZfliHlYtk~*e%uP?|x zi}?c?NNTk=H~aQ*d^d?d-`Bcl=I%AQZOhwto!<9aBsAKXA3ad?_VxiFA*mCU0aU$= z1Dni8)*=^)s~Sew{wtkO`Qc4zoMj@<7YQl?12Cz0gHinOR4jk5K1+8Jk<-tw2@SIRQ-*6g&6L zYv2cChNbLkYxUsoL@(?YZV>mi3_SZM(iVtc-_cXlF~+_R1OTw{f|0*2S>P1(d#ImY z(m7DELL@D`h+NnYUD=DjiafAKo%|lEYL3|`*{F9{mDe)WB9qXRO&20fwn_jGi3x>XN3q-LRj4+y zK7FL>=jYeiNrUYdxRJxk01opwoU)o)hw<&efvLxie*UY(qsWpUutbxbh#Vt^EGUm2 zp;W_zgYgaR@z05CHo-d4c@?{avV*5r7dz`Yam6F!mXcxG%Zi6}gKPoRVw+q_3(aNx z`R8V#^4jJ|xW4+ zgDf@-Dzr)R#gVUd#qz+QNEE&eGQnF0KwH|8VD@QP%pU67KoXen90{dRmp96$Of06%6B!HpQFFU~qbu*3$NnH^ zl#!M^^m6G2YBa_g$zv}@@QF*#kvFuh6>9o^bxT1^RU1c|53`=+370e8MeoD8fR@%a zd<&&H;)KBstp8MT`606}9$0vO`9vuuCK|gUTJR$j^^IZ6gmYQ_*UuzusKccM@r`5p zhhln;c3A2;*yD^j(&6!fpJ)yEsUKqX0zZlt*Oc@#QeK%q0EKwpWpPWJFLw>bTPD56 zag}gt?Ec2wIcS&oJ}CbO1(T%MgYBoVT&D+b0#Sk<1XOj^)j_;1otk0M#Cq%xaN+H` z%N0|T)^7T(}QO*qi$Ax2D7mj`#(F0V$yKiY-2^OJw2sG>IBRewZk zXaW4hEUu)5>c`*Jts8P4UX0|wP&BuXT_!?#n{R1{SeRqa_`zFmk613yj3>y=lvPv~ z?Gf@J=~te}8*gtt%en%U~cDQeQ!B4`+}To*#091 z2Kd4HPxiog!~$X3#=fRy;yu0p+b70%HJnou<1iIDVrE|AhgHK{iJ#xg8ea+LEO}3^ z|KyeNjKgiOuXEHVj*~kPbTld(h=l}N&4RKWioT&stKm$20k|!81 zq7g({Y&Hvj;gQe?Iue*(6hr=?j>}J5-v7zM_rg;}KOb+rbR?~`B#yVFnO*+neG&2W zTDysj>k%~{D&bcx9Y{{X45OVRJVdj|AG9z=1_uiChAtUSqv86AA^`kE8xZ>Wn`$8XE4#=fv#4@;S0%CRJvn3i zwi&i;VsQpx(rXci!e|+<6s>P=E?wNoUEGJUbmy!mAuP_U|6Iu+CNvlf!nE&*X+Q8k zELIww9Wc6V)y}-CXBodr{F|7|Ep6wN_!tszheddR4F)4|b}4RlKXqw8bndz5-1A!@ z+5vt9m_*B<94Zb(K^}<5 z;K2}aA%r^|bfFmVQ!&bmU)X=(lklOGo~faMM_5$l@}}G1q>{3dZc4W6+}=-V^}iRh z)ibxmTiW0dFnPdWkFya9fsm|&!R$f)TGaTmvhhE}PentMH+$Y`>V^5#3){|-EBcn6 zYs90X?)No3VnYKFNun<_dq$-}F$jx0K3-N`gA_~jA`v~mA3D1qy+9x^kt^!{_L)XV zNN{iO!3o^M%qQE&6P!71uCEJcF2r!xW!(c+3mSFXxbMl^n^@Xm*8;eQfgdIYRlxJU zo~|4^6N(Wxy`vf&=h-!uIKO{Cxb(KXJ_36zyFqrxy8{E^2K&1^of`*?YZ<>6H4pId z!i!M_ONfU%dfofi!w*^qm%(d#S7%xmBXWgELeI4i#sGd3`{hFQYaX4v&3Z2~_)T>)df zaB2^bQXM&7umV-q+hxUsKc6 z&;ad6jsZ$Wc8$Mt{K={jZvHZ%7?t;jn=%UO8Ur{&)Ow!+31^U=lN1;SySxNGAo zkyWn4d+}vRDYi1BFNt@g8i)3+wQ+3!dFG?jt+l^Mp5l*M4LZlXDs66!=WoRiO*Va;T161n3Ga%R>A3%iB0>wkEpsi>`&lyLC2E|fu-3%s4E z1OgIK04fe`Yp$zJZ)`8xBFdJCw3+9Tb6Y8s+iyJ7S24EDPEUo5$(ewlB6;)j{5C6t zIhDRb*f%ks=on?J5xQ&=LV9EWP{z_;*2;eJ(q78^zB6a# zpT%4ijO>c?4-Sn$>9;mF8G{356N|Mwgn3Mgl2=gN^wxVawl@`YPJI6X+J|)n%sL2y2cpiC%6&3C6#63SyBIc`azibS1vz)q^fbzKjQx6o=ErP|DovDlFbS4LVNlJX-%20t+h+ROEy_ms@9NSUT29V{LQx;tDRiirGmaYK^}W5#Xr zg?8J>RSP#W&ZZ`95^qR!adpE>cHq^a(>M}e!O!0{9JXY1#(ap-tfEPkk z4WXW>3Sbc0!B;>9w6>wTD!sbCc%7(N-7lWmOJ3NEn%?@>B1%NV45v*Ixxprp?Hm~- zHY*G>nW-aF@e6x;En^S#P2+cow?xc-R5rw}B4`!bM@P^(7#kc9?d$E$9~{eDCt?=% z>sE=9O~Sf)=+}}qMvgv|x*AfG@cs}+e}Cb`A{Jz9V>1-(Jqs3|f2L%2SxhYfG2Y8F zz@Q%&Nepf<%pMvovzI9op8efDvC^VKbd3;>EOTIS*(}QBqU$zc(LZfJxt2b=C1-AP zL*K%lHLJy3`Hi^IEm^h1m`Efc;Kv~ESE&Me#8@V|+r2u@=5esHGO)bPaHv+`XIHa7{)lCOVQ%Kj&MWFet#dq^T{Kwd}=O3*m3a z&+Ug!?kW~gzZKVe>3hcJLfO78=w$8aBF=$lGw5CBAo0y``W}9(Fj5!ZkysPV{5&6~io60%sYkQkKob-|JiWydeIf<@}Yjjfa~H_Duo9U=uEo zG1x~hE-A}hBJ$>Tl4p0bruJL*i1(G9zZa2@iiqld`9cr$a`67D{((&HQpF3xDm72c z(lK?J_`%5M!b6$hz<}oFW{?e^i6MY0To@WmBYp=Vo;{}!lJ=KN5A$=f;6_M20Iwig zEIL(jW>Obl1kUYrY!D9(%&%zb+cG9X*NC^YgD>5az{zT47co+_e7aEKQjqbhV;tn) z-u?0M4>uph#6*#AMLfbHQcU>0jI^qHzZJrZHTT%g-K42IVTX7})kQ(~Am2ms_K23B zt~BJg=nDgEZEB3|WCl*|`%G+w^7n$L2(^r+iw|T%ga01C9ccH8p6u3&@7fw}8Y)Xm>$tm}% zMuAQd#FjO-1`o~UY!bh@CTnhEj~M|}0@`?DUuS%HPW+&CND&ai+yguL()ziD>x6G} zx2U021f89|wEwA+?LBb?OA8C^daNifhXaAx29~f$hYP_Nk~7$oR+yWUl9mzH*cG)v zlrHX9E$x+V5UEpJ?~5Bss2e24Mz*&dET@2RkQT`u{KY+t9~2h^V0T6{tuuUjGh>zT zqmTb&?&P;YeC1vI-V+5aZJoH-*s`)RSQ-GSI4?IPEe#u`(--%W=l6=1c9Yi$)#9!{ ziW^uud*bCRm|tOP2dBa1a2nd$bH|o*Hwf$GJb7o|{53)DuNRh7&0h_jlhmfdQW$8er`hFWEGTnX3MT;$UZSc zXL!zco%jN<6j$@`@WhOk1dm{(0uho!2E#FAKoQxbPFg3tCEm+*Xfni}+@ zJMiiN(=XpUh2h{8$9cIqvEz#&vpas=xl5XcNlSZ{^ob8|%iuRQ$)EH=%YwdM>js7c z3Z2(Ah)67Ydf#ts&4sn9hy3+pC3iPhoFl-9KrrkkEG9G+H^?aT_x5JjH-*mc;q?;Q zv034axwtjrl6UTPC39@Hz~U(>aTJD>Np6s$M+?ZCW1msh!V4?`n|E;EyDZ}8>kFq1 z`*_&s2snl+AQCvo&kp2O)y8mEBBq~zWfX8vK?}cZhZq4VJMan|Ku51NcCzsK@dFY; z94N#4W~$1|3mRLh7I!j+r=63t{JNM~tAs%gMbg&uk&L>ju}MgPe@bEk^6oenm7AH7 zk(?A88XOv*6j9Zj%AC(yBXXyAk`@WXOM2P$KggTtTi9YF8Keul0s#mFj7~{4LcicL zpxD{bkyBCWF}oK(y%)xs(v8oFSb1?Pr0CaoHSXTMZ>p`~VsGc~=@IDV8IV<2$X}^k zCCU~LGH=B@gmLZ2+sYow#sR{8I1rB~Q0Y=@t<=wGrMs6w^1F zxldeij=nCXmYfhz&JWM0I-nD>n7|uws%qkS8(sf3jsl7ff)@ln5D*YS5tNI-$W`Q`c-QfUf}nze;(caLA4@{aZgx9qH#8w1 zA$a)w_}=$@&Ur8A@}2`D0_IVh;Bdgu*Er~D#QLd~-J2RScVUOxBX5@Te|70f72}a! zuZJ(i7$!u3{zK}#7UjvIxnt2(*IIVy1$nDc_sc(jD5FIAzF$EKzy)1``T)Y-@8piHJjs$zH0~c>{NUmJ2L^)yMi31Nh8PWzL52j<^`S~CJb_3b(Dl~Mo6@Uo=zffnmf|dasQk$C#vom4;FpiT@D-;9A1p0G> z(trE=7v8z_b}P5BPuuNvJK^gvi-k|0bI7Px%FOo8)QL2?&y3}`i9>hhNVZR2|4Z53 zdllG*5*3Gb^JSu6;Nh#j;)gK&k&$8kR6>v<&8g?YEcu5y^t~Va;`;lSd3CHFwbE%H z3&cx$>R zJA1a(%wQrH*vg6hQ$IoKef}imzS<+ek|7@&=#m5V#S3mS8YIa75~pr`Pn}x0@8V`Eshy)Tz)IQu12K{s% ze`R?6wcq_oDV4y*<#Uz_Jpa2v9>llOk=2AfFeY~gc&^c|rS1B)WA^$<>*h;Ujwo{E zW8capmgpgm5-PRm$-@v7p7830Z$N)Q3>@bj5gc?RGG;XmNTgCpZ@c z14cEHx+=@dn;Yw~TD(uM2RZc05M5w@&Be7?cxoDFnDrX^gano9T2?iaiHGp`%{rYHu?m_9tSm%EAP(yQ86jz*3Q-0W>7C3{ zEba@2`mHu?uf9XxDG*a&qJi7gzylZUQl(O7#34G)UZb(c;nGYkYQj^U{;@X4uwc+F zuzN&ySKFXV>koX!6<5@9aFitI!jr>PLvQiQ(>+hRz{A%Rz#Arl5Cv&xR$IMeT$``n z;$~ZYe0M-NGQ|nb;~b4Lo#P(6NjbAdO~-|i`DXt_tus(-ddjtUSSDAc$=NvIeq#0V z9R6neuyS-xGQMP-TNOG2Rc-S5XPETMf=ZqTK!mZA!1!bZc2Fy0xEywvKRBiHY(tRa z!-Khv?cQj5U_RzvT(wRv82#fKPe9}ffdle1n!lu*zKm9q6 zFTz}OAut|)manE(QDQM)AZTh8a9Y~xcr9#RGmFcw;WR#~evBg#xeXj74q%}d2H6nB zBAh_Lim(+h!TI0?zl;~YVz3J@)HfU*T0D9dSRRkuIGj*|j6xh!qfx8XN~H=Jb8`9F zTOpUrIac$Z zctdy$qYJdr{_qI}&XWe(dAcACea6@GR|<@wkpC}!9>oek|FGGh*8nrINI{9a`pQp+G8V!zaq5s{Z&vo z;}EpuGK01oCx1Aqi>@TC@}K0<``V6>geX zi6KDiPl;71ElyDpp!KJyaMQ#}3;|kyN~}U@af*rntv^MDnh0@{_6#-g*iV8PPti%wY^{2!t LloqF`2z={b0q!s@ literal 0 HcmV?d00001 diff --git a/files/plugins.cfg.win32 b/files/plugins.cfg.win32 index f71e8d325..ea12c0394 100644 --- a/files/plugins.cfg.win32 +++ b/files/plugins.cfg.win32 @@ -4,10 +4,10 @@ PluginFolder=.\ # Define plugins -Plugin=RenderSystem_Direct3D9_d -Plugin=RenderSystem_GL_d -Plugin=Plugin_ParticleFX_d -Plugin=Plugin_OctreeSceneManager_d -Plugin=Plugin_CgProgramManager_d +Plugin=RenderSystem_Direct3D9 +Plugin=RenderSystem_GL +Plugin=Plugin_ParticleFX +Plugin=Plugin_OctreeSceneManager +Plugin=Plugin_CgProgramManager From c6da3872b443572b5c686eae15d14f4ac35ab8c1 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 19 Apr 2012 20:59:57 +0200 Subject: [PATCH 071/109] light improvements --- apps/openmw/mwrender/objects.cpp | 132 ++++++++++++---------- apps/openmw/mwrender/objects.hpp | 26 +++-- apps/openmw/mwrender/renderingmanager.cpp | 11 ++ apps/openmw/mwrender/renderingmanager.hpp | 3 + apps/openmw/mwrender/terrainmaterial.cpp | 4 +- apps/openmw/mwworld/scene.cpp | 5 +- 6 files changed, 113 insertions(+), 68 deletions(-) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index eb7e440cb..a79d72989 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -8,20 +8,15 @@ using namespace MWRender; -bool Objects::lightConst = false; -float Objects::lightConstValue = 0.0f; - -bool Objects::lightLinear = true; -int Objects::lightLinearMethod = 1; +// These are the Morrowind.ini defaults float Objects::lightLinearValue = 3; float Objects::lightLinearRadiusMult = 1; -bool Objects::lightQuadratic = false; -int Objects::lightQuadraticMethod = 2; float Objects::lightQuadraticValue = 16; float Objects::lightQuadraticRadiusMult = 1; -bool Objects::lightOutQuadInLin = false; +bool Objects::lightOutQuadInLin = true; +bool Objects::lightQuadratic = false; int Objects::uniqueID = 0; @@ -132,7 +127,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh) } } - if(!mIsStatic || !Settings::Manager::getBool("use static geometry", "Objects")) + if(!mIsStatic || !Settings::Manager::getBool("use static geometry", "Objects") || transparent) { insert->attachObject(ent); @@ -144,18 +139,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh) { Ogre::StaticGeometry* sg = 0; -/* if (transparent) - { - if( mStaticGeometryAlpha.find(ptr.getCell()) == mStaticGeometryAlpha.end()) - { - uniqueID = uniqueID +1; - sg = mRenderer.getScene()->createStaticGeometry( "sg" + Ogre::StringConverter::toString(uniqueID)); - mStaticGeometryAlpha[ptr.getCell()] = sg; - } - else - sg = mStaticGeometryAlpha[ptr.getCell()]; - } - else*/ if (small) + if (small) { if( mStaticGeometrySmall.find(ptr.getCell()) == mStaticGeometrySmall.end()) { @@ -207,34 +191,35 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f assert(insert); Ogre::Light *light = mRenderer.getScene()->createLight(); light->setDiffuseColour (r, g, b); - mLights.push_back(light->getName()); - float cval=0.0f, lval=0.0f, qval=0.0f; + LightInfo info; + info.name = light->getName(); + info.radius = radius; + info.colour = Ogre::ColourValue(r, g, b); + mLights.push_back(info); - if(lightConst) - cval = lightConstValue; - if(!lightOutQuadInLin) + bool quadratic = false; + if (!lightOutQuadInLin) + quadratic = lightQuadratic; + else { - if(lightLinear) - radius *= lightLinearRadiusMult; - if(lightQuadratic) - radius *= lightQuadraticRadiusMult; + quadratic = !mInterior; + } - if(lightLinear) - lval = lightLinearValue / pow(radius, lightLinearMethod); - if(lightQuadratic) - qval = lightQuadraticValue / pow(radius, lightQuadraticMethod); + if (!quadratic) + { + float r = radius * lightLinearRadiusMult; + float attenuation = lightLinearValue / r; + light->setAttenuation(r*10, 0, attenuation, 0); } else { - // FIXME: - // Do quadratic or linear, depending if we're in an exterior or interior - // cell, respectively. Ignore lightLinear and lightQuadratic. + float r = radius * lightQuadraticRadiusMult; + float attenuation = lightQuadraticValue / pow(r, 2); + light->setAttenuation(r*10, 0, 0, attenuation); } - light->setAttenuation(10*radius, cval, lval, qval); - insert->attachObject(light); } @@ -290,13 +275,6 @@ void Objects::removeCell(MWWorld::Ptr::CellStore* store) mRenderer.getScene()->destroyStaticGeometry (sg); sg = 0; } - /*if(mStaticGeometryAlpha.find(store) != mStaticGeometryAlpha.end()) - { - Ogre::StaticGeometry* sg = mStaticGeometryAlpha[store]; - mStaticGeometryAlpha.erase(store); - mRenderer.getScene()->destroyStaticGeometry (sg); - sg = 0; - }*/ if(mBounds.find(store) != mBounds.end()) mBounds.erase(store); @@ -314,11 +292,6 @@ void Objects::buildStaticGeometry(ESMS::CellStore& cell) Ogre::StaticGeometry* sg = mStaticGeometrySmall[&cell]; sg->build(); } - /*if(mStaticGeometryAlpha.find(&cell) != mStaticGeometryAlpha.end()) - { - Ogre::StaticGeometry* sg = mStaticGeometryAlpha[&cell]; - sg->build(); - }*/ } Ogre::AxisAlignedBox Objects::getDimensions(MWWorld::Ptr::CellStore* cell) @@ -328,12 +301,12 @@ Ogre::AxisAlignedBox Objects::getDimensions(MWWorld::Ptr::CellStore* cell) void Objects::enableLights() { - std::vector::iterator it = mLights.begin(); + std::vector::iterator it = mLights.begin(); while (it != mLights.end()) { - if (mMwRoot->getCreator()->hasLight(*it)) + if (mMwRoot->getCreator()->hasLight(it->name)) { - mMwRoot->getCreator()->getLight(*it)->setVisible(true); + mMwRoot->getCreator()->getLight(it->name)->setVisible(true); ++it; } else @@ -343,12 +316,12 @@ void Objects::enableLights() void Objects::disableLights() { - std::vector::iterator it = mLights.begin(); + std::vector::iterator it = mLights.begin(); while (it != mLights.end()) { - if (mMwRoot->getCreator()->hasLight(*it)) + if (mMwRoot->getCreator()->hasLight(it->name)) { - mMwRoot->getCreator()->getLight(*it)->setVisible(false); + mMwRoot->getCreator()->getLight(it->name)->setVisible(false); ++it; } else @@ -356,3 +329,48 @@ void Objects::disableLights() } } +void Objects::setInterior(const bool interior) +{ + mInterior = interior; +} + +void Objects::update(const float dt) +{ + // adjust the lights depending if we're in an interior or exterior cell + // quadratic means the light intensity falls off quite fast, resulting in a + // dark, atmospheric environment (perfect for exteriors) + // for interiors, we want more "warm" lights, so use linear attenuation. + std::vector::iterator it = mLights.begin(); + while (it != mLights.end()) + { + if (mMwRoot->getCreator()->hasLight(it->name)) + { + Ogre::Light* light = mMwRoot->getCreator()->getLight(it->name); + + bool quadratic = false; + if (!lightOutQuadInLin) + quadratic = lightQuadratic; + else + { + quadratic = !mInterior; + } + + if (!quadratic) + { + float radius = it->radius * lightLinearRadiusMult; + float attenuation = lightLinearValue / it->radius; + light->setAttenuation(radius*10, 0, attenuation, 0); + } + else + { + float radius = it->radius * lightQuadraticRadiusMult; + float attenuation = lightQuadraticValue / pow(it->radius, 2); + light->setAttenuation(radius*10, 0, 0, attenuation); + } + + ++it; + } + else + it = mLights.erase(it); + } +} diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index 0c19f9f33..63e639ef7 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -10,37 +10,41 @@ namespace MWRender{ +/// information about light needed for rendering +struct LightInfo +{ + std::string name; // ogre handle + Ogre::ColourValue colour; + float radius; +}; + class Objects{ OEngine::Render::OgreRenderer &mRenderer; std::map mCellSceneNodes; std::map mStaticGeometry; std::map mStaticGeometrySmall; - //std::map mStaticGeometryAlpha; std::map mBounds; - std::vector mLights; + std::vector mLights; Ogre::SceneNode* mMwRoot; bool mIsStatic; static int uniqueID; - static bool lightConst; - static float lightConstValue; - static bool lightLinear; - static int lightLinearMethod; static float lightLinearValue; static float lightLinearRadiusMult; static bool lightQuadratic; - static int lightQuadraticMethod; static float lightQuadraticValue; static float lightQuadraticRadiusMult; static bool lightOutQuadInLin; + bool mInterior; + void clearSceneNode (Ogre::SceneNode *node); ///< Remove all movable objects from \a node. public: - Objects(OEngine::Render::OgreRenderer& renderer): mRenderer (renderer){} + Objects(OEngine::Render::OgreRenderer& renderer): mRenderer (renderer), mInterior(true) {} ~Objects(){} void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh); @@ -49,6 +53,12 @@ public: void enableLights(); void disableLights(); + void update (const float dt); + ///< per-frame update + + void setInterior(const bool interior); + ///< call this to switch from interior to exterior or vice versa + Ogre::AxisAlignedBox getDimensions(MWWorld::Ptr::CellStore*); ///< get a bounding box that encloses all objects in the specified cell diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 581973811..5232c5140 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -213,6 +213,7 @@ void RenderingManager::moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Ve void RenderingManager::update (float duration){ mActors.update (duration); + mObjects.update (duration); mOcclusionQuery->update(duration); @@ -508,4 +509,14 @@ Shadows* RenderingManager::getShadows() return mShadows; } +void RenderingManager::switchToInterior() +{ + mObjects.setInterior(true); +} + +void RenderingManager::switchToExterior() +{ + mObjects.setInterior(false); +} + } // namespace diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index a563d78c6..cc3bc62b5 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -117,6 +117,9 @@ class RenderingManager: private RenderingInterface { Shadows* getShadows(); + void switchToInterior(); + void switchToExterior(); + void setGlare(bool glare); void skyEnable (); void skyDisable (); diff --git a/apps/openmw/mwrender/terrainmaterial.cpp b/apps/openmw/mwrender/terrainmaterial.cpp index 9785ec903..a3265b2a5 100644 --- a/apps/openmw/mwrender/terrainmaterial.cpp +++ b/apps/openmw/mwrender/terrainmaterial.cpp @@ -1149,8 +1149,8 @@ namespace Ogre // simple per-pixel lighting with no normal mapping for (int i=0; igetNumberOfLightsSupported(); ++i) { - outStream << " float3 halfAngle"< 0) outStream << diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 2123b4799..c8b20b8b1 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -203,6 +203,8 @@ namespace MWWorld // Sky system mWorld->adjustSky(); + mRendering.switchToExterior(); + mCellChanged = true; } @@ -248,8 +250,9 @@ namespace MWWorld // adjust player mCurrentCell = cell; playerCellChange (cell, position); - + // adjust fog + mRendering.switchToInterior(); mRendering.configureFog(*cell); // Sky system From 7400b7f313d8cbc7141ca89d926be3dc42dca9be Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 19 Apr 2012 23:25:58 +0200 Subject: [PATCH 072/109] fix underwater effect staying active when teleporting from underwater to a cell that doesn't have water --- apps/openmw/mwrender/renderingmanager.cpp | 2 ++ apps/openmw/mwrender/water.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 5232c5140..3f1bb924f 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -512,11 +512,13 @@ Shadows* RenderingManager::getShadows() void RenderingManager::switchToInterior() { mObjects.setInterior(true); + mRendering.getScene()->setCameraRelativeRendering(false); } void RenderingManager::switchToExterior() { mObjects.setInterior(false); + mRendering.getScene()->setCameraRelativeRendering(true); } } // namespace diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 445677808..c81f23f54 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -176,7 +176,12 @@ void Water::toggle() void Water::checkUnderwater(float y) { - if (!mActive) return; + if (!mActive) + { + CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, false); + return; + } + if ((mIsUnderwater && y > mTop) || !mWater->isVisible() || mCamera->getPolygonMode() != Ogre::PM_SOLID) { CompositorManager::getSingleton().setCompositorEnabled(mViewport, mCompositorName, false); From cc86998281f03898859c8c4b83ccf223b0a44568 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 21 Apr 2012 10:12:59 +0200 Subject: [PATCH 073/109] removing some cout spam --- apps/openmw/mwdialogue/dialoguemanager.cpp | 1 - apps/openmw/mwrender/npcanimation.cpp | 1 - apps/openmw/mwworld/inventorystore.cpp | 12 +----------- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 90f0c0231..e9cb3d33e 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -677,7 +677,6 @@ namespace MWDialogue void DialogueManager::executeScript(std::string script) { - std::cout << script; std::vector code; if(compile(script,code)) { diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 751a07548..3d760f28e 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -159,7 +159,6 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O insert->scale(race->data.height.female, race->data.height.female, race->data.height.female); else insert->scale(race->data.height.male, race->data.height.male, race->data.height.male); - std::cout << "Inv" << inv.getStateId() << "\n"; updateParts(); } diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 230f7d69a..7d6be4dd7 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -8,8 +8,6 @@ #include "class.hpp" -#include /// \todo remove after rendering is implemented - void MWWorld::InventoryStore::copySlots (const InventoryStore& store) { // some const-trickery, required because of a flaw in the handling of MW-references and the @@ -72,7 +70,7 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite /// \todo restack item previously in this slot (if required) /// \todo unstack item pointed to by iterator if required) - + mSlots[slot] = iterator; flagAsModified(); @@ -169,13 +167,5 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats, { mSlots.swap (slots); flagAsModified(); - - /// \todo remove the following line after rendering is implemented - for (std::size_t i=0; i Date: Sat, 21 Apr 2012 16:21:30 -0400 Subject: [PATCH 074/109] Implementing snapping --- apps/openmw/mwworld/physicssystem.cpp | 2 + libs/openengine/bullet/pmove.cpp | 84 ++++++++++++++++----------- libs/openengine/bullet/pmove.h | 7 ++- 3 files changed, 58 insertions(+), 35 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index d224385ae..9af7a7285 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -27,6 +27,8 @@ namespace MWWorld NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader(); mEngine = new OEngine::Physic::PhysicEngine(shapeLoader); playerphysics->mEngine = mEngine; + //playerphysics->ps.snappingImplemented = true; + } diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 7741d2f04..82f473085 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -417,7 +417,7 @@ int PM_StepSlideMove( bool gravity ) Ogre::Vector3 up, down; float stepSize; - + std::cout << "StepSlideMove\n"; // start_o = pm->ps->origin //VectorCopy (pm->ps->origin, start_o); start_o = pm->ps.origin; @@ -516,6 +516,7 @@ int PM_StepSlideMove( bool gravity ) delta = pm->ps.origin.z - start_o.z; if ( delta > 2 ) { + pm->ps.counter = 10; if (gravity) printf("g on: %f ", delta); else @@ -688,6 +689,7 @@ static bool PM_CheckJump(void) pm->ps.groundEntityNum = ENTITYNUM_NONE; pm->ps.velocity.z = JUMP_VELOCITY; + pm->ps.bSnap = false; //PM_AddEvent( EV_JUMP ); /*if ( pm->cmd.forwardmove >= 0 ) @@ -840,7 +842,7 @@ static void PM_WalkMove( playerMove* const pmove ) playerMove::playercmd cmd; float accelerate; float vel; - + //pm->ps.gravity = 4000; if ( pm->ps.waterlevel > 2 && //DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) pml.forward.dotProduct(pml.groundTrace.planenormal) > 0.0f) @@ -1142,9 +1144,7 @@ void PM_GroundTraceMissed() { traceResults trace; Ogre::Vector3 point; - - if ( pm->ps.groundEntityNum != ENTITYNUM_NONE ) - { + std::cout << "Ground trace missed\n"; // we just transitioned into freefall //if ( pm->debugLevel ) //Com_Printf("%i:lift\n", c_pmove); @@ -1154,29 +1154,28 @@ void PM_GroundTraceMissed() //VectorCopy( pm->ps->origin, point ); point = pm->ps.origin; //point[2] -= 64; - point.z -= 64; + point.z -= 32; //pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); //tracefunc(&trace, *(const D3DXVECTOR3* const)&(pm->ps.origin), *(const D3DXVECTOR3* const)&point, D3DXVECTOR3(0.0f, -64.0f, 0.0f), 0, pml.traceObj); newtrace(&trace, pm->ps.origin, point, halfExtents, Ogre::Math::DegreesToRadians(pm->ps.viewangles.y), pm->isInterior, pm->mEngine); - if ( trace.fraction == 1.0 ) + //It hit the ground below + if ( trace.fraction < 1.0 && pm->ps.origin.z > trace.endpos.z) { - if ( pm->cmd.forwardmove >= 0 ) - { - //PM_ForceLegsAnim( LEGS_JUMP ); - //pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; - } - else - { - //PM_ForceLegsAnim( LEGS_JUMPB ); - //pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; - } + pm->ps.origin = trace.endpos; + pml.walking = true; + pml.groundPlane = true; + pm->ps.groundEntityNum = trace.entityNum; + } - } + else{ + pm->ps.groundEntityNum = ENTITYNUM_NONE; + pml.groundPlane = false; + pml.walking = false; + pm->ps.bSnap = false; + } - pm->ps.groundEntityNum = ENTITYNUM_NONE; - pml.groundPlane = false; - pml.walking = false; + } static bool PM_CorrectAllSolid(traceResults* const trace) @@ -1404,19 +1403,26 @@ static void PM_GroundTrace( void ) return; } } - - // if the trace didn't hit anything, we are in free fall - if ( trace.fraction == 1.0 ) + // if the trace didn't hit anything, we are in free fall + if ( trace.fraction == 1.0) { - PM_GroundTraceMissed(); - pml.groundPlane = false; - pml.walking = false; + if(pm->ps.snappingImplemented){ + if(pm->ps.bSnap && pm->ps.counter <= 0) + PM_GroundTraceMissed(); + } + + return; } + else + { + //It hit something, so we are on the ground + pm->ps.bSnap = true; - // check if getting thrown off the ground + } + // check if getting thrown off the ground //if ( pm->ps->velocity[2] > 0 && DotProduct( pm->ps->velocity, trace.plane.normal ) > 10 ) - if (pm->ps.velocity.z > 0 && pm->ps.velocity.dotProduct(trace.planenormal) > 10.0f) + if (pm->ps.velocity.z > 0 && pm->ps.velocity.dotProduct(trace.planenormal) > 10.0f ) { //if ( pm->debugLevel ) //Com_Printf("%i:kickoff\n", c_pmove); @@ -1432,13 +1438,22 @@ static void PM_GroundTrace( void ) PM_ForceLegsAnim( LEGS_JUMPB ); pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; }*/ - + if(!pm->ps.bSnap){ pm->ps.groundEntityNum = ENTITYNUM_NONE; pml.groundPlane = false; pml.walking = false; + } + else + { + pml.groundPlane = true; + pml.walking = true; + } return; } + + + // slopes that are too steep will not be considered onground //if ( trace.plane.normal[2] < MIN_WALK_NORMAL ) if (trace.planenormal.z < MIN_WALK_NORMAL) @@ -1500,7 +1515,7 @@ static void PM_AirMove() float wishspeed; float scale; playerMove::playercmd cmd; - + //pm->ps.gravity = 800; PM_Friction(); fmove = pm->cmd.forwardmove; @@ -1508,7 +1523,6 @@ static void PM_AirMove() cmd = pm->cmd; scale = PM_CmdScale( &cmd ); - // set the movementDir so clients can rotate the legs for strafing //PM_SetMovementDir(); @@ -1749,7 +1763,7 @@ void PM_SetWaterLevel( playerMove* const pm ) void PmoveSingle (playerMove* const pmove) { - + pmove->ps.counter--; //pm = pmove; // Aedra doesn't support Q3-style VM traps D: //while(1); @@ -1763,6 +1777,10 @@ void PmoveSingle (playerMove* const pmove) pm->ps.watertype = 0; pm->ps.waterlevel = WL_DRYLAND; + if(pml.walking) + std::cout << "Walking\n"; + else + std::cout << "Not Walking\n"; //if ( pm->ps->stats[STAT_HEALTH] <= 0 ) //pm->tracemask &= ~CONTENTS_BODY; // corpses can fly through bodies diff --git a/libs/openengine/bullet/pmove.h b/libs/openengine/bullet/pmove.h index 304572b02..a14a1e660 100644 --- a/libs/openengine/bullet/pmove.h +++ b/libs/openengine/bullet/pmove.h @@ -42,7 +42,7 @@ static const Ogre::Vector3 halfExtents(14.64f * 2, 14.24f * 2, 33.25f * 2); #define ENTITYNUM_NONE (MAX_GENTITIES - 1) #define ENTITYNUM_WORLD (MAX_GENTITIES - 2) #define MIN_WALK_NORMAL 0.7f // can't walk on very steep slopes -#define JUMP_VELOCITY (270 * 1) +#define JUMP_VELOCITY (270) #define PS_PMOVEFRAMECOUNTBITS 6 #define MINS_Z -24 #define DEFAULT_VIEWHEIGHT 26 @@ -90,7 +90,7 @@ struct playerMove { struct playerStruct { - playerStruct() : gravity(800.0f), speed(480.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0) + playerStruct() : gravity(800.0f), speed(480.0f), pmove_framecount(20), groundEntityNum(ENTITYNUM_NONE), commandTime(40), move_type(PM_NOCLIP), pm_time(0), snappingImplemented(true), bSnap(false), counter(-1) { origin = Ogre::Vector3(733.164f,900.0f, 839.432f); velocity = Ogre::Vector3(0.0f, 0.0f, 0.0f); @@ -117,6 +117,9 @@ struct playerMove Ogre::Vector3 velocity; Ogre::Vector3 origin; + bool bSnap; + bool snappingImplemented; + int counter; float gravity; // default = 800 float speed; // default = 320 From 8ebae0b7061ee3ef4056c5cbbd123c3917427725 Mon Sep 17 00:00:00 2001 From: Jason Hooks Date: Sat, 21 Apr 2012 16:57:46 -0400 Subject: [PATCH 075/109] Solid trace --- apps/openmw/mwworld/physicssystem.cpp | 2 +- libs/openengine/bullet/pmove.cpp | 4 ---- libs/openengine/bullet/trace.cpp | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 9af7a7285..63bf8dda3 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -27,7 +27,7 @@ namespace MWWorld NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader(); mEngine = new OEngine::Physic::PhysicEngine(shapeLoader); playerphysics->mEngine = mEngine; - //playerphysics->ps.snappingImplemented = true; + } diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 82f473085..922fd844c 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -1777,10 +1777,6 @@ void PmoveSingle (playerMove* const pmove) pm->ps.watertype = 0; pm->ps.waterlevel = WL_DRYLAND; - if(pml.walking) - std::cout << "Walking\n"; - else - std::cout << "Not Walking\n"; //if ( pm->ps->stats[STAT_HEALTH] <= 0 ) //pm->tracemask &= ~CONTENTS_BODY; // corpses can fly through bodies diff --git a/libs/openengine/bullet/trace.cpp b/libs/openengine/bullet/trace.cpp index ca68a5d5c..81c064c2d 100644 --- a/libs/openengine/bullet/trace.cpp +++ b/libs/openengine/bullet/trace.cpp @@ -172,7 +172,7 @@ const bool NewPhysicsTrace(NewPhysTraceResults* const out, const Ogre::Vector3& if (!TestPointAgainstAabb2(aabbMin, aabbMax, *(const btVector3* const)&(start) ) ) { //We're solid - out->startSolid = false; + out->startSolid = true; } } } From 2bfd90f3f98221d2071acf162d12cc8b575a87ab Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 23 Apr 2012 10:57:16 +0200 Subject: [PATCH 076/109] Issue #255: added new environment class (not in use yet) --- apps/openmw/CMakeLists.txt | 4 + apps/openmw/mwbase/environment.cpp | 123 +++++++++++++++++++++++++++++ apps/openmw/mwbase/environment.hpp | 117 +++++++++++++++++++++++++++ 3 files changed, 244 insertions(+) create mode 100644 apps/openmw/mwbase/environment.cpp create mode 100644 apps/openmw/mwbase/environment.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index c4b3776ed..a27d5ae75 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -58,6 +58,10 @@ add_openmw_dir (mwmechanics mechanicsmanager stat creaturestats magiceffects movement actors drawstate spells ) +add_openmw_dir (mwbase + environment + ) + # Main executable IF(OGRE_STATIC) IF(WIN32) diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp new file mode 100644 index 000000000..43e726e7c --- /dev/null +++ b/apps/openmw/mwbase/environment.cpp @@ -0,0 +1,123 @@ + +#include "environment.hpp" + +#include + +MWBase::Environment *MWBase::Environment::sThis = 0; + +MWBase::Environment::Environment() +: mWorld (0), mSoundManager (0), mGlobalScripts (0), mScriptManager (0), mWindowManager (0), + mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0) +{ + assert (!sThis); + sThis = this; +} + +MWBase::Environment::~Environment() +{ + sThis = 0; +} + +void MWBase::Environment::setWorld (MWWorld::World *world) +{ + mWorld = world; +} + +void MWBase::Environment::setSoundManager (MWSound::SoundManager *soundManager) +{ + mSoundManager = soundManager; +} + +void MWBase::Environment::setGlobalScripts (MWScript::GlobalScripts *globalScripts) +{ + mGlobalScripts = globalScripts; +} + +void MWBase::Environment::setScriptManager (MWScript::ScriptManager *scriptManager) +{ + mScriptManager = scriptManager; +} + +void MWBase::Environment::setWindowManager (MWGui::WindowManager *windowManager) +{ + mWindowManager = windowManager; +} + +void MWBase::Environment::setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager) +{ + mMechanicsManager = mechanicsManager; +} + +void MWBase::Environment::setDialogueManager (MWDialogue::DialogueManager *dialogueManager) +{ + mDialogueManager = dialogueManager; +} + +void MWBase::Environment::setJournal (MWDialogue::Journal *journal) +{ + mJournal = journal; +} + +void MWBase::Environment::setFrameDuration (float duration) +{ + mFrameDuration = duration; +} + +MWWorld::World *MWBase::Environment::getWorld() const +{ + assert (mWorld); + return mWorld; +} + +MWSound::SoundManager *MWBase::Environment::getSoundManager() const +{ + assert (mSoundManager); + return mSoundManager; +} + +MWScript::GlobalScripts *MWBase::Environment::getGlobalScripts() const +{ + assert (mGlobalScripts); + return mGlobalScripts; +} + +MWScript::ScriptManager *MWBase::Environment::getScriptManager() const +{ + assert (mScriptManager); + return mScriptManager; +} + +MWGui::WindowManager *MWBase::Environment::getWindowManager() const +{ + assert (mWindowManager); + return mWindowManager; +} + +MWMechanics::MechanicsManager *MWBase::Environment::getMechanicsManager() const +{ + assert (mMechanicsManager); + return mMechanicsManager; +} + +MWDialogue::DialogueManager *MWBase::Environment::getDialogueManager() const +{ + assert (mDialogueManager); + return mDialogueManager; +} + +MWDialogue::Journal *MWBase::Environment::getJournal() const +{ + assert (mJournal); + return mJournal; +} + +float MWBase::Environment::getFrameDuration() const +{ + return mFrameDuration; +} + +const MWBase::Environment& MWBase::Environment::get() +{ + assert (sThis); + return *sThis; +} diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp new file mode 100644 index 000000000..9fca70435 --- /dev/null +++ b/apps/openmw/mwbase/environment.hpp @@ -0,0 +1,117 @@ +#ifndef GAME_BASE_INVIRONMENT_H +#define GAME_BASE_INVIRONMENT_H + +namespace MWSound +{ + class SoundManager; +} + +namespace MWScript +{ + class GlobalScripts; + class ScriptManager; +} + +namespace MWGui +{ + class WindowManager; +} + +namespace MWMechanics +{ + class MechanicsManager; +} + +namespace MWDialogue +{ + class DialogueManager; + class Journal; +} + +namespace MWInput +{ + struct MWInputManager; +} + +namespace MWWorld +{ + class World; +} + +namespace MWBase +{ + /// \brief Central hub for mw-subsystems + /// + /// This class allows each mw-subsystem to access any others subsystem's top-level manager class. + /// + /// \attention Environment does not take ownership of the manager class instances it is handed over in + /// the set* functions. + class Environment + { + static Environment *sThis; + + MWWorld::World *mWorld; + MWSound::SoundManager *mSoundManager; + MWScript::GlobalScripts *mGlobalScripts; + MWScript::ScriptManager *mScriptManager; + MWGui::WindowManager *mWindowManager; + MWMechanics::MechanicsManager *mMechanicsManager; + MWDialogue::DialogueManager *mDialogueManager; + MWDialogue::Journal *mJournal; + float mFrameDuration; + + Environment (const Environment&); + ///< not implemented + + Environment& operator= (const Environment&); + ///< not implemented + + public: + + Environment(); + + ~Environment(); + + void setWorld (MWWorld::World *world); + + void setSoundManager (MWSound::SoundManager *soundManager); + + void setGlobalScripts (MWScript::GlobalScripts *globalScripts); + + void setScriptManager (MWScript::ScriptManager *scriptManager); + + void setWindowManager (MWGui::WindowManager *windowManager); + + void setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager); + + void setDialogueManager (MWDialogue::DialogueManager *dialogueManager); + + void setJournal (MWDialogue::Journal *journal); + + void setFrameDuration (float duration); + ///< Set length of current frame in seconds. + + MWWorld::World *getWorld() const; + + MWSound::SoundManager *getSoundManager() const; + + MWScript::GlobalScripts *getGlobalScripts() const; + + MWScript::ScriptManager *getScriptManager() const; + + MWGui::WindowManager *getWindowManager() const; + + MWMechanics::MechanicsManager *getMechanicsManager() const; + + MWDialogue::DialogueManager *getDialogueManager() const; + + MWDialogue::Journal *getJournal() const; + + float getFrameDuration() const; + + static const Environment& get(); + ///< Return instance of this class. + }; +} + +#endif From 7102a825c265ac8d6d43152ccb963731859a7709 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 23 Apr 2012 11:15:47 +0200 Subject: [PATCH 077/109] Issue 255: moved global scripts into script manager (simplifying the environment class) --- apps/openmw/engine.cpp | 8 ++------ apps/openmw/mwbase/environment.cpp | 13 +------------ apps/openmw/mwbase/environment.hpp | 6 ------ apps/openmw/mwscript/interpretercontext.cpp | 7 ++++--- apps/openmw/mwscript/scriptmanager.cpp | 7 ++++++- apps/openmw/mwscript/scriptmanager.hpp | 6 +++++- apps/openmw/mwworld/environment.hpp | 4 +--- 7 files changed, 19 insertions(+), 32 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 2d3c872dd..ef1497905 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -142,7 +142,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration); // global scripts - mEnvironment.mGlobalScripts->run (mEnvironment); + mEnvironment.mScriptManager->getGlobalScripts().run (mEnvironment); bool changed = mEnvironment.mWorld->hasCellChanged(); @@ -205,7 +205,6 @@ OMW::Engine::~Engine() { delete mEnvironment.mWorld; delete mEnvironment.mSoundManager; - delete mEnvironment.mGlobalScripts; delete mEnvironment.mMechanicsManager; delete mEnvironment.mDialogueManager; delete mEnvironment.mJournal; @@ -219,7 +218,7 @@ OMW::Engine::~Engine() void OMW::Engine::loadBSA() { const Files::MultiDirCollection& bsa = mFileCollections.getCollection (".bsa"); - + for (Files::MultiDirCollection::TIter iter(bsa.begin()); iter!=bsa.end(); ++iter) { std::cout << "Adding " << iter->second.string() << std::endl; @@ -402,9 +401,6 @@ void OMW::Engine::go() mEnvironment.mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(), mVerboseScripts, *mScriptContext); - mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(), - *mEnvironment.mScriptManager); - // Create game mechanics system mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment); diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index 43e726e7c..084505171 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -6,7 +6,7 @@ MWBase::Environment *MWBase::Environment::sThis = 0; MWBase::Environment::Environment() -: mWorld (0), mSoundManager (0), mGlobalScripts (0), mScriptManager (0), mWindowManager (0), +: mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0), mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0) { assert (!sThis); @@ -28,11 +28,6 @@ void MWBase::Environment::setSoundManager (MWSound::SoundManager *soundManager) mSoundManager = soundManager; } -void MWBase::Environment::setGlobalScripts (MWScript::GlobalScripts *globalScripts) -{ - mGlobalScripts = globalScripts; -} - void MWBase::Environment::setScriptManager (MWScript::ScriptManager *scriptManager) { mScriptManager = scriptManager; @@ -75,12 +70,6 @@ MWSound::SoundManager *MWBase::Environment::getSoundManager() const return mSoundManager; } -MWScript::GlobalScripts *MWBase::Environment::getGlobalScripts() const -{ - assert (mGlobalScripts); - return mGlobalScripts; -} - MWScript::ScriptManager *MWBase::Environment::getScriptManager() const { assert (mScriptManager); diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index 9fca70435..1b1ace0c7 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -8,7 +8,6 @@ namespace MWSound namespace MWScript { - class GlobalScripts; class ScriptManager; } @@ -52,7 +51,6 @@ namespace MWBase MWWorld::World *mWorld; MWSound::SoundManager *mSoundManager; - MWScript::GlobalScripts *mGlobalScripts; MWScript::ScriptManager *mScriptManager; MWGui::WindowManager *mWindowManager; MWMechanics::MechanicsManager *mMechanicsManager; @@ -76,8 +74,6 @@ namespace MWBase void setSoundManager (MWSound::SoundManager *soundManager); - void setGlobalScripts (MWScript::GlobalScripts *globalScripts); - void setScriptManager (MWScript::ScriptManager *scriptManager); void setWindowManager (MWGui::WindowManager *windowManager); @@ -95,8 +91,6 @@ namespace MWBase MWSound::SoundManager *getSoundManager() const; - MWScript::GlobalScripts *getGlobalScripts() const; - MWScript::ScriptManager *getScriptManager() const; MWGui::WindowManager *getWindowManager() const; diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 258493782..acd1d957d 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -15,6 +15,7 @@ #include "locals.hpp" #include "globalscripts.hpp" +#include "scriptmanager.hpp" namespace MWScript { @@ -174,17 +175,17 @@ namespace MWScript bool InterpreterContext::isScriptRunning (const std::string& name) const { - return mEnvironment.mGlobalScripts->isRunning (name); + return mEnvironment.mScriptManager->getGlobalScripts().isRunning (name); } void InterpreterContext::startScript (const std::string& name) { - mEnvironment.mGlobalScripts->addScript (name); + mEnvironment.mScriptManager->getGlobalScripts().addScript (name); } void InterpreterContext::stopScript (const std::string& name) { - mEnvironment.mGlobalScripts->removeScript (name); + mEnvironment.mScriptManager->getGlobalScripts().removeScript (name); } float InterpreterContext::getDistance (const std::string& name, const std::string& id) const diff --git a/apps/openmw/mwscript/scriptmanager.cpp b/apps/openmw/mwscript/scriptmanager.cpp index e93f2deec..506cf049c 100644 --- a/apps/openmw/mwscript/scriptmanager.cpp +++ b/apps/openmw/mwscript/scriptmanager.cpp @@ -20,7 +20,7 @@ namespace MWScript Compiler::Context& compilerContext) : mErrorHandler (std::cerr), mStore (store), mVerbose (verbose), mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext), - mOpcodesInstalled (false) + mOpcodesInstalled (false), mGlobalScripts (store, *this) {} bool ScriptManager::compile (const std::string& name) @@ -151,4 +151,9 @@ namespace MWScript return iter->second.second; } + + GlobalScripts& ScriptManager::getGlobalScripts() + { + return mGlobalScripts; + } } diff --git a/apps/openmw/mwscript/scriptmanager.hpp b/apps/openmw/mwscript/scriptmanager.hpp index 35cbc0d1e..35c1fadd9 100644 --- a/apps/openmw/mwscript/scriptmanager.hpp +++ b/apps/openmw/mwscript/scriptmanager.hpp @@ -11,6 +11,8 @@ #include #include +#include "globalscripts.hpp" + namespace ESMS { struct ESMStore; @@ -42,8 +44,8 @@ namespace MWScript typedef std::pair, Compiler::Locals> CompiledScript; typedef std::map ScriptCollection; - ScriptCollection mScripts; + GlobalScripts mGlobalScripts; public: @@ -63,6 +65,8 @@ namespace MWScript Compiler::Locals& getLocals (const std::string& name); ///< Return locals for script \a name. + + GlobalScripts& getGlobalScripts(); }; }; diff --git a/apps/openmw/mwworld/environment.hpp b/apps/openmw/mwworld/environment.hpp index 3a83f886f..8c4a001e0 100644 --- a/apps/openmw/mwworld/environment.hpp +++ b/apps/openmw/mwworld/environment.hpp @@ -8,7 +8,6 @@ namespace MWSound namespace MWScript { - class GlobalScripts; class ScriptManager; } @@ -42,14 +41,13 @@ namespace MWWorld { public: Environment() - : mWorld (0), mSoundManager (0), mGlobalScripts (0), mScriptManager (0), mWindowManager (0), + : mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0), mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0), mInputManager (0) {} World *mWorld; MWSound::SoundManager *mSoundManager; - MWScript::GlobalScripts *mGlobalScripts; MWScript::ScriptManager *mScriptManager; MWGui::WindowManager *mWindowManager; MWMechanics::MechanicsManager *mMechanicsManager; From 35f478071e8ea81bff6b2e06ca14970e796752c7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 23 Apr 2012 15:27:03 +0200 Subject: [PATCH 078/109] Issue #255: deleted the old environment class and using the new one instead --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/engine.cpp | 120 +++++++++---------- apps/openmw/engine.hpp | 5 +- apps/openmw/mwbase/environment.cpp | 13 +- apps/openmw/mwbase/environment.hpp | 5 + apps/openmw/mwclass/activator.cpp | 4 +- apps/openmw/mwclass/activator.hpp | 2 +- apps/openmw/mwclass/apparatus.cpp | 9 +- apps/openmw/mwclass/apparatus.hpp | 4 +- apps/openmw/mwclass/armor.cpp | 26 ++-- apps/openmw/mwclass/armor.hpp | 11 +- apps/openmw/mwclass/book.cpp | 13 +- apps/openmw/mwclass/book.hpp | 8 +- apps/openmw/mwclass/clothing.cpp | 16 +-- apps/openmw/mwclass/clothing.hpp | 11 +- apps/openmw/mwclass/container.cpp | 11 +- apps/openmw/mwclass/container.hpp | 4 +- apps/openmw/mwclass/creature.cpp | 15 +-- apps/openmw/mwclass/creature.hpp | 8 +- apps/openmw/mwclass/door.cpp | 17 +-- apps/openmw/mwclass/door.hpp | 4 +- apps/openmw/mwclass/ingredient.cpp | 13 +- apps/openmw/mwclass/ingredient.hpp | 8 +- apps/openmw/mwclass/light.cpp | 17 +-- apps/openmw/mwclass/light.hpp | 10 +- apps/openmw/mwclass/lockpick.cpp | 13 +- apps/openmw/mwclass/lockpick.hpp | 8 +- apps/openmw/mwclass/misc.cpp | 13 +- apps/openmw/mwclass/misc.hpp | 8 +- apps/openmw/mwclass/npc.cpp | 21 ++-- apps/openmw/mwclass/npc.hpp | 8 +- apps/openmw/mwclass/potion.cpp | 13 +- apps/openmw/mwclass/potion.hpp | 8 +- apps/openmw/mwclass/probe.cpp | 13 +- apps/openmw/mwclass/probe.hpp | 8 +- apps/openmw/mwclass/repair.cpp | 13 +- apps/openmw/mwclass/repair.hpp | 8 +- apps/openmw/mwclass/static.cpp | 2 +- apps/openmw/mwclass/static.hpp | 2 +- apps/openmw/mwclass/weapon.cpp | 16 +-- apps/openmw/mwclass/weapon.hpp | 11 +- apps/openmw/mwdialogue/dialoguemanager.cpp | 56 ++++----- apps/openmw/mwdialogue/dialoguemanager.hpp | 11 +- apps/openmw/mwdialogue/journal.cpp | 17 ++- apps/openmw/mwdialogue/journal.hpp | 8 +- apps/openmw/mwgui/charactercreation.cpp | 27 +++-- apps/openmw/mwgui/charactercreation.hpp | 3 +- apps/openmw/mwgui/console.cpp | 21 ++-- apps/openmw/mwgui/console.hpp | 3 +- apps/openmw/mwgui/dialogue.cpp | 17 ++- apps/openmw/mwgui/dialogue.hpp | 9 +- apps/openmw/mwgui/journalwindow.cpp | 18 +-- apps/openmw/mwgui/window_manager.cpp | 24 ++-- apps/openmw/mwgui/window_manager.hpp | 6 +- apps/openmw/mwmechanics/actors.cpp | 4 +- apps/openmw/mwmechanics/actors.hpp | 8 +- apps/openmw/mwmechanics/mechanicsmanager.cpp | 67 ++++++----- apps/openmw/mwmechanics/mechanicsmanager.hpp | 8 +- apps/openmw/mwmechanics/spells.cpp | 7 +- apps/openmw/mwmechanics/spells.hpp | 7 +- apps/openmw/mwrender/actors.cpp | 8 +- apps/openmw/mwrender/actors.hpp | 4 +- apps/openmw/mwrender/animation.cpp | 5 +- apps/openmw/mwrender/animation.hpp | 20 ++-- apps/openmw/mwrender/creatureanimation.cpp | 2 +- apps/openmw/mwrender/creatureanimation.hpp | 9 +- apps/openmw/mwrender/debugging.cpp | 8 +- apps/openmw/mwrender/debugging.hpp | 4 +- apps/openmw/mwrender/localmap.cpp | 27 ++--- apps/openmw/mwrender/localmap.hpp | 8 +- apps/openmw/mwrender/npcanimation.cpp | 66 +++++----- apps/openmw/mwrender/npcanimation.hpp | 17 ++- apps/openmw/mwrender/renderingmanager.cpp | 13 +- apps/openmw/mwrender/renderingmanager.hpp | 2 +- apps/openmw/mwrender/sky.cpp | 19 ++- apps/openmw/mwrender/sky.hpp | 9 +- apps/openmw/mwrender/terrain.cpp | 14 ++- apps/openmw/mwrender/terrain.hpp | 3 +- apps/openmw/mwscript/animationextensions.cpp | 15 +-- apps/openmw/mwscript/cellextensions.cpp | 58 +++------ apps/openmw/mwscript/compilercontext.cpp | 58 ++++----- apps/openmw/mwscript/compilercontext.hpp | 30 ++--- apps/openmw/mwscript/containerextensions.cpp | 7 +- apps/openmw/mwscript/controlextensions.cpp | 4 +- apps/openmw/mwscript/dialogueextensions.cpp | 29 ++--- apps/openmw/mwscript/globalscripts.cpp | 29 +++-- apps/openmw/mwscript/globalscripts.hpp | 20 ++-- apps/openmw/mwscript/guiextensions.cpp | 19 +-- apps/openmw/mwscript/interpretercontext.cpp | 85 +++++-------- apps/openmw/mwscript/interpretercontext.hpp | 17 +-- apps/openmw/mwscript/miscextensions.cpp | 28 ++--- apps/openmw/mwscript/ref.hpp | 7 +- apps/openmw/mwscript/skyextensions.cpp | 48 +++----- apps/openmw/mwscript/soundextensions.cpp | 44 ++----- apps/openmw/mwscript/statsextensions.cpp | 30 ++--- apps/openmw/mwsound/soundmanager.cpp | 16 +-- apps/openmw/mwsound/soundmanager.hpp | 9 +- apps/openmw/mwworld/action.hpp | 4 +- apps/openmw/mwworld/actiontake.cpp | 9 +- apps/openmw/mwworld/actiontake.hpp | 2 +- apps/openmw/mwworld/actiontalk.cpp | 6 +- apps/openmw/mwworld/actiontalk.hpp | 2 +- apps/openmw/mwworld/actionteleport.cpp | 9 +- apps/openmw/mwworld/actionteleport.hpp | 2 +- apps/openmw/mwworld/class.cpp | 18 ++- apps/openmw/mwworld/class.hpp | 18 ++- apps/openmw/mwworld/environment.hpp | 63 ---------- apps/openmw/mwworld/inventorystore.cpp | 9 +- apps/openmw/mwworld/inventorystore.hpp | 4 +- apps/openmw/mwworld/nullaction.hpp | 2 +- apps/openmw/mwworld/scene.cpp | 77 ++++++------ apps/openmw/mwworld/scene.hpp | 6 +- apps/openmw/mwworld/weather.cpp | 63 +++++----- apps/openmw/mwworld/weather.hpp | 107 ++++++++--------- apps/openmw/mwworld/world.cpp | 23 ++-- apps/openmw/mwworld/world.hpp | 4 +- 116 files changed, 891 insertions(+), 1170 deletions(-) delete mode 100644 apps/openmw/mwworld/environment.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index a27d5ae75..fb0e1db69 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -44,7 +44,7 @@ add_openmw_dir (mwsound ) add_openmw_dir (mwworld - refdata world physicssystem scene environment globals class action nullaction actionteleport + refdata world physicssystem scene globals class action nullaction actionteleport containerstore actiontalk actiontake manualref player cellfunctors cells localscripts customdata weather inventorystore ptr ) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index ef1497905..4ae6ae747 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -50,10 +50,12 @@ #include "mwmechanics/mechanicsmanager.hpp" +#include "mwbase/environment.hpp" + void OMW::Engine::executeLocalScripts() { - MWWorld::LocalScripts& localScripts = mEnvironment.mWorld->getLocalScripts(); + MWWorld::LocalScripts& localScripts = MWBase::Environment::get().getWorld()->getLocalScripts(); localScripts.startIteration(); @@ -61,11 +63,11 @@ void OMW::Engine::executeLocalScripts() { std::pair script = localScripts.getNext(); - MWScript::InterpreterContext interpreterContext (mEnvironment, + MWScript::InterpreterContext interpreterContext ( &script.second.getRefData().getLocals(), script.second); - mEnvironment.mScriptManager->run (script.first, interpreterContext); + MWBase::Environment::get().getScriptManager()->run (script.first, interpreterContext); - if (mEnvironment.mWorld->hasCellChanged()) + if (MWBase::Environment::get().getWorld()->hasCellChanged()) break; } @@ -81,7 +83,7 @@ void OMW::Engine::updateFocusReport (float duration) std::string name; - std::string handle = mEnvironment.mWorld->getFacedHandle(); + std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle(); if (!handle.empty()) { @@ -90,7 +92,7 @@ void OMW::Engine::updateFocusReport (float duration) // therefore, we are catching the "Unknown Ogre handle" exception that occurs in this case try { - MWWorld::Ptr ptr = mEnvironment.mWorld->getPtrViaHandle (handle); + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtrViaHandle (handle); if (!ptr.isEmpty()){ name = MWWorld::Class::get (ptr).getName (ptr); @@ -124,27 +126,27 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) { try { - mEnvironment.mFrameDuration = evt.timeSinceLastFrame; + mEnvironment.setFrameDuration (evt.timeSinceLastFrame); // update input - mEnvironment.mInputManager->update(); + MWBase::Environment::get().getInputManager()->update(); // sound if (mUseSound) - mEnvironment.mSoundManager->update (evt.timeSinceLastFrame); + MWBase::Environment::get().getSoundManager()->update (evt.timeSinceLastFrame); // update GUI Ogre::RenderWindow* window = mOgre->getWindow(); - mEnvironment.mWindowManager->wmUpdateFps(window->getLastFPS(), + MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), window->getTriangleCount(), window->getBatchCount()); - mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration); + MWBase::Environment::get().getWindowManager()->onFrame(mEnvironment.getFrameDuration()); // global scripts - mEnvironment.mScriptManager->getGlobalScripts().run (mEnvironment); + MWBase::Environment::get().getScriptManager()->getGlobalScripts().run(); - bool changed = mEnvironment.mWorld->hasCellChanged(); + bool changed = MWBase::Environment::get().getWorld()->hasCellChanged(); // local scripts executeLocalScripts(); // This does not handle the case where a global script causes a cell @@ -152,28 +154,28 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) // frame. // passing of time - if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game) - mEnvironment.mWorld->advanceTime ( - mEnvironment.mFrameDuration*mEnvironment.mWorld->getTimeScaleFactor()/3600); + if (MWBase::Environment::get().getWindowManager()->getMode()==MWGui::GM_Game) + MWBase::Environment::get().getWorld()->advanceTime ( + mEnvironment.getFrameDuration()*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600); if (changed) // keep change flag for another frame, if cell changed happend in local script - mEnvironment.mWorld->markCellAsUnchanged(); + MWBase::Environment::get().getWorld()->markCellAsUnchanged(); // update actors std::vector > movement; - mEnvironment.mMechanicsManager->update (movement, mEnvironment.mFrameDuration, - mEnvironment.mWindowManager->getMode()!=MWGui::GM_Game); + MWBase::Environment::get().getMechanicsManager()->update (movement, mEnvironment.getFrameDuration(), + MWBase::Environment::get().getWindowManager()->getMode()!=MWGui::GM_Game); - if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game) - mEnvironment.mWorld->doPhysics (movement, mEnvironment.mFrameDuration); + if (MWBase::Environment::get().getWindowManager()->getMode()==MWGui::GM_Game) + MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration()); // update world - mEnvironment.mWorld->update (evt.timeSinceLastFrame); + MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame); // report focus object (for debugging) if (mReportFocus) - updateFocusReport (mEnvironment.mFrameDuration); + updateFocusReport (mEnvironment.getFrameDuration()); } catch (const std::exception& e) { @@ -203,12 +205,13 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) OMW::Engine::~Engine() { - delete mEnvironment.mWorld; - delete mEnvironment.mSoundManager; - delete mEnvironment.mMechanicsManager; - delete mEnvironment.mDialogueManager; - delete mEnvironment.mJournal; - delete mEnvironment.mScriptManager; + delete MWBase::Environment::get().getInputManager(); + delete MWBase::Environment::get().getSoundManager(); + delete MWBase::Environment::get().getMechanicsManager(); + delete MWBase::Environment::get().getDialogueManager(); + delete MWBase::Environment::get().getJournal(); + delete MWBase::Environment::get().getScriptManager(); + delete MWBase::Environment::get().getWorld(); delete mScriptContext; delete mOgre; } @@ -312,7 +315,6 @@ void OMW::Engine::setReportFocus (bool report) void OMW::Engine::go() { mFocusTDiff = 0; - assert (!mEnvironment.mWorld); assert (!mCellName.empty()); assert (!mMaster.empty()); assert (!mOgre); @@ -381,66 +383,66 @@ void OMW::Engine::go() MWGui::CursorReplace replacer; // Create the world - mEnvironment.mWorld = new MWWorld::World (*mOgre, mFileCollections, mMaster, - mResDir, mNewGame, mEnvironment, mEncoding, mFallbackMap); + mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster, + mResDir, mNewGame, mEncoding, mFallbackMap)); // Create window manager - this manages all the MW-specific GUI windows MWScript::registerExtensions (mExtensions); - mEnvironment.mWindowManager = new MWGui::WindowManager(mEnvironment, - mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/")); + mEnvironment.setWindowManager (new MWGui::WindowManager( + mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"))); // Create sound system - mEnvironment.mSoundManager = new MWSound::SoundManager(mUseSound, mEnvironment); + mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound)); // Create script system - mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full, - mEnvironment); + mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full); mScriptContext->setExtensions (&mExtensions); - mEnvironment.mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(), - mVerboseScripts, *mScriptContext); + mEnvironment.setScriptManager (new MWScript::ScriptManager (MWBase::Environment::get().getWorld()->getStore(), + mVerboseScripts, *mScriptContext)); // Create game mechanics system - mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment); + mEnvironment.setMechanicsManager (new MWMechanics::MechanicsManager); // Create dialog system - mEnvironment.mJournal = new MWDialogue::Journal (mEnvironment); - mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment,mExtensions); + mEnvironment.setJournal (new MWDialogue::Journal); + mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions)); // load cell ESM::Position pos; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; pos.pos[2] = 0; - if (const ESM::Cell *exterior = mEnvironment.mWorld->getExterior (mCellName)) + if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName)) { - mEnvironment.mWorld->indexToPosition (exterior->data.gridX, exterior->data.gridY, + MWBase::Environment::get().getWorld()->indexToPosition (exterior->data.gridX, exterior->data.gridY, pos.pos[0], pos.pos[1], true); - mEnvironment.mWorld->changeToExteriorCell (pos); + MWBase::Environment::get().getWorld()->changeToExteriorCell (pos); } else { pos.pos[0] = pos.pos[1] = 0; - mEnvironment.mWorld->changeToInteriorCell (mCellName, pos); + MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos); } // Sets up the input system - MWInput::MWInputManager input(*mOgre, mEnvironment.mWorld->getPlayer(), - *mEnvironment.mWindowManager, mDebug, *this); - mEnvironment.mInputManager = &input; + + mEnvironment.setInputManager (new MWInput::MWInputManager (*mOgre, + MWBase::Environment::get().getWorld()->getPlayer(), + *MWBase::Environment::get().getWindowManager(), mDebug, *this)); std::cout << "\nPress Q/ESC or close window to exit.\n"; mOgre->getRoot()->addFrameListener (this); // Play some good 'ol tunes - mEnvironment.mSoundManager->playPlaylist(std::string("Explore")); + MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Explore")); // scripts if (mCompileAll) { - std::pair result = mEnvironment.mScriptManager->compileAll(); + std::pair result = MWBase::Environment::get().getScriptManager()->compileAll(); if (result.first) std::cout @@ -461,10 +463,10 @@ void OMW::Engine::go() void OMW::Engine::activate() { - if (mEnvironment.mWindowManager->getMode()!=MWGui::GM_Game) + if (MWBase::Environment::get().getWindowManager()->getMode()!=MWGui::GM_Game) return; - std::string handle = mEnvironment.mWorld->getFacedHandle(); + std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle(); if (handle.empty()) return; @@ -475,7 +477,7 @@ void OMW::Engine::activate() MWWorld::Ptr ptr; try { - ptr = mEnvironment.mWorld->getPtrViaHandle (handle); + ptr = MWBase::Environment::get().getWorld()->getPtrViaHandle (handle); if (ptr.isEmpty()) return; @@ -485,12 +487,10 @@ void OMW::Engine::activate() return; } - MWScript::InterpreterContext interpreterContext (mEnvironment, - &ptr.getRefData().getLocals(), ptr); + MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr); boost::shared_ptr action = - MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(), - mEnvironment); + MWWorld::Class::get (ptr).activate (ptr, MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); interpreterContext.activate (ptr, action); @@ -498,8 +498,8 @@ void OMW::Engine::activate() if (!script.empty()) { - mEnvironment.mWorld->getLocalScripts().setIgnore (ptr); - mEnvironment.mScriptManager->run (script, interpreterContext); + MWBase::Environment::get().getWorld()->getLocalScripts().setIgnore (ptr); + MWBase::Environment::get().getScriptManager()->run (script, interpreterContext); } if (!interpreterContext.hasActivationBeenHandled()) diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 6eae20cc0..ccd7314cb 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -10,7 +10,8 @@ #include #include -#include "mwworld/environment.hpp" +#include "mwbase/environment.hpp" + #include "mwworld/ptr.hpp" namespace Compiler @@ -78,7 +79,7 @@ namespace OMW std::string mFocusName; std::map mFallbackMap; - MWWorld::Environment mEnvironment; + MWBase::Environment mEnvironment; Compiler::Extensions mExtensions; Compiler::Context *mScriptContext; diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index 084505171..8e9a9cfce 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -7,7 +7,7 @@ MWBase::Environment *MWBase::Environment::sThis = 0; MWBase::Environment::Environment() : mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0), - mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0) + mMechanicsManager (0), mDialogueManager (0), mJournal (0), mInputManager (0), mFrameDuration (0) { assert (!sThis); sThis = this; @@ -53,6 +53,11 @@ void MWBase::Environment::setJournal (MWDialogue::Journal *journal) mJournal = journal; } +void MWBase::Environment::setInputManager (MWInput::MWInputManager *inputManager) +{ + mInputManager = inputManager; +} + void MWBase::Environment::setFrameDuration (float duration) { mFrameDuration = duration; @@ -100,6 +105,12 @@ MWDialogue::Journal *MWBase::Environment::getJournal() const return mJournal; } +MWInput::MWInputManager *MWBase::Environment::getInputManager() const +{ + assert (mInputManager); + return mInputManager; +} + float MWBase::Environment::getFrameDuration() const { return mFrameDuration; diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index 1b1ace0c7..a010e7faa 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -56,6 +56,7 @@ namespace MWBase MWMechanics::MechanicsManager *mMechanicsManager; MWDialogue::DialogueManager *mDialogueManager; MWDialogue::Journal *mJournal; + MWInput::MWInputManager *mInputManager; float mFrameDuration; Environment (const Environment&); @@ -84,6 +85,8 @@ namespace MWBase void setJournal (MWDialogue::Journal *journal); + void setInputManager (MWInput::MWInputManager *inputManager); + void setFrameDuration (float duration); ///< Set length of current frame in seconds. @@ -101,6 +104,8 @@ namespace MWBase MWDialogue::Journal *getJournal() const; + MWInput::MWInputManager *getInputManager() const; + float getFrameDuration() const; static const Environment& get(); diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 6749a2bfd..5b5028f1c 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -18,7 +18,7 @@ namespace MWClass assert (ref->base != NULL); const std::string &model = ref->base->model; - + if (!model.empty()) { MWRender::Objects& objects = renderingInterface.getObjects(); @@ -27,7 +27,7 @@ namespace MWClass } } - void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/activator.hpp b/apps/openmw/mwclass/activator.hpp index 08be8a5ff..d0b1f25e0 100644 --- a/apps/openmw/mwclass/activator.hpp +++ b/apps/openmw/mwclass/activator.hpp @@ -12,7 +12,7 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 90db40b5a..e7c208d4a 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -54,9 +55,9 @@ namespace MWClass } boost::shared_ptr Apparatus::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); diff --git a/apps/openmw/mwclass/apparatus.hpp b/apps/openmw/mwclass/apparatus.hpp index 861610f6c..9015aedb8 100644 --- a/apps/openmw/mwclass/apparatus.hpp +++ b/apps/openmw/mwclass/apparatus.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 8e1f81136..3a3403261 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -9,11 +9,11 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" - #include "../mwworld/inventorystore.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" +#include "../mwbase/environment.hpp" + #include "../mwrender/objects.hpp" #include "../mwsound/soundmanager.hpp" @@ -36,7 +36,7 @@ namespace MWClass } } - void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -58,9 +58,9 @@ namespace MWClass } boost::shared_ptr Armor::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -121,7 +121,7 @@ namespace MWClass return std::make_pair (slots, false); } - int Armor::getEquipmentSkill (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + int Armor::getEquipmentSkill (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -147,13 +147,13 @@ namespace MWClass if (typeGmst.empty()) return -1; - float iWeight = environment.mWorld->getStore().gameSettings.find (typeGmst)->i; + float iWeight = MWBase::Environment::get().getWorld()->getStore().gameSettings.find (typeGmst)->i; - if (iWeight * environment.mWorld->getStore().gameSettings.find ("fLightMaxMod")->f>= + if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fLightMaxMod")->f>= ref->base->data.weight) return ESM::Skill::LightArmor; - if (iWeight * environment.mWorld->getStore().gameSettings.find ("fMedMaxMod")->f>= + if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMedMaxMod")->f>= ref->base->data.weight) return ESM::Skill::MediumArmor; @@ -175,9 +175,9 @@ namespace MWClass registerClass (typeid (ESM::Armor).name(), instance); } - std::string Armor::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Armor::getUpSoundId (const MWWorld::Ptr& ptr) const { - int es = getEquipmentSkill(ptr, environment); + int es = getEquipmentSkill(ptr); if (es == ESM::Skill::LightArmor) return std::string("Item Armor Light Up"); else if (es == ESM::Skill::MediumArmor) @@ -186,9 +186,9 @@ namespace MWClass return std::string("Item Armor Heavy Up"); } - std::string Armor::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Armor::getDownSoundId (const MWWorld::Ptr& ptr) const { - int es = getEquipmentSkill(ptr, environment); + int es = getEquipmentSkill(ptr); if (es == ESM::Skill::LightArmor) return std::string("Item Armor Light Down"); else if (es == ESM::Skill::MediumArmor) diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index de5ca3983..6cba07726 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const; @@ -35,8 +35,7 @@ namespace MWClass ///< \return first: Return IDs of the slot this object can be equipped in; second: can object /// stay stacked when equipped? - virtual int getEquipmentSkill (const MWWorld::Ptr& ptr, - const MWWorld::Environment& environment) const; + virtual int getEquipmentSkill (const MWWorld::Ptr& ptr) const; /// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// no such skill. @@ -45,10 +44,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 9069d9476..b3b71104b 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -54,11 +55,11 @@ namespace MWClass } boost::shared_ptr Book::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { // TODO implement reading - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -87,12 +88,12 @@ namespace MWClass registerClass (typeid (ESM::Book).name(), instance); } - std::string Book::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Book::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Book Up"); } - std::string Book::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Book::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Book Down"); } diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index 4738187cd..975cdf12b 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -30,10 +30,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 672a2b60a..15f00bb05 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwrender/objects.hpp" @@ -32,7 +33,7 @@ namespace MWClass } } - void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -55,9 +56,9 @@ namespace MWClass } boost::shared_ptr Clothing::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -111,8 +112,7 @@ namespace MWClass return std::make_pair (slots, false); } - int Clothing::getEquipmentSkill (const MWWorld::Ptr& ptr, - const MWWorld::Environment& environment) const + int Clothing::getEquipmentSkill (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -138,7 +138,7 @@ namespace MWClass registerClass (typeid (ESM::Clothing).name(), instance); } - std::string Clothing::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Clothing::getUpSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -150,7 +150,7 @@ namespace MWClass return std::string("Item Clothes Up"); } - std::string Clothing::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Clothing::getDownSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index 97e09012d..7fc05bef3 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -29,8 +29,7 @@ namespace MWClass ///< \return first: Return IDs of the slot this object can be equipped in; second: can object /// stay stacked when equipped? - virtual int getEquipmentSkill (const MWWorld::Ptr& ptr, - const MWWorld::Environment& environment) const; + virtual int getEquipmentSkill (const MWWorld::Ptr& ptr) const; /// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// no such skill. @@ -39,10 +38,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 29b3331ba..a229cbe9b 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -5,11 +5,12 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/nullaction.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/customdata.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -61,7 +62,7 @@ namespace MWClass } } - void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -76,7 +77,7 @@ namespace MWClass } boost::shared_ptr Container::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { const std::string lockedSound = "LockedChest"; const std::string trapActivationSound = "Disarm Trap Fail"; @@ -85,7 +86,7 @@ namespace MWClass { // TODO check for key std::cout << "Locked container" << std::endl; - environment.mSoundManager->playSound3D (ptr, lockedSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0); return boost::shared_ptr (new MWWorld::NullAction); } else @@ -100,7 +101,7 @@ namespace MWClass { // Trap activation goes here std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; - environment.mSoundManager->playSound3D (ptr, trapActivationSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, trapActivationSound, 1.0, 1.0); ptr.getCellRef().trap = ""; return boost::shared_ptr (new MWWorld::NullAction); } diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 387714176..c371e8898 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -14,14 +14,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual MWWorld::ContainerStore& getContainerStore (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 7270fd22b..b5a17b2b5 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -6,9 +6,10 @@ #include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/mechanicsmanager.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/customdata.hpp" #include "../mwworld/containerstore.hpp" @@ -74,7 +75,7 @@ namespace MWClass actors.insertCreature(ptr); } - void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -87,14 +88,14 @@ namespace MWClass } } - void Creature::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + void Creature::enable (const MWWorld::Ptr& ptr) const { - environment.mMechanicsManager->addActor (ptr); + MWBase::Environment::get().getMechanicsManager()->addActor (ptr); } - void Creature::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + void Creature::disable (const MWWorld::Ptr& ptr) const { - environment.mMechanicsManager->removeActor (ptr); + MWBase::Environment::get().getMechanicsManager()->removeActor (ptr); } std::string Creature::getName (const MWWorld::Ptr& ptr) const @@ -113,7 +114,7 @@ namespace MWClass } boost::shared_ptr Creature::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); } diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index 8eb45e838..fa07f9625 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -20,12 +20,12 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; - virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + virtual void enable (const MWWorld::Ptr& ptr) const; ///< Enable reference; only does the non-rendering part - virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + virtual void disable (const MWWorld::Ptr& ptr) const; ///< Enable reference; only does the non-rendering part virtual std::string getName (const MWWorld::Ptr& ptr) const; @@ -36,7 +36,7 @@ namespace MWClass ///< Return creature stats virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual MWWorld::ContainerStore& getContainerStore ( diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 9d6c6a78d..003beaa30 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -5,11 +5,12 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/player.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/nullaction.hpp" #include "../mwworld/actionteleport.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwrender/objects.hpp" @@ -34,7 +35,7 @@ namespace MWClass } } - void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -58,7 +59,7 @@ namespace MWClass } boost::shared_ptr Door::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -73,7 +74,7 @@ namespace MWClass // TODO check for key // TODO report failure to player (message, sound?). Look up behaviour of original MW. std::cout << "Locked!" << std::endl; - environment.mSoundManager->playSound3D (ptr, lockedSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0); return boost::shared_ptr (new MWWorld::NullAction); } @@ -81,7 +82,7 @@ namespace MWClass { // Trap activation std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; - environment.mSoundManager->playSound3D(ptr, trapActivationSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound3D(ptr, trapActivationSound, 1.0, 1.0); ptr.getCellRef().trap = ""; return boost::shared_ptr (new MWWorld::NullAction); } @@ -89,11 +90,11 @@ namespace MWClass if (ref->ref.teleport) { // teleport door - if (environment.mWorld->getPlayer().getPlayer()==actor) + if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor) { // the player is using the door // The reason this is not 3D is that it would get interrupted when you teleport - environment.mSoundManager->playSound(openSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound(openSound, 1.0, 1.0); return boost::shared_ptr ( new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest)); } @@ -110,7 +111,7 @@ namespace MWClass // TODO return action for rotating the door // This is a little pointless, but helps with testing - environment.mSoundManager->playSound3D (ptr, openSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, openSound, 1.0, 1.0); return boost::shared_ptr (new MWWorld::NullAction); } } diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index aecb4224c..4779ed174 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual void lock (const MWWorld::Ptr& ptr, int lockLevel) const; diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 9707e79a8..79b1bb92f 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -52,9 +53,9 @@ namespace MWClass } boost::shared_ptr Ingredient::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -83,12 +84,12 @@ namespace MWClass registerClass (typeid (ESM::Ingredient).name(), instance); } - std::string Ingredient::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Ingredient::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Ingredient Up"); } - std::string Ingredient::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Ingredient::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Ingredient Down"); } diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index 2d7717672..d8190c8fc 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -30,10 +30,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index f67dd4cf0..deb8c2567 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -5,10 +5,11 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/nullaction.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwsound/soundmanager.hpp" @@ -39,7 +40,7 @@ namespace MWClass objects.insertLight (ptr, r, g, b, radius); } - void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -52,14 +53,14 @@ namespace MWClass } } - void Light::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + void Light::enable (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); if (!ref->base->sound.empty()) { - environment.mSoundManager->playSound3D (ptr, ref->base->sound, 1.0, 1.0, MWSound::Play_Loop); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, ref->base->sound, 1.0, 1.0, MWSound::Play_Loop); } } @@ -75,7 +76,7 @@ namespace MWClass } boost::shared_ptr Light::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -83,7 +84,7 @@ namespace MWClass if (!(ref->base->data.flags & ESM::Light::Carry)) return boost::shared_ptr (new MWWorld::NullAction); - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -125,12 +126,12 @@ namespace MWClass registerClass (typeid (ESM::Light).name(), instance); } - std::string Light::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Light::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Misc Up"); } - std::string Light::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Light::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Misc Down"); } diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index bde252c28..5d139cb8f 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -12,9 +12,9 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; - virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + virtual void enable (const MWWorld::Ptr& ptr) const; ///< Enable reference; only does the non-rendering part /// \attention This is not the same as the script instruction with the same name. References /// should only be enabled while in an active cell. @@ -24,7 +24,7 @@ namespace MWClass /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -39,10 +39,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index 76bc3948f..d682538ea 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwrender/objects.hpp" @@ -32,7 +33,7 @@ namespace MWClass } } - void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -56,9 +57,9 @@ namespace MWClass } boost::shared_ptr Lockpick::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -96,12 +97,12 @@ namespace MWClass registerClass (typeid (ESM::Tool).name(), instance); } - std::string Lockpick::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Lockpick::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Lockpick Up"); } - std::string Lockpick::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Lockpick::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Lockpick Down"); } diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index 1b56234af..042c726e4 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -34,10 +34,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 84099caaa..bcbf26870 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -54,9 +55,9 @@ namespace MWClass } boost::shared_ptr Miscellaneous::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -85,7 +86,7 @@ namespace MWClass registerClass (typeid (ESM::Miscellaneous).name(), instance); } - std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -97,7 +98,7 @@ namespace MWClass return std::string("Item Misc Up"); } - std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index fc002280c..bc05169c0 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -30,10 +30,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c053ad130..aaa239d47 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -14,11 +14,12 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwworld/customdata.hpp" +#include "../mwbase/environment.hpp" + namespace { const Ogre::Radian kOgrePi (Ogre::Math::PI); @@ -105,13 +106,13 @@ namespace MWClass void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - - + + renderingInterface.getActors().insertNPC(ptr, getInventoryStore(ptr)); - + } - void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { @@ -133,14 +134,14 @@ namespace MWClass } - void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + void Npc::enable (const MWWorld::Ptr& ptr) const { - environment.mMechanicsManager->addActor (ptr); + MWBase::Environment::get().getMechanicsManager()->addActor (ptr); } - void Npc::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const + void Npc::disable (const MWWorld::Ptr& ptr) const { - environment.mMechanicsManager->removeActor (ptr); + MWBase::Environment::get().getMechanicsManager()->removeActor (ptr); } std::string Npc::getName (const MWWorld::Ptr& ptr) const @@ -166,7 +167,7 @@ namespace MWClass } boost::shared_ptr Npc::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { return boost::shared_ptr (new MWWorld::ActionTalk (ptr)); } diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index f210eda5f..1ef77bd1b 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -17,12 +17,12 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; - virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + virtual void enable (const MWWorld::Ptr& ptr) const; ///< Enable reference; only does the non-rendering part - virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const; + virtual void disable (const MWWorld::Ptr& ptr) const; ///< Enable reference; only does the non-rendering part virtual std::string getName (const MWWorld::Ptr& ptr) const; @@ -42,7 +42,7 @@ namespace MWClass ///< Return inventory store virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 642211df3..790b4d13e 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -54,9 +55,9 @@ namespace MWClass } boost::shared_ptr Potion::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -85,12 +86,12 @@ namespace MWClass registerClass (typeid (ESM::Potion).name(), instance); } - std::string Potion::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Potion::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Potion Up"); } - std::string Potion::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Potion::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Potion Down"); } diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 7d3017937..f9137766b 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -30,10 +30,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 923c29ee6..bfb1d2951 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwrender/objects.hpp" @@ -32,7 +33,7 @@ namespace MWClass } } - void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -55,9 +56,9 @@ namespace MWClass return ref->base->name; } boost::shared_ptr Probe::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -95,12 +96,12 @@ namespace MWClass registerClass (typeid (ESM::Probe).name(), instance); } - std::string Probe::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Probe::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Probe Up"); } - std::string Probe::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Probe::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Probe Down"); } diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index 232b52364..543fa3f39 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -34,10 +34,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index d6433f5df..8bae71e19 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwrender/objects.hpp" @@ -31,7 +32,7 @@ namespace MWClass } } - void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -54,9 +55,9 @@ namespace MWClass } boost::shared_ptr Repair::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -85,12 +86,12 @@ namespace MWClass registerClass (typeid (ESM::Repair).name(), instance); } - std::string Repair::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Repair::getUpSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Repair Up"); } - std::string Repair::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Repair::getDownSoundId (const MWWorld::Ptr& ptr) const { return std::string("Item Repair Down"); } diff --git a/apps/openmw/mwclass/repair.hpp b/apps/openmw/mwclass/repair.hpp index 0a9d9c253..446ab325d 100644 --- a/apps/openmw/mwclass/repair.hpp +++ b/apps/openmw/mwclass/repair.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual std::string getScript (const MWWorld::Ptr& ptr) const; @@ -30,10 +30,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index 48750dd01..4a4136816 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -25,7 +25,7 @@ namespace MWClass } } - void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/static.hpp b/apps/openmw/mwclass/static.hpp index a4b1d8c54..cd1626c19 100644 --- a/apps/openmw/mwclass/static.hpp +++ b/apps/openmw/mwclass/static.hpp @@ -12,7 +12,7 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 7790e6a80..22745f82d 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -5,9 +5,10 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwrender/objects.hpp" @@ -32,7 +33,7 @@ namespace MWClass } } - void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -55,9 +56,9 @@ namespace MWClass } boost::shared_ptr Weapon::activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const + const MWWorld::Ptr& actor) const { - environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, MWSound::Play_NoTrack); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack); return boost::shared_ptr ( new MWWorld::ActionTake (ptr)); @@ -108,8 +109,7 @@ namespace MWClass return std::make_pair (slots, stack); } - int Weapon::getEquipmentSkill (const MWWorld::Ptr& ptr, - const MWWorld::Environment& environment) const + int Weapon::getEquipmentSkill (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -154,7 +154,7 @@ namespace MWClass registerClass (typeid (ESM::Weapon).name(), instance); } - std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); @@ -200,7 +200,7 @@ namespace MWClass return std::string("Item Misc Up"); } - std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const + std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index 505c45645..204d327ad 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -12,14 +12,14 @@ namespace MWClass virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering - virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const; virtual std::string getName (const MWWorld::Ptr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, - const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; + const MWWorld::Ptr& actor) const; ///< Generate action for activation virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const; @@ -35,8 +35,7 @@ namespace MWClass ///< \return first: Return IDs of the slot this object can be equipped in; second: can object /// stay stacked when equipped? - virtual int getEquipmentSkill (const MWWorld::Ptr& ptr, - const MWWorld::Environment& environment) const; + virtual int getEquipmentSkill (const MWWorld::Ptr& ptr) const; /// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// no such skill. @@ -45,10 +44,10 @@ namespace MWClass static void registerSelf(); - virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; ///< Return the pick up sound Id - virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; ///< Return the put down sound Id }; } diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 3188136b3..f753e936e 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -9,9 +9,9 @@ #include +#include "../mwbase/environment.hpp" #include "../mwworld/class.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwworld/refdata.hpp" #include "../mwworld/player.hpp" @@ -181,7 +181,7 @@ namespace MWDialogue case 46://Same faction { - MWMechanics::NpcStats PCstats = MWWorld::Class::get(mEnvironment.mWorld->getPlayer().getPlayer()).getNpcStats(mEnvironment.mWorld->getPlayer().getPlayer()); + MWMechanics::NpcStats PCstats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor); int sameFaction = 0; if(!NPCstats.mFactionRank.empty()) @@ -288,12 +288,12 @@ namespace MWDialogue if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || select.type==ESM::VT_Long) { - if (!checkGlobal (comp, toLower (name), select.i, *mEnvironment.mWorld)) + if (!checkGlobal (comp, toLower (name), select.i, *MWBase::Environment::get().getWorld())) return false; } else if (select.type==ESM::VT_Float) { - if (!checkGlobal (comp, toLower (name), select.f, *mEnvironment.mWorld)) + if (!checkGlobal (comp, toLower (name), select.f, *MWBase::Environment::get().getWorld())) return false; } else @@ -308,13 +308,13 @@ namespace MWDialogue select.type==ESM::VT_Long) { if (!checkLocal (comp, toLower (name), select.i, actor, - mEnvironment.mWorld->getStore())) + MWBase::Environment::get().getWorld()->getStore())) return false; } else if (select.type==ESM::VT_Float) { if (!checkLocal (comp, toLower (name), select.f, actor, - mEnvironment.mWorld->getStore())) + MWBase::Environment::get().getWorld()->getStore())) return false; } else @@ -326,7 +326,7 @@ namespace MWDialogue case '4'://journal if(select.type==ESM::VT_Int) { - if(!selectCompare(comp,mEnvironment.mJournal->getJournalIndex(toLower(name)),select.i)) return false; + if(!selectCompare(comp,MWBase::Environment::get().getJournal()->getJournalIndex(toLower(name)),select.i)) return false; } else throw std::runtime_error ( @@ -336,7 +336,7 @@ namespace MWDialogue case '5'://item { - MWWorld::Ptr player = mEnvironment.mWorld->getPlayer().getPlayer(); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player); int sum = 0; @@ -424,13 +424,13 @@ namespace MWDialogue select.type==ESM::VT_Long) { if (checkLocal (comp, toLower (name), select.i, actor, - mEnvironment.mWorld->getStore())) + MWBase::Environment::get().getWorld()->getStore())) return false; } else if (select.type==ESM::VT_Float) { if (checkLocal (comp, toLower (name), select.f, actor, - mEnvironment.mWorld->getStore())) + MWBase::Environment::get().getWorld()->getStore())) return false; } else @@ -500,7 +500,7 @@ namespace MWDialogue // TODO check player faction if(!info.pcFaction.empty()) { - MWMechanics::NpcStats stats = MWWorld::Class::get(mEnvironment.mWorld->getPlayer().getPlayer()).getNpcStats(mEnvironment.mWorld->getPlayer().getPlayer()); + MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); std::map::iterator it = stats.mFactionRank.find(info.pcFaction); if(it!=stats.mFactionRank.end()) { @@ -528,7 +528,7 @@ namespace MWDialogue // check cell if (!info.cell.empty()) - if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell) + if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->name != info.cell) return false; // TODO check DATAstruct @@ -540,8 +540,8 @@ namespace MWDialogue return true; } - DialogueManager::DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions) : - mEnvironment (environment),mCompilerContext (MWScript::CompilerContext::Type_Dialgoue, environment), + DialogueManager::DialogueManager (const Compiler::Extensions& extensions) : + mCompilerContext (MWScript::CompilerContext::Type_Dialgoue), mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) { mChoice = -1; @@ -549,7 +549,7 @@ namespace MWDialogue mCompilerContext.setExtensions (&extensions); mDialogueMap.clear(); actorKnownTopics.clear(); - ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + ESMS::RecListCaseT::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { mDialogueMap[toLower(it->first)] = it->second; @@ -592,8 +592,8 @@ namespace MWDialogue actorKnownTopics.clear(); //initialise the GUI - mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue); - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + MWBase::Environment::get().getInputManager()->setGuiMode(MWGui::GM_Dialogue); + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->startDialogue(MWWorld::Class::get (actor).getName (actor)); //setup the list of topics known by the actor. Topics who are also on the knownTopics list will be added to the GUI @@ -601,8 +601,8 @@ namespace MWDialogue //greeting bool greetingFound = false; - //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + //ESMS::RecListT::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; + ESMS::RecListCaseT::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; @@ -650,7 +650,7 @@ namespace MWDialogue if (!actorScript.empty()) { // grab local variables from actor's script, if available. - locals = mEnvironment.mScriptManager->getLocals (actorScript); + locals = MWBase::Environment::get().getScriptManager()->getLocals (actorScript); } Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false); @@ -683,7 +683,7 @@ namespace MWDialogue { try { - MWScript::InterpreterContext interpreterContext(mEnvironment,&mActor.getRefData().getLocals(),mActor); + MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor); Interpreter::Interpreter interpreter; MWScript::installOpcodes (interpreter); interpreter.run (&code[0], code.size(), interpreterContext); @@ -701,8 +701,8 @@ namespace MWDialogue int choice = mChoice; mChoice = -1; actorKnownTopics.clear(); - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - ESMS::RecListCaseT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); + ESMS::RecListCaseT::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; for(ESMS::RecListCaseT::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; @@ -747,7 +747,7 @@ namespace MWDialogue parseText(text); - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->addTitle(keyword); win->addText(iter->response); @@ -767,7 +767,7 @@ namespace MWDialogue void DialogueManager::goodbyeSelected() { - mEnvironment.mInputManager->setGuiMode(MWGui::GM_Game); + MWBase::Environment::get().getInputManager()->setGuiMode(MWGui::GM_Game); } void DialogueManager::questionAnswered(std::string answere) @@ -790,7 +790,7 @@ namespace MWDialogue mChoiceMap.clear(); mChoice = -1; mIsInChoice = false; - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); std::string text = iter->response; parseText(text); win->addText(text); @@ -808,13 +808,13 @@ namespace MWDialogue void DialogueManager::printError(std::string error) { - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->addText(error); } void DialogueManager::askQuestion(std::string question, int choice) { - MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->askQuestion(question); mChoiceMap[question] = choice; mIsInChoice = true; diff --git a/apps/openmw/mwdialogue/dialoguemanager.hpp b/apps/openmw/mwdialogue/dialoguemanager.hpp index d0380fa71..a3e37987d 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.hpp +++ b/apps/openmw/mwdialogue/dialoguemanager.hpp @@ -11,17 +11,10 @@ #include "../mwworld/ptr.hpp" #include -namespace MWWorld -{ - class Environment; -} - namespace MWDialogue { class DialogueManager { - MWWorld::Environment& mEnvironment; - bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const; bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; @@ -39,7 +32,7 @@ namespace MWDialogue MWScript::CompilerContext mCompilerContext; std::ostream mErrorStream; Compiler::StreamErrorHandler mErrorHandler; - + bool compile (const std::string& cmd,std::vector& code); void executeScript(std::string script); @@ -55,7 +48,7 @@ namespace MWDialogue public: - DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions); + DialogueManager (const Compiler::Extensions& extensions); void startDialogue (const MWWorld::Ptr& actor); diff --git a/apps/openmw/mwdialogue/journal.cpp b/apps/openmw/mwdialogue/journal.cpp index 0715214eb..e0245406e 100644 --- a/apps/openmw/mwdialogue/journal.cpp +++ b/apps/openmw/mwdialogue/journal.cpp @@ -1,7 +1,7 @@ #include "journal.hpp" -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwgui/window_manager.hpp" #include "../mwgui/messagebox.hpp" @@ -23,31 +23,30 @@ namespace MWDialogue return iter->second; } - Journal::Journal (MWWorld::Environment& environment) - : mEnvironment (environment) + Journal::Journal() {} void Journal::addEntry (const std::string& id, int index) { StampedJournalEntry entry = - StampedJournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld); + StampedJournalEntry::makeFromQuest (id, index, *MWBase::Environment::get().getWorld()); mJournal.push_back (entry); Quest& quest = getQuest (id); - quest.addEntry (entry, *mEnvironment.mWorld); // we are doing slicing on purpose here - + quest.addEntry (entry, *MWBase::Environment::get().getWorld()); // we are doing slicing on purpose here + std::vector empty; std::string notification = "Your Journal has been updated."; - mEnvironment.mWindowManager->messageBox (notification, empty); + MWBase::Environment::get().getWindowManager()->messageBox (notification, empty); } void Journal::setJournalIndex (const std::string& id, int index) { Quest& quest = getQuest (id); - quest.setIndex (index, *mEnvironment.mWorld); + quest.setIndex (index, *MWBase::Environment::get().getWorld()); } void Journal::addTopic (const std::string& topicId, const std::string& infoId) @@ -62,7 +61,7 @@ namespace MWDialogue iter = result.first; } - iter->second.addEntry (JournalEntry (topicId, infoId), *mEnvironment.mWorld); + iter->second.addEntry (JournalEntry (topicId, infoId), *MWBase::Environment::get().getWorld()); } int Journal::getJournalIndex (const std::string& id) const diff --git a/apps/openmw/mwdialogue/journal.hpp b/apps/openmw/mwdialogue/journal.hpp index ff1343945..62b9f4bed 100644 --- a/apps/openmw/mwdialogue/journal.hpp +++ b/apps/openmw/mwdialogue/journal.hpp @@ -8,11 +8,6 @@ #include "journalentry.hpp" #include "quest.hpp" -namespace MWWorld -{ - struct Environment; -} - namespace MWDialogue { /// \brief The player's journal @@ -29,7 +24,6 @@ namespace MWDialogue private: - MWWorld::Environment& mEnvironment; TEntryContainer mJournal; TQuestContainer mQuests; TTopicContainer mTopics; @@ -38,7 +32,7 @@ namespace MWDialogue public: - Journal (MWWorld::Environment& environment); + Journal(); void addEntry (const std::string& id, int index); ///< Add a journal entry. diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index ce5e744cc..9a2375855 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -8,6 +8,8 @@ #include "dialogue.hpp" #include "mode.hpp" +#include "../mwbase/environment.hpp" + namespace { struct Step @@ -93,7 +95,7 @@ namespace using namespace MWGui; -CharacterCreation::CharacterCreation(WindowManager* _wm, MWWorld::Environment* _environment) +CharacterCreation::CharacterCreation(WindowManager* _wm) : mNameDialog(0) , mRaceDialog(0) , mDialogueWindow(0) @@ -105,7 +107,6 @@ CharacterCreation::CharacterCreation(WindowManager* _wm, MWWorld::Environment* _ , mBirthSignDialog(0) , mReviewDialog(0) , mWM(_wm) - , mEnvironment(_environment) { mCreationStage = CSE_NotStarted; } @@ -279,8 +280,8 @@ void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow) { const std::string &classId = mPickClassDialog->getClassId(); if (!classId.empty()) - mEnvironment->mMechanicsManager->setPlayerClass(classId); - const ESM::Class *klass = mEnvironment->mWorld->getStore().classes.find(classId); + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId); + const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(classId); if (klass) { mPlayerClass = *klass; @@ -307,7 +308,7 @@ void CharacterCreation::onPickClassDialogBack() { const std::string classId = mPickClassDialog->getClassId(); if (!classId.empty()) - mEnvironment->mMechanicsManager->setPlayerClass(classId); + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId); mWM->removeDialog(mPickClassDialog); } @@ -345,7 +346,7 @@ void CharacterCreation::onNameDialogDone(WindowBase* parWindow) { mPlayerName = mNameDialog->getTextInput(); mWM->setValue("name", mPlayerName); - mEnvironment->mMechanicsManager->setPlayerName(mPlayerName); + MWBase::Environment::get().getMechanicsManager()->setPlayerName(mPlayerName); mWM->removeDialog(mNameDialog); } @@ -366,7 +367,7 @@ void CharacterCreation::onRaceDialogBack() { mPlayerRaceId = mRaceDialog->getRaceId(); if (!mPlayerRaceId.empty()) - mEnvironment->mMechanicsManager->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); + MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); mWM->removeDialog(mRaceDialog); } @@ -380,7 +381,7 @@ void CharacterCreation::onRaceDialogDone(WindowBase* parWindow) mPlayerRaceId = mRaceDialog->getRaceId(); mWM->setValue("race", mPlayerRaceId); if (!mPlayerRaceId.empty()) - mEnvironment->mMechanicsManager->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); + MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); mWM->removeDialog(mRaceDialog); } @@ -402,7 +403,7 @@ void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow) mPlayerBirthSignId = mBirthSignDialog->getBirthId(); mWM->setBirthSign(mPlayerBirthSignId); if (!mPlayerBirthSignId.empty()) - mEnvironment->mMechanicsManager->setPlayerBirthsign(mPlayerBirthSignId); + MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mPlayerBirthSignId); mWM->removeDialog(mBirthSignDialog); } @@ -419,7 +420,7 @@ void CharacterCreation::onBirthSignDialogBack() { if (mBirthSignDialog) { - mEnvironment->mMechanicsManager->setPlayerBirthsign(mBirthSignDialog->getBirthId()); + MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mBirthSignDialog->getBirthId()); mWM->removeDialog(mBirthSignDialog); } @@ -450,7 +451,7 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow) klass.data.skills[i][1] = majorSkills[i]; klass.data.skills[i][0] = minorSkills[i]; } - mEnvironment->mMechanicsManager->setPlayerClass(klass); + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass); mPlayerClass = klass; mWM->setPlayerClass(klass); @@ -592,7 +593,7 @@ void CharacterCreation::onGenerateClassBack() if (mGenerateClassResultDialog) mWM->removeDialog(mGenerateClassResultDialog); - mEnvironment->mMechanicsManager->setPlayerClass(mGenerateClass); + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); mWM->setGuiMode(GM_Class); } @@ -601,7 +602,7 @@ void CharacterCreation::onGenerateClassDone(WindowBase* parWindow) { if (mGenerateClassResultDialog) mWM->removeDialog(mGenerateClassResultDialog); - mEnvironment->mMechanicsManager->setPlayerClass(mGenerateClass); + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); if (mCreationStage == CSE_ReviewNext) mWM->setGuiMode(GM_Review); diff --git a/apps/openmw/mwgui/charactercreation.hpp b/apps/openmw/mwgui/charactercreation.hpp index b01e754d9..222754cdc 100644 --- a/apps/openmw/mwgui/charactercreation.hpp +++ b/apps/openmw/mwgui/charactercreation.hpp @@ -30,7 +30,7 @@ namespace MWGui public: typedef std::vector SkillList; - CharacterCreation(WindowManager* _wm, MWWorld::Environment* _environment); + CharacterCreation(WindowManager* _wm); ~CharacterCreation(); //Show a dialog @@ -56,7 +56,6 @@ namespace MWGui ReviewDialog* mReviewDialog; WindowManager* mWM; - MWWorld::Environment* mEnvironment; //Player data std::string mPlayerName; diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index ac4f4a82a..8e15abddd 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -7,6 +7,8 @@ #include "../mwscript/extensions.hpp" +#include "../mwbase/environment.hpp" + namespace MWGui { class ConsoleInterpreterContext : public MWScript::InterpreterContext @@ -15,15 +17,14 @@ namespace MWGui public: - ConsoleInterpreterContext (Console& console, MWWorld::Environment& environment, - MWWorld::Ptr reference); + ConsoleInterpreterContext (Console& console, MWWorld::Ptr reference); virtual void report (const std::string& message); }; ConsoleInterpreterContext::ConsoleInterpreterContext (Console& console, - MWWorld::Environment& environment, MWWorld::Ptr reference) - : MWScript::InterpreterContext (environment, + MWWorld::Ptr reference) + : MWScript::InterpreterContext ( reference.isEmpty() ? 0 : &reference.getRefData().getLocals(), reference), mConsole (console) {} @@ -88,7 +89,7 @@ namespace MWGui scanner.listKeywords (mNames); // identifier - const ESMS::ESMStore& store = mEnvironment.mWorld->getStore(); + const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); for (ESMS::RecListList::const_iterator iter (store.recLists.begin()); iter!=store.recLists.end(); ++iter) @@ -101,11 +102,9 @@ namespace MWGui } } - Console::Console(int w, int h, MWWorld::Environment& environment, - const Compiler::Extensions& extensions) + Console::Console(int w, int h, const Compiler::Extensions& extensions) : Layout("openmw_console_layout.xml"), - mCompilerContext (MWScript::CompilerContext::Type_Console, environment), - mEnvironment (environment) + mCompilerContext (MWScript::CompilerContext::Type_Console) { setCoord(10,10, w-10, h/2); @@ -139,7 +138,7 @@ namespace MWGui void Console::disable() { setVisible(false); - // Remove keyboard focus from the console input whenever the + // Remove keyboard focus from the console input whenever the // console is turned off MyGUI::InputManager::getInstance().setKeyFocusWidget(NULL); } @@ -241,7 +240,7 @@ namespace MWGui { try { - ConsoleInterpreterContext interpreterContext (*this, mEnvironment, MWWorld::Ptr()); + ConsoleInterpreterContext interpreterContext (*this, MWWorld::Ptr()); Interpreter::Interpreter interpreter; MWScript::installOpcodes (interpreter); std::vector code; diff --git a/apps/openmw/mwgui/console.hpp b/apps/openmw/mwgui/console.hpp index eaf4299be..6974d8333 100644 --- a/apps/openmw/mwgui/console.hpp +++ b/apps/openmw/mwgui/console.hpp @@ -23,7 +23,6 @@ namespace MWGui private: MWScript::CompilerContext mCompilerContext; - MWWorld::Environment& mEnvironment; std::vector mNames; bool compile (const std::string& cmd, Compiler::Output& output); @@ -51,7 +50,7 @@ namespace MWGui StringList::iterator current; std::string editString; - Console(int w, int h, MWWorld::Environment& environment, const Compiler::Extensions& extensions); + Console(int w, int h, const Compiler::Extensions& extensions); void enable(); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index fc7a36382..2386cf9a3 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -3,7 +3,7 @@ #include "window_manager.hpp" #include "widgets.hpp" #include "components/esm_store/store.hpp" -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwdialogue/dialoguemanager.hpp" #include @@ -36,9 +36,8 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su } -DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment) - : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager), - mEnvironment(environment) +DialogueWindow::DialogueWindow(WindowManager& parWindowManager) + : WindowBase("openmw_dialogue_window_layout.xml", parWindowManager) { // Centre dialog center(); @@ -54,7 +53,7 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environm /// \todo scrolling the dialogue history with the mouse wheel doesn't work using this solution getWidget(eventbox, "EventBox"); eventbox->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked); - + //Topics list getWidget(topicsList, "TopicsList"); topicsList->setScrollVisible(true); @@ -83,9 +82,9 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) if(color != "#B29154") { UString key = history->getColorTextAt(cursorPosition); - if(color == "#686EBA") mEnvironment.mDialogueManager->keywordSelected(lower_string(key)); + if(color == "#686EBA") MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(key)); - if(color == "#572D21") mEnvironment.mDialogueManager->questionAnswered(key); + if(color == "#572D21") MWBase::Environment::get().getDialogueManager()->questionAnswered(key); } } @@ -100,7 +99,7 @@ void DialogueWindow::open() void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) { - mEnvironment.mDialogueManager->goodbyeSelected(); + MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); } void DialogueWindow::onSelectTopic(MyGUI::ListBox* _sender, size_t _index) @@ -108,7 +107,7 @@ void DialogueWindow::onSelectTopic(MyGUI::ListBox* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; std::string topic = _sender->getItemNameAt(_index); - mEnvironment.mDialogueManager->keywordSelected(lower_string(topic)); + MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic)); } void DialogueWindow::startDialogue(std::string npcName) diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index b80a016cb..5b8439758 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -9,11 +9,6 @@ namespace MWGui class WindowManager; } -namespace MWWorld -{ - class Environment; -} - /* This file contains the dialouge window Layout is defined by resources/mygui/openmw_dialogue_window_layout.xml. @@ -28,7 +23,7 @@ namespace MWGui class DialogueWindow: public WindowBase { public: - DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment); + DialogueWindow(WindowManager& parWindowManager); void open(); @@ -65,8 +60,6 @@ namespace MWGui MyGUI::ProgressPtr pDispositionBar; MyGUI::EditPtr pDispositionText; std::map pTopicsText;// this map links keyword and "real" text. - - MWWorld::Environment& mEnvironment; }; } #endif diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 644bcbc04..e67eda777 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -1,7 +1,7 @@ #include "journalwindow.hpp" #include "window_manager.hpp" #include "../mwdialogue/journal.hpp" -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwworld/world.hpp" #include "../mwsound/soundmanager.hpp" @@ -118,20 +118,20 @@ void MWGui::JournalWindow::open() { mPageNumber = 0; std::string journalOpenSound = "book open"; - mWindowManager.getEnvironment().mSoundManager->playSound (journalOpenSound, 1.0, 1.0); - if(mWindowManager.getEnvironment().mJournal->begin()!=mWindowManager.getEnvironment().mJournal->end()) + MWBase::Environment::get().getSoundManager()->playSound (journalOpenSound, 1.0, 1.0); + if(MWBase::Environment::get().getJournal()->begin()!=MWBase::Environment::get().getJournal()->end()) { book journal; journal.endLine = 0; - for(std::deque::const_iterator it = mWindowManager.getEnvironment().mJournal->begin();it!=mWindowManager.getEnvironment().mJournal->end();it++) + for(std::deque::const_iterator it = MWBase::Environment::get().getJournal()->begin();it!=MWBase::Environment::get().getJournal()->end();it++) { - std::string a = it->getText(mWindowManager.getEnvironment().mWorld->getStore()); + std::string a = it->getText(MWBase::Environment::get().getWorld()->getStore()); journal = formatText(a,journal,10,17); journal.endLine = journal.endLine +1; journal.pages.back() = journal.pages.back() + std::string("\n"); } - //std::string a = mWindowManager.getEnvironment().mJournal->begin()->getText(mWindowManager.getEnvironment().mWorld->getStore()); + //std::string a = MWBase::Environment::get().getJournal()->begin()->getText(MWBase::Environment::get().getWorld()->getStore()); //std::list journal = formatText(a,10,20,1); bool left = true; for(std::list::iterator it = journal.pages.begin(); it != journal.pages.end();it++) @@ -155,7 +155,7 @@ void MWGui::JournalWindow::open() } else { - //std::cout << mWindowManager.getEnvironment().mJournal->begin()->getText(mWindowManager.getEnvironment().mWorld->getStore()); + //std::cout << MWBase::Environment::get().getJournal()->begin()->getText(MWBase::Environment::get().getWorld()->getStore()); } } @@ -181,7 +181,7 @@ void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender) if(mPageNumber < int(leftPages.size())-1) { std::string nextSound = "book page2"; - mWindowManager.getEnvironment().mSoundManager->playSound (nextSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound (nextSound, 1.0, 1.0); mPageNumber = mPageNumber + 1; displayLeftText(leftPages[mPageNumber]); displayRightText(rightPages[mPageNumber]); @@ -193,7 +193,7 @@ void MWGui::JournalWindow::notifyPrevPage(MyGUI::WidgetPtr _sender) if(mPageNumber > 0) { std::string prevSound = "book page"; - mWindowManager.getEnvironment().mSoundManager->playSound (prevSound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound (prevSound, 1.0, 1.0); mPageNumber = mPageNumber - 1; displayLeftText(leftPages[mPageNumber]); displayRightText(rightPages[mPageNumber]); diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index 34d62ba08..0792b0fcb 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -11,6 +11,8 @@ #include "../mwmechanics/mechanicsmanager.hpp" #include "../mwinput/inputmanager.hpp" +#include "../mwbase/environment.hpp" + #include "console.hpp" #include "journalwindow.hpp" #include "charactercreation.hpp" @@ -23,10 +25,9 @@ using namespace MWGui; -WindowManager::WindowManager(MWWorld::Environment& environment, +WindowManager::WindowManager( const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string logpath) : mGuiManager(NULL) - , environment(environment) , hud(NULL) , map(NULL) , menu(NULL) @@ -76,15 +77,15 @@ WindowManager::WindowManager(MWWorld::Environment& environment, menu = new MainMenu(w,h); map = new MapWindow(*this); stats = new StatsWindow(*this); - console = new Console(w,h, environment, extensions); + console = new Console(w,h, extensions); mJournal = new JournalWindow(*this); mMessageBoxManager = new MessageBoxManager(this); - dialogueWindow = new DialogueWindow(*this,environment); + dialogueWindow = new DialogueWindow(*this); // The HUD is always on hud->setVisible(true); - mCharGen = new CharacterCreation(this, &environment); + mCharGen = new CharacterCreation(this); // Setup player stats for (int i = 0; i < ESM::Attribute::Length; ++i) @@ -143,7 +144,7 @@ void WindowManager::update() if (needModeChange) { needModeChange = false; - environment.mInputManager->setGuiMode(nextMode); + MWBase::Environment::get().getInputManager()->setGuiMode(nextMode); nextMode = GM_Game; } if (showFPSLevel > 0) @@ -154,11 +155,6 @@ void WindowManager::update() } } -MWWorld::Environment& WindowManager::getEnvironment() -{ - return environment; -} - void WindowManager::setNextMode(GuiMode newMode) { nextMode = newMode; @@ -167,7 +163,7 @@ void WindowManager::setNextMode(GuiMode newMode) void WindowManager::setGuiMode(GuiMode newMode) { - environment.mInputManager->setGuiMode(newMode); + MWBase::Environment::get().getInputManager()->setGuiMode(newMode); } void WindowManager::updateVisible() @@ -388,7 +384,7 @@ int WindowManager::readPressedButton () const std::string &WindowManager::getGameSettingString(const std::string &id, const std::string &default_) { - const ESM::GameSetting *setting = environment.mWorld->getStore().gameSettings.search(id); + const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.search(id); if (setting && setting->type == ESM::VT_String) return setting->str; return default_; @@ -412,7 +408,7 @@ void WindowManager::onFrame (float frameDuration) const ESMS::ESMStore& WindowManager::getStore() const { - return environment.mWorld->getStore(); + return MWBase::Environment::get().getWorld()->getStore(); } void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) diff --git a/apps/openmw/mwgui/window_manager.hpp b/apps/openmw/mwgui/window_manager.hpp index 2b53560ba..6e446387e 100644 --- a/apps/openmw/mwgui/window_manager.hpp +++ b/apps/openmw/mwgui/window_manager.hpp @@ -34,7 +34,6 @@ namespace Compiler namespace MWWorld { - class Environment; class World; } @@ -83,7 +82,7 @@ namespace MWGui typedef std::vector FactionList; typedef std::vector SkillList; - WindowManager(MWWorld::Environment& environment, 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(); void setGuiMode(GuiMode newMode); @@ -95,8 +94,6 @@ namespace MWGui */ void update(); - MWWorld::Environment& getEnvironment(); - void setMode(GuiMode newMode) { if (newMode==GM_Inventory && allowed==GW_None) @@ -192,7 +189,6 @@ namespace MWGui private: OEngine::GUI::MyGUIManager *mGuiManager; - MWWorld::Environment& environment; HUD *hud; MapWindow *map; MainMenu *menu; diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 7d9f748d4..849ab8ea4 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -19,10 +19,10 @@ namespace MWMechanics { if (!paused && ptr.getRefData().getHandle()!="player") MWWorld::Class::get (ptr).getInventoryStore (ptr).autoEquip ( - MWWorld::Class::get (ptr).getNpcStats (ptr), mEnvironment); + MWWorld::Class::get (ptr).getNpcStats (ptr)); } - Actors::Actors (MWWorld::Environment& environment) : mEnvironment (environment), mDuration (0) {} + Actors::Actors() : mDuration (0) {} void Actors::addActor (const MWWorld::Ptr& ptr) { diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index 7ff33b63b..ae93fb52e 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -12,16 +12,10 @@ namespace Ogre class Vector3; } -namespace MWWorld -{ - class Environment; -} - namespace MWMechanics { class Actors { - MWWorld::Environment& mEnvironment; std::set mActors; float mDuration; @@ -31,7 +25,7 @@ namespace MWMechanics public: - Actors (MWWorld::Environment& environment); + Actors(); void addActor (const MWWorld::Ptr& ptr); ///< Register an actor for stats management diff --git a/apps/openmw/mwmechanics/mechanicsmanager.cpp b/apps/openmw/mwmechanics/mechanicsmanager.cpp index f5711e78e..8bc408be6 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.cpp @@ -5,8 +5,9 @@ #include "../mwgui/window_manager.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/class.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwworld/player.hpp" @@ -14,7 +15,7 @@ namespace MWMechanics { void MechanicsManager::buildPlayer() { - MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayer().getPlayer(); + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr); @@ -33,10 +34,10 @@ namespace MWMechanics if (mRaceSelected) { const ESM::Race *race = - mEnvironment.mWorld->getStore().races.find ( - mEnvironment.mWorld->getPlayer().getRace()); + MWBase::Environment::get().getWorld()->getStore().races.find ( + MWBase::Environment::get().getWorld()->getPlayer().getRace()); - bool male = mEnvironment.mWorld->getPlayer().isMale(); + bool male = MWBase::Environment::get().getWorld()->getPlayer().isMale(); for (int i=0; i<8; ++i) { @@ -76,11 +77,11 @@ namespace MWMechanics } // birthsign - if (!mEnvironment.mWorld->getPlayer().getBirthsign().empty()) + if (!MWBase::Environment::get().getWorld()->getPlayer().getBirthsign().empty()) { const ESM::BirthSign *sign = - mEnvironment.mWorld->getStore().birthSigns.find ( - mEnvironment.mWorld->getPlayer().getBirthsign()); + MWBase::Environment::get().getWorld()->getStore().birthSigns.find ( + MWBase::Environment::get().getWorld()->getPlayer().getBirthsign()); for (std::vector::const_iterator iter (sign->powers.list.begin()); iter!=sign->powers.list.end(); ++iter) @@ -92,7 +93,7 @@ namespace MWMechanics // class if (mClassSelected) { - const ESM::Class& class_ = mEnvironment.mWorld->getPlayer().getClass(); + const ESM::Class& class_ = MWBase::Environment::get().getWorld()->getPlayer().getClass(); for (int i=0; i<2; ++i) { @@ -121,7 +122,7 @@ namespace MWMechanics } typedef ESMS::IndexListT::MapType ContainerType; - const ContainerType& skills = mEnvironment.mWorld->getStore().skills.list; + const ContainerType& skills = MWBase::Environment::get().getWorld()->getStore().skills.list; for (ContainerType::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter) { @@ -164,7 +165,7 @@ namespace MWMechanics MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (creature).getCreatureStats (creature); - MagicEffects now = creatureStats.mSpells.getMagicEffects (mEnvironment); + MagicEffects now = creatureStats.mSpells.getMagicEffects(); /// \todo add effects from active spells and equipment @@ -175,9 +176,9 @@ namespace MWMechanics // TODO apply diff to other stats } - MechanicsManager::MechanicsManager (MWWorld::Environment& environment) - : mEnvironment (environment), mUpdatePlayer (true), mClassSelected (false), - mRaceSelected (false), mActors (environment) + MechanicsManager::MechanicsManager() + : mUpdatePlayer (true), mClassSelected (false), + mRaceSelected (false) { buildPlayer(); } @@ -236,7 +237,7 @@ namespace MWMechanics { mWatchedCreature.mAttributes[i] = stats.mAttributes[i]; - mEnvironment.mWindowManager->setValue (attributeNames[i], stats.mAttributes[i]); + MWBase::Environment::get().getWindowManager()->setValue (attributeNames[i], stats.mAttributes[i]); } } @@ -246,7 +247,7 @@ namespace MWMechanics { mWatchedCreature.mDynamic[i] = stats.mDynamic[i]; - mEnvironment.mWindowManager->setValue (dynamicNames[i], stats.mDynamic[i]); + MWBase::Environment::get().getWindowManager()->setValue (dynamicNames[i], stats.mDynamic[i]); } } @@ -259,25 +260,25 @@ namespace MWMechanics { update = true; mWatchedNpc.mSkill[i] = npcStats.mSkill[i]; - mEnvironment.mWindowManager->setValue((ESM::Skill::SkillEnum)i, npcStats.mSkill[i]); + MWBase::Environment::get().getWindowManager()->setValue((ESM::Skill::SkillEnum)i, npcStats.mSkill[i]); } } if (update) - mEnvironment.mWindowManager->updateSkillArea(); + MWBase::Environment::get().getWindowManager()->updateSkillArea(); - mEnvironment.mWindowManager->setValue ("level", stats.mLevel); + MWBase::Environment::get().getWindowManager()->setValue ("level", stats.mLevel); } if (mUpdatePlayer) { // basic player profile; should not change anymore after the creation phase is finished. - mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayer().getName()); - mEnvironment.mWindowManager->setValue ("race", - mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayer(). + MWBase::Environment::get().getWindowManager()->setValue ("name", MWBase::Environment::get().getWorld()->getPlayer().getName()); + MWBase::Environment::get().getWindowManager()->setValue ("race", + MWBase::Environment::get().getWorld()->getStore().races.find (MWBase::Environment::get().getWorld()->getPlayer(). getRace())->name); - mEnvironment.mWindowManager->setValue ("class", - mEnvironment.mWorld->getPlayer().getClass().name); + MWBase::Environment::get().getWindowManager()->setValue ("class", + MWBase::Environment::get().getWorld()->getPlayer().getClass().name); mUpdatePlayer = false; MWGui::WindowManager::SkillList majorSkills (5); @@ -285,11 +286,11 @@ namespace MWMechanics for (int i=0; i<5; ++i) { - minorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][0]; - majorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][1]; + minorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().data.skills[i][0]; + majorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().data.skills[i][1]; } - mEnvironment.mWindowManager->configureSkills (majorSkills, minorSkills); + MWBase::Environment::get().getWindowManager()->configureSkills (majorSkills, minorSkills); } mActors.update (movement, duration, paused); @@ -297,14 +298,14 @@ namespace MWMechanics void MechanicsManager::setPlayerName (const std::string& name) { - mEnvironment.mWorld->getPlayer().setName (name); + MWBase::Environment::get().getWorld()->getPlayer().setName (name); mUpdatePlayer = true; } void MechanicsManager::setPlayerRace (const std::string& race, bool male) { - mEnvironment.mWorld->getPlayer().setGender (male); - mEnvironment.mWorld->getPlayer().setRace (race); + MWBase::Environment::get().getWorld()->getPlayer().setGender (male); + MWBase::Environment::get().getWorld()->getPlayer().setRace (race); mRaceSelected = true; buildPlayer(); mUpdatePlayer = true; @@ -312,14 +313,14 @@ namespace MWMechanics void MechanicsManager::setPlayerBirthsign (const std::string& id) { - mEnvironment.mWorld->getPlayer().setBirthsign (id); + MWBase::Environment::get().getWorld()->getPlayer().setBirthsign (id); buildPlayer(); mUpdatePlayer = true; } void MechanicsManager::setPlayerClass (const std::string& id) { - mEnvironment.mWorld->getPlayer().setClass (*mEnvironment.mWorld->getStore().classes.find (id)); + MWBase::Environment::get().getWorld()->getPlayer().setClass (*MWBase::Environment::get().getWorld()->getStore().classes.find (id)); mClassSelected = true; buildPlayer(); mUpdatePlayer = true; @@ -327,7 +328,7 @@ namespace MWMechanics void MechanicsManager::setPlayerClass (const ESM::Class& class_) { - mEnvironment.mWorld->getPlayer().setClass (class_); + MWBase::Environment::get().getWorld()->getPlayer().setClass (class_); mClassSelected = true; buildPlayer(); mUpdatePlayer = true; diff --git a/apps/openmw/mwmechanics/mechanicsmanager.hpp b/apps/openmw/mwmechanics/mechanicsmanager.hpp index a121507ce..a26fb98cd 100644 --- a/apps/openmw/mwmechanics/mechanicsmanager.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanager.hpp @@ -15,16 +15,10 @@ namespace Ogre class Vector3; } -namespace MWWorld -{ - class Environment; -} - namespace MWMechanics { class MechanicsManager { - MWWorld::Environment& mEnvironment; MWWorld::Ptr mWatched; CreatureStats mWatchedCreature; NpcStats mWatchedNpc; @@ -41,7 +35,7 @@ namespace MWMechanics public: - MechanicsManager (MWWorld::Environment& environment); + MechanicsManager (); void configureGUI(); diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index 916239a84..a53c75dc2 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -3,7 +3,8 @@ #include -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" #include "magiceffects.hpp" @@ -48,13 +49,13 @@ namespace MWMechanics mSelectedSpell.clear(); } - MagicEffects Spells::getMagicEffects (const MWWorld::Environment& environment) const + MagicEffects Spells::getMagicEffects() const { MagicEffects effects; for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) { - const ESM::Spell *spell = environment.mWorld->getStore().spells.find (*iter); + const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter); if (spell->data.type==ESM::Spell::ST_Ability || spell->data.type==ESM::Spell::ST_Blight || spell->data.type==ESM::Spell::ST_Disease || spell->data.type==ESM::Spell::ST_Curse) diff --git a/apps/openmw/mwmechanics/spells.hpp b/apps/openmw/mwmechanics/spells.hpp index f7606c4ac..d90f5b502 100644 --- a/apps/openmw/mwmechanics/spells.hpp +++ b/apps/openmw/mwmechanics/spells.hpp @@ -9,11 +9,6 @@ namespace ESM struct Spell; } -namespace MWWorld -{ - struct Environment; -} - namespace MWMechanics { class MagicEffects; @@ -49,7 +44,7 @@ namespace MWMechanics ///< If the spell to be removed is the selected spell, the selected spell will be changed to /// no spell (empty string). - MagicEffects getMagicEffects (const MWWorld::Environment& environment) const; + MagicEffects getMagicEffects() const; ///< Return sum of magic effects resulting from abilities, blights, deseases and curses. void clear(); diff --git a/apps/openmw/mwrender/actors.cpp b/apps/openmw/mwrender/actors.cpp index 5034e72b3..152cf3277 100644 --- a/apps/openmw/mwrender/actors.cpp +++ b/apps/openmw/mwrender/actors.cpp @@ -22,10 +22,10 @@ void Actors::setMwRoot(Ogre::SceneNode* root){ } void Actors::insertNPC(const MWWorld::Ptr& ptr, MWWorld::InventoryStore& inv){ - insertBegin(ptr, true, true); - NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mEnvironment, mRend, inv); + insertBegin(ptr, true, true); + NpcAnimation* anim = new MWRender::NpcAnimation(ptr, mRend, inv); - mAllActors[ptr] = anim; + mAllActors[ptr] = anim; } void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ Ogre::SceneNode* cellnode; @@ -68,7 +68,7 @@ void Actors::insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_){ void Actors::insertCreature (const MWWorld::Ptr& ptr){ insertBegin(ptr, true, true); - CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mEnvironment, mRend); + CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mRend); //mAllActors.insert(std::pair(ptr,anim)); delete mAllActors[ptr]; mAllActors[ptr] = anim; diff --git a/apps/openmw/mwrender/actors.hpp b/apps/openmw/mwrender/actors.hpp index 66c98c541..432bcc297 100644 --- a/apps/openmw/mwrender/actors.hpp +++ b/apps/openmw/mwrender/actors.hpp @@ -13,7 +13,6 @@ #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" -#include "../mwworld/environment.hpp" #include "npcanimation.hpp" #include "creatureanimation.hpp" #include @@ -23,13 +22,12 @@ namespace MWRender{ OEngine::Render::OgreRenderer &mRend; std::map mCellSceneNodes; Ogre::SceneNode* mMwRoot; - MWWorld::Environment& mEnvironment; std::map mAllActors; public: - Actors(OEngine::Render::OgreRenderer& _rend, MWWorld::Environment& _env): mRend(_rend), mEnvironment(_env){} + Actors(OEngine::Render::OgreRenderer& _rend): mRend(_rend) {} ~Actors(); void setMwRoot(Ogre::SceneNode* root); void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 5755418e2..fc6258208 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -4,10 +4,9 @@ namespace MWRender{ std::map Animation::mUniqueIDs; - Animation::Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend) + Animation::Animation(OEngine::Render::OgreRenderer& _rend) : insert(NULL) , mRend(_rend) - , mEnvironment(_env) , vecRotPos() , time(0.0f) , startTime(0.0f) @@ -428,7 +427,7 @@ namespace MWRender{ //base->_updateAnimation(); //base->_notifyMoved(); - + std::vector::iterator iter; diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 98f0e7487..4ab60cff4 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -5,7 +5,6 @@ #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" -#include "../mwworld/environment.hpp" #include #include #include @@ -21,16 +20,15 @@ struct PosAndRot{ }; class Animation{ - + protected: Ogre::SceneNode* insert; OEngine::Render::OgreRenderer &mRend; - MWWorld::Environment& mEnvironment; std::map vecRotPos; static std::map mUniqueIDs; - - - + + + float time; @@ -41,14 +39,14 @@ class Animation{ std::vectorrindexI; //Represents a translation index for each bone std::vectortindexI; - + //Only shapes with morphing data will use a shape number int shapeNumber; std::vector > shapeIndexI; //Ogre::SkeletonInstance* skel; std::vector* shapes; //All the NiTriShapeData for a creature - + std::vector* transformations; @@ -58,16 +56,16 @@ class Animation{ void handleAnimationTransforms(); bool timeIndex( float time, const std::vector & times, int & i, int & j, float & x ); std::string getUniqueID(std::string mesh); - + public: - Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend); + Animation(OEngine::Render::OgreRenderer& _rend); virtual void runAnimation(float timepassed) = 0; void startScript(std::string groupname, int mode, int loops); void stopScript(); virtual ~Animation(); - + }; } #endif diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index e0eb5ccc2..9ca3ed731 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -10,7 +10,7 @@ namespace MWRender{ CreatureAnimation::~CreatureAnimation(){ } -CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend): Animation(_env,_rend){ +CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend): Animation(_rend){ insert = ptr.getRefData().getBaseNode(); ESMS::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwrender/creatureanimation.hpp b/apps/openmw/mwrender/creatureanimation.hpp index 2229eeec9..f50b7904b 100644 --- a/apps/openmw/mwrender/creatureanimation.hpp +++ b/apps/openmw/mwrender/creatureanimation.hpp @@ -7,20 +7,19 @@ #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" -#include "../mwworld/environment.hpp" #include "components/nifogre/ogre_nif_loader.hpp" namespace MWRender{ class CreatureAnimation: public Animation{ - + public: virtual ~CreatureAnimation(); - CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend); + CreatureAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend); virtual void runAnimation(float timepassed); - + }; } -#endif \ No newline at end of file +#endif diff --git a/apps/openmw/mwrender/debugging.cpp b/apps/openmw/mwrender/debugging.cpp index d42672179..be8afbae6 100644 --- a/apps/openmw/mwrender/debugging.cpp +++ b/apps/openmw/mwrender/debugging.cpp @@ -8,7 +8,7 @@ #include #include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwworld/ptr.hpp" #include #include @@ -138,8 +138,8 @@ ManualObject *Debugging::createPathgridPoints(const ESM::Pathgrid *pathgrid) return result; } -Debugging::Debugging(SceneNode *mwRoot, MWWorld::Environment &env, OEngine::Physic::PhysicEngine *engine) : - mMwRoot(mwRoot), mEnvironment(env), mEngine(engine), +Debugging::Debugging(SceneNode *mwRoot, OEngine::Physic::PhysicEngine *engine) : + mMwRoot(mwRoot), mEngine(engine), mSceneMgr(mwRoot->getCreator()), mPathgridEnabled(false), mInteriorPathgridNode(NULL), mPathGridRoot(NULL), @@ -218,7 +218,7 @@ void Debugging::togglePathgrid() void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store) { - ESM::Pathgrid *pathgrid = mEnvironment.mWorld->getStore().pathgrids.search(*store->cell); + ESM::Pathgrid *pathgrid = MWBase::Environment::get().getWorld()->getStore().pathgrids.search(*store->cell); if (!pathgrid) return; Vector3 cellPathGridPos(0, 0, 0); diff --git a/apps/openmw/mwrender/debugging.hpp b/apps/openmw/mwrender/debugging.hpp index ebf3884dc..e12c0647c 100644 --- a/apps/openmw/mwrender/debugging.hpp +++ b/apps/openmw/mwrender/debugging.hpp @@ -23,7 +23,6 @@ namespace Ogre namespace MWWorld { class World; - class Environment; } namespace MWRender @@ -34,7 +33,6 @@ namespace MWRender { OEngine::Physic::PhysicEngine* mEngine; Ogre::SceneManager *mSceneMgr; - MWWorld::Environment& mEnvironment; // Path grid stuff bool mPathgridEnabled; @@ -68,7 +66,7 @@ namespace MWRender Ogre::ManualObject *createPathgridLines(const ESM::Pathgrid *pathgrid); Ogre::ManualObject *createPathgridPoints(const ESM::Pathgrid *pathgrid); public: - Debugging(Ogre::SceneNode* mwRoot, MWWorld::Environment &env, OEngine::Physic::PhysicEngine *engine); + Debugging(Ogre::SceneNode* mwRoot, OEngine::Physic::PhysicEngine *engine); ~Debugging(); bool toggleRenderMode (int mode); diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 2cc233a01..ea8902443 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -1,7 +1,7 @@ #include "localmap.hpp" #include "renderingmanager.hpp" -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwworld/world.hpp" #include "../mwgui/window_manager.hpp" #include "renderconst.hpp" @@ -12,12 +12,11 @@ using namespace MWRender; using namespace Ogre; -LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManager* rendering, MWWorld::Environment* env) : +LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManager* rendering) : mInterior(false), mCellX(0), mCellY(0) { mRendering = rend; mRenderingManager = rendering; - mEnvironment = env; mCameraPosNode = mRendering->getScene()->getRootSceneNode()->createChildSceneNode(); mCameraRotNode = mCameraPosNode->createChildSceneNode(); @@ -54,12 +53,12 @@ void LocalMap::saveTexture(const std::string& texname, const std::string& filena if (tex.isNull()) return; HardwarePixelBufferSharedPtr readbuffer = tex->getBuffer(); readbuffer->lock(HardwareBuffer::HBL_NORMAL ); - const PixelBox &readrefpb = readbuffer->getCurrentLock(); - uchar *readrefdata = static_cast(readrefpb.data); + const PixelBox &readrefpb = readbuffer->getCurrentLock(); + uchar *readrefdata = static_cast(readrefpb.data); Image img; img = img.loadDynamicImage (readrefdata, tex->getWidth(), - tex->getHeight(), tex->getFormat()); + tex->getHeight(), tex->getFormat()); img.save("./" + filename); readbuffer->unlock(); @@ -82,7 +81,7 @@ void LocalMap::saveFogOfWar(MWWorld::Ptr::CellStore* cell) Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z); Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().z); Vector2 length = max-min; - + // divide into segments const int segsX = std::ceil( length.x / sSize ); const int segsY = std::ceil( length.y / sSize ); @@ -123,7 +122,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell, Vector2 z(mBounds.getMaximum().y, mBounds.getMinimum().y); - const Vector2& north = mEnvironment->mWorld->getNorthVector(cell); + const Vector2& north = MWBase::Environment::get().getWorld()->getNorthVector(cell); Radian angle(std::atan2(-north.x, -north.y)); mAngle = angle.valueRadians(); mCameraRotNode->setOrientation(Quaternion(Math::Cos(angle/2.f), 0, Math::Sin(angle/2.f), 0)); @@ -213,7 +212,7 @@ void LocalMap::render(const float x, const float y, texture, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, - xw*sMapResolution/sSize, yw*sMapResolution/sSize, + xw*sMapResolution/sSize, yw*sMapResolution/sSize, 0, PF_R8G8B8, TU_RENDERTARGET); @@ -236,7 +235,7 @@ void LocalMap::render(const float x, const float y, texture + "_fog", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, - xw*sFogOfWarResolution/sSize, yw*sFogOfWarResolution/sSize, + xw*sFogOfWarResolution/sSize, yw*sFogOfWarResolution/sSize, 0, PF_A8R8G8B8, TU_DYNAMIC_WRITE_ONLY_DISCARDABLE); @@ -276,7 +275,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni return; } - // retrieve the x,y grid coordinates the player is in + // retrieve the x,y grid coordinates the player is in int x,y; Vector3 _pos(position.x, 0, position.z); Vector2 pos(_pos.x, _pos.z); @@ -303,7 +302,7 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni x = std::ceil((pos.x - min.x)/sSize)-1; y = std::ceil((pos.y - min.y)/sSize)-1; - mEnvironment->mWindowManager->setInteriorMapTexture(x,y); + MWBase::Environment::get().getWindowManager()->setInteriorMapTexture(x,y); } // convert from world coordinates to texture UV coordinates @@ -323,8 +322,8 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni texName = mInteriorName + "_" + coordStr(x,y); } - mEnvironment->mWindowManager->setPlayerPos(u, v); - mEnvironment->mWindowManager->setPlayerDir(playerdirection.x, -playerdirection.z); + MWBase::Environment::get().getWindowManager()->setPlayerPos(u, v); + MWBase::Environment::get().getWindowManager()->setPlayerDir(playerdirection.x, -playerdirection.z); // explore radius (squared) const float sqrExploreRadius = 0.01 * sFogOfWarResolution*sFogOfWarResolution; diff --git a/apps/openmw/mwrender/localmap.hpp b/apps/openmw/mwrender/localmap.hpp index 95685167c..9e03988f3 100644 --- a/apps/openmw/mwrender/localmap.hpp +++ b/apps/openmw/mwrender/localmap.hpp @@ -5,11 +5,6 @@ #include -namespace MWWorld -{ - class Environment; -} - namespace MWRender { class RenderingManager; @@ -20,7 +15,7 @@ namespace MWRender class LocalMap { public: - LocalMap(OEngine::Render::OgreRenderer*, MWRender::RenderingManager* rendering, MWWorld::Environment* env); + LocalMap(OEngine::Render::OgreRenderer*, MWRender::RenderingManager* rendering); ~LocalMap(); /** @@ -61,7 +56,6 @@ namespace MWRender private: OEngine::Render::OgreRenderer* mRendering; MWRender::RenderingManager* mRenderingManager; - MWWorld::Environment* mEnvironment; // 1024*1024 pixels for a cell static const int sMapResolution = 1024; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 751a07548..94a746989 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -2,7 +2,7 @@ #include "../mwworld/world.hpp" #include "renderconst.hpp" - +#include "../mwbase/environment.hpp" using namespace Ogre; using namespace NifOgre; @@ -12,7 +12,7 @@ NpcAnimation::~NpcAnimation(){ } -NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), +NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_rend), mStateID(-1), inv(_inv), timeToChange(0), robe(inv.end()), helmet(inv.end()), shirt(inv.end()), cuirass(inv.end()), greaves(inv.end()), leftpauldron(inv.end()), rightpauldron(inv.end()), @@ -77,14 +77,14 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,O std::string hairID = ref->base->hair; std::string headID = ref->base->head; headModel = "meshes\\" + - mEnvironment.mWorld->getStore().bodyParts.find(headID)->model; + MWBase::Environment::get().getWorld()->getStore().bodyParts.find(headID)->model; hairModel = "meshes\\" + - mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; + MWBase::Environment::get().getWorld()->getStore().bodyParts.find(hairID)->model; npcName = ref->base->name; //ESMStore::Races r = - const ESM::Race* race = mEnvironment.mWorld->getStore().races.find(ref->base->race); + const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().races.find(ref->base->race); bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4); @@ -370,116 +370,116 @@ void NpcAnimation::updateParts(){ addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1,hairModel); } if(partpriorities[ESM::PRT_Neck] < 1){ - const ESM::BodyPart *neckPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "neck"); + const ESM::BodyPart *neckPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "neck"); if(neckPart) addOrReplaceIndividualPart(ESM::PRT_Neck, -1,1,"meshes\\" + neckPart->model); } if(partpriorities[ESM::PRT_Cuirass] < 1){ - const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); + const ESM::BodyPart *chestPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "chest"); if(chestPart) addOrReplaceIndividualPart(ESM::PRT_Cuirass, -1,1,"meshes\\" + chestPart->model); } if(partpriorities[ESM::PRT_Groin] < 1){ - const ESM::BodyPart *groinPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "groin"); + const ESM::BodyPart *groinPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "groin"); if(groinPart) addOrReplaceIndividualPart(ESM::PRT_Groin, -1,1,"meshes\\" + groinPart->model); } if(partpriorities[ESM::PRT_RHand] < 1){ - const ESM::BodyPart *handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand"); + const ESM::BodyPart *handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hand"); if(!handPart) - handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands"); + handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hands"); if(handPart) addOrReplaceIndividualPart(ESM::PRT_RHand, -1,1,"meshes\\" + handPart->model); } if(partpriorities[ESM::PRT_LHand] < 1){ - const ESM::BodyPart *handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hand"); + const ESM::BodyPart *handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hand"); if(!handPart) - handPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "hands"); + handPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "hands"); if(handPart) addOrReplaceIndividualPart(ESM::PRT_LHand, -1,1,"meshes\\" + handPart->model); } if(partpriorities[ESM::PRT_RWrist] < 1){ - const ESM::BodyPart *wristPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); + const ESM::BodyPart *wristPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "wrist"); if(wristPart) addOrReplaceIndividualPart(ESM::PRT_RWrist, -1,1,"meshes\\" + wristPart->model); } if(partpriorities[ESM::PRT_LWrist] < 1){ - const ESM::BodyPart *wristPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "wrist"); + const ESM::BodyPart *wristPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "wrist"); if(wristPart) addOrReplaceIndividualPart(ESM::PRT_LWrist, -1,1,"meshes\\" + wristPart->model); } if(partpriorities[ESM::PRT_RForearm] < 1){ - const ESM::BodyPart *forearmPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); + const ESM::BodyPart *forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "forearm"); if(bodyRaceID == "b_n_argonian_f_") - forearmPart = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); + forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search ("b_n_argonian_m_forearm"); if(forearmPart) addOrReplaceIndividualPart(ESM::PRT_RForearm, -1,1,"meshes\\" + forearmPart->model); } if(partpriorities[ESM::PRT_LForearm] < 1){ - const ESM::BodyPart *forearmPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "forearm"); + const ESM::BodyPart *forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "forearm"); if(bodyRaceID == "b_n_argonian_f_") - forearmPart = mEnvironment.mWorld->getStore().bodyParts.search ("b_n_argonian_m_forearm"); + forearmPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search ("b_n_argonian_m_forearm"); if(forearmPart) addOrReplaceIndividualPart(ESM::PRT_LForearm, -1,1,"meshes\\" + forearmPart->model); } if(partpriorities[ESM::PRT_RUpperarm] < 1){ - const ESM::BodyPart *armPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); + const ESM::BodyPart *armPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper arm"); if(armPart) addOrReplaceIndividualPart(ESM::PRT_RUpperarm, -1,1,"meshes\\" + armPart->model); } if(partpriorities[ESM::PRT_LUpperarm] < 1){ - const ESM::BodyPart *armPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper arm"); + const ESM::BodyPart *armPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper arm"); if(armPart) addOrReplaceIndividualPart(ESM::PRT_LUpperarm, -1,1,"meshes\\" + armPart->model); } if(partpriorities[ESM::PRT_RFoot] < 1){ - const ESM::BodyPart *footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); + const ESM::BodyPart *footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "foot"); if(isBeast && !footPart) - footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); + footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "feet"); if(footPart) addOrReplaceIndividualPart(ESM::PRT_RFoot, -1,1,"meshes\\" + footPart->model); } if(partpriorities[ESM::PRT_LFoot] < 1){ - const ESM::BodyPart *footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "foot"); + const ESM::BodyPart *footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "foot"); if(isBeast && !footPart) - footPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "feet"); + footPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "feet"); if(footPart) addOrReplaceIndividualPart(ESM::PRT_LFoot, -1,1,"meshes\\" + footPart->model); } if(partpriorities[ESM::PRT_RAnkle] < 1){ - const ESM::BodyPart *anklePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); + const ESM::BodyPart *anklePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "ankle"); if(anklePart) addOrReplaceIndividualPart(ESM::PRT_RAnkle, -1,1,"meshes\\" + anklePart->model); } if(partpriorities[ESM::PRT_LAnkle] < 1){ - const ESM::BodyPart *anklePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "ankle"); + const ESM::BodyPart *anklePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "ankle"); if(anklePart) addOrReplaceIndividualPart(ESM::PRT_LAnkle, -1,1,"meshes\\" + anklePart->model); } if(partpriorities[ESM::PRT_RKnee] < 1){ - const ESM::BodyPart *kneePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); + const ESM::BodyPart *kneePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "knee"); if(kneePart) addOrReplaceIndividualPart(ESM::PRT_RKnee, -1,1,"meshes\\" + kneePart->model); } if(partpriorities[ESM::PRT_LKnee] < 1){ - const ESM::BodyPart *kneePart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "knee"); + const ESM::BodyPart *kneePart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "knee"); if(kneePart) addOrReplaceIndividualPart(ESM::PRT_LKnee, -1,1,"meshes\\" + kneePart->model); } if(partpriorities[ESM::PRT_RLeg] < 1){ - const ESM::BodyPart *legPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); + const ESM::BodyPart *legPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper leg"); if(legPart) addOrReplaceIndividualPart(ESM::PRT_RLeg, -1,1,"meshes\\" + legPart->model); } if(partpriorities[ESM::PRT_LLeg] < 1){ - const ESM::BodyPart *legPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "upper leg"); + const ESM::BodyPart *legPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "upper leg"); if(legPart) addOrReplaceIndividualPart(ESM::PRT_LLeg, -1,1,"meshes\\" + legPart->model); } if(partpriorities[ESM::PRT_Tail] < 1){ - const ESM::BodyPart *tailPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "tail"); + const ESM::BodyPart *tailPart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (bodyRaceID + "tail"); if(tailPart) addOrReplaceIndividualPart(ESM::PRT_Tail, -1,1,"meshes\\" + tailPart->model); } @@ -848,9 +848,9 @@ void NpcAnimation::removeIndividualPart(int type){ const ESM::BodyPart *bodypart = 0; if(isFemale) - bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.female); + bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (part.female); if(!bodypart) - bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); + bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search (part.male); if(bodypart){ addOrReplaceIndividualPart(part.part, group,priority,"meshes\\" + bodypart->model); } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 352b54bec..a37becc26 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -10,7 +10,6 @@ #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" -#include "../mwworld/environment.hpp" #include "components/nifogre/ogre_nif_loader.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwclass/npc.hpp" @@ -36,8 +35,8 @@ private: int partpriorities[27]; std::pair*> zero; - - + + //Bounded Parts Ogre::Entity* lclavicle; Ogre::Entity* rclavicle; @@ -59,7 +58,7 @@ private: Ogre::Entity* rfoot; Ogre::Entity* hair; Ogre::Entity* head; - + Ogre::SceneNode* insert; bool isBeast; bool isFemale; @@ -80,9 +79,9 @@ private: MWWorld::ContainerStoreIterator leftglove; MWWorld::ContainerStoreIterator rightglove; MWWorld::ContainerStoreIterator skirtiter; - + public: - NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); + NpcAnimation(const MWWorld::Ptr& ptr, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); virtual ~NpcAnimation(); Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename); std::pair*> insertFreePart(const std::string &mesh, const std::string suffix); @@ -91,12 +90,12 @@ private: void updateParts(); void removeIndividualPart(int type); void reserveIndividualPart(int type, int group, int priority); - + bool addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh); void removePartGroup(int group); void addPartGroup(int group, int priority, std::vector& parts); - + }; } -#endif \ No newline at end of file +#endif diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index c1462807f..266fbfb62 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -24,8 +24,8 @@ using namespace Ogre; namespace MWRender { -RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine, MWWorld::Environment& environment) - :mRendering(_rend), mObjects(mRendering), mActors(mRendering, environment), mAmbientMode(0), mSunEnabled(0) +RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine) + :mRendering(_rend), mObjects(mRendering), mActors(mRendering), mAmbientMode(0), mSunEnabled(0) { mRendering.createScene("PlayerCam", Settings::Manager::getFloat("field of view", "General"), 5); @@ -93,19 +93,18 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const mShadows = new Shadows(&mRendering); mShaderHelper = new ShaderHelper(this); - mTerrainManager = new TerrainManager(mRendering.getScene(), this, - environment); + mTerrainManager = new TerrainManager(mRendering.getScene(), this); //mSkyManager = 0; - mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera(), &environment); + mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera()); mOcclusionQuery = new OcclusionQuery(&mRendering, mSkyManager->getSunNode()); mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode); mSun = 0; - mDebugging = new Debugging(mMwRoot, environment, engine); - mLocalMap = new MWRender::LocalMap(&mRendering, this, &environment); + mDebugging = new Debugging(mMwRoot, engine); + mLocalMap = new MWRender::LocalMap(&mRendering, this); } RenderingManager::~RenderingManager () diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index a563d78c6..c4134eede 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -57,7 +57,7 @@ class RenderingManager: private RenderingInterface { virtual MWRender::Actors& getActors(); public: - RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine, MWWorld::Environment& environment); + RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine); virtual ~RenderingManager(); diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 859da2dc1..da2e7446a 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -10,7 +10,7 @@ #include -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwworld/world.hpp" #include "renderconst.hpp" #include "renderingmanager.hpp" @@ -271,10 +271,10 @@ void Moon::setPhase(const Moon::Phase& phase) { // Colour texture Ogre::String textureName = "textures\\tx_"; - + if (mType == Moon::Type_Secunda) textureName += "secunda_"; else textureName += "masser_"; - + if (phase == Moon::Phase_New) textureName += "new"; else if (phase == Moon::Phase_WaxingCrescent) textureName += "one_wax"; else if (phase == Moon::Phase_WaxingHalf) textureName += "half_wax"; @@ -283,9 +283,9 @@ void Moon::setPhase(const Moon::Phase& phase) else if (phase == Moon::Phase_WaningHalf) textureName += "half_wan"; else if (phase == Moon::Phase_WaningGibbous) textureName += "three_wan"; else if (phase == Moon::Phase_Full) textureName += "full"; - + textureName += ".dds"; - + mMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(textureName); mPhase = phase; @@ -365,9 +365,8 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType) ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock(); } -SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environment* env) - : mEnvironment(env) - , mHour(0.0f) +SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) + : mHour(0.0f) , mDay(0) , mMonth(0) , mSun(NULL) @@ -713,7 +712,7 @@ void SkyManager::update(float duration) if (!mEnabled) return; // UV Scroll the clouds - mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", mEnvironment->mWorld->getTimeScaleFactor()/30.f); + mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", MWBase::Environment::get().getWorld()->getTimeScaleFactor()/30.f); /// \todo improve this mMasser->setPhase( static_cast( (int) ((mDay % 32)/4.f)) ); @@ -752,7 +751,7 @@ void SkyManager::update(float duration) mSecunda->setVisible(mSecundaEnabled); // rotate the stars by 360 degrees every 4 days - mAtmosphereNight->roll(Degree(mEnvironment->mWorld->getTimeScaleFactor()*duration*360 / (3600*96.f))); + mAtmosphereNight->roll(Degree(MWBase::Environment::get().getWorld()->getTimeScaleFactor()*duration*360 / (3600*96.f))); } void SkyManager::enable() diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index 64d5c16a0..da89d0eb0 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -59,8 +59,8 @@ namespace MWRender Ogre::MaterialPtr mMaterial; Ogre::BillboardSet* mBBSet; }; - - + + /* * The moons need a seperate class because of their shader (which allows them to be partially transparent) */ @@ -104,11 +104,11 @@ namespace MWRender Type mType; Phase mPhase; }; - + class SkyManager { public: - SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera, MWWorld::Environment* env); + SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera); ~SkyManager(); void update(float duration); @@ -176,7 +176,6 @@ namespace MWRender private: bool mCreated; - MWWorld::Environment* mEnvironment; float mHour; int mDay; int mMonth; diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index f9b43655b..90d853f75 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -4,6 +4,8 @@ #include "../mwworld/world.hpp" +#include "../mwbase/environment.hpp" + #include "terrainmaterial.hpp" #include "terrain.hpp" #include "renderconst.hpp" @@ -17,8 +19,8 @@ namespace MWRender //---------------------------------------------------------------------------------------------- - TerrainManager::TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend, const MWWorld::Environment& evn) : - mEnvironment(evn), mTerrainGroup(TerrainGroup(mgr, Terrain::ALIGN_X_Z, mLandSize, mWorldSize)), mRendering(rend) + TerrainManager::TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend) : + mTerrainGroup(TerrainGroup(mgr, Terrain::ALIGN_X_Z, mLandSize, mWorldSize)), mRendering(rend) { TerrainMaterialGeneratorPtr matGen; @@ -107,7 +109,7 @@ namespace MWRender const int cellX = store->cell->getGridX(); const int cellY = store->cell->getGridY(); - ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); + ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY); if ( land != NULL ) { if (!land->dataLoaded) @@ -268,7 +270,7 @@ namespace MWRender { //NB: All vtex ids are +1 compared to the ltex ids - assert( (int)mEnvironment.mWorld->getStore().landTexts.getSize() >= (int)ltexIndex - 1 && + assert( (int)MWBase::Environment::get().getWorld()->getStore().landTexts.getSize() >= (int)ltexIndex - 1 && "LAND.VTEX must be within the bounds of the LTEX array"); std::string texture; @@ -278,7 +280,7 @@ namespace MWRender } else { - texture = mEnvironment.mWorld->getStore().landTexts.search(ltexIndex-1)->texture; + texture = MWBase::Environment::get().getWorld()->getStore().landTexts.search(ltexIndex-1)->texture; //TODO this is needed due to MWs messed up texture handling texture = texture.substr(0, texture.rfind(".")) + ".dds"; } @@ -434,7 +436,7 @@ namespace MWRender } - ESM::Land* land = mEnvironment.mWorld->getStore().lands.search(cellX, cellY); + ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY); if ( land != NULL ) { if (!land->dataLoaded) diff --git a/apps/openmw/mwrender/terrain.hpp b/apps/openmw/mwrender/terrain.hpp index dc4a2388c..c4ff053a6 100644 --- a/apps/openmw/mwrender/terrain.hpp +++ b/apps/openmw/mwrender/terrain.hpp @@ -24,7 +24,7 @@ namespace MWRender{ */ class TerrainManager{ public: - TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend, const MWWorld::Environment& env); + TerrainManager(Ogre::SceneManager* mgr, RenderingManager* rend); virtual ~TerrainManager(); void setDiffuse(const Ogre::ColourValue& diffuse); @@ -36,7 +36,6 @@ namespace MWRender{ Ogre::TerrainGlobalOptions mTerrainGlobals; Ogre::TerrainGroup mTerrainGroup; - const MWWorld::Environment& mEnvironment; RenderingManager* mRendering; Ogre::TerrainMaterialGeneratorB::SM2Profile* mActiveProfile; diff --git a/apps/openmw/mwscript/animationextensions.cpp b/apps/openmw/mwscript/animationextensions.cpp index 184be83db..864a2bf1d 100644 --- a/apps/openmw/mwscript/animationextensions.cpp +++ b/apps/openmw/mwscript/animationextensions.cpp @@ -27,10 +27,7 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getWorld().skipAnimation (ptr); + MWBase::Environment::get().getWorld()->skipAnimation (ptr); } }; @@ -43,9 +40,6 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - InterpreterContext& context = - static_cast (runtime.getContext()); - std::string group = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -60,7 +54,7 @@ namespace MWScript throw std::runtime_error ("animation mode out of range"); } - context.getWorld().playAnimationGroup (ptr, group, mode, 1); + MWBase::Environment::get().getWorld()->playAnimationGroup (ptr, group, mode, 1); } }; @@ -73,9 +67,6 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - InterpreterContext& context = - static_cast (runtime.getContext()); - std::string group = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -96,7 +87,7 @@ namespace MWScript throw std::runtime_error ("animation mode out of range"); } - context.getWorld().playAnimationGroup (ptr, group, mode, loops); + MWBase::Environment::get().getWorld()->playAnimationGroup (ptr, group, mode, loops); } }; diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index d69c42ab3..a5db5fd5f 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" #include "../mwworld/player.hpp" @@ -22,10 +24,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - - runtime.push (context.getWorld().hasCellChanged() ? 1 : 0); + runtime.push (MWBase::Environment::get().getWorld()->hasCellChanged() ? 1 : 0); } }; @@ -35,9 +34,6 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - std::string cell = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -45,16 +41,16 @@ namespace MWScript pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; pos.pos[2] = 0; - if (const ESM::Cell *exterior = context.getWorld().getExterior (cell)) + if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (cell)) { - context.getWorld().indexToPosition (exterior->data.gridX, exterior->data.gridY, + MWBase::Environment::get().getWorld()->indexToPosition (exterior->data.gridX, exterior->data.gridY, pos.pos[0], pos.pos[1], true); - context.getWorld().changeToExteriorCell (pos); + MWBase::Environment::get().getWorld()->changeToExteriorCell (pos); } else { pos.pos[0] = pos.pos[1] = 0; - context.getWorld().changeToInteriorCell (cell, pos); + MWBase::Environment::get().getWorld()->changeToInteriorCell (cell, pos); } } }; @@ -65,9 +61,6 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - Interpreter::Type_Integer x = runtime[0].mInteger; runtime.pop(); @@ -76,12 +69,12 @@ namespace MWScript ESM::Position pos; - context.getWorld().indexToPosition (x, y, pos.pos[0], pos.pos[1], true); + MWBase::Environment::get().getWorld()->indexToPosition (x, y, pos.pos[0], pos.pos[1], true); pos.pos[2] = 0; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; - context.getWorld().changeToExteriorCell (pos); + MWBase::Environment::get().getWorld()->changeToExteriorCell (pos); } }; @@ -91,11 +84,8 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - bool interior = - context.getWorld().getPlayer().getPlayer().getCell()->cell->data.flags & + MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->data.flags & ESM::Cell::Interior; runtime.push (interior ? 1 : 0); @@ -108,20 +98,17 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - std::string name = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - const ESM::Cell *cell = context.getWorld().getPlayer().getPlayer().getCell()->cell; + const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell; std::string current = cell->name; if (!(cell->data.flags & ESM::Cell::Interior) && current.empty()) { const ESM::Region *region = - context.getWorld().getStore().regions.find (cell->region); + MWBase::Environment::get().getWorld()->getStore().regions.find (cell->region); current = region->name; } @@ -139,10 +126,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - - MWWorld::Ptr::CellStore *cell = context.getWorld().getPlayer().getPlayer().getCell(); + MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); runtime.push (cell->mWaterLevel); } }; @@ -153,18 +137,15 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - Interpreter::Type_Float level = runtime[0].mFloat; - MWWorld::Ptr::CellStore *cell = context.getWorld().getPlayer().getPlayer().getCell(); + MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); if (!(cell->cell->data.flags & ESM::Cell::Interior)) throw std::runtime_error("Can't set water level in exterior cell"); cell->mWaterLevel = level; - context.getEnvironment().mWorld->setWaterHeight(cell->mWaterLevel); + MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel); } }; @@ -174,18 +155,15 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context - = static_cast (runtime.getContext()); - Interpreter::Type_Float level = runtime[0].mFloat; - MWWorld::Ptr::CellStore *cell = context.getWorld().getPlayer().getPlayer().getCell(); + MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); if (!(cell->cell->data.flags & ESM::Cell::Interior)) throw std::runtime_error("Can't set water level in exterior cell"); - + cell->mWaterLevel +=level; - context.getEnvironment().mWorld->setWaterHeight(cell->mWaterLevel); + MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel); } }; diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index 15cc599a7..078d0da5e 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -1,48 +1,48 @@ #include "compilercontext.hpp" -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" namespace MWScript { - CompilerContext::CompilerContext (Type type, const MWWorld::Environment& environment) - : mType (type), mEnvironment (environment) + CompilerContext::CompilerContext (Type type) + : mType (type) {} bool CompilerContext::canDeclareLocals() const { return mType==Type_Full; - } - + } + char CompilerContext::getGlobalType (const std::string& name) const { - return mEnvironment.mWorld->getGlobalVariableType (name); - } - + return MWBase::Environment::get().getWorld()->getGlobalVariableType (name); + } + bool CompilerContext::isId (const std::string& name) const { return - mEnvironment.mWorld->getStore().activators.search (name) || - mEnvironment.mWorld->getStore().potions.search (name) || - mEnvironment.mWorld->getStore().appas.search (name) || - mEnvironment.mWorld->getStore().armors.search (name) || - mEnvironment.mWorld->getStore().books.search (name) || - mEnvironment.mWorld->getStore().clothes.search (name) || - mEnvironment.mWorld->getStore().containers.search (name) || - mEnvironment.mWorld->getStore().creatures.search (name) || - mEnvironment.mWorld->getStore().doors.search (name) || - mEnvironment.mWorld->getStore().ingreds.search (name) || - mEnvironment.mWorld->getStore().creatureLists.search (name) || - mEnvironment.mWorld->getStore().itemLists.search (name) || - mEnvironment.mWorld->getStore().lights.search (name) || - mEnvironment.mWorld->getStore().lockpicks.search (name) || - mEnvironment.mWorld->getStore().miscItems.search (name) || - mEnvironment.mWorld->getStore().npcs.search (name) || - mEnvironment.mWorld->getStore().probes.search (name) || - mEnvironment.mWorld->getStore().repairs.search (name) || - mEnvironment.mWorld->getStore().statics.search (name) || - mEnvironment.mWorld->getStore().weapons.search (name); + MWBase::Environment::get().getWorld()->getStore().activators.search (name) || + MWBase::Environment::get().getWorld()->getStore().potions.search (name) || + MWBase::Environment::get().getWorld()->getStore().appas.search (name) || + MWBase::Environment::get().getWorld()->getStore().armors.search (name) || + MWBase::Environment::get().getWorld()->getStore().books.search (name) || + MWBase::Environment::get().getWorld()->getStore().clothes.search (name) || + MWBase::Environment::get().getWorld()->getStore().containers.search (name) || + MWBase::Environment::get().getWorld()->getStore().creatures.search (name) || + MWBase::Environment::get().getWorld()->getStore().doors.search (name) || + MWBase::Environment::get().getWorld()->getStore().ingreds.search (name) || + MWBase::Environment::get().getWorld()->getStore().creatureLists.search (name) || + MWBase::Environment::get().getWorld()->getStore().itemLists.search (name) || + MWBase::Environment::get().getWorld()->getStore().lights.search (name) || + MWBase::Environment::get().getWorld()->getStore().lockpicks.search (name) || + MWBase::Environment::get().getWorld()->getStore().miscItems.search (name) || + MWBase::Environment::get().getWorld()->getStore().npcs.search (name) || + MWBase::Environment::get().getWorld()->getStore().probes.search (name) || + MWBase::Environment::get().getWorld()->getStore().repairs.search (name) || + MWBase::Environment::get().getWorld()->getStore().statics.search (name) || + MWBase::Environment::get().getWorld()->getStore().weapons.search (name); } } - diff --git a/apps/openmw/mwscript/compilercontext.hpp b/apps/openmw/mwscript/compilercontext.hpp index 7a3411bba..32b2f1881 100644 --- a/apps/openmw/mwscript/compilercontext.hpp +++ b/apps/openmw/mwscript/compilercontext.hpp @@ -3,44 +3,36 @@ #include -namespace MWWorld -{ - class Environment; -} - namespace MWScript { class CompilerContext : public Compiler::Context { public: - + enum Type { Type_Full, // global, local, targetted Type_Dialgoue, Type_Console }; - + private: - + Type mType; - const MWWorld::Environment& mEnvironment; - + public: - - CompilerContext (Type type, const MWWorld::Environment& environment); - + + CompilerContext (Type type); + /// Is the compiler allowed to declare local variables? - virtual bool canDeclareLocals() const; - - /// 'l: long, 's': short, 'f': float, ' ': does not exist. + virtual bool canDeclareLocals() const; + + /// 'l: long, 's': short, 'f': float, ' ': does not exist. virtual char getGlobalType (const std::string& name) const; virtual bool isId (const std::string& name) const; - ///< Does \a name match an ID, that can be referenced? + ///< Does \a name match an ID, that can be referenced? }; } #endif - - diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index a0aba5db9..3e8658bf8 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -9,6 +9,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/manualref.hpp" #include "../mwworld/class.hpp" #include "../mwworld/containerstore.hpp" @@ -29,9 +31,6 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string item = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -41,7 +40,7 @@ namespace MWScript if (count<0) throw std::runtime_error ("second argument for AddItem must be non-negative"); - MWWorld::ManualRef ref (context.getWorld().getStore(), item); + MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), item); ref.getPtr().getRefData().setCount (count); diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index 384e13e45..363a09b6b 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/player.hpp" #include "interpretercontext.hpp" @@ -46,7 +48,7 @@ namespace MWScript InterpreterContext& context = static_cast (runtime.getContext()); - bool enabled = context.getWorld().toggleCollisionMode(); + bool enabled = MWBase::Environment::get().getWorld()->toggleCollisionMode(); context.report (enabled ? "Collision -> On" : "Collision -> Off"); } diff --git a/apps/openmw/mwscript/dialogueextensions.cpp b/apps/openmw/mwscript/dialogueextensions.cpp index fec539d3e..b99d55999 100644 --- a/apps/openmw/mwscript/dialogueextensions.cpp +++ b/apps/openmw/mwscript/dialogueextensions.cpp @@ -23,16 +23,13 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string quest = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); Interpreter::Type_Integer index = runtime[0].mInteger; runtime.pop(); - context.getEnvironment().mJournal->addEntry (quest, index); + MWBase::Environment::get().getJournal()->addEntry (quest, index); } }; @@ -42,16 +39,13 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string quest = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); Interpreter::Type_Integer index = runtime[0].mInteger; runtime.pop(); - context.getEnvironment().mJournal->setJournalIndex (quest, index); + MWBase::Environment::get().getJournal()->setJournalIndex (quest, index); } }; @@ -61,13 +55,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string quest = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - int index = context.getEnvironment().mJournal->getJournalIndex (quest); + int index = MWBase::Environment::get().getJournal()->getJournalIndex (quest); runtime.push (index); @@ -80,13 +71,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string topic = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getEnvironment().mDialogueManager->addTopic(topic); + MWBase::Environment::get().getDialogueManager()->addTopic(topic); } }; @@ -96,9 +84,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - MWDialogue::DialogueManager* dialogue = context.getEnvironment().mDialogueManager; + MWDialogue::DialogueManager* dialogue = MWBase::Environment::get().getDialogueManager(); while(arg0>0) { std::string question = runtime.getStringLiteral (runtime[0].mInteger); @@ -124,9 +110,8 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - context.getEnvironment().mDialogueManager->startDialogue (ptr); + + MWBase::Environment::get().getDialogueManager()->startDialogue (ptr); } }; diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index 14930b828..eb96ba5e2 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -12,9 +12,9 @@ namespace MWScript : mStore (store), mScriptManager (scriptManager) { addScript ("Main"); - - for (ESMS::RecListT::MapType::const_iterator iter - (store.startScripts.list.begin()); + + for (ESMS::RecListT::MapType::const_iterator iter + (store.startScripts.list.begin()); iter != store.startScripts.list.end(); ++iter) addScript (iter->second.script); } @@ -23,15 +23,15 @@ namespace MWScript { if (mScripts.find (name)==mScripts.end()) if (const ESM::Script *script = mStore.scripts.find (name)) - { + { Locals locals; - + locals.configure (*script); - mScripts.insert (std::make_pair (name, std::make_pair (true, locals))); + mScripts.insert (std::make_pair (name, std::make_pair (true, locals))); } } - + void GlobalScripts::removeScript (const std::string& name) { std::map >::iterator iter = mScripts.find (name); @@ -39,31 +39,30 @@ namespace MWScript if (iter!=mScripts.end()) iter->second.first = false; } - + bool GlobalScripts::isRunning (const std::string& name) const { std::map >::const_iterator iter = mScripts.find (name); - + if (iter==mScripts.end()) return false; - + return iter->second.first; } - - void GlobalScripts::run (MWWorld::Environment& environment) + + void GlobalScripts::run() { for (std::map >::iterator iter (mScripts.begin()); iter!=mScripts.end(); ++iter) { if (iter->second.first) { - MWScript::InterpreterContext interpreterContext (environment, + MWScript::InterpreterContext interpreterContext ( &iter->second.second, MWWorld::Ptr()); - mScriptManager.run (iter->first, interpreterContext); + mScriptManager.run (iter->first, interpreterContext); } } } } - diff --git a/apps/openmw/mwscript/globalscripts.hpp b/apps/openmw/mwscript/globalscripts.hpp index 741968fcd..3d62e4d7a 100644 --- a/apps/openmw/mwscript/globalscripts.hpp +++ b/apps/openmw/mwscript/globalscripts.hpp @@ -11,11 +11,6 @@ namespace ESMS struct ESMStore; } -namespace MWWorld -{ - class Environment; -} - namespace MWScript { class ScriptManager; @@ -25,21 +20,20 @@ namespace MWScript const ESMS::ESMStore& mStore; ScriptManager& mScriptManager; std::map > mScripts; // running, local variables - + public: - + GlobalScripts (const ESMS::ESMStore& store, ScriptManager& scriptManager); - + void addScript (const std::string& name); - + void removeScript (const std::string& name); - + bool isRunning (const std::string& name) const; - - void run (MWWorld::Environment& environment); + + void run(); ///< run all active global scripts }; } #endif - diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 426378efc..a37595ea8 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwgui/window_manager.hpp" #include "../mwinput/inputmanager.hpp" @@ -26,10 +28,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getWindowManager().allow (mWindow); + MWBase::Environment::get().getWindowManager()->allow (mWindow); } }; @@ -45,10 +44,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getInputManager().setGuiMode(mDialogue); + MWBase::Environment::get().getInputManager()->setGuiMode(mDialogue); } }; @@ -63,7 +59,7 @@ namespace MWScript MWWorld::Ptr ptr = context.getReference(); - runtime.push (context.getWindowManager().readPressedButton()); + runtime.push (MWBase::Environment::get().getWindowManager()->readPressedButton()); } }; @@ -73,10 +69,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getEnvironment().mWindowManager->toggleFogOfWar(); + MWBase::Environment::get().getWindowManager()->toggleFogOfWar(); } }; diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index acd1d957d..a369486fa 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -7,6 +7,8 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" #include "../mwgui/window_manager.hpp" @@ -24,7 +26,7 @@ namespace MWScript { if (!id.empty()) { - return mEnvironment.mWorld->getPtr (id, activeOnly); + return MWBase::Environment::get().getWorld()->getPtr (id, activeOnly); } else { @@ -40,7 +42,7 @@ namespace MWScript { if (!id.empty()) { - return mEnvironment.mWorld->getPtr (id, activeOnly); + return MWBase::Environment::get().getWorld()->getPtr (id, activeOnly); } else { @@ -51,9 +53,9 @@ namespace MWScript } } - InterpreterContext::InterpreterContext (MWWorld::Environment& environment, + InterpreterContext::InterpreterContext ( MWScript::Locals *locals, MWWorld::Ptr reference) - : mEnvironment (environment), mLocals (locals), mReference (reference), + : mLocals (locals), mReference (reference), mActivationHandled (false) {} @@ -108,7 +110,7 @@ namespace MWScript void InterpreterContext::messageBox (const std::string& message, const std::vector& buttons) { - mEnvironment.mWindowManager->messageBox (message, buttons); + MWBase::Environment::get().getWindowManager()->messageBox (message, buttons); } void InterpreterContext::report (const std::string& message) @@ -118,74 +120,74 @@ namespace MWScript bool InterpreterContext::menuMode() { - return mEnvironment.mWindowManager->isGuiMode(); + return MWBase::Environment::get().getWindowManager()->isGuiMode(); } int InterpreterContext::getGlobalShort (const std::string& name) const { - return mEnvironment.mWorld->getGlobalVariable (name).mShort; + return MWBase::Environment::get().getWorld()->getGlobalVariable (name).mShort; } int InterpreterContext::getGlobalLong (const std::string& name) const { // a global long is internally a float. - return mEnvironment.mWorld->getGlobalVariable (name).mLong; + return MWBase::Environment::get().getWorld()->getGlobalVariable (name).mLong; } float InterpreterContext::getGlobalFloat (const std::string& name) const { - return mEnvironment.mWorld->getGlobalVariable (name).mFloat; + return MWBase::Environment::get().getWorld()->getGlobalVariable (name).mFloat; } void InterpreterContext::setGlobalShort (const std::string& name, int value) { if (name=="gamehour") - mEnvironment.mWorld->setHour (value); + MWBase::Environment::get().getWorld()->setHour (value); else if (name=="day") - mEnvironment.mWorld->setDay (value); + MWBase::Environment::get().getWorld()->setDay (value); else if (name=="month") - mEnvironment.mWorld->setMonth (value); + MWBase::Environment::get().getWorld()->setMonth (value); else - mEnvironment.mWorld->getGlobalVariable (name).mShort = value; + MWBase::Environment::get().getWorld()->getGlobalVariable (name).mShort = value; } void InterpreterContext::setGlobalLong (const std::string& name, int value) { if (name=="gamehour") - mEnvironment.mWorld->setHour (value); + MWBase::Environment::get().getWorld()->setHour (value); else if (name=="day") - mEnvironment.mWorld->setDay (value); + MWBase::Environment::get().getWorld()->setDay (value); else if (name=="month") - mEnvironment.mWorld->setMonth (value); + MWBase::Environment::get().getWorld()->setMonth (value); else - mEnvironment.mWorld->getGlobalVariable (name).mLong = value; + MWBase::Environment::get().getWorld()->getGlobalVariable (name).mLong = value; } void InterpreterContext::setGlobalFloat (const std::string& name, float value) { if (name=="gamehour") - mEnvironment.mWorld->setHour (value); + MWBase::Environment::get().getWorld()->setHour (value); else if (name=="day") - mEnvironment.mWorld->setDay (value); + MWBase::Environment::get().getWorld()->setDay (value); else if (name=="month") - mEnvironment.mWorld->setMonth (value); + MWBase::Environment::get().getWorld()->setMonth (value); else - mEnvironment.mWorld->getGlobalVariable (name).mFloat = value; + MWBase::Environment::get().getWorld()->getGlobalVariable (name).mFloat = value; } bool InterpreterContext::isScriptRunning (const std::string& name) const { - return mEnvironment.mScriptManager->getGlobalScripts().isRunning (name); + return MWBase::Environment::get().getScriptManager()->getGlobalScripts().isRunning (name); } void InterpreterContext::startScript (const std::string& name) { - mEnvironment.mScriptManager->getGlobalScripts().addScript (name); + MWBase::Environment::get().getScriptManager()->getGlobalScripts().addScript (name); } void InterpreterContext::stopScript (const std::string& name) { - mEnvironment.mScriptManager->getGlobalScripts().removeScript (name); + MWBase::Environment::get().getScriptManager()->getGlobalScripts().removeScript (name); } float InterpreterContext::getDistance (const std::string& name, const std::string& id) const @@ -193,7 +195,7 @@ namespace MWScript // TODO handle exterior cells (when ref and ref2 are located in different cells) const MWWorld::Ptr ref2 = getReference (id, false); - const MWWorld::Ptr ref = mEnvironment.mWorld->getPtr (name, true); + const MWWorld::Ptr ref = MWBase::Environment::get().getWorld()->getPtr (name, true); double diff[3]; @@ -234,7 +236,7 @@ namespace MWScript if (!mAction.get()) throw std::runtime_error ("activation failed, because no action to perform"); - mAction->execute (mEnvironment); + mAction->execute(); mActivationHandled = true; } @@ -247,7 +249,7 @@ namespace MWScript float InterpreterContext::getSecondsPassed() const { - return mEnvironment.mFrameDuration; + return MWBase::Environment::get().getFrameDuration(); } bool InterpreterContext::isDisabled (const std::string& id) const @@ -259,38 +261,13 @@ namespace MWScript void InterpreterContext::enable (const std::string& id) { MWWorld::Ptr ref = getReference (id, false); - mEnvironment.mWorld->enable (ref); + MWBase::Environment::get().getWorld()->enable (ref); } void InterpreterContext::disable (const std::string& id) { MWWorld::Ptr ref = getReference (id, false); - mEnvironment.mWorld->disable (ref); - } - - MWWorld::Environment& InterpreterContext::getEnvironment() - { - return mEnvironment; - } - - MWGui::WindowManager& InterpreterContext::getWindowManager() - { - return *mEnvironment.mWindowManager; - } - - MWInput::MWInputManager& InterpreterContext::getInputManager() - { - return *mEnvironment.mInputManager; - } - - MWWorld::World& InterpreterContext::getWorld() - { - return *mEnvironment.mWorld; - } - - MWSound::SoundManager& InterpreterContext::getSoundManager() - { - return *mEnvironment.mSoundManager; + MWBase::Environment::get().getWorld()->disable (ref); } MWWorld::Ptr InterpreterContext::getReference() diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index 35b4a169d..40f53337d 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -6,7 +6,6 @@ #include #include "../mwworld/ptr.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" #include "../mwworld/action.hpp" @@ -26,7 +25,6 @@ namespace MWScript class InterpreterContext : public Interpreter::Context { - MWWorld::Environment& mEnvironment; Locals *mLocals; MWWorld::Ptr mReference; @@ -40,8 +38,7 @@ namespace MWScript public: - InterpreterContext (MWWorld::Environment& environment, - MWScript::Locals *locals, MWWorld::Ptr reference); + InterpreterContext (MWScript::Locals *locals, MWWorld::Ptr reference); ///< The ownership of \a locals is not transferred. 0-pointer allowed. virtual int getLocalShort (int index) const; @@ -110,18 +107,6 @@ namespace MWScript virtual void disable (const std::string& id = ""); - MWWorld::Environment& getEnvironment(); - - /// \todo remove the following functions (extentions should use getEnvironment instead) - - MWWorld::World& getWorld(); - - MWSound::SoundManager& getSoundManager(); - - MWGui::WindowManager& getWindowManager(); - - MWInput::MWInputManager& getInputManager(); - MWWorld::Ptr getReference(); ///< Reference, that the script is running from (can be empty) }; diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index a0770b9a8..4ba523937 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/class.hpp" #include "interpretercontext.hpp" @@ -100,7 +102,7 @@ namespace MWScript static_cast (runtime.getContext()); bool enabled = - context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug); + MWBase::Environment::get().getWorld()->toggleRenderMode (MWWorld::World::Render_CollisionDebug); context.report (enabled ? "Collision Mesh Rendering -> On" : "Collision Mesh Rendering -> Off"); @@ -117,7 +119,7 @@ namespace MWScript static_cast (runtime.getContext()); bool enabled = - context.getWorld().toggleRenderMode (MWWorld::World::Render_Wireframe); + MWBase::Environment::get().getWorld()->toggleRenderMode (MWWorld::World::Render_Wireframe); context.report (enabled ? "Wireframe Rendering -> On" : "Wireframe Rendering -> Off"); @@ -133,7 +135,7 @@ namespace MWScript static_cast (runtime.getContext()); bool enabled = - context.getWorld().toggleRenderMode (MWWorld::World::Render_Pathgrid); + MWBase::Environment::get().getWorld()->toggleRenderMode (MWWorld::World::Render_Pathgrid); context.report (enabled ? "Path Grid rendering -> On" : "Path Grid Rendering -> Off"); @@ -146,13 +148,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - Interpreter::Type_Float time = runtime[0].mFloat; runtime.pop(); - context.getWorld().getFader()->fadeIn(time); + MWBase::Environment::get().getWorld()->getFader()->fadeIn(time); } }; @@ -162,13 +161,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - Interpreter::Type_Float time = runtime[0].mFloat; runtime.pop(); - context.getWorld().getFader()->fadeOut(time); + MWBase::Environment::get().getWorld()->getFader()->fadeOut(time); } }; @@ -178,16 +174,13 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - Interpreter::Type_Float alpha = runtime[0].mFloat; runtime.pop(); Interpreter::Type_Float time = runtime[0].mFloat; runtime.pop(); - context.getWorld().getFader()->fadeTo(alpha, time); + MWBase::Environment::get().getWorld()->getFader()->fadeTo(alpha, time); } }; @@ -197,10 +190,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getWorld().toggleWater(); + MWBase::Environment::get().getWorld()->toggleWater(); } }; diff --git a/apps/openmw/mwscript/ref.hpp b/apps/openmw/mwscript/ref.hpp index 5ca1ea4d6..28093c4e5 100644 --- a/apps/openmw/mwscript/ref.hpp +++ b/apps/openmw/mwscript/ref.hpp @@ -5,6 +5,8 @@ #include +#include "../mwbase/environment.hpp" + #include "../mwworld/ptr.hpp" #include "../mwworld/world.hpp" @@ -16,13 +18,10 @@ namespace MWScript { MWWorld::Ptr operator() (Interpreter::Runtime& runtime) const { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string id = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - return context.getWorld().getPtr (id, false); + return MWBase::Environment::get().getWorld()->getPtr (id, false); } }; diff --git a/apps/openmw/mwscript/skyextensions.cpp b/apps/openmw/mwscript/skyextensions.cpp index a5cc9e213..e16c2ec23 100644 --- a/apps/openmw/mwscript/skyextensions.cpp +++ b/apps/openmw/mwscript/skyextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "interpretercontext.hpp" namespace MWScript @@ -19,11 +21,11 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { + bool enabled = MWBase::Environment::get().getWorld()->toggleSky(); + InterpreterContext& context = static_cast (runtime.getContext()); - bool enabled = context.getWorld().toggleSky(); - context.report (enabled ? "Sky -> On" : "Sky -> Off"); } }; @@ -34,10 +36,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getWorld().setMoonColour (false); + MWBase::Environment::get().getWorld()->setMoonColour (false); } }; @@ -47,10 +46,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - context.getWorld().setMoonColour (true); + MWBase::Environment::get().getWorld()->setMoonColour (true); } }; @@ -60,10 +56,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - runtime.push (context.getWorld().getMasserPhase()); + runtime.push (MWBase::Environment::get().getWorld()->getMasserPhase()); } }; @@ -73,42 +66,33 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - runtime.push (context.getWorld().getSecundaPhase()); + runtime.push (MWBase::Environment::get().getWorld()->getSecundaPhase()); } }; - + class OpGetCurrentWeather : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - - runtime.push (context.getWorld().getCurrentWeather()); + runtime.push (MWBase::Environment::get().getWorld()->getCurrentWeather()); } }; - + class OpChangeWeather : public Interpreter::Opcode0 { public: - + virtual void execute (Interpreter::Runtime& runtime) { - InterpreterContext& context = - static_cast (runtime.getContext()); - std::string region = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - + Interpreter::Type_Integer id = runtime[0].mInteger; runtime.pop(); - - context.getWorld().changeWeather(region, id); + + MWBase::Environment::get().getWorld()->changeWeather(region, id); } }; diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index b4386a8a0..c2b45641a 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" #include "../mwsound/soundmanager.hpp" @@ -36,7 +38,7 @@ namespace MWScript std::string text = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().say (ptr, file); + MWBase::Environment::get().getSoundManager()->say (ptr, file); context.messageBox (text); } }; @@ -50,10 +52,7 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - - runtime.push (context.getSoundManager().sayDone (ptr)); + runtime.push (MWBase::Environment::get().getSoundManager()->sayDone (ptr)); } }; @@ -63,13 +62,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().streamMusic (sound); + MWBase::Environment::get().getSoundManager()->streamMusic (sound); } }; @@ -79,13 +75,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().playSound (sound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); } }; @@ -95,9 +88,6 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -107,7 +97,7 @@ namespace MWScript Interpreter::Type_Float pitch = runtime[0].mFloat; runtime.pop(); - context.getSoundManager().playSound (sound, volume, pitch); + MWBase::Environment::get().getSoundManager()->playSound (sound, volume, pitch); } }; @@ -124,13 +114,10 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().playSound3D (ptr, sound, 1.0, 1.0, mLoop ? MWSound::Play_Loop : 0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, sound, 1.0, 1.0, mLoop ? MWSound::Play_Loop : 0); } }; @@ -147,9 +134,6 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -159,7 +143,7 @@ namespace MWScript Interpreter::Type_Float pitch = runtime[0].mFloat; runtime.pop(); - context.getSoundManager().playSound3D (ptr, sound, volume, pitch, mLoop ? MWSound::Play_Loop : 0); + MWBase::Environment::get().getSoundManager()->playSound3D (ptr, sound, volume, pitch, mLoop ? MWSound::Play_Loop : 0); } }; @@ -173,13 +157,10 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - context.getSoundManager().stopSound3D (ptr, sound); + MWBase::Environment::get().getSoundManager()->stopSound3D (ptr, sound); } }; @@ -192,13 +173,10 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - int index = runtime[0].mInteger; runtime.pop(); - runtime.push (context.getSoundManager().getSoundPlaying ( + runtime.push (MWBase::Environment::get().getSoundManager()->getSoundPlaying ( ptr, runtime.getStringLiteral (index))); } }; diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 239f8d768..cad52e593 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -7,8 +7,9 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwworld/class.hpp" -#include "../mwworld/environment.hpp" #include "../mwworld/player.hpp" #include "../mwmechanics/creaturestats.hpp" @@ -351,11 +352,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { std::string factionID = ""; - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + if(arg0==0) { - factionID = context.getEnvironment().mDialogueManager->getFaction(); + factionID = MWBase::Environment::get().getDialogueManager()->getFaction(); } else { @@ -364,7 +364,7 @@ namespace MWScript } if(factionID != "") { - MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer(); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) == MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) { MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = 0; @@ -380,11 +380,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { std::string factionID = ""; - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + if(arg0==0) { - factionID = context.getEnvironment().mDialogueManager->getFaction(); + factionID = MWBase::Environment::get().getDialogueManager()->getFaction(); } else { @@ -393,7 +392,7 @@ namespace MWScript } if(factionID != "") { - MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer(); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) == MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) { MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = 0; @@ -413,11 +412,10 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) { std::string factionID = ""; - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); + if(arg0==0) { - factionID = context.getEnvironment().mDialogueManager->getFaction(); + factionID = MWBase::Environment::get().getDialogueManager()->getFaction(); } else { @@ -426,7 +424,7 @@ namespace MWScript } if(factionID != "") { - MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer(); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) != MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) { MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] = MWWorld::Class::get(player).getNpcStats(player).mFactionRank[factionID] -1; @@ -461,9 +459,7 @@ namespace MWScript factionID = MWWorld::Class::get(ptr).getNpcStats(ptr).mFactionRank.begin()->first; } } - MWScript::InterpreterContext& context - = static_cast (runtime.getContext()); - MWWorld::Ptr player = context.getEnvironment().mWorld->getPlayer().getPlayer(); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); if(factionID!="") { if(MWWorld::Class::get(player).getNpcStats(player).mFactionRank.find(factionID) != MWWorld::Class::get(player).getNpcStats(player).mFactionRank.end()) @@ -481,7 +477,7 @@ namespace MWScript } } }; - + template class OpModDisposition : public Interpreter::Opcode0 { diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 730d9d9b2..4656efb6e 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -9,7 +9,8 @@ #include #include -#include "../mwworld/environment.hpp" +#include "../mwbase/environment.hpp" + #include "../mwworld/world.hpp" #include "../mwworld/player.hpp" @@ -46,9 +47,8 @@ namespace MWSound { - SoundManager::SoundManager(bool useSound, MWWorld::Environment& environment) + SoundManager::SoundManager(bool useSound) : mResourceMgr(Ogre::ResourceGroupManager::getSingleton()) - , mEnvironment(environment) , mOutput(new DEFAULT_OUTPUT(*this)) , mMasterVolume(1.0f) , mSFXVolume(1.0f) @@ -113,7 +113,7 @@ namespace MWSound std::string SoundManager::lookup(const std::string &soundId, float &volume, float &min, float &max) { - const ESM::Sound *snd = mEnvironment.mWorld->getStore().sounds.search(soundId); + const ESM::Sound *snd = MWBase::Environment::get().getWorld()->getStore().sounds.search(soundId); if(snd == NULL) throw std::runtime_error(std::string("Failed to lookup sound ")+soundId); @@ -380,7 +380,7 @@ namespace MWSound void SoundManager::updateRegionSound(float duration) { - MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell(); + MWWorld::Ptr::CellStore *current = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); static int total = 0; static std::string regionName = ""; static float timePassed = 0.0; @@ -397,7 +397,7 @@ namespace MWSound total = 0; } - const ESM::Region *regn = mEnvironment.mWorld->getStore().regions.find(regionName); + const ESM::Region *regn = MWBase::Environment::get().getWorld()->getStore().regions.find(regionName); std::vector::const_iterator soundIter; if(total == 0) { @@ -445,8 +445,8 @@ namespace MWSound if(!isMusicPlaying()) startRandomTitle(); - const ESM::Cell *cell = mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell; - Ogre::Camera *cam = mEnvironment.mWorld->getPlayer().getRenderer()->getCamera(); + const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell; + Ogre::Camera *cam = MWBase::Environment::get().getWorld()->getPlayer().getRenderer()->getCamera(); Ogre::Vector3 nPos, nDir, nUp; nPos = cam->getRealPosition(); nDir = cam->getRealDirection(); diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index d64db299b..8afd488e1 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -16,11 +16,6 @@ namespace Ogre class Camera; } -namespace MWWorld -{ - struct Environment; -} - namespace MWSound { class Sound_Output; @@ -52,8 +47,6 @@ namespace MWSound { Ogre::ResourceGroupManager& mResourceMgr; - MWWorld::Environment& mEnvironment; - std::auto_ptr mOutput; float mMasterVolume; @@ -82,7 +75,7 @@ namespace MWSound friend class OpenAL_Output; public: - SoundManager(bool useSound, MWWorld::Environment& environment); + SoundManager(bool useSound); ~SoundManager(); void stopMusic(); diff --git a/apps/openmw/mwworld/action.hpp b/apps/openmw/mwworld/action.hpp index 155819335..d5cf12779 100644 --- a/apps/openmw/mwworld/action.hpp +++ b/apps/openmw/mwworld/action.hpp @@ -3,8 +3,6 @@ namespace MWWorld { - class Environment; - /// \brief Abstract base for actions class Action { @@ -18,7 +16,7 @@ namespace MWWorld virtual ~Action() {} - virtual void execute (Environment& environment) = 0; + virtual void execute() = 0; }; } diff --git a/apps/openmw/mwworld/actiontake.cpp b/apps/openmw/mwworld/actiontake.cpp index bbe954049..b1e2e1fc3 100644 --- a/apps/openmw/mwworld/actiontake.cpp +++ b/apps/openmw/mwworld/actiontake.cpp @@ -1,8 +1,9 @@ #include "actiontake.hpp" +#include "../mwbase/environment.hpp" + #include "class.hpp" -#include "environment.hpp" #include "world.hpp" #include "containerstore.hpp" @@ -10,14 +11,14 @@ namespace MWWorld { ActionTake::ActionTake (const MWWorld::Ptr& object) : mObject (object) {} - void ActionTake::execute (Environment& environment) + void ActionTake::execute() { // insert into player's inventory - MWWorld::Ptr player = environment.mWorld->getPtr ("player", true); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true); MWWorld::Class::get (player).getContainerStore (player).add (mObject); // remove from world - environment.mWorld->deleteObject (mObject); + MWBase::Environment::get().getWorld()->deleteObject (mObject); } } diff --git a/apps/openmw/mwworld/actiontake.hpp b/apps/openmw/mwworld/actiontake.hpp index 509ebc6bb..f495fc3c4 100644 --- a/apps/openmw/mwworld/actiontake.hpp +++ b/apps/openmw/mwworld/actiontake.hpp @@ -14,7 +14,7 @@ namespace MWWorld ActionTake (const MWWorld::Ptr& object); - virtual void execute (Environment& environment); + virtual void execute(); }; } diff --git a/apps/openmw/mwworld/actiontalk.cpp b/apps/openmw/mwworld/actiontalk.cpp index 7d38c22fd..b33b78832 100644 --- a/apps/openmw/mwworld/actiontalk.cpp +++ b/apps/openmw/mwworld/actiontalk.cpp @@ -1,7 +1,7 @@ #include "actiontalk.hpp" -#include "environment.hpp" +#include "../mwbase/environment.hpp" #include "../mwdialogue/dialoguemanager.hpp" @@ -9,8 +9,8 @@ namespace MWWorld { ActionTalk::ActionTalk (const Ptr& actor) : mActor (actor) {} - void ActionTalk::execute (Environment& environment) + void ActionTalk::execute() { - environment.mDialogueManager->startDialogue (mActor); + MWBase::Environment::get().getDialogueManager()->startDialogue (mActor); } } diff --git a/apps/openmw/mwworld/actiontalk.hpp b/apps/openmw/mwworld/actiontalk.hpp index a60a61660..1b7b9b6d6 100644 --- a/apps/openmw/mwworld/actiontalk.hpp +++ b/apps/openmw/mwworld/actiontalk.hpp @@ -15,7 +15,7 @@ namespace MWWorld ActionTalk (const Ptr& actor); ///< \param actor The actor the player is talking to - virtual void execute (Environment& environment); + virtual void execute(); }; } diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index 207e2c50e..6ebbd7b7f 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -1,7 +1,8 @@ #include "actionteleport.hpp" -#include "environment.hpp" +#include "../mwbase/environment.hpp" + #include "world.hpp" namespace MWWorld @@ -11,11 +12,11 @@ namespace MWWorld : mCellName (cellName), mPosition (position) {} - void ActionTeleportPlayer::execute (Environment& environment) + void ActionTeleportPlayer::execute() { if (mCellName.empty()) - environment.mWorld->changeToExteriorCell (mPosition); + MWBase::Environment::get().getWorld()->changeToExteriorCell (mPosition); else - environment.mWorld->changeToInteriorCell (mCellName, mPosition); + MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, mPosition); } } diff --git a/apps/openmw/mwworld/actionteleport.hpp b/apps/openmw/mwworld/actionteleport.hpp index e4c972a9e..00efdc876 100644 --- a/apps/openmw/mwworld/actionteleport.hpp +++ b/apps/openmw/mwworld/actionteleport.hpp @@ -19,7 +19,7 @@ namespace MWWorld ActionTeleportPlayer (const std::string& cellName, const ESM::Position& position); ///< If cellName is empty, an exterior cell is asumed. - virtual void execute (Environment& environment); + virtual void execute(); }; } diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index d49b98d0f..c53ebcfd0 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -27,17 +27,17 @@ namespace MWWorld } - void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const + void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const { } - void Class::enable (const Ptr& ptr, MWWorld::Environment& environment) const + void Class::enable (const Ptr& ptr) const { } - void Class::disable (const Ptr& ptr, MWWorld::Environment& environment) const + void Class::disable (const Ptr& ptr) const { } @@ -62,14 +62,12 @@ namespace MWWorld throw std::runtime_error ("class does not have item health"); } - boost::shared_ptr Class::activate (const Ptr& ptr, const Ptr& actor, - const Environment& environment) const + boost::shared_ptr Class::activate (const Ptr& ptr, const Ptr& actor) const { return boost::shared_ptr (new NullAction); } - boost::shared_ptr Class::use (const Ptr& ptr, - const Environment& environment) const + boost::shared_ptr Class::use (const Ptr& ptr) const { return boost::shared_ptr (new NullAction); } @@ -134,7 +132,7 @@ namespace MWWorld return std::make_pair (std::vector(), false); } - int Class::getEquipmentSkill (const Ptr& ptr, const Environment& environment) const + int Class::getEquipmentSkill (const Ptr& ptr) const { return -1; } @@ -164,12 +162,12 @@ namespace MWWorld sClasses.insert (std::make_pair (key, instance)); } - std::string Class::getUpSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const + std::string Class::getUpSoundId (const Ptr& ptr) const { throw std::runtime_error ("class does not have an up sound"); } - std::string Class::getDownSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const + std::string Class::getDownSoundId (const Ptr& ptr) const { throw std::runtime_error ("class does not have an down sound"); } diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index e474e9b92..622d9eeae 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -33,7 +33,6 @@ namespace MWMechanics namespace MWWorld { class Ptr; - class Environment; class ContainerStore; class InventoryStore; @@ -65,15 +64,15 @@ namespace MWWorld /// (default implementation: throw an exception) virtual void insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; - virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const; + virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const; ///< Add reference into a cell for rendering (default implementation: don't render anything). - virtual void enable (const Ptr& ptr, MWWorld::Environment& environment) const; + virtual void enable (const Ptr& ptr) const; ///< Enable reference; only does the non-rendering part (default implementation: ignore) /// \attention This is not the same as the script instruction with the same name. References /// should only be enabled while in an active cell. - virtual void disable (const Ptr& ptr, MWWorld::Environment& environment) const; + virtual void disable (const Ptr& ptr) const; ///< Enable reference; only does the non-rendering part (default implementation: ignore) /// \attention This is not the same as the script instruction with the same name. References /// should only be enabled while in an active cell. @@ -97,11 +96,10 @@ namespace MWWorld ///< Return item max health or throw an exception, if class does not have item health /// (default implementation: throw an exceoption) - virtual boost::shared_ptr activate (const Ptr& ptr, const Ptr& actor, - const Environment& environment) const; + virtual boost::shared_ptr activate (const Ptr& ptr, const Ptr& actor) const; ///< Generate action for activation (default implementation: return a null action). - virtual boost::shared_ptr use (const Ptr& ptr, const Environment& environment) + virtual boost::shared_ptr use (const Ptr& ptr) const; ///< Generate action for using via inventory menu (default implementation: return a /// null action). @@ -149,7 +147,7 @@ namespace MWWorld /// /// Default implementation: return (empty vector, false). - virtual int getEquipmentSkill (const Ptr& ptr, const Environment& environment) + virtual int getEquipmentSkill (const Ptr& ptr) const; /// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// no such skill. @@ -167,11 +165,11 @@ namespace MWWorld static void registerClass (const std::string& key, boost::shared_ptr instance); - virtual std::string getUpSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getUpSoundId (const Ptr& ptr) const; ///< Return the up sound ID of \a ptr or throw an exception, if class does not support ID retrieval /// (default implementation: throw an exception) - virtual std::string getDownSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const; + virtual std::string getDownSoundId (const Ptr& ptr) const; ///< Return the down sound ID of \a ptr or throw an exception, if class does not support ID retrieval /// (default implementation: throw an exception) }; diff --git a/apps/openmw/mwworld/environment.hpp b/apps/openmw/mwworld/environment.hpp deleted file mode 100644 index 8c4a001e0..000000000 --- a/apps/openmw/mwworld/environment.hpp +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef GAME_WORLD_INVIRONMENT_H -#define GAME_WORLD_INVIRONMENT_H - -namespace MWSound -{ - class SoundManager; -} - -namespace MWScript -{ - class ScriptManager; -} - -namespace MWGui -{ - class WindowManager; -} - -namespace MWMechanics -{ - class MechanicsManager; -} - -namespace MWDialogue -{ - class DialogueManager; - class Journal; -} - -namespace MWInput -{ - struct MWInputManager; -} - -namespace MWWorld -{ - class World; - - ///< Collection of script-accessable sub-systems - class Environment - { - public: - Environment() - : mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0), - mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0), - mInputManager (0) - {} - - World *mWorld; - MWSound::SoundManager *mSoundManager; - MWScript::ScriptManager *mScriptManager; - MWGui::WindowManager *mWindowManager; - MWMechanics::MechanicsManager *mMechanicsManager; - MWDialogue::DialogueManager *mDialogueManager; - MWDialogue::Journal *mJournal; - float mFrameDuration; - - // For setting GUI mode - MWInput::MWInputManager *mInputManager; - }; -} - -#endif diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 230f7d69a..b93a62e4e 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -72,7 +72,7 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite /// \todo restack item previously in this slot (if required) /// \todo unstack item pointed to by iterator if required) - + mSlots[slot] = iterator; flagAsModified(); @@ -96,8 +96,7 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot) return mSlots[slot]; } -void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats, - const Environment& environment) +void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats) { TSlots slots; initSlots (slots); @@ -105,7 +104,7 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats, for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter) { Ptr test = *iter; - int testSkill = MWWorld::Class::get (test).getEquipmentSkill (test, environment); + int testSkill = MWWorld::Class::get (test).getEquipmentSkill (test); std::pair, bool> itemsSlots = MWWorld::Class::get (*iter).getEquipmentSlots (*iter); @@ -125,7 +124,7 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats, { // check skill int oldSkill = - MWWorld::Class::get (old).getEquipmentSkill (old, environment); + MWWorld::Class::get (old).getEquipmentSkill (old); if (testSkill!=-1 || oldSkill!=-1 || testSkill!=oldSkill) { diff --git a/apps/openmw/mwworld/inventorystore.hpp b/apps/openmw/mwworld/inventorystore.hpp index 60b89b0b4..5eeaf570d 100644 --- a/apps/openmw/mwworld/inventorystore.hpp +++ b/apps/openmw/mwworld/inventorystore.hpp @@ -10,8 +10,6 @@ namespace MWMechanics namespace MWWorld { - class Environment; - ///< \brief Variant of the ContainerStore for NPCs class InventoryStore : public ContainerStore { @@ -64,7 +62,7 @@ namespace MWWorld ContainerStoreIterator getSlot (int slot); - void autoEquip (const MWMechanics::NpcStats& stats, const Environment& environment); + void autoEquip (const MWMechanics::NpcStats& stats); ///< Auto equip items according to stats and item value. }; } diff --git a/apps/openmw/mwworld/nullaction.hpp b/apps/openmw/mwworld/nullaction.hpp index 820fc4538..c8e3368e4 100644 --- a/apps/openmw/mwworld/nullaction.hpp +++ b/apps/openmw/mwworld/nullaction.hpp @@ -10,7 +10,7 @@ namespace MWWorld { public: - virtual void execute (Environment& environment) {} + virtual void execute() {} }; } diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 2123b4799..abb988c83 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -1,6 +1,7 @@ #include "scene.hpp" #include "world.hpp" +#include "../mwbase/environment.hpp" #include "../mwmechanics/mechanicsmanager.hpp" @@ -9,7 +10,6 @@ #include "../mwgui/window_manager.hpp" #include "ptr.hpp" -#include "environment.hpp" #include "player.hpp" #include "class.hpp" @@ -18,7 +18,7 @@ namespace { template -void insertCellRefList(MWRender::RenderingManager& rendering, MWWorld::Environment& environment, +void insertCellRefList(MWRender::RenderingManager& rendering, T& cellRefList, ESMS::CellStore &cell, MWWorld::PhysicsSystem& physics) { if (!cellRefList.list.empty()) @@ -36,8 +36,8 @@ void insertCellRefList(MWRender::RenderingManager& rendering, MWWorld::Environme try { rendering.addObject(ptr); - class_.insertObject(ptr, physics, environment); - class_.enable (ptr, environment); + class_.insertObject(ptr, physics); + class_.enable (ptr); } catch (const std::exception& e) { @@ -86,12 +86,12 @@ namespace MWWorld //mPhysics->removeObject("Unnamed_43"); mWorld->getLocalScripts().clearCell (*iter); - mEnvironment.mMechanicsManager->dropActors (*iter); - mEnvironment.mSoundManager->stopSound (*iter); + MWBase::Environment::get().getMechanicsManager()->dropActors (*iter); + MWBase::Environment::get().getSoundManager()->stopSound (*iter); mActiveCells.erase(*iter); - - + + } void Scene::loadCell (Ptr::CellStore *cell) @@ -104,7 +104,7 @@ namespace MWWorld std::pair result = mActiveCells.insert(cell); if(result.second){ - insertCell(*cell, mEnvironment); + insertCell(*cell); mRendering.cellAdded(cell); mRendering.configureAmbient(*cell); mRendering.requestMap(cell); @@ -122,10 +122,10 @@ namespace MWWorld mWorld->getPlayer().setCell (cell); // TODO orientation - mEnvironment.mMechanicsManager->addActor (mWorld->getPlayer().getPlayer()); - mEnvironment.mMechanicsManager->watchActor (mWorld->getPlayer().getPlayer()); + MWBase::Environment::get().getMechanicsManager()->addActor (mWorld->getPlayer().getPlayer()); + MWBase::Environment::get().getMechanicsManager()->watchActor (mWorld->getPlayer().getPlayer()); - mEnvironment.mWindowManager->changeCell( mCurrentCell ); + MWBase::Environment::get().getWindowManager()->changeCell( mCurrentCell ); } void Scene::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos) @@ -133,7 +133,7 @@ namespace MWWorld mRendering.preCellChange(mCurrentCell); // remove active - mEnvironment.mMechanicsManager->removeActor (mWorld->getPlayer().getPlayer()); + MWBase::Environment::get().getMechanicsManager()->removeActor (mWorld->getPlayer().getPlayer()); CellStoreCollection::iterator active = mActiveCells.begin(); @@ -207,8 +207,8 @@ namespace MWWorld } //We need the ogre renderer and a scene node. - Scene::Scene (Environment& environment, World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics) - : mCurrentCell (0), mCellChanged (false), mEnvironment (environment), mWorld(world), + Scene::Scene (World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics) + : mCurrentCell (0), mCellChanged (false), mWorld(world), mPhysics(physics), mRendering(rendering) { } @@ -243,12 +243,12 @@ namespace MWWorld Ptr::CellStore *cell = mWorld->getInterior(cellName); loadCell (cell); - + // adjust player mCurrentCell = cell; playerCellChange (cell, position); - + // adjust fog mRendering.configureFog(*cell); @@ -278,30 +278,29 @@ namespace MWWorld mCellChanged = false; } -void Scene::insertCell(ESMS::CellStore &cell, - MWWorld::Environment& environment) +void Scene::insertCell(ESMS::CellStore &cell) { // Loop through all references in the cell - insertCellRefList(mRendering, environment, cell.activators, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.potions, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.appas, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.armors, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.books, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.clothes, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.containers, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.creatures, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.doors, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.ingreds, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.creatureLists, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.itemLists, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.lights, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.lockpicks, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.miscItems, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.npcs, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.probes, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.repairs, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.statics, cell, *mPhysics); - insertCellRefList(mRendering, environment, cell.weapons, cell, *mPhysics); + insertCellRefList(mRendering, cell.activators, cell, *mPhysics); + insertCellRefList(mRendering, cell.potions, cell, *mPhysics); + insertCellRefList(mRendering, cell.appas, cell, *mPhysics); + insertCellRefList(mRendering, cell.armors, cell, *mPhysics); + insertCellRefList(mRendering, cell.books, cell, *mPhysics); + insertCellRefList(mRendering, cell.clothes, cell, *mPhysics); + insertCellRefList(mRendering, cell.containers, cell, *mPhysics); + insertCellRefList(mRendering, cell.creatures, cell, *mPhysics); + insertCellRefList(mRendering, cell.doors, cell, *mPhysics); + insertCellRefList(mRendering, cell.ingreds, cell, *mPhysics); + insertCellRefList(mRendering, cell.creatureLists, cell, *mPhysics); + insertCellRefList(mRendering, cell.itemLists, cell, *mPhysics); + insertCellRefList(mRendering, cell.lights, cell, *mPhysics); + insertCellRefList(mRendering, cell.lockpicks, cell, *mPhysics); + insertCellRefList(mRendering, cell.miscItems, cell, *mPhysics); + insertCellRefList(mRendering, cell.npcs, cell, *mPhysics); + insertCellRefList(mRendering, cell.probes, cell, *mPhysics); + insertCellRefList(mRendering, cell.repairs, cell, *mPhysics); + insertCellRefList(mRendering, cell.statics, cell, *mPhysics); + insertCellRefList(mRendering, cell.weapons, cell, *mPhysics); } diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index 4d1bd6fb5..1a9f2f271 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -46,7 +46,6 @@ namespace MWRender namespace MWWorld { - class Environment; class Player; class Scene @@ -62,7 +61,6 @@ namespace MWWorld Ptr::CellStore* mCurrentCell; // the cell, the player is in CellStoreCollection mActiveCells; bool mCellChanged; - Environment& mEnvironment; World *mWorld; PhysicsSystem *mPhysics; MWRender::RenderingManager& mRendering; @@ -73,7 +71,7 @@ namespace MWWorld public: - Scene (Environment& environment, World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics); + Scene (World *world, MWRender::RenderingManager& rendering, PhysicsSystem *physics); ~Scene(); @@ -100,7 +98,7 @@ namespace MWWorld void markCellAsUnchanged(); - void insertCell(ESMS::CellStore &cell, MWWorld::Environment& environment); + void insertCell(ESMS::CellStore &cell); void update (float duration); }; diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index fb0480171..803fce1e1 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -9,7 +9,9 @@ #include #include -#include +#include + +#include "../mwbase/environment.hpp" using namespace Ogre; using namespace MWWorld; @@ -34,15 +36,14 @@ const float WeatherGlobals::mThunderFrequency = .4; const float WeatherGlobals::mThunderThreshold = 0.6; const float WeatherGlobals::mThunderSoundDelay = 0.25; -WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::Environment* env) : +WeatherManager::WeatherManager(MWRender::RenderingManager* rendering) : mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0), mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0) { mRendering = rendering; - mEnvironment = env; - + #define clr(r,g,b) ColourValue(r/255.f, g/255.f, b/255.f) - + /// \todo read these from Morrowind.ini Weather clear; clear.mCloudTexture = "tx_sky_clear.dds"; @@ -71,7 +72,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E clear.mCloudSpeed = 1.25; clear.mGlareView = 1.0; mWeatherSettings["clear"] = clear; - + Weather cloudy; cloudy.mCloudTexture = "tx_sky_cloudy.dds"; cloudy.mCloudsMaximumPercent = 1.0; @@ -99,7 +100,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E cloudy.mCloudSpeed = 2; cloudy.mGlareView = 1.0; mWeatherSettings["cloudy"] = cloudy; - + Weather foggy; foggy.mCloudTexture = "tx_sky_foggy.dds"; foggy.mCloudsMaximumPercent = 1.0; @@ -127,7 +128,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E foggy.mCloudSpeed = 1.25; foggy.mGlareView = 0.25; mWeatherSettings["foggy"] = foggy; - + Weather thunderstorm; thunderstorm.mCloudTexture = "tx_sky_thunder.dds"; thunderstorm.mCloudsMaximumPercent = 0.66; @@ -156,7 +157,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E thunderstorm.mGlareView = 0; thunderstorm.mRainLoopSoundID = "rain heavy"; mWeatherSettings["thunderstorm"] = thunderstorm; - + Weather rain; rain.mCloudTexture = "tx_sky_rainy.dds"; rain.mCloudsMaximumPercent = 0.66; @@ -185,7 +186,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E rain.mGlareView = 0; rain.mRainLoopSoundID = "rain"; mWeatherSettings["rain"] = rain; - + Weather overcast; overcast.mCloudTexture = "tx_sky_overcast.dds"; overcast.mCloudsMaximumPercent = 1.0; @@ -213,7 +214,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E overcast.mCloudSpeed = 1.5; overcast.mGlareView = 0; mWeatherSettings["overcast"] = overcast; - + Weather ashstorm; ashstorm.mCloudTexture = "tx_sky_ashstorm.dds"; ashstorm.mCloudsMaximumPercent = 1.0; @@ -242,7 +243,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E ashstorm.mGlareView = 0; ashstorm.mAmbientLoopSoundID = "ashstorm"; mWeatherSettings["ashstorm"] = ashstorm; - + Weather blight; blight.mCloudTexture = "tx_sky_blight.dds"; blight.mCloudsMaximumPercent = 1.0; @@ -300,7 +301,7 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, MWWorld::E snow.mCloudSpeed = 1.5; snow.mGlareView = 0; mWeatherSettings["snow"] = snow; - + Weather blizzard; blizzard.mCloudTexture = "tx_bm_sky_blizzard.dds"; blizzard.mCloudsMaximumPercent = 1.0; @@ -484,15 +485,15 @@ WeatherResult WeatherManager::transition(float factor) void WeatherManager::update(float duration) { - mWeatherUpdateTime -= duration * mEnvironment->mWorld->getTimeScaleFactor(); + mWeatherUpdateTime -= duration * MWBase::Environment::get().getWorld()->getTimeScaleFactor(); - bool exterior = (mEnvironment->mWorld->isCellExterior() || mEnvironment->mWorld->isCellQuasiExterior()); + bool exterior = (MWBase::Environment::get().getWorld()->isCellExterior() || MWBase::Environment::get().getWorld()->isCellQuasiExterior()); if (exterior) { - std::string regionstr = mEnvironment->mWorld->getPlayer().getPlayer().getCell()->cell->region; + std::string regionstr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->region; boost::algorithm::to_lower(regionstr); - + if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion) { mCurrentRegion = regionstr; @@ -505,7 +506,7 @@ void WeatherManager::update(float duration) else { // get weather probabilities for the current region - const ESM::Region *region = mEnvironment->mWorld->getStore().regions.find (regionstr); + const ESM::Region *region = MWBase::Environment::get().getWorld()->getStore().regions.find (regionstr); float clear = region->data.clear/255.f; float cloudy = region->data.cloudy/255.f; @@ -553,7 +554,7 @@ void WeatherManager::update(float duration) if (mNextWeather != "") { - mRemainingTransitionTime -= duration * mEnvironment->mWorld->getTimeScaleFactor(); + mRemainingTransitionTime -= duration * MWBase::Environment::get().getWorld()->getTimeScaleFactor(); if (mRemainingTransitionTime < 0) { mCurrentWeather = mNextWeather; @@ -588,8 +589,8 @@ void WeatherManager::update(float duration) int facing = (mHour > 13.f) ? 1 : -1; Vector3 final( - -(1-height)*facing, - -(1-height)*facing, + -(1-height)*facing, + -(1-height)*facing, height); mRendering->setSunDirection(final); @@ -609,13 +610,13 @@ void WeatherManager::update(float duration) float moonHeight = 1-std::abs((night-0.5)*2); int facing = (mHour > 0.f && mHour<12.f) ? 1 : -1; Vector3 masser( - (1-moonHeight)*facing, - (1-moonHeight)*facing, + (1-moonHeight)*facing, + (1-moonHeight)*facing, moonHeight); Vector3 secunda( - (1-moonHeight)*facing*0.8, - (1-moonHeight)*facing*1.25, + (1-moonHeight)*facing*0.8, + (1-moonHeight)*facing*1.25, moonHeight); mRendering->getSkyManager()->setMasserDirection(masser); @@ -676,7 +677,7 @@ void WeatherManager::update(float duration) else if (sound == 1) soundname = WeatherGlobals::mThunderSoundID1; else if (sound == 2) soundname = WeatherGlobals::mThunderSoundID2; else if (sound == 3) soundname = WeatherGlobals::mThunderSoundID3; - mEnvironment->mSoundManager->playSound(soundname, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound(soundname, 1.0, 1.0); mThunderSoundDelay = 1000; } @@ -729,7 +730,7 @@ void WeatherManager::update(float duration) if (std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), ambientSnd) == mSoundsPlaying.end()) { mSoundsPlaying.push_back(ambientSnd); - mEnvironment->mSoundManager->playSound(ambientSnd, 1.0, 1.0, true); + MWBase::Environment::get().getSoundManager()->playSound(ambientSnd, 1.0, 1.0, true); } } @@ -740,7 +741,7 @@ void WeatherManager::update(float duration) if (std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), rainSnd) == mSoundsPlaying.end()) { mSoundsPlaying.push_back(rainSnd); - mEnvironment->mSoundManager->playSound(rainSnd, 1.0, 1.0, true); + MWBase::Environment::get().getSoundManager()->playSound(rainSnd, 1.0, 1.0, true); } } @@ -750,7 +751,7 @@ void WeatherManager::update(float duration) { if ( *it != ambientSnd && *it != rainSnd) { - mEnvironment->mSoundManager->stopSound(*it); + MWBase::Environment::get().getSoundManager()->stopSound(*it); it = mSoundsPlaying.erase(it); } else @@ -772,7 +773,7 @@ void WeatherManager::setDate(const int day, const int month) unsigned int WeatherManager::getWeatherID() const { // Source: http://www.uesp.net/wiki/Tes3Mod:GetCurrentWeather - + if (mCurrentWeather == "clear") return 0; else if (mCurrentWeather == "cloudy") @@ -793,7 +794,7 @@ unsigned int WeatherManager::getWeatherID() const return 8; else if (mCurrentWeather == "blizzard") return 9; - + else return 0; } diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index b9b40e6fa..5e0388751 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -11,8 +11,6 @@ namespace MWRender namespace MWWorld { - class Environment; - /// Global weather manager properties (according to INI) struct WeatherGlobals { @@ -67,8 +65,8 @@ namespace MWWorld Snow Gravity Scale=0.1 Snow High Kill=700 Snow Low Kill=150 - - + + [Moons] Masser Size=94 Masser Fade In Start=14 @@ -94,14 +92,14 @@ namespace MWWorld Secunda Moon Shadow Early Fade Angle=0.5 Script Color=255,20,20 */ - + static const float mSunriseTime; static const float mSunsetTime; static const float mSunriseDuration; static const float mSunsetDuration; - + static const float mWeatherUpdateTime; - + // morrowind sets these per-weather, but since they are only used by 'thunderstorm' // weather setting anyway, we can just as well set them globally static const float mThunderFrequency; @@ -119,154 +117,153 @@ namespace MWWorld Ogre::String mCloudTexture; Ogre::String mNextCloudTexture; float mCloudBlendFactor; - + Ogre::ColourValue mFogColor; - + Ogre::ColourValue mAmbientColor; - + Ogre::ColourValue mSkyColor; - + Ogre::ColourValue mSunColor; - + Ogre::ColourValue mSunDiscColor; - + float mFogDepth; - + float mWindSpeed; - + float mCloudSpeed; - + float mCloudOpacity; - + float mGlareView; - + bool mNight; // use night skybox float mNightFade; // fading factor for night skybox - + Ogre::String mAmbientLoopSoundID; }; - - + + /// Defines a single weather setting (according to INI) struct Weather { Ogre::String mCloudTexture; - - // Sky (atmosphere) colors + + // Sky (atmosphere) colors Ogre::ColourValue mSkySunriseColor, mSkyDayColor, mSkySunsetColor, mSkyNightColor; - + // Fog colors Ogre::ColourValue mFogSunriseColor, mFogDayColor, mFogSunsetColor, mFogNightColor; - + // Ambient lighting colors Ogre::ColourValue mAmbientSunriseColor, mAmbientDayColor, mAmbientSunsetColor, mAmbientNightColor; - + // Sun (directional) lighting colors Ogre::ColourValue mSunSunriseColor, mSunDayColor, mSunSunsetColor, mSunNightColor; - + // Fog depth/density float mLandFogDayDepth, mLandFogNightDepth; - + // Color modulation for the sun itself during sunset (not completely sure) Ogre::ColourValue mSunDiscSunsetColor; - + // Duration of weather transition (in days) float mTransitionDelta; - + // No idea what this one is used for? float mWindSpeed; - + // Cloud animation speed multiplier float mCloudSpeed; - + // Multiplier for clouds transparency float mCloudsMaximumPercent; - + // Value between 0 and 1, defines the strength of the sun glare effect float mGlareView; - + // Sound effect // This is used for Blight, Ashstorm and Blizzard (Bloodmoon) Ogre::String mAmbientLoopSoundID; - + // Rain sound effect Ogre::String mRainLoopSoundID; - + /// \todo disease chance }; - + /// /// Interface for weather settings /// class WeatherManager { public: - WeatherManager(MWRender::RenderingManager*, MWWorld::Environment*); - + WeatherManager(MWRender::RenderingManager*); + /** * Change the weather in the specified region * @param region that should be changed * @param ID of the weather setting to shift to */ void changeWeather(const std::string& region, const unsigned int id); - + /** * Per-frame update * @param duration */ void update(float duration); - + void setHour(const float hour); - + void setDate(const int day, const int month); - + unsigned int getWeatherID() const; - + private: float mHour; int mDay, mMonth; - + MWRender::RenderingManager* mRendering; - MWWorld::Environment* mEnvironment; - + std::map mWeatherSettings; std::map mRegionOverrides; std::vector mSoundsPlaying; - + Ogre::String mCurrentWeather; Ogre::String mNextWeather; - + std::string mCurrentRegion; - + bool mFirstUpdate; - + float mWeatherUpdateTime; - + float mRemainingTransitionTime; - + float mThunderFlash; float mThunderChance; float mThunderChanceNeeded; float mThunderSoundDelay; - + WeatherResult transition(const float factor); WeatherResult getResult(const Ogre::String& weather); - + void setWeather(const Ogre::String& weather, bool instant=false); }; } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 1c64039d4..66eedcb84 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -6,6 +6,8 @@ #include #include +#include "../mwbase/environment.hpp" + #include "../mwrender/sky.hpp" #include "../mwrender/player.hpp" @@ -15,7 +17,6 @@ #include "ptr.hpp" -#include "environment.hpp" #include "class.hpp" #include "player.hpp" #include "weather.hpp" @@ -174,18 +175,18 @@ namespace MWWorld World::World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, - const std::string& master, const boost::filesystem::path& resDir, - bool newGame, Environment& environment, const std::string& encoding, std::map fallbackMap) + const std::string& master, const boost::filesystem::path& resDir, bool newGame, + const std::string& encoding, std::map fallbackMap) : mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), - mSky (true), mEnvironment (environment), mNextDynamicRecord (0), mCells (mStore, mEsm, *this), + mSky (true), mNextDynamicRecord (0), mCells (mStore, mEsm, *this), mNumFacing(0) { mPhysics = new PhysicsSystem(renderer); mPhysEngine = mPhysics->getEngine(); - mRendering = new MWRender::RenderingManager(renderer, resDir, mPhysEngine, environment); + mRendering = new MWRender::RenderingManager(renderer, resDir, mPhysEngine); - mWeatherManager = new MWWorld::WeatherManager(mRendering, &environment); + mWeatherManager = new MWWorld::WeatherManager(mRendering); boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master)); @@ -209,7 +210,7 @@ namespace MWWorld mGlobalVariables->setInt ("chargenstate", 1); } - mWorldScene = new Scene(environment, this, *mRendering, mPhysics); + mWorldScene = new Scene(this, *mRendering, mPhysics); setFallbackValues(fallbackMap); @@ -357,7 +358,7 @@ namespace MWWorld //render->enable (reference.getRefData().getHandle()); if(mWorldScene->getActiveCells().find (reference.getCell()) != mWorldScene->getActiveCells().end()) - Class::get (reference).enable (reference, mEnvironment); + Class::get (reference).enable (reference); } @@ -372,8 +373,8 @@ namespace MWWorld //render->disable (reference.getRefData().getHandle()); if(mWorldScene->getActiveCells().find (reference.getCell())!=mWorldScene->getActiveCells().end()){ - Class::get (reference).disable (reference, mEnvironment); - mEnvironment.mSoundManager->stopSound3D (reference); + Class::get (reference).disable (reference); + MWBase::Environment::get().getSoundManager()->stopSound3D (reference); } @@ -547,7 +548,7 @@ namespace MWWorld if (mWorldScene->getActiveCells().find (ptr.getCell())!=mWorldScene->getActiveCells().end()){ // Class::get (ptr).disable (ptr, mEnvironment); /// \todo this line needs to be removed - mEnvironment.mSoundManager->stopSound3D (ptr); + MWBase::Environment::get().getSoundManager()->stopSound3D (ptr); mPhysics->removeObject (ptr.getRefData().getHandle()); mRendering->removeObject(ptr); diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 8dd370ad7..77e5bcef6 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -51,7 +51,6 @@ namespace MWRender namespace MWWorld { class WeatherManager; - class Environment; class Player; /// \brief The game world and its visual representation @@ -81,7 +80,6 @@ namespace MWWorld MWWorld::Globals *mGlobalVariables; MWWorld::PhysicsSystem *mPhysics; bool mSky; - Environment& mEnvironment; int mNextDynamicRecord; Cells mCells; @@ -111,7 +109,7 @@ namespace MWWorld World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, const std::string& master, const boost::filesystem::path& resDir, bool newGame, - Environment& environment, const std::string& encoding, std::map fallbackMap); + const std::string& encoding, std::map fallbackMap); ~World(); From 9f1199ee7e2e5e92c22a416ad5a707d9241b50d9 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 23 Apr 2012 15:29:15 +0200 Subject: [PATCH 079/109] removing a using directive from a header file --- apps/openmw/mwgui/dialogue.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 5b8439758..61e8c124c 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -18,8 +18,6 @@ namespace MWGui { class DialogueHistory; - using namespace MyGUI; - class DialogueWindow: public WindowBase { public: @@ -28,7 +26,7 @@ namespace MWGui void open(); // Events - typedef delegates::CMultiDelegate0 EventHandle_Void; + typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; /** Event : Dialog finished, OK button clicked.\n signature : void method()\n From f4428097f951d0c021bb46753e78cf8700c5aa27 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 23 Apr 2012 15:37:38 +0200 Subject: [PATCH 080/109] removing more cout spam --- apps/openmw/mwclass/npc.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c053ad130..afb904f51 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -105,10 +105,10 @@ namespace MWClass void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { - - + + renderingInterface.getActors().insertNPC(ptr, getInventoryStore(ptr)); - + } void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const @@ -296,7 +296,6 @@ namespace MWClass void Npc::registerSelf() { boost::shared_ptr instance (new Npc); - std::cout << "class npc:" << typeid (ESM::NPC).name(); registerClass (typeid (ESM::NPC).name(), instance); } } From d5e52e46ea58fb10bbe1cc9171f9aef428947b3f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 24 Apr 2012 09:19:41 +0200 Subject: [PATCH 081/109] removing even more cout spam (thanks to scrawl for finding this one) --- apps/openmw/mwworld/player.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index d24780ec1..5ed9aeaff 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -24,8 +24,6 @@ namespace MWWorld float* playerPos = mPlayer.mData.getPosition().pos; playerPos[0] = playerPos[1] = playerPos[2] = 0; - std::cout << renderer->getHandle(); - mPlayer.mData.setBaseNode(renderer->getNode()); /// \todo Do not make a copy of classes defined in esm/p records. mClass = new ESM::Class (*world.getStore().classes.find (player->cls)); From 4ce83badc9860cc965cbdf79c7d859517d16cc96 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 28 Apr 2012 20:42:53 +0200 Subject: [PATCH 082/109] flickering lights --- apps/openmw/mwrender/objects.cpp | 121 +++++++++++++++++----- apps/openmw/mwrender/objects.hpp | 33 ++++-- apps/openmw/mwrender/renderingmanager.cpp | 2 - apps/openmw/mwworld/weather.cpp | 1 - components/esm/loadligh.hpp | 2 +- 5 files changed, 122 insertions(+), 37 deletions(-) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index a79d72989..86a845a27 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -192,19 +192,43 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f Ogre::Light *light = mRenderer.getScene()->createLight(); light->setDiffuseColour (r, g, b); + ESMS::LiveCellRef *ref = + ptr.get(); + LightInfo info; info.name = light->getName(); info.radius = radius; info.colour = Ogre::ColourValue(r, g, b); - mLights.push_back(info); + if (ref->base->data.flags & ESM::Light::Negative) + info.colour *= -1; + info.interior = (ptr.getCell()->cell->data.flags & ESM::Cell::Interior); + + if (ref->base->data.flags & ESM::Light::Flicker) + info.type = LT_Flicker; + else if (ref->base->data.flags & ESM::Light::FlickerSlow) + info.type = LT_FlickerSlow; + else if (ref->base->data.flags & ESM::Light::Pulse) + info.type = LT_Pulse; + else if (ref->base->data.flags & ESM::Light::PulseSlow) + info.type = LT_PulseSlow; + else + info.type = LT_Normal; + + // random starting phase for the animation + info.time = Ogre::Math::RangeRandom(0, 2 * M_PI); + + // adjust the lights depending if we're in an interior or exterior cell + // quadratic means the light intensity falls off quite fast, resulting in a + // dark, atmospheric environment (perfect for exteriors) + // for interiors, we want more "warm" lights, so use linear attenuation. bool quadratic = false; if (!lightOutQuadInLin) quadratic = lightQuadratic; else { - quadratic = !mInterior; + quadratic = !info.interior; } if (!quadratic) @@ -221,6 +245,7 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f } insert->attachObject(light); + mLights.push_back(info); } bool Objects::deleteObject (const MWWorld::Ptr& ptr) @@ -329,17 +354,8 @@ void Objects::disableLights() } } -void Objects::setInterior(const bool interior) -{ - mInterior = interior; -} - void Objects::update(const float dt) { - // adjust the lights depending if we're in an interior or exterior cell - // quadratic means the light intensity falls off quite fast, resulting in a - // dark, atmospheric environment (perfect for exteriors) - // for interiors, we want more "warm" lights, so use linear attenuation. std::vector::iterator it = mLights.begin(); while (it != mLights.end()) { @@ -347,26 +363,77 @@ void Objects::update(const float dt) { Ogre::Light* light = mMwRoot->getCreator()->getLight(it->name); - bool quadratic = false; - if (!lightOutQuadInLin) - quadratic = lightQuadratic; - else - { - quadratic = !mInterior; - } + // Light animation (pulse & flicker) + it->time += dt; + const float phase = std::fmod(it->time, (32 * 2 * M_PI)) * 20; + float pulseConstant; - if (!quadratic) + // These formulas are just guesswork, but they work pretty well + if (it->type == LT_Normal) { - float radius = it->radius * lightLinearRadiusMult; - float attenuation = lightLinearValue / it->radius; - light->setAttenuation(radius*10, 0, attenuation, 0); + // Less than 1/255 light modifier for a constant light: + pulseConstant = (const float)(1.0 + sin(phase) / 255.0 ); + } + else if (it->type == LT_Flicker) + { + // Let's do a 50% -> 100% sine wave pulse over 1 second: + // This is 75% +/- 25% + pulseConstant = (const float)(0.75 + sin(phase) * 0.25); + + // Then add a 25% flicker variation: + it->resetTime -= dt; + if (it->resetTime < 0) + { + it->flickerVariation = (rand() % 1000) / 1000 * 0.25; + it->resetTime = 0.5; + } + if (it->resetTime > 0.25) + { + pulseConstant = (pulseConstant+it->flickerVariation) * (1-it->resetTime * 2.0f) + pulseConstant * it->resetTime * 2.0f; + } + else + { + pulseConstant = (pulseConstant+it->flickerVariation) * (it->resetTime * 2.0f) + pulseConstant * (1-it->resetTime * 2.0f); + } + } + else if (it->type == LT_FlickerSlow) + { + // Let's do a 50% -> 100% sine wave pulse over 1 second: + // This is 75% +/- 25% + pulseConstant = (const float)(0.75 + sin(phase / 4.0) * 0.25); + + // Then add a 25% flicker variation: + it->resetTime -= dt; + if (it->resetTime < 0) + { + it->flickerVariation = (rand() % 1000) / 1000 * 0.25; + it->resetTime = 0.5; + } + if (it->resetTime > 0.5) + { + pulseConstant = (pulseConstant+it->flickerVariation) * (1-it->resetTime) + pulseConstant * it->resetTime; + } + else + { + pulseConstant = (pulseConstant+it->flickerVariation) * (it->resetTime) + pulseConstant * (1-it->resetTime); + } + } + else if (it->type == LT_Pulse) + { + // Let's do a 75% -> 125% sine wave pulse over 1 second: + // This is 100% +/- 25% + pulseConstant = (const float)(1.0 + sin(phase) * 0.25); + } + else if (it->type == LT_PulseSlow) + { + // Let's do a 75% -> 125% sine wave pulse over 1 second: + // This is 100% +/- 25% + pulseConstant = (const float)(1.0 + sin(phase / 4.0) * 0.25); } else - { - float radius = it->radius * lightQuadraticRadiusMult; - float attenuation = lightQuadraticValue / pow(it->radius, 2); - light->setAttenuation(radius*10, 0, 0, attenuation); - } + assert(0 && "Invalid light type"); + + light->setDiffuseColour( it->colour * pulseConstant ); ++it; } diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index 63e639ef7..fb26808b9 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -11,11 +11,37 @@ namespace MWRender{ /// information about light needed for rendering +enum LightType +{ + // These are all mutually exclusive + LT_Normal=0, + LT_Flicker=1, + LT_FlickerSlow=2, + LT_Pulse=3, + LT_PulseSlow=4 +}; + struct LightInfo { + // Constants std::string name; // ogre handle Ogre::ColourValue colour; float radius; + bool interior; // Does this light belong to an interior or exterior cell + LightType type; + + // Runtime variables + float flickerVariation; // 25% flicker variation, reset once every 0.5 seconds + float flickerSlowVariation; // 25% flicker variation, reset once every 1.0 seconds + float resetTime; + long double time; + + + LightInfo() : + flickerVariation(0), resetTime(0.5), + flickerSlowVariation(0), time(0), interior(true) + { + } }; class Objects{ @@ -38,13 +64,11 @@ class Objects{ static bool lightOutQuadInLin; - bool mInterior; - void clearSceneNode (Ogre::SceneNode *node); ///< Remove all movable objects from \a node. public: - Objects(OEngine::Render::OgreRenderer& renderer): mRenderer (renderer), mInterior(true) {} + Objects(OEngine::Render::OgreRenderer& renderer): mRenderer (renderer) {} ~Objects(){} void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_); void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh); @@ -56,9 +80,6 @@ public: void update (const float dt); ///< per-frame update - void setInterior(const bool interior); - ///< call this to switch from interior to exterior or vice versa - Ogre::AxisAlignedBox getDimensions(MWWorld::Ptr::CellStore*); ///< get a bounding box that encloses all objects in the specified cell diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 6f6503a2e..a95a179c6 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -510,13 +510,11 @@ Shadows* RenderingManager::getShadows() void RenderingManager::switchToInterior() { - mObjects.setInterior(true); mRendering.getScene()->setCameraRelativeRendering(false); } void RenderingManager::switchToExterior() { - mObjects.setInterior(false); mRendering.getScene()->setCameraRelativeRendering(true); } diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 803fce1e1..bcbb96eec 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -522,7 +522,6 @@ void WeatherManager::update(float duration) // re-scale to 100 percent const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight;//+snow+blizzard; - srand(time(NULL)); float random = ((rand()%100)/100.f) * total; //if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) diff --git a/components/esm/loadligh.hpp b/components/esm/loadligh.hpp index 178258a05..9e7934b15 100644 --- a/components/esm/loadligh.hpp +++ b/components/esm/loadligh.hpp @@ -17,7 +17,7 @@ struct Light { Dynamic = 0x001, Carry = 0x002, // Can be carried - Negative = 0x004, // Negative light? + Negative = 0x004, // Negative light - i.e. darkness Flicker = 0x008, Fire = 0x010, OffDefault = 0x020, // Off by default From d1d21c8a0e48ac393883376d166cf6a5f190bb6c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 28 Apr 2012 21:21:40 +0200 Subject: [PATCH 083/109] compile fix --- apps/openmw/mwrender/objects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 86a845a27..5922086a0 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -365,7 +365,7 @@ void Objects::update(const float dt) // Light animation (pulse & flicker) it->time += dt; - const float phase = std::fmod(it->time, (32 * 2 * M_PI)) * 20; + const float phase = std::fmod(static_cast (it->time), (32 * 2 * M_PI)) * 20; float pulseConstant; // These formulas are just guesswork, but they work pretty well From af3ccd85e313d3d5e26b50a3ce9b745df6c3d894 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 28 Apr 2012 21:23:24 +0200 Subject: [PATCH 084/109] determine shield weight (tested with some light/medium/heavy shields) --- apps/openmw/mwclass/armor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 3a3403261..d4dab13d4 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -138,8 +138,7 @@ namespace MWClass case ESM::Armor::Boots: typeGmst = "iBootsWeight"; break; case ESM::Armor::LGauntlet: case ESM::Armor::RGauntlet: typeGmst = "iGauntletWeight"; break; -/// \todo how to determine if shield light, medium or heavy? -// case ESM::Armor::Shield: + case ESM::Armor::Shield: typeGmst = "iShieldWeight"; break; case ESM::Armor::LBracer: case ESM::Armor::RBracer: typeGmst = "iGauntletWeight"; break; } From cca39978d413205e83e548ac2e2050fbb9cbbc09 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 29 Apr 2012 17:46:09 +0200 Subject: [PATCH 085/109] changed messagebox text colors --- files/mygui/openmw_interactive_messagebox_layout.xml | 2 +- files/mygui/openmw_messagebox_layout.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/mygui/openmw_interactive_messagebox_layout.xml b/files/mygui/openmw_interactive_messagebox_layout.xml index 744f21227..b8a71c670 100644 --- a/files/mygui/openmw_interactive_messagebox_layout.xml +++ b/files/mygui/openmw_interactive_messagebox_layout.xml @@ -5,7 +5,7 @@ - + diff --git a/files/mygui/openmw_messagebox_layout.xml b/files/mygui/openmw_messagebox_layout.xml index 81d1c0a57..c99c00a49 100644 --- a/files/mygui/openmw_messagebox_layout.xml +++ b/files/mygui/openmw_messagebox_layout.xml @@ -8,7 +8,7 @@ - + From eca18f3e1d5d73c44ee0e05f39ce0d733524c927 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 29 Apr 2012 18:13:03 +0200 Subject: [PATCH 086/109] dialogue topic and choice sorting independent of case --- apps/openmw/mwdialogue/dialoguemanager.cpp | 20 +++++++++++++++++++- apps/openmw/mwgui/dialogue.cpp | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 24ee4ee7f..ac41244d1 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -54,6 +54,20 @@ namespace return lowerCase; } + bool stringCompareNoCase (std::string first, std::string second) + { + unsigned int i=0; + while ( (itolower(second[i])) return false; + ++i; + } + if (first.length() bool selectCompare (char comp, T1 value1, T2 value2) @@ -723,7 +737,11 @@ namespace MWDialogue } } } + + // sort again, because the previous sort was case-sensitive + keywordList.sort(stringCompareNoCase); win->setKeywords(keywordList); + mChoice = choice; } @@ -815,7 +833,7 @@ namespace MWDialogue { MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->askQuestion(question); - mChoiceMap[question] = choice; + mChoiceMap[toLower(question)] = choice; mIsInChoice = true; } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 2386cf9a3..960ead2ac 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -84,7 +84,7 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) UString key = history->getColorTextAt(cursorPosition); if(color == "#686EBA") MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(key)); - if(color == "#572D21") MWBase::Environment::get().getDialogueManager()->questionAnswered(key); + if(color == "#572D21") MWBase::Environment::get().getDialogueManager()->questionAnswered(lower_string(key)); } } From 397a97814510816284268ed3ef56714eace95324 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 29 Apr 2012 18:57:26 +0200 Subject: [PATCH 087/109] DispositionEdit tweaks --- files/mygui/openmw_dialogue_window_layout.xml | 2 +- files/mygui/openmw_dialogue_window_skin.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/files/mygui/openmw_dialogue_window_layout.xml b/files/mygui/openmw_dialogue_window_layout.xml index 29a3b511e..b0e437074 100644 --- a/files/mygui/openmw_dialogue_window_layout.xml +++ b/files/mygui/openmw_dialogue_window_layout.xml @@ -16,7 +16,7 @@ - + diff --git a/files/mygui/openmw_dialogue_window_skin.xml b/files/mygui/openmw_dialogue_window_skin.xml index ecdec8a5c..31ce626be 100644 --- a/files/mygui/openmw_dialogue_window_skin.xml +++ b/files/mygui/openmw_dialogue_window_skin.xml @@ -8,12 +8,12 @@ - - + + - + From f733382f749dc3d7755534adcb3f2db7bacee067 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 30 Apr 2012 00:57:41 +0200 Subject: [PATCH 088/109] tooltip now contains info about item enchantment --- apps/openmw/mwclass/armor.cpp | 2 + apps/openmw/mwclass/book.cpp | 2 + apps/openmw/mwclass/clothing.cpp | 2 + apps/openmw/mwclass/weapon.cpp | 30 +--------- apps/openmw/mwgui/dialogue.cpp | 10 +++- apps/openmw/mwgui/dialogue.hpp | 1 + apps/openmw/mwgui/tooltips.cpp | 83 +++++++++++++++++++++++++--- apps/openmw/mwgui/tooltips.hpp | 3 +- apps/openmw/mwgui/widgets.cpp | 35 +++++++++++- apps/openmw/mwgui/widgets.hpp | 21 ++++++- apps/openmw/mwgui/window_manager.cpp | 1 + files/mygui/openmw_text.skin.xml | 5 ++ 12 files changed, 153 insertions(+), 42 deletions(-) diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index a01b28a21..fb34e4c88 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -242,6 +242,8 @@ namespace MWClass text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); } + info.enchant = ref->base->enchant; + info.text = text; return info; diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index aa87b009b..ab659b480 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -130,6 +130,8 @@ namespace MWClass text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); } + info.enchant = ref->base->enchant; + info.text = text; return info; diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 669407d84..620b664cc 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -195,6 +195,8 @@ namespace MWClass text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); } + info.enchant = ref->base->enchant; + info.text = text; return info; diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 1caedce62..fcfaebcb7 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -328,35 +328,7 @@ namespace MWClass text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str); - // this should be going into a custom mygui widget MWEnchantment - /* - // enchantments - if (ref->base->enchant != "") - { - const ESM::Enchantment* enchant = environment.mWorld->getStore().enchants.search(ref->base->enchant); - if (enchant->data.type == ESM::Enchantment::CastOnce) - text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastOnce")->str; - else if (enchant->data.type == ESM::Enchantment::WhenStrikes) - text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastWhenStrikes")->str; - else if (enchant->data.type == ESM::Enchantment::WhenUsed) - text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastWhenUsed")->str; - else if (enchant->data.type == ESM::Enchantment::ConstantEffect) - text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastConstant")->str; - - if (enchant->data.type == ESM::Enchantment::WhenStrikes - || enchant->data.type == ESM::Enchantment::WhenUsed) - { - /// \todo store the current enchantment charge somewhere - // info.currentCharge = enchant->data.charge; - //info.totalCharge = enchant->data.charge; - } - } - */ - if (ref->base->enchant != "") - { - const ESM::Enchantment* enchant = store.enchants.search(ref->base->enchant); - info.enchant = enchant; - } + info.enchant = ref->base->enchant; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 2386cf9a3..aec405f46 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -50,9 +50,9 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager) //An EditBox cannot receive mouse click events, so we use an //invisible widget on top of the editbox to receive them - /// \todo scrolling the dialogue history with the mouse wheel doesn't work using this solution getWidget(eventbox, "EventBox"); eventbox->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked); + eventbox->eventMouseWheel += MyGUI::newDelegate(this, &DialogueWindow::onMouseWheel); //Topics list getWidget(topicsList, "TopicsList"); @@ -88,6 +88,14 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) } } +void DialogueWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel) +{ + if (history->getVScrollPosition() - _rel*0.3 < 0) + history->setVScrollPosition(0); + else + history->setVScrollPosition(history->getVScrollPosition() - _rel*0.3); +} + void DialogueWindow::open() { topicsList->removeAllItems(); diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 61e8c124c..5921ca57a 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -45,6 +45,7 @@ namespace MWGui void onSelectTopic(MyGUI::ListBox* _sender, size_t _index); void onByeClicked(MyGUI::Widget* _sender); void onHistoryClicked(MyGUI::Widget* _sender); + void onMouseWheel(MyGUI::Widget* _sender, int _rel); private: void updateOptions(); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index ef30b88d7..f5b140ec1 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -1,7 +1,10 @@ #include "tooltips.hpp" -#include "window_manager.hpp" +#include "window_manager.hpp" +#include "widgets.hpp" #include "../mwworld/class.hpp" +#include "../mwworld/world.hpp" +#include "../mwbase/environment.hpp" #include @@ -177,6 +180,21 @@ IntSize ToolTips::createToolTip(const ToolTipInfo& info) if (text.size() > 0 && text[0] == '\n') text.erase(0, 1); + const ESM::Enchantment* enchant; + const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + if (info.enchant != "") + { + enchant = store.enchants.search(info.enchant); + if (enchant->data.type == ESM::Enchantment::CastOnce) + text += "\n" + store.gameSettings.search("sItemCastOnce")->str; + else if (enchant->data.type == ESM::Enchantment::WhenStrikes) + text += "\n" + store.gameSettings.search("sItemCastWhenStrikes")->str; + else if (enchant->data.type == ESM::Enchantment::WhenUsed) + text += "\n" + store.gameSettings.search("sItemCastWhenUsed")->str; + else if (enchant->data.type == ESM::Enchantment::ConstantEffect) + text += "\n" + store.gameSettings.search("sItemCastConstant")->str; + } + // this the maximum width of the tooltip before it starts word-wrapping setCoord(0, 0, 300, 300); @@ -207,13 +225,55 @@ IntSize ToolTips::createToolTip(const ToolTipInfo& info) IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width + ((image != "") ? imageCaptionHPadding : 0)), ((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight ); - if (image != "") + if (info.enchant != "") { - ImageBox* imageWidget = mDynamicToolTipBox->createWidget("ImageBox", - IntCoord((totalSize.width - captionSize.width - imageCaptionHPadding)/2, 0, imageSize, imageSize), - Align::Left | Align::Top, "ToolTipImage"); - imageWidget->setImageTexture(realImage); - imageWidget->setPosition (imageWidget->getPosition() + padding); + Widget* enchantArea = mDynamicToolTipBox->createWidget("", + IntCoord(0, totalSize.height, 300, 300-totalSize.height), + Align::Stretch, "ToolTipEnchantArea"); + + IntCoord coord(0, 6, totalSize.width, 24); + + Widgets::MWEnchantmentPtr enchantWidget = enchantArea->createWidget + ("MW_StatName", coord, Align::Default, "ToolTipEnchantWidget"); + enchantWidget->setWindowManager(mWindowManager); + enchantWidget->setEnchantmentId(info.enchant); + + std::vector enchantEffectItems; + enchantWidget->createEffectWidgets(enchantEffectItems, enchantArea, coord, true, (enchant->data.type == ESM::Enchantment::ConstantEffect)); + totalSize.height += coord.top-6; + totalSize.width = std::max(totalSize.width, coord.width); + + if (enchant->data.type == ESM::Enchantment::WhenStrikes + || enchant->data.type == ESM::Enchantment::WhenUsed) + { + /// \todo store the current enchantment charge somewhere + int charge = enchant->data.charge; + + const int chargeWidth = 204; + + TextBox* chargeText = enchantArea->createWidget("SandText", IntCoord(0, 0, 10, 18), Align::Default, "ToolTipEnchantChargeText"); + chargeText->setCaption(store.gameSettings.search("sCharges")->str); + chargeText->setProperty("Static", "true"); + const int chargeTextWidth = chargeText->getTextSize().width + 5; + + const int chargeAndTextWidth = chargeWidth + chargeTextWidth; + chargeText->setCoord((totalSize.width - chargeAndTextWidth)/2, coord.top+6, chargeTextWidth, 18); + + IntCoord chargeCoord; + if (totalSize.width < chargeWidth) + { + totalSize.width = chargeWidth; + chargeCoord = IntCoord(0, coord.top+6, chargeWidth, 18); + } + else + { + chargeCoord = IntCoord((totalSize.width - chargeAndTextWidth)/2 + chargeTextWidth, coord.top+6, chargeWidth, 18); + } + Widgets::MWDynamicStatPtr chargeWidget = enchantArea->createWidget + ("MW_ChargeBar", chargeCoord, Align::Default, "ToolTipEnchantCharge"); + chargeWidget->setValue(charge, charge); + totalSize.height += 24; + } } captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize, @@ -224,6 +284,15 @@ IntSize ToolTips::createToolTip(const ToolTipInfo& info) captionWidget->setPosition (captionWidget->getPosition() + padding); textWidget->setPosition (textWidget->getPosition() + IntPoint(0, padding.top)); // only apply vertical padding, the horizontal works automatically due to Align::HCenter + if (image != "") + { + ImageBox* imageWidget = mDynamicToolTipBox->createWidget("ImageBox", + IntCoord((totalSize.width - captionSize.width - imageCaptionHPadding)/2, 0, imageSize, imageSize), + Align::Left | Align::Top, "ToolTipImage"); + imageWidget->setImageTexture(realImage); + imageWidget->setPosition (imageWidget->getPosition() + padding); + } + totalSize += IntSize(padding.left*2, padding.top*2); return totalSize; diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index c00faba86..fafe471a5 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -14,7 +14,6 @@ namespace MWGui { public: ToolTipInfo() : - enchant(0), effects(0) { }; @@ -24,7 +23,7 @@ namespace MWGui std::string icon; // enchantment (for cloth, armor, weapons) - const ESM::Enchantment* enchant; + std::string enchant; // effects (for potions, ingredients) const ESM::EffectList* effects; diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 58cfee991..769220f7b 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -238,6 +238,7 @@ void MWSpell::createEffectWidgets(std::vector &effects, MyGUI: effect->setSpellEffect(*it); effects.push_back(effect); coord.top += effect->getHeight(); + coord.width = std::max(coord.width, effect->getRequestedWidth()); } } @@ -278,22 +279,49 @@ void MWEnchantment::setEnchantmentId(const std::string &enchantId) updateWidgets(); } -void MWEnchantment::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord) +void MWEnchantment::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, bool constant) { const ESMS::ESMStore &store = mWindowManager->getStore(); const ESM::Enchantment *enchant = store.enchants.search(id); MYGUI_ASSERT(enchant, "enchantment with id '" << id << "' not found"); + // We don't know the width of all the elements beforehand, so we do it in + // 2 steps: first, create all widgets and check their width MWSpellEffectPtr effect = nullptr; std::vector::const_iterator end = enchant->effects.list.end(); + int maxwidth = coord.width; for (std::vector::const_iterator it = enchant->effects.list.begin(); it != end; ++it) { effect = creator->createWidget("MW_EffectImage", coord, MyGUI::Align::Default); effect->setWindowManager(mWindowManager); effect->setSpellEffect(*it); + effect->setConstant(constant); effects.push_back(effect); + + if (effect->getRequestedWidth() > maxwidth) + maxwidth = effect->getRequestedWidth(); + coord.top += effect->getHeight(); } + + // then adjust the size for all widgets + for (std::vector::iterator it = effects.begin(); it != effects.end(); ++it) + { + effect = static_cast(*it); + bool needcenter = center && (maxwidth > effect->getRequestedWidth()); + int diff = maxwidth - effect->getRequestedWidth(); + if (needcenter) + { + effect->setCoord(diff/2, effect->getCoord().top, effect->getRequestedWidth(), effect->getCoord().height); + } + else + { + effect->setCoord(0, effect->getCoord().top, effect->getRequestedWidth(), effect->getCoord().height); + } + } + + // inform the parent about width + coord.width = maxwidth; } void MWEnchantment::updateWidgets() @@ -315,6 +343,8 @@ MWSpellEffect::MWSpellEffect() : mWindowManager(nullptr) , imageWidget(nullptr) , textWidget(nullptr) + , mRequestedWidth(0) + , mIsConstant(0) { } @@ -366,7 +396,7 @@ void MWSpellEffect::updateWidgets() spellLine += " " + boost::lexical_cast(effect.magnMin) + " " + ((effect.magnMin == 1) ? pt : pts); else { - spellLine += " " + boost::lexical_cast(effect.magnMin) + to + boost::lexical_cast(effect.magnMin) + " " + pts; + spellLine += " " + boost::lexical_cast(effect.magnMin) + to + boost::lexical_cast(effect.magnMax) + " " + pts; } } @@ -388,6 +418,7 @@ void MWSpellEffect::updateWidgets() } static_cast(textWidget)->setCaption(spellLine); + mRequestedWidth = textWidget->getTextSize().width + 24; } else static_cast(textWidget)->setCaption(""); diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index 8ac27795d..b4915ac6a 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -119,6 +119,14 @@ namespace MWGui void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; } void setSpellId(const std::string &id); + + /** + * @param vector to store the created effect widgets + * @param parent widget + * @param coordinates to use, will be expanded if more space is needed + * @param spell category, if this is 0, this means the spell effects are permanent and won't display e.g. duration + * @param center the effect widgets horizontally + */ void createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, const int category); const std::string &getSpellId() const { return id; } @@ -147,7 +155,15 @@ namespace MWGui void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; } void setEnchantmentId(const std::string &enchantId); - void createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord); + + /** + * @param vector to store the created effect widgets + * @param parent widget + * @param coordinates to use, will be expanded if more space is needed + * @param center the effect widgets horizontally + * @param are the effects of this enchantment constant? + */ + void createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, bool constant); const std::string &getSpellId() const { return id; } @@ -180,6 +196,8 @@ namespace MWGui const SpellEffectValue &getSpellEffect() const { return effect; } + int getRequestedWidth() const { return mRequestedWidth; } + protected: virtual ~MWSpellEffect(); @@ -194,6 +212,7 @@ namespace MWGui bool mIsConstant; // constant effect MyGUI::ImageBox* imageWidget; MyGUI::TextBox* textWidget; + int mRequestedWidth; }; typedef MWSpellEffect* MWSpellEffectPtr; diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index a3e44f65b..ccf558de5 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -104,6 +104,7 @@ WindowManager::WindowManager( MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); diff --git a/files/mygui/openmw_text.skin.xml b/files/mygui/openmw_text.skin.xml index 9f87c93b3..36d97e153 100644 --- a/files/mygui/openmw_text.skin.xml +++ b/files/mygui/openmw_text.skin.xml @@ -93,6 +93,11 @@ + + + + + From b82c39c8be6976e3386b413e4a49298dd6e49e3a Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 30 Apr 2012 01:08:10 +0200 Subject: [PATCH 089/109] renamed Widgets::MWEnchantment to Widgets::MWEffectList so it can be reused for potion effects --- apps/openmw/mwclass/potion.cpp | 2 ++ apps/openmw/mwgui/tooltips.cpp | 2 +- apps/openmw/mwgui/widgets.cpp | 14 +++++++------- apps/openmw/mwgui/widgets.hpp | 10 +++++----- apps/openmw/mwgui/window_manager.cpp | 2 +- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 12ce622ee..edf82cee4 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -124,6 +124,8 @@ namespace MWClass text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str); + ESM::EffectList list = ref->base->effects; + if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); text += MWGui::ToolTips::getMiscString(ref->base->script, "Script"); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index f5b140ec1..0cab26b2c 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -233,7 +233,7 @@ IntSize ToolTips::createToolTip(const ToolTipInfo& info) IntCoord coord(0, 6, totalSize.width, 24); - Widgets::MWEnchantmentPtr enchantWidget = enchantArea->createWidget + Widgets::MWEffectListPtr enchantWidget = enchantArea->createWidget ("MW_StatName", coord, Align::Default, "ToolTipEnchantWidget"); enchantWidget->setWindowManager(mWindowManager); enchantWidget->setEnchantmentId(info.enchant); diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 769220f7b..f327a9c1e 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -266,20 +266,20 @@ MWSpell::~MWSpell() { } -/* MWEnchantment */ +/* MWEffectList */ -MWEnchantment::MWEnchantment() +MWEffectList::MWEffectList() : mWindowManager(nullptr) { } -void MWEnchantment::setEnchantmentId(const std::string &enchantId) +void MWEffectList::setEnchantmentId(const std::string &enchantId) { id = enchantId; updateWidgets(); } -void MWEnchantment::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, bool constant) +void MWEffectList::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, bool constant) { const ESMS::ESMStore &store = mWindowManager->getStore(); const ESM::Enchantment *enchant = store.enchants.search(id); @@ -324,16 +324,16 @@ void MWEnchantment::createEffectWidgets(std::vector &effects, coord.width = maxwidth; } -void MWEnchantment::updateWidgets() +void MWEffectList::updateWidgets() { } -void MWEnchantment::initialiseOverride() +void MWEffectList::initialiseOverride() { Base::initialiseOverride(); } -MWEnchantment::~MWEnchantment() +MWEffectList::~MWEffectList() { } diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index b4915ac6a..51ad51678 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -145,11 +145,11 @@ namespace MWGui }; typedef MWSpell* MWSpellPtr; - class MYGUI_EXPORT MWEnchantment : public Widget + class MYGUI_EXPORT MWEffectList : public Widget { - MYGUI_RTTI_DERIVED( MWEnchantment ); + MYGUI_RTTI_DERIVED( MWEffectList ); public: - MWEnchantment(); + MWEffectList(); typedef MWMechanics::Stat EnchantmentValue; @@ -168,7 +168,7 @@ namespace MWGui const std::string &getSpellId() const { return id; } protected: - virtual ~MWEnchantment(); + virtual ~MWEffectList(); virtual void initialiseOverride(); @@ -178,7 +178,7 @@ namespace MWGui WindowManager* mWindowManager; std::string id; }; - typedef MWEnchantment* MWEnchantmentPtr; + typedef MWEffectList* MWEffectListPtr; class MYGUI_EXPORT MWSpellEffect : public Widget { diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index ccf558de5..0f2df53e1 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -104,7 +104,7 @@ WindowManager::WindowManager( MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); From 22f524f8d52408bbca31af711b745889ef32ad1f Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 30 Apr 2012 01:53:22 +0200 Subject: [PATCH 090/109] potion effects in tooltip --- apps/openmw/mwclass/potion.cpp | 2 +- apps/openmw/mwgui/birth.cpp | 2 +- apps/openmw/mwgui/tooltips.cpp | 30 ++++++++++++++- apps/openmw/mwgui/widgets.cpp | 70 ++++++++++++++++++++-------------- apps/openmw/mwgui/widgets.hpp | 20 ++++++---- 5 files changed, 84 insertions(+), 40 deletions(-) diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index edf82cee4..07e7663b3 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -124,7 +124,7 @@ namespace MWClass text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight); text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str); - ESM::EffectList list = ref->base->effects; + info.effects = &ref->base->effects; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner"); diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 046017204..cb15eaf15 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -202,7 +202,7 @@ void BirthDialog::updateSpells() MyGUI::IntCoord spellCoord = coord; spellCoord.height = 24; // TODO: This should be fetched from the skin somehow, or perhaps a widget in the layout as a template? - spellWidget->createEffectWidgets(spellItems, spellArea, spellCoord, category); + spellWidget->createEffectWidgets(spellItems, spellArea, spellCoord, (category == 0) ? MWEffectList::EF_Constant : 0); coord.top = spellCoord.top; ++i; diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 0cab26b2c..90b5baa67 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -225,6 +225,31 @@ IntSize ToolTips::createToolTip(const ToolTipInfo& info) IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width + ((image != "") ? imageCaptionHPadding : 0)), ((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight ); + if (info.effects != 0) + { + Widget* effectArea = mDynamicToolTipBox->createWidget("", + IntCoord(0, totalSize.height, 300, 300-totalSize.height), + Align::Stretch, "ToolTipEffectArea"); + + IntCoord coord(0, 6, totalSize.width, 24); + + /** + * \todo + * the various potion effects should appear in the tooltip depending if the player + * has enough skill in alchemy to know about the effects of this potion. + */ + + Widgets::MWEffectListPtr effectsWidget = effectArea->createWidget + ("MW_StatName", coord, Align::Default, "ToolTipEffectsWidget"); + effectsWidget->setWindowManager(mWindowManager); + effectsWidget->setEffectList(info.effects); + + std::vector effectItems; + effectsWidget->createEffectWidgets(effectItems, effectArea, coord, true, Widgets::MWEffectList::EF_Potion); + totalSize.height += coord.top-6; + totalSize.width = std::max(totalSize.width, coord.width); + } + if (info.enchant != "") { Widget* enchantArea = mDynamicToolTipBox->createWidget("", @@ -236,10 +261,11 @@ IntSize ToolTips::createToolTip(const ToolTipInfo& info) Widgets::MWEffectListPtr enchantWidget = enchantArea->createWidget ("MW_StatName", coord, Align::Default, "ToolTipEnchantWidget"); enchantWidget->setWindowManager(mWindowManager); - enchantWidget->setEnchantmentId(info.enchant); + enchantWidget->setEffectList(&enchant->effects); std::vector enchantEffectItems; - enchantWidget->createEffectWidgets(enchantEffectItems, enchantArea, coord, true, (enchant->data.type == ESM::Enchantment::ConstantEffect)); + int flag = (enchant->data.type == ESM::Enchantment::ConstantEffect) ? Widgets::MWEffectList::EF_Constant : 0; + enchantWidget->createEffectWidgets(enchantEffectItems, enchantArea, coord, true, flag); totalSize.height += coord.top-6; totalSize.width = std::max(totalSize.width, coord.width); diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index f327a9c1e..2f5af6473 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -222,7 +222,7 @@ void MWSpell::setSpellId(const std::string &spellId) updateWidgets(); } -void MWSpell::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, const int category) +void MWSpell::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags) { const ESMS::ESMStore &store = mWindowManager->getStore(); const ESM::Spell *spell = store.spells.search(id); @@ -234,7 +234,7 @@ void MWSpell::createEffectWidgets(std::vector &effects, MyGUI: { effect = creator->createWidget("MW_EffectImage", coord, MyGUI::Align::Default); effect->setWindowManager(mWindowManager); - effect->setConstant(category == 0); + effect->setFlags(flags); effect->setSpellEffect(*it); effects.push_back(effect); coord.top += effect->getHeight(); @@ -270,32 +270,29 @@ MWSpell::~MWSpell() MWEffectList::MWEffectList() : mWindowManager(nullptr) + , mEffectList(0) { } -void MWEffectList::setEnchantmentId(const std::string &enchantId) +void MWEffectList::setEffectList(const ESM::EffectList* list) { - id = enchantId; + mEffectList = list; updateWidgets(); } -void MWEffectList::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, bool constant) +void MWEffectList::createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, int flags) { - const ESMS::ESMStore &store = mWindowManager->getStore(); - const ESM::Enchantment *enchant = store.enchants.search(id); - MYGUI_ASSERT(enchant, "enchantment with id '" << id << "' not found"); - // We don't know the width of all the elements beforehand, so we do it in // 2 steps: first, create all widgets and check their width MWSpellEffectPtr effect = nullptr; - std::vector::const_iterator end = enchant->effects.list.end(); + std::vector::const_iterator end = mEffectList->list.end(); int maxwidth = coord.width; - for (std::vector::const_iterator it = enchant->effects.list.begin(); it != end; ++it) + for (std::vector::const_iterator it = mEffectList->list.begin(); it != end; ++it) { effect = creator->createWidget("MW_EffectImage", coord, MyGUI::Align::Default); effect->setWindowManager(mWindowManager); + effect->setFlags(flags); effect->setSpellEffect(*it); - effect->setConstant(constant); effects.push_back(effect); if (effect->getRequestedWidth() > maxwidth) @@ -344,7 +341,7 @@ MWSpellEffect::MWSpellEffect() , imageWidget(nullptr) , textWidget(nullptr) , mRequestedWidth(0) - , mIsConstant(0) + , mFlags(0) { } @@ -359,6 +356,18 @@ void MWSpellEffect::updateWidgets() if (!mWindowManager) return; + // lists effects that have no magnitude (e.g. invisiblity) + /// \todo this list is probably incomplete + std::vector effectsWithoutMagnitude; + effectsWithoutMagnitude.push_back("sEffectInvisibility"); + effectsWithoutMagnitude.push_back("sEffectStuntedMagicka"); + effectsWithoutMagnitude.push_back("sEffectParalyze"); + + // lists effects that have no duration (e.g. open lock) + /// \todo this list is probably incomplete + std::vector effectsWithoutDuration; + effectsWithoutDuration.push_back("sEffectOpen"); + const ESMS::ESMStore &store = mWindowManager->getStore(); const ESM::MagicEffect *magicEffect = store.magicEffects.search(effect.effectID); if (textWidget) @@ -371,7 +380,8 @@ void MWSpellEffect::updateWidgets() std::string sec = " " + mWindowManager->getGameSettingString("ssecond", ""); std::string secs = " " + mWindowManager->getGameSettingString("sseconds", ""); - std::string spellLine = effectIDToString(effect.effectID); + std::string effectIDStr = effectIDToString(effect.effectID); + std::string spellLine = mWindowManager->getGameSettingString(effectIDStr, ""); if (effect.skill >= 0 && effect.skill < ESM::Skill::Length) { spellLine += " " + mWindowManager->getGameSettingString(ESM::Skill::sSkillNameIds[effect.skill], ""); @@ -390,7 +400,9 @@ void MWSpellEffect::updateWidgets() }; spellLine += " " + mWindowManager->getGameSettingString(attributes[effect.attribute], ""); } - if (effect.magnMin >= 0 || effect.magnMax >= 0) + + bool hasMagnitude = (std::find(effectsWithoutMagnitude.begin(), effectsWithoutMagnitude.end(), effectIDStr) == effectsWithoutMagnitude.end()); + if ((effect.magnMin >= 0 || effect.magnMax >= 0) && hasMagnitude) { if (effect.magnMin == effect.magnMax) spellLine += " " + boost::lexical_cast(effect.magnMin) + " " + ((effect.magnMin == 1) ? pt : pts); @@ -401,20 +413,25 @@ void MWSpellEffect::updateWidgets() } // constant effects have no duration and no target - if (!mIsConstant) + if (!(mFlags & MWEffectList::EF_Constant)) { - if (effect.duration >= 0) + bool hasDuration = (std::find(effectsWithoutDuration.begin(), effectsWithoutDuration.end(), effectIDStr) == effectsWithoutDuration.end()); + if (effect.duration >= 0 && hasDuration) { spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast(effect.duration) + ((effect.duration == 1) ? sec : secs); } - std::string on = mWindowManager->getGameSettingString("sonword", ""); - if (effect.range == ESM::RT_Self) - spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeSelf", ""); - else if (effect.range == ESM::RT_Touch) - spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTouch", ""); - else if (effect.range == ESM::RT_Target) - spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTarget", ""); + // potions have no target + if (!(mFlags & MWEffectList::EF_Potion)) + { + std::string on = mWindowManager->getGameSettingString("sonword", ""); + if (effect.range == ESM::RT_Self) + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeSelf", ""); + else if (effect.range == ESM::RT_Touch) + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTouch", ""); + else if (effect.range == ESM::RT_Target) + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTarget", ""); + } } static_cast(textWidget)->setCaption(spellLine); @@ -574,11 +591,8 @@ std::string MWSpellEffect::effectIDToString(const short effectID) names[30] ="sEffectWeaknesstoShock"; assert(names.find(effectID) != names.end() && "Unimplemented effect type"); - std::string res = mWindowManager->getGameSettingString(names[effectID], ""); - if (res == "") - std::cout << "Warning: Unknown effect name " << names[effectID] << std::endl; - return res; + return names[effectID]; } MWSpellEffect::~MWSpellEffect() diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index 51ad51678..a1caa3c94 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -153,19 +153,23 @@ namespace MWGui typedef MWMechanics::Stat EnchantmentValue; + enum EffectFlags + { + EF_Potion = 0x01, // potions have no target (target is always the player) + EF_Constant = 0x02 // constant effect means that duration will not be displayed + }; + void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; } - void setEnchantmentId(const std::string &enchantId); + void setEffectList(const ESM::EffectList* list); /** * @param vector to store the created effect widgets * @param parent widget * @param coordinates to use, will be expanded if more space is needed * @param center the effect widgets horizontally - * @param are the effects of this enchantment constant? + * @param various flags, see MWEffectList::EffectFlags */ - void createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, bool constant); - - const std::string &getSpellId() const { return id; } + void createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, bool center, int flags); protected: virtual ~MWEffectList(); @@ -176,7 +180,7 @@ namespace MWGui void updateWidgets(); WindowManager* mWindowManager; - std::string id; + const ESM::EffectList* mEffectList; }; typedef MWEffectList* MWEffectListPtr; @@ -190,7 +194,7 @@ namespace MWGui void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; } void setSpellEffect(SpellEffectValue value); - void setConstant(bool constant) { mIsConstant = constant; } + void setFlags(int flags) { mFlags = flags; } std::string effectIDToString(const short effectID); @@ -209,7 +213,7 @@ namespace MWGui WindowManager* mWindowManager; SpellEffectValue effect; - bool mIsConstant; // constant effect + int mFlags; MyGUI::ImageBox* imageWidget; MyGUI::TextBox* textWidget; int mRequestedWidth; From 2f0a69160cffefdba93a70eb9aa5f818e0237643 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 30 Apr 2012 02:10:55 +0200 Subject: [PATCH 091/109] small fix --- apps/openmw/mwgui/widgets.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index a1caa3c94..c0e62533d 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -125,9 +125,9 @@ namespace MWGui * @param parent widget * @param coordinates to use, will be expanded if more space is needed * @param spell category, if this is 0, this means the spell effects are permanent and won't display e.g. duration - * @param center the effect widgets horizontally + * @param various flags, see MWEffectList::EffectFlags */ - void createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, const int category); + void createEffectWidgets(std::vector &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags); const std::string &getSpellId() const { return id; } From ea275a8aa85c6952e015a85e5fe5e30d0deced3d Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 30 Apr 2012 18:11:34 +0200 Subject: [PATCH 092/109] extended the list of spells with no magnitude / no duration --- apps/openmw/mwgui/widgets.cpp | 100 ++++++++++++++++++++++++++++------ apps/openmw/mwgui/widgets.hpp | 2 + 2 files changed, 86 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 2f5af6473..0af035d31 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -356,18 +356,6 @@ void MWSpellEffect::updateWidgets() if (!mWindowManager) return; - // lists effects that have no magnitude (e.g. invisiblity) - /// \todo this list is probably incomplete - std::vector effectsWithoutMagnitude; - effectsWithoutMagnitude.push_back("sEffectInvisibility"); - effectsWithoutMagnitude.push_back("sEffectStuntedMagicka"); - effectsWithoutMagnitude.push_back("sEffectParalyze"); - - // lists effects that have no duration (e.g. open lock) - /// \todo this list is probably incomplete - std::vector effectsWithoutDuration; - effectsWithoutDuration.push_back("sEffectOpen"); - const ESMS::ESMStore &store = mWindowManager->getStore(); const ESM::MagicEffect *magicEffect = store.magicEffects.search(effect.effectID); if (textWidget) @@ -401,8 +389,7 @@ void MWSpellEffect::updateWidgets() spellLine += " " + mWindowManager->getGameSettingString(attributes[effect.attribute], ""); } - bool hasMagnitude = (std::find(effectsWithoutMagnitude.begin(), effectsWithoutMagnitude.end(), effectIDStr) == effectsWithoutMagnitude.end()); - if ((effect.magnMin >= 0 || effect.magnMax >= 0) && hasMagnitude) + if ((effect.magnMin >= 0 || effect.magnMax >= 0) && effectHasMagnitude(effectIDStr)) { if (effect.magnMin == effect.magnMax) spellLine += " " + boost::lexical_cast(effect.magnMin) + " " + ((effect.magnMin == 1) ? pt : pts); @@ -415,8 +402,7 @@ void MWSpellEffect::updateWidgets() // constant effects have no duration and no target if (!(mFlags & MWEffectList::EF_Constant)) { - bool hasDuration = (std::find(effectsWithoutDuration.begin(), effectsWithoutDuration.end(), effectIDStr) == effectsWithoutDuration.end()); - if (effect.duration >= 0 && hasDuration) + if (effect.duration >= 0 && effectHasDuration(effectIDStr)) { spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast(effect.duration) + ((effect.duration == 1) ? sec : secs); } @@ -590,11 +576,93 @@ std::string MWSpellEffect::effectIDToString(const short effectID) names[35] ="sEffectWeaknesstoPoison"; names[30] ="sEffectWeaknesstoShock"; + /// \todo bloodmoon and tribunal spells - can't find the IDs anywhere? + assert(names.find(effectID) != names.end() && "Unimplemented effect type"); return names[effectID]; } +bool MWSpellEffect::effectHasDuration(const std::string& effect) +{ + // lists effects that have no duration (e.g. open lock) + std::vector effectsWithoutDuration; + effectsWithoutDuration.push_back("sEffectOpen"); + effectsWithoutDuration.push_back("sOpen"); + effectsWithoutDuration.push_back("sLock"); + effectsWithoutDuration.push_back("sDispel"); + effectsWithoutDuration.push_back("sSunDamage"); + effectsWithoutDuration.push_back("sCorprus"); + effectsWithoutDuration.push_back("sVampirism"); + effectsWithoutDuration.push_back("sMark"); + effectsWithoutDuration.push_back("sRecall"); + effectsWithoutDuration.push_back("sDivineIntervention"); + effectsWithoutDuration.push_back("sAlmsiviIntervention"); + effectsWithoutDuration.push_back("sCureCommonDisease"); + effectsWithoutDuration.push_back("sCureBlightDisease"); + effectsWithoutDuration.push_back("sCureCorprusDisease"); + effectsWithoutDuration.push_back("sCurePoison"); + effectsWithoutDuration.push_back("sCureParalyzation"); + effectsWithoutDuration.push_back("sRemoveCurse"); + + return (std::find(effectsWithoutDuration.begin(), effectsWithoutDuration.end(), effect) == effectsWithoutDuration.end()); +} + +bool MWSpellEffect::effectHasMagnitude(const std::string& effect) +{ + // lists effects that have no magnitude (e.g. invisiblity) + std::vector effectsWithoutMagnitude; + effectsWithoutMagnitude.push_back("sEffectInvisibility"); + effectsWithoutMagnitude.push_back("sEffectStuntedMagicka"); + effectsWithoutMagnitude.push_back("sEffectParalyze"); + effectsWithoutMagnitude.push_back("sSoultrap"); + effectsWithoutMagnitude.push_back("sSilence"); + effectsWithoutMagnitude.push_back("sParalyze"); + effectsWithoutMagnitude.push_back("sInvisibility"); + effectsWithoutMagnitude.push_back("sWaterWalking"); + effectsWithoutMagnitude.push_back("sWaterBreathing"); + effectsWithoutMagnitude.push_back("sSummonScamp"); + effectsWithoutMagnitude.push_back("sSummonClannfear"); + effectsWithoutMagnitude.push_back("sSummonDaedroth"); + effectsWithoutMagnitude.push_back("sSummonDremora"); + effectsWithoutMagnitude.push_back("sSummonAncestralGhost"); + effectsWithoutMagnitude.push_back("sSummonSkeletalMinion"); + effectsWithoutMagnitude.push_back("sSummonBonewalker"); + effectsWithoutMagnitude.push_back("sSummonGreaterBonewalker"); + effectsWithoutMagnitude.push_back("sSummonBonelord"); + effectsWithoutMagnitude.push_back("sSummonWingedTwilight"); + effectsWithoutMagnitude.push_back("sSummonHunger"); + effectsWithoutMagnitude.push_back("sSummonGoldenSaint"); + effectsWithoutMagnitude.push_back("sSummonFlameAtronach"); + effectsWithoutMagnitude.push_back("sSummonFrostAtronach"); + effectsWithoutMagnitude.push_back("sSummonStormAtronach"); + effectsWithoutMagnitude.push_back("sSummonCenturionSphere"); + effectsWithoutMagnitude.push_back("sBoundDagger"); + effectsWithoutMagnitude.push_back("sBoundLongsword"); + effectsWithoutMagnitude.push_back("sBoundMace"); + effectsWithoutMagnitude.push_back("sBoundBattleAxe"); + effectsWithoutMagnitude.push_back("sBoundSpear"); + effectsWithoutMagnitude.push_back("sBoundLongbow"); + effectsWithoutMagnitude.push_back("sBoundCuirass"); + effectsWithoutMagnitude.push_back("sBoundHelm"); + effectsWithoutMagnitude.push_back("sBoundBoots"); + effectsWithoutMagnitude.push_back("sBoundShield"); + effectsWithoutMagnitude.push_back("sBoundGloves"); + effectsWithoutMagnitude.push_back("sStuntedMagicka"); + effectsWithoutMagnitude.push_back("sMark"); + effectsWithoutMagnitude.push_back("sRecall"); + effectsWithoutMagnitude.push_back("sDivineIntervention"); + effectsWithoutMagnitude.push_back("sAlmsiviIntervention"); + effectsWithoutMagnitude.push_back("sCureCommonDisease"); + effectsWithoutMagnitude.push_back("sCureBlightDisease"); + effectsWithoutMagnitude.push_back("sCureCorprusDisease"); + effectsWithoutMagnitude.push_back("sCurePoison"); + effectsWithoutMagnitude.push_back("sCureParalyzation"); + effectsWithoutMagnitude.push_back("sRemoveCurse"); + + return (std::find(effectsWithoutMagnitude.begin(), effectsWithoutMagnitude.end(), effect) == effectsWithoutMagnitude.end()); +} + MWSpellEffect::~MWSpellEffect() { } diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index c0e62533d..74da7fc93 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -197,6 +197,8 @@ namespace MWGui void setFlags(int flags) { mFlags = flags; } std::string effectIDToString(const short effectID); + bool effectHasMagnitude (const std::string& effect); + bool effectHasDuration (const std::string& effect); const SpellEffectValue &getSpellEffect() const { return effect; } From fc06dc72c9f94774851452747d0993b6722c39ed Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 30 Apr 2012 18:20:44 +0200 Subject: [PATCH 093/109] small fix --- apps/openmw/mwgui/widgets.cpp | 120 +++++++++++++++++----------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 0af035d31..3c7f33ecd 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -588,22 +588,22 @@ bool MWSpellEffect::effectHasDuration(const std::string& effect) // lists effects that have no duration (e.g. open lock) std::vector effectsWithoutDuration; effectsWithoutDuration.push_back("sEffectOpen"); - effectsWithoutDuration.push_back("sOpen"); - effectsWithoutDuration.push_back("sLock"); - effectsWithoutDuration.push_back("sDispel"); - effectsWithoutDuration.push_back("sSunDamage"); - effectsWithoutDuration.push_back("sCorprus"); - effectsWithoutDuration.push_back("sVampirism"); - effectsWithoutDuration.push_back("sMark"); - effectsWithoutDuration.push_back("sRecall"); - effectsWithoutDuration.push_back("sDivineIntervention"); - effectsWithoutDuration.push_back("sAlmsiviIntervention"); - effectsWithoutDuration.push_back("sCureCommonDisease"); - effectsWithoutDuration.push_back("sCureBlightDisease"); - effectsWithoutDuration.push_back("sCureCorprusDisease"); - effectsWithoutDuration.push_back("sCurePoison"); - effectsWithoutDuration.push_back("sCureParalyzation"); - effectsWithoutDuration.push_back("sRemoveCurse"); + effectsWithoutDuration.push_back("sEffectLock"); + effectsWithoutDuration.push_back("sEffectDispel"); + effectsWithoutDuration.push_back("sEffectSunDamage"); + effectsWithoutDuration.push_back("sEffectCorpus"); + effectsWithoutDuration.push_back("sEffectVampirism"); + effectsWithoutDuration.push_back("sEffectMark"); + effectsWithoutDuration.push_back("sEffectRecall"); + effectsWithoutDuration.push_back("sEffectDivineIntervention"); + effectsWithoutDuration.push_back("sEffectAlmsiviIntervention"); + effectsWithoutDuration.push_back("sEffectCureCommonDisease"); + effectsWithoutDuration.push_back("sEffectCureBlightDisease"); + effectsWithoutDuration.push_back("sEffectCureCorprusDisease"); + effectsWithoutDuration.push_back("sEffectCurePoison"); + effectsWithoutDuration.push_back("sEffectCureParalyzation"); + effectsWithoutDuration.push_back("sEffectRemoveCurse"); + effectsWithoutDuration.push_back("sEffectRestoreAttribute"); return (std::find(effectsWithoutDuration.begin(), effectsWithoutDuration.end(), effect) == effectsWithoutDuration.end()); } @@ -615,50 +615,50 @@ bool MWSpellEffect::effectHasMagnitude(const std::string& effect) effectsWithoutMagnitude.push_back("sEffectInvisibility"); effectsWithoutMagnitude.push_back("sEffectStuntedMagicka"); effectsWithoutMagnitude.push_back("sEffectParalyze"); - effectsWithoutMagnitude.push_back("sSoultrap"); - effectsWithoutMagnitude.push_back("sSilence"); - effectsWithoutMagnitude.push_back("sParalyze"); - effectsWithoutMagnitude.push_back("sInvisibility"); - effectsWithoutMagnitude.push_back("sWaterWalking"); - effectsWithoutMagnitude.push_back("sWaterBreathing"); - effectsWithoutMagnitude.push_back("sSummonScamp"); - effectsWithoutMagnitude.push_back("sSummonClannfear"); - effectsWithoutMagnitude.push_back("sSummonDaedroth"); - effectsWithoutMagnitude.push_back("sSummonDremora"); - effectsWithoutMagnitude.push_back("sSummonAncestralGhost"); - effectsWithoutMagnitude.push_back("sSummonSkeletalMinion"); - effectsWithoutMagnitude.push_back("sSummonBonewalker"); - effectsWithoutMagnitude.push_back("sSummonGreaterBonewalker"); - effectsWithoutMagnitude.push_back("sSummonBonelord"); - effectsWithoutMagnitude.push_back("sSummonWingedTwilight"); - effectsWithoutMagnitude.push_back("sSummonHunger"); - effectsWithoutMagnitude.push_back("sSummonGoldenSaint"); - effectsWithoutMagnitude.push_back("sSummonFlameAtronach"); - effectsWithoutMagnitude.push_back("sSummonFrostAtronach"); - effectsWithoutMagnitude.push_back("sSummonStormAtronach"); - effectsWithoutMagnitude.push_back("sSummonCenturionSphere"); - effectsWithoutMagnitude.push_back("sBoundDagger"); - effectsWithoutMagnitude.push_back("sBoundLongsword"); - effectsWithoutMagnitude.push_back("sBoundMace"); - effectsWithoutMagnitude.push_back("sBoundBattleAxe"); - effectsWithoutMagnitude.push_back("sBoundSpear"); - effectsWithoutMagnitude.push_back("sBoundLongbow"); - effectsWithoutMagnitude.push_back("sBoundCuirass"); - effectsWithoutMagnitude.push_back("sBoundHelm"); - effectsWithoutMagnitude.push_back("sBoundBoots"); - effectsWithoutMagnitude.push_back("sBoundShield"); - effectsWithoutMagnitude.push_back("sBoundGloves"); - effectsWithoutMagnitude.push_back("sStuntedMagicka"); - effectsWithoutMagnitude.push_back("sMark"); - effectsWithoutMagnitude.push_back("sRecall"); - effectsWithoutMagnitude.push_back("sDivineIntervention"); - effectsWithoutMagnitude.push_back("sAlmsiviIntervention"); - effectsWithoutMagnitude.push_back("sCureCommonDisease"); - effectsWithoutMagnitude.push_back("sCureBlightDisease"); - effectsWithoutMagnitude.push_back("sCureCorprusDisease"); - effectsWithoutMagnitude.push_back("sCurePoison"); - effectsWithoutMagnitude.push_back("sCureParalyzation"); - effectsWithoutMagnitude.push_back("sRemoveCurse"); + effectsWithoutMagnitude.push_back("sEffectSoultrap"); + effectsWithoutMagnitude.push_back("sEffectSilence"); + effectsWithoutMagnitude.push_back("sEffectParalyze"); + effectsWithoutMagnitude.push_back("sEffectInvisibility"); + effectsWithoutMagnitude.push_back("sEffectWaterWalking"); + effectsWithoutMagnitude.push_back("sEffectWaterBreathing"); + effectsWithoutMagnitude.push_back("sEffectSummonScamp"); + effectsWithoutMagnitude.push_back("sEffectSummonClannfear"); + effectsWithoutMagnitude.push_back("sEffectSummonDaedroth"); + effectsWithoutMagnitude.push_back("sEffectSummonDremora"); + effectsWithoutMagnitude.push_back("sEffectSummonAncestralGhost"); + effectsWithoutMagnitude.push_back("sEffectSummonSkeletalMinion"); + effectsWithoutMagnitude.push_back("sEffectSummonBonewalker"); + effectsWithoutMagnitude.push_back("sEffectSummonGreaterBonewalker"); + effectsWithoutMagnitude.push_back("sEffectSummonBonelord"); + effectsWithoutMagnitude.push_back("sEffectSummonWingedTwilight"); + effectsWithoutMagnitude.push_back("sEffectSummonHunger"); + effectsWithoutMagnitude.push_back("sEffectSummonGoldenSaint"); + effectsWithoutMagnitude.push_back("sEffectSummonFlameAtronach"); + effectsWithoutMagnitude.push_back("sEffectSummonFrostAtronach"); + effectsWithoutMagnitude.push_back("sEffectSummonStormAtronach"); + effectsWithoutMagnitude.push_back("sEffectSummonCenturionSphere"); + effectsWithoutMagnitude.push_back("sEffectBoundDagger"); + effectsWithoutMagnitude.push_back("sEffectBoundLongsword"); + effectsWithoutMagnitude.push_back("sEffectBoundMace"); + effectsWithoutMagnitude.push_back("sEffectBoundBattleAxe"); + effectsWithoutMagnitude.push_back("sEffectBoundSpear"); + effectsWithoutMagnitude.push_back("sEffectBoundLongbow"); + effectsWithoutMagnitude.push_back("sEffectBoundCuirass"); + effectsWithoutMagnitude.push_back("sEffectBoundHelm"); + effectsWithoutMagnitude.push_back("sEffectBoundBoots"); + effectsWithoutMagnitude.push_back("sEffectBoundShield"); + effectsWithoutMagnitude.push_back("sEffectBoundGloves"); + effectsWithoutMagnitude.push_back("sEffectStuntedMagicka"); + effectsWithoutMagnitude.push_back("sEffectMark"); + effectsWithoutMagnitude.push_back("sEffectRecall"); + effectsWithoutMagnitude.push_back("sEffectDivineIntervention"); + effectsWithoutMagnitude.push_back("sEffectAlmsiviIntervention"); + effectsWithoutMagnitude.push_back("sEffectCureCommonDisease"); + effectsWithoutMagnitude.push_back("sEffectCureBlightDisease"); + effectsWithoutMagnitude.push_back("sEffectCureCorprusDisease"); + effectsWithoutMagnitude.push_back("sEffectCurePoison"); + effectsWithoutMagnitude.push_back("sEffectCureParalyzation"); + effectsWithoutMagnitude.push_back("sEffectRemoveCurse"); return (std::find(effectsWithoutMagnitude.begin(), effectsWithoutMagnitude.end(), effect) == effectsWithoutMagnitude.end()); } From 6d21fe3115518c36fec2877a1c9048a8941c3927 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 30 Apr 2012 21:07:25 +0200 Subject: [PATCH 094/109] fixed mygui leaking some stuff resulting in lower fps after looking at tooltips and low-quality text --- apps/openmw/mwgui/tooltips.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 90b5baa67..e1cb05111 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -31,13 +31,10 @@ void ToolTips::onFrame(float frameDuration) { /// \todo Store a MWWorld::Ptr in the widget user data, retrieve it here and construct a tooltip dynamically - /// \todo we are destroying/creating the tooltip widgets every frame here, - /// because the tooltip might change (e.g. when trap is activated) - /// is there maybe a better way (listener when the object changes)? - for (size_t i=0; igetChildCount(); ++i) - { - mDynamicToolTipBox->_destroyChildWidget(mDynamicToolTipBox->getChildAt(i)); - } + MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox); + mDynamicToolTipBox = mMainWidget->createWidget("HUD_Box", + IntCoord(0, 0, mMainWidget->getCoord().width, mMainWidget->getCoord().height), + Align::Stretch, "DynamicToolTipBox"); const IntSize &viewSize = RenderManager::getInstance().getViewSize(); From 48e3c4382376089e2657e665469eeb871c1f352b Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 30 Apr 2012 21:36:45 +0200 Subject: [PATCH 095/109] added the bloodmoon/tribunal spells --- apps/openmw/mwgui/widgets.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 3c7f33ecd..0422bb0e2 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -576,7 +576,15 @@ std::string MWSpellEffect::effectIDToString(const short effectID) names[35] ="sEffectWeaknesstoPoison"; names[30] ="sEffectWeaknesstoShock"; - /// \todo bloodmoon and tribunal spells - can't find the IDs anywhere? + // bloodmoon + names[138] ="sEffectSummonCreature01"; + names[139] ="sEffectSummonCreature02"; + names[140] ="sEffectSummonCreature03"; + names[141] ="sEffectSummonCreature04"; + names[142] ="sEffectSummonCreature05"; + + // tribunal + names[137] ="sEffectSummonFabricant"; assert(names.find(effectID) != names.end() && "Unimplemented effect type"); @@ -659,6 +667,12 @@ bool MWSpellEffect::effectHasMagnitude(const std::string& effect) effectsWithoutMagnitude.push_back("sEffectCurePoison"); effectsWithoutMagnitude.push_back("sEffectCureParalyzation"); effectsWithoutMagnitude.push_back("sEffectRemoveCurse"); + effectsWithoutMagnitude.push_back("sEffectSummonCreature01"); + effectsWithoutMagnitude.push_back("sEffectSummonCreature02"); + effectsWithoutMagnitude.push_back("sEffectSummonCreature03"); + effectsWithoutMagnitude.push_back("sEffectSummonCreature04"); + effectsWithoutMagnitude.push_back("sEffectSummonCreature05"); + effectsWithoutMagnitude.push_back("sEffectSummonFabricant"); return (std::find(effectsWithoutMagnitude.begin(), effectsWithoutMagnitude.end(), effect) == effectsWithoutMagnitude.end()); } From bd132074af1541b00b3d458fb7283199a1ba17f0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 30 Apr 2012 22:37:23 +0200 Subject: [PATCH 096/109] some formatting tweaks --- apps/openmw/mwgui/tooltips.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index e1cb05111..9d7a7ee87 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -53,7 +53,6 @@ void ToolTips::onFrame(float frameDuration) std::string text = focus->getUserString("ToolTipText"); ToolTipInfo info; - if (type == "") { mDynamicToolTipBox->setVisible(false); @@ -61,7 +60,7 @@ void ToolTips::onFrame(float frameDuration) } else if (type == "Text") { - info.caption = text; + info.text = text; } else if (type == "CaptionText") { @@ -197,8 +196,8 @@ IntSize ToolTips::createToolTip(const ToolTipInfo& info) const IntPoint padding(8, 8); - const int imageCaptionHPadding = 8; - const int imageCaptionVPadding = 4; + const int imageCaptionHPadding = (caption != "" ? 8 : 0); + const int imageCaptionVPadding = (caption != "" ? 4 : 0); std::string realImage = "icons\\" + image; findImageExtension(realImage); @@ -208,7 +207,7 @@ IntSize ToolTips::createToolTip(const ToolTipInfo& info) captionWidget->setCaption(caption); IntSize captionSize = captionWidget->getTextSize(); - int captionHeight = std::max(captionSize.height, imageSize); + int captionHeight = std::max(caption != "" ? captionSize.height : 0, imageSize); EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", IntCoord(0, captionHeight+imageCaptionVPadding, 300, 300-captionHeight-imageCaptionVPadding), Align::Stretch, "ToolTipText"); textWidget->setProperty("Static", "true"); From 86b6184f438ad45b15c849a512b138910c70814c Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 30 Apr 2012 23:55:22 +0200 Subject: [PATCH 097/109] pMove in a seperate loop with fixed timestep to prevent frame-dependent movement --- apps/openmw/mwworld/physicssystem.cpp | 103 +++++++++++++------------- apps/openmw/mwworld/physicssystem.hpp | 10 ++- apps/openmw/mwworld/world.cpp | 53 +++++++++---- apps/openmw/mwworld/world.hpp | 8 +- libs/openengine/bullet/physic.cpp | 2 +- 5 files changed, 102 insertions(+), 74 deletions(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 7fe83eeab..fb13e37c6 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -21,27 +21,24 @@ namespace MWWorld PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend) : mRender(_rend), mEngine(0), mFreeFly (true) { - + playerphysics = new playerMove; // Create physics. shapeLoader is deleted by the physic engine NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader(); mEngine = new OEngine::Physic::PhysicEngine(shapeLoader); playerphysics->mEngine = mEngine; - - - } PhysicsSystem::~PhysicsSystem() { delete mEngine; - + } OEngine::Physic::PhysicEngine* PhysicsSystem::getEngine() { return mEngine; } - + std::pair PhysicsSystem::getFacedHandle (MWWorld::World& world) { std::string handle = ""; @@ -74,7 +71,7 @@ namespace MWWorld if(hasWater){ playerphysics->waterHeight = waterHeight; } - + } btVector3 PhysicsSystem::getRayPoint(float extent) @@ -86,26 +83,23 @@ namespace MWWorld btVector3 result(centerRay.getPoint(500*extent).x,-centerRay.getPoint(500*extent).z,centerRay.getPoint(500*extent).y); return result; } - + bool PhysicsSystem::castRay(const Vector3& from, const Vector3& to) { btVector3 _from, _to; _from = btVector3(from.x, from.y, from.z); _to = btVector3(to.x, to.y, to.z); - + std::pair result = mEngine->rayTest(_from, _to); - + return !(result.first == ""); } - - std::vector< std::pair > PhysicsSystem::doPhysics (float duration, - const std::vector >& actors) + void PhysicsSystem::doPhysics(float dt, const std::vector >& actors) { //set the DebugRenderingMode. To disable it,set it to 0 //eng->setDebugRenderingMode(1); - - + //set the walkdirection to 0 (no movement) for every actor) for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) { @@ -117,8 +111,7 @@ namespace MWWorld pm_ref.rightmove = 0; pm_ref.forwardmove = 0; pm_ref.upmove = 0; - - + //playerphysics->ps.move_type = PM_NOCLIP; for (std::vector >::const_iterator iter (actors.begin()); iter!=actors.end(); ++iter) @@ -133,29 +126,24 @@ namespace MWWorld Ogre::Node* yawNode = sceneNode->getChildIterator().getNext(); Ogre::Node* pitchNode = yawNode->getChildIterator().getNext(); Ogre::Quaternion yawQuat = yawNode->getOrientation(); - Ogre::Quaternion pitchQuat = pitchNode->getOrientation(); + Ogre::Quaternion pitchQuat = pitchNode->getOrientation(); - // unused - //Ogre::Quaternion both = yawQuat * pitchQuat; - - playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees(); - playerphysics->ps.viewangles.z = 0; + // unused + //Ogre::Quaternion both = yawQuat * pitchQuat; + + playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees(); + playerphysics->ps.viewangles.z = 0; playerphysics->ps.viewangles.y = yawQuat.getYaw().valueDegrees() *-1 + 90; - - - if(mFreeFly) { - Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); pm_ref.rightmove = -dir1.x; pm_ref.forwardmove = dir1.z; pm_ref.upmove = dir1.y; - - + //std::cout << "Current angle" << yawQuat.getYaw().valueDegrees() - 90<< "\n"; //playerphysics->ps.viewangles.x = pitchQuat.getPitch().valueDegrees(); //std::cout << "Pitch: " << yawQuat.getPitch() << "Yaw:" << yawQuat.getYaw() << "Roll: " << yawQuat.getRoll() << "\n"; @@ -163,46 +151,50 @@ namespace MWWorld } else { - + Ogre::Quaternion quat = yawNode->getOrientation(); Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); - + pm_ref.rightmove = -dir1.x; pm_ref.forwardmove = dir1.z; pm_ref.upmove = dir1.y; - - - + + + dir = 0.025*(quat*dir1); } - + //set the walk direction act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y)); } - mEngine->stepSimulation(duration); - Pmove(playerphysics); + mEngine->stepSimulation(dt); + } + + std::vector< std::pair > PhysicsSystem::doPhysicsFixed ( + const std::vector >& actors) + { + Pmove(playerphysics); - std::vector< std::pair > response; for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) { btVector3 newPos = it->second->getPosition(); - - Ogre::Vector3 coord(newPos.x(), newPos.y(), newPos.z()); - if(it->first == "player"){ - - coord = playerphysics->ps.origin; - //std::cout << "ZCoord: " << coord.z << "\n"; - //std::cout << "Coord" << coord << "\n"; - //coord = Ogre::Vector3(coord.x, coord.z, coord.y); //x, z, -y - - } - + Ogre::Vector3 coord(newPos.x(), newPos.y(), newPos.z()); + if(it->first == "player"){ + + coord = playerphysics->ps.origin; + //std::cout << "ZCoord: " << coord.z << "\n"; + //std::cout << "Coord" << coord << "\n"; + //coord = Ogre::Vector3(coord.x, coord.z, coord.y); //x, z, -y + + } + + response.push_back(std::pair(it->first, coord)); } - + return response; } @@ -260,7 +252,14 @@ namespace MWWorld { // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow // start positions others than 0, 0, 0 - act->setPosition(btVector3(position.x,position.y,position.z)); + if (handle == "player") + { + playerphysics->ps.origin = position; + } + else + { + act->setPosition(btVector3(position.x,position.y,position.z)); + } } } @@ -316,7 +315,7 @@ namespace MWWorld } void PhysicsSystem::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string model){ - + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); // unused diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index cb559f000..1af6bcca2 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -16,8 +16,11 @@ namespace MWWorld PhysicsSystem (OEngine::Render::OgreRenderer &_rend); ~PhysicsSystem (); - std::vector< std::pair > doPhysics (float duration, - const std::vector >& actors); + void doPhysics(float duration, const std::vector >& actors); + ///< do physics with dt - Usage: first call doPhysics with frame dt, then call doPhysicsFixed as often as time steps have passed + + std::vector< std::pair > doPhysicsFixed (const std::vector >& actors); + ///< do physics with fixed timestep - Usage: first call doPhysics with frame dt, then call doPhysicsFixed as often as time steps have passed void addObject (const std::string& handle, const std::string& mesh, const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position); @@ -55,7 +58,7 @@ namespace MWWorld void insertActorPhysics(const MWWorld::Ptr&, std::string model); OEngine::Physic::PhysicEngine* getEngine(); - + void setCurrentWater(bool hasWater, int waterHeight); private: @@ -64,7 +67,6 @@ namespace MWWorld bool mFreeFly; playerMove* playerphysics; - PhysicsSystem (const PhysicsSystem&); PhysicsSystem& operator= (const PhysicsSystem&); }; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 04bc999a0..adbdaece6 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -215,6 +215,7 @@ namespace MWWorld setFallbackValues(fallbackMap); + lastTick = mTimer.getMilliseconds(); } @@ -559,8 +560,9 @@ namespace MWWorld } } - void World::moveObjectImp (Ptr ptr, float x, float y, float z) + bool World::moveObjectImp (Ptr ptr, float x, float y, float z) { + bool ret = false; ptr.getRefData().getPosition().pos[0] = x; ptr.getRefData().getPosition().pos[1] = y; ptr.getRefData().getPosition().pos[2] = z; @@ -582,6 +584,7 @@ namespace MWWorld if (currentCell->cell->data.gridX!=cellX || currentCell->cell->data.gridY!=cellY) { mWorldScene->changeCell (cellX, cellY, mPlayer->getPlayer().getRefData().getPosition(), false); + ret = true; } } @@ -591,6 +594,8 @@ namespace MWWorld /// \todo cell change for non-player ref mRendering->moveObject (ptr, Ogre::Vector3 (x, y, z)); + + return ret; } void World::moveObject (Ptr ptr, float x, float y, float z) @@ -632,29 +637,45 @@ namespace MWWorld void World::doPhysics (const std::vector >& actors, float duration) { - std::vector< std::pair > vectors = mPhysics->doPhysics (duration, actors); + mPhysics->doPhysics(duration, actors); - std::vector< std::pair >::iterator player = vectors.end(); + const int tick = 16; // 16 ms ^= 60 Hz - for (std::vector< std::pair >::iterator it = vectors.begin(); - it!= vectors.end(); ++it) + // Game clock part of the loop, contains everything that has to be executed in a fixed timestep + long long dt = mTimer.getMilliseconds() - lastTick; + if (dt >= 100) dt = 100; // throw away wall clock time if necessary to keep the framerate above the minimum of 10 fps + while (dt >= tick) { - if (it->first=="player") + dt -= tick; + lastTick += tick; + + std::vector< std::pair > vectors = mPhysics->doPhysicsFixed (actors); + + std::vector< std::pair >::iterator player = vectors.end(); + + for (std::vector< std::pair >::iterator it = vectors.begin(); + it!= vectors.end(); ++it) { - player = it; + if (it->first=="player") + { + player = it; + } + else + { + MWWorld::Ptr ptr = getPtrViaHandle (it->first); + moveObjectImp (ptr, it->second.x, it->second.y, it->second.z); + } } - else + + // Make sure player is moved last (otherwise the cell might change in the middle of an update + // loop) + if (player!=vectors.end()) { - MWWorld::Ptr ptr = getPtrViaHandle (it->first); - moveObjectImp (ptr, it->second.x, it->second.y, it->second.z); + if (moveObjectImp (getPtrViaHandle (player->first), + player->second.x, player->second.y, player->second.z) == true) + return; // abort the current loop if the cell has changed } } - - // Make sure player is moved last (otherwise the cell might change in the middle of an update - // loop) - if (player!=vectors.end()) - moveObjectImp (getPtrViaHandle (player->first), - player->second.x, player->second.y, player->second.z); } bool World::toggleCollisionMode() diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 77e5bcef6..7359f8b90 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -22,6 +22,8 @@ #include #include +#include + namespace Ogre { class Vector3; @@ -100,9 +102,13 @@ namespace MWWorld int mNumFacing; std::map mFallback; + unsigned long lastTick; + Ogre::Timer mTimer; + int getDaysPerMonth (int month) const; - void moveObjectImp (Ptr ptr, float x, float y, float z); + bool moveObjectImp (Ptr ptr, float x, float y, float z); + ///< @return true if the active cell (cell player is in) changed public: diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 3d507d4ee..42853d8cf 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -393,7 +393,7 @@ namespace Physic void PhysicEngine::stepSimulation(double deltaT) { - dynamicsWorld->stepSimulation(deltaT,10); + dynamicsWorld->stepSimulation(deltaT,10, 1/60.0); if(isDebugCreated) { mDebugDrawer->step(); From b3caf82714d0b1e2f508ac82481e81472fff6f9a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 1 May 2012 10:12:45 -0700 Subject: [PATCH 098/109] Avoid using vector<>::data(), which requires C++11 --- apps/openmw/mwsound/mpgsnd_decoder.cpp | 2 +- apps/openmw/mwsound/openal_output.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwsound/mpgsnd_decoder.cpp b/apps/openmw/mwsound/mpgsnd_decoder.cpp index 9b91b4e74..7f7a84889 100644 --- a/apps/openmw/mwsound/mpgsnd_decoder.cpp +++ b/apps/openmw/mwsound/mpgsnd_decoder.cpp @@ -189,7 +189,7 @@ void MpgSnd_Decoder::readAll(std::vector &output) { size_t pos = output.size(); output.resize(pos + mSndInfo.frames*mSndInfo.channels*2); - sf_readf_short(mSndFile, (short*)(output.data()+pos), mSndInfo.frames); + sf_readf_short(mSndFile, (short*)(&output[0]+pos), mSndInfo.frames); return; } // Fallback in case we don't know the total already diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 615def701..ac4baa8b2 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -222,8 +222,8 @@ void OpenAL_SoundStream::play() for(ALuint i = 0;i < sNumBuffers;i++) { size_t got; - got = mDecoder->read(data.data(), data.size()); - alBufferData(mBuffers[i], mFormat, data.data(), got, mSampleRate); + got = mDecoder->read(&data[0], data.size()); + alBufferData(mBuffers[i], mFormat, &data[0], got, mSampleRate); } throwALerror(); @@ -299,11 +299,11 @@ bool OpenAL_SoundStream::process() if(finished) continue; - got = mDecoder->read(data.data(), data.size()); + got = mDecoder->read(&data[0], data.size()); finished = (got < data.size()); if(got > 0) { - alBufferData(bufid, mFormat, data.data(), got, mSampleRate); + alBufferData(bufid, mFormat, &data[0], got, mSampleRate); alSourceQueueBuffers(mSource, 1, &bufid); } } while(processed > 0); @@ -595,7 +595,7 @@ ALuint OpenAL_Output::getBuffer(const std::string &fname) alGenBuffers(1, &buf); throwALerror(); - alBufferData(buf, format, data.data(), data.size(), srate); + alBufferData(buf, format, &data[0], data.size(), srate); mBufferCache[fname] = buf; mBufferRefs[buf] = 1; From 6acb777c5a3f085f19314b0e599dec37e9958ceb Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 1 May 2012 20:51:32 +0200 Subject: [PATCH 099/109] minimum framerate fix --- apps/openmw/mwworld/world.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index adbdaece6..4adaf7918 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -643,7 +643,12 @@ namespace MWWorld // Game clock part of the loop, contains everything that has to be executed in a fixed timestep long long dt = mTimer.getMilliseconds() - lastTick; - if (dt >= 100) dt = 100; // throw away wall clock time if necessary to keep the framerate above the minimum of 10 fps + if (dt >= 100) + { + // throw away wall clock time if necessary to keep the framerate above the minimum of 10 fps + lastTick += (dt - 100); + dt = 100; + } while (dt >= tick) { dt -= tick; From 7f15385dc5afa870723a0cf84079740a55ab2a2e Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 1 May 2012 20:58:09 +0200 Subject: [PATCH 100/109] unrelated cleanup --- apps/openmw/engine.cpp | 2 -- apps/openmw/engine.hpp | 1 - 2 files changed, 3 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 539afe1c8..12a5956a9 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -148,7 +148,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) , mNewGame (false) , mUseSound (true) , mCompileAll (false) - , mFocusTDiff (0) , mScriptContext (0) , mFSStrict (false) , mCfgMgr(configurationManager) @@ -263,7 +262,6 @@ void OMW::Engine::setNewGame(bool newGame) void OMW::Engine::go() { - mFocusTDiff = 0; assert (!mCellName.empty()); assert (!mMaster.empty()); assert (!mOgre); diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index c834ee438..09d6bc820 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -74,7 +74,6 @@ namespace OMW bool mNewGame; bool mUseSound; bool mCompileAll; - float mFocusTDiff; std::string mFocusName; std::map mFallbackMap; From a13f5423965871737c2fbf08e43de5116c4f1d86 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 1 May 2012 21:01:18 +0200 Subject: [PATCH 101/109] disable snapping underwater --- libs/openengine/bullet/pmove.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index e215d8ff6..210f7eb70 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -717,6 +717,8 @@ static void PM_WaterMove( playerMove* const pm ) float scale; float vel; + pm->ps.bSnap = false; + /*if ( PM_CheckWaterJump() ) { PM_WaterJumpMove(); From 6850f3945c9ee82cd00d699e653582ce70ba93ef Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 1 May 2012 21:13:41 +0200 Subject: [PATCH 102/109] disable those physics debug prints --- libs/openengine/bullet/pmove.cpp | 16 +++++++++------- libs/openengine/bullet/pmove.h | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 210f7eb70..35bbd9c03 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -372,7 +372,7 @@ bool PM_SlideMove( bool gravity ) // stop dead at a tripple plane interaction //VectorClear( pm->ps->velocity ); - printf("Stop dead at a triple plane interaction\n"); + //printf("Stop dead at a triple plane interaction\n"); pm->ps.velocity = Ogre::Vector3(0,0,0); return true; } @@ -417,7 +417,7 @@ int PM_StepSlideMove( bool gravity ) Ogre::Vector3 up, down; float stepSize; - std::cout << "StepSlideMove\n"; + //std::cout << "StepSlideMove\n"; // start_o = pm->ps->origin //VectorCopy (pm->ps->origin, start_o); start_o = pm->ps.origin; @@ -517,6 +517,8 @@ int PM_StepSlideMove( bool gravity ) if ( delta > 2 ) { pm->ps.counter = 10; + + /* if (gravity) printf("g on: %f ", delta); else @@ -534,7 +536,7 @@ int PM_StepSlideMove( bool gravity ) else printf("stepped 15+\n"); //PM_AddEvent( EV_STEP_16 ); - + */ } /*if ( pm->debugLevel ) Com_Printf("%i:stepped\n", c_pmove);*/ @@ -863,7 +865,7 @@ static void PM_WalkMove( playerMove* const pmove ) PM_WaterMove(pmove); else PM_AirMove(); - printf("Jumped away\n"); + //printf("Jumped away\n"); return; } @@ -1146,7 +1148,7 @@ void PM_GroundTraceMissed() { traceResults trace; Ogre::Vector3 point; - std::cout << "Ground trace missed\n"; + //std::cout << "Ground trace missed\n"; // we just transitioned into freefall //if ( pm->debugLevel ) //Com_Printf("%i:lift\n", c_pmove); @@ -1292,14 +1294,14 @@ static void PM_CrashLand( void ) if ( delta < 1 ) return; - +/* if (delta > 60) printf("Far crashland: %f\n", delta); else if (delta > 40) printf("Medium crashland: %f\n", delta); else if (delta > 4) printf("Short crashland: %f\n", delta); - +*/ if (delta > 60) { /* diff --git a/libs/openengine/bullet/pmove.h b/libs/openengine/bullet/pmove.h index 2c61b3e7d..e46eb9d2e 100644 --- a/libs/openengine/bullet/pmove.h +++ b/libs/openengine/bullet/pmove.h @@ -105,13 +105,13 @@ struct playerMove inline void SpeedUp(void) { - printf("speed up to: %f\n", speed); + //printf("speed up to: %f\n", speed); speed *= 1.25f; } inline void SpeedDown(void) { - printf("speed down to %f\n", speed); + //printf("speed down to %f\n", speed); speed /= 1.25f; } From 04ead5eb42e67b1346f8e5055d16d37d8fa06741 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 1 May 2012 21:22:15 +0200 Subject: [PATCH 103/109] make the no-clip mode move much faster --- libs/openengine/bullet/pmove.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/openengine/bullet/pmove.cpp b/libs/openengine/bullet/pmove.cpp index 35bbd9c03..591f1869f 100644 --- a/libs/openengine/bullet/pmove.cpp +++ b/libs/openengine/bullet/pmove.cpp @@ -636,7 +636,7 @@ float PM_CmdScale(playerMove::playercmd* const cmd) + cmd->rightmove * cmd->rightmove + cmd->upmove * cmd->upmove) ); scale = (float)pm->ps.speed * max / ( 127.0f * total ); if(pm->ps.move_type == PM_NOCLIP) - scale *= 2; + scale *= 10; return scale; } From 144d52cf495a93aa7eb7204fd580ff0f9cf0f472 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 1 May 2012 20:30:31 -0700 Subject: [PATCH 104/109] Add voices to the chargen class questions --- apps/openmw/mwgui/charactercreation.cpp | 16 +++++++++++ apps/openmw/mwsound/soundmanager.cpp | 36 +++++++++++++++++++++++++ apps/openmw/mwsound/soundmanager.hpp | 11 ++++++-- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 9a2375855..10c4cdcb4 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -9,6 +9,7 @@ #include "mode.hpp" #include "../mwbase/environment.hpp" +#include "../mwsound/soundmanager.hpp" namespace { @@ -16,6 +17,7 @@ namespace { const char* mText; const char* mButtons[3]; + const char* mSound; ESM::Class::Specialization mSpecializations[3]; // The specialization for each answer }; @@ -25,6 +27,7 @@ namespace {"Draw your dagger, mercifully endings its life with a single thrust.", "Use herbs from your pack to put it to sleep.", "Do not interfere in the natural evolution of events, but rather take the opportunity to learn more about a strange animal that you have never seen before."}, + "vo\\misc\\chargen qa1.wav", {ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth} }, // Question 2 @@ -32,6 +35,7 @@ namespace {"Work in the forge with him casting iron for a new plow.", "Gather herbs for your mother who is preparing dinner.", "Go catch fish at the stream using a net and line."}, + "vo\\misc\\chargen qa2.wav", {ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth} }, // Question 3 @@ -39,6 +43,7 @@ namespace {"Beat up your cousin, then tell him that if he ever calls you that nickname again, you will bloody him worse than this time.", "Make up a story that makes your nickname a badge of honor instead of something humiliating.", "Make up an even more embarrassing nickname for him and use it constantly until he learns his lesson."}, + "vo\\misc\\chargen qa3.wav", {ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth} }, // Question 4 @@ -46,6 +51,7 @@ namespace {"This is a terrible practice. A person's thoughts are his own and no one, not even a king, has the right to make such an invasion into another human's mind.", "Loyal followers to the king have nothing to fear from a Telepath. It is important to have a method of finding assassins and spies before it is too late.", "In these times, it is a necessary evil. Although you do not necessarily like the idea, a Telepath could have certain advantages during a time of war or in finding someone innocent of a crime."}, + "vo\\misc\\chargen qa4.wav", {ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth} }, // Question 5 @@ -53,6 +59,7 @@ namespace {"Return to the store and give the shopkeeper his hard-earned money, explaining to him the mistake?", "Decide to put the extra money to good use and purchase items that would help your family?", "Pocket the extra money, knowing that shopkeepers in general tend to overcharge customers anyway?"}, + "vo\\misc\\chargen qa5.wav", {ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth} }, // Question 6 @@ -60,6 +67,7 @@ namespace {"Pick up the bag and signal to the guard, knowing that the only honorable thing to do is return the money to its rightful owner.", "Leave the bag there, knowing that it is better not to get involved.", "Pick up the bag and pocket it, knowing that the extra windfall will help your family in times of trouble."}, + "vo\\misc\\chargen qa6.wav", {ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth} }, // Question 7 @@ -67,6 +75,7 @@ namespace {"Decline his offer, knowing that your father expects you to do the work, and it is better not to be in debt.", "Ask him to help you, knowing that two people can do the job faster than one, and agree to help him with one task of his choosing in the future.", "Accept his offer, reasoning that as long as the stables are cleaned, it matters not who does the cleaning."}, + "vo\\misc\\chargen qa7.wav", {ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth} }, // Question 8 @@ -74,6 +83,7 @@ namespace {"Position yourself between the pipe and your mother.", "Grab the hot pipe and try to push it away.", "Push your mother out of the way."}, + "vo\\misc\\chargen qa8.wav", {ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth} }, // Question 9 @@ -81,6 +91,7 @@ namespace {"Drop the sweetroll and step on it, then get ready for the fight.", "Give him the sweetroll now without argument, knowing that later this afternoon you will have all your friends with you and can come and take whatever he owes you.", "Act like you're going to give him the sweetroll, but at the last minute throw it in the air, hoping that they'll pay attention to it long enough for you to get a shot in on the leader."}, + "vo\\misc\\chargen qa9.wav", {ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth} }, // Question 10 @@ -88,6 +99,7 @@ namespace {"Rush to the town's aid immediately, despite your lack of knowledge of the circumstances.", "Stand aside and allow the man and the mob to pass, realizing it is probably best not to get involved.", "Rush to the man's aid immediately, despite your lack of knowledge of the circumstances."}, + "vo\\misc\\chargen qa10.wav", {ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth} } } }; @@ -479,6 +491,8 @@ void CharacterCreation::onCreateClassDialogBack() void CharacterCreation::onClassQuestionChosen(int _index) { + MWBase::Environment::get().getSoundManager()->stopSay(); + if (mGenerateClassQuestionDialog) mWM->removeDialog(mGenerateClassQuestionDialog); if (_index < 0 || _index >= 3) @@ -584,6 +598,8 @@ void CharacterCreation::showClassQuestionDialog() mGenerateClassQuestionDialog->setButtons(buttons); mGenerateClassQuestionDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen); mGenerateClassQuestionDialog->open(); + + MWBase::Environment::get().getSoundManager()->say(sGenerateClassSteps[mGenerateClassStep].mSound); } void CharacterCreation::onGenerateClassBack() diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 4656efb6e..9eefc7a28 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -228,11 +228,47 @@ namespace MWSound } } + void SoundManager::say(const std::string& filename) + { + if(!mOutput->isInitialized()) + return; + try + { + float basevol = mMasterVolume * mSFXVolume; + std::string filePath = "Sound/"+filename; + + SoundPtr sound = mOutput->playSound(filePath, basevol, 1.0f, Play_Normal); + sound->mBaseVolume = basevol; + + mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), std::string("_say_sound")); + } + catch(std::exception &e) + { + std::cout <<"Sound Error: "<second.first == ptr && snditer->second.second == "_say_sound") + { + snditer->first->stop(); + mActiveSounds.erase(snditer++); + } + else + snditer++; + } + } + + SoundPtr SoundManager::playSound(const std::string& soundId, float volume, float pitch, int mode) { diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index 8afd488e1..e1816cd1f 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -97,11 +97,18 @@ namespace MWSound void say(MWWorld::Ptr reference, const std::string& filename); ///< Make an actor say some text. - /// \param filename name of a sound file in "Sound/Vo/" in the data directory. + /// \param filename name of a sound file in "Sound/" in the data directory. - bool sayDone(MWWorld::Ptr reference) const; + void say(const std::string& filename); + ///< Say some text, without an actor ref + /// \param filename name of a sound file in "Sound/" in the data directory. + + bool sayDone(MWWorld::Ptr reference=MWWorld::Ptr()) const; ///< Is actor not speaking? + void stopSay(MWWorld::Ptr reference=MWWorld::Ptr()); + ///< Stop an actor speaking + SoundPtr playSound(const std::string& soundId, float volume, float pitch, int mode=Play_Normal); ///< Play a sound, independently of 3D-position From c4b63bdb2fdb98afc809778c1c06a87119c02ffc Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 2 May 2012 23:27:56 +0200 Subject: [PATCH 105/109] .gitmodules --- libs/openengine/.gitmodules | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 libs/openengine/.gitmodules diff --git a/libs/openengine/.gitmodules b/libs/openengine/.gitmodules deleted file mode 100644 index 0a9a9121f..000000000 --- a/libs/openengine/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "mangle"] - path = mangle - url = git://github.com/korslund/mangle From dc378fc6cfc5e0ad01a7cf6d8e636ed7b32f06fb Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 3 May 2012 06:07:41 +0200 Subject: [PATCH 106/109] allow talking with creatures --- apps/openmw/mwdialogue/dialoguemanager.cpp | 48 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index ac41244d1..282fba354 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -161,6 +161,8 @@ namespace MWDialogue bool DialogueManager::functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice) { + bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name()); + for (std::vector::const_iterator iter (info.selects.begin()); iter != info.selects.end(); ++iter) { @@ -195,6 +197,9 @@ namespace MWDialogue case 46://Same faction { + if (isCreature) + return false; + MWMechanics::NpcStats PCstats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor); int sameFaction = 0; @@ -283,6 +288,8 @@ namespace MWDialogue bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const { + bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name()); + char type = select.selectRule[1]; if (type!='0') @@ -380,6 +387,9 @@ namespace MWDialogue return true; case '8':// not faction + if (isCreature) + return false; + if(select.type==ESM::VT_Int) { ESMS::LiveCellRef* npc = actor.get(); @@ -394,6 +404,9 @@ namespace MWDialogue return true; case '9':// not class + if (isCreature) + return false; + if(select.type==ESM::VT_Int) { ESMS::LiveCellRef* npc = actor.get(); @@ -408,6 +421,9 @@ namespace MWDialogue return true; case 'A'://not Race + if (isCreature) + return false; + if(select.type==ESM::VT_Int) { ESMS::LiveCellRef* npc = actor.get(); @@ -464,6 +480,8 @@ namespace MWDialogue bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const { + bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name()); + // actor id if (!info.actor.empty()) if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor)) @@ -472,6 +490,9 @@ namespace MWDialogue //NPC race if (!info.race.empty()) { + if (isCreature) + return false; + ESMS::LiveCellRef *cellRef = actor.get(); if (!cellRef) @@ -484,6 +505,9 @@ namespace MWDialogue //NPC class if (!info.clas.empty()) { + if (isCreature) + return false; + ESMS::LiveCellRef *cellRef = actor.get(); if (!cellRef) @@ -496,6 +520,9 @@ namespace MWDialogue //NPC faction if (!info.npcFaction.empty()) { + if (isCreature) + return false; + //MWWorld::Class npcClass = MWWorld::Class::get(actor); MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor); std::map::iterator it = stats.mFactionRank.find(info.npcFaction); @@ -529,16 +556,18 @@ namespace MWDialogue } //check gender - ESMS::LiveCellRef* npc = actor.get(); - if(npc->base->flags&npc->base->Female) + if (!isCreature) { - if(static_cast (info.data.gender)==0) return false; + ESMS::LiveCellRef* npc = actor.get(); + if(npc->base->flags&npc->base->Female) + { + if(static_cast (info.data.gender)==0) return false; + } + else + { + if(static_cast (info.data.gender)==1) return false; + } } - else - { - if(static_cast (info.data.gender)==1) return false; - } - // check cell if (!info.cell.empty()) @@ -839,6 +868,9 @@ namespace MWDialogue std::string DialogueManager::getFaction() { + if (mActor.getTypeName() != typeid(ESM::NPC).name()) + return ""; + std::string factionID(""); MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mActor); if(stats.mFactionRank.empty()) From b653f047acfbe61f0d7b4b21f8548e1ee3202c5a Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 3 May 2012 09:15:56 +0200 Subject: [PATCH 107/109] removed a file that wasn't supposed to be there --- apps/openmw/physicssystem.cpp | 225 ---------------------------------- 1 file changed, 225 deletions(-) delete mode 100644 apps/openmw/physicssystem.cpp diff --git a/apps/openmw/physicssystem.cpp b/apps/openmw/physicssystem.cpp deleted file mode 100644 index a07358f8e..000000000 --- a/apps/openmw/physicssystem.cpp +++ /dev/null @@ -1,225 +0,0 @@ -#include - -#include "physicssystem.hpp" -#include "../mwworld/ptr.hpp" -#include "../mwworld/world.hpp" // FIXME -#include - -#include "OgreRoot.h" -#include "OgreRenderWindow.h" -#include "OgreSceneManager.h" -#include "OgreViewport.h" -#include "OgreCamera.h" -#include "OgreTextureManager.h" - - -using namespace Ogre; -namespace MWWorld -{ - - PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend) : - mRender(_rend), mEngine(0), mFreeFly (true) - { - // Create physics. shapeLoader is deleted by the physic engine - NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader(); - mEngine = new OEngine::Physic::PhysicEngine(shapeLoader); - } - - PhysicsSystem::~PhysicsSystem() - { - delete mEngine; - - } - OEngine::Physic::PhysicEngine* PhysicsSystem::getEngine() - { - return mEngine; - } - - std::pair PhysicsSystem::getFacedHandle (MWWorld::World& world) - { - std::string handle = ""; - - //get a ray pointing to the center of the viewport - Ray centerRay = mRender.getCamera()->getCameraToViewportRay( - mRender.getViewport()->getWidth()/2, - mRender.getViewport()->getHeight()/2); - //let's avoid the capsule shape of the player. - centerRay.setOrigin(centerRay.getOrigin() + 20*centerRay.getDirection()); - btVector3 from(centerRay.getOrigin().x,-centerRay.getOrigin().z,centerRay.getOrigin().y); - btVector3 to(centerRay.getPoint(500).x,-centerRay.getPoint(500).z,centerRay.getPoint(500).y); - - return mEngine->rayTest(from,to); - } - - bool PhysicsSystem::castRay(const Vector3& from, const Vector3& to) - { - btVector3 _from, _to; - _from = btVector3(from.x, from.y, from.z); - _to = btVector3(to.x, to.y, to.z); - - std::pair result = mEngine->rayTest(_from, _to); - - return !(result.first == ""); - } - - - std::vector< std::pair > PhysicsSystem::doPhysics (float duration, - const std::vector >& actors) - { - //set the DebugRenderingMode. To disable it,set it to 0 - //eng->setDebugRenderingMode(1); - - //set the walkdirection to 0 (no movement) for every actor) - for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) - { - OEngine::Physic::PhysicActor* act = it->second; - act->setWalkDirection(btVector3(0,0,0)); - } - - for (std::vector >::const_iterator iter (actors.begin()); - iter!=actors.end(); ++iter) - { - OEngine::Physic::PhysicActor* act = mEngine->getCharacter(iter->first); - - //dirty stuff to get the camera orientation. Must be changed! - - Ogre::SceneNode *sceneNode = mRender.getScene()->getSceneNode (iter->first); - Ogre::Vector3 dir; - Ogre::Node* yawNode = sceneNode->getChildIterator().getNext(); - Ogre::Node* pitchNode = yawNode->getChildIterator().getNext(); - if(mFreeFly) - { - Ogre::Quaternion yawQuat = yawNode->getOrientation(); - Ogre::Quaternion pitchQuat = pitchNode->getOrientation(); - Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); - dir = 0.07*(yawQuat*pitchQuat*dir1); - } - else - { - Ogre::Quaternion quat = yawNode->getOrientation(); - Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y); - dir = 0.025*(quat*dir1); - } - - //set the walk direction - act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y)); - } - mEngine->stepSimulation(duration); - - std::vector< std::pair > response; - for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) - { - btVector3 newPos = it->second->getPosition(); - Ogre::Vector3 coord(newPos.x(), newPos.y(), newPos.z()); - - response.push_back(std::pair(it->first, coord)); - } - return response; - } - - void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh, - const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position) - { - OEngine::Physic::RigidBody* body = mEngine->createRigidBody(mesh,handle,scale); - mEngine->addRigidBody(body); - btTransform tr; - tr.setOrigin(btVector3(position.x,position.y,position.z)); - std::cout << "Position object:" << position << "\n"; - tr.setRotation(btQuaternion(rotation.x,rotation.y,rotation.z,rotation.w)); - body->setWorldTransform(tr); - } - - void PhysicsSystem::addActor (const std::string& handle, const std::string& mesh, - const Ogre::Vector3& position) - { - //TODO:optimize this. Searching the std::map isn't very efficient i think. - mEngine->addCharacter(handle); - OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle); - act->setPosition(btVector3(position.x,position.y,position.z)); - } - - void PhysicsSystem::removeObject (const std::string& handle) - { - //TODO:check if actor??? - mEngine->removeCharacter(handle); - mEngine->removeRigidBody(handle); - mEngine->deleteRigidBody(handle); - } - - void PhysicsSystem::moveObject (const std::string& handle, const Ogre::Vector3& position) - { - if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle)) - { - // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow - // start positions others than 0, 0, 0 - btTransform tr = body->getWorldTransform(); - tr.setOrigin(btVector3(position.x,position.y,position.z)); - body->setWorldTransform(tr); - } - if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle)) - { - // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow - // start positions others than 0, 0, 0 - act->setPosition(btVector3(position.x,position.y,position.z)); - } - } - - void PhysicsSystem::rotateObject (const std::string& handle, const Ogre::Quaternion& rotation) - { - if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle)) - { - // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow - // start positions others than 0, 0, 0 - act->setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)); - } - } - - void PhysicsSystem::scaleObject (const std::string& handle, float scale) - { - - } - - bool PhysicsSystem::toggleCollisionMode() - { - for(std::map::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) - { - if (it->first=="player") - { - OEngine::Physic::PhysicActor* act = it->second; - - bool cmode = act->getCollisionMode(); - if(cmode) - { - act->enableCollisions(false); - act->setGravity(0.); - act->setVerticalVelocity(0); - mFreeFly = true; - return false; - } - else - { - mFreeFly = false; - act->enableCollisions(true); - act->setGravity(4.); - act->setVerticalVelocity(0); - return true; - } - } - } - - throw std::logic_error ("can't find player"); - } - - void PhysicsSystem::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string model){ - Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); - addObject (node->getName(), model, node->getOrientation(), - node->getScale().x, node->getPosition()); - } - - void PhysicsSystem::insertActorPhysics(const MWWorld::Ptr& ptr, const std::string model){ - Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); - // std::cout << "Adding node with name" << node->getName(); - addActor (node->getName(), model, node->getPosition()); - } - -} From e26f39e56394d2cd9af09b10234b9c09e94c311f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 4 May 2012 17:20:57 +0200 Subject: [PATCH 108/109] fixed exception handling during subsystem setup --- apps/openmw/engine.cpp | 8 +------ apps/openmw/engine.hpp | 2 +- apps/openmw/mwbase/environment.cpp | 38 ++++++++++++++++++++++++++++++ apps/openmw/mwbase/environment.hpp | 5 +++- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 12a5956a9..319c42bbd 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -158,13 +158,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) OMW::Engine::~Engine() { - delete MWBase::Environment::get().getInputManager(); - delete MWBase::Environment::get().getSoundManager(); - delete MWBase::Environment::get().getMechanicsManager(); - delete MWBase::Environment::get().getDialogueManager(); - delete MWBase::Environment::get().getJournal(); - delete MWBase::Environment::get().getScriptManager(); - delete MWBase::Environment::get().getWorld(); + mEnvironment.cleanup(); delete mScriptContext; delete mOgre; } diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 09d6bc820..63464a40d 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -62,6 +62,7 @@ namespace OMW /// \brief Main engine class, that brings together all the components of OpenMW class Engine : private Ogre::FrameListener { + MWBase::Environment mEnvironment; std::string mEncoding; Files::PathContainer mDataDirs; boost::filesystem::path mResDir; @@ -77,7 +78,6 @@ namespace OMW std::string mFocusName; std::map mFallbackMap; - MWBase::Environment mEnvironment; Compiler::Extensions mExtensions; Compiler::Context *mScriptContext; diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index 8e9a9cfce..792e240f4 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -3,6 +3,19 @@ #include +#include "../mwinput/inputmanager.hpp" + +#include "../mwscript/scriptmanager.hpp" + +#include "../mwsound/soundmanager.hpp" + +#include "../mwworld/world.hpp" + +#include "../mwdialogue/dialoguemanager.hpp" +#include "../mwdialogue/journal.hpp" + +#include "../mwmechanics/mechanicsmanager.hpp" + MWBase::Environment *MWBase::Environment::sThis = 0; MWBase::Environment::Environment() @@ -15,6 +28,7 @@ MWBase::Environment::Environment() MWBase::Environment::~Environment() { + cleanup(); sThis = 0; } @@ -116,6 +130,30 @@ float MWBase::Environment::getFrameDuration() const return mFrameDuration; } +void MWBase::Environment::cleanup() +{ + delete mInputManager; + mInputManager = 0; + + delete mSoundManager; + mSoundManager = 0; + + delete mMechanicsManager; + mMechanicsManager = 0; + + delete mDialogueManager; + mDialogueManager = 0; + + delete mJournal; + mJournal = 0; + + delete mScriptManager; + mScriptManager = 0; + + delete mWorld; + mWorld = 0; +} + const MWBase::Environment& MWBase::Environment::get() { assert (sThis); diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index a010e7faa..521beee0a 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -43,7 +43,7 @@ namespace MWBase /// /// This class allows each mw-subsystem to access any others subsystem's top-level manager class. /// - /// \attention Environment does not take ownership of the manager class instances it is handed over in + /// \attention Environment takes ownership of the manager class instances it is handed over in /// the set* functions. class Environment { @@ -108,6 +108,9 @@ namespace MWBase float getFrameDuration() const; + void cleanup(); + ///< Delete all mw*-subsystems. + static const Environment& get(); ///< Return instance of this class. }; From 2b584300d6cc94dc1b1e54cda5700589fcafb9f2 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 7 May 2012 23:16:29 +0200 Subject: [PATCH 109/109] throw an exception when no default settings file is found, which indicates a packaging error --- apps/openmw/engine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 319c42bbd..c1bbeb586 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -281,6 +281,8 @@ void OMW::Engine::go() settings.loadDefault(localdefault); else if (boost::filesystem::exists(globaldefault)) settings.loadDefault(globaldefault); + else + throw std::runtime_error ("No default settings file found! Make sure the file \"settings-default.cfg\" was properly installed."); // load user settings if they exist, otherwise just load the default settings as user settings const std::string settingspath = mCfgMgr.getUserPath().string() + "/settings.cfg";