Added placeholders for all 1.6 functions
Implemented most of the systems functions
This commit is contained in:
parent
897ba9310e
commit
b597235874
@ -59,6 +59,9 @@ Registers a button function.
|
||||
| **default**: string
|
||||
| The default color and/or animation assigned to the state when it is first selected. See :ref:`ref-ledcolor` for a list of valid values.
|
||||
|
|
||||
| **order**: number (optional)
|
||||
| Specifies the order in which the state is shown in the button function selection screen. If not specified, defaults to 0. States with an equal order are sorted alphabetically.
|
||||
|
|
||||
| **setupCallback**: function
|
||||
| A Lua function which is called when the button function is configured. Please note that if a button function is linked to multiple G940 throttle buttons, setupCallback is called multiple times, so be careful with variables which are outside of the setupCallback's scope (global or script-local)!
|
||||
|
|
||||
@ -129,9 +132,12 @@ Registers a Lua function to be called when the specified SimConnect variable(s)
|
||||
| **variable**: string
|
||||
| The name of the variable as described in `Simulation variables <https://msdn.microsoft.com/en-us/library/cc526981.aspx>`_.
|
||||
|
|
||||
| **data**: string
|
||||
| **type**: string
|
||||
| One of the :ref:`ref-simconnectdatatype` values.
|
||||
|
|
||||
| **units**: string
|
||||
| If relevant to the variable, one of the `Units of Measurement <https://msdn.microsoft.com/en-us/library/cc526981.aspx#UnitsofMeasurement>`_ supported by SimConnect. For example, 'percent'. If type is SimConnectDataType.Bool, this will be automatically set to 'bool'.
|
||||
|
|
||||
| **variablesChangedCallback**: function
|
||||
| A Lua function which is called when the variable's value changes. It receives 2 parameters: 'context' and 'data'. The data parameter is a Lua table where each key corresponds to a variable defined in the 'variables' parameter and it's value is the current value of the simulation variable.
|
||||
|
|
||||
|
@ -1,7 +1,7 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 0
|
||||
Top = 0
|
||||
ActiveControl = cbTrayIcon
|
||||
ActiveControl = cmbProfiles
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
BorderStyle = bsSingle
|
||||
Caption = 'G940 LED Control'
|
||||
@ -30,7 +30,7 @@ object MainForm: TMainForm
|
||||
Margins.Top = 8
|
||||
Margins.Right = 8
|
||||
Margins.Bottom = 8
|
||||
ActivePage = tsConfiguration
|
||||
ActivePage = tsButtons
|
||||
Align = alClient
|
||||
TabOrder = 0
|
||||
object tsButtons: TTabSheet
|
||||
@ -529,10 +529,6 @@ object MainForm: TMainForm
|
||||
object tsAbout: TTabSheet
|
||||
Caption = 'About'
|
||||
ImageIndex = 1
|
||||
ExplicitLeft = 0
|
||||
ExplicitTop = 0
|
||||
ExplicitWidth = 0
|
||||
ExplicitHeight = 0
|
||||
object lblVersionCaption: TLabel
|
||||
Left = 16
|
||||
Top = 67
|
||||
|
@ -53,14 +53,17 @@ var
|
||||
begin
|
||||
isRestarting := FindCmdLineSwitch('restart');
|
||||
|
||||
while not SingleInstance('{67D1802F-2AB8-40B9-ADD7-14C9D36903C8}', False, False) do
|
||||
if not FindCmdLineSwitch('multiinstance') then
|
||||
begin
|
||||
Instance.Close;
|
||||
while not SingleInstance('{67D1802F-2AB8-40B9-ADD7-14C9D36903C8}', False, False) do
|
||||
begin
|
||||
Instance.Close;
|
||||
|
||||
if not isRestarting then
|
||||
exit;
|
||||
if not isRestarting then
|
||||
exit;
|
||||
|
||||
Sleep(1000);
|
||||
Sleep(1000);
|
||||
end;
|
||||
end;
|
||||
|
||||
Application.Initialize;
|
||||
|
@ -97,7 +97,7 @@
|
||||
<DCC_UNIT_PLATFORM>False</DCC_UNIT_PLATFORM>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
|
||||
<Debugger_RunParams>/restart</Debugger_RunParams>
|
||||
<Debugger_RunParams>/multiinstance</Debugger_RunParams>
|
||||
<VerInfo_IncludeVerInfo>false</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.1.3.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=0.2;Comments=</VerInfo_Keys>
|
||||
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
|
||||
|
@ -1,15 +1,23 @@
|
||||
local strings = require './lib/strings'
|
||||
|
||||
-- Autopilot master
|
||||
-- Autopilot altitude
|
||||
-- Autopilot approach
|
||||
-- Autopilot backcourse
|
||||
-- Autopilot heading
|
||||
-- Autopilot nav
|
||||
|
||||
|
||||
-- Autopilot airspeed
|
||||
RegisterFunction(
|
||||
{
|
||||
uid = 'autoPilotAirspeed',
|
||||
category = strings.Category.FSX.AutoPilot,
|
||||
displayName = 'Autopilot airspeed',
|
||||
states = {
|
||||
on = { displayName = 'On', default = LEDColor.Green },
|
||||
off = { displayName = 'Off', default = LEDColor.Red },
|
||||
notAvailable = { displayName = 'Not available', default = LEDColor.Off }
|
||||
notAvailable = { displayName = 'Not available', default = LEDColor.Off, order = 1 },
|
||||
on = { displayName = 'On', default = LEDColor.Green, order = 2 },
|
||||
off = { displayName = 'Off', default = LEDColor.Red, order = 3 }
|
||||
}
|
||||
},
|
||||
function(context)
|
||||
|
6
G940LEDControl/Scripts/FSX/controlsurfaces.lua
Normal file
6
G940LEDControl/Scripts/FSX/controlsurfaces.lua
Normal file
@ -0,0 +1,6 @@
|
||||
-- Flaps
|
||||
-- Flaps (handle position)
|
||||
-- Flaps (handle position - percentage)
|
||||
-- Spoilers
|
||||
-- Auto-spoilers armed
|
||||
-- Water rudder
|
3
G940LEDControl/Scripts/FSX/engines.lua
Normal file
3
G940LEDControl/Scripts/FSX/engines.lua
Normal file
@ -0,0 +1,3 @@
|
||||
-- Carb heat / engine anti-ice
|
||||
-- Engine
|
||||
-- Throttle
|
2
G940LEDControl/Scripts/FSX/instruments.lua
Normal file
2
G940LEDControl/Scripts/FSX/instruments.lua
Normal file
@ -0,0 +1,2 @@
|
||||
-- Pitot heat (on / off only)
|
||||
-- Pitot heat (including warnings)
|
49
G940LEDControl/Scripts/FSX/lib/basefunctions.lua
Normal file
49
G940LEDControl/Scripts/FSX/lib/basefunctions.lua
Normal file
@ -0,0 +1,49 @@
|
||||
local basefunctions = {}
|
||||
|
||||
-- Required keys for info:
|
||||
-- uid
|
||||
-- category
|
||||
-- displayName
|
||||
-- variable (SimConnect boolean-compatible variable name)
|
||||
--
|
||||
-- Optional keys:
|
||||
-- inverted (Off is Green instead of Red)
|
||||
basefunctions.RegisterOnOffFunction = function(info)
|
||||
if info.inverted then
|
||||
onOffStates = {
|
||||
on = { displayName = 'On', default = LEDColor.Green, order = 1 },
|
||||
off = { displayName = 'Off', default = LEDColor.Red, order = 2 }
|
||||
}
|
||||
else
|
||||
onOffStates = {
|
||||
on = { displayName = 'On', default = LEDColor.Red, order = 1 },
|
||||
off = { displayName = 'Off', default = LEDColor.Green, order = 2 }
|
||||
}
|
||||
end
|
||||
|
||||
RegisterFunction(
|
||||
{
|
||||
uid = info.uid,
|
||||
category = info.category,
|
||||
displayName = info.displayName,
|
||||
states = onOffStates
|
||||
},
|
||||
function(context)
|
||||
SetState(context, 'on')
|
||||
|
||||
OnSimConnect(context,
|
||||
{
|
||||
value = { variable = info.variable, type = SimConnectDataType.Bool }
|
||||
},
|
||||
function(context, data)
|
||||
if data.value then
|
||||
SetState(context, 'on')
|
||||
else
|
||||
SetState(context, 'off')
|
||||
end
|
||||
end)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
return basefunctions
|
8
G940LEDControl/Scripts/FSX/lights.lua
Normal file
8
G940LEDControl/Scripts/FSX/lights.lua
Normal file
@ -0,0 +1,8 @@
|
||||
-- Beacon lights
|
||||
-- Instrument lights
|
||||
-- Landing lights
|
||||
-- Nav lights
|
||||
-- Recognition lights
|
||||
-- Strobe lights
|
||||
-- Taxi lights
|
||||
-- All lights
|
@ -1,14 +1,16 @@
|
||||
local strings = require './lib/strings'
|
||||
|
||||
|
||||
|
||||
-- ATC panel
|
||||
RegisterFunction(
|
||||
{
|
||||
uid = 'atcVisiblity',
|
||||
category = strings.Category.FSX.Panels,
|
||||
displayName = 'ATC Visibility',
|
||||
displayName = 'ATC panel',
|
||||
states = {
|
||||
hidden = { displayName = 'Hidden', default = LEDColor.Green },
|
||||
visible = { displayName = 'Visible', default = LEDColor.FlashingAmberNormal },
|
||||
hidden = { displayName = 'Hidden', default = LEDColor.Green, order = 1 },
|
||||
visible = { displayName = 'Visible', default = LEDColor.FlashingAmberNormal, order = 2 },
|
||||
}
|
||||
},
|
||||
function(context)
|
||||
|
1
G940LEDControl/Scripts/FSX/radios.lua
Normal file
1
G940LEDControl/Scripts/FSX/radios.lua
Normal file
@ -0,0 +1 @@
|
||||
-- Avionics master
|
173
G940LEDControl/Scripts/FSX/systems.lua
Normal file
173
G940LEDControl/Scripts/FSX/systems.lua
Normal file
@ -0,0 +1,173 @@
|
||||
local basefunctions = require './lib/basefunctions'
|
||||
local strings = require './lib/strings'
|
||||
|
||||
|
||||
-- Battery master
|
||||
basefunctions.RegisterOnOffFunction({
|
||||
category = strings.Category.FSX.Systems,
|
||||
uid = 'batteryMaster',
|
||||
displayName = 'Battery Master',
|
||||
variable = 'ELECTRICAL MASTER BATTERY'
|
||||
})
|
||||
|
||||
|
||||
-- De-ice
|
||||
basefunctions.RegisterOnOffFunction({
|
||||
category = strings.Category.FSX.Systems,
|
||||
uid = 'structuralDeIce',
|
||||
displayName = "De-ice",
|
||||
variable = 'STRUCTURAL DEICE SWITCH'
|
||||
})
|
||||
|
||||
|
||||
-- Exit door
|
||||
RegisterFunction(
|
||||
{
|
||||
uid = 'exitDoor',
|
||||
category = strings.Category.FSX.Systems,
|
||||
displayName = 'Exit door',
|
||||
states = {
|
||||
closed = { displayName = 'Closed', default = LEDColor.Green, order = 1 },
|
||||
between = { displayName = 'Opening / closing', default = LEDColor.Amber, order = 2 },
|
||||
open = { displayName = 'Open', default = LEDColor.Red, order = 3 }
|
||||
}
|
||||
},
|
||||
function(context)
|
||||
SetState(context, 'closed')
|
||||
|
||||
OnSimConnect(context,
|
||||
{
|
||||
canopyOpen = { variable = 'CANOPY OPEN', type = SimConnectDataType.Float64, units = 'percent' }
|
||||
},
|
||||
function(context, data)
|
||||
if data.canopyOpen >= 0 and data.canopyOpen <= 5 then
|
||||
SetState(context, 'closed')
|
||||
elseif data.canopyOpen >= 95 and data.canopyOpen <= 100 then
|
||||
SetState(context, 'open')
|
||||
else
|
||||
SetState(context, 'between')
|
||||
end
|
||||
end)
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
-- Landing gears
|
||||
local function registerGearFunction(functionUid, functionDisplayName, variableName, isFloat)
|
||||
RegisterFunction(
|
||||
{
|
||||
uid = functionUid,
|
||||
category = strings.Category.FSX.Systems,
|
||||
displayName = functionDisplayName,
|
||||
states = {
|
||||
notRetractable = { displayName = 'Not retractable', default = LEDColor.Off, order = 1 },
|
||||
retracted = { displayName = 'Retracted', default = LEDColor.Red, order = 2 },
|
||||
between = { displayName = 'Extending / retracting', default = LEDColor.Amber, order = 3 },
|
||||
extended = { displayName = 'Extended', default = LEDColor.Green, order = 4 },
|
||||
speedExceeded = { displayName = 'Speed exceeded', default = LEDColor.FlashingAmberNormal, order = 5 },
|
||||
damageBySpeed = { displayName = 'Damage by speed', default = LEDColor.FlashingRedFast, order = 6 }
|
||||
}
|
||||
},
|
||||
function(context)
|
||||
SetState(context, 'notRetractable')
|
||||
|
||||
OnSimConnect(context,
|
||||
{
|
||||
isGearRetractable = { variable = 'IS GEAR RETRACTABLE', type = SimConnectDataType.Bool },
|
||||
percentageExtended = { variable = variableName, type = SimConnectDataType.Float64, units = 'percent' },
|
||||
damageBySpeed = { variable = 'GEAR DAMAGE BY SPEED', type = SimConnectDataType.Bool },
|
||||
speedExceeded = { variable = 'GEAR SPEED EXCEEDED', type = SimConnectDataType.Bool },
|
||||
},
|
||||
function(context, data)
|
||||
if data.damageBySpeed then
|
||||
SetState(context, 'damageBySpeed')
|
||||
elseif data.speedExceeded then
|
||||
SetState(context, 'speedExceeded')
|
||||
elseif data.isGearRetractable then
|
||||
local extended = data.percentageExtended
|
||||
|
||||
if isFloat then
|
||||
extended = extended * 100
|
||||
end
|
||||
|
||||
extended = math.floor(extended)
|
||||
if extended == 0 then
|
||||
SetState(context, 'retracted')
|
||||
elseif extended >= 95 and extended <= 100 then
|
||||
SetState(context, 'extended')
|
||||
else
|
||||
SetState(context, 'between')
|
||||
end
|
||||
else
|
||||
SetState(context, 'notRetractable')
|
||||
end
|
||||
end)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
registerGearFunction('gear', 'Landing gear', 'GEAR TOTAL PCT EXTENDED', true)
|
||||
registerGearFunction('leftGear', 'Left main landing gear', 'GEAR LEFT POSITION', false)
|
||||
registerGearFunction('rightGear', 'Right main landing gear', 'GEAR RIGHT POSITION', false)
|
||||
registerGearFunction('centerGear', 'Nose landing gear', 'GEAR CENTER POSITION', false)
|
||||
registerGearFunction('tailGear', 'Tail landing gear', 'GEAR TAIL POSITION', false)
|
||||
|
||||
|
||||
-- Parking brake
|
||||
basefunctions.RegisterOnOffFunction({
|
||||
category = strings.Category.FSX.Systems,
|
||||
uid = 'parkingBrake',
|
||||
displayName = 'Parking brake',
|
||||
variable = 'BRAKE PARKING INDICATOR'
|
||||
})
|
||||
|
||||
|
||||
-- Auto brake
|
||||
RegisterFunction(
|
||||
{
|
||||
uid = 'autoBrake',
|
||||
category = strings.Category.FSX.Systems,
|
||||
displayName = 'Auto brake',
|
||||
states = {
|
||||
['0'] = { displayName = 'Off / not available', default = LEDColor.Green, order = 1 },
|
||||
['1'] = { displayName = '1', default = LEDColor.Amber, order = 2 },
|
||||
['2'] = { displayName = '2', default = LEDColor.Amber, order = 3 },
|
||||
['3'] = { displayName = '3', default = LEDColor.Amber, order = 4 },
|
||||
['4'] = { displayName = '4', default = LEDColor.Red, order = 5 }
|
||||
}
|
||||
},
|
||||
function(context)
|
||||
SetState(context, '0')
|
||||
|
||||
OnSimConnect(context,
|
||||
{
|
||||
switch = { variable = 'AUTO BRAKE SWITCH CB', type = SimConnectDataType.Int32, units = 'number' }
|
||||
},
|
||||
function(context, data)
|
||||
local switch = 4
|
||||
|
||||
if data.switch >= 0 and data.switch <= 4 then
|
||||
switch = data.switch
|
||||
end
|
||||
|
||||
SetState(context, tostring(switch))
|
||||
end)
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
-- Pressurization dump switch
|
||||
basefunctions.RegisterOnOffFunction({
|
||||
category = strings.Category.FSX.Systems,
|
||||
uid = 'pressurizationDumpSwitch',
|
||||
displayName = 'Pressurization dump switch',
|
||||
variable = 'PRESSURIZATION DUMP SWITCH'
|
||||
})
|
||||
|
||||
|
||||
-- Tail hook
|
||||
-- Tail wheel lock
|
||||
-- Float (left)
|
||||
-- Float (right)
|
||||
-- Fuel level
|
@ -176,75 +176,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
(*
|
||||
procedure TFSXLEDFunctionProvider.RegisterFunctions;
|
||||
begin
|
||||
inherited RegisterFunctions;
|
||||
|
||||
{ Systems }
|
||||
RegisterFunction(TFSXBatteryMasterFunction.Create( Self, FSXFunctionDisplayNameBatteryMaster, FSXFunctionUIDBatteryMaster));
|
||||
RegisterFunction(TFSXDeIceFunction.Create( Self, FSXFunctionDisplayNameDeIce, FSXFunctionUIDDeIce));
|
||||
RegisterFunction(TFSXExitDoorFunction.Create( Self, FSXFunctionDisplayNameExitDoor, FSXFunctionUIDExitDoor));
|
||||
RegisterFunction(TFSXGearFunction.Create( Self, FSXFunctionDisplayNameGear, FSXFunctionUIDGear));
|
||||
RegisterFunction(TFSXLeftGearFunction.Create( Self, FSXFunctionDisplayNameLeftGear, FSXFunctionUIDLeftGear));
|
||||
RegisterFunction(TFSXRightGearFunction.Create( Self, FSXFunctionDisplayNameRightGear, FSXFunctionUIDRightGear));
|
||||
RegisterFunction(TFSXCenterGearFunction.Create( Self, FSXFunctionDisplayNameCenterGear, FSXFunctionUIDCenterGear));
|
||||
RegisterFunction(TFSXTailGearFunction.Create( Self, FSXFunctionDisplayNameTailGear, FSXFunctionUIDTailGear));
|
||||
RegisterFunction(TFSXParkingBrakeFunction.Create( Self, FSXFunctionDisplayNameParkingBrake, FSXFunctionUIDParkingBrake));
|
||||
RegisterFunction(TFSXAutoBrakeFunction.Create( Self, FSXFunctionDisplayNameAutoBrake, FSXFunctionUIDAutoBrake));
|
||||
RegisterFunction(TFSXPressDumpSwitchFunction.Create( Self, FSXFunctionDisplayNamePressDumpSwitch, FSXFunctionUIDPressDumpSwitch));
|
||||
RegisterFunction(TFSXTailHookFunction.Create( Self, FSXFunctionDisplayNameTailHook, FSXFunctionUIDTailHook));
|
||||
RegisterFunction(TFSXTailWheelLockFunction.Create( Self, FSXFunctionDisplayNameTailWheelLock, FSXFunctionUIDTailWheelLock));
|
||||
RegisterFunction(TFSXFloatLeftFunction.Create( Self, FSXFunctionDisplayNameFloatLeft, FSXFunctionUIDFloatLeft));
|
||||
RegisterFunction(TFSXFloatRightFunction.Create( Self, FSXFunctionDisplayNameFloatRight, FSXFunctionUIDFloatRight));
|
||||
|
||||
{ Instruments }
|
||||
RegisterFunction(TFSXPitotOnOffFunction.Create( Self, FSXFunctionDisplayNamePitotOnOff, FSXFunctionUIDPitotOnOff));
|
||||
RegisterFunction(TFSXPitotWarningFunction.Create( Self, FSXFunctionDisplayNamePitotWarning, FSXFunctionUIDPitotWarning));
|
||||
|
||||
{ Engines }
|
||||
RegisterFunction(TFSXEngineAntiIceFunction.Create( Self, FSXFunctionDisplayNameEngineAntiIce, FSXFunctionUIDEngineAntiIce));
|
||||
RegisterFunction(TFSXEngineFunction.Create( Self, FSXFunctionDisplayNameEngine, FSXFunctionUIDEngine));
|
||||
RegisterFunction(TFSXThrottleFunction.Create( Self, FSXFunctionDisplayNameThrottle, FSXFunctionUIDThrottle));
|
||||
|
||||
{ Control surfaces }
|
||||
RegisterFunction(TFSXFlapsFunction.Create( Self, FSXFunctionDisplayNameFlaps, FSXFunctionUIDFlaps));
|
||||
RegisterFunction(TFSXFlapsHandleIndexFunction.Create( Self, FSXFunctionDisplayNameFlapsHandleIndex, FSXFunctionUIDFlapsHandleIndex));
|
||||
RegisterFunction(TFSXFlapsHandlePercentageFunction.Create(Self, FSXFunctionDisplayNameFlapsHandlePercentage, FSXFunctionUIDFlapsHandlePercentage));
|
||||
RegisterFunction(TFSXSpoilersFunction.Create( Self, FSXFunctionDisplayNameSpoilers, FSXFunctionUIDSpoilers));
|
||||
RegisterFunction(TFSXSpoilersArmedFunction.Create( Self, FSXFunctionDisplayNameSpoilersArmed, FSXFunctionUIDSpoilersArmed));
|
||||
RegisterFunction(TFSXWaterRudderFunction.Create( Self, FSXFunctionDisplayNameWaterRudder, FSXFunctionUIDWaterRudder));
|
||||
|
||||
{ Lights }
|
||||
RegisterFunction(TFSXBeaconLightsFunction.Create( Self, FSXFunctionDisplayNameBeaconLights, FSXFunctionUIDBeaconLights));
|
||||
RegisterFunction(TFSXInstrumentLightsFunction.Create( Self, FSXFunctionDisplayNameInstrumentLights, FSXFunctionUIDInstrumentLights));
|
||||
RegisterFunction(TFSXLandingLightsFunction.Create( Self, FSXFunctionDisplayNameLandingLights, FSXFunctionUIDLandingLights));
|
||||
RegisterFunction(TFSXNavLightsFunction.Create( Self, FSXFunctionDisplayNameNavLights, FSXFunctionUIDNavLights));
|
||||
RegisterFunction(TFSXRecognitionLightsFunction.Create( Self, FSXFunctionDisplayNameRecognitionLights, FSXFunctionUIDRecognitionLights));
|
||||
RegisterFunction(TFSXStrobeLightsFunction.Create( Self, FSXFunctionDisplayNameStrobeLights, FSXFunctionUIDStrobeLights));
|
||||
RegisterFunction(TFSXTaxiLightsFunction.Create( Self, FSXFunctionDisplayNameTaxiLights, FSXFunctionUIDTaxiLights));
|
||||
RegisterFunction(TFSXAllLightsFunction.Create( Self, FSXFunctionDisplayNameAllLights, FSXFunctionUIDAllLights));
|
||||
|
||||
{ Autopilot }
|
||||
RegisterFunction(TFSXAutoPilotFunction.Create( Self, FSXFunctionDisplayNameAutoPilot, FSXFunctionUIDAutoPilot));
|
||||
RegisterFunction(TFSXAutoPilotAltitudeFunction.Create( Self, FSXFunctionDisplayNameAutoPilotAltitude, FSXFunctionUIDAutoPilotAltitude));
|
||||
RegisterFunction(TFSXAutoPilotApproachFunction.Create( Self, FSXFunctionDisplayNameAutoPilotApproach, FSXFunctionUIDAutoPilotApproach));
|
||||
RegisterFunction(TFSXAutoPilotBackcourseFunction.Create( Self, FSXFunctionDisplayNameAutoPilotBackcourse, FSXFunctionUIDAutoPilotBackcourse));
|
||||
RegisterFunction(TFSXAutoPilotHeadingFunction.Create( Self, FSXFunctionDisplayNameAutoPilotHeading, FSXFunctionUIDAutoPilotHeading));
|
||||
RegisterFunction(TFSXAutoPilotNavFunction.Create( Self, FSXFunctionDisplayNameAutoPilotNav, FSXFunctionUIDAutoPilotNav));
|
||||
RegisterFunction(TFSXAutoPilotAirspeedFunction.Create( Self, FSXFunctionDisplayNameAutoPilotAirspeed, FSXFunctionUIDAutoPilotAirspeed));
|
||||
|
||||
{ Radios }
|
||||
RegisterFunction(TFSXAvionicsMasterFunction.Create( Self, FSXFunctionDisplayNameAvionicsMaster, FSXFunctionUIDAvionicsMaster));
|
||||
|
||||
{ Fuel }
|
||||
RegisterFunction(TFSXFuelFunction.Create( Self, FSXFunctionDisplayNameFuel, FSXFunctionUIDFuel));
|
||||
|
||||
{ ATC }
|
||||
RegisterFunction(TFSXATCVisibilityFunction.Create(FSXProviderUID));
|
||||
end;
|
||||
*)
|
||||
|
||||
function TFSXLEDFunctionProvider.CreateLuaLEDFunction(AInfo: ILuaTable; AOnSetup: ILuaFunction): TCustomLuaLEDFunction;
|
||||
begin
|
||||
Result := TFSXLEDFunction.Create(Self, AInfo, AOnSetup);
|
||||
|
@ -108,6 +108,8 @@ implementation
|
||||
uses
|
||||
System.Classes,
|
||||
System.IOUtils,
|
||||
System.Generics.Defaults,
|
||||
System.Math,
|
||||
System.StrUtils,
|
||||
Winapi.Windows,
|
||||
|
||||
@ -557,32 +559,62 @@ end;
|
||||
|
||||
|
||||
procedure TCustomLuaLEDFunction.RegisterStates;
|
||||
type
|
||||
TOrderedLEDState = record
|
||||
Order: Integer;
|
||||
State: ILEDState;
|
||||
end;
|
||||
|
||||
var
|
||||
state: TLuaKeyValuePair;
|
||||
states: TList<TOrderedLEDState>;
|
||||
scriptState: TLuaKeyValuePair;
|
||||
displayName: string;
|
||||
defaultColor: TLEDColor;
|
||||
info: ILuaTable;
|
||||
state: TOrderedLEDState;
|
||||
|
||||
begin
|
||||
if not Assigned(ScriptStates) then
|
||||
exit;
|
||||
|
||||
for state in ScriptStates do
|
||||
begin
|
||||
displayName := state.Key.AsString;
|
||||
defaultColor := lcOff;
|
||||
|
||||
if state.Value.VariableType = VariableTable then
|
||||
states := TList<TOrderedLEDState>.Create;
|
||||
try
|
||||
for scriptState in ScriptStates do
|
||||
begin
|
||||
info := state.Value.AsTable;
|
||||
if info.HasValue('displayName') then
|
||||
displayName := info.GetValue('displayName').AsString;
|
||||
state.Order := 0;
|
||||
|
||||
if info.HasValue('default') then
|
||||
defaultColor := GetLEDColor(info.GetValue('default').AsString);
|
||||
displayName := scriptState.Key.AsString;
|
||||
defaultColor := lcOff;
|
||||
|
||||
if scriptState.Value.VariableType = VariableTable then
|
||||
begin
|
||||
info := scriptState.Value.AsTable;
|
||||
if info.HasValue('displayName') then
|
||||
displayName := info.GetValue('displayName').AsString;
|
||||
|
||||
if info.HasValue('default') then
|
||||
defaultColor := GetLEDColor(info.GetValue('default').AsString);
|
||||
|
||||
if info.HasValue('order') then
|
||||
state.Order := info.GetValue('order').AsInteger;
|
||||
end;
|
||||
|
||||
state.State := TLEDState.Create(scriptState.Key.AsString, displayName, defaultColor);
|
||||
states.Add(state)
|
||||
end;
|
||||
|
||||
RegisterState(TLEDState.Create(state.Key.AsString, displayName, defaultColor));
|
||||
states.Sort(TDelegatedComparer<TOrderedLEDState>.Create(
|
||||
function(const Left, Right: TOrderedLEDState): Integer
|
||||
begin
|
||||
Result := CompareValue(Left.Order, Right.Order);
|
||||
if Result = 0 then
|
||||
Result := CompareText(Left.State.GetDisplayName, Right.State.GetDisplayName);
|
||||
end));
|
||||
|
||||
for state in states do
|
||||
RegisterState(state.State);
|
||||
finally
|
||||
FreeAndNil(states);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user