diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 9e83cbd..1f6e4d9 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -1010,27 +1010,24 @@ namespace Bloxstrap await CheckModPreset(App.Settings.Prop.UseDisableAppPatch && !_launchCommandLine.Contains("--deeplink"), @"ExtraContent\places\Mobile.rbxl", ""); // emoji presets are downloaded remotely from github due to how large they are - string emojiFontLocation = Path.Combine(Directories.Modifications, "content\\fonts\\TwemojiMozilla.ttf"); + string contentFonts = Path.Combine(Directories.Modifications, "content\\fonts"); + string emojiFontLocation = Path.Combine(contentFonts, "TwemojiMozilla.ttf"); + string emojiFontHash = File.Exists(emojiFontLocation) ? Utility.MD5Hash.FromFile(emojiFontLocation) : ""; - if (App.Settings.Prop.PreferredEmojiType == EmojiType.Default && App.State.Prop.CurrentEmojiType != EmojiType.Default) + if (App.Settings.Prop.EmojiType == EmojiType.Default && EmojiTypeEx.Hashes.Values.Contains(emojiFontHash)) { - if (File.Exists(emojiFontLocation)) - File.Delete(emojiFontLocation); - - App.State.Prop.CurrentEmojiType = EmojiType.Default; + File.Delete(emojiFontLocation); } - else if (App.Settings.Prop.PreferredEmojiType != EmojiType.Default && App.State.Prop.CurrentEmojiType != App.Settings.Prop.PreferredEmojiType) + else if (App.Settings.Prop.EmojiType != EmojiType.Default && emojiFontHash != App.Settings.Prop.EmojiType.GetHash()) { - if (File.Exists(emojiFontLocation)) + if (emojiFontHash != "") File.Delete(emojiFontLocation); - string remoteEmojiLocation = App.Settings.Prop.PreferredEmojiType.GetRemoteLocation(); + Directory.CreateDirectory(contentFonts); - var response = await App.HttpClient.GetAsync(remoteEmojiLocation); + var response = await App.HttpClient.GetAsync(App.Settings.Prop.EmojiType.GetUrl()); await using var fileStream = new FileStream(emojiFontLocation, FileMode.CreateNew); await response.Content.CopyToAsync(fileStream); - - App.State.Prop.CurrentEmojiType = App.Settings.Prop.PreferredEmojiType; } foreach (string file in Directory.GetFiles(modFolder, "*.*", SearchOption.AllDirectories)) diff --git a/Bloxstrap/Extensions/EmojiTypeEx.cs b/Bloxstrap/Extensions/EmojiTypeEx.cs index 5978b66..07fd220 100644 --- a/Bloxstrap/Extensions/EmojiTypeEx.cs +++ b/Bloxstrap/Extensions/EmojiTypeEx.cs @@ -23,7 +23,17 @@ namespace Bloxstrap.Extensions { EmojiType.Windows8, "Win8.1SegoeUIEmoji.ttf" }, }; - public static string GetRemoteLocation(this EmojiType emojiType) + public static IReadOnlyDictionary Hashes => new Dictionary + { + { EmojiType.Catmoji, "98138f398a8cde897074dd2b8d53eca0" }, + { EmojiType.Windows11, "d50758427673578ddf6c9edcdbf367f5" }, + { EmojiType.Windows10, "d8a7eecbebf9dfdf622db8ccda63aff5" }, + { EmojiType.Windows8, "2b01c6caabbe95afc92aa63b9bf100f3" }, + }; + + public static string GetHash(this EmojiType emojiType) => Hashes[emojiType]; + + public static string GetUrl(this EmojiType emojiType) { if (emojiType == EmojiType.Default) return ""; diff --git a/Bloxstrap/Models/Settings.cs b/Bloxstrap/Models/Settings.cs index 477d324..80e28c2 100644 --- a/Bloxstrap/Models/Settings.cs +++ b/Bloxstrap/Models/Settings.cs @@ -31,7 +31,7 @@ namespace Bloxstrap.Models public bool UseOldCharacterSounds { get; set; } = false; public bool UseOldMouseCursor { get; set; } = false; public bool UseDisableAppPatch { get; set; } = false; - public EmojiType PreferredEmojiType { get; set; } = EmojiType.Default; + public EmojiType EmojiType { get; set; } = EmojiType.Default; public bool DisableFullscreenOptimizations { get; set; } = false; } } diff --git a/Bloxstrap/Models/State.cs b/Bloxstrap/Models/State.cs index cd1a7fc..b099001 100644 --- a/Bloxstrap/Models/State.cs +++ b/Bloxstrap/Models/State.cs @@ -7,7 +7,6 @@ namespace Bloxstrap.Models public class State { public string VersionGuid { get; set; } = ""; - public EmojiType CurrentEmojiType { get; set; } = EmojiType.Default; public List ModManifest { get; set; } = new(); } } diff --git a/Bloxstrap/UI/ViewModels/Menu/ModsViewModel.cs b/Bloxstrap/UI/ViewModels/Menu/ModsViewModel.cs index a1b20ca..1f94b4c 100644 --- a/Bloxstrap/UI/ViewModels/Menu/ModsViewModel.cs +++ b/Bloxstrap/UI/ViewModels/Menu/ModsViewModel.cs @@ -44,8 +44,8 @@ namespace Bloxstrap.UI.ViewModels.Menu public string SelectedEmojiType { - get => EmojiTypes.FirstOrDefault(x => x.Value == App.Settings.Prop.PreferredEmojiType).Key; - set => App.Settings.Prop.PreferredEmojiType = EmojiTypes[value]; + get => EmojiTypes.FirstOrDefault(x => x.Value == App.Settings.Prop.EmojiType).Key; + set => App.Settings.Prop.EmojiType = EmojiTypes[value]; } public bool DisableFullscreenOptimizationsEnabled