Implement ToggleWorld instruction

deque
scrawl 10 years ago
parent 3e153d0a9b
commit c010c28337

@ -119,6 +119,7 @@ namespace MWBase
virtual void setWaterHeight(const float height) = 0;
virtual bool toggleWater() = 0;
virtual bool toggleWorld() = 0;
virtual void adjustSky() = 0;

@ -63,6 +63,7 @@ RenderingManager::RenderingManager(OEngine::Render::OgreRenderer& _rend, const b
, mPhysicsEngine(engine)
, mTerrain(NULL)
, mEffectManager(NULL)
, mRenderWorld(true)
{
mActors = new MWRender::Actors(mRendering, this);
mObjects = new MWRender::Objects(mRendering);
@ -232,6 +233,15 @@ bool RenderingManager::toggleWater()
return mWater->toggle();
}
bool RenderingManager::toggleWorld()
{
mRenderWorld = !mRenderWorld;
int visibilityMask = mRenderWorld ? ~int(0) : 0;
mRendering.getViewport()->setVisibilityMask(visibilityMask);
return mRenderWorld;
}
void RenderingManager::cellAdded (MWWorld::CellStore *store)
{
if (store->isExterior())

@ -123,6 +123,7 @@ public:
void setWaterHeight(const float height);
bool toggleWater();
bool toggleWorld();
/// Updates object rendering after cell change
/// \param old Object reference in previous cell
@ -266,6 +267,8 @@ private:
MWRender::LocalMap* mLocalMap;
MWRender::Shadows* mShadows;
bool mRenderWorld;
};
}

@ -432,5 +432,6 @@ op 0x20002ac-0x20002c3: SetMagicEffect, explicit
op 0x20002c4-0x20002db: ModMagicEffect
op 0x20002dc-0x20002f3: ModMagicEffect, explicit
op 0x20002f4: ResetActors
op 0x20002f5: ToggleWorld
opcodes 0x20002f5-0x3ffffff unused
opcodes 0x20002f6-0x3ffffff unused

@ -290,6 +290,17 @@ namespace MWScript
}
};
class OpToggleWorld : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
runtime.getContext().report(MWBase::Environment::get().getWorld()->toggleWorld() ? "World -> On"
: "World -> Off");
}
};
class OpDontSaveObject : public Interpreter::Opcode0
{
public:
@ -979,6 +990,7 @@ namespace MWScript
interpreter.installSegment5 (Compiler::Misc::opcodeFadeTo, new OpFadeTo);
interpreter.installSegment5 (Compiler::Misc::opcodeTogglePathgrid, new OpTogglePathgrid);
interpreter.installSegment5 (Compiler::Misc::opcodeToggleWater, new OpToggleWater);
interpreter.installSegment5 (Compiler::Misc::opcodeToggleWorld, new OpToggleWorld);
interpreter.installSegment5 (Compiler::Misc::opcodeDontSaveObject, new OpDontSaveObject);
interpreter.installSegment5 (Compiler::Misc::opcodeToggleVanityMode, new OpToggleVanityMode);
interpreter.installSegment5 (Compiler::Misc::opcodeGetPcSleep, new OpGetPcSleep);

@ -1663,6 +1663,11 @@ namespace MWWorld
return mRendering->toggleWater();
}
bool World::toggleWorld()
{
return mRendering->toggleWorld();
}
void World::PCDropped (const Ptr& item)
{
std::string script = item.getClass().getScript(item);

@ -180,6 +180,7 @@ namespace MWWorld
virtual void setWaterHeight(const float height);
virtual bool toggleWater();
virtual bool toggleWorld();
virtual void adjustSky();

@ -256,6 +256,8 @@ namespace Compiler
extensions.registerInstruction ("fadeto", "ff", opcodeFadeTo);
extensions.registerInstruction ("togglewater", "", opcodeToggleWater);
extensions.registerInstruction ("twa", "", opcodeToggleWater);
extensions.registerInstruction ("toggleworld", "", opcodeToggleWorld);
extensions.registerInstruction ("tw", "", opcodeToggleWorld);
extensions.registerInstruction ("togglepathgrid", "", opcodeTogglePathgrid);
extensions.registerInstruction ("tpg", "", opcodeTogglePathgrid);
extensions.registerInstruction ("dontsaveobject", "", opcodeDontSaveObject);

@ -212,6 +212,7 @@ namespace Compiler
const int opcodeFadeOut = 0x200013d;
const int opcodeFadeTo = 0x200013e;
const int opcodeToggleWater = 0x2000144;
const int opcodeToggleWorld = 0x20002f5;
const int opcodeTogglePathgrid = 0x2000146;
const int opcodeDontSaveObject = 0x2000153;
const int opcodeToggleVanityMode = 0x2000174;

Loading…
Cancel
Save