From 906d290935904a85d87f760eaaf14324eec3fab0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 12 Sep 2012 12:41:12 +0200 Subject: [PATCH 01/15] Markers are actually hidden now. Inspecting the markers in NifSkope revealed why it didn't work previously: the flag that is being looked for is not present in any of the markers, nor any other flag or extra data to identify them. However, the root node name always starts with "marker", making it possible to do a string search. --- components/nifbullet/bullet_nif_loader.cpp | 5 +++++ components/nifogre/ogre_nif_loader.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index 071f03630..b70404635 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -164,6 +164,11 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, // the flags we currently use, at least. flags |= node->flags; + // Marker objects: just skip the entire node + /// \todo don't do this in the editor + if (node->name.find("marker") != std::string::npos) + return; + // Check for extra data Nif::Extra *e = node; while (!e->extra.empty()) diff --git a/components/nifogre/ogre_nif_loader.cpp b/components/nifogre/ogre_nif_loader.cpp index 5a5a614ef..5127af966 100644 --- a/components/nifogre/ogre_nif_loader.cpp +++ b/components/nifogre/ogre_nif_loader.cpp @@ -940,6 +940,11 @@ public: { flags |= node->flags; + // Marker objects: just skip the entire node + /// \todo don't do this in the editor + if (node->name.find("marker") != std::string::npos) + return; + Nif::ExtraPtr e = node->extra; while(!e.empty()) { From a96ed6ac61fe4cc2ddce70c9437389b1b1b44982 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 12 Sep 2012 19:15:29 +0200 Subject: [PATCH 02/15] splash screens on startup --- apps/openmw/mwgui/loadingscreen.cpp | 35 +++++++++++++++++++++++++- apps/openmw/mwgui/loadingscreen.hpp | 2 ++ apps/openmw/mwgui/mode.hpp | 3 +++ apps/openmw/mwgui/windowmanagerimp.cpp | 9 +++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index d93cc50c3..c25fad6bc 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -11,6 +11,8 @@ #include "../mwbase/environment.hpp" #include "../mwbase/inputmanager.hpp" +#include "../mwbase/windowmanager.hpp" + namespace MWGui { @@ -20,6 +22,7 @@ namespace MWGui , WindowBase("openmw_loading_screen.layout", parWindowManager) , mLoadingOn(false) , mLastRenderTime(0.f) + , mFirstLoad(true) { getWidget(mLoadingText, "LoadingText"); getWidget(mProgressBar, "ProgressBar"); @@ -139,7 +142,8 @@ namespace MWGui } else { - mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName()); + if (!mFirstLoad) + mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName()); mRectangle->setVisible(true); for (unsigned int i = 0; igetNumCompositors(); ++i) @@ -171,6 +175,30 @@ namespace MWGui { setVisible(true); mLoadingOn = true; + + if (mFirstLoad) + { + /// \todo use a directory listing here + std::vector splash; + splash.push_back ("Splash/Splash_Bonelord.tga"); + splash.push_back ("Splash/Splash_ClannDaddy.tga"); + splash.push_back ("Splash/Splash_ClannFear.tga"); + splash.push_back ("Splash/Splash_Daedroth.tga"); + splash.push_back ("Splash/Splash_Hunger.tga"); + splash.push_back ("Splash/Splash_KwamaWarrior.tga"); + splash.push_back ("Splash/Splash_Netch.tga"); + splash.push_back ("Splash/Splash_NixHound.tga"); + splash.push_back ("Splash/Splash_Siltstriker.tga"); + splash.push_back ("Splash/Splash_Skeleton.tga"); + splash.push_back ("Splash/Splash_SphereCenturion.tga"); + + mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(splash[rand() % splash.size()]); + mRectangle->setVisible(true); + + mWindowManager.pushGuiMode(GM_LoadingWallpaper); + } + else + mWindowManager.pushGuiMode(GM_Loading); } @@ -178,5 +206,10 @@ namespace MWGui { setVisible(false); mLoadingOn = false; + mFirstLoad = false; + mRectangle->setVisible(false); + + mWindowManager.removeGuiMode(GM_Loading); + mWindowManager.removeGuiMode(GM_LoadingWallpaper); } } diff --git a/apps/openmw/mwgui/loadingscreen.hpp b/apps/openmw/mwgui/loadingscreen.hpp index abd59db49..5cee37a51 100644 --- a/apps/openmw/mwgui/loadingscreen.hpp +++ b/apps/openmw/mwgui/loadingscreen.hpp @@ -19,6 +19,8 @@ namespace MWGui void onResChange(int w, int h); private: + bool mFirstLoad; + Ogre::SceneManager* mSceneMgr; Ogre::RenderWindow* mWindow; diff --git a/apps/openmw/mwgui/mode.hpp b/apps/openmw/mwgui/mode.hpp index 4417f7b9c..7e1adcf8b 100644 --- a/apps/openmw/mwgui/mode.hpp +++ b/apps/openmw/mwgui/mode.hpp @@ -35,6 +35,9 @@ namespace MWGui // interactive MessageBox GM_InterMessageBox, + GM_Loading, + GM_LoadingWallpaper, + GM_QuickKeysMenu }; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index b29980b21..a4dd54e78 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -248,6 +248,8 @@ void WindowManager::updateVisible() mSpellWindow->setVisible(false); mQuickKeysMenu->setVisible(false); + mHud->setVisible(true); + // Mouse is visible whenever we're not in game mode MyGUI::PointerManager::getInstance().setVisible(isGuiMode()); @@ -340,6 +342,13 @@ void WindowManager::updateVisible() case GM_Journal: mJournal->setVisible(true); break; + case GM_LoadingWallpaper: + mHud->setVisible(false); + MyGUI::PointerManager::getInstance().setVisible(false); + break; + case GM_Loading: + MyGUI::PointerManager::getInstance().setVisible(false); + break; default: // Unsupported mode, switch back to game break; From 2f0b47fc38314073388030c678ac829a80cea0d6 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Sep 2012 00:21:58 +0200 Subject: [PATCH 03/15] test --- apps/openmw/mwbase/windowmanager.hpp | 1 + apps/openmw/mwgui/loadingscreen.cpp | 34 ++++++++++++++------------ apps/openmw/mwgui/loadingscreen.hpp | 1 + apps/openmw/mwgui/windowmanagerimp.cpp | 5 ++++ apps/openmw/mwgui/windowmanagerimp.hpp | 1 + apps/openmw/mwrender/sky.cpp | 3 --- apps/openmw/mwrender/sky.hpp | 1 - apps/openmw/mwworld/scene.cpp | 5 +++- 8 files changed, 30 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index bd8b7eb18..58fe180e9 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -218,6 +218,7 @@ namespace MWBase virtual void executeInConsole (const std::string& path) = 0; virtual void setLoadingProgress (const std::string& stage, int depth, int current, int total) = 0; + virtual void loadingDone() = 0; }; } diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index c25fad6bc..a56075d4d 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -80,11 +80,7 @@ namespace MWGui mTotalRefsLoading = total; } - if (mTotalCellsLoading == 0) - { - loadingOff(); - return; - } + assert (mTotalCellsLoading != 0); float refProgress; if (mTotalRefsLoading <= 1) @@ -101,11 +97,6 @@ namespace MWGui float progress = (float(mCurrentCellLoading)+refProgress) / float(mTotalCellsLoading); assert(progress <= 1 && progress >= 0); - if (progress >= 1) - { - loadingOff(); - return; - } mLoadingText->setCaption(stage + "... "); mProgressBar->setProgressPosition (static_cast(progress * 1000)); @@ -138,13 +129,14 @@ namespace MWGui if (!hasCompositor) { - mWindow->getViewport(0)->setClearEveryFrame(false); + //mWindow->getViewport(0)->setClearEveryFrame(false); } else { if (!mFirstLoad) - mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName()); - mRectangle->setVisible(true); + { + //mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName()); + } for (unsigned int i = 0; igetNumCompositors(); ++i) { @@ -152,6 +144,9 @@ namespace MWGui } } + mRectangle->setVisible(hasCompositor || mFirstLoad); + std::cout << "rect vis? " << mRectangle->getVisible () << " first load? " << mFirstLoad << std::endl; + mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("Splash/Splash_Bonelord.tga"); mWindow->update(); if (!hasCompositor) @@ -162,17 +157,24 @@ namespace MWGui { Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), true); } - mRectangle->setVisible(false); } + mRectangle->setVisible(false); + // resume 3d rendering mSceneMgr->clearSpecialCaseRenderQueues(); mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE); } } + void LoadingScreen::loadingDone() + { + loadingOff(); + } + void LoadingScreen::loadingOn() { + std::cout << "loading on " <setVisible(false); + //mFirstLoad = false; mWindowManager.removeGuiMode(GM_Loading); mWindowManager.removeGuiMode(GM_LoadingWallpaper); diff --git a/apps/openmw/mwgui/loadingscreen.hpp b/apps/openmw/mwgui/loadingscreen.hpp index 5cee37a51..28d970040 100644 --- a/apps/openmw/mwgui/loadingscreen.hpp +++ b/apps/openmw/mwgui/loadingscreen.hpp @@ -15,6 +15,7 @@ namespace MWGui virtual ~LoadingScreen(); void setLoadingProgress (const std::string& stage, int depth, int current, int total); + void loadingDone(); void onResChange(int w, int h); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index a4dd54e78..99f476574 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -918,3 +918,8 @@ void WindowManager::setLoadingProgress (const std::string& stage, int depth, int { mLoadingScreen->setLoadingProgress (stage, depth, current, total); } + +void WindowManager::loadingDone () +{ + mLoadingScreen->loadingDone (); +} diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 5327bb868..e16b03e43 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -197,6 +197,7 @@ namespace MWGui virtual void executeInConsole (const std::string& path); virtual void setLoadingProgress (const std::string& stage, int depth, int current, int total); + virtual void loadingDone(); private: OEngine::GUI::MyGUIManager *mGuiManager; diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index eba605d0c..60ecd4303 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -11,9 +11,6 @@ #include #include #include -#include -#include -#include #include diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index 09d56dbd9..ee1360853 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -24,7 +24,6 @@ namespace Ogre class Entity; class BillboardSet; class TextureUnitState; - class Overlay; } namespace MWRender diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index c3843b831..8a4a09358 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -290,7 +290,6 @@ namespace MWWorld mCurrentCell = *iter; - // adjust player playerCellChange (mCurrentCell, position, adjustPlayerPos); @@ -300,6 +299,8 @@ namespace MWWorld mRendering.switchToExterior(); mCellChanged = true; + + MWBase::Environment::get().getWindowManager ()->loadingDone (); } //We need the ogre renderer and a scene node. @@ -369,6 +370,8 @@ namespace MWWorld MWBase::Environment::get().getWorld()->adjustSky(); mCellChanged = true; + + MWBase::Environment::get().getWindowManager ()->loadingDone (); } void Scene::changeToExteriorCell (const ESM::Position& position) From f2ab4c929daa35d7401a5347e06bd83f4fb7b210 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Sep 2012 09:26:17 +0200 Subject: [PATCH 04/15] Issue #356: added hardcoded magic effect flags *grumble* --- components/esm/loadmgef.cpp | 29 +++++++++++++++++++++++++++++ components/esm/loadmgef.hpp | 1 + 2 files changed, 30 insertions(+) diff --git a/components/esm/loadmgef.cpp b/components/esm/loadmgef.cpp index 2eda67b61..9aa6b26e3 100644 --- a/components/esm/loadmgef.cpp +++ b/components/esm/loadmgef.cpp @@ -1,5 +1,30 @@ #include "loadmgef.hpp" +namespace +{ + const int NumberOfHardcodedFlags = 143; + const int HardcodedFlags[NumberOfHardcodedFlags] = { + 0x11c8, 0x11c0, 0x11c8, 0x11e0, 0x11e0, 0x11e0, 0x11e0, 0x11d0, + 0x11c0, 0x11c0, 0x11e0, 0x11c0, 0x11184, 0x11184, 0x1f0, 0x1f0, + 0x1f0, 0x11d2, 0x11f0, 0x11d0, 0x11d0, 0x11d1, 0x1d2, 0x1f0, + 0x1d0, 0x1d0, 0x1d1, 0x1f0, 0x11d0, 0x11d0, 0x11d0, 0x11d0, + 0x11d0, 0x11d0, 0x11d0, 0x11d0, 0x11d0, 0x1d0, 0x1d0, 0x11c8, + 0x31c0, 0x11c0, 0x11c0, 0x11c0, 0x1180, 0x11d8, 0x11d8, 0x11d0, + 0x11d0, 0x11180, 0x11180, 0x11180, 0x11180, 0x11180, 0x11180, 0x11180, + 0x11180, 0x11c4, 0x111b8, 0x1040, 0x104c, 0x104c, 0x104c, 0x104c, + 0x1040, 0x1040, 0x1040, 0x11c0, 0x11c0, 0x1cc, 0x1cc, 0x1cc, + 0x1cc, 0x1cc, 0x1c2, 0x1c0, 0x1c0, 0x1c0, 0x1c1, 0x11c2, + 0x11c0, 0x11c0, 0x11c0, 0x11c1, 0x11c0, 0x21192, 0x20190, 0x20190, + 0x20190, 0x21191, 0x11c0, 0x11c0, 0x11c0, 0x11c0, 0x11c0, 0x11c0, + 0x11c0, 0x11c0, 0x11c0, 0x11c0, 0x1c0, 0x11190, 0x9048, 0x9048, + 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, + 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x11c0, 0x1180, 0x1180, + 0x5048, 0x5048, 0x5048, 0x5048, 0x5048, 0x5048, 0x1188, 0x5048, + 0x5048, 0x5048, 0x5048, 0x5048, 0x1048, 0x104c, 0x1048, 0x40, + 0x11c8, 0x1048, 0x1048, 0x1048, 0x1048, 0x1048, 0x1048 + }; +} + namespace ESM { @@ -8,6 +33,10 @@ void MagicEffect::load(ESMReader &esm) esm.getHNT(index, "INDX"); esm.getHNT(data, "MEDT", 36); + + if (index>=0 && index Date: Thu, 13 Sep 2012 09:30:47 +0200 Subject: [PATCH 05/15] Issue #356: basic support for ingredients in ActiveSpells (still using the wrong formula) --- apps/openmw/mwmechanics/activespells.cpp | 49 ++++++++++++++++++------ apps/openmw/mwmechanics/activespells.hpp | 2 +- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 94b98d3be..5361a52c8 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -5,6 +5,8 @@ #include #include +#include +#include #include @@ -46,13 +48,13 @@ namespace MWMechanics for (TIterator iter (begin()); iter!=end(); ++iter) { - const ESM::EffectList& effects = getEffectList (iter->first); + std::pair effects = getEffectList (iter->first); const MWWorld::TimeStamp& start = iter->second.first; float magnitude = iter->second.second; - for (std::vector::const_iterator iter (effects.list.begin()); - iter!=effects.list.end(); ++iter) + for (std::vector::const_iterator iter (effects.first.list.begin()); + iter!=effects.first.list.end(); ++iter) { if (iter->duration) { @@ -73,15 +75,38 @@ namespace MWMechanics } } - const ESM::EffectList& ActiveSpells::getEffectList (const std::string& id) const + std::pair ActiveSpells::getEffectList (const std::string& id) const { if (const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.search (id)) - return spell->effects; + return std::make_pair (spell->effects, false); if (const ESM::Potion *potion = MWBase::Environment::get().getWorld()->getStore().potions.search (id)) - return potion->effects; + return std::make_pair (potion->effects, false); + + if (const ESM::Ingredient *ingredient = + MWBase::Environment::get().getWorld()->getStore().ingreds.search (id)) + { + const ESM::MagicEffect *magicEffect = + MWBase::Environment::get().getWorld()->getStore().magicEffects.find ( + ingredient->data.effectID[0]); + + ESM::ENAMstruct effect; + effect.effectID = ingredient->data.effectID[0]; + effect.skill = ingredient->data.skills[0]; + effect.attribute = ingredient->data.attributes[0]; + effect.range = 0; + effect.area = 0; + effect.duration = magicEffect->data.flags & ESM::MagicEffect::NoDuration ? 0 : 1; + effect.magnMin = 0; + effect.magnMax = 0; + + std::pair result; + + result.first.list.push_back (effect); + result.second = true; + } throw std::runtime_error ("ID " + id + " can not produce lasting effects"); } @@ -92,12 +117,12 @@ namespace MWMechanics bool ActiveSpells::addSpell (const std::string& id) { - const ESM::EffectList& effects = getEffectList (id); + std::pair effects = getEffectList (id); bool found = false; - for (std::vector::const_iterator iter (effects.list.begin()); - iter!=effects.list.end(); ++iter) + for (std::vector::const_iterator iter (effects.first.list.begin()); + iter!=effects.first.list.end(); ++iter) { if (iter->duration) { @@ -155,12 +180,12 @@ namespace MWMechanics double ActiveSpells::timeToExpire (const TIterator& iterator) const { - const ESM::EffectList& effects = getEffectList (iterator->first); + std::pair effects = getEffectList (iterator->first); int duration = 0; - for (std::vector::const_iterator iter (effects.list.begin()); - iter!=effects.list.end(); ++iter) + for (std::vector::const_iterator iter (effects.first.list.begin()); + iter!=effects.first.list.end(); ++iter) { if (iter->duration>duration) duration = iter->duration; diff --git a/apps/openmw/mwmechanics/activespells.hpp b/apps/openmw/mwmechanics/activespells.hpp index 2226cea84..6a1205bfb 100644 --- a/apps/openmw/mwmechanics/activespells.hpp +++ b/apps/openmw/mwmechanics/activespells.hpp @@ -37,7 +37,7 @@ namespace MWMechanics void update() const; - const ESM::EffectList& getEffectList (const std::string& id) const; + std::pair getEffectList (const std::string& id) const; public: From 677158c477da1fa08ad9353430eb9b1511c24b5e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Sep 2012 10:41:55 +0200 Subject: [PATCH 06/15] added typesafe access functions for GMST values --- components/esm/loadgmst.cpp | 35 +++++++++++++++++++++++++++++++++++ components/esm/loadgmst.hpp | 9 +++++++++ 2 files changed, 44 insertions(+) diff --git a/components/esm/loadgmst.cpp b/components/esm/loadgmst.cpp index 677642e31..4bd464da6 100644 --- a/components/esm/loadgmst.cpp +++ b/components/esm/loadgmst.cpp @@ -1,8 +1,15 @@ #include "loadgmst.hpp" +#include + +#include "defs.hpp" + namespace ESM { +/// \todo Review GMST "fixing". Probably remove completely or at least make it optional. Its definitely not +/// working properly in its current state and I doubt it can be fixed without breaking other stuff. + // Some handy macros #define cI(s,x) { if(id == (s)) return (i == (x)); } #define cF(s,x) { if(id == (s)) return (f == (x)); } @@ -169,4 +176,32 @@ void GameSetting::load(ESMReader &esm) dirty = true; } +int GameSetting::getInt() const +{ + switch (type) + { + case VT_Float: return static_cast (f); + case VT_Int: return i; + default: throw std::runtime_error ("GMST " + id + " is not of a numeric type"); + } +} + +int GameSetting::getFloat() const +{ + switch (type) + { + case VT_Float: return f; + case VT_Int: return i; + default: throw std::runtime_error ("GMST " + id + " is not of a numeric type"); + } +} + +std::string GameSetting::getString() const +{ + if (type==VT_String) + return str; + + throw std::runtime_error ("GMST " + id + " is not a string"); +} + } diff --git a/components/esm/loadgmst.hpp b/components/esm/loadgmst.hpp index 01fbc3067..f63028731 100644 --- a/components/esm/loadgmst.hpp +++ b/components/esm/loadgmst.hpp @@ -83,6 +83,15 @@ struct GameSetting bool isDirtyBloodmoon(); void load(ESMReader &esm); + + int getInt() const; + ///< Throws an exception if GMST is not of type int or float. + + int getFloat() const; + ///< Throws an exception if GMST is not of type int or float. + + std::string getString() const; + ///< Throwns an exception if GMST is not of type string. }; } #endif From 9dcf8939e96edd7e1b988b8d5d65af9357b256ae Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Sep 2012 10:45:32 +0200 Subject: [PATCH 07/15] Issue #356: added function for fatigue term calculation --- apps/openmw/mwmechanics/creaturestats.cpp | 20 ++++++++++++++++++++ apps/openmw/mwmechanics/creaturestats.hpp | 3 +++ 2 files changed, 23 insertions(+) diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 09603bff2..49e5bb390 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -1,5 +1,12 @@ #include "creaturestats.hpp" +#include + +#include + +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + namespace MWMechanics { CreatureStats::CreatureStats() @@ -55,4 +62,17 @@ namespace MWMechanics { return mAiSequence; } + + float CreatureStats::getFatigueTerm() const + { + int max = getFatigue().getModified(); + int current = getFatigue().getCurrent(); + + float normalised = max==0 ? 1 : std::max (0.0f, static_cast (current)/max); + + const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + + return store.gameSettings.find ("fFatigueBase")->getFloat() + - store.gameSettings.find ("fFatigueMult")->getFloat() * (1-normalised); + } } diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index d19972e7b..bb6ec9451 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -106,6 +106,9 @@ namespace MWMechanics const AiSequence& getAiSequence() const; AiSequence& getAiSequence(); + + float getFatigueTerm() const; + ///< Return effective fatigue }; // Inline const getters From 2934987f78a556e0451bc8498f597af37169b51a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Sep 2012 10:52:34 +0200 Subject: [PATCH 08/15] Issue #356: Some CreatureStats cleanup --- apps/openmw/mwmechanics/creaturestats.cpp | 172 +++++++++++++++++++++ apps/openmw/mwmechanics/creaturestats.hpp | 178 ---------------------- 2 files changed, 172 insertions(+), 178 deletions(-) diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 49e5bb390..0d8dab0f5 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -75,4 +75,176 @@ namespace MWMechanics return store.gameSettings.find ("fFatigueBase")->getFloat() - store.gameSettings.find ("fFatigueMult")->getFloat() * (1-normalised); } + + const Stat &CreatureStats::getAttribute(int index) const + { + if (index < 0 || index > 7) { + throw std::runtime_error("attribute index is out of range"); + } + return mAttributes[index]; + } + + const DynamicStat &CreatureStats::getHealth() const + { + return mDynamic[0]; + } + + const DynamicStat &CreatureStats::getMagicka() const + { + return mDynamic[1]; + } + + const DynamicStat &CreatureStats::getFatigue() const + { + return mDynamic[2]; + } + + const Spells &CreatureStats::getSpells() const + { + return mSpells; + } + + const ActiveSpells &CreatureStats::getActiveSpells() const + { + return mActiveSpells; + } + + const MagicEffects &CreatureStats::getMagicEffects() const + { + return mMagicEffects; + } + + int CreatureStats::getLevel() const + { + return mLevel; + } + + int CreatureStats::getHello() const + { + return mHello; + } + + int CreatureStats::getFight() const + { + return mFight; + } + + int CreatureStats::getFlee() const + { + return mFlee; + } + + int CreatureStats::getAlarm() const + { + return mAlarm; + } + + Stat &CreatureStats::getAttribute(int index) + { + if (index < 0 || index > 7) { + throw std::runtime_error("attribute index is out of range"); + } + return mAttributes[index]; + } + + DynamicStat &CreatureStats::getHealth() + { + return mDynamic[0]; + } + + DynamicStat &CreatureStats::getMagicka() + { + return mDynamic[1]; + } + + DynamicStat &CreatureStats::getFatigue() + { + return mDynamic[2]; + } + + DynamicStat &CreatureStats::getDynamic(int index) + { + if (index < 0 || index > 2) { + throw std::runtime_error("dynamic stat index is out of range"); + } + return mDynamic[index]; + } + + Spells &CreatureStats::getSpells() + { + return mSpells; + } + + void CreatureStats::setSpells(const Spells &spells) + { + mSpells = spells; + } + + ActiveSpells &CreatureStats::getActiveSpells() + { + return mActiveSpells; + } + + MagicEffects &CreatureStats::getMagicEffects() + { + return mMagicEffects; + } + + void CreatureStats::setAttribute(int index, const Stat &value) + { + if (index < 0 || index > 7) { + throw std::runtime_error("attribute index is out of range"); + } + mAttributes[index] = value; + } + + void CreatureStats::setHealth(const DynamicStat &value) + { + mDynamic[0] = value; + } + + void CreatureStats::setMagicka(const DynamicStat &value) + { + mDynamic[1] = value; + } + + void CreatureStats::setFatigue(const DynamicStat &value) + { + mDynamic[2] = value; + } + + void CreatureStats::setLevel(int level) + { + mLevel = level; + } + + void CreatureStats::setActiveSpells(const ActiveSpells &active) + { + mActiveSpells = active; + } + + void CreatureStats::setMagicEffects(const MagicEffects &effects) + { + mMagicEffects = effects; + } + + void CreatureStats::setHello(int value) + { + mHello = value; + } + + void CreatureStats::setFight(int value) + { + mFight = value; + } + + void CreatureStats::setFlee(int value) + { + mFlee = value; + } + + void CreatureStats::setAlarm(int value) + { + mAlarm = value; + } } diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index bb6ec9451..d8d0f957a 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -110,184 +110,6 @@ namespace MWMechanics float getFatigueTerm() const; ///< Return effective fatigue }; - - // Inline const getters - - inline const Stat & - CreatureStats::getAttribute(int index) const { - if (index < 0 || index > 7) { - throw std::runtime_error("attribute index is out of range"); - } - return mAttributes[index]; - } - - inline const DynamicStat & - CreatureStats::getHealth() const { - return mDynamic[0]; - } - - inline const DynamicStat & - CreatureStats::getMagicka() const { - return mDynamic[1]; - } - - inline const DynamicStat & - CreatureStats::getFatigue() const { - return mDynamic[2]; - } - - inline const Spells & - CreatureStats::getSpells() const { - return mSpells; - } - - inline const ActiveSpells & - CreatureStats::getActiveSpells() const { - return mActiveSpells; - } - - inline const MagicEffects & - CreatureStats::getMagicEffects() const { - return mMagicEffects; - } - - inline int - CreatureStats::getLevel() const { - return mLevel; - } - - inline int - CreatureStats::getHello() const { - return mHello; - } - - inline int - CreatureStats::getFight() const { - return mFight; - } - - inline int - CreatureStats::getFlee() const { - return mFlee; - } - - inline int - CreatureStats::getAlarm() const { - return mAlarm; - } - - // Inline non-const getters - - inline Stat & - CreatureStats::getAttribute(int index) { - if (index < 0 || index > 7) { - throw std::runtime_error("attribute index is out of range"); - } - return mAttributes[index]; - } - - inline DynamicStat & - CreatureStats::getHealth() { - return mDynamic[0]; - } - - inline DynamicStat & - CreatureStats::getMagicka() { - return mDynamic[1]; - } - - inline DynamicStat & - CreatureStats::getFatigue() { - return mDynamic[2]; - } - - inline DynamicStat & - CreatureStats::getDynamic(int index) { - if (index < 0 || index > 2) { - throw std::runtime_error("dynamic stat index is out of range"); - } - return mDynamic[index]; - } - - inline Spells & - CreatureStats::getSpells() { - return mSpells; - } - - inline void - CreatureStats::setSpells(const Spells &spells) { - mSpells = spells; - } - - inline ActiveSpells & - CreatureStats::getActiveSpells() { - return mActiveSpells; - } - - inline MagicEffects & - CreatureStats::getMagicEffects() { - return mMagicEffects; - } - - // Inline setters - - inline void - CreatureStats::setAttribute(int index, const Stat &value) { - if (index < 0 || index > 7) { - throw std::runtime_error("attribute index is out of range"); - } - mAttributes[index] = value; - } - - inline void - CreatureStats::setHealth(const DynamicStat &value) { - mDynamic[0] = value; - } - - inline void - CreatureStats::setMagicka(const DynamicStat &value) { - mDynamic[1] = value; - } - - inline void - CreatureStats::setFatigue(const DynamicStat &value) { - mDynamic[2] = value; - } - - inline void - CreatureStats::setLevel(int level) { - mLevel = level; - } - - inline void - CreatureStats::setActiveSpells(const ActiveSpells &active) { - mActiveSpells = active; - } - - inline void - CreatureStats::setMagicEffects(const MagicEffects &effects) { - mMagicEffects = effects; - } - - inline void - CreatureStats::setHello(int value) { - mHello = value; - } - - inline void - CreatureStats::setFight(int value) { - mFight = value; - } - - inline void - CreatureStats::setFlee(int value) { - mFlee = value; - } - - inline void - CreatureStats::setAlarm(int value) { - mAlarm = value; - } } #endif From 0af0dc0d5de485872b04b74764820654448126af Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Sep 2012 11:13:05 +0200 Subject: [PATCH 09/15] Issue #356: More CreatureStats cleanup --- apps/openmw/mwmechanics/creaturestats.cpp | 46 +---------------------- apps/openmw/mwmechanics/creaturestats.hpp | 5 --- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 0d8dab0f5..91a9225fe 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -8,51 +8,7 @@ #include "../mwbase/world.hpp" namespace MWMechanics -{ - CreatureStats::CreatureStats() - {} - - // Can't use all benefits of members initialization because of - // lack of copy constructors - CreatureStats::CreatureStats(const CreatureStats &orig) - : mLevel(orig.mLevel), mHello(orig.mHello), mFight(orig.mFight), - mFlee(orig.mFlee), mAlarm(orig.mAlarm) - { - for (int i = 0; i < 8; ++i) { - mAttributes[i] = orig.mAttributes[i]; - } - for (int i = 0; i < 3; ++i) { - mDynamic[i] = orig.mDynamic[i]; - } - mSpells = orig.mSpells; - mActiveSpells = orig.mActiveSpells; - mMagicEffects = orig.mMagicEffects; - } - - CreatureStats::~CreatureStats() - {} - - const CreatureStats & - CreatureStats::operator=(const CreatureStats &orig) - { - for (int i = 0; i < 8; ++i) { - mAttributes[i] = orig.mAttributes[i]; - } - for (int i = 0; i < 3; ++i) { - mDynamic[i] = orig.mDynamic[i]; - } - mLevel = orig.mLevel; - mSpells = orig.mSpells; - mActiveSpells = orig.mActiveSpells; - mMagicEffects = orig.mMagicEffects; - mHello = orig.mHello; - mFight = orig.mFight; - mFlee = orig.mFlee; - mAlarm = orig.mAlarm; - - return *this; - } - +{ const AiSequence& CreatureStats::getAiSequence() const { return mAiSequence; diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index d8d0f957a..a6fb6779a 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -31,11 +31,6 @@ namespace MWMechanics AiSequence mAiSequence; public: - CreatureStats(); - CreatureStats(const CreatureStats &); - virtual ~CreatureStats(); - - const CreatureStats & operator=(const CreatureStats &); const Stat & getAttribute(int index) const; From 9de7b3bf90d5a5c6691226276faaea9c4b71d51a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Sep 2012 11:30:59 +0200 Subject: [PATCH 10/15] Issue #356: Properly support ingredients effect in ActiveSpells (hopefully) --- apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwmechanics/activespells.cpp | 101 +++++++++++++++++------ apps/openmw/mwmechanics/activespells.hpp | 9 +- 3 files changed, 87 insertions(+), 25 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 8aab9da56..063f39d2a 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -365,7 +365,7 @@ namespace MWClass /// \todo consider instant effects - return stats.getActiveSpells().addSpell (id); + return stats.getActiveSpells().addSpell (id, actor); } void Npc::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 5361a52c8..b8273093c 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -7,12 +7,18 @@ #include #include #include +#include #include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" +#include "../mwworld/class.hpp" + +#include "creaturestats.hpp" +#include "npcstats.hpp" + namespace MWMechanics { void ActiveSpells::update() const @@ -43,36 +49,66 @@ namespace MWMechanics } if (rebuild) - { - mEffects = MagicEffects(); + rebuildEffects(); + } - for (TIterator iter (begin()); iter!=end(); ++iter) - { - std::pair effects = getEffectList (iter->first); + void ActiveSpells::rebuildEffects() const + { + MWWorld::TimeStamp now = MWBase::Environment::get().getWorld()->getTimeStamp(); + + mEffects = MagicEffects(); - const MWWorld::TimeStamp& start = iter->second.first; - float magnitude = iter->second.second; + for (TIterator iter (begin()); iter!=end(); ++iter) + { + std::pair effects = getEffectList (iter->first); - for (std::vector::const_iterator iter (effects.first.list.begin()); - iter!=effects.first.list.end(); ++iter) + const MWWorld::TimeStamp& start = iter->second.first; + float magnitude = iter->second.second; + + for (std::vector::const_iterator iter (effects.first.list.begin()); + iter!=effects.first.list.end(); ++iter) + { + if (iter->duration) { - if (iter->duration) + int duration = iter->duration; + + if (effects.second) + duration *= magnitude; + + MWWorld::TimeStamp end = start; + end += static_cast (duration)* + MWBase::Environment::get().getWorld()->getTimeScaleFactor()/(60*60); + + if (end>now) { - MWWorld::TimeStamp end = start; - end += static_cast (iter->duration)* - MWBase::Environment::get().getWorld()->getTimeScaleFactor()/(60*60); - - if (end>now) + EffectParam param; + + if (effects.second) { - EffectParam param; - param.mMagnitude = static_cast ( - (iter->magnMax-iter->magnMin+1)*magnitude + iter->magnMin); - mEffects.add (*iter, param); + const ESM::MagicEffect *magicEffect = + MWBase::Environment::get().getWorld()->getStore().magicEffects.find ( + iter->effectID); + + if (iter->duration==0) + { + param.mMagnitude = + static_cast (magnitude / (0.1 * magicEffect->data.baseCost)); + } + else + { + param.mMagnitude = + static_cast (0.05*magnitude / (0.1 * magicEffect->data.baseCost)); + } } + else + param.mMagnitude = static_cast ( + (iter->magnMax-iter->magnMin)*magnitude + iter->magnMin); + + mEffects.add (*iter, param); } } } - } + } } std::pair ActiveSpells::getEffectList (const std::string& id) const @@ -99,8 +135,8 @@ namespace MWMechanics effect.range = 0; effect.area = 0; effect.duration = magicEffect->data.flags & ESM::MagicEffect::NoDuration ? 0 : 1; - effect.magnMin = 0; - effect.magnMax = 0; + effect.magnMin = 1; + effect.magnMax = 1; std::pair result; @@ -115,7 +151,7 @@ namespace MWMechanics : mSpellsChanged (false), mLastUpdate (MWBase::Environment::get().getWorld()->getTimeStamp()) {} - bool ActiveSpells::addSpell (const std::string& id) + bool ActiveSpells::addSpell (const std::string& id, const MWWorld::Ptr& actor) { std::pair effects = getEffectList (id); @@ -138,6 +174,22 @@ namespace MWMechanics float random = static_cast (std::rand()) / RAND_MAX; + if (effects.second) + { + // ingredient -> special treatment required. + const CreatureStats& creatureStats = MWWorld::Class::get (actor).getCreatureStats (actor); + const NpcStats& npcStats = MWWorld::Class::get (actor).getNpcStats (actor); + + float x = + (npcStats.getSkill (ESM::Skill::Alchemy).getModified() + + 0.2 * creatureStats.getAttribute (1).getModified() + + 0.1 * creatureStats.getAttribute (7).getModified()) + * creatureStats.getFatigueTerm(); + random *= 100; + random = random / std::min (x, 100.0f); + random *= 0.25 * x; + } + if (iter==mSpells.end()) mSpells.insert (std::make_pair (id, std::make_pair (MWBase::Environment::get().getWorld()->getTimeStamp(), random))); @@ -191,6 +243,9 @@ namespace MWMechanics duration = iter->duration; } + if (effects.second) + duration *= iterator->second.second; + double scaledDuration = duration * MWBase::Environment::get().getWorld()->getTimeScaleFactor()/(60*60); diff --git a/apps/openmw/mwmechanics/activespells.hpp b/apps/openmw/mwmechanics/activespells.hpp index 6a1205bfb..e7a239854 100644 --- a/apps/openmw/mwmechanics/activespells.hpp +++ b/apps/openmw/mwmechanics/activespells.hpp @@ -15,6 +15,11 @@ namespace ESM struct EffectList; } +namespace MWWorld +{ + class Ptr; +} + namespace MWMechanics { /// \brief Lasting spell effects @@ -36,6 +41,8 @@ namespace MWMechanics mutable MWWorld::TimeStamp mLastUpdate; void update() const; + + void rebuildEffects() const; std::pair getEffectList (const std::string& id) const; @@ -43,7 +50,7 @@ namespace MWMechanics ActiveSpells(); - bool addSpell (const std::string& id); + bool addSpell (const std::string& id, const MWWorld::Ptr& actor); ///< Overwrites an existing spell with the same ID. If the spell does not have any /// non-instant effects, it is ignored. /// From 7ad80e306b3292d14c0055895e7bef8093908f01 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Sep 2012 12:33:09 +0200 Subject: [PATCH 11/15] fixed the disappearing --- apps/openmw/engine.cpp | 4 ++ apps/openmw/mwgui/loadingscreen.cpp | 57 +++++++++++++++++------------ apps/openmw/mwgui/loadingscreen.hpp | 3 ++ 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 82bd3b69b..db6edf397 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -162,6 +162,10 @@ void OMW::Engine::loadBSA() dataDirectory = iter->string(); std::cout << "Data dir " << dataDirectory << std::endl; Bsa::addDir(dataDirectory, mFSStrict); + + // Workaround: Mygui does not find textures in non-BSA subfolders, _unless_ they are explicitely added like this + // For splash screens, this is OK to do, but eventually we will need an investigation why this is necessary + Bsa::addDir(dataDirectory + "/Splash", mFSStrict); } } diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index a56075d4d..e41f2eec9 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -22,6 +22,7 @@ namespace MWGui , WindowBase("openmw_loading_screen.layout", parWindowManager) , mLoadingOn(false) , mLastRenderTime(0.f) + , mLastWallpaperChangeTime(0.f) , mFirstLoad(true) { getWidget(mLoadingText, "LoadingText"); @@ -107,6 +108,11 @@ namespace MWGui { mLastRenderTime = mTimer.getMilliseconds (); + if (mFirstLoad && mTimer.getMilliseconds () > mLastWallpaperChangeTime + 3000*1) + { + mLastWallpaperChangeTime = mTimer.getMilliseconds (); + changeWallpaper(); + } // Turn off rendering except the GUI mSceneMgr->clearSpecialCaseRenderQueues(); @@ -129,13 +135,14 @@ namespace MWGui if (!hasCompositor) { - //mWindow->getViewport(0)->setClearEveryFrame(false); + mWindow->getViewport(0)->setClearEveryFrame(false); } else { if (!mFirstLoad) { - //mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName()); + mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName()); + mRectangle->setVisible(true); } for (unsigned int i = 0; igetNumCompositors(); ++i) @@ -144,9 +151,6 @@ namespace MWGui } } - mRectangle->setVisible(hasCompositor || mFirstLoad); - std::cout << "rect vis? " << mRectangle->getVisible () << " first load? " << mFirstLoad << std::endl; - mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("Splash/Splash_Bonelord.tga"); mWindow->update(); if (!hasCompositor) @@ -174,44 +178,49 @@ namespace MWGui void LoadingScreen::loadingOn() { - std::cout << "loading on " < splash; - splash.push_back ("Splash/Splash_Bonelord.tga"); - splash.push_back ("Splash/Splash_ClannDaddy.tga"); - splash.push_back ("Splash/Splash_ClannFear.tga"); - splash.push_back ("Splash/Splash_Daedroth.tga"); - splash.push_back ("Splash/Splash_Hunger.tga"); - splash.push_back ("Splash/Splash_KwamaWarrior.tga"); - splash.push_back ("Splash/Splash_Netch.tga"); - splash.push_back ("Splash/Splash_NixHound.tga"); - splash.push_back ("Splash/Splash_Siltstriker.tga"); - splash.push_back ("Splash/Splash_Skeleton.tga"); - splash.push_back ("Splash/Splash_SphereCenturion.tga"); - - mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(splash[rand() % splash.size()]); - mRectangle->setVisible(true); + changeWallpaper(); mWindowManager.pushGuiMode(GM_LoadingWallpaper); } else + { + mBackgroundImage->setImageTexture(""); mWindowManager.pushGuiMode(GM_Loading); + } } void LoadingScreen::loadingOff() { - std::cout << "loading off " << std::endl; setVisible(false); mLoadingOn = false; - //mFirstLoad = false; + mFirstLoad = false; mWindowManager.removeGuiMode(GM_Loading); mWindowManager.removeGuiMode(GM_LoadingWallpaper); } + + void LoadingScreen::changeWallpaper () + { + /// \todo use a directory listing here + std::vector splash; + splash.push_back ("Splash_Bonelord.tga"); + splash.push_back ("Splash_ClannDaddy.tga"); + splash.push_back ("Splash_Clannfear.tga"); + splash.push_back ("Splash_Daedroth.tga"); + splash.push_back ("Splash_Hunger.tga"); + splash.push_back ("Splash_KwamaWarrior.tga"); + splash.push_back ("Splash_Netch.tga"); + splash.push_back ("Splash_NixHound.tga"); + splash.push_back ("Splash_Siltstriker.tga"); + splash.push_back ("Splash_Skeleton.tga"); + splash.push_back ("Splash_SphereCenturion.tga"); + + mBackgroundImage->setImageTexture (splash[rand() % splash.size()]); + } } diff --git a/apps/openmw/mwgui/loadingscreen.hpp b/apps/openmw/mwgui/loadingscreen.hpp index 28d970040..a012793ca 100644 --- a/apps/openmw/mwgui/loadingscreen.hpp +++ b/apps/openmw/mwgui/loadingscreen.hpp @@ -25,6 +25,7 @@ namespace MWGui Ogre::SceneManager* mSceneMgr; Ogre::RenderWindow* mWindow; + unsigned long mLastWallpaperChangeTime; unsigned long mLastRenderTime; Ogre::Timer mTimer; @@ -46,6 +47,8 @@ namespace MWGui void loadingOn(); void loadingOff(); + + void changeWallpaper(); }; } From 2ccd7a480dbe5fa629316599e78ff302badd9cb0 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Sep 2012 13:01:59 +0200 Subject: [PATCH 12/15] Issue #356: added a missing return --- apps/openmw/mwmechanics/activespells.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index b8273093c..67e5bad3d 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -142,6 +142,8 @@ namespace MWMechanics result.first.list.push_back (effect); result.second = true; + + return result; } throw std::runtime_error ("ID " + id + " can not produce lasting effects"); From fe68a252d5ba4c7ea0f933f3a719a63fc2eae2d4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Sep 2012 13:02:26 +0200 Subject: [PATCH 13/15] Issue #356: Implemented ingredient eating --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwclass/ingredient.cpp | 17 +++++++++++ apps/openmw/mwclass/ingredient.hpp | 7 +++++ apps/openmw/mwworld/actioneat.cpp | 49 ++++++++++++++++++++++++++++++ apps/openmw/mwworld/actioneat.hpp | 19 ++++++++++++ 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 apps/openmw/mwworld/actioneat.cpp create mode 100644 apps/openmw/mwworld/actioneat.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 4cf3bd7fd..68dd9b8a8 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -51,7 +51,7 @@ add_openmw_dir (mwworld refdata worldimp physicssystem scene globals class action nullaction actionteleport containerstore actiontalk actiontake manualref player cellfunctors cells localscripts customdata weather inventorystore ptr actionopen actionread - actionequip timestamp actionalchemy cellstore actionapply + actionequip timestamp actionalchemy cellstore actionapply actioneat ) add_openmw_dir (mwclass diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index f0354de76..4d88be1eb 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -11,6 +11,7 @@ #include "../mwworld/actiontake.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/physicssystem.hpp" +#include "../mwworld/actioneat.hpp" #include "../mwgui/tooltips.hpp" @@ -19,6 +20,14 @@ namespace MWClass { + std::string Ingredient::getId (const MWWorld::Ptr& ptr) const + { + MWWorld::LiveCellRef *ref = + ptr.get(); + + return ref->base->mId; + } + void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const { const std::string model = getModel(ptr); @@ -84,6 +93,14 @@ namespace MWClass return ref->base->data.value; } + + boost::shared_ptr Ingredient::use (const MWWorld::Ptr& ptr) const + { + boost::shared_ptr action (new MWWorld::ActionEat (ptr)); + + return action; + } + void Ingredient::registerSelf() { boost::shared_ptr instance (new Ingredient); diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index 1365c4a71..0afd202fb 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -12,6 +12,9 @@ namespace MWClass public: + virtual std::string getId (const MWWorld::Ptr& ptr) const; + ///< Return ID of \a ptr + virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const; ///< Add reference into a cell for rendering @@ -37,6 +40,10 @@ 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 boost::shared_ptr use (const MWWorld::Ptr& ptr) + const; + ///< Generate action for using via inventory menu + static void registerSelf(); virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwworld/actioneat.cpp b/apps/openmw/mwworld/actioneat.cpp new file mode 100644 index 000000000..abd1ac4b9 --- /dev/null +++ b/apps/openmw/mwworld/actioneat.cpp @@ -0,0 +1,49 @@ + +#include "actioneat.hpp" + +#include + +#include + +#include + +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + +#include "../mwmechanics/creaturestats.hpp" +#include "../mwmechanics/npcstats.hpp" + +#include "class.hpp" + +namespace MWWorld +{ + void ActionEat::executeImp (const Ptr& actor) + { + // remove used item + getTarget().getRefData().setCount (getTarget().getRefData().getCount()-1); + + // check for success + const MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (actor).getCreatureStats (actor); + MWMechanics::NpcStats& npcStats = MWWorld::Class::get (actor).getNpcStats (actor); + + float x = + (npcStats.getSkill (ESM::Skill::Alchemy).getModified() + + 0.2 * creatureStats.getAttribute (1).getModified() + + 0.1 * creatureStats.getAttribute (7).getModified()) + * creatureStats.getFatigueTerm(); + + if (x>=100*static_cast (std::rand()) / RAND_MAX) + { + // apply to actor + std::string id = Class::get (getTarget()).getId (getTarget()); + + Class::get (actor).apply (actor, id, actor); + // we ignore the result here. Skill increases no matter if the ingredient did something or not. + + // increase skill + Class::get (actor).skillUsageSucceeded (actor, ESM::Skill::Alchemy, 1); + } + } + + ActionEat::ActionEat (const MWWorld::Ptr& object) : Action (false, object) {} +} diff --git a/apps/openmw/mwworld/actioneat.hpp b/apps/openmw/mwworld/actioneat.hpp new file mode 100644 index 000000000..ce5330db7 --- /dev/null +++ b/apps/openmw/mwworld/actioneat.hpp @@ -0,0 +1,19 @@ +#ifndef GAME_MWWORLD_ACTIONEAT_H +#define GAME_MWWORLD_ACTIONEAT_H + +#include "action.hpp" +#include "ptr.hpp" + +namespace MWWorld +{ + class ActionEat : public Action + { + virtual void executeImp (const Ptr& actor); + + public: + + ActionEat (const MWWorld::Ptr& object); + }; +} + +#endif From b5ddc8d4fb3af8d050ee852bee63a0380fed947f Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 13 Sep 2012 13:10:02 +0200 Subject: [PATCH 14/15] Fix the marker collision; also, nodes marked with NCO are now correctly ignored for collision. --- components/nifbullet/bullet_nif_loader.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index b70404635..0fb758ea8 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -164,10 +164,12 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, // the flags we currently use, at least. flags |= node->flags; - // Marker objects: just skip the entire node + // Marker objects: no collision /// \todo don't do this in the editor if (node->name.find("marker") != std::string::npos) - return; + { + flags |= 0x800; + } // Check for extra data Nif::Extra *e = node; @@ -183,12 +185,10 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, // affecting the entire subtree of this node Nif::NiStringExtraData *sd = (Nif::NiStringExtraData*)e; - if (sd->string == "NCO" && !raycastingOnly) + if (sd->string == "NCO") { // No collision. Use an internal flag setting to mark this. - // We ignor this node! flags |= 0x800; - return; } else if (sd->string == "MRK" && !raycastingOnly) // Marker objects. These are only visible in the @@ -234,7 +234,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, } else if (node->recType == Nif::RC_NiTriShape && (isCollisionNode || !hasCollisionNode)) { - cShape->collide = true; + cShape->collide = !(flags&0x800); handleNiTriShape(dynamic_cast(node), flags,node->trafo.rotation,node->trafo.pos,node->trafo.scale,raycastingOnly); } else if(node->recType == Nif::RC_RootCollisionNode) From 5706caa141044553809a8646e29da06b07bd28fa Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Sep 2012 13:30:57 +0200 Subject: [PATCH 15/15] Issue #356: added ingredient eating sound effect --- apps/openmw/mwclass/ingredient.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 4d88be1eb..bdeb0e82b 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -98,6 +98,8 @@ namespace MWClass { boost::shared_ptr action (new MWWorld::ActionEat (ptr)); + action->setSound ("Swallow"); + return action; }