Difference between revisions of "Lib Config"

From Elite Wiki
(Documentation)
 
m (Retagged!)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Image:IconLib.png|100px|right]]
 
[[Image:IconLib.png|100px|right]]
 
==Overview==
 
==Overview==
Lib_Config (part of [[Library]]) is a Interface to give AddOns the possibility to let users change settings in the game. It's really easy to implement the data and usually only needs a few lines of code.
+
Lib_Config (part of [[Library OXP|Library]]) is a Interface to give AddOns the possibility to let users change settings in the game. It's really easy to implement the data and usually only needs a few lines of code. AddOns can also register multiple entries if they need some more options.
 
 
  
 
==Methods==
 
==Methods==
Line 37: Line 36:
 
     }
 
     }
 
   };
 
   };
   worldScripts.Lib_Config._registerSet(this.$my.oxpc);
+
   worldScripts.Lib_Config._registerSet(this.$myOXPC);
 +
 
 +
Pathes can be used as well:
 +
 
 +
  this.$path = {
 +
    dog: {dog:false},
 +
    notify: function(boo){
 +
      log("","Path Notify for "+boo);
 +
    }
 +
  };
 +
  this.$myOXPC = {Name:this.name, Display:"Path", Alive:"$myOXPC", Notify:"$path.notify",
 +
    Bool:{
 +
      B0:{Name:"$path.dog.dog", Def:false, Desc:"Blurp.", Notify:"$path.notify"},
 +
      Info:"OK", Notify:"$path.notify"
 +
    }
 +
  };
 +
  worldScripts.Lib_Config._registerSet(this.$myOXPC);
  
  
 
==Full Dataset==
 
==Full Dataset==
 
The members:
 
The members:
:Name
+
:;Name: Required. String. worldScript name, usually simply this.name.
::Required. String. worldScript name, usually simply this.name.
+
:;Display: Required. String. Identifier for this specific settings Object, e.g. "Planets". Name and Display are used to sort and group settings Objects.
:Display
+
:;Alive: Required. String. Path to settings Object, e.g. "$mySettings".
::Required. String. Identifier for this specific settings Object, e.g. "Planets". Name and Display are used to sort and group settings Objects.
+
:;Notify: Optional. String. Path to global notification function when user leaves the OXP screen.
:Alive
+
:;Reset: Optional. Boolean. If set allows "Reset to defaults" option. See [[#Reset option|Reset option]].
::Required. String. Path to settings Object, e.g. "$mySettings".
 
:Notify
 
::Optional. String. Path to global notification function when user leaves the OXP screen.
 
:Reset
 
::Optional. Boolean. If set allows "Reset to defaults" option.
 
  
 
and at least one of
 
and at least one of
  
:Bool:{
+
:;Bool: Boolean handling.
::Boolean handling.
+
::;B0: Up to 9 unique Objects.
::B0:{
+
:::;Name: Required. String. Path to boolean property, e.g. "$switchOn".
:::Up to 9 unique Objects.
+
:::;Def: Required. Boolean. Default value.
:::Name
+
:::;Desc: Required. String. Short description, e.g. "Add planets".
::::Required. String. Path to boolean property, e.g. "$switchOn".
+
:::;Hide: Optional. Boolean. Hide from display.
:::Def
+
:::;Notify: Optional. String. Path to notification function when user changes this property.
::::Required. Boolean. Default value.
 
:::Desc
 
::::Required. String. Short description, e.g. "Add planets".
 
:::Hide
 
::::Optional. Boolean. Hide from display.
 
:::Notify
 
::::Optional. String. Path to notification function when user changes this property.
 
 
::},
 
::},
::Info
+
::;Info: Optional. String. Description for the boolean settings. If prefixed with '^' points to a missiontext key.
:::Optional. String. Description for the boolean settings. If prefixed with '^' points to a missiontext key.
+
::;Notify: Optional. String. Path to group notification function when user leaves the boolean screen.
::Notify
 
:::Optional. String. Path to group notification function when user leaves the boolean screen.
 
 
:},
 
:},
:SInt
+
:;SInt: Number handling. Integer or Float. Used values can be in range -16777215...16777215 (or -0xffffff...0xffffff).
::Number handling. Integer or Float. Used values can be in range -16777215...16777215 (or -0xffffff...0xffffff).
+
::;S0: Up to 9 unique Objects.
::S0:{
+
:::;Name: Required. String. Path to integer or float property, e.g. "$amountMoons".
:::Up to 9 unique Objects.
+
:::;Def: Required. Number. Default value.
:::Name
+
:::;Min: Required. Number. Minimum value, e.g. -43.
::::Required. String. Path to integer or float property, e.g. "$amountMoons".
+
:::;Max: Required. Number. Maximum value, e.g. 0xfffffe.
:::Def
+
:::;Desc: Required. String. Short description, e.g. "Max planets".
::::Required. Number. Default value.
+
:::;Float: Optional. Boolean. If true floating point input allowed.
:::Min
+
:::;Hide: Optional. Boolean. Hide from display.
::::Required. Number. Minimum value, e.g. -43.
+
:::;Notify: Optional. String. Path to notification function when user changes this property.
:::Max
 
::::Required. Number. Maximum value, e.g. 0xfffffe.
 
:::Desc
 
::::Required. String. Short description, e.g. "Max planets".
 
:::Float
 
::::Optional. Boolean. If true floating point input allowed.
 
:::Hide
 
::::Optional. Boolean. Hide from display.
 
:::Notify
 
::::Optional. String. Path to notification function when user changes this property.
 
 
::},
 
::},
::Info
+
::;Info: Optional. String. Description for the number settings. If prefixed with '^' points to a missiontext key.
:::Optional. String. Description for the number settings. If prefixed with '^' points to a missiontext key.
+
::;Notify: Optional. String. Path to group notification function when user leaves the number screen.
::Notify
 
:::Optional. String. Path to group notification function when user leaves the number screen.
 
 
:},
 
:},
:EInt
+
:;EInt: Bitmask handling. Positive Integer. Used values can be in range 0...16777215 (or 0x0...0xffffff).
::Bitmask handling. Positive Integer. Used values can be in range 0...16777215 (or 0x0...0xffffff).
+
::;E0: 1 object.
::E0:{
+
:::;Name: Required. String. Path to bitmask property, e.g. "$myBitmask".
:::1 object.
+
:::;Def: Required. Number. Default value.
:::Name
+
:::;Min: Required. Number. Minimum value.
::::Required. String. Path to bitmask property, e.g. "$myBitmask".
+
:::;Max: Required. Number. Maximum value.
:::Def
+
:::;Desc: Required. Array. Contains Strings, describing the single elements.
::::Required. Number. Default value.
+
:::;Hide: Optional. Boolean. Hide from display.
:::Min
+
:::;Notify: Optional. String. Path to notification function when user changes this property.
::::Required. Number. Minimum value.
+
:::;OneOf: Optional. Boolean. Selects only one bit at a time.
:::Max
+
:::;OneOfZero: Optional. Boolean. Selects only one bit or none at a time.
::::Required. Number. Maximum value.
 
:::Desc
 
::::Required. Array. Contains Strings, describing the single elements.
 
:::Hide
 
::::Optional. Boolean. Hide from display.
 
:::Notify
 
::::Optional. String. Path to notification function when user changes this property.
 
:::OneOf
 
::::Optional. Boolean. Selects only one bit at a time.
 
:::OneOfZero
 
::::Optional. Boolean. Selects only one bit or none at a time.
 
 
::},
 
::},
::Info
+
::;Info: Optional. String. Description for the bitmask settings. If prefixed with '^' points to a missiontext key.
:::Optional. String. Description for the bitmask settings. If prefixed with '^' points to a missiontext key.
+
::;Notify: Optional. String. Path to group notification function when user leaves the bitmask screen.
::Notify
 
:::Optional. String. Path to group notification function when user leaves the bitmask screen.
 
 
:}
 
:}
  
 +
===Reset option===
 +
Lib_Configs "Reset to defaults" option handles the notifications as follows:
 +
* If a global .Notify is declared it ignores group or property .Notify
 +
* If no global .Notify and a group .Notify is declared it ignores property .Notify
  
  
[[Category:OXPDoc]]
+
[[Category:OXP API's]]

Latest revision as of 14:06, 20 September 2023

IconLib.png

Overview

Lib_Config (part of Library) is a Interface to give AddOns the possibility to let users change settings in the game. It's really easy to implement the data and usually only needs a few lines of code. AddOns can also register multiple entries if they need some more options.

Methods

_registerSet

_registerSet: function( obj )

Register a data set on .startUpComplete or later.

Parameters:

obj
Object. See Full Dataset for its members.

Returns:

n
Number. Errorcode. If OK 0 (zero).


_unregisterSet

_unregisterSet: function( obj )

Unregister a data set.

Parameters:

obj
Object. See Full Dataset for its members.

Returns:

n
Number. Errorcode. If OK 0 (zero).


Examples

A very simple one with 1 boolean property to stare at:

 this.$log = false;
 this.$myOXPC = {Name:this.name, Display:"Example A", Alive:"$myOXPC",
    Bool:{
      B0:{Name:"$log", Def:false, Desc:"Blurp."},
      Info:"Hmmm."
    }
 };
 worldScripts.Lib_Config._registerSet(this.$myOXPC);

Pathes can be used as well:

 this.$path = {
   dog: {dog:false},
   notify: function(boo){
     log("","Path Notify for "+boo);
   }
 };
 this.$myOXPC = {Name:this.name, Display:"Path", Alive:"$myOXPC", Notify:"$path.notify",
   Bool:{
     B0:{Name:"$path.dog.dog", Def:false, Desc:"Blurp.", Notify:"$path.notify"},
     Info:"OK", Notify:"$path.notify"
   }
 };
 worldScripts.Lib_Config._registerSet(this.$myOXPC);


Full Dataset

The members:

Name
Required. String. worldScript name, usually simply this.name.
Display
Required. String. Identifier for this specific settings Object, e.g. "Planets". Name and Display are used to sort and group settings Objects.
Alive
Required. String. Path to settings Object, e.g. "$mySettings".
Notify
Optional. String. Path to global notification function when user leaves the OXP screen.
Reset
Optional. Boolean. If set allows "Reset to defaults" option. See Reset option.

and at least one of

Bool
Boolean handling.
B0
Up to 9 unique Objects.
Name
Required. String. Path to boolean property, e.g. "$switchOn".
Def
Required. Boolean. Default value.
Desc
Required. String. Short description, e.g. "Add planets".
Hide
Optional. Boolean. Hide from display.
Notify
Optional. String. Path to notification function when user changes this property.
},
Info
Optional. String. Description for the boolean settings. If prefixed with '^' points to a missiontext key.
Notify
Optional. String. Path to group notification function when user leaves the boolean screen.
},
SInt
Number handling. Integer or Float. Used values can be in range -16777215...16777215 (or -0xffffff...0xffffff).
S0
Up to 9 unique Objects.
Name
Required. String. Path to integer or float property, e.g. "$amountMoons".
Def
Required. Number. Default value.
Min
Required. Number. Minimum value, e.g. -43.
Max
Required. Number. Maximum value, e.g. 0xfffffe.
Desc
Required. String. Short description, e.g. "Max planets".
Float
Optional. Boolean. If true floating point input allowed.
Hide
Optional. Boolean. Hide from display.
Notify
Optional. String. Path to notification function when user changes this property.
},
Info
Optional. String. Description for the number settings. If prefixed with '^' points to a missiontext key.
Notify
Optional. String. Path to group notification function when user leaves the number screen.
},
EInt
Bitmask handling. Positive Integer. Used values can be in range 0...16777215 (or 0x0...0xffffff).
E0
1 object.
Name
Required. String. Path to bitmask property, e.g. "$myBitmask".
Def
Required. Number. Default value.
Min
Required. Number. Minimum value.
Max
Required. Number. Maximum value.
Desc
Required. Array. Contains Strings, describing the single elements.
Hide
Optional. Boolean. Hide from display.
Notify
Optional. String. Path to notification function when user changes this property.
OneOf
Optional. Boolean. Selects only one bit at a time.
OneOfZero
Optional. Boolean. Selects only one bit or none at a time.
},
Info
Optional. String. Description for the bitmask settings. If prefixed with '^' points to a missiontext key.
Notify
Optional. String. Path to group notification function when user leaves the bitmask screen.
}

Reset option

Lib_Configs "Reset to defaults" option handles the notifications as follows:

  • If a global .Notify is declared it ignores group or property .Notify
  • If no global .Notify and a group .Notify is declared it ignores property .Notify