1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-19 12:40:49 +00:00

Merge remote-tracking branch 'scrawl/master'

This commit is contained in:
Marc Zinnschlag 2013-11-30 09:45:46 +01:00
commit 016500af98
13 changed files with 49 additions and 27 deletions

View File

@ -147,6 +147,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
, mEncoding(ToUTF8::WINDOWS_1252) , mEncoding(ToUTF8::WINDOWS_1252)
, mEncoder(NULL) , mEncoder(NULL)
, mActivationDistanceOverride(-1) , mActivationDistanceOverride(-1)
, mGrab(true)
{ {
std::srand ( std::time(NULL) ); std::srand ( std::time(NULL) );
@ -370,7 +371,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
std::string keybinderUser = (mCfgMgr.getUserPath() / "input.xml").string(); std::string keybinderUser = (mCfgMgr.getUserPath() / "input.xml").string();
bool keybinderUserExists = boost::filesystem::exists(keybinderUser); bool keybinderUserExists = boost::filesystem::exists(keybinderUser);
MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists); MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists, mGrab);
mEnvironment.setInputManager (input); mEnvironment.setInputManager (input);
MWGui::WindowManager* window = new MWGui::WindowManager( MWGui::WindowManager* window = new MWGui::WindowManager(

View File

@ -79,6 +79,8 @@ namespace OMW
bool mScriptConsoleMode; bool mScriptConsoleMode;
std::string mStartupScript; std::string mStartupScript;
int mActivationDistanceOverride; int mActivationDistanceOverride;
// Grab mouse?
bool mGrab;
Compiler::Extensions mExtensions; Compiler::Extensions mExtensions;
Compiler::Context *mScriptContext; Compiler::Context *mScriptContext;
@ -152,6 +154,8 @@ namespace OMW
/// Start as a new game. /// Start as a new game.
void setNewGame(bool newGame); void setNewGame(bool newGame);
void setGrabMouse(bool grab) { mGrab = grab; }
/// Initialise and enter main loop. /// Initialise and enter main loop.
void go(); void go();

View File

@ -154,6 +154,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
("fallback", bpo::value<FallbackMap>()->default_value(FallbackMap(), "") ("fallback", bpo::value<FallbackMap>()->default_value(FallbackMap(), "")
->multitoken()->composing(), "fallback values") ->multitoken()->composing(), "fallback values")
("no-grab", "Don't grab mouse cursor")
("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override"); ("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override");
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv) bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
@ -184,6 +186,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
if (!run) if (!run)
return false; return false;
engine.setGrabMouse(!variables.count("no-grab"));
// Font encoding settings // Font encoding settings
std::string encoding(variables["encoding"].as<std::string>()); std::string encoding(variables["encoding"].as<std::string>());
std::cout << ToUTF8::encodingUsingMessage(encoding) << std::endl; std::cout << ToUTF8::encodingUsingMessage(encoding) << std::endl;

View File

@ -110,11 +110,6 @@ namespace MWGui
else else
{ {
const MyGUI::IntPoint& lastPressed = MyGUI::InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
if (mousePos == lastPressed) // mouseclick makes tooltip disappear
return;
if (mousePos.left == mLastMouseX && mousePos.top == mLastMouseY) if (mousePos.left == mLastMouseX && mousePos.top == mLastMouseY)
{ {
mRemainingDelay -= frameDuration; mRemainingDelay -= frameDuration;

View File

@ -80,7 +80,7 @@ namespace MWGui
} }
void TradeWindow::startTrade(const MWWorld::Ptr& actor) void TradeWindow::startTrade(const MWWorld::Ptr& actor)
{ {
mPtr = actor; mPtr = actor;
mCurrentBalance = 0; mCurrentBalance = 0;
@ -102,6 +102,8 @@ namespace MWGui
// Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last // Careful here. setTitle may cause size updates, causing itemview redraw, so make sure to do it last
// or we end up using a possibly invalid model. // or we end up using a possibly invalid model.
setTitle(MWWorld::Class::get(actor).getName(actor)); setTitle(MWWorld::Class::get(actor).getName(actor));
onFilterChanged(mFilterAll);
} }
void TradeWindow::onFilterChanged(MyGUI::Widget* _sender) void TradeWindow::onFilterChanged(MyGUI::Widget* _sender)

View File

@ -87,7 +87,7 @@ namespace MWInput
{ {
InputManager::InputManager(OEngine::Render::OgreRenderer &ogre, InputManager::InputManager(OEngine::Render::OgreRenderer &ogre,
OMW::Engine& engine, OMW::Engine& engine,
const std::string& userFile, bool userFileExists) const std::string& userFile, bool userFileExists, bool grab)
: mOgre(ogre) : mOgre(ogre)
, mPlayer(NULL) , mPlayer(NULL)
, mEngine(engine) , mEngine(engine)
@ -111,7 +111,7 @@ namespace MWInput
Ogre::RenderWindow* window = ogre.getWindow (); Ogre::RenderWindow* window = ogre.getWindow ();
mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow(), mOgre.getWindow()); mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow(), mOgre.getWindow(), grab);
mInputManager->setMouseEventCallback (this); mInputManager->setMouseEventCallback (this);
mInputManager->setKeyboardEventCallback (this); mInputManager->setKeyboardEventCallback (this);
mInputManager->setWindowEventCallback(this); mInputManager->setWindowEventCallback(this);

View File

@ -61,7 +61,7 @@ namespace MWInput
public: public:
InputManager(OEngine::Render::OgreRenderer &_ogre, InputManager(OEngine::Render::OgreRenderer &_ogre,
OMW::Engine& engine, OMW::Engine& engine,
const std::string& userFile, bool userFileExists); const std::string& userFile, bool userFileExists, bool grab);
virtual ~InputManager(); virtual ~InputManager();

View File

@ -160,6 +160,8 @@ namespace MWMechanics
void Actors::calculateRestoration (const MWWorld::Ptr& ptr, float duration) void Actors::calculateRestoration (const MWWorld::Ptr& ptr, float duration)
{ {
if (ptr.getClass().getCreatureStats(ptr).isDead())
return;
CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr); CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
const MWWorld::Store<ESM::GameSetting>& settings = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); const MWWorld::Store<ESM::GameSetting>& settings = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();

View File

@ -1066,6 +1066,7 @@ void Animation::addEffect(const std::string &model, int effectId, bool loop, con
for(size_t i = 0;i < params.mObjects.mParticles.size(); ++i) for(size_t i = 0;i < params.mObjects.mParticles.size(); ++i)
{ {
Ogre::ParticleSystem* partSys = params.mObjects.mParticles[i]; Ogre::ParticleSystem* partSys = params.mObjects.mParticles[i];
sh::Factory::getInstance()._ensureMaterial(partSys->getMaterialName(), "Default");
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(partSys->getMaterialName()); Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(partSys->getMaterialName());
static int count = 0; static int count = 0;
Ogre::String materialName = "openmw/" + Ogre::StringConverter::toString(count++); Ogre::String materialName = "openmw/" + Ogre::StringConverter::toString(count++);

View File

@ -490,10 +490,20 @@ namespace MWScript
ipos.pos[0] = pos.x; ipos.pos[0] = pos.x;
ipos.pos[1] = pos.y; ipos.pos[1] = pos.y;
ipos.pos[2] = pos.z; ipos.pos[2] = pos.z;
ipos.rot[0] = 0;
ipos.rot[1] = 0;
ipos.rot[2] = 0;
if (actor.getClass().isActor())
{
// TODO: should this depend on the 'direction' parameter?
ipos.rot[0] = 0;
ipos.rot[1] = 0;
ipos.rot[2] = 0;
}
else
{
ipos.rot[0] = actor.getRefData().getPosition().rot[0];
ipos.rot[1] = actor.getRefData().getPosition().rot[1];
ipos.rot[2] = actor.getRefData().getPosition().rot[2];
}
// create item // create item
MWWorld::CellStore* store = actor.getCell(); MWWorld::CellStore* store = actor.getCell();
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), itemID, count); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), itemID, count);

View File

@ -1127,10 +1127,6 @@ namespace MWWorld
void World::doPhysics(float duration) void World::doPhysics(float duration)
{ {
/* No duration? Shouldn't be any movement, then. */
if(duration <= 0.0f)
return;
processDoors(duration); processDoors(duration);
moveProjectiles(duration); moveProjectiles(duration);
@ -1547,12 +1543,15 @@ namespace MWWorld
MWWorld::Ptr dropped = MWWorld::Ptr dropped =
MWWorld::Class::get(object).copyToCell(object, cell, pos); MWWorld::Class::get(object).copyToCell(object, cell, pos);
Ogre::Vector3 min, max; if (object.getClass().isActor())
if (mPhysics->getObjectAABB(object, min, max)) { {
float *pos = dropped.getRefData().getPosition().pos; Ogre::Vector3 min, max;
pos[0] -= (min.x + max.x) / 2; if (mPhysics->getObjectAABB(object, min, max)) {
pos[1] -= (min.y + max.y) / 2; float *pos = dropped.getRefData().getPosition().pos;
pos[2] -= min.z; pos[0] -= (min.x + max.x) / 2;
pos[1] -= (min.y + max.y) / 2;
pos[2] -= min.z;
}
} }
if (mWorldScene->isCellActive(cell)) { if (mWorldScene->isCellActive(cell)) {
@ -2086,6 +2085,8 @@ namespace MWWorld
iter->mEffectID); iter->mEffectID);
projectileModel = magicEffect->mBolt; projectileModel = magicEffect->mBolt;
if (projectileModel.empty())
projectileModel = "VFX_DefaultBolt";
static const std::string schools[] = { static const std::string schools[] = {
"alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration"

View File

@ -9,7 +9,7 @@ namespace SFO
{ {
/// \brief General purpose wrapper for OGRE applications around SDL's event /// \brief General purpose wrapper for OGRE applications around SDL's event
/// queue, mostly used for handling input-related events. /// queue, mostly used for handling input-related events.
InputWrapper::InputWrapper(SDL_Window* window, Ogre::RenderWindow* ogreWindow) : InputWrapper::InputWrapper(SDL_Window* window, Ogre::RenderWindow* ogreWindow, bool grab) :
mSDLWindow(window), mSDLWindow(window),
mOgreWindow(ogreWindow), mOgreWindow(ogreWindow),
mWarpCompensate(false), mWarpCompensate(false),
@ -27,7 +27,8 @@ namespace SFO
mWindowHasFocus(true), mWindowHasFocus(true),
mWantGrab(false), mWantGrab(false),
mWantRelative(false), mWantRelative(false),
mWantMouseVisible(false) mWantMouseVisible(false),
mAllowGrab(grab)
{ {
_setupOISKeys(); _setupOISKeys();
} }
@ -226,7 +227,7 @@ namespace SFO
void InputWrapper::updateMouseSettings() void InputWrapper::updateMouseSettings()
{ {
mGrabPointer = mWantGrab && mMouseInWindow && mWindowHasFocus; mGrabPointer = mWantGrab && mMouseInWindow && mWindowHasFocus;
SDL_SetWindowGrab(mSDLWindow, mGrabPointer ? SDL_TRUE : SDL_FALSE); SDL_SetWindowGrab(mSDLWindow, mGrabPointer && mAllowGrab ? SDL_TRUE : SDL_FALSE);
SDL_ShowCursor(mWantMouseVisible || !mWindowHasFocus); SDL_ShowCursor(mWantMouseVisible || !mWindowHasFocus);

View File

@ -16,7 +16,7 @@ namespace SFO
class InputWrapper class InputWrapper
{ {
public: public:
InputWrapper(SDL_Window *window, Ogre::RenderWindow* ogreWindow); InputWrapper(SDL_Window *window, Ogre::RenderWindow* ogreWindow, bool grab);
~InputWrapper(); ~InputWrapper();
void setMouseEventCallback(MouseListener* listen) { mMouseListener = listen; } void setMouseEventCallback(MouseListener* listen) { mMouseListener = listen; }
@ -62,6 +62,7 @@ namespace SFO
bool mWarpCompensate; bool mWarpCompensate;
bool mWrapPointer; bool mWrapPointer;
bool mAllowGrab;
bool mWantMouseVisible; bool mWantMouseVisible;
bool mWantGrab; bool mWantGrab;
bool mWantRelative; bool mWantRelative;