mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 18:11:27 -07:00
Rework emoji font mod
This commit is contained in:
parent
e683af373d
commit
88ea69c56d
@ -1010,27 +1010,24 @@ namespace Bloxstrap
|
|||||||
await CheckModPreset(App.Settings.Prop.UseDisableAppPatch && !_launchCommandLine.Contains("--deeplink"), @"ExtraContent\places\Mobile.rbxl", "");
|
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
|
// 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);
|
File.Delete(emojiFontLocation);
|
||||||
|
|
||||||
App.State.Prop.CurrentEmojiType = EmojiType.Default;
|
|
||||||
}
|
}
|
||||||
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);
|
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 using var fileStream = new FileStream(emojiFontLocation, FileMode.CreateNew);
|
||||||
await response.Content.CopyToAsync(fileStream);
|
await response.Content.CopyToAsync(fileStream);
|
||||||
|
|
||||||
App.State.Prop.CurrentEmojiType = App.Settings.Prop.PreferredEmojiType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string file in Directory.GetFiles(modFolder, "*.*", SearchOption.AllDirectories))
|
foreach (string file in Directory.GetFiles(modFolder, "*.*", SearchOption.AllDirectories))
|
||||||
|
@ -23,7 +23,17 @@ namespace Bloxstrap.Extensions
|
|||||||
{ EmojiType.Windows8, "Win8.1SegoeUIEmoji.ttf" },
|
{ EmojiType.Windows8, "Win8.1SegoeUIEmoji.ttf" },
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string GetRemoteLocation(this EmojiType emojiType)
|
public static IReadOnlyDictionary<EmojiType, string> Hashes => new Dictionary<EmojiType, string>
|
||||||
|
{
|
||||||
|
{ 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)
|
if (emojiType == EmojiType.Default)
|
||||||
return "";
|
return "";
|
||||||
|
@ -31,7 +31,7 @@ namespace Bloxstrap.Models
|
|||||||
public bool UseOldCharacterSounds { get; set; } = false;
|
public bool UseOldCharacterSounds { get; set; } = false;
|
||||||
public bool UseOldMouseCursor { get; set; } = false;
|
public bool UseOldMouseCursor { get; set; } = false;
|
||||||
public bool UseDisableAppPatch { 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;
|
public bool DisableFullscreenOptimizations { get; set; } = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ namespace Bloxstrap.Models
|
|||||||
public class State
|
public class State
|
||||||
{
|
{
|
||||||
public string VersionGuid { get; set; } = "";
|
public string VersionGuid { get; set; } = "";
|
||||||
public EmojiType CurrentEmojiType { get; set; } = EmojiType.Default;
|
|
||||||
public List<string> ModManifest { get; set; } = new();
|
public List<string> ModManifest { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,8 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
|
|
||||||
public string SelectedEmojiType
|
public string SelectedEmojiType
|
||||||
{
|
{
|
||||||
get => EmojiTypes.FirstOrDefault(x => x.Value == App.Settings.Prop.PreferredEmojiType).Key;
|
get => EmojiTypes.FirstOrDefault(x => x.Value == App.Settings.Prop.EmojiType).Key;
|
||||||
set => App.Settings.Prop.PreferredEmojiType = EmojiTypes[value];
|
set => App.Settings.Prop.EmojiType = EmojiTypes[value];
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DisableFullscreenOptimizationsEnabled
|
public bool DisableFullscreenOptimizationsEnabled
|
||||||
|
Loading…
Reference in New Issue
Block a user