From 68a788b2c87abe5af73023a7e48ed0fbe1f035f6 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 22 Aug 2010 15:11:40 +0200 Subject: [PATCH] added instructions for enabling/disabling player controls (they don't do anything yet) --- apps/openmw/CMakeLists.txt | 2 + apps/openmw/mwscript/controlextensions.cpp | 70 ++++++++++++++++++++++ apps/openmw/mwscript/controlextensions.hpp | 25 ++++++++ apps/openmw/mwscript/docs/vmformat.txt | 4 +- apps/openmw/mwscript/extensions.cpp | 3 + 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 apps/openmw/mwscript/controlextensions.cpp create mode 100644 apps/openmw/mwscript/controlextensions.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index f0aafbbbc..6863b2e13 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -61,6 +61,7 @@ set(GAMESCRIPT mwscript/statsextensions.cpp mwscript/containerextensions.cpp mwscript/aiextensions.cpp + mwscript/controlextensions.cpp mwscript/extensions.cpp mwscript/globalscripts.cpp ) @@ -77,6 +78,7 @@ set(GAMESCRIPT_HEADER mwscript/statsextensions.hpp mwscript/containerextensions.hpp mwscript/aiextensions.hpp + mwscript/controlextensions.hpp mwscript/extensions.hpp mwscript/globalscripts.hpp ) diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp new file mode 100644 index 000000000..e38ee7c2d --- /dev/null +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -0,0 +1,70 @@ + +#include "statsextensions.hpp" + +#include + +#include +#include +#include + +#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; + } + }; + + const int numberOfControls = 7; + + const int opcodeEnable = 0x200007e; + const int opcodeDisable = 0x2000085; + + 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