diff --git a/Gum/Gum.csproj b/Gum/Gum.csproj
index 85c2a875..cf773d4c 100644
--- a/Gum/Gum.csproj
+++ b/Gum/Gum.csproj
@@ -250,6 +250,7 @@
RecentFileItem.xaml
+
diff --git a/Gum/Managers/ProjectManager.cs b/Gum/Managers/ProjectManager.cs
index 996e2498..4c11b239 100644
--- a/Gum/Managers/ProjectManager.cs
+++ b/Gum/Managers/ProjectManager.cs
@@ -591,12 +591,6 @@ private void FillWithNecessaryInstances(ComponentSave component, List first.Name.CompareTo(second.Name));
- }
- }
- foreach (var elementSave in GumProjectSave.Components)
- {
- foreach (var stateSave in elementSave.AllStates)
- {
- stateSave.Variables.Sort((first, second) => first.Name.CompareTo(second.Name));
- }
- }
- foreach (var elementSave in GumProjectSave.StandardElements)
- {
- foreach (var stateSave in elementSave.AllStates)
- {
- stateSave.Variables.Sort((first, second) => first.Name.CompareTo(second.Name));
- }
- }
- foreach (var behavior in GumProjectSave.Behaviors)
- {
- foreach (var stateSave in behavior.AllStates)
- {
- stateSave.Variables.Sort((first, second) => first.Name.CompareTo(second.Name));
- }
- }
+ SortVariables();
bool saveContainedElements = isNewProject || forceSaveContainedElements;
@@ -668,25 +635,6 @@ internal void SaveProject(bool forceSaveContainedElements = false)
FileWatchLogic.Self.IgnoreNextChangeOn(GumProjectSave.FullFileName);
GumCommands.Self.TryMultipleTimes(() => GumProjectSave.Save(GumProjectSave.FullFileName, saveContainedElements));
-
- if (isNewProject)
- {
-
- var sourceFile = Path.Combine(GetExecutingDirectory(), "Content\\ExampleSpriteFrame.png");
- var destinationFile = FileManager.GetDirectory(GumProjectSave.FullFileName) + "ExampleSpriteFrame.png";
- try
- {
- System.IO.File.Copy(sourceFile, destinationFile);
-
- var nineSliceStandard = GumProjectSave.StandardElements.Find(item => item.Name == "NineSlice");
- nineSliceStandard.DefaultState.SetValue("SourceFile", "ExampleSpriteFrame.png", "string");
- }
- catch (Exception e)
- {
- GumCommands.Self.GuiCommands.PrintOutput($"Error copying ExampleSpriteFrame.png: {e}");
- }
- }
-
succeeded = true;
if (succeeded && saveContainedElements)
@@ -735,6 +683,38 @@ internal void SaveProject(bool forceSaveContainedElements = false)
}
}
+ private void SortVariables()
+ {
+ foreach (var elementSave in GumProjectSave.Screens)
+ {
+ foreach (var stateSave in elementSave.AllStates)
+ {
+ stateSave.Variables.Sort((first, second) => first.Name.CompareTo(second.Name));
+ }
+ }
+ foreach (var elementSave in GumProjectSave.Components)
+ {
+ foreach (var stateSave in elementSave.AllStates)
+ {
+ stateSave.Variables.Sort((first, second) => first.Name.CompareTo(second.Name));
+ }
+ }
+ foreach (var elementSave in GumProjectSave.StandardElements)
+ {
+ foreach (var stateSave in elementSave.AllStates)
+ {
+ stateSave.Variables.Sort((first, second) => first.Name.CompareTo(second.Name));
+ }
+ }
+ foreach (var behavior in GumProjectSave.Behaviors)
+ {
+ foreach (var stateSave in behavior.AllStates)
+ {
+ stateSave.Variables.Sort((first, second) => first.Name.CompareTo(second.Name));
+ }
+ }
+ }
+
private static string TryGetFileNameFromException(UnauthorizedAccessException exception)
{
string message = exception.Message;
diff --git a/Gum/Plugins/InternalPlugins/NineSlicePlugin/MainNineSlicePlugin.cs b/Gum/Plugins/InternalPlugins/NineSlicePlugin/MainNineSlicePlugin.cs
new file mode 100644
index 00000000..f4650ba6
--- /dev/null
+++ b/Gum/Plugins/InternalPlugins/NineSlicePlugin/MainNineSlicePlugin.cs
@@ -0,0 +1,56 @@
+using Gum.DataTypes;
+using Gum.Managers;
+using Gum.Plugins.BaseClasses;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using ToolsUtilities;
+
+namespace Gum.Plugins.InternalPlugins.NineSlicePlugin;
+
+[Export(typeof(PluginBase))]
+internal class MainNineSlicePlugin : InternalPlugin
+{
+ public override void StartUp()
+ {
+ AssignEvents();
+ }
+
+ private void AssignEvents()
+ {
+ this.ProjectLocationSet += HandleProjectLocationSet;
+ }
+
+ private void HandleProjectLocationSet(FilePath path)
+ {
+ var gumProject = ObjectFinder.Self.GumProjectSave;
+
+ var sourceFile = Path.Combine(GetExecutingDirectory(), "Content\\ExampleSpriteFrame.png");
+ var destinationFile = FileManager.GetDirectory(gumProject.FullFileName) + "ExampleSpriteFrame.png";
+ try
+ {
+ System.IO.File.Copy(sourceFile, destinationFile);
+
+ var nineSliceStandard = gumProject.StandardElements.Find(item => item.Name == "NineSlice");
+ nineSliceStandard.DefaultState.SetValue("SourceFile", "ExampleSpriteFrame.png", "string");
+
+ GumCommands.Self.FileCommands.TryAutoSaveElement(nineSliceStandard);
+ }
+ catch (Exception e)
+ {
+ GumCommands.Self.GuiCommands.PrintOutput($"Error copying ExampleSpriteFrame.png: {e}");
+ }
+ }
+
+ static string GetExecutingDirectory()
+ {
+ string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+ return path;
+ }
+
+}