mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-20 06:47:44 +01:00
Reapply "IFontAtlas: font atlas per plugin"
This reverts commit b5696afe94.
This commit is contained in:
parent
b5696afe94
commit
63b16bcc7c
44 changed files with 7944 additions and 1500 deletions
|
|
@ -5,10 +5,10 @@ using CheapLoc;
|
|||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Internal.Windows.Settings.Tabs;
|
||||
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Utility;
|
||||
using ImGuiNET;
|
||||
|
||||
|
|
@ -19,14 +19,7 @@ namespace Dalamud.Interface.Internal.Windows.Settings;
|
|||
/// </summary>
|
||||
internal class SettingsWindow : Window
|
||||
{
|
||||
private readonly SettingsTab[] tabs =
|
||||
{
|
||||
new SettingsTabGeneral(),
|
||||
new SettingsTabLook(),
|
||||
new SettingsTabDtr(),
|
||||
new SettingsTabExperimental(),
|
||||
new SettingsTabAbout(),
|
||||
};
|
||||
private SettingsTab[]? tabs;
|
||||
|
||||
private string searchInput = string.Empty;
|
||||
|
||||
|
|
@ -49,6 +42,15 @@ internal class SettingsWindow : Window
|
|||
/// <inheritdoc/>
|
||||
public override void OnOpen()
|
||||
{
|
||||
this.tabs ??= new SettingsTab[]
|
||||
{
|
||||
new SettingsTabGeneral(),
|
||||
new SettingsTabLook(),
|
||||
new SettingsTabDtr(),
|
||||
new SettingsTabExperimental(),
|
||||
new SettingsTabAbout(),
|
||||
};
|
||||
|
||||
foreach (var settingsTab in this.tabs)
|
||||
{
|
||||
settingsTab.Load();
|
||||
|
|
@ -64,15 +66,12 @@ internal class SettingsWindow : Window
|
|||
{
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
var interfaceManager = Service<InterfaceManager>.Get();
|
||||
var fontAtlasFactory = Service<FontAtlasFactory>.Get();
|
||||
|
||||
var rebuildFont =
|
||||
ImGui.GetIO().FontGlobalScale != configuration.GlobalUiScale ||
|
||||
interfaceManager.FontGamma != configuration.FontGammaLevel ||
|
||||
interfaceManager.UseAxis != configuration.UseAxisFontsFromGame;
|
||||
var rebuildFont = fontAtlasFactory.UseAxis != configuration.UseAxisFontsFromGame;
|
||||
|
||||
ImGui.GetIO().FontGlobalScale = configuration.GlobalUiScale;
|
||||
interfaceManager.FontGammaOverride = null;
|
||||
interfaceManager.UseAxisOverride = null;
|
||||
fontAtlasFactory.UseAxisOverride = null;
|
||||
|
||||
if (rebuildFont)
|
||||
interfaceManager.RebuildFonts();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
using CheapLoc;
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.Interface.GameFonts;
|
||||
using Dalamud.Interface.ManagedFontAtlas;
|
||||
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Plugin.Internal;
|
||||
|
|
@ -15,7 +15,6 @@ using Dalamud.Storage.Assets;
|
|||
using Dalamud.Utility;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
||||
using ImGuiNET;
|
||||
using ImGuiScene;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows.Settings.Tabs;
|
||||
|
||||
|
|
@ -173,16 +172,21 @@ Contribute at: https://github.com/goatcorp/Dalamud
|
|||
";
|
||||
|
||||
private readonly Stopwatch creditsThrottler;
|
||||
private readonly IFontAtlas privateAtlas;
|
||||
|
||||
private string creditsText;
|
||||
|
||||
private bool resetNow = false;
|
||||
private IDalamudTextureWrap? logoTexture;
|
||||
private GameFontHandle? thankYouFont;
|
||||
private IFontHandle? thankYouFont;
|
||||
|
||||
public SettingsTabAbout()
|
||||
{
|
||||
this.creditsThrottler = new();
|
||||
|
||||
this.privateAtlas = Service<FontAtlasFactory>
|
||||
.Get()
|
||||
.CreateFontAtlas(nameof(SettingsTabAbout), FontAtlasAutoRebuildMode.Async);
|
||||
}
|
||||
|
||||
public override SettingsEntry[] Entries { get; } = { };
|
||||
|
|
@ -207,11 +211,7 @@ Contribute at: https://github.com/goatcorp/Dalamud
|
|||
|
||||
this.creditsThrottler.Restart();
|
||||
|
||||
if (this.thankYouFont == null)
|
||||
{
|
||||
var gfm = Service<GameFontManager>.Get();
|
||||
this.thankYouFont = gfm.NewFontRef(new GameFontStyle(GameFontFamilyAndSize.TrumpGothic34));
|
||||
}
|
||||
this.thankYouFont ??= this.privateAtlas.NewGameFontHandle(new(GameFontFamilyAndSize.TrumpGothic34));
|
||||
|
||||
this.resetNow = true;
|
||||
|
||||
|
|
@ -269,14 +269,12 @@ Contribute at: https://github.com/goatcorp/Dalamud
|
|||
|
||||
if (this.thankYouFont != null)
|
||||
{
|
||||
ImGui.PushFont(this.thankYouFont.ImFont);
|
||||
using var fontPush = this.thankYouFont.Push();
|
||||
var thankYouLenX = ImGui.CalcTextSize(ThankYouText).X;
|
||||
|
||||
ImGui.Dummy(new Vector2((windowX / 2) - (thankYouLenX / 2), 0f));
|
||||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(ThankYouText);
|
||||
|
||||
ImGui.PopFont();
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(0, windowSize.Y + 50f);
|
||||
|
|
@ -305,9 +303,5 @@ Contribute at: https://github.com/goatcorp/Dalamud
|
|||
/// <summary>
|
||||
/// Disposes of managed and unmanaged resources.
|
||||
/// </summary>
|
||||
public override void Dispose()
|
||||
{
|
||||
this.logoTexture?.Dispose();
|
||||
this.thankYouFont?.Dispose();
|
||||
}
|
||||
public override void Dispose() => this.privateAtlas.Dispose();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
|
||||
using CheapLoc;
|
||||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Internal.Windows.PluginInstaller;
|
||||
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
|
||||
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Utility;
|
||||
using ImGuiNET;
|
||||
|
|
@ -28,7 +30,6 @@ public class SettingsTabLook : SettingsTab
|
|||
};
|
||||
|
||||
private float globalUiScale;
|
||||
private float fontGamma;
|
||||
|
||||
public override SettingsEntry[] Entries { get; } =
|
||||
{
|
||||
|
|
@ -41,9 +42,8 @@ public class SettingsTabLook : SettingsTab
|
|||
(v, c) => c.UseAxisFontsFromGame = v,
|
||||
v =>
|
||||
{
|
||||
var im = Service<InterfaceManager>.Get();
|
||||
im.UseAxisOverride = v;
|
||||
im.RebuildFonts();
|
||||
Service<FontAtlasFactory>.Get().UseAxisOverride = v;
|
||||
Service<InterfaceManager>.Get().RebuildFonts();
|
||||
}),
|
||||
|
||||
new GapSettingsEntry(5, true),
|
||||
|
|
@ -145,6 +145,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 +165,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,33 +188,25 @@ public class SettingsTabLook : SettingsTab
|
|||
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsGlobalUiScaleHint", "Scale text in all XIVLauncher UI elements - this is useful for 4K displays."));
|
||||
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImGui.Text(Loc.Localize("DalamudSettingsFontGamma", "Font Gamma"));
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "Reset") + "##DalamudSettingsFontGammaReset"))
|
||||
if (fontBuildTask.IsFaulted || fontBuildTask.IsCanceled)
|
||||
{
|
||||
this.fontGamma = 1.4f;
|
||||
interfaceManager.FontGammaOverride = this.fontGamma;
|
||||
interfaceManager.RebuildFonts();
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui.DragFloat("##DalamudSettingsFontGammaDrag", ref this.fontGamma, 0.005f, 0.3f, 3f, "%.2f", ImGuiSliderFlags.AlwaysClamp))
|
||||
{
|
||||
interfaceManager.FontGammaOverride = this.fontGamma;
|
||||
interfaceManager.RebuildFonts();
|
||||
}
|
||||
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsFontGammaHint", "Changes the thickness of text."));
|
||||
|
||||
base.Draw();
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
this.globalUiScale = Service<DalamudConfiguration>.Get().GlobalUiScale;
|
||||
this.fontGamma = Service<DalamudConfiguration>.Get().FontGammaLevel;
|
||||
|
||||
base.Load();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue