From c16b3fefaf0dc3a7f7c3738b451b150881eedf26 Mon Sep 17 00:00:00 2001 From: Stanley Date: Thu, 4 Aug 2022 23:43:51 -0400 Subject: [PATCH] Started development v3.4.2 --- Orchestration/FlightSimData.cs | 3 +++ Orchestration/FlightSimOrchestrator.cs | 13 ++++++++++--- Orchestration/PanelConfigurationOrchestrator.cs | 2 +- Orchestration/ProfileData.cs | 15 +++++++++++++++ ReactClient/public/config/PlanePanelProfile.json | 4 ++-- .../kodiak/pfdmfd/PopoutPanelDefinition.json | 5 ++++- ReactClient/src/App/InteractiveControlTemplate.js | 6 +++--- SimconnectAgent/TouchPanel/ActionProvider.cs | 10 +++++++--- UserDataAgent/Profile.cs | 7 +++++++ 9 files changed, 52 insertions(+), 13 deletions(-) diff --git a/Orchestration/FlightSimData.cs b/Orchestration/FlightSimData.cs index 0db6897..63e78f0 100644 --- a/Orchestration/FlightSimData.cs +++ b/Orchestration/FlightSimData.cs @@ -10,6 +10,8 @@ namespace MSFSPopoutPanelManager.Orchestration public string CurrentMsfsAircraft { get; set; } + public string CurrentMsfsLiveryTitle { get; set; } + public bool HasCurrentMsfsAircraft { get { return !String.IsNullOrEmpty(CurrentMsfsAircraft); } @@ -35,6 +37,7 @@ namespace MSFSPopoutPanelManager.Orchestration public void ClearData() { CurrentMsfsAircraft = null; + CurrentMsfsLiveryTitle = null; ElectricalMasterBatteryStatus = false; IsEnteredFlight = false; } diff --git a/Orchestration/FlightSimOrchestrator.cs b/Orchestration/FlightSimOrchestrator.cs index 46a4a5f..d5343cb 100644 --- a/Orchestration/FlightSimOrchestrator.cs +++ b/Orchestration/FlightSimOrchestrator.cs @@ -46,6 +46,16 @@ namespace MSFSPopoutPanelManager.Orchestration var aircraftName = Convert.ToString(e.Find(d => d.PropName == "AircraftName").Value); aircraftName = String.IsNullOrEmpty(aircraftName) ? null : aircraftName; var electricalMasterBattery = Convert.ToBoolean(e.Find(d => d.PropName == "ElectricalMasterBattery").Value); + var liveryName = Convert.ToString(e.Find(d => d.PropName == "Title").Value); + + if (electricalMasterBattery != FlightSimData.ElectricalMasterBatteryStatus) + FlightSimData.ElectricalMasterBatteryStatus = electricalMasterBattery; + + if (liveryName != FlightSimData.CurrentMsfsLiveryTitle) + { + FlightSimData.CurrentMsfsLiveryTitle = liveryName; + ProfileData.MigrateLiveryToAircraftBinding(liveryName, aircraftName); + } // Automatic switching of active profile when SimConnect active aircraft change if (FlightSimData.CurrentMsfsAircraft != aircraftName) @@ -53,9 +63,6 @@ namespace MSFSPopoutPanelManager.Orchestration FlightSimData.CurrentMsfsAircraft = aircraftName; ProfileData.AutoSwitchProfile(aircraftName); } - - if (electricalMasterBattery != FlightSimData.ElectricalMasterBatteryStatus) - FlightSimData.ElectricalMasterBatteryStatus = electricalMasterBattery; }; _simConnectProvider.OnFlightStarted += (sender, e) => OnFlightStarted?.Invoke(this, null); _simConnectProvider.OnFlightStopped += HandleOnFlightStopped; diff --git a/Orchestration/PanelConfigurationOrchestrator.cs b/Orchestration/PanelConfigurationOrchestrator.cs index f2037f1..04d0433 100644 --- a/Orchestration/PanelConfigurationOrchestrator.cs +++ b/Orchestration/PanelConfigurationOrchestrator.cs @@ -231,7 +231,7 @@ namespace MSFSPopoutPanelManager.Orchestration { case PInvokeConstant.EVENT_SYSTEM_MOVESIZEEND: // Move window back to original location - PInvoke.MoveWindow(panelConfig.PanelHandle, panelConfig.Left, panelConfig.Top, panelConfig.Width, panelConfig.Height, false); + WindowActionManager.MoveWindow(panelConfig.PanelHandle, panelConfig.PanelType, panelConfig.Left, panelConfig.Top, panelConfig.Width, panelConfig.Height); break; case PInvokeConstant.EVENT_OBJECT_LOCATIONCHANGE: // Detect if window is maximized, if so, save settings diff --git a/Orchestration/ProfileData.cs b/Orchestration/ProfileData.cs index 673b583..04e71bc 100644 --- a/Orchestration/ProfileData.cs +++ b/Orchestration/ProfileData.cs @@ -170,5 +170,20 @@ namespace MSFSPopoutPanelManager.Orchestration UpdateActiveProfile(matchedProfile.ProfileId); } } + + // This is to migrate profile binding from aircraft livery to aircraft name + // Started in v3.4.2 + public void MigrateLiveryToAircraftBinding(string liveryName, string aircraftName) + { + if (Profiles != null) + { + var matchedProfile = Profiles.FirstOrDefault(p => p.BindingAircraftLiveries.Any(t => t == liveryName)); + if (matchedProfile != null && !matchedProfile.BindingAircrafts.Any(a => a == aircraftName)) + { + matchedProfile.BindingAircrafts.Add(aircraftName); + WriteProfiles(); + } + } + } } } diff --git a/ReactClient/public/config/PlanePanelProfile.json b/ReactClient/public/config/PlanePanelProfile.json index 7da876d..3f390b3 100644 --- a/ReactClient/public/config/PlanePanelProfile.json +++ b/ReactClient/public/config/PlanePanelProfile.json @@ -69,8 +69,8 @@ "width": 1408, "height": 914 }, - "showMenuBar": false, - "enableMap": false, + "showMenuBar": true, + "enableMap": true, "subPanels": [ { "panelId": "pfd", diff --git a/ReactClient/public/config/profiles/kodiak/pfdmfd/PopoutPanelDefinition.json b/ReactClient/public/config/profiles/kodiak/pfdmfd/PopoutPanelDefinition.json index 9b92e12..c501ed8 100644 --- a/ReactClient/public/config/profiles/kodiak/pfdmfd/PopoutPanelDefinition.json +++ b/ReactClient/public/config/profiles/kodiak/pfdmfd/PopoutPanelDefinition.json @@ -351,7 +351,10 @@ "actionType": "EncoderAction" } ], - "useDualEncoder": true + "useDualEncoder": true, + "encoderAction": { + "$ref": "#value.encoderAction.mfdFms" + } } }, { diff --git a/ReactClient/src/App/InteractiveControlTemplate.js b/ReactClient/src/App/InteractiveControlTemplate.js index 4c944c4..12aa0f5 100644 --- a/ReactClient/src/App/InteractiveControlTemplate.js +++ b/ReactClient/src/App/InteractiveControlTemplate.js @@ -31,6 +31,7 @@ const getImagePath = (panelInfo) => { const playSound = (isEnabledSound) => { if (isEnabledSound) { let audio = new Audio('/sound/button-click.mp3'); + audio.volume = 0.5; audio.play(); } } @@ -53,7 +54,6 @@ const execActions = (event, action, simConnectData, showEncoder) => { actionType: curAction.actionType, encoderAction: action.encoderAction === undefined ? null : action.encoderAction }), 200 * i); - if(action.useEncoder) { @@ -123,7 +123,7 @@ const ImageButton = ({ctrl, panelInfo, showEncoder}) => { setTimeout(() => { isHighlighted.current = false; }, 2000); } - if (ctrl.actions != null && ctrl.actions.length > 0) + if (ctrl.action != null) playSound(isEnabledSound); if (!isUsedArduino && (ctrl.action.useEncoder || ctrl.action.useDualEncoder)) @@ -176,7 +176,7 @@ const BindableImageButton = ({ctrl, panelInfo, showEncoder}) => { setTimeout(() => { isHighlighted.current = false; }, 2000); } - if (ctrl.actions != null && ctrl.actions.length > 0) + if (ctrl.action != null) playSound(isEnabledSound); if (!isUsedArduino && (ctrl.action.useEncoder || ctrl.action.useDualEncoder)) diff --git a/SimconnectAgent/TouchPanel/ActionProvider.cs b/SimconnectAgent/TouchPanel/ActionProvider.cs index 78c483a..8f5e830 100644 --- a/SimconnectAgent/TouchPanel/ActionProvider.cs +++ b/SimconnectAgent/TouchPanel/ActionProvider.cs @@ -129,9 +129,9 @@ namespace MSFSPopoutPanelManager.SimConnectAgent.TouchPanel var commandAction = ActionLogicArduino.GetSimConnectCommand(_currentSimConnectEncoderAction, e.InputName, e.InputAction); - if (e.Acceleration == 1) + // do manual arduino joystick acceleration + if (e.Acceleration == 1 && e.InputName == InputName.Joystick) { - // do manual acceleration if (_lastCommandAction != null && commandAction.Action == _lastCommandAction.Action) _repeatCommandActionCount++; else @@ -149,13 +149,17 @@ namespace MSFSPopoutPanelManager.SimConnectAgent.TouchPanel _actionQueue.Enqueue(commandAction); } - else + else if (e.Acceleration > 1) { for (var a = 0; a < e.Acceleration; a++) { _actionQueue.Enqueue(commandAction); } } + else + { + _actionQueue.Enqueue(commandAction); + } } } diff --git a/UserDataAgent/Profile.cs b/UserDataAgent/Profile.cs index b7c598c..4d7f33e 100644 --- a/UserDataAgent/Profile.cs +++ b/UserDataAgent/Profile.cs @@ -14,6 +14,9 @@ namespace MSFSPopoutPanelManager.UserDataAgent PanelSourceCoordinates = new ObservableCollection(); TouchPanelBindings = new ObservableCollection(); IsLocked = false; + + // Legacy data + BindingAircraftLiveries = new ObservableCollection(); } public int ProfileId { get; set; } @@ -29,6 +32,10 @@ namespace MSFSPopoutPanelManager.UserDataAgent public ObservableCollection TouchPanelBindings { get; set; } + // Legacy data + [JsonConverter(typeof(SingleValueArrayConvertor))] + public ObservableCollection BindingAircraftLiveries { get; set; } + public bool IsLocked { get; set; } public bool PowerOnRequiredForColdStart { get; set; }