From e42bfe670d65f4a703025d1f7bfffca1cd5f5fa3 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Wed, 18 Mar 2020 21:39:07 -0500 Subject: [PATCH] More actively refresh cached profile properties --- DS4Windows/DS4Control/ScpUtil.cs | 7 ++++++ DS4Windows/DS4Forms/ProfileEditor.xaml.cs | 22 ++++++++++++------- .../ViewModels/SpecialActionsListViewModel.cs | 8 ++----- DS4Windows/ProfileEntity.cs | 4 +--- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/DS4Windows/DS4Control/ScpUtil.cs b/DS4Windows/DS4Control/ScpUtil.cs index 73baa4b..e8d3bd4 100644 --- a/DS4Windows/DS4Control/ScpUtil.cs +++ b/DS4Windows/DS4Control/ScpUtil.cs @@ -1694,6 +1694,13 @@ namespace DS4Windows m_Config.containsCustomExtras[device] = HasCustomExtras(device); } + public static void CacheExtraProfileInfo(int device) + { + calculateProfileActionCount(device); + calculateProfileActionDicts(device); + cacheProfileCustomsFlags(device); + } + public static X360Controls getX360ControlsByName(string key) { return m_Config.getX360ControlsByName(key); diff --git a/DS4Windows/DS4Forms/ProfileEditor.xaml.cs b/DS4Windows/DS4Forms/ProfileEditor.xaml.cs index 55b1af4..9df5ebf 100644 --- a/DS4Windows/DS4Forms/ProfileEditor.xaml.cs +++ b/DS4Windows/DS4Forms/ProfileEditor.xaml.cs @@ -583,8 +583,8 @@ namespace DS4WinWPF.DS4Forms { App.rootHub.setRumble(0, 0, profileSettingsVM.FuncDevNum); } - DS4Windows.Global.outDevTypeTemp[deviceNum] = DS4Windows.OutContType.X360; - DS4Windows.Global.LoadProfile(deviceNum, false, App.rootHub); + Global.outDevTypeTemp[deviceNum] = OutContType.X360; + Global.LoadProfile(deviceNum, false, App.rootHub); Closed?.Invoke(this, EventArgs.Empty); } @@ -596,6 +596,7 @@ namespace DS4WinWPF.DS4Forms window.ShowDialog(); mpControl.UpdateMappingName(); UpdateHighlightLabel(mpControl); + Global.CacheExtraProfileInfo(profileSettingsVM.Device); } private void InputControlHighlight(Button control) @@ -704,9 +705,9 @@ namespace DS4WinWPF.DS4Forms private void SetLateProperties() { - DS4Windows.Global.BTPollRate[deviceNum] = profileSettingsVM.TempBTPollRateIndex; - DS4Windows.Global.OutContType[deviceNum] = profileSettingsVM.TempConType; - DS4Windows.Global.outDevTypeTemp[deviceNum] = DS4Windows.OutContType.X360; + Global.BTPollRate[deviceNum] = profileSettingsVM.TempBTPollRateIndex; + Global.OutContType[deviceNum] = profileSettingsVM.TempConType; + Global.outDevTypeTemp[deviceNum] = OutContType.X360; } private void SaveBtn_Click(object sender, RoutedEventArgs e) @@ -746,9 +747,6 @@ namespace DS4WinWPF.DS4Forms if (!File.Exists(tempprof)) { Global.SaveProfile(deviceNum, temp); - Global.calculateProfileActionCount(deviceNum); - Global.calculateProfileActionDicts(deviceNum); - Global.cacheProfileCustomsFlags(deviceNum); CreatedProfile?.Invoke(this, temp); Closed?.Invoke(this, EventArgs.Empty); } @@ -1075,6 +1073,7 @@ namespace DS4WinWPF.DS4Forms baseSpeActPanel.Visibility = Visibility.Visible; specialActionsVM.ExportEnabledActions(); + Global.CacheExtraProfileInfo(profileSettingsVM.Device); }; } @@ -1103,6 +1102,7 @@ namespace DS4WinWPF.DS4Forms specialActionsVM.ActionCol.Insert(currentIndex, newitem); specialActionDockPanel.Children.Remove(actEditor); baseSpeActPanel.Visibility = Visibility.Visible; + Global.CacheExtraProfileInfo(profileSettingsVM.Device); }; } } @@ -1113,6 +1113,7 @@ namespace DS4WinWPF.DS4Forms { SpecialActionItem item = specialActionsVM.ActionCol[specialActionsVM.SpecialActionIndex]; specialActionsVM.RemoveAction(item); + Global.CacheExtraProfileInfo(profileSettingsVM.Device); } } @@ -1217,6 +1218,7 @@ namespace DS4WinWPF.DS4Forms profileSettingsVM.UseControllerReadout = false; inputTimer.Stop(); conReadingsUserCon.EnableControl(false); + Global.CacheExtraProfileInfo(profileSettingsVM.Device); } private void UseControllerReadoutCk_Click(object sender, RoutedEventArgs e) @@ -1239,6 +1241,7 @@ namespace DS4WinWPF.DS4Forms window.ShowDialog(); mpControl.UpdateMappingName(); UpdateHighlightLabel(mpControl); + Global.CacheExtraProfileInfo(profileSettingsVM.Device); } private void MappingListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e) @@ -1273,6 +1276,7 @@ namespace DS4WinWPF.DS4Forms window.ShowDialog(); mpControl.UpdateMappingName(); UpdateHighlightLabel(mpControl); + Global.CacheExtraProfileInfo(profileSettingsVM.Device); } private void SwipeControlsButton_Click(object sender, RoutedEventArgs e) @@ -1285,6 +1289,7 @@ namespace DS4WinWPF.DS4Forms window.ShowDialog(); mpControl.UpdateMappingName(); UpdateHighlightLabel(mpControl); + Global.CacheExtraProfileInfo(profileSettingsVM.Device); } private void ConBtn_MouseRightButtonUp(object sender, MouseButtonEventArgs e) @@ -1314,6 +1319,7 @@ namespace DS4WinWPF.DS4Forms mpControl.UpdateMappingName(); } + Global.CacheExtraProfileInfo(profileSettingsVM.Device); highlightControlDisplayLb.Content = ""; } } diff --git a/DS4Windows/DS4Forms/ViewModels/SpecialActionsListViewModel.cs b/DS4Windows/DS4Forms/ViewModels/SpecialActionsListViewModel.cs index ffbe51e..9f88a56 100644 --- a/DS4Windows/DS4Forms/ViewModels/SpecialActionsListViewModel.cs +++ b/DS4Windows/DS4Forms/ViewModels/SpecialActionsListViewModel.cs @@ -121,9 +121,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels } Global.ProfileActions[deviceNum] = pactions; - Global.calculateProfileActionCount(deviceNum); - Global.calculateProfileActionDicts(deviceNum); - Global.cacheProfileCustomsFlags(deviceNum); + Global.CacheExtraProfileInfo(deviceNum); } public void RemoveAction(SpecialActionItem item) @@ -131,9 +129,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels Global.RemoveAction(item.SpecialAction.name); actionCol.RemoveAt(specialActionIndex); Global.ProfileActions[deviceNum].Remove(item.SpecialAction.name); - Global.calculateProfileActionCount(deviceNum); - Global.calculateProfileActionDicts(deviceNum); - Global.cacheProfileCustomsFlags(deviceNum); + Global.CacheExtraProfileInfo(deviceNum); } } diff --git a/DS4Windows/ProfileEntity.cs b/DS4Windows/ProfileEntity.cs index f9421d0..0d05632 100644 --- a/DS4Windows/ProfileEntity.cs +++ b/DS4Windows/ProfileEntity.cs @@ -43,9 +43,7 @@ namespace DS4WinWPF if (!string.IsNullOrWhiteSpace(name)) { DS4Windows.Global.SaveProfile(deviceNum, name); - DS4Windows.Global.calculateProfileActionCount(deviceNum); - DS4Windows.Global.calculateProfileActionDicts(deviceNum); - DS4Windows.Global.cacheProfileCustomsFlags(deviceNum); + DS4Windows.Global.CacheExtraProfileInfo(deviceNum); } }