Browse Source

Merge fixes2

flabbet 1 year ago
parent
commit
72af1f7faa

+ 0 - 37
src/PixiEditor.AvaloniaUI/Helpers/VersionHelpers.cs

@@ -1,37 +0,0 @@
-using System.Reflection;
-using System.Text;
-
-namespace PixiEditor.AvaloniaUI.Helpers;
-
-internal static class VersionHelpers
-{
-    public static Version GetCurrentAssemblyVersion() => Assembly.GetExecutingAssembly().GetName().Version;
-
-    public static string GetCurrentAssemblyVersion(Func<Version, string> toString) => toString(GetCurrentAssemblyVersion());
-
-    public static string GetCurrentAssemblyVersionString(bool moreSpecific = false)
-    {
-        StringBuilder builder = new($"{GetCurrentAssemblyVersion().ToString(2)} Closed Beta");
-
-        // Dev Build removed for closed beta
-#if MSIX_DEBUG
-        builder.Append(" MSIX Debug Build");
-        return builder.ToString();
-#elif DEBUG
-        builder.Append(" Debug Build");
-        return builder.ToString();
-#endif
-
-        if (!moreSpecific)
-            return builder.ToString();
-
-#if STEAM
-        builder.Append(" Steam Build");
-#elif MSIX
-        builder.Append(" MSIX Build");
-#elif RELEASE
-        builder.Append(" Release Build");
-#endif
-        return builder.ToString();
-    }
-}

+ 0 - 279
src/PixiEditor.AvaloniaUI/Models/Preferences/PreferencesSettings.cs

@@ -1,279 +0,0 @@
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using PixiEditor.Extensions.CommonApi.UserPreferences;
-
-namespace PixiEditor.AvaloniaUI.Models.Preferences;
-
-[DebuggerDisplay("{Preferences.Count + LocalPreferences.Count} Preference(s)")]
-internal class PreferencesSettings : IPreferences
-{
-    public bool IsLoaded { get; private set; } = false;
-
-    public string PathToRoamingUserPreferences { get; private set; } = GetPathToSettings(Environment.SpecialFolder.ApplicationData, "user_preferences.json");
-
-    public string PathToLocalPreferences { get; private set; } = GetPathToSettings(Environment.SpecialFolder.LocalApplicationData, "2_0_beta_editor_data.json");
-
-    public Dictionary<string, object> Preferences { get; set; } = new Dictionary<string, object>();
-
-    public Dictionary<string, object> LocalPreferences { get; set; } = new Dictionary<string, object>();
-
-    public void Init()
-    {
-        IPreferences.SetAsCurrent(this);
-        Init(PathToRoamingUserPreferences, PathToLocalPreferences);
-    }
-
-    public void Init(string path, string localPath)
-    {
-        PathToRoamingUserPreferences = path;
-        PathToLocalPreferences = localPath;
-
-        if (IsLoaded == false)
-        {
-            Preferences = InitPath(path);
-            LocalPreferences = InitPath(localPath);
-
-            IsLoaded = true;
-        }
-    }
-
-    public void UpdatePreference<T>(string name, T value)
-    {
-        name = TrimPrefix(name);
-
-        if (IsLoaded == false)
-        {
-            Init();
-        }
-
-        Preferences[name] = value;
-
-        if (Callbacks.TryGetValue(name, out var callback))
-        {
-            foreach (var action in callback)
-            {
-                action.Invoke(name, value);
-            }
-        }
-
-        Save();
-    }
-
-    public void UpdateLocalPreference<T>(string name, T value)
-    {
-        name = TrimPrefix(name);
-
-        if (IsLoaded == false)
-        {
-            Init();
-        }
-
-        LocalPreferences[name] = value;
-
-        if (Callbacks.TryGetValue(name, out var callback))
-        {
-            foreach (var action in callback)
-            {
-                action.Invoke(name, value);
-            }
-        }
-
-        Save();
-    }
-
-    public void Save()
-    {
-        if (IsLoaded == false)
-        {
-            Init();
-        }
-
-        File.WriteAllText(PathToRoamingUserPreferences, JsonConvert.SerializeObject(Preferences));
-        File.WriteAllText(PathToLocalPreferences, JsonConvert.SerializeObject(LocalPreferences));
-    }
-
-    public Dictionary<string, List<Action<string, object>>> Callbacks { get; set; } = new Dictionary<string, List<Action<string, object>>>();
-
-    public void AddCallback(string name, Action<string, object> action)
-    {
-        name = TrimPrefix(name);
-
-        if (action == null)
-        {
-            throw new ArgumentNullException(nameof(action));
-        }
-
-        if (Callbacks.ContainsKey(name))
-        {
-            Callbacks[name].Add(action);
-            return;
-        }
-
-        Callbacks.Add(name, new List<Action<string, object>>() { action });
-    }
-
-    public void AddCallback<T>(string name, Action<string, T> action)
-    {
-        name = TrimPrefix(name);
-
-        if (action == null)
-        {
-            throw new ArgumentNullException(nameof(action));
-        }
-
-        AddCallback(name, new Action<string, object>((n, o) => action(n, (T)o)));
-    }
-
-    public void RemoveCallback(string name, Action<string, object> action)
-    {
-        name = TrimPrefix(name);
-
-        if (action == null)
-        {
-            throw new ArgumentNullException(nameof(action));
-        }
-
-        if (Callbacks.TryGetValue(name, out var callback))
-        {
-            callback.Remove(action);
-        }
-    }
-
-    public void RemoveCallback<T>(string name, Action<string, T> action)
-    {
-        name = TrimPrefix(name);
-
-        if (action == null)
-        {
-            throw new ArgumentNullException(nameof(action));
-        }
-
-        RemoveCallback(name, new Action<string, object>((n, o) => action(n, (T)o)));
-    }
-
-#nullable enable
-
-    public T? GetPreference<T>(string name)
-    {
-        name = TrimPrefix(name);
-
-        return GetPreference(name, default(T));
-    }
-
-    public T? GetPreference<T>(string name, T? fallbackValue)
-    {
-        name = TrimPrefix(name);
-
-        if (IsLoaded == false)
-        {
-            Init();
-        }
-
-        try
-        {
-            return GetValue(Preferences, name, fallbackValue);
-        }
-        catch (InvalidCastException)
-        {
-            Preferences.Remove(name);
-            Save();
-
-            return fallbackValue;
-        }
-    }
-
-    public T? GetLocalPreference<T>(string name)
-    {
-        name = TrimPrefix(name);
-
-        return GetLocalPreference(name, default(T));
-    }
-
-    public T? GetLocalPreference<T>(string name, T? fallbackValue)
-    {
-        name = TrimPrefix(name);
-        
-        if (IsLoaded == false)
-        {
-            Init();
-        }
-
-        try
-        {
-            return GetValue(LocalPreferences, name, fallbackValue);
-        }
-        catch (InvalidCastException)
-        {
-            LocalPreferences.Remove(name);
-            Save();
-
-            return fallbackValue;
-        }
-    }
-
-    private T? GetValue<T>(Dictionary<string, object> dict, string name, T? fallbackValue)
-    {
-        name = TrimPrefix(name);
-        
-        if (!dict.ContainsKey(name)) return fallbackValue;
-        var preference = dict[name];
-        if (typeof(T) == preference.GetType()) return (T)preference;
-
-        if (typeof(T).IsEnum)
-        {
-            return (T)Enum.Parse(typeof(T), preference.ToString());
-        }
-        
-        if (preference.GetType() == typeof(JArray))
-        {
-            return ((JArray)preference).ToObject<T>();
-        }
-
-        return (T)Convert.ChangeType(dict[name], typeof(T));
-    }
-
-#nullable disable
-
-    private static string GetPathToSettings(Environment.SpecialFolder folder, string fileName)
-    {
-        return Path.Join(
-            Environment.GetFolderPath(folder),
-            "PixiEditor",
-            fileName);
-    }
-
-    private static Dictionary<string, object> InitPath(string path)
-    {
-        string dir = Path.GetDirectoryName(path);
-
-        if (!Directory.Exists(dir))
-        {
-            Directory.CreateDirectory(dir);
-        }
-
-        if (!File.Exists(path))
-        {
-            File.WriteAllText(path, "{\n}");
-        }
-        else
-        {
-            string json = File.ReadAllText(path);
-            var dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
-
-            // dictionary is null if the user deletes the content of the preference file.
-            if (dictionary != null)
-            {
-                return dictionary;
-            }
-        }
-
-        return new Dictionary<string, object>();
-    }
-
-    private const string Prefix = "PixiEditor:";
-
-    private string TrimPrefix(string value) => value.StartsWith("PixiEditor:") ? value[Prefix.Length..] : value;
-}

+ 0 - 46
src/PixiEditor.AvaloniaUI/Properties/AssemblyInfo.cs

@@ -1,46 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Windows;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("PixiEditor")]
-[assembly: AssemblyDescription("A fast, nice looking universal graphics editor.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("PixiEditor")]
-[assembly: AssemblyProduct("PixiEditor")]
-[assembly: AssemblyCopyright("Copyright PixiEditor © 2017 - 2024")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components.  If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// In order to begin building localizable applications, set
-// <UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
-// inside a <PropertyGroup>.  For example, if you are using US english
-// in your source files, set the <UICulture> to en-US.  Then uncomment
-// the NeutralResourceLanguage attribute below.  Update the "en-US" in
-// the line below to match the UICulture setting in the project file.
-
-// [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
-
-// ResourceDictionaryLocation.None where theme specific resource dictionaries are located
-// (used if a resource is not found in the page,
-// or application resource dictionaries)
-
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version
-//      Build Number
-//      Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0")]
-[assembly: AssemblyFileVersion("2.0")]

BIN
src/PixiEditor/Data/BetaExampleFiles/Outline.pixi


BIN
src/PixiEditor/Data/BetaExampleFiles/Pond.pixi


BIN
src/PixiEditor/Data/BetaExampleFiles/Slime.pixi


BIN
src/PixiEditor/Data/BetaExampleFiles/Tree.pixi


+ 9 - 1
src/PixiEditor/Data/Localization/Languages/en.json

@@ -673,5 +673,13 @@
   "ACTIVE_FRAME": "Active Frame",
   "NORMALIZED_TIME": "Normalized Time",
   "WITHOUT_FILTERS": "Without filters",
-  "RAW_LAYER_OUTPUT": "Raw"
+  "RAW_LAYER_OUTPUT": "Raw",
+  "BETA_EXAMPLE_FILES": "Beta Example Files",
+  "BETA_PROCEDURAL_GENERATION": "Procedural Animation",
+  "POND_EXAMPLE": "Pond",
+  "TREE_EXAMPLE": "Windy Tree",
+  "OUTLINE_EXAMPLE": "Automatic Outline",
+  "BETA_ANIMATIONS": "Animations",
+  "SLIME_EXAMPLE": "Animated Slime",
+  "SHOW_ALL_EXAMPLES": "Show all"
 }

+ 3 - 5
src/PixiEditor/Helpers/VersionHelpers.cs

@@ -11,12 +11,10 @@ internal static class VersionHelpers
 
     public static string GetCurrentAssemblyVersionString(bool moreSpecific = false)
     {
-        StringBuilder builder = new(GetCurrentAssemblyVersion().ToString());
+        StringBuilder builder = new($"{GetCurrentAssemblyVersion().ToString(2)} Closed Beta");
 
-#if DEVRELEASE
-        builder.Append(" Dev Build");
-        return builder.ToString();
-#elif MSIX_DEBUG
+        // Dev Build removed for closed beta
+#if MSIX_DEBUG
         builder.Append(" MSIX Debug Build");
         return builder.ToString();
 #elif DEBUG

+ 2 - 4
src/PixiEditor/Models/Preferences/PreferencesSettings.cs

@@ -1,6 +1,4 @@
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
+using System.Diagnostics;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using PixiEditor.Extensions.CommonApi.UserPreferences;
@@ -14,7 +12,7 @@ internal class PreferencesSettings : IPreferences
 
     public string PathToRoamingUserPreferences { get; private set; } = GetPathToSettings(Environment.SpecialFolder.ApplicationData, "user_preferences.json");
 
-    public string PathToLocalPreferences { get; private set; } = GetPathToSettings(Environment.SpecialFolder.LocalApplicationData, "editor_data.json");
+    public string PathToLocalPreferences { get; private set; } = GetPathToSettings(Environment.SpecialFolder.LocalApplicationData, "2_0_beta_editor_data.json");
 
     public Dictionary<string, object> Preferences { get; set; } = new Dictionary<string, object>();
 

+ 2 - 2
src/PixiEditor/Properties/AssemblyInfo.cs

@@ -42,5 +42,5 @@ using System.Windows;
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.9.0.0")]
-[assembly: AssemblyFileVersion("1.9.0.0")]
+[assembly: AssemblyVersion("2.0.0.1")]
+[assembly: AssemblyFileVersion("2.0.0.1")]

+ 1 - 1
src/PixiEditor/Views/Windows/HelloTherePopup.axaml

@@ -93,7 +93,7 @@
                                         Command="{Binding SetShowAllBetaExamplesCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}"
                                         CommandParameter="{x:True}">
                                     <Grid Width="100" Height="100">
-                                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Show all 8 >"/>
+                                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" ui:Translator.Key="SHOW_ALL_EXAMPLES"/>
                                     </Grid>
                                 </Button>