mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Merge branch 'script'
This commit is contained in:
commit
7144657cfc
@ -84,7 +84,7 @@ void MWScene::doPhysics (float duration, MWWorld::World& world,
|
||||
MWWorld::DoingPhysics scopeGuard;
|
||||
|
||||
//set the DebugRenderingMode. To disable it,set it to 0
|
||||
eng->setDebugRenderingMode(1);
|
||||
// eng->setDebugRenderingMode(1);
|
||||
|
||||
//set the walkdirection to 0 (no movement) for every actor)
|
||||
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++)
|
||||
@ -213,3 +213,16 @@ void MWScene::toggleCollisionMode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MWScene::toggleRenderMode (int mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case MWWorld::World::Render_CollisionDebug:
|
||||
|
||||
// TODO use a proper function instead of accessing the member variable
|
||||
// directly.
|
||||
eng->setDebugRenderingMode (!eng->isDebugCreated);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,11 @@ namespace MWRender
|
||||
/// Toggle collision mode for player. If disabled player object should ignore
|
||||
/// collisions and gravity.
|
||||
void toggleCollisionMode();
|
||||
|
||||
/// Toggle render mode
|
||||
/// \todo Using an int instead of a enum here to avoid cyclic includes. Will be fixed
|
||||
/// when the mw*-refactoring is done.
|
||||
void toggleRenderMode (int mode);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include "../mwworld/world.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
|
||||
@ -84,9 +85,27 @@ namespace MWScript
|
||||
}
|
||||
};
|
||||
|
||||
class OpGetInterior : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
InterpreterContext& context
|
||||
= static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
bool interior =
|
||||
context.getWorld().getPlayer().getPlayer().getCell()->cell->data.flags &
|
||||
ESM::Cell::Interior;
|
||||
|
||||
runtime.push (interior ? 1 : 0);
|
||||
}
|
||||
};
|
||||
|
||||
const int opcodeCellChanged = 0x2000000;
|
||||
const int opcodeCOC = 0x2000026;
|
||||
const int opcodeCOE = 0x200008e;
|
||||
const int opcodeGetInterior = 0x2000131;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
@ -95,6 +114,7 @@ namespace MWScript
|
||||
extensions.registerInstruction ("centeroncell", "S", opcodeCOC);
|
||||
extensions.registerInstruction ("coe", "ll", opcodeCOE);
|
||||
extensions.registerInstruction ("centeronexterior", "ll", opcodeCOE);
|
||||
extensions.registerFunction ("getinterior", 'l', "", opcodeGetInterior);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
@ -102,6 +122,7 @@ namespace MWScript
|
||||
interpreter.installSegment5 (opcodeCellChanged, new OpCellChanged);
|
||||
interpreter.installSegment5 (opcodeCOC, new OpCOC);
|
||||
interpreter.installSegment5 (opcodeCOE, new OpCOE);
|
||||
interpreter.installSegment5 (opcodeGetInterior, new OpGetInterior);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,4 +102,6 @@ op 0x20000df-0x20000f9: SetSkill, explicit reference
|
||||
op 0x20000fa-0x2000114: ModSkill
|
||||
op 0x2000115-0x200012f: ModSKill, explicit reference
|
||||
op 0x2000130: ToggleCollision
|
||||
opcodes 0x2000131-0x3ffffff unused
|
||||
op 0x2000131: GetInterior
|
||||
op 0x2000132: ToggleCollsionDebug
|
||||
opcodes 0x2000133-0x3ffffff unused
|
||||
|
@ -90,6 +90,18 @@ namespace MWScript
|
||||
}
|
||||
};
|
||||
|
||||
class OpToggleCollisionDebug : public Interpreter::Opcode0
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Interpreter::Runtime& runtime)
|
||||
{
|
||||
InterpreterContext& context =
|
||||
static_cast<InterpreterContext&> (runtime.getContext());
|
||||
|
||||
context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug);
|
||||
}
|
||||
};
|
||||
|
||||
const int opcodeXBox = 0x200000c;
|
||||
const int opcodeOnActivate = 0x200000d;
|
||||
@ -98,6 +110,7 @@ namespace MWScript
|
||||
const int opcodeLockExplicit = 0x20005;
|
||||
const int opcodeUnlock = 0x200008c;
|
||||
const int opcodeUnlockExplicit = 0x200008d;
|
||||
const int opcodeToggleCollisionDebug = 0x2000132;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
@ -106,6 +119,10 @@ namespace MWScript
|
||||
extensions.registerInstruction ("activate", "", opcodeActivate);
|
||||
extensions.registerInstruction ("lock", "/l", opcodeLock, opcodeLockExplicit);
|
||||
extensions.registerInstruction ("unlock", "", opcodeUnlock, opcodeUnlockExplicit);
|
||||
extensions.registerInstruction ("togglecollisionboxes", "", opcodeToggleCollisionDebug);
|
||||
extensions.registerInstruction ("togglecollisiongrid", "", opcodeToggleCollisionDebug);
|
||||
extensions.registerInstruction ("tcb", "", opcodeToggleCollisionDebug);
|
||||
extensions.registerInstruction ("tcg", "", opcodeToggleCollisionDebug);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
@ -117,6 +134,7 @@ namespace MWScript
|
||||
interpreter.installSegment3 (opcodeLockExplicit, new OpLock<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeUnlock, new OpUnlock<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlock<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeToggleCollisionDebug, new OpToggleCollisionDebug);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -859,4 +859,9 @@ namespace MWWorld
|
||||
{
|
||||
mScene.toggleCollisionMode();
|
||||
}
|
||||
|
||||
void World::toggleRenderMode (RenderMode mode)
|
||||
{
|
||||
mScene.toggleRenderMode (mode);
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,11 @@ namespace MWWorld
|
||||
public:
|
||||
typedef std::list<std::pair<std::string, Ptr> > ScriptList;
|
||||
|
||||
enum RenderMode
|
||||
{
|
||||
Render_CollisionDebug
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection;
|
||||
@ -183,6 +188,9 @@ namespace MWWorld
|
||||
void toggleCollisionMode();
|
||||
///< Toggle collision mode for player. If disabled player object should ignore
|
||||
/// collisions and gravity.
|
||||
|
||||
void toggleRenderMode (RenderMode mode);
|
||||
///< Toggle a render mode.
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user