From be93e16da642b2afac078351b8d8084020da1eb7 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 30 Dec 2019 22:35:31 -0600 Subject: [PATCH] Check for valid trigger names. Check for null value --- .../DS4Forms/SpecialActionEditor.xaml.cs | 22 ++++++++++++++++--- .../SpecialActions/LoadProfileViewModel.cs | 5 +++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Forms/SpecialActionEditor.xaml.cs b/DS4Windows/DS4Forms/SpecialActionEditor.xaml.cs index 2e5d65b..e1112d1 100644 --- a/DS4Windows/DS4Forms/SpecialActionEditor.xaml.cs +++ b/DS4Windows/DS4Forms/SpecialActionEditor.xaml.cs @@ -124,28 +124,44 @@ namespace DS4WinWPF.DS4Forms private void LoadAction(DS4Windows.SpecialAction specialAction) { specialActVM.LoadAction(specialAction); - foreach(string control in specialActVM.ControlTriggerList) + string[] tempTriggers = specialActVM.ControlTriggerList.ToArray(); + foreach (string control in tempTriggers) { - foreach(CheckBox box in triggerBoxes) + bool found = false; + foreach (CheckBox box in triggerBoxes) { if (box.Tag.ToString() == control) { box.IsChecked = true; + found = true; break; } } + + if (!found) + { + specialActVM.ControlTriggerList.Remove(control); + } } - foreach (string control in specialActVM.ControlUnloadTriggerList) + tempTriggers = specialActVM.ControlUnloadTriggerList.ToArray(); + foreach (string control in tempTriggers) { + bool found = false; foreach (CheckBox box in unloadTriggerBoxes) { if (box.Tag.ToString() == control) { box.IsChecked = true; + found = true; break; } } + + if (!found) + { + specialActVM.ControlUnloadTriggerList.Remove(control); + } } switch (specialAction.typeID) diff --git a/DS4Windows/DS4Forms/ViewModels/SpecialActions/LoadProfileViewModel.cs b/DS4Windows/DS4Forms/ViewModels/SpecialActions/LoadProfileViewModel.cs index bb880dc..d378198 100644 --- a/DS4Windows/DS4Forms/ViewModels/SpecialActions/LoadProfileViewModel.cs +++ b/DS4Windows/DS4Forms/ViewModels/SpecialActions/LoadProfileViewModel.cs @@ -63,6 +63,11 @@ namespace DS4WinWPF.DS4Forms.ViewModels.SpecialActions if (profileIndex > 0) { string profilename = profileList.ProfileListCol[profileIndex - 1].Name; + if (action.ucontrols == null) + { + action.ucontrols = string.Empty; + } + Global.SaveAction(action.name, action.controls, 3, profilename, edit, action.ucontrols + (autoUntrigger ? ((action.ucontrols?.Length ?? 0) > 0 ? "/" : "") + "AutomaticUntrigger" : ""));