mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
Add font build status display to Settings window
This commit is contained in:
parent
8bdab4d2c8
commit
f8e6df1172
2 changed files with 35 additions and 3 deletions
|
|
@ -4,9 +4,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.Unicode;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Game;
|
||||
|
|
@ -236,6 +234,11 @@ internal class InterfaceManager : IDisposable, IServiceType
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the font build task.
|
||||
/// </summary>
|
||||
public Task FontBuildTask => WhenFontsReady().dalamudAtlas!.BuildTask;
|
||||
|
||||
/// <summary>
|
||||
/// Dispose of managed and unmanaged resources.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
|
||||
using CheapLoc;
|
||||
using Dalamud.Configuration.Internal;
|
||||
|
|
@ -145,6 +146,7 @@ public class SettingsTabLook : SettingsTab
|
|||
public override void Draw()
|
||||
{
|
||||
var interfaceManager = Service<InterfaceManager>.Get();
|
||||
var fontBuildTask = interfaceManager.FontBuildTask;
|
||||
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.Text(Loc.Localize("DalamudSettingsGlobalUiScale", "Global Font Scale"));
|
||||
|
|
@ -164,6 +166,19 @@ public class SettingsTabLook : SettingsTab
|
|||
}
|
||||
}
|
||||
|
||||
if (!fontBuildTask.IsCompleted)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
var buildingFonts = Loc.Localize("DalamudSettingsFontBuildInProgressWithEndingThreeDots", "Building fonts...");
|
||||
unsafe
|
||||
{
|
||||
var len = Encoding.UTF8.GetByteCount(buildingFonts);
|
||||
var p = stackalloc byte[len];
|
||||
Encoding.UTF8.GetBytes(buildingFonts, new(p, len));
|
||||
ImGuiNative.igTextUnformatted(p, (p + len + ((Environment.TickCount / 200) % 3)) - 2);
|
||||
}
|
||||
}
|
||||
|
||||
var globalUiScaleInPt = 12f * this.globalUiScale;
|
||||
if (ImGui.DragFloat("##DalamudSettingsGlobalUiScaleDrag", ref globalUiScaleInPt, 0.1f, 9.6f, 36f, "%.1fpt", ImGuiSliderFlags.AlwaysClamp))
|
||||
{
|
||||
|
|
@ -174,6 +189,19 @@ public class SettingsTabLook : SettingsTab
|
|||
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsGlobalUiScaleHint", "Scale text in all XIVLauncher UI elements - this is useful for 4K displays."));
|
||||
|
||||
if (fontBuildTask.IsFaulted || fontBuildTask.IsCanceled)
|
||||
{
|
||||
ImGui.TextColored(
|
||||
ImGuiColors.DalamudRed,
|
||||
Loc.Localize("DalamudSettingsFontBuildFaulted", "Failed to load fonts as requested."));
|
||||
if (fontBuildTask.Exception is not null
|
||||
&& ImGui.CollapsingHeader("##DalamudSetingsFontBuildFaultReason"))
|
||||
{
|
||||
foreach (var e in fontBuildTask.Exception.InnerExceptions)
|
||||
ImGui.TextUnformatted(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
|
||||
ImGui.AlignTextToFramePadding();
|
||||
|
|
@ -208,6 +236,7 @@ public class SettingsTabLook : SettingsTab
|
|||
public override void Save()
|
||||
{
|
||||
Service<DalamudConfiguration>.Get().GlobalUiScale = this.globalUiScale;
|
||||
Service<DalamudConfiguration>.Get().FontGammaLevel = this.fontGamma;
|
||||
|
||||
base.Save();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue