mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Move UseAxis/Override to FAF
This commit is contained in:
parent
f172ee2308
commit
015c313c5e
7 changed files with 64 additions and 30 deletions
|
|
@ -11,6 +11,7 @@ using System.Text.Unicode;
|
|||
using Dalamud.Game.Text;
|
||||
using Dalamud.Hooking.WndProcHook;
|
||||
using Dalamud.Interface.GameFonts;
|
||||
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||
using Dalamud.Interface.Utility;
|
||||
|
||||
using ImGuiNET;
|
||||
|
|
@ -196,9 +197,9 @@ internal sealed unsafe class DalamudIme : IDisposable, IServiceType
|
|||
{
|
||||
if (HanRange.Any(x => x.FirstCodePoint <= chr && chr < x.FirstCodePoint + x.Length))
|
||||
{
|
||||
if (Service<GameFontManager>.Get()
|
||||
.GetFdtReader(GameFontFamilyAndSize.Axis12)
|
||||
?.FindGlyph(chr) is null)
|
||||
if (Service<FontAtlasFactory>.Get()
|
||||
?.GetFdtReader(GameFontFamilyAndSize.Axis12)
|
||||
.FindGlyph(chr) is null)
|
||||
{
|
||||
if (!this.EncounteredHan)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -189,16 +189,6 @@ internal class InterfaceManager : IDisposable, IServiceType
|
|||
/// </summary>
|
||||
public bool IsDispatchingEvents { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to override configuration for UseAxis.
|
||||
/// </summary>
|
||||
public bool? UseAxisOverride { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether to use AXIS fonts.
|
||||
/// </summary>
|
||||
public bool UseAxis => this.UseAxisOverride ?? Service<DalamudConfiguration>.Get().UseAxisFontsFromGame;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating the native handle of the game main window.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ 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;
|
||||
|
|
@ -65,11 +66,12 @@ internal class SettingsWindow : Window
|
|||
{
|
||||
var configuration = Service<DalamudConfiguration>.Get();
|
||||
var interfaceManager = Service<InterfaceManager>.Get();
|
||||
var fontAtlasFactory = Service<FontAtlasFactory>.Get();
|
||||
|
||||
var rebuildFont = interfaceManager.UseAxis != configuration.UseAxisFontsFromGame;
|
||||
var rebuildFont = fontAtlasFactory.UseAxis != configuration.UseAxisFontsFromGame;
|
||||
|
||||
ImGui.GetIO().FontGlobalScale = configuration.GlobalUiScale;
|
||||
interfaceManager.UseAxisOverride = null;
|
||||
fontAtlasFactory.UseAxisOverride = null;
|
||||
|
||||
if (rebuildFont)
|
||||
interfaceManager.RebuildFonts();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ 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;
|
||||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ internal sealed partial class FontAtlasFactory
|
|||
return fontPtr;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
/// <inheritdoc cref="IFontAtlasBuildToolkitPreBuild.IsGlobalScaleIgnored"/>
|
||||
public bool IsGlobalScaleIgnored(ImFontPtr fontPtr) =>
|
||||
this.GlobalScaleExclusions.Contains(fontPtr);
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ internal sealed partial class FontAtlasFactory
|
|||
{
|
||||
ImFontPtr font;
|
||||
glyphRanges ??= this.factory.DefaultGlyphRanges;
|
||||
if (Service<InterfaceManager>.Get().UseAxis)
|
||||
if (this.factory.UseAxis)
|
||||
{
|
||||
font = this.AddGameGlyphs(new(GameFontFamily.Axis, sizePx), glyphRanges, default);
|
||||
}
|
||||
|
|
@ -360,7 +360,8 @@ internal sealed partial class FontAtlasFactory
|
|||
public void AttachExtraGlyphsForDalamudLanguage(in SafeFontConfig fontConfig)
|
||||
{
|
||||
var dalamudConfiguration = Service<DalamudConfiguration>.Get();
|
||||
if (dalamudConfiguration.EffectiveLanguage == "ko")
|
||||
if (dalamudConfiguration.EffectiveLanguage == "ko"
|
||||
|| Service<DalamudIme>.GetNullable()?.EncounteredHangul is true)
|
||||
{
|
||||
this.AddDalamudAssetFont(
|
||||
DalamudAsset.NotoSansKrRegular,
|
||||
|
|
@ -374,6 +375,35 @@ internal sealed partial class FontAtlasFactory
|
|||
UnicodeRanges.HangulJamoExtendedB),
|
||||
});
|
||||
}
|
||||
|
||||
var windowsDir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
|
||||
var fontPathChs = Path.Combine(windowsDir, "Fonts", "msyh.ttc");
|
||||
if (!File.Exists(fontPathChs))
|
||||
fontPathChs = null;
|
||||
|
||||
var fontPathCht = Path.Combine(windowsDir, "Fonts", "msjh.ttc");
|
||||
if (!File.Exists(fontPathCht))
|
||||
fontPathCht = null;
|
||||
|
||||
if (fontPathCht != null && Service<DalamudConfiguration>.Get().EffectiveLanguage == "tw")
|
||||
{
|
||||
this.AddFontFromFile(fontPathCht, fontConfig with
|
||||
{
|
||||
GlyphRanges = ImGuiHelpers.CreateImGuiRangesFrom(
|
||||
UnicodeRanges.CjkUnifiedIdeographs,
|
||||
UnicodeRanges.CjkUnifiedIdeographsExtensionA),
|
||||
});
|
||||
}
|
||||
else if (fontPathChs != null && (Service<DalamudConfiguration>.Get().EffectiveLanguage == "zh"
|
||||
|| Service<DalamudIme>.GetNullable()?.EncounteredHan is true))
|
||||
{
|
||||
this.AddFontFromFile(fontPathChs, fontConfig with
|
||||
{
|
||||
GlyphRanges = ImGuiHelpers.CreateImGuiRangesFrom(
|
||||
UnicodeRanges.CjkUnifiedIdeographs,
|
||||
UnicodeRanges.CjkUnifiedIdeographsExtensionA),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void PreBuildSubstances()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dalamud.Configuration.Internal;
|
||||
using Dalamud.Data;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Interface.GameFonts;
|
||||
|
|
@ -106,6 +107,16 @@ internal sealed partial class FontAtlasFactory
|
|||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to override configuration for UseAxis.
|
||||
/// </summary>
|
||||
public bool? UseAxisOverride { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether to use AXIS fonts.
|
||||
/// </summary>
|
||||
public bool UseAxis => this.UseAxisOverride ?? Service<DalamudConfiguration>.Get().UseAxisFontsFromGame;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the service instance of <see cref="Framework"/>.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -549,6 +549,15 @@ public static class ImGuiHelpers
|
|||
/// <returns>Whether it is empty.</returns>
|
||||
public static unsafe bool IsNull(this ImFontAtlasPtr ptr) => ptr.NativePtr == null;
|
||||
|
||||
/// <summary>
|
||||
/// If <paramref name="self"/> is default, then returns <paramref name="other"/>.
|
||||
/// </summary>
|
||||
/// <param name="self">The self.</param>
|
||||
/// <param name="other">The other.</param>
|
||||
/// <returns><paramref name="self"/> if it is not default; otherwise, <paramref name="other"/>.</returns>
|
||||
public static unsafe ImFontPtr OrElse(this ImFontPtr self, ImFontPtr other) =>
|
||||
self.NativePtr is null ? other : self;
|
||||
|
||||
/// <summary>
|
||||
/// Finds the corresponding ImGui viewport ID for the given window handle.
|
||||
/// </summary>
|
||||
|
|
@ -569,15 +578,6 @@ public static class ImGuiHelpers
|
|||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If <paramref name="self"/> is default, then returns <paramref name="other"/>.
|
||||
/// </summary>
|
||||
/// <param name="self">The self.</param>
|
||||
/// <param name="other">The other.</param>
|
||||
/// <returns><paramref name="self"/> if it is not default; otherwise, <paramref name="other"/>.</returns>
|
||||
public static unsafe ImFontPtr OrElse(this ImFontPtr self, ImFontPtr other) =>
|
||||
self.NativePtr is null ? other : self;
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to validate that <paramref name="fontPtr"/> is valid.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue