Maybe only oxps with a wiki page are listed ?
Added :
OXPConfig_Doc still doesn't list the .hide property, is my oxp the only one using that property ?
If so, i guess ShieldCycler is more unique then i thought

Moderators: winston, another_commander
Yes, and only if the [[Category:OXPConfig-compatible OXPs]] is used. The number is just the value of entries in that Category.Lone_Wolf wrote:small error in readme : there are 24 oxps recognized by oxpconfig, not 19 (my shieldcycler is one of the missing oxps).
Maybe only oxps with a wiki page are listed ?
As far as I'm aware - yes .-)Lone_Wolf wrote:OXPConfig_Doc still doesn't list the .hide property, is my oxp the only one using that property ?
If so, i guess ShieldCycler is more unique then i thought
Code: Select all
this.oxpcSettings = {
Info: {
Name:this.name,
Display:"GGIndustries LRS",
Notify: true,
InfoB:"Setup how to access the LRS configuration screen. If alwaysPrimable=true, the specials can be ignored. If not, they are used and default to F6-F6-F7.",
InfoS:"Current Setting: "+$getKeyComboAsString()+"\nSetup which key combo you want to use to open the LRS configuration screen.\nValues: 0->F5, 1->F6, 2->F7, 3->F8.\nKeys1-3 have to be set, Key4 is optional
},
Bool0: {Name:"$alwaysPrimable",Def:false,Desc:"access LRS configScreen through priming?"},
SInt0: {Name:"$key1st", Def:0x01, Max:0x03, Desc:"1st key of key combo."},
SInt1: {Name:"$key2nd", Def:0x01, Max:0x03, Desc:"2nd key of key combo."},
SInt2: {Name:"$key3rd", Def:0x02, Max:0x03, Desc:"3rd key of key combo."},
SInt3: {Name:"$key4th", Def:0x04, Max:0x04, Desc:"4th key of key combo."}
};
Code: Select all
this.$getKeyComboAsString = function() {
var last = "";
if ($key4th <= 3) { last = "-F"+($key4th+5); }
return "F"+($key1st+5)+"-F"+($key2nd+5)+"-F"+($key3rd+5)+last
}
Dynamic switching of texts is not supported. OXPConfig collects the objects and builds its binary search trees. If (and only if) theGGShinobi wrote:This works perfectly, but only one time (at start).The value never gets updated, so when I change the key-combo, the InfoS-String still shows the old value
![]()
I've also tried to use a variable instead of a function call, but the results are the same. The shown InfoS-String is not updated after I've changed some values with OXPConfig.
Am I missing something? Or is it not possible?
.LeaveData
flag is true the object won't be deleted after collecting it and OXPConfig uses a reference. Changing the object at runtime automagically updates OXPConfigs used texts. But still - it doesn't support dynamic switching of texts as your script doesn't know when to apply changes..oxpcNotifyOnChange
) is only sent when stored settings are loaded, default settings are loaded by the user and when the player exits OXPConfig or switches to the OXP list. Changing a setting itself does not trigger a notification - it only stores a flag internally..dynamicNotify
) to send notifications for any settings change. I'll have a peek in your script to see what would be required.The colored texts are done via HUD.GGShinobi wrote:How did you manage to display text in different font sizes and on different positions on the screen?
Then I'll update my script so that it uses theSvengali wrote:Dynamic switching of texts is not supported. OXPConfig collects the objects and builds its binary search trees. If (and only if) the.LeaveData
flag is true the object won't be deleted after collecting it and OXPConfig uses a reference. Changing the object at runtime automagically updates OXPConfigs used texts. But still - it doesn't support dynamic switching of texts as your script doesn't know when to apply changes.
The callback (.oxpcNotifyOnChange
) is only sent when stored settings are loaded, default settings are loaded by the user and when the player exits OXPConfig or switches to the OXP list. Changing a setting itself does not trigger a notification - it only stores a flag internally.
.LeaveData
flag. This is better than nothing! While not a pressing matter, I think such a functionality would be useful. Before diving into the matter, I was quite confused by the possibilities OXPConfig offers on how to setup the oxps. Some text that explains what is done and that is updated "live" (like I tried in my example) could help.Svengali wrote:It would be possible to add a flag to change this behaviour for specific OXPs (maybe.dynamicNotify
) to send notifications for any settings change.
Aaah, I see I see... Nice!Svengali wrote:The colored texts are done via HUD.GGShinobi wrote:How did you manage to display text in different font sizes and on different positions on the screen?
I've implemented it now - will test and measure a bit before uploading though (together a small test.oxp) .-)GGShinobi wrote:While not a pressing matter, I think such a functionality would be useful. Before diving into the matter, I was quite confused by the possibilities OXPConfig offers on how to setup the oxps. Some text that explains what is done and that is updated "live" (like I tried in my example) could help.Svengali wrote:It would be possible to add a flag to change this behaviour for specific OXPs (maybe.dynamicNotify
) to send notifications for any settings change.
Cool!Svengali wrote:I've implemented it now - will test and measure a bit before uploading though (together a small test.oxp) .-)
.DynamicNotify
flag (calls .oxpcNotifyOnChange
like .Notify
).Hide
and .DynamicNotify
flag is available at .Notify
seems to have no effect if .DynamicNotify
is true. (I thought setting it to false would prevent the oxpcNotifyOnChange-function to get called on start, so that, for example, at first the string "1st key of key combo." is used. But instead, the string has already been substituted by the value from oxpcNotifyOnChange even the first time I enter OXPConfig.)this.oxpcSettings.Info.InfoS
didn't use the fresh values from the variables. No matter how I changed key1-key4, the string shown is always the same (always: "CHANGED: ...")Code: Select all
this.name = "GGIndustries_LongRangeScanner_MainScript.js";
this.author = "GGShinobi";
this.copyright = "© 2013 GGShinobi, Creative Commons: attribution, non-commercial, sharealike.";
this.description = "Main Script for the GGIndustries Long Range Scanner.";
this.version = "0.0.1";
"use strict";
// =============================================================================
// local global variables / switches, configure as desired:
this.$showDebug = true;
// configuration / declare OXPConfig-variables:
this.$alwaysPrimable = false; // if true, keyCombos will be ignored, enter setup screen through priming instead
// the keys for key combination to open LRS config screen. 0=F5, 1=F6, 2=F7, 3=F8
this.$key1st = 2; // 1 => F7 }\
this.$key2nd = 1; // 1 => F6 } => default combo:
this.$key3rd = 2; // 2 => F7 } => F7-F6-F7
this.$key4th = 4; // 4 => disabled by default }/
// =============================================================================
// OXPConfig:
this.$getKeyComboAsString = function() {
var last = "";
if ($key4th <= 3) { last = "-F"+($key4th+5); }
return "F"+($key1st+5)+"-F"+($key2nd+5)+"-F"+($key3rd+5)+last
}
this.oxpcSettings = {
Info: {
Name:this.name,
Display:"GGIndustries LRS",
LeaveData: true,
Notify: false, // seems to have no effect if DynamicNotify is true
DynamicNotify: true,
InfoB:"Setup how to access the LRS configuration screen. If alwaysPrimable=true, the specials can be ignored. If not, they are used and default to F7-F6-F7.",
InfoS:"Current Setting: "+$getKeyComboAsString()+"\nSetup which key combo you want to use to open the LRS configuration screen.\nValues: 0->F5, 1->F6, 2->F7, 3->F8.\nKeys1-3 have to be set, Key4 is optional. Set it to 4 to deactivate."
},
Bool0: {Name:"$alwaysPrimable",Def:false,Desc:"access LRS configScreen through priming?"},
SInt0: {Name:"$key1st", Def:0x01, Max:0x03, Desc:"1st key of key combo."},
SInt1: {Name:"$key2nd", Def:0x01, Max:0x03, Desc:"2nd key of key combo."},
SInt2: {Name:"$key3rd", Def:0x02, Max:0x03, Desc:"3rd key of key combo."},
SInt3: {Name:"$key4th", Def:0x04, Max:0x04, Desc:"4th key of key combo."}
};
this.oxpcNotifyOnChange = this.$setupKeyArrays = function(n) {
// TODO: make use of n for more efficency
// prepare vars used for configuration screen access:
this.$guiStage = 0; // remembers pos of key combo. Always between 0 and 3.
this.$keyCombo = [$key1st, $key2nd, $key3rd, $key4th];
var key1 = "F-" + ($key1st+5); var key2 = "F-" + ($key2nd+5); var key3 = "F-" + ($key3rd+5);
var key4; if ($key4th <= 3) key4 = "F-" + ($key4th+5); else key4 = "disabled";
this.oxpcSettings.SInt0.Desc = "1. key: " + key1;
this.oxpcSettings.SInt1.Desc = "2. key: " + key2;
this.oxpcSettings.SInt2.Desc = "3. key: " + key3;
this.oxpcSettings.SInt3.Desc = "4. key: " + key4;
if ($key4th <= 3) key4 = "-" + key4; else key4 = "";
// the following line doesn't update / use the "fresh" values from the variables, but the values they had upon game start.
this.oxpcSettings.Info.InfoS = "CHANGED: Current Setting: "+key1 + "-" + key2 + "-" + key3 + key4+"\nSetup which key combo you want to use to open the LRS configuration screen.\nValues: 0->F5, 1->F6, 2->F7, 3->F8.\nKeys1-3 have to be set, Key4 is optional. Set it to 4 to deactivate.";
}
// =============================================================================
// Helpers:
// show message on destination
// dest: 0 none, 1 logfile, 2 console
this.$showDebugInfo = function(message, dest) {
if ($showDebug) {
if ((dest&1)) { log("SmellyDebug", message); }
if ((dest&2)) { player.consoleMessage(message); }
}
}
// =============================================================================
// startup - called when OXP is loaded (on game start, load game,...)
this.startUp = function () {
// setup key combo catcher:
// GUI_SCREEN_MAIN, GUI_SCREEN_STATUS F5, GUI_SCREEN_MANIFEST F5-F5,
// GUI_SCREEN_SYSTEM_DATA F7, GUI_SCREEN_OPTIONS, GUI_SCREEN_EQUIP_SHIP,
// GUI_SCREEN_SHIPYARD, GUI_SCREEN_SHORT_RANGE_CHART F6, GUI_SCREEN_REPORT,
// GUI_SCREEN_LONG_RANGE_CHART F6-F6, GUI_SCREEN_MARKET F8, GUI_SCREEN_CONTRACTS
this.$F5 = ["GUI_SCREEN_STATUS", "GUI_SCREEN_MANIFEST"];
this.$F6 = ["GUI_SCREEN_SHORT_RANGE_CHART", "GUI_SCREEN_LONG_RANGE_CHART"];
this.$F7 = ["GUI_SCREEN_SYSTEM_DATA"];
this.$F8 = ["GUI_SCREEN_MARKET"];
this.$FKeys = [$F5, $F6, $F7, $F8];
$setupKeyArrays();
}
// =============================================================================
// show the GGIndustries LRS configuration screen:
this.$showLRSConfigScreen = function() {
var LRSConfigScreen = new Object();
LRSConfigScreen.title = "GGIndustries Long Range Scanner Configuration";
LRSConfigScreen.screenID = "GGIndustries-LRS-configuration-screen"
LRSConfigScreen.allowInterrupt = true;
//LRSConfigScreen.model = "GGIndustries-LRS";
//LRSConfigScreen.model = "flying-dutchman";
// LRSConfigScreen.model = "thargoid";
// LRSConfigScreen.spinModel = true; // false;
// LRSConfigScreen.backgroundSpecial = "SHORT_RANGE_CHART";
LRSConfigScreen.choicesKey = "activate_LRS_Scanner?";
LRSConfigScreen.message = "spawn the dutchman scanner?";
function $callback(choice) {
if (choice === "1_YES") player.commsMessage("Yay!");
else if (choice === "2_NO") player.commsMessage("Boo.");
else player.commsMessage("Whut?");
}
// mission.runScreen(LRSConfigScreen);
mission.runScreen(LRSConfigScreen, $callback);
}
// =============================================================================
// key combo catcher:
// check if given guiScreen (either to or from from guiScreenChanged()) can be reached by pressing
// the given key. Key is intended to be $keyCombo[$guiStage].
this.$guiScreenMatchesKey = function(guiScreen, key) {
for (var i = 0; i < $FKeys[key].length; i++) {
// $showDebugInfo(" Comparing: "+guiScreen+" <-> "+$FKeys[key][i], 1);
if (guiScreen == $FKeys[key][i]) {
// $showDebugInfo("FKeys["+key+"]["+i+"] match: "+guiScreen, 1);
return true;
}
}
return false;
}
this.$guiScreenChangeMatchesStage = function(to, from, stage) {
//$showDebugInfo(from + "->"+to+"@$keyCombo["+stage+"]="+$keyCombo[stage], 3);
if ($guiScreenMatchesKey(to, $keyCombo[stage])) {
// combo button pressed => check if previous button was correct, too:
if (stage == 0 || $guiScreenMatchesKey(from,$keyCombo[stage - 1])) { // WARNING: order of tests is important here! (or else (stage - 1) could be negative)
// $showDebugInfo("stage match: " + stage, 3);
return true;
}
}
return false;
}
this.$isFinalGUIStage = function() {
return ($guiStage == 4 || ($guiStage == 3 && $key4th >= 4));
}
this.guiScreenChanged = function(to, from) {
if ($alwaysPrimable) { return; } // key combo not used anyway
// if (player.ship.docked) { return; } // only in-flight
// if (player.ship.equipmentStatus("EQ_GGINDUSTRIES_LONG_RANGE_SCANNER") !== "EQUIPMENT_OK") { return; } // TODO: activate when equipment exists
if ($guiScreenChangeMatchesStage(to, from, $guiStage)) {
// yep, we've entered the next stage! increase stage, then check if this is the final stage:
$guiStage++;
if ($isFinalGUIStage()) {
$guiStage = 0; // reset
$showDebugInfo("entering GGIndustries LRS configuration menu...", 3);
$showLRSConfigScreen()
}
} else {
$guiStage = 0; // reset
}
}
this.oxpcSettings.SInt0.Desc
-this.oxpcSettings.SInt4.Desc
, but it would be nice if it would also be possible to change this.oxpcSettings.Info.InfoS
. I'm not sure I understand (and sorry for the longer text).GGShinobi wrote:.Notify
seems to have no effect if.DynamicNotify
is true. (I thought setting it to false would prevent the oxpcNotifyOnChange-function to get called on start, so that, for example, at first the string "1st key of key combo." is used. But instead, the string has already been substituted by the value from oxpcNotifyOnChange even the first time I enter OXPConfig.)
.oxpcNotifyOnChange
won't be called at all when OXPConfig runs its own start routines as long as no settings were stored before. OXPConfig also won't call it if you're just browsing through the settings. If settings were stored before we have a different situation and OXPConfig will call it if the .Notify
flag is true when it runs its own start routines. The passed argument will always be 7 (1-boolean + 2-short int + 4-24bit int) to indicate the full range for stored values..DynamicNotify
flag and passes 1, 2 or 4 based on the type of the changed setting if the flag is true. And last but not least if the user has finished his changes and leaves the screens OXPConfig uses the .Notify
flag and passes the sum of changed settings, so it can be 1...7 if the flag is true..Notify
flag.this.$setupKeyArrays()
in you scripts .startUp
the loading order will become important. Specially for these cases OXPConfig has the .EarlyCall
, .EarlySet
flags. But calling other OXPs .startUp
from within OXPConfig has a drawback - it raises the time the function runs and we may hit the timelimiter some day. A approach for your script could be to get rid of the duplicated this.$setupKeyArrays
function and call the remaining this.oxpcNotifyOnChange()
a bit later (e.g. via the .missionScreenOpportunity
handler) or use a init property which gets checked on guiScreenChanged
. This way you'd still get your configuration in all cases and don't have to worry about things like loading order or if the user has OXPConfig installed or not..EarlySet
is probably not a bad idea too. OXPConfig will apply stored settings in its first cycle then.Yep. InfoB, InfoS and InfoE are not part of the dynamic stuff as their meaning was always to describe the settings and not their values. Shouldn't be hard to change it to give OXPs some more room.GGShinobi wrote:this.oxpcSettings.Info.InfoS
didn't use the fresh values from the variables. No matter how I changed key1-key4, the string shown is always the same (always: "CHANGED: ...")
Cool!Svengali wrote:Yep. InfoB, InfoS and InfoE are not part of the dynamic stuff as their meaning was always to describe the settings and not their values. Shouldn't be hard to change it to give OXPs some more room.GGShinobi wrote:this.oxpcSettings.Info.InfoS
didn't use the fresh values from the variables. No matter how I changed key1-key4, the string shown is always the same (always: "CHANGED: ...")
You are right - the doc is incomplete. I've reworked it now - hopefully it will be more valuable now. Some things are beyond the scope of OXPConfigs documentation though, because they apply to all OXPs in Oolite (e.g. infos about loading order, access to missionVariables, order of fired handlers, Oolites timelimiter and profiling via console).GGShinobi wrote:Indeed your post is so good, I'd even recommend to add it to the wiki or at least place a link there to your post. What do you think??