Patch: Writable PlayerShip.compassMode
Posted: Sun Mar 26, 2017 2:26 pm
Below is a patch generated with git format-patch. I cannot submit a pull request cause I don't have a Github account (yet?).
It makes playerShip.compassMode writable, mainly in order to let scripts set it to COMPASS_MODE_TARGET. I wanted this because the compass is more accurate than the HUD arrow when the target is off-screen, and also shows clearly when the target is behind the ship.
It makes playerShip.compassMode writable, mainly in order to let scripts set it to COMPASS_MODE_TARGET. I wanted this because the compass is more accurate than the HUD arrow when the target is off-screen, and also shows clearly when the target is behind the ship.
Code: Select all
From c7ccf914d836b53acba4578d175efc789b6c5d16 Mon Sep 17 00:00:00 2001
From: Astrobe <REDACTED@REDACTED>
Date: Sun, 26 Mar 2017 16:13:31 +0200
Subject: [PATCH] Script-writable compass mode
---
src/Core/Scripting/OOJSPlayerShip.m | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/Core/Scripting/OOJSPlayerShip.m b/src/Core/Scripting/OOJSPlayerShip.m
index 3a35a37..c1ba4c4 100644
--- a/src/Core/Scripting/OOJSPlayerShip.m
+++ b/src/Core/Scripting/OOJSPlayerShip.m
@@ -162,7 +162,7 @@ static JSPropertySpec sPlayerShipProperties[] =
// JS name ID flags
{ "aftShield", kPlayerShip_aftShield, OOJS_PROP_READWRITE_CB },
{ "aftShieldRechargeRate", kPlayerShip_aftShieldRechargeRate, OOJS_PROP_READWRITE_CB },
- { "compassMode", kPlayerShip_compassMode, OOJS_PROP_READONLY_CB },
+ { "compassMode", kPlayerShip_compassMode, OOJS_PROP_READWRITE_CB },
{ "compassTarget", kPlayerShip_compassTarget, OOJS_PROP_READONLY_CB },
{ "compassType", kPlayerShip_compassType, OOJS_PROP_READWRITE_CB },
{ "currentWeapon", kPlayerShip_currentWeapon, OOJS_PROP_READWRITE_CB },
@@ -602,6 +602,16 @@ static JSBool PlayerShipSetProperty(JSContext *context, JSObject *this, jsid pro
}
break;
+ case kPlayerShip_compassMode:
+ sValue = OOStringFromJSValue(context, *value);
+ if(sValue != nil)
+ {
+ OOCompassMode mode=OOCompassModeFromJSValue(context, *value);
+ [player setCompassMode:mode];
+ [player validateCompassTarget];
+ return YES;
+ }
+ break;
case kPlayerShip_compassType:
sValue = OOStringFromJSValue(context, *value);
if (sValue != nil)
--
1.8.3.msysgit.0