made toggle-type script instructions more verbose

This commit is contained in:
Marc Zinnschlag 2011-04-26 21:38:21 +02:00
parent 53e0e38862
commit f52e6bd5ef
7 changed files with 63 additions and 42 deletions

View file

@ -191,7 +191,7 @@ void MWScene::scaleObject (const std::string& handle, float scale)
} }
void MWScene::toggleCollisionMode() bool MWScene::toggleCollisionMode()
{ {
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++) for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++)
{ {
@ -203,6 +203,7 @@ void MWScene::toggleCollisionMode()
act->setGravity(0.); act->setGravity(0.);
act->setVerticalVelocity(0); act->setVerticalVelocity(0);
mFreeFly = true; mFreeFly = true;
return false;
} }
else else
{ {
@ -210,11 +211,15 @@ void MWScene::toggleCollisionMode()
act->enableCollisions(true); act->enableCollisions(true);
act->setGravity(4.); act->setGravity(4.);
act->setVerticalVelocity(0); act->setVerticalVelocity(0);
} return true;
} }
} }
void MWScene::toggleRenderMode (int mode) return false; // This should never happen, but it shall not bother us now, since
// this part of the code needs a rewrite anyway.
}
bool MWScene::toggleRenderMode (int mode)
{ {
switch (mode) switch (mode)
{ {
@ -223,6 +228,8 @@ void MWScene::toggleRenderMode (int mode)
// TODO use a proper function instead of accessing the member variable // TODO use a proper function instead of accessing the member variable
// directly. // directly.
eng->setDebugRenderingMode (!eng->isDebugCreated); eng->setDebugRenderingMode (!eng->isDebugCreated);
break; return eng->isDebugCreated;
} }
return false;
} }

View file

@ -91,12 +91,14 @@ namespace MWRender
/// Toggle collision mode for player. If disabled player object should ignore /// Toggle collision mode for player. If disabled player object should ignore
/// collisions and gravity. /// collisions and gravity.
void toggleCollisionMode(); /// \return Resulting mode
bool toggleCollisionMode();
/// Toggle render mode /// Toggle render mode
/// \todo Using an int instead of a enum here to avoid cyclic includes. Will be fixed /// \todo Using an int instead of a enum here to avoid cyclic includes. Will be fixed
/// when the mw*-refactoring is done. /// when the mw*-refactoring is done.
void toggleRenderMode (int mode); /// \return Resulting mode
bool toggleRenderMode (int mode);
}; };
} }

View file

@ -46,7 +46,9 @@ namespace MWScript
InterpreterContext& context InterpreterContext& context
= static_cast<InterpreterContext&> (runtime.getContext()); = static_cast<InterpreterContext&> (runtime.getContext());
context.getWorld().toggleCollisionMode(); bool enabled = context.getWorld().toggleCollisionMode();
context.messageBox (enabled ? "Collsion -> On" : "Collision -> Off");
} }
}; };

View file

@ -99,7 +99,11 @@ namespace MWScript
InterpreterContext& context = InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext()); static_cast<InterpreterContext&> (runtime.getContext());
bool enabled =
context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug); context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug);
context.messageBox (enabled ?
"Collsion Mesh Rendering -> On" : "Collision Mesh Rendering -> Off");
} }
}; };

View file

@ -22,7 +22,9 @@ namespace MWScript
InterpreterContext& context = InterpreterContext& context =
static_cast<InterpreterContext&> (runtime.getContext()); static_cast<InterpreterContext&> (runtime.getContext());
context.getWorld().toggleSky(); bool enabled = context.getWorld().toggleSky();
context.messageBox (enabled ? "Sky -> On" : "Sky -> Off");
} }
}; };
@ -104,4 +106,3 @@ namespace MWScript
} }
} }
} }

View file

@ -645,12 +645,13 @@ namespace MWWorld
mSkyManager->setDate (mGlobalVariables->getInt ("day"), month); mSkyManager->setDate (mGlobalVariables->getInt ("day"), month);
} }
void World::toggleSky() bool World::toggleSky()
{ {
if (mSky) if (mSky)
{ {
mSky = false; mSky = false;
mSkyManager->disable(); mSkyManager->disable();
return false;
} }
else else
{ {
@ -660,6 +661,7 @@ namespace MWWorld
mSkyManager->setDate (mGlobalVariables->getInt ("day"), mSkyManager->setDate (mGlobalVariables->getInt ("day"),
mGlobalVariables->getInt ("month")); mGlobalVariables->getInt ("month"));
mSkyManager->enable(); mSkyManager->enable();
return true;
} }
} }
@ -853,13 +855,13 @@ namespace MWWorld
mScene.doPhysics (duration, *this, actors); mScene.doPhysics (duration, *this, actors);
} }
void World::toggleCollisionMode() bool World::toggleCollisionMode()
{ {
mScene.toggleCollisionMode(); return mScene.toggleCollisionMode();
} }
void World::toggleRenderMode (RenderMode mode) bool World::toggleRenderMode (RenderMode mode)
{ {
mScene.toggleRenderMode (mode); return mScene.toggleRenderMode (mode);
} }
} }

View file

@ -147,7 +147,8 @@ namespace MWWorld
void setDay (int day); void setDay (int day);
void toggleSky(); bool toggleSky();
///< \return Resulting mode
int getMasserPhase() const; int getMasserPhase() const;
@ -185,12 +186,14 @@ namespace MWWorld
float duration); float duration);
///< Run physics simulation and modify \a world accordingly. ///< Run physics simulation and modify \a world accordingly.
void toggleCollisionMode(); bool toggleCollisionMode();
///< Toggle collision mode for player. If disabled player object should ignore ///< Toggle collision mode for player. If disabled player object should ignore
/// collisions and gravity. /// collisions and gravity.
///< \return Resulting mode
void toggleRenderMode (RenderMode mode); bool toggleRenderMode (RenderMode mode);
///< Toggle a render mode. ///< Toggle a render mode.
///< \return Resulting mode
}; };
} }