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.Game.Text;
|
||||||
using Dalamud.Hooking.WndProcHook;
|
using Dalamud.Hooking.WndProcHook;
|
||||||
using Dalamud.Interface.GameFonts;
|
using Dalamud.Interface.GameFonts;
|
||||||
|
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
|
|
||||||
using ImGuiNET;
|
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 (HanRange.Any(x => x.FirstCodePoint <= chr && chr < x.FirstCodePoint + x.Length))
|
||||||
{
|
{
|
||||||
if (Service<GameFontManager>.Get()
|
if (Service<FontAtlasFactory>.Get()
|
||||||
.GetFdtReader(GameFontFamilyAndSize.Axis12)
|
?.GetFdtReader(GameFontFamilyAndSize.Axis12)
|
||||||
?.FindGlyph(chr) is null)
|
.FindGlyph(chr) is null)
|
||||||
{
|
{
|
||||||
if (!this.EncounteredHan)
|
if (!this.EncounteredHan)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -189,16 +189,6 @@ internal class InterfaceManager : IDisposable, IServiceType
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsDispatchingEvents { get; set; } = true;
|
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>
|
/// <summary>
|
||||||
/// Gets a value indicating the native handle of the game main window.
|
/// Gets a value indicating the native handle of the game main window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using CheapLoc;
|
||||||
using Dalamud.Configuration.Internal;
|
using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Interface.Colors;
|
using Dalamud.Interface.Colors;
|
||||||
using Dalamud.Interface.Internal.Windows.Settings.Tabs;
|
using Dalamud.Interface.Internal.Windows.Settings.Tabs;
|
||||||
|
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
using Dalamud.Interface.Utility.Raii;
|
using Dalamud.Interface.Utility.Raii;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
|
|
@ -65,11 +66,12 @@ internal class SettingsWindow : Window
|
||||||
{
|
{
|
||||||
var configuration = Service<DalamudConfiguration>.Get();
|
var configuration = Service<DalamudConfiguration>.Get();
|
||||||
var interfaceManager = Service<InterfaceManager>.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;
|
ImGui.GetIO().FontGlobalScale = configuration.GlobalUiScale;
|
||||||
interfaceManager.UseAxisOverride = null;
|
fontAtlasFactory.UseAxisOverride = null;
|
||||||
|
|
||||||
if (rebuildFont)
|
if (rebuildFont)
|
||||||
interfaceManager.RebuildFonts();
|
interfaceManager.RebuildFonts();
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Interface.Colors;
|
using Dalamud.Interface.Colors;
|
||||||
using Dalamud.Interface.Internal.Windows.PluginInstaller;
|
using Dalamud.Interface.Internal.Windows.PluginInstaller;
|
||||||
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
|
using Dalamud.Interface.Internal.Windows.Settings.Widgets;
|
||||||
|
using Dalamud.Interface.ManagedFontAtlas.Internals;
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
@ -41,9 +42,8 @@ public class SettingsTabLook : SettingsTab
|
||||||
(v, c) => c.UseAxisFontsFromGame = v,
|
(v, c) => c.UseAxisFontsFromGame = v,
|
||||||
v =>
|
v =>
|
||||||
{
|
{
|
||||||
var im = Service<InterfaceManager>.Get();
|
Service<FontAtlasFactory>.Get().UseAxisOverride = v;
|
||||||
im.UseAxisOverride = v;
|
Service<InterfaceManager>.Get().RebuildFonts();
|
||||||
im.RebuildFonts();
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
new GapSettingsEntry(5, true),
|
new GapSettingsEntry(5, true),
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ internal sealed partial class FontAtlasFactory
|
||||||
return fontPtr;
|
return fontPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc cref="IFontAtlasBuildToolkitPreBuild.IsGlobalScaleIgnored"/>
|
||||||
public bool IsGlobalScaleIgnored(ImFontPtr fontPtr) =>
|
public bool IsGlobalScaleIgnored(ImFontPtr fontPtr) =>
|
||||||
this.GlobalScaleExclusions.Contains(fontPtr);
|
this.GlobalScaleExclusions.Contains(fontPtr);
|
||||||
|
|
||||||
|
|
@ -275,7 +275,7 @@ internal sealed partial class FontAtlasFactory
|
||||||
{
|
{
|
||||||
ImFontPtr font;
|
ImFontPtr font;
|
||||||
glyphRanges ??= this.factory.DefaultGlyphRanges;
|
glyphRanges ??= this.factory.DefaultGlyphRanges;
|
||||||
if (Service<InterfaceManager>.Get().UseAxis)
|
if (this.factory.UseAxis)
|
||||||
{
|
{
|
||||||
font = this.AddGameGlyphs(new(GameFontFamily.Axis, sizePx), glyphRanges, default);
|
font = this.AddGameGlyphs(new(GameFontFamily.Axis, sizePx), glyphRanges, default);
|
||||||
}
|
}
|
||||||
|
|
@ -360,7 +360,8 @@ internal sealed partial class FontAtlasFactory
|
||||||
public void AttachExtraGlyphsForDalamudLanguage(in SafeFontConfig fontConfig)
|
public void AttachExtraGlyphsForDalamudLanguage(in SafeFontConfig fontConfig)
|
||||||
{
|
{
|
||||||
var dalamudConfiguration = Service<DalamudConfiguration>.Get();
|
var dalamudConfiguration = Service<DalamudConfiguration>.Get();
|
||||||
if (dalamudConfiguration.EffectiveLanguage == "ko")
|
if (dalamudConfiguration.EffectiveLanguage == "ko"
|
||||||
|
|| Service<DalamudIme>.GetNullable()?.EncounteredHangul is true)
|
||||||
{
|
{
|
||||||
this.AddDalamudAssetFont(
|
this.AddDalamudAssetFont(
|
||||||
DalamudAsset.NotoSansKrRegular,
|
DalamudAsset.NotoSansKrRegular,
|
||||||
|
|
@ -374,6 +375,35 @@ internal sealed partial class FontAtlasFactory
|
||||||
UnicodeRanges.HangulJamoExtendedB),
|
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()
|
public void PreBuildSubstances()
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Data;
|
using Dalamud.Data;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Interface.GameFonts;
|
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>
|
/// <summary>
|
||||||
/// Gets the service instance of <see cref="Framework"/>.
|
/// Gets the service instance of <see cref="Framework"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -548,6 +548,15 @@ public static class ImGuiHelpers
|
||||||
/// <param name="ptr">The pointer.</param>
|
/// <param name="ptr">The pointer.</param>
|
||||||
/// <returns>Whether it is empty.</returns>
|
/// <returns>Whether it is empty.</returns>
|
||||||
public static unsafe bool IsNull(this ImFontAtlasPtr ptr) => ptr.NativePtr == null;
|
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>
|
/// <summary>
|
||||||
/// Finds the corresponding ImGui viewport ID for the given window handle.
|
/// Finds the corresponding ImGui viewport ID for the given window handle.
|
||||||
|
|
@ -569,15 +578,6 @@ public static class ImGuiHelpers
|
||||||
return -1;
|
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>
|
/// <summary>
|
||||||
/// Attempts to validate that <paramref name="fontPtr"/> is valid.
|
/// Attempts to validate that <paramref name="fontPtr"/> is valid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue