diff --git a/Orchestration/FlightSimData.cs b/Orchestration/FlightSimData.cs index 1557bc5..733efd3 100644 --- a/Orchestration/FlightSimData.cs +++ b/Orchestration/FlightSimData.cs @@ -22,7 +22,7 @@ namespace MSFSPopoutPanelManager.Orchestration public bool IsSimulatorStarted { get; set; } - public bool IsEnteredFlight { get; set; } + public bool IsInCockpit { get; set; } public new void OnPropertyChanged(string propertyName, object oldValue, object newValue) { @@ -43,7 +43,6 @@ namespace MSFSPopoutPanelManager.Orchestration CurrentMsfsAircraft = null; CurrentMsfsLiveryTitle = null; ElectricalMasterBatteryStatus = false; - IsEnteredFlight = false; } } } diff --git a/Orchestration/FlightSimOrchestrator.cs b/Orchestration/FlightSimOrchestrator.cs index e82f2ba..42be496 100644 --- a/Orchestration/FlightSimOrchestrator.cs +++ b/Orchestration/FlightSimOrchestrator.cs @@ -64,8 +64,9 @@ namespace MSFSPopoutPanelManager.Orchestration ProfileData.AutoSwitchProfile(); } }; - _simConnectProvider.OnFlightStarted += (sender, e) => OnFlightStarted?.Invoke(this, null); + _simConnectProvider.OnFlightStarted += HandleOnFlightStarted; _simConnectProvider.OnFlightStopped += HandleOnFlightStopped; + _simConnectProvider.OnIsInCockpitChanged += (sender, e) => FlightSimData.IsInCockpit = e; _simConnectProvider.Start(); } @@ -110,22 +111,16 @@ namespace MSFSPopoutPanelManager.Orchestration _simConnectProvider.TurnOffAvionics(ProfileData.ActiveProfile.PowerOnRequiredForColdStart); } - public void AutoPanelPopOutActivation(bool activate) + private void HandleOnFlightStarted(object sender, EventArgs e) { - if (activate) - _simConnectProvider.OnFlightStarted += HandleOnFlightStartedForAutoPopOut; - else - _simConnectProvider.OnFlightStarted -= HandleOnFlightStartedForAutoPopOut; - } + OnFlightStarted?.Invoke(this, null); - private void HandleOnFlightStartedForAutoPopOut(object sender, EventArgs e) - { - OnFlightStartedForAutoPopOut?.Invoke(this, null); + if (AppSettingData.AppSetting.AutoPopOutPanels) + OnFlightStartedForAutoPopOut?.Invoke(this, null); } private void HandleOnFlightStopped(object sender, EventArgs e) { - FlightSimData.IsEnteredFlight = false; OnFlightStopped?.Invoke(this, null); } } diff --git a/Orchestration/MainOrchestrator.cs b/Orchestration/MainOrchestrator.cs index b3a044b..191d7c7 100644 --- a/Orchestration/MainOrchestrator.cs +++ b/Orchestration/MainOrchestrator.cs @@ -24,7 +24,6 @@ namespace MSFSPopoutPanelManager.Orchestration FlightSimData.CurrentMsfsLiveryTitleChanged += (sernder, e) => { ProfileData.MigrateLiveryToAircraftBinding(); ProfileData.AutoSwitchProfile(); }; AppSettingData = new AppSettingData(); - AppSettingData.AutoPopOutPanelsChanged += (sender, e) => FlightSim.AutoPanelPopOutActivation(e); AppSettingData.TouchPanelIntegrationChanged += async (sender, e) => { await TouchPanel.TouchPanelIntegrationUpdated(e); @@ -99,7 +98,6 @@ namespace MSFSPopoutPanelManager.Orchestration CheckForAutoUpdate(); ProfileData.UpdateActiveProfile(AppSettingData.AppSetting.LastUsedProfileId); // Load last used profile - FlightSim.AutoPanelPopOutActivation(AppSettingData.AppSetting.AutoPopOutPanels); // Activate auto pop out panel if defined in preferences FlightSim.StartSimConnectServer(); // Start the SimConnect server // Enable/Disable touch panel feature (Personal use only feature) diff --git a/Orchestration/PanelPopOutOrchestrator.cs b/Orchestration/PanelPopOutOrchestrator.cs index 14065cd..2d0cdb1 100644 --- a/Orchestration/PanelPopOutOrchestrator.cs +++ b/Orchestration/PanelPopOutOrchestrator.cs @@ -57,8 +57,6 @@ namespace MSFSPopoutPanelManager.Orchestration ProfileData.AutoSwitchProfile(); - FlightSimData.IsEnteredFlight = true; - // find the profile with the matching binding aircraft var profile = ProfileData.Profiles.FirstOrDefault(p => p.BindingAircrafts.Any(p => p == FlightSimData.CurrentMsfsAircraft)); diff --git a/Orchestration/ProfileData.cs b/Orchestration/ProfileData.cs index a5e3c9e..8c6fb51 100644 --- a/Orchestration/ProfileData.cs +++ b/Orchestration/ProfileData.cs @@ -175,13 +175,25 @@ namespace MSFSPopoutPanelManager.Orchestration // Started in v3.4.2 public void MigrateLiveryToAircraftBinding(string liveryName, string aircraftName) { + bool hasChanges = false; if (Profiles != null && !string.IsNullOrEmpty(liveryName) && !string.IsNullOrEmpty(aircraftName)) { var matchedProfile = Profiles.FirstOrDefault(p => p.BindingAircraftLiveries.Any(t => t == liveryName)); + if (matchedProfile != null && !matchedProfile.BindingAircrafts.Any(a => a == aircraftName)) { matchedProfile.BindingAircrafts.Add(aircraftName); + hasChanges = true; + } + + if (matchedProfile != null) + { matchedProfile.BindingAircraftLiveries.Remove(liveryName); + hasChanges = true; + } + + if (hasChanges) + { WriteProfiles(); RefreshProfile(); } diff --git a/SimconnectAgent/SimConnectProvider.cs b/SimconnectAgent/SimConnectProvider.cs index ab61549..bb5d776 100644 --- a/SimconnectAgent/SimConnectProvider.cs +++ b/SimconnectAgent/SimConnectProvider.cs @@ -22,6 +22,7 @@ namespace MSFSPopoutPanelManager.SimConnectAgent public event EventHandler OnConnected; public event EventHandler OnDisconnected; + public event EventHandler OnIsInCockpitChanged; public event EventHandler OnFlightStarted; public event EventHandler OnFlightStopped; public event EventHandler> OnSimConnectDataRefreshed; @@ -227,7 +228,6 @@ namespace MSFSPopoutPanelManager.SimConnectAgent DetectFlightStartedOrStopped(); } - private const int CAMERA_STATE_INIT = 0; private const int CAMERA_STATE_COCKPIT = 2; private const int CAMERA_STATE_LOAD_SCREEN = 11; private const int CAMERA_STATE_HOME_SCREEN = 15; @@ -241,9 +241,11 @@ namespace MSFSPopoutPanelManager.SimConnectAgent if (_currentCameraState == cameraState) return; + if (cameraState == CAMERA_STATE_COCKPIT) + OnIsInCockpitChanged?.Invoke(this, true); + switch (_currentCameraState) { - case CAMERA_STATE_INIT: case CAMERA_STATE_HOME_SCREEN: case CAMERA_STATE_LOAD_SCREEN: if (cameraState == CAMERA_STATE_COCKPIT) @@ -254,16 +256,17 @@ namespace MSFSPopoutPanelManager.SimConnectAgent break; case CAMERA_STATE_COCKPIT: - if ((cameraState == CAMERA_STATE_LOAD_SCREEN || cameraState == CAMERA_STATE_HOME_SCREEN)) + if (cameraState == CAMERA_STATE_LOAD_SCREEN || cameraState == CAMERA_STATE_HOME_SCREEN) { _currentCameraState = cameraState; OnFlightStopped?.Invoke(this, null); + OnIsInCockpitChanged?.Invoke(this, false); } break; } - if (cameraState == CAMERA_STATE_INIT || cameraState == CAMERA_STATE_COCKPIT || cameraState == CAMERA_STATE_HOME_SCREEN || cameraState == CAMERA_STATE_LOAD_SCREEN) + if (cameraState == CAMERA_STATE_COCKPIT || cameraState == CAMERA_STATE_HOME_SCREEN || cameraState == CAMERA_STATE_LOAD_SCREEN) _currentCameraState = cameraState; } diff --git a/VERSION.md b/VERSION.md index fd7752d..96eafe3 100644 --- a/VERSION.md +++ b/VERSION.md @@ -12,7 +12,9 @@ * Added work around for SU10 Beta issue when after panel separations, panels' size become so big and they block most of the game window for lower resolution screen and prevented Pop Out Panel Manager from popping out the next panel. -* Made improvement to how panels are separated when using multiple monitors. +* Made improvements to how panels are separated during pop out process. + +* Fixed an issue when adjusting position and size of a pop out, it may not work correctly on some PC configuration. Known issue: diff --git a/WpfApp/ViewModel/PanelSelectionViewModel.cs b/WpfApp/ViewModel/PanelSelectionViewModel.cs index bfa9325..be2c1a8 100644 --- a/WpfApp/ViewModel/PanelSelectionViewModel.cs +++ b/WpfApp/ViewModel/PanelSelectionViewModel.cs @@ -45,33 +45,33 @@ namespace MSFSPopoutPanelManager.WpfApp.ViewModel .ObservesProperty(() => ProfileData.ActiveProfile) .ObservesProperty(() => FlightSimData.IsSimulatorStarted); - StartPanelSelectionCommand = new DelegateCommand(OnStartPanelSelection, () => FlightSimData.HasCurrentMsfsAircraft && ProfileData.HasActiveProfile && ProfileData.ActiveProfile != null && FlightSimData.IsSimulatorStarted && FlightSimData.IsEnteredFlight) + StartPanelSelectionCommand = new DelegateCommand(OnStartPanelSelection, () => FlightSimData.HasCurrentMsfsAircraft && ProfileData.HasActiveProfile && ProfileData.ActiveProfile != null && FlightSimData.IsSimulatorStarted && FlightSimData.IsInCockpit) .ObservesProperty(() => FlightSimData.HasCurrentMsfsAircraft) .ObservesProperty(() => ProfileData.ActiveProfile) .ObservesProperty(() => FlightSimData.IsSimulatorStarted) - .ObservesProperty(() => FlightSimData.IsEnteredFlight); + .ObservesProperty(() => FlightSimData.IsInCockpit); - StartPopOutCommand = new DelegateCommand(OnStartPopOut, () => FlightSimData.HasCurrentMsfsAircraft && ProfileData.HasActiveProfile && (ProfileData.ActiveProfile.PanelSourceCoordinates.Count > 0 || ProfileData.ActiveProfile.TouchPanelBindings.Count > 0) && FlightSimData.IsSimulatorStarted && FlightSimData.IsEnteredFlight) + StartPopOutCommand = new DelegateCommand(OnStartPopOut, () => FlightSimData.HasCurrentMsfsAircraft && ProfileData.HasActiveProfile && (ProfileData.ActiveProfile.PanelSourceCoordinates.Count > 0 || ProfileData.ActiveProfile.TouchPanelBindings.Count > 0) && FlightSimData.IsSimulatorStarted && FlightSimData.IsInCockpit) .ObservesProperty(() => FlightSimData.HasCurrentMsfsAircraft) .ObservesProperty(() => ProfileData.ActiveProfile) .ObservesProperty(() => ProfileData.ActiveProfile.PanelSourceCoordinates.Count) .ObservesProperty(() => ProfileData.ActiveProfile.TouchPanelBindings.Count) .ObservesProperty(() => FlightSimData.IsSimulatorStarted) - .ObservesProperty(() => FlightSimData.IsEnteredFlight); + .ObservesProperty(() => FlightSimData.IsInCockpit); - SaveAutoPanningCameraCommand = new DelegateCommand(OnSaveAutoPanningCamera, () => FlightSimData.HasCurrentMsfsAircraft && ProfileData.HasActiveProfile && ProfileData.ActiveProfile.PanelSourceCoordinates.Count > 0 && FlightSimData.IsSimulatorStarted && FlightSimData.IsEnteredFlight) + SaveAutoPanningCameraCommand = new DelegateCommand(OnSaveAutoPanningCamera, () => FlightSimData.HasCurrentMsfsAircraft && ProfileData.HasActiveProfile && ProfileData.ActiveProfile.PanelSourceCoordinates.Count > 0 && FlightSimData.IsSimulatorStarted && FlightSimData.IsInCockpit) .ObservesProperty(() => FlightSimData.HasCurrentMsfsAircraft) .ObservesProperty(() => ProfileData.ActiveProfile) .ObservesProperty(() => ProfileData.ActiveProfile.PanelSourceCoordinates.Count) .ObservesProperty(() => FlightSimData.IsSimulatorStarted) - .ObservesProperty(() => FlightSimData.IsEnteredFlight); + .ObservesProperty(() => FlightSimData.IsInCockpit); - EditPanelSourceCommand = new DelegateCommand(EditPanelSource, () => FlightSimData.HasCurrentMsfsAircraft && ProfileData.HasActiveProfile && ProfileData.ActiveProfile.PanelSourceCoordinates.Count > 0 && FlightSimData.IsSimulatorStarted && FlightSimData.IsEnteredFlight) + EditPanelSourceCommand = new DelegateCommand(EditPanelSource, () => FlightSimData.HasCurrentMsfsAircraft && ProfileData.HasActiveProfile && ProfileData.ActiveProfile.PanelSourceCoordinates.Count > 0 && FlightSimData.IsSimulatorStarted && FlightSimData.IsInCockpit) .ObservesProperty(() => FlightSimData.HasCurrentMsfsAircraft) .ObservesProperty(() => ProfileData.ActiveProfile) .ObservesProperty(() => ProfileData.ActiveProfile.PanelSourceCoordinates.Count) .ObservesProperty(() => FlightSimData.IsSimulatorStarted) - .ObservesProperty(() => FlightSimData.IsEnteredFlight); + .ObservesProperty(() => FlightSimData.IsInCockpit); OpenTouchPanelBindingCommand = new DelegateCommand(OnOpenTouchPanelBinding, () => FlightSimData.HasCurrentMsfsAircraft && FlightSimData.IsSimulatorStarted && ProfileData.HasActiveProfile && AppSettingData.AppSetting.TouchPanelSettings.EnableTouchPanelIntegration) .ObservesProperty(() => FlightSimData.HasCurrentMsfsAircraft) diff --git a/latestreleasenotes.txt b/latestreleasenotes.txt index 7829931..3ec5459 100644 --- a/latestreleasenotes.txt +++ b/latestreleasenotes.txt @@ -26,7 +26,10 @@ how to use these new keyboard shortcuts. so big and they block most of the game window for lower resolution screen and prevented Pop Out Panel Manager from popping out the next panel. -* Made improvement to how panels are separated when using multiple monitors. +* Made improvements to how panels are separated during pop out process. + +* Fixed an issue when adjusting position and size of a pop out, it may not work correctly +on some PC configuration. Known issue: