diff --git a/FRBDK/Glue/Glue/Plugins/ExportedImplementations/CommandInterfaces/GluxCommands.cs b/FRBDK/Glue/Glue/Plugins/ExportedImplementations/CommandInterfaces/GluxCommands.cs index c0a99f03d..58f521abf 100644 --- a/FRBDK/Glue/Glue/Plugins/ExportedImplementations/CommandInterfaces/GluxCommands.cs +++ b/FRBDK/Glue/Glue/Plugins/ExportedImplementations/CommandInterfaces/GluxCommands.cs @@ -43,6 +43,7 @@ using FlatRedBall.Glue.AutomatedGlue; using static FlatRedBall.Debugging.Debugger; using FlatRedBall.Glue.Plugins.EmbeddedPlugins.FactoryPlugin; +using WpfDataUi.DataTypes; namespace FlatRedBall.Glue.Plugins.ExportedImplementations.CommandInterfaces; @@ -2393,9 +2394,9 @@ await SetVariableOnInner(assignment.NamedObjectSave, assignment.VariableName, as [Obsolete("Use SetVariableOnAsync")] public async void SetVariableOn(NamedObjectSave nos, string memberName, object value, bool performSaveAndGenerateCode = true, - bool updateUi = true, bool recordUndo = true) + bool updateUi = true, bool recordUndo = true, SetPropertyCommitType commitType = SetPropertyCommitType.Full) { - await SetVariableOnInner(nos, memberName, value, performSaveAndGenerateCode, updateUi, notifyPlugins: true, recordUndo:recordUndo); + await SetVariableOnInner(nos, memberName, value, performSaveAndGenerateCode, updateUi, notifyPlugins: true, recordUndo:recordUndo, commitType); } @@ -2408,7 +2409,7 @@ await TaskManager.Self.AddAsync( } private async Task SetVariableOnInner(NamedObjectSave nos, string memberName, object value, bool performSaveAndGenerateCode = true, - bool updateUi = true, bool notifyPlugins = true, bool recordUndo = true) + bool updateUi = true, bool notifyPlugins = true, bool recordUndo = true, SetPropertyCommitType commitType = SetPropertyCommitType.Full) { // XML serialization doesn't like enums var needsEnum = GlueState.Self.CurrentGlueProject.FileVersion < (int)GlueProjectSave.GluxVersions.GlueSavedToJson; @@ -2509,7 +2510,8 @@ await EditorObjects.IoC.Container.Get().ReactToName { NamedObjectSave = nos, ChangedPropertyName = memberName, - OldValue = oldValue + OldValue = oldValue, + CommitType = commitType }; PluginManager.ReactToChangedProperty(memberName, oldValue, nosContainer, variableChange); @@ -2520,7 +2522,8 @@ await EditorObjects.IoC.Container.Get().ReactToName NamedObject = nos, ChangedMember = memberName, OldValue = oldValue, - RecordUndo = recordUndo + RecordUndo = recordUndo, + CommitType = commitType } }); } diff --git a/FRBDK/Glue/Glue/Plugins/ExportedInterfaces/CommandInterfaces/IGluxCommands.cs b/FRBDK/Glue/Glue/Plugins/ExportedInterfaces/CommandInterfaces/IGluxCommands.cs index f38b2471c..6fcac7b08 100644 --- a/FRBDK/Glue/Glue/Plugins/ExportedInterfaces/CommandInterfaces/IGluxCommands.cs +++ b/FRBDK/Glue/Glue/Plugins/ExportedInterfaces/CommandInterfaces/IGluxCommands.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using FlatRedBall.Glue.Managers; using FlatRedBall.Glue.FormHelpers; +using WpfDataUi.DataTypes; namespace FlatRedBall.Glue.Plugins.ExportedInterfaces.CommandInterfaces { @@ -195,7 +196,7 @@ Task AddNamedObjectToAsync(NamedObjectSave newNos, GlueElement element, NamedObj /// The value of the variable. [Obsolete("Use SetVariableOnAsync")] void SetVariableOn(NamedObjectSave nos, string memberName, object value, bool performSaveAndGenerateCode = true, - bool updateUi = true, bool recordUndo = true); + bool updateUi = true, bool recordUndo = true, SetPropertyCommitType commitType = SetPropertyCommitType.Full); Task SetVariableOnAsync(NamedObjectSave nos, string memberName, object value, bool performSaveAndGenerateCode = true, bool updateUi = true, bool recordUndo = true); diff --git a/FRBDK/Glue/Glue/Plugins/PluginBase.cs b/FRBDK/Glue/Glue/Plugins/PluginBase.cs index b85d8fde2..a86423428 100644 --- a/FRBDK/Glue/Glue/Plugins/PluginBase.cs +++ b/FRBDK/Glue/Glue/Plugins/PluginBase.cs @@ -33,6 +33,7 @@ using Newtonsoft.Json.Linq; using System.Windows; using System.Windows.Media; +using WpfDataUi.DataTypes; namespace FlatRedBall.Glue.Plugins { @@ -188,7 +189,7 @@ public class VariableChangeArguments public object OldValue { get; set; } public NamedObjectSave NamedObject { get; set; } public bool RecordUndo { get; set; } = true; - + public SetPropertyCommitType CommitType { get; set; } = SetPropertyCommitType.Full; public override string ToString() { return $"{NamedObject}.{ChangedMember}"; diff --git a/FRBDK/Glue/Glue/Plugins/PluginManager.cs b/FRBDK/Glue/Glue/Plugins/PluginManager.cs index 7e2493774..3e00b9b0d 100644 --- a/FRBDK/Glue/Glue/Plugins/PluginManager.cs +++ b/FRBDK/Glue/Glue/Plugins/PluginManager.cs @@ -43,6 +43,7 @@ using System.Threading.Tasks; using FlatRedBall.Glue.Managers; using FlatRedBall.Glue.Plugins.ExportedInterfaces.CommandInterfaces; +using WpfDataUi.DataTypes; //using Gum.Wireframe; //using Gum.Converters; @@ -1615,6 +1616,7 @@ public class NamedObjectSavePropertyChange public NamedObjectSave NamedObjectSave { get; set; } public string ChangedPropertyName { get; set; } public object OldValue { get; set; } + public SetPropertyCommitType CommitType { get; set; } = SetPropertyCommitType.Full; public bool RecordUndo { get; set; } diff --git a/FRBDK/Glue/OfficialPlugins/CustomVariablePlugin/PreferredDisplayerManager.cs b/FRBDK/Glue/OfficialPlugins/CustomVariablePlugin/PreferredDisplayerManager.cs index 596b9cef5..98149465f 100644 --- a/FRBDK/Glue/OfficialPlugins/CustomVariablePlugin/PreferredDisplayerManager.cs +++ b/FRBDK/Glue/OfficialPlugins/CustomVariablePlugin/PreferredDisplayerManager.cs @@ -40,8 +40,9 @@ public static void AddDisplayerUi(DataUiGrid grid, CustomVariable variable) }; - member.CustomSetEvent += (instance, value) => + member.CustomSetPropertyEvent += (instance, args) => { + var value = args.Value; var variableDefinition = instance as VariableDefinition; if (value is Type type) { @@ -109,8 +110,9 @@ void Add(string propertyName) var member = new InstanceMember(); member.Name = propertyName; member.CustomGetTypeEvent += (_) => typeof(T); - member.CustomSetEvent += (_, newValue) => + member.CustomSetPropertyEvent += (_, args) => { + var newValue = args.Value; variable.VariableDefinition.PropertiesToSetOnDisplayer[propertyName] = newValue; }; member.CustomGetEvent += (_) => diff --git a/FRBDK/Glue/OfficialPlugins/ErrorReportingPlugin/MainErrorReportingPlugin.cs b/FRBDK/Glue/OfficialPlugins/ErrorReportingPlugin/MainErrorReportingPlugin.cs index ab7616784..50c4d2738 100644 --- a/FRBDK/Glue/OfficialPlugins/ErrorReportingPlugin/MainErrorReportingPlugin.cs +++ b/FRBDK/Glue/OfficialPlugins/ErrorReportingPlugin/MainErrorReportingPlugin.cs @@ -37,8 +37,11 @@ public override void StartUp() private async void HandleChangedNamedObjectPropertyList(List obj) { - await GlueCommands.Self.RefreshCommands.ClearFixedErrors(); - this.RefreshErrors(); + if(obj.Count > 0 && obj[0].CommitType == WpfDataUi.DataTypes.SetPropertyCommitType.Full) + { + await GlueCommands.Self.RefreshCommands.ClearFixedErrors(); + this.RefreshErrors(); + } } //private async void HandleNamedObjectChangedValue(string changedMember, object oldValue, NamedObjectSave namedObject) diff --git a/FRBDK/Glue/OfficialPlugins/PropertyGrid/ElementVariableShowingLogic.cs b/FRBDK/Glue/OfficialPlugins/PropertyGrid/ElementVariableShowingLogic.cs index 1c91ccb69..b08db01f5 100644 --- a/FRBDK/Glue/OfficialPlugins/PropertyGrid/ElementVariableShowingLogic.cs +++ b/FRBDK/Glue/OfficialPlugins/PropertyGrid/ElementVariableShowingLogic.cs @@ -117,8 +117,9 @@ private static DataGridItem CreateInstanceMemberForVariable(GlueElement element, instanceMember.UiCreated += (view) => variableDefinition.UiCreated(view); } - instanceMember.CustomSetEvent += async (intance, value) => + instanceMember.CustomSetPropertyEvent += async (intance, args) => { + var value = args.Value; instanceMember.IsDefault = false; //RefreshLogic.IgnoreNextRefresh(); @@ -329,8 +330,9 @@ private static void CreateInstanceMembersForVariables(GlueElement element, List< //TypeConverter converter = variable.GetTypeConverter(element); //instanceMember.TypeConverter = converter; - instanceMember.CustomSetEvent += (intance, value) => + instanceMember.CustomSetPropertyEvent += (intance, args) => { + var value = args.Value; instanceMember.IsDefault = false; RefreshLogic.IgnoreNextRefresh(); diff --git a/FRBDK/Glue/OfficialPlugins/PropertyGrid/NamedObjectSaveVariableDataGridItem.cs b/FRBDK/Glue/OfficialPlugins/PropertyGrid/NamedObjectSaveVariableDataGridItem.cs index 60cf83cf0..9d7545379 100644 --- a/FRBDK/Glue/OfficialPlugins/PropertyGrid/NamedObjectSaveVariableDataGridItem.cs +++ b/FRBDK/Glue/OfficialPlugins/PropertyGrid/NamedObjectSaveVariableDataGridItem.cs @@ -88,7 +88,8 @@ public NamedObjectSaveVariableDataGridItem() { CustomGetEvent += HandleCustomGet; - CustomSetEvent += HandleVariableSet; + //CustomSetEvent += HandleVariableSet; + CustomSetPropertyEvent += HandleVariableSet; SetValueError += (newValue) => { @@ -252,10 +253,11 @@ public object HandleCustomGet(object throwaway) } } - private async void HandleVariableSet(object owner, object value) + private async void HandleVariableSet(object owner, SetPropertyArgs args) { if (GlueState.Self.CurrentGlueProject == null) return; + var value = args.Value; //NamedObjectVariableChangeLogic.ReactToValueSet(instance, memberName, value, out bool makeDefault); //static void ReactToValueSet(NamedObjectSave instance, string memberName, object value, out bool makeDefault) @@ -319,46 +321,52 @@ private async void HandleVariableSet(object owner, object value) GlueCommands.Self.GluxCommands.SetVariableOn( NamedObjectSave, NameOnInstance, - value, performSaveAndGenerateCode: false, updateUi: false); + value, performSaveAndGenerateCode: false, updateUi: false, commitType: args.CommitType); #pragma warning restore CS0618 // Type or member is obsolete - // We're going to delay updating all UI, saving, and codegen for a half second to not spam the system: - await System.Threading.Tasks.Task.Delay(400); - // Set subtext before refreshing property grid - NamedObjectVariableShowingLogic.AssignVariableSubtext(NamedObjectSave, categories.ToList(), NamedObjectSave.GetAssetTypeInfo()); + // If it's an intermediate set, no need to generate, refresh UI, or save: + if(args.CommitType == SetPropertyCommitType.Full) + { - IsDefault = makeDefault; + // We're going to delay updating all UI, saving, and codegen for a half second to not spam the system: + await System.Threading.Tasks.Task.Delay(400); - await TaskManager.Self.AddAsync(async () => - { - GlueCommands.Self.GenerateCodeCommands.GenerateElementCode(Container); - EditorObjects.IoC.Container.Get().ClearFixedErrors(); + // Set subtext before refreshing property grid + NamedObjectVariableShowingLogic.AssignVariableSubtext(NamedObjectSave, categories.ToList(), NamedObjectSave.GetAssetTypeInfo()); + + IsDefault = makeDefault; - GlueCommands.Self.DoOnUiThread(() => + await TaskManager.Self.AddAsync(async () => { - MainGlueWindow.Self.PropertyGrid.Refresh(); - PropertyGridHelper.UpdateNamedObjectDisplay(); - if (DisplayName == "Name") + GlueCommands.Self.GenerateCodeCommands.GenerateElementCode(Container); + EditorObjects.IoC.Container.Get().ClearFixedErrors(); + + GlueCommands.Self.DoOnUiThread(() => + { + MainGlueWindow.Self.PropertyGrid.Refresh(); + PropertyGridHelper.UpdateNamedObjectDisplay(); + if (DisplayName == "Name") + { + GlueCommands.Self.RefreshCommands.RefreshTreeNodeFor(Container, + // We can be faster by doing only a NamedObject refresh, since the only way this could change is the Name...right? + FlatRedBall.Glue.Plugins.ExportedInterfaces.CommandInterfaces.TreeNodeRefreshType.NamedObjects); + } + }); + + if (GlueState.Self.CurrentGlueProject.FileVersion >= (int)GluxVersions.SeparateJsonFilesForElements) { - GlueCommands.Self.RefreshCommands.RefreshTreeNodeFor(Container, - // We can be faster by doing only a NamedObject refresh, since the only way this could change is the Name...right? - FlatRedBall.Glue.Plugins.ExportedInterfaces.CommandInterfaces.TreeNodeRefreshType.NamedObjects); + await GlueCommands.Self.GluxCommands.SaveElementAsync(Container); + } + else + { + GlueCommands.Self.GluxCommands.SaveProjectAndElements(TaskExecutionPreference.AddOrMoveToEnd); } - }); - - if (GlueState.Self.CurrentGlueProject.FileVersion >= (int)GluxVersions.SeparateJsonFilesForElements) - { - await GlueCommands.Self.GluxCommands.SaveElementAsync(Container); - } - else - { - GlueCommands.Self.GluxCommands.SaveProjectAndElements(TaskExecutionPreference.AddOrMoveToEnd); - } - }, $"Delayed task to do all updates for {NamedObjectSave}", TaskExecutionPreference.AddOrMoveToEnd); + }, $"Delayed task to do all updates for {NamedObjectSave}", TaskExecutionPreference.AddOrMoveToEnd); + } } } diff --git a/FRBDK/Glue/OfficialPlugins/PropertyGrid/NamedObjectVariableShowingLogic.cs b/FRBDK/Glue/OfficialPlugins/PropertyGrid/NamedObjectVariableShowingLogic.cs index 0578dbf0a..356ed27d9 100644 --- a/FRBDK/Glue/OfficialPlugins/PropertyGrid/NamedObjectVariableShowingLogic.cs +++ b/FRBDK/Glue/OfficialPlugins/PropertyGrid/NamedObjectVariableShowingLogic.cs @@ -480,8 +480,9 @@ private static InstanceMember CreateInstanceMemberForSourceName(NamedObjectSave return instance.SourceName; }; - instanceMember.CustomSetEvent += (owner, value) => + instanceMember.CustomSetPropertyEvent += (owner, args) => { + var value = args.Value; instanceMember.IsDefault = false; RefreshLogic.IgnoreNextRefresh(); @@ -525,8 +526,9 @@ private static DataGridItem CreateNameInstanceMember(NamedObjectSave instance) instanceMember.MakeReadOnly(); } - instanceMember.CustomSetEvent += (throwaway, value) => + instanceMember.CustomSetPropertyEvent += (throwaway, args) => { + var value = args.Value; instanceMember.IsDefault = false; RefreshLogic.IgnoreNextRefresh(); @@ -564,8 +566,9 @@ private static DataGridItem CreateIsLockedMember(NamedObjectSave instance) var oldValue = instance.IsEditingLocked; - instanceMember.CustomSetEvent += (throwaway, value) => + instanceMember.CustomSetPropertyEvent += (throwaway, args) => { + var value = args.Value; instanceMember.IsDefault = false; RefreshLogic.IgnoreNextRefresh(); diff --git a/FRBDK/Glue/TopDownPlugin/Views/IndividualTopDownValuesView.xaml.cs b/FRBDK/Glue/TopDownPlugin/Views/IndividualTopDownValuesView.xaml.cs index 1eacd67a8..59768972c 100644 --- a/FRBDK/Glue/TopDownPlugin/Views/IndividualTopDownValuesView.xaml.cs +++ b/FRBDK/Glue/TopDownPlugin/Views/IndividualTopDownValuesView.xaml.cs @@ -49,8 +49,9 @@ private void HandleDataContextChanged(object sender, DependencyPropertyChangedEv var instanceMember = new InstanceMember(); instanceMember.Name = kvp.Key; - instanceMember.CustomSetEvent += (owner, value) => + instanceMember.CustomSetPropertyEvent += (owner, args) => { + var value = args.Value; ViewModel.AdditionalProperties[kvp.Key].Value = value; ViewModel.NotifyAdditionalPropertiesChanged();