forked from teamnwah/openmw-tes3coop
made toggle-type script instructions more verbose
This commit is contained in:
parent
53e0e38862
commit
f52e6bd5ef
7 changed files with 63 additions and 42 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false; // This should never happen, but it shall not bother us now, since
|
||||||
|
// this part of the code needs a rewrite anyway.
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWScene::toggleRenderMode (int mode)
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,11 @@ namespace MWScript
|
||||||
InterpreterContext& context =
|
InterpreterContext& context =
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug);
|
bool enabled =
|
||||||
|
context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug);
|
||||||
|
|
||||||
|
context.messageBox (enabled ?
|
||||||
|
"Collsion Mesh Rendering -> On" : "Collision Mesh Rendering -> Off");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,68 +16,70 @@ namespace MWScript
|
||||||
class OpToggleSky : public Interpreter::Opcode0
|
class OpToggleSky : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
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");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class OpTurnMoonWhite : public Interpreter::Opcode0
|
class OpTurnMoonWhite : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
InterpreterContext& context =
|
InterpreterContext& context =
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
context.getWorld().setMoonColour (false);
|
context.getWorld().setMoonColour (false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpTurnMoonRed : public Interpreter::Opcode0
|
class OpTurnMoonRed : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
InterpreterContext& context =
|
InterpreterContext& context =
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
context.getWorld().setMoonColour (true);
|
context.getWorld().setMoonColour (true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpGetMasserPhase : public Interpreter::Opcode0
|
class OpGetMasserPhase : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
InterpreterContext& context =
|
InterpreterContext& context =
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
runtime.push (context.getWorld().getMasserPhase());
|
runtime.push (context.getWorld().getMasserPhase());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpGetSecundaPhase : public Interpreter::Opcode0
|
class OpGetSecundaPhase : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
InterpreterContext& context =
|
InterpreterContext& context =
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
runtime.push (context.getWorld().getSecundaPhase());
|
runtime.push (context.getWorld().getSecundaPhase());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const int opcodeToggleSky = 0x2000021;
|
const int opcodeToggleSky = 0x2000021;
|
||||||
const int opcodeTurnMoonWhite = 0x2000022;
|
const int opcodeTurnMoonWhite = 0x2000022;
|
||||||
const int opcodeTurnMoonRed = 0x2000023;
|
const int opcodeTurnMoonRed = 0x2000023;
|
||||||
|
@ -93,7 +95,7 @@ namespace MWScript
|
||||||
extensions.registerFunction ("getmasserphase", 'l', "", opcodeGetMasserPhase);
|
extensions.registerFunction ("getmasserphase", 'l', "", opcodeGetMasserPhase);
|
||||||
extensions.registerFunction ("getsecundaphase", 'l', "", opcodeGetSecundaPhase);
|
extensions.registerFunction ("getsecundaphase", 'l', "", opcodeGetSecundaPhase);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeToggleSky, new OpToggleSky);
|
interpreter.installSegment5 (opcodeToggleSky, new OpToggleSky);
|
||||||
|
@ -101,7 +103,6 @@ namespace MWScript
|
||||||
interpreter.installSegment5 (opcodeTurnMoonRed, new OpTurnMoonRed);
|
interpreter.installSegment5 (opcodeTurnMoonRed, new OpTurnMoonRed);
|
||||||
interpreter.installSegment5 (opcodeGetMasserPhase, new OpGetMasserPhase);
|
interpreter.installSegment5 (opcodeGetMasserPhase, new OpGetMasserPhase);
|
||||||
interpreter.installSegment5 (opcodeGetSecundaPhase, new OpGetSecundaPhase);
|
interpreter.installSegment5 (opcodeGetSecundaPhase, new OpGetSecundaPhase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue