mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-29 08:15:35 +00:00
added instructions for enabling/disabling player controls (they don't do anything yet)
This commit is contained in:
parent
14cf007a3f
commit
68a788b2c8
5 changed files with 103 additions and 1 deletions
|
@ -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
|
||||
)
|
||||
|
|
70
apps/openmw/mwscript/controlextensions.cpp
Normal file
70
apps/openmw/mwscript/controlextensions.cpp
Normal file
|
@ -0,0 +1,70 @@
|
|||
|
||||
#include "statsextensions.hpp"
|
||||
|
||||
#include <components/compiler/extensions.hpp>
|
||||
|
||||
#include <components/interpreter/interpreter.hpp>
|
||||
#include <components/interpreter/runtime.hpp>
|
||||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include "interpretercontext.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
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<numberOfControls; ++i)
|
||||
{
|
||||
extensions.registerInstruction (enable + controls[i], "", opcodeEnable+i);
|
||||
extensions.registerInstruction (disable + controls[i], "", opcodeDisable+i);
|
||||
}
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
{
|
||||
for (int i=0; i<numberOfControls; ++i)
|
||||
{
|
||||
interpreter.installSegment5 (opcodeEnable+i, new OpSetControl (controls[i], true));
|
||||
interpreter.installSegment5 (opcodeDisable+i, new OpSetControl (controls[i], false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
apps/openmw/mwscript/controlextensions.hpp
Normal file
25
apps/openmw/mwscript/controlextensions.hpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef GAME_SCRIPT_CONTROLEXTENSIONS_H
|
||||
#define GAME_SCRIPT_CONTROLEXTENSIONS_H
|
||||
|
||||
namespace Compiler
|
||||
{
|
||||
class Extensions;
|
||||
}
|
||||
|
||||
namespace Interpreter
|
||||
{
|
||||
class Interpreter;
|
||||
}
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
/// \brief player controls-related script functionality
|
||||
namespace Control
|
||||
{
|
||||
void registerExtensions (Compiler::Extensions& extensions);
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -88,4 +88,6 @@ op 0x200007a: RemoveItem
|
|||
op 0x200007b: RemoveItem, explicit reference
|
||||
op 0x200007c: GetAiPackageDone
|
||||
op 0x200007d: GetAiPackageDone, explicit reference
|
||||
opcodes 0x200007e-0x3ffffff unused
|
||||
op 0x200007e-0x2000084: Enable Controls
|
||||
op 0x2000085-0x200008b: Disable Controls
|
||||
opcodes 0x200008c-0x3ffffff unused
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "statsextensions.hpp"
|
||||
#include "containerextensions.hpp"
|
||||
#include "aiextensions.hpp"
|
||||
#include "controlextensions.hpp"
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
|
@ -25,6 +26,7 @@ namespace MWScript
|
|||
Stats::registerExtensions (extensions);
|
||||
Container::registerExtensions (extensions);
|
||||
Ai::registerExtensions (extensions);
|
||||
Control::registerExtensions (extensions);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -38,5 +40,6 @@ namespace MWScript
|
|||
Stats::installOpcodes (interpreter);
|
||||
Container::installOpcodes (interpreter);
|
||||
Ai::installOpcodes (interpreter);
|
||||
Control::installOpcodes (interpreter);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue