mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 20:33:40 +01:00
feat: show error message if font doesn't exist
This commit is contained in:
parent
f81a368ed6
commit
6d891ff416
2 changed files with 26 additions and 0 deletions
|
|
@ -308,6 +308,13 @@ namespace Dalamud.Interface
|
|||
public static ImFontPtr DefaultFont { get; private set; }
|
||||
public static ImFontPtr IconFont { get; private set; }
|
||||
|
||||
private static void ShowFontError(string path)
|
||||
{
|
||||
Util.Fatal(
|
||||
$"One or more files required by XIVLauncher were not found.\nPlease restart and report this error if it occurs again.\n\n{path}",
|
||||
"Error");
|
||||
}
|
||||
|
||||
private unsafe void SetupFonts()
|
||||
{
|
||||
this.fontBuildSignal.Reset();
|
||||
|
|
@ -320,12 +327,18 @@ namespace Dalamud.Interface
|
|||
|
||||
var fontPathJp = Path.Combine(this.dalamud.AssetDirectory.FullName, "UIRes", "NotoSansCJKjp-Medium.otf");
|
||||
|
||||
if (!File.Exists(fontPathJp))
|
||||
ShowFontError(fontPathJp);
|
||||
|
||||
var japaneseRangeHandle = GCHandle.Alloc(GlyphRangesJapanese.GlyphRanges, GCHandleType.Pinned);
|
||||
|
||||
DefaultFont = ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathJp, 17.0f, null, japaneseRangeHandle.AddrOfPinnedObject());
|
||||
|
||||
var fontPathGame = Path.Combine(this.dalamud.AssetDirectory.FullName, "UIRes", "gamesym.ttf");
|
||||
|
||||
if (!File.Exists(fontPathGame))
|
||||
ShowFontError(fontPathGame);
|
||||
|
||||
var gameRangeHandle = GCHandle.Alloc(new ushort[]
|
||||
{
|
||||
0xE020,
|
||||
|
|
@ -337,6 +350,9 @@ namespace Dalamud.Interface
|
|||
|
||||
var fontPathIcon = Path.Combine(this.dalamud.AssetDirectory.FullName, "UIRes", "FontAwesome5FreeSolid.otf");
|
||||
|
||||
if (!File.Exists(fontPathIcon))
|
||||
ShowFontError(fontPathIcon);
|
||||
|
||||
var iconRangeHandle = GCHandle.Alloc(new ushort[]
|
||||
{
|
||||
0xE000,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
|
@ -146,5 +147,14 @@ namespace Dalamud
|
|||
ImGui.TextColored(ImGuiColors.HealerGreen, $" {fieldInfo.Name}: {fieldInfo.GetValue(obj)}");
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet= CharSet.Auto)]
|
||||
public static extern int MessageBox(IntPtr hWnd, string text, string caption, uint type);
|
||||
|
||||
public static void Fatal(string message, string caption)
|
||||
{
|
||||
MessageBox(Process.GetCurrentProcess().MainWindowHandle, message, caption, 0);
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue