mrcheko 11 years ago
parent fd9f8c34f6
commit f50ff0b1c4

@ -94,35 +94,39 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
MWBase::Environment::get().getSoundManager()->update(frametime); MWBase::Environment::get().getSoundManager()->update(frametime);
// global scripts // global scripts
if (MWBase::Environment::get().getStateManager()->getState()== MWBase::Environment::get().getScriptManager()->getGlobalScripts().run();
MWBase::StateManager::State_Running)
{
MWBase::Environment::get().getScriptManager()->getGlobalScripts().run();
bool changed = MWBase::Environment::get().getWorld()->hasCellChanged();
// local scripts bool changed = MWBase::Environment::get().getWorld()->hasCellChanged();
executeLocalScripts(); // This does not handle the case where a global script causes a
// cell change, followed by a cell change in a local script during
// the same frame.
if (changed) // keep change flag for another frame, if cell changed happened in local script // local scripts
MWBase::Environment::get().getWorld()->markCellAsUnchanged(); executeLocalScripts(); // This does not handle the case where a global script causes a
// cell change, followed by a cell change in a local script during
// the same frame.
if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) if (changed) // keep change flag for another frame, if cell changed happened in local script
MWBase::Environment::get().getWorld()->advanceTime( MWBase::Environment::get().getWorld()->markCellAsUnchanged();
frametime*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600);
// update actors if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
MWBase::Environment::get().getMechanicsManager()->update(frametime, MWBase::Environment::get().getWorld()->advanceTime(
MWBase::Environment::get().getWindowManager()->isGuiMode()); frametime*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600);
// update world // update actors
MWBase::Environment::get().getWorld()->update(frametime, MWBase::Environment::get().getWindowManager()->isGuiMode()); MWBase::Environment::get().getMechanicsManager()->update(frametime,
MWBase::Environment::get().getWindowManager()->isGuiMode());
// update game state if (MWBase::Environment::get().getStateManager()->getState()==
MWBase::Environment::get().getStateManager()->update (frametime); MWBase::StateManager::State_Running)
{
MWWorld::Ptr player = mEnvironment.getWorld()->getPlayer().getPlayer();
if(MWWorld::Class::get(player).getCreatureStats(player).isDead())
MWBase::Environment::get().getStateManager()->endGame();
} }
// update world
MWBase::Environment::get().getWorld()->update(frametime, MWBase::Environment::get().getWindowManager()->isGuiMode());
// update game state
MWBase::Environment::get().getStateManager()->update (frametime);
// update GUI // update GUI
Ogre::RenderWindow* window = mOgre->getWindow(); Ogre::RenderWindow* window = mOgre->getWindow();

@ -43,7 +43,6 @@ namespace MWRender
{ {
class ExternalRendering; class ExternalRendering;
class Animation; class Animation;
class Camera;
} }
namespace MWMechanics namespace MWMechanics
@ -113,7 +112,7 @@ namespace MWBase
virtual MWWorld::CellStore *getInterior (const std::string& name) = 0; virtual MWWorld::CellStore *getInterior (const std::string& name) = 0;
virtual MWRender::Camera* getCamera() const = 0; virtual void useDeathCamera() = 0;
virtual void setWaterHeight(const float height) = 0; virtual void setWaterHeight(const float height) = 0;

@ -181,8 +181,9 @@ namespace MWInput
switch (action) switch (action)
{ {
case A_GameMenu: case A_GameMenu:
if(MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_Running) if(!(MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_Running
toggleMainMenu (); && MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_MainMenu))
toggleMainMenu ();
break; break;
case A_Screenshot: case A_Screenshot:
screenshot(); screenshot();
@ -303,8 +304,8 @@ namespace MWInput
// Disable movement in Gui mode // Disable movement in Gui mode
if (MWBase::Environment::get().getWindowManager()->isGuiMode() if (MWBase::Environment::get().getWindowManager()->isGuiMode()
|| MWWorld::Class::get(mPlayer->getPlayer()).getCreatureStats(mPlayer->getPlayer()).isDead() ) || MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_Running)
return; return;
// Configure player movement according to keyboard input. Actual movement will // Configure player movement according to keyboard input. Actual movement will

@ -19,7 +19,6 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/statemanager.hpp"
#include "npcstats.hpp" #include "npcstats.hpp"
#include "creaturestats.hpp" #include "creaturestats.hpp"

@ -26,14 +26,12 @@
#include "creaturestats.hpp" #include "creaturestats.hpp"
#include "security.hpp" #include "security.hpp"
#include "../mwrender/camera.hpp"
#include "../mwrender/animation.hpp" #include "../mwrender/animation.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/statemanager.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
@ -1058,11 +1056,10 @@ bool CharacterController::kill()
{ {
if( isDead() ) if( isDead() )
{ {
//state=end game only when player's death animation is over //player's death animation is over
if( mPtr.getRefData().getHandle()=="player" && !isAnimPlaying(mCurrentDeath) if( mPtr.getRefData().getHandle()=="player" && !isAnimPlaying(mCurrentDeath)
&& MWBase::Environment::get().getWindowManager()->getMode () != MWGui::GM_MainMenu ) && MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_MainMenu )
{ {
MWBase::Environment::get().getStateManager()->endGame();
MWWorld::Class::get(mPtr).getCreatureStats(mPtr).setHealth(0); MWWorld::Class::get(mPtr).getCreatureStats(mPtr).setHealth(0);
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu); MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
} }
@ -1105,18 +1102,6 @@ bool CharacterController::kill()
if(mAnimation) if(mAnimation)
{ {
//switch to 3rd person before player's death animation
if (mPtr.getRefData().getHandle()=="player")
{
if(MWBase::Environment::get().getWorld()->getCamera()->isVanityOrPreviewModeEnabled() )
{
MWBase::Environment::get().getWorld()->getCamera()->togglePreviewMode(false);
MWBase::Environment::get().getWorld()->getCamera()->toggleVanityMode(false);
}
if(MWBase::Environment::get().getWorld()->getCamera()->isFirstPerson())
MWBase::Environment::get().getWorld()->togglePOV();
}
mAnimation->play(mCurrentDeath, Priority_Death, MWRender::Animation::Group_All, mAnimation->play(mCurrentDeath, Priority_Death, MWRender::Animation::Group_All,
false, 1.0f, "start", "stop", 0.0f, 0); false, 1.0f, "start", "stop", 0.0f, 0);
mAnimation->disable(mCurrentIdle); mAnimation->disable(mCurrentIdle);

@ -70,6 +70,7 @@ void MWState::StateManager::newGame (bool bypass)
void MWState::StateManager::endGame() void MWState::StateManager::endGame()
{ {
mState = State_Ended; mState = State_Ended;
MWBase::Environment::get().getWorld()->useDeathCamera();
} }
void MWState::StateManager::saveGame (const std::string& description, const Slot *slot) void MWState::StateManager::saveGame (const std::string& description, const Slot *slot)

@ -400,9 +400,15 @@ namespace MWWorld
return mCells.getInterior (name); return mCells.getInterior (name);
} }
MWRender::Camera* World::getCamera() const void World::useDeathCamera()
{ {
return mRendering->getCamera(); if(mRendering->getCamera()->isVanityOrPreviewModeEnabled() )
{
mRendering->getCamera()->togglePreviewMode(false);
mRendering->getCamera()->toggleVanityMode(false);
}
if(mRendering->getCamera()->isFirstPerson())
togglePOV();
} }
MWWorld::Player& World::getPlayer() MWWorld::Player& World::getPlayer()

@ -42,6 +42,7 @@ namespace MWRender
class SkyManager; class SkyManager;
class CellRender; class CellRender;
class Animation; class Animation;
class Camera;
} }
struct ContentLoader; struct ContentLoader;
@ -185,7 +186,8 @@ namespace MWWorld
virtual CellStore *getInterior (const std::string& name); virtual CellStore *getInterior (const std::string& name);
virtual MWRender::Camera* getCamera() const; //switch to POV before showing player's death animation
virtual void useDeathCamera();
virtual void setWaterHeight(const float height); virtual void setWaterHeight(const float height);

Loading…
Cancel
Save