implemented "get<Control>Disabled" functions

This commit is contained in:
scrawl 2012-09-10 18:44:59 +02:00
parent 89ad2af1d9
commit 9448ce5968
5 changed files with 27 additions and 0 deletions

View file

@ -31,6 +31,7 @@ namespace MWBase
virtual void setDragDrop(bool dragDrop) = 0;
virtual void toggleControlSwitch (const std::string& sw, bool value) = 0;
virtual bool getControlSwitch (const std::string& sw) = 0;
virtual std::string getActionDescription (int action) = 0;
virtual std::string getActionBindingName (int action) = 0;

View file

@ -380,6 +380,11 @@ namespace MWInput
adjustMouseRegion(Settings::Manager::getInt("resolution x", "Video"), Settings::Manager::getInt("resolution y", "Video"));
}
bool InputManager::getControlSwitch (const std::string& sw)
{
return mControlSwitch[sw];
}
void InputManager::toggleControlSwitch (const std::string& sw, bool value)
{
if (mControlSwitch[sw] == value) {

View file

@ -75,6 +75,7 @@ namespace MWInput
virtual void setDragDrop(bool dragDrop);
virtual void toggleControlSwitch (const std::string& sw, bool value);
virtual bool getControlSwitch (const std::string& sw);
virtual std::string getActionDescription (int action);
virtual std::string getActionBindingName (int action);

View file

@ -41,6 +41,22 @@ namespace MWScript
}
};
class OpGetDisabled : public Interpreter::Opcode0
{
std::string mControl;
public:
OpGetDisabled (const std::string& control)
: mControl (control)
{}
virtual void execute (Interpreter::Runtime& runtime)
{
runtime.push(!MWBase::Environment::get().getInputManager()->getControlSwitch (mControl));
}
};
class OpToggleCollision : public Interpreter::Opcode0
{
public:
@ -103,6 +119,7 @@ namespace MWScript
const int opcodeClearForceSneakExplicit = 0x2000159;
const int opcodeForceSneak = 0x200015a;
const int opcodeForceSneakExplicit = 0x200015b;
const int opcodeGetDisabled = 0x2000175;
const char *controls[numberOfControls] =
{
@ -119,6 +136,7 @@ namespace MWScript
{
extensions.registerInstruction (enable + controls[i], "", opcodeEnable+i);
extensions.registerInstruction (disable + controls[i], "", opcodeDisable+i);
extensions.registerFunction (std::string("get") + controls[i] + std::string("disabled"), 'l', "", opcodeGetDisabled+i);
}
extensions.registerInstruction ("togglecollision", "", opcodeToggleCollision);
@ -141,6 +159,7 @@ namespace MWScript
{
interpreter.installSegment5 (opcodeEnable+i, new OpSetControl (controls[i], true));
interpreter.installSegment5 (opcodeDisable+i, new OpSetControl (controls[i], false));
interpreter.installSegment5 (opcodeGetDisabled+i, new OpGetDisabled (controls[i]));
}
interpreter.installSegment5 (opcodeToggleCollision, new OpToggleCollision);

View file

@ -182,4 +182,5 @@ op 0x2000171: user4 (implicit reference, console only, requires --script-console
op 0x2000172: GetStartingAngle
op 0x2000173: GetStartingAngle, explicit reference
op 0x2000174: ToggleVanityMode
op 0x2000175-0x200018B: Get controls disabled
opcodes 0x2000175-0x3ffffff unused