#include "controlextensions.hpp" #include #include #include #include #include "../mwbase/environment.hpp" #include "../mwworld/player.hpp" #include "interpretercontext.hpp" #include namespace MWScript { namespace Control { class OpSetControl : public Interpreter::Opcode0 { std::string mControl; bool mEnable; public: OpSetControl (const std::string& control, bool enable) : mControl (control), mEnable (enable) {} virtual void execute (Interpreter::Runtime& runtime) { if (mEnable) std::cout << "enable: " << mControl << std::endl; else std::cout << "disable: " << mControl << std::endl; } }; class OpToggleCollision : public Interpreter::Opcode0 { public: virtual void execute (Interpreter::Runtime& runtime) { InterpreterContext& context = static_cast (runtime.getContext()); bool enabled = MWBase::Environment::get().getWorld()->toggleCollisionMode(); context.report (enabled ? "Collision -> On" : "Collision -> Off"); } }; const int numberOfControls = 7; const int opcodeEnable = 0x200007e; const int opcodeDisable = 0x2000085; const int opcodeToggleCollision = 0x2000130; const char *controls[numberOfControls] = { "playercontrols", "playerfighting", "playerjumping", "playerlooking", "playermagic", "playerviewswitch", "vanitymode" }; void registerExtensions (Compiler::Extensions& extensions) { std::string enable ("enable"); std::string disable ("disable"); for (int i=0; i