Fix font application mod on first install

This commit is contained in:
pizzaboxer 2023-07-25 17:52:23 +01:00
parent dc3500e110
commit f02fba2ce1
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
5 changed files with 26 additions and 9 deletions

View File

@ -17,8 +17,10 @@ namespace Bloxstrap
// used only for communicating between app and menu - use Directories.Base for anything else // used only for communicating between app and menu - use Directories.Base for anything else
public static string BaseDirectory = null!; public static string BaseDirectory = null!;
public static string? CustomFontLocation;
public static bool ShouldSaveConfigs { get; set; } = false; public static bool ShouldSaveConfigs { get; set; } = false;
public static bool IsSetupComplete { get; set; } = true; public static bool IsSetupComplete { get; set; } = true;
public static bool IsFirstRun { get; private set; } = true; public static bool IsFirstRun { get; private set; } = true;
public static bool IsQuiet { get; private set; } = false; public static bool IsQuiet { get; private set; } = false;

View File

@ -980,7 +980,6 @@ namespace Bloxstrap
bool appDisabled = App.Settings.Prop.UseDisableAppPatch && !_launchCommandLine.Contains("--deeplink"); bool appDisabled = App.Settings.Prop.UseDisableAppPatch && !_launchCommandLine.Contains("--deeplink");
// cursors // cursors
await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2006, new Dictionary<string, string> await CheckModPreset(App.Settings.Prop.CursorType == CursorType.From2006, new Dictionary<string, string>
{ {
{ @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", "Cursor.From2006.ArrowCursor.png" }, { @"content\textures\Cursors\KeyboardMouse\ArrowCursor.png", "Cursor.From2006.ArrowCursor.png" },
@ -1036,9 +1035,14 @@ namespace Bloxstrap
// instead of replacing the fonts themselves, we'll just alter the font family manifests // instead of replacing the fonts themselves, we'll just alter the font family manifests
string modFontFamiliesFolder = Path.Combine(Directories.Modifications, "content\\fonts\\families"); string modFontFamiliesFolder = Path.Combine(Directories.Modifications, "content\\fonts\\families");
string customFontLocation = Path.Combine(Directories.Modifications, "content\\fonts\\CustomFont.ttf");
if (File.Exists(customFontLocation)) if (App.IsFirstRun && App.CustomFontLocation is not null)
{
Directory.CreateDirectory(Path.GetDirectoryName(Directories.CustomFont)!);
File.Copy(App.CustomFontLocation, Directories.CustomFont);
}
if (File.Exists(Directories.CustomFont))
{ {
App.Logger.WriteLine("[Bootstrapper::ApplyModifications] Begin font check"); App.Logger.WriteLine("[Bootstrapper::ApplyModifications] Begin font check");

View File

@ -19,6 +19,8 @@
public static string Application { get; private set; } = ""; public static string Application { get; private set; } = "";
public static string CustomFont => Path.Combine(Modifications, "content\\fonts\\CustomFont.ttf");
public static bool Initialized => !String.IsNullOrEmpty(Base); public static bool Initialized => !String.IsNullOrEmpty(Base);
public static void Initialize(string baseDirectory) public static void Initialize(string baseDirectory)

View File

@ -75,7 +75,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
$"The folder you've chosen to install {App.ProjectName} to already exists and is NOT empty. It is strongly recommended for {App.ProjectName} to be installed to its own independent folder.\n\n" + $"The folder you've chosen to install {App.ProjectName} to already exists and is NOT empty. It is strongly recommended for {App.ProjectName} to be installed to its own independent folder.\n\n" +
"Changing to the following location is suggested:\n" + "Changing to the following location is suggested:\n" +
$"{suggestedChange}\n\n" + $"{suggestedChange}\n\n" +
"Would you like to change your install location to this?\n" + "Would you like to change to the suggested location?\n" +
"Selecting 'No' will ignore this warning and continue installation.", "Selecting 'No' will ignore this warning and continue installation.",
MessageBoxImage.Warning, MessageBoxImage.Warning,
MessageBoxButton.YesNoCancel, MessageBoxButton.YesNoCancel,

View File

@ -11,14 +11,16 @@ namespace Bloxstrap.UI.ViewModels.Menu
{ {
private void OpenModsFolder() => Process.Start("explorer.exe", Directories.Modifications); private void OpenModsFolder() => Process.Start("explorer.exe", Directories.Modifications);
private string _customFontLocation = Path.Combine(Directories.Modifications, "content\\fonts\\CustomFont.ttf"); private bool _usingCustomFont => App.IsFirstRun && App.CustomFontLocation is not null || !App.IsFirstRun && File.Exists(Directories.CustomFont);
private bool _usingCustomFont => File.Exists(_customFontLocation);
private void ManageCustomFont() private void ManageCustomFont()
{ {
if (_usingCustomFont) if (_usingCustomFont)
{ {
File.Delete(_customFontLocation); if (App.IsFirstRun)
App.CustomFontLocation = null;
else
File.Delete(Directories.CustomFont);
} }
else else
{ {
@ -30,8 +32,15 @@ namespace Bloxstrap.UI.ViewModels.Menu
if (dialog.ShowDialog() != true) if (dialog.ShowDialog() != true)
return; return;
Directory.CreateDirectory(Path.GetDirectoryName(_customFontLocation)!); if (App.IsFirstRun)
File.Copy(dialog.FileName, _customFontLocation); {
App.CustomFontLocation = dialog.FileName;
}
else
{
Directory.CreateDirectory(Path.GetDirectoryName(Directories.CustomFont)!);
File.Copy(dialog.FileName, Directories.CustomFont);
}
} }
OnPropertyChanged(nameof(ChooseCustomFontVisibility)); OnPropertyChanged(nameof(ChooseCustomFontVisibility));