From f996863bd8a04c6acd8177cfa18867ff31dba91b Mon Sep 17 00:00:00 2001 From: Stanley Date: Tue, 2 Aug 2022 11:51:28 -0400 Subject: [PATCH] Started development v3.4.2 --- Orchestration/MainOrchestrator.cs | 1 + Orchestration/PanelPopOutOrchestrator.cs | 3 ++ Orchestration/ProfileOrchestrator.cs | 12 ++++++++ Shared/FileIO.cs | 8 +++++ SimconnectAgent/Enums.cs | 7 ++++- SimconnectAgent/SimConnector.cs | 37 +++++++++++++++++++----- VERSION.md | 7 +++++ WpfApp/UserControlPanelSelection.xaml | 12 +++++--- 8 files changed, 74 insertions(+), 13 deletions(-) diff --git a/Orchestration/MainOrchestrator.cs b/Orchestration/MainOrchestrator.cs index aeee2c4..76475e4 100644 --- a/Orchestration/MainOrchestrator.cs +++ b/Orchestration/MainOrchestrator.cs @@ -68,6 +68,7 @@ namespace MSFSPopoutPanelManager.Orchestration ProfileData.ReadProfiles(); Profile.ProfileData = ProfileData; + Profile.FlightSimData = FlightSimData; PanelSource.ProfileData = ProfileData; PanelSource.AppSettingData = AppSettingData; diff --git a/Orchestration/PanelPopOutOrchestrator.cs b/Orchestration/PanelPopOutOrchestrator.cs index 478655d..dc88925 100644 --- a/Orchestration/PanelPopOutOrchestrator.cs +++ b/Orchestration/PanelPopOutOrchestrator.cs @@ -259,6 +259,9 @@ namespace MSFSPopoutPanelManager.Orchestration return null; } + // Fix SU10+ bug where pop out window after separation is huge + WindowActionManager.MoveWindow(handle, PanelType.CustomPopout, -8, 0, 800, 600); + var panel = new PanelConfig(); panel.PanelHandle = handle; panel.PanelType = PanelType.CustomPopout; diff --git a/Orchestration/ProfileOrchestrator.cs b/Orchestration/ProfileOrchestrator.cs index c6b7824..86f9c35 100644 --- a/Orchestration/ProfileOrchestrator.cs +++ b/Orchestration/ProfileOrchestrator.cs @@ -1,4 +1,5 @@ using MSFSPopoutPanelManager.Shared; +using System.Linq; namespace MSFSPopoutPanelManager.Orchestration { @@ -6,12 +7,23 @@ namespace MSFSPopoutPanelManager.Orchestration { internal ProfileData ProfileData { get; set; } + internal FlightSimData FlightSimData { get; set; } + public void AddProfile(string profileName, int copyProfileId) { if (copyProfileId == -1) ProfileData.AddProfile(profileName); else ProfileData.AddProfile(profileName, copyProfileId); + + // Automatically bind aircraft + var boundProfile = ProfileData.Profiles.FirstOrDefault(p => p.BindingAircrafts.Any(p => p == FlightSimData.CurrentMsfsAircraft)); + if (boundProfile == null && FlightSimData.HasCurrentMsfsAircraft) + { + ProfileData.ActiveProfile.BindingAircrafts.Add(FlightSimData.CurrentMsfsAircraft); + ProfileData.WriteProfiles(); + ProfileData.RefreshProfile(); + } } public void DeleteActiveProfile() diff --git a/Shared/FileIO.cs b/Shared/FileIO.cs index d74ad4f..fd9d9eb 100644 --- a/Shared/FileIO.cs +++ b/Shared/FileIO.cs @@ -9,6 +9,8 @@ namespace MSFSPopoutPanelManager.Shared { #if DEBUG || DEBUGTOUCHPANEL return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MSFS Pop Out Panel Manager Debug"); +#elif RELEASETOUCHPANEL + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MSFS Pop Out Panel Manager Touch Panel"); #else return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MSFS Pop Out Panel Manager"); #endif @@ -18,6 +20,8 @@ namespace MSFSPopoutPanelManager.Shared { #if DEBUG || DEBUGTOUCHPANEL return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"MSFS Pop Out Panel Manager Debug\LogFiles\error.log"); +#elif RELEASETOUCHPANEL + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"MSFS Pop Out Panel Manager Touch Panel\LogFiles\error.log"); #else return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"MSFS Pop Out Panel Manager\LogFiles\error.log"); #endif @@ -27,6 +31,8 @@ namespace MSFSPopoutPanelManager.Shared { #if DEBUG || DEBUGTOUCHPANEL return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"MSFS Pop Out Panel Manager Debug\LogFiles\debug.log"); +#elif RELEASETOUCHPANEL + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"MSFS Pop Out Panel Manager Touch Panel\LogFiles\debug.log"); #else return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"MSFS Pop Out Panel Manager\LogFiles\debug.log"); #endif @@ -36,6 +42,8 @@ namespace MSFSPopoutPanelManager.Shared { #if DEBUG || DEBUGTOUCHPANEL return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"MSFS Pop Out Panel Manager Debug\LogFiles\info.log"); +#elif RELEASETOUCHPANEL + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"MSFS Pop Out Panel Manager Touch Panel\LogFiles\info.log"); #else return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"MSFS Pop Out Panel Manager\LogFiles\info.log"); #endif diff --git a/SimconnectAgent/Enums.cs b/SimconnectAgent/Enums.cs index e904778..153c557 100644 --- a/SimconnectAgent/Enums.cs +++ b/SimconnectAgent/Enums.cs @@ -55,5 +55,10 @@ namespace MSFSPopoutPanelManager.SimConnectAgent PAUSED, VIEW, NONE - }; + } + + public enum SystemStateRequestId + { + AIRCRAFTPATH + } } diff --git a/SimconnectAgent/SimConnector.cs b/SimconnectAgent/SimConnector.cs index 4a14d19..83422aa 100644 --- a/SimconnectAgent/SimConnector.cs +++ b/SimconnectAgent/SimConnector.cs @@ -153,6 +153,7 @@ namespace MSFSPopoutPanelManager.SimConnectAgent _simConnect.OnRecvEvent += HandleOnReceiveSystemEvent; _simConnect.OnRecvSimobjectDataBytype += HandleOnRecvSimobjectDataBytype; _simConnect.OnRecvEventFilename += HandleOnRecvEventFilename; + _simConnect.OnRecvSystemState += HandleOnRecvSystemState; // Register simConnect system events _simConnect.UnsubscribeFromSystemEvent(SimConnectSystemEvent.SIMSTART); @@ -164,26 +165,37 @@ namespace MSFSPopoutPanelManager.SimConnectAgent _simConnect.UnsubscribeFromSystemEvent(SimConnectSystemEvent.AIRCRAFTLOADED); _simConnect.SubscribeToSystemEvent(SimConnectSystemEvent.AIRCRAFTLOADED, "AircraftLoaded"); - System.Threading.Thread.Sleep(5000); - ReceiveMessage(); - AddDataDefinitions(); + for (var i = 0; i < 5; i++) + { + System.Threading.Thread.Sleep(1000); + ReceiveMessage(); + } + + _simConnect.RequestSystemState(SystemStateRequestId.AIRCRAFTPATH, "AircraftLoaded"); + Connected = true; OnConnected?.Invoke(this, null); StatusMessageWriter.WriteMessage("MSFS is connected", StatusMessageType.Info, false); } + private void HandleOnRecvSystemState(SimConnect sender, SIMCONNECT_RECV_SYSTEM_STATE data) + { + switch ((SystemStateRequestId)Enum.Parse(typeof(SystemStateRequestId), data.dwRequestID.ToString())) + { + case SystemStateRequestId.AIRCRAFTPATH: + SetActiveAircraftTitle(data.szString); + break; + } + } + private void HandleOnRecvEventFilename(SimConnect sender, SIMCONNECT_RECV_EVENT_FILENAME data) { switch (data.uEventID) { case (uint)SimConnectSystemEvent.AIRCRAFTLOADED: - var filePathToken = data.szFileName.Split(@"\"); - var aircraftName = filePathToken[filePathToken.Length - 2]; - aircraftName = aircraftName.Replace("_", " ").ToUpper(); - - SimConnectDataDefinitions.Find(s => s.PropName == "AircraftName").Value = aircraftName; + SetActiveAircraftTitle(data.szFileName); break; } } @@ -296,5 +308,14 @@ namespace MSFSPopoutPanelManager.SimConnectAgent var systemEvent = ((SimConnectSystemEvent)data.uEventID); OnReceiveSystemEvent?.Invoke(this, systemEvent); } + + private void SetActiveAircraftTitle(string aircraftFilePath) + { + var filePathToken = aircraftFilePath.Split(@"\"); + var aircraftName = filePathToken[filePathToken.Length - 2]; + aircraftName = aircraftName.Replace("_", " ").ToUpper(); + + SimConnectDataDefinitions.Find(s => s.PropName == "AircraftName").Value = aircraftName; + } } } \ No newline at end of file diff --git a/VERSION.md b/VERSION.md index cabccbd..ce43776 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1,6 +1,13 @@ # Version History
+## Version 3.4.2 +* Major change in how profile is being bound to aircraft. A profile is no longer bound to a livery but instead it is bound to an aircraft so you do not have to manual activate binding for individual livery for the same plane. This has been a long awaited request. + +* Auto assign aircraft binding when profile is initially created if the active aircraft has no previous profile binding specify. + +* Implemented work around for SU10+ issue where after panel separation, the panel's size is huge which blocked most of the game window for lower resolution screen and prevented Pop Out Panel Manager from popping out the next panel. + ## Version 3.4.1 This release is solely focused on addressing issues regarding touch panel capabilities as well as making improvements to touch feature. Panels I used for testing are diff --git a/WpfApp/UserControlPanelSelection.xaml b/WpfApp/UserControlPanelSelection.xaml index 7f3ee91..22f32c4 100644 --- a/WpfApp/UserControlPanelSelection.xaml +++ b/WpfApp/UserControlPanelSelection.xaml @@ -45,12 +45,12 @@ -