From 3496bd5fa3104b86d980097af460fc4b85a83936 Mon Sep 17 00:00:00 2001 From: goaaats Date: Sun, 3 Apr 2022 19:02:32 +0200 Subject: [PATCH 01/15] build: 6.3.0.16 --- Dalamud/Dalamud.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index 7fbd2d4c8..aac9922c8 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -8,7 +8,7 @@ - 6.3.0.15 + 6.3.0.16 XIV Launcher addon framework $(DalamudVersion) $(DalamudVersion) From 31436cabfdcef2ac8c762895fee75da0c093f4d9 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Tue, 5 Apr 2022 15:33:21 +0900 Subject: [PATCH 02/15] Add atlas texture size opportunistic limiter --- .../Internal/DalamudConfiguration.cs | 5 +- .../Interface/GameFonts/GameFontManager.cs | 3 +- Dalamud/Interface/GameFonts/GameFontStyle.cs | 43 ++++++------ .../Interface/Internal/InterfaceManager.cs | 65 ++++++++++++++----- .../Internal/Windows/SettingsWindow.cs | 63 +++++++++++++++--- 5 files changed, 131 insertions(+), 48 deletions(-) diff --git a/Dalamud/Configuration/Internal/DalamudConfiguration.cs b/Dalamud/Configuration/Internal/DalamudConfiguration.cs index e9209e2d0..8975bf1a0 100644 --- a/Dalamud/Configuration/Internal/DalamudConfiguration.cs +++ b/Dalamud/Configuration/Internal/DalamudConfiguration.cs @@ -144,9 +144,10 @@ namespace Dalamud.Configuration.Internal public float FontGamma { get; set; } = 1.4f; /// - /// Gets or sets a value indicating whether to allow big font atlas. + /// Gets or sets a value indicating the level of font resolution between 1 to 5. + /// 0(1024x1024), 1(2048x2048), 2(4096x4096), 3(8192x8192), 4(16384x16384). /// - public bool AllowBigFontAtlas { get; set; } = false; + public int FontResolutionLevel { get; set; } = 2; /// /// Gets or sets a value indicating whether or not plugin UI should be hidden. diff --git a/Dalamud/Interface/GameFonts/GameFontManager.cs b/Dalamud/Interface/GameFonts/GameFontManager.cs index adbe6dfa4..056b22912 100644 --- a/Dalamud/Interface/GameFonts/GameFontManager.cs +++ b/Dalamud/Interface/GameFonts/GameFontManager.cs @@ -289,7 +289,7 @@ namespace Dalamud.Interface.GameFonts ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig(); fontConfig.OversampleH = 1; fontConfig.OversampleV = 1; - fontConfig.PixelSnapH = true; + fontConfig.PixelSnapH = false; var io = ImGui.GetIO(); @@ -305,6 +305,7 @@ namespace Dalamud.Interface.GameFonts continue; var font = io.Fonts.AddFontDefault(fontConfig); + this.fonts[style] = font; foreach (var glyph in fdt.Glyphs) { diff --git a/Dalamud/Interface/GameFonts/GameFontStyle.cs b/Dalamud/Interface/GameFonts/GameFontStyle.cs index 8a713f1cf..8636f128e 100644 --- a/Dalamud/Interface/GameFonts/GameFontStyle.cs +++ b/Dalamud/Interface/GameFonts/GameFontStyle.cs @@ -87,9 +87,9 @@ namespace Dalamud.Interface.GameFonts }; /// - /// Gets the font size. + /// Gets the font size in point unit. /// - public float Size => this.FamilyAndSize switch + public float SizePt => this.FamilyAndSize switch { GameFontFamilyAndSize.Undefined => 0, GameFontFamilyAndSize.Axis96 => 9.6f, @@ -118,6 +118,11 @@ namespace Dalamud.Interface.GameFonts _ => throw new InvalidOperationException(), }; + /// + /// Gets the font size in pixel unit. + /// + public float SizePx => this.SizePt * 4 / 3; + /// /// Gets or sets a value indicating whether this font is bold. /// @@ -153,59 +158,59 @@ namespace Dalamud.Interface.GameFonts return GameFontFamilyAndSize.Undefined; case GameFontFamily.Axis: - if (size <= 9.6) + if (size <= 9.601) return GameFontFamilyAndSize.Axis96; - else if (size <= 12) + else if (size <= 12.001) return GameFontFamilyAndSize.Axis12; - else if (size <= 14) + else if (size <= 14.001) return GameFontFamilyAndSize.Axis14; - else if (size <= 18) + else if (size <= 18.001) return GameFontFamilyAndSize.Axis18; else return GameFontFamilyAndSize.Axis36; case GameFontFamily.Jupiter: - if (size <= 16) + if (size <= 16.001) return GameFontFamilyAndSize.Jupiter16; - else if (size <= 20) + else if (size <= 20.001) return GameFontFamilyAndSize.Jupiter20; - else if (size <= 23) + else if (size <= 23.001) return GameFontFamilyAndSize.Jupiter23; else return GameFontFamilyAndSize.Jupiter46; case GameFontFamily.JupiterNumeric: - if (size <= 45) + if (size <= 45.001) return GameFontFamilyAndSize.Jupiter45; else return GameFontFamilyAndSize.Jupiter90; case GameFontFamily.Meidinger: - if (size <= 16) + if (size <= 16.001) return GameFontFamilyAndSize.Meidinger16; - else if (size <= 20) + else if (size <= 20.001) return GameFontFamilyAndSize.Meidinger20; else return GameFontFamilyAndSize.Meidinger40; case GameFontFamily.MiedingerMid: - if (size <= 10) + if (size <= 10.001) return GameFontFamilyAndSize.MiedingerMid10; - else if (size <= 12) + else if (size <= 12.001) return GameFontFamilyAndSize.MiedingerMid12; - else if (size <= 14) + else if (size <= 14.001) return GameFontFamilyAndSize.MiedingerMid14; - else if (size <= 18) + else if (size <= 18.001) return GameFontFamilyAndSize.MiedingerMid18; else return GameFontFamilyAndSize.MiedingerMid36; case GameFontFamily.TrumpGothic: - if (size <= 18.4) + if (size <= 18.401) return GameFontFamilyAndSize.TrumpGothic184; - else if (size <= 23) + else if (size <= 23.001) return GameFontFamilyAndSize.TrumpGothic23; - else if (size <= 34) + else if (size <= 34.001) return GameFontFamilyAndSize.TrumpGothic34; else return GameFontFamilyAndSize.TrumpGothic68; diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index c19a32601..fee865af3 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -216,14 +216,14 @@ namespace Dalamud.Interface.Internal public float FontGamma => Math.Max(0.1f, this.FontGammaOverride.GetValueOrDefault(Service.Get().FontGamma)); /// - /// Gets or sets a value indicating whether to override configuration for AllowBigFontAtlas. + /// Gets or sets a value indicating whether to override configuration for FontResolutionLevel. /// - public bool? AllowBigFontAtlasOverride { get; set; } = null; + public int? FontResolutionLevelOverride { get; set; } = null; /// - /// Gets a value indicating whether to allow big font atlas. + /// Gets a value indicating the level of font resolution. /// - public bool AllowBigFontAtlas => this.AllowBigFontAtlasOverride ?? Service.Get().AllowBigFontAtlas; + public int FontResolutionLevel => this.FontResolutionLevelOverride ?? Service.Get().FontResolutionLevel; /// /// Enable this module. @@ -594,21 +594,24 @@ namespace Dalamud.Interface.Internal ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.ViewportsEnable; } - private unsafe void SetupFonts() + private unsafe void SetupFonts(int scaler = 0) { var gameFontManager = Service.Get(); var dalamud = Service.Get(); var io = ImGui.GetIO(); var ioFonts = io.Fonts; - var fontLoadScale = this.AllowBigFontAtlas ? io.FontGlobalScale : 1; - var fontGamma = this.FontGamma; List fontsToUnscale = new(); List fontsToOverwriteFromAxis = new(); List fontsToReassignSizes = new(); + var maxTexDimension = 1 << (10 + Math.Max(0, Math.Min(4, this.FontResolutionLevel))); + var disableBigFonts = scaler != 0; + var fontLoadScale = disableBigFonts ? Math.Min(io.FontGlobalScale, 1.0f / scaler) : io.FontGlobalScale; + var fontGamma = this.FontGamma; + this.fontBuildSignal.Reset(); ioFonts.Clear(); - ioFonts.TexDesiredWidth = this.AllowBigFontAtlas ? 4096 : 2048; + ioFonts.TexDesiredWidth = maxTexDimension; Log.Verbose("[FONT] SetupFonts - 1"); @@ -633,7 +636,6 @@ namespace Dalamud.Interface.Internal fontConfig = ImGuiNative.ImFontConfig_ImFontConfig(); fontConfig.OversampleH = 1; fontConfig.OversampleV = 1; - fontConfig.PixelSnapH = true; var fontPathJp = Path.Combine(dalamud.AssetDirectory.FullName, "UIRes", "NotoSansCJKjp-Medium.otf"); if (!File.Exists(fontPathJp)) @@ -641,15 +643,17 @@ namespace Dalamud.Interface.Internal // Default font Log.Verbose("[FONT] SetupFonts - Default font"); - this.axisFontHandles.Add(gameFontManager.NewFontRef(this.AllowBigFontAtlas ? new(GameFontFamily.Axis, DefaultFontSizePt * fontLoadScale) : new(GameFontFamilyAndSize.Axis12))); + this.axisFontHandles.Add(gameFontManager.NewFontRef(new(GameFontFamily.Axis, DefaultFontSizePt * fontLoadScale))); + Log.Verbose("[FONT] SetupFonts - Default corresponding AXIS size: {0}pt ({1}px)", this.axisFontHandles.Last().Style.SizePt, this.axisFontHandles.Last().Style.SizePx); if (this.UseAxis) { fontConfig.GlyphRanges = dummyRangeHandle.AddrOfPinnedObject(); fontConfig.SizePixels = DefaultFontSizePx * fontLoadScale; + fontConfig.PixelSnapH = false; DefaultFont = ioFonts.AddFontDefault(fontConfig); fontsToUnscale.Add(DefaultFont); fontsToOverwriteFromAxis.Add(true); - fontsToReassignSizes.Add(null); + fontsToReassignSizes.Add(disableBigFonts ? DefaultFontSizePx * fontLoadScale : null); } else { @@ -657,6 +661,7 @@ namespace Dalamud.Interface.Internal garbageList.Add(japaneseRangeHandle); fontConfig.GlyphRanges = japaneseRangeHandle.AddrOfPinnedObject(); + fontConfig.PixelSnapH = true; DefaultFont = ioFonts.AddFontFromFileTTF(fontPathJp, (DefaultFontSizePx + 1) * fontLoadScale, fontConfig); fontsToUnscale.Add(DefaultFont); fontsToOverwriteFromAxis.Add(false); @@ -674,6 +679,7 @@ namespace Dalamud.Interface.Internal garbageList.Add(iconRangeHandle); fontConfig.GlyphRanges = iconRangeHandle.AddrOfPinnedObject(); + fontConfig.PixelSnapH = true; IconFont = ioFonts.AddFontFromFileTTF(fontPathIcon, DefaultFontSizePx * fontLoadScale, fontConfig); fontsToUnscale.Add(IconFont); this.axisFontHandles.Add(null); @@ -689,6 +695,7 @@ namespace Dalamud.Interface.Internal ShowFontError(fontPathMono); fontConfig.GlyphRanges = IntPtr.Zero; + fontConfig.PixelSnapH = true; MonoFont = ioFonts.AddFontFromFileTTF(fontPathMono, DefaultFontSizePx * fontLoadScale, fontConfig); fontsToUnscale.Add(MonoFont); this.axisFontHandles.Add(null); @@ -742,24 +749,26 @@ namespace Dalamud.Interface.Internal flattenedRanges.Add(0); ImFontPtr sizedFont; - this.axisFontHandles.Add(gameFontManager.NewFontRef(this.AllowBigFontAtlas ? new(GameFontFamily.Axis, fontSize * 3 / 4 * fontLoadScale) : new(GameFontFamilyAndSize.Axis12))); + this.axisFontHandles.Add(gameFontManager.NewFontRef(new(GameFontFamily.Axis, (disableBigFonts ? DefaultFontSizePt : fontSize * 3 / 4) * fontLoadScale))); if (this.UseAxis) { fontConfig.GlyphRanges = dummyRangeHandle.AddrOfPinnedObject(); - fontConfig.SizePixels = (this.AllowBigFontAtlas ? fontSize : DefaultFontSizePx) * fontLoadScale; + fontConfig.SizePixels = this.axisFontHandles.Last().Style.SizePx; + fontConfig.PixelSnapH = false; sizedFont = ioFonts.AddFontDefault(fontConfig); fontsToUnscale.Add(sizedFont); fontsToOverwriteFromAxis.Add(true); - fontsToReassignSizes.Add(this.AllowBigFontAtlas ? null : fontSize); + fontsToReassignSizes.Add(disableBigFonts ? fontLoadScale * fontSize : null); } else { var rangeHandle = GCHandle.Alloc(flattenedRanges.ToArray(), GCHandleType.Pinned); garbageList.Add(rangeHandle); - sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, (this.AllowBigFontAtlas ? fontSize : DefaultFontSizePx + 1) * fontLoadScale, fontConfig, rangeHandle.AddrOfPinnedObject()); + fontConfig.PixelSnapH = true; + sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, (disableBigFonts ? fontSize : DefaultFontSizePx + 1) * fontLoadScale, fontConfig, rangeHandle.AddrOfPinnedObject()); fontsToUnscale.Add(sizedFont); fontsToOverwriteFromAxis.Add(false); - fontsToReassignSizes.Add(this.AllowBigFontAtlas ? null : fontSize); + fontsToReassignSizes.Add(disableBigFonts ? fontSize : null); } foreach (var request in requests) @@ -769,17 +778,37 @@ namespace Dalamud.Interface.Internal gameFontManager.BuildFonts(); + var customFontFirstConfigIndex = ioFonts.ConfigData.Size; + Log.Verbose("[FONT] Invoke OnBuildFonts"); this.BuildFonts?.Invoke(); Log.Verbose("[FONT] OnBuildFonts OK!"); - for (var i = 0; i < ImGui.GetIO().Fonts.Fonts.Size; i++) + for (int i = customFontFirstConfigIndex, i_ = ioFonts.ConfigData.Size; i < i_; i++) { - Log.Verbose("{0} - {1}", i, ImGui.GetIO().Fonts.Fonts[i].GetDebugName()); + var configPtr = ioFonts.ConfigData[i].NativePtr; + configPtr->OversampleH = 1; + configPtr->OversampleV = 1; + if (disableBigFonts) + configPtr->SizePixels = DefaultFontSizePx * fontLoadScale; } ioFonts.Build(); + if (ioFonts.TexHeight > maxTexDimension) + { + if (scaler < 4) + { + Log.Information("[FONT] Atlas size is {0}x{1} which is bigger than allowed {2}x{3}. Retrying with scale {4}.", ioFonts.TexWidth, ioFonts.TexHeight, maxTexDimension, maxTexDimension, scaler + 1); + this.SetupFonts(scaler + 1); + return; + } + else + { + Log.Warning("[FONT] Atlas size is {0}x{1} which is bigger than allowed {2}x{3}, but giving up trying to scale smaller.", ioFonts.TexWidth, ioFonts.TexHeight, maxTexDimension, maxTexDimension); + } + } + if (Math.Abs(fontGamma - 1.0f) >= 0.001) { // Gamma correction (stbtt/FreeType would output in linear space whereas most real world usages will apply 1.4 or 1.8 gamma; Windows/XIV prebaked uses 1.4) diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index b1f212d49..69202c523 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -38,9 +38,11 @@ namespace Dalamud.Interface.Internal.Windows private bool doCfChatMessage; private bool doMbCollect; + private readonly string[] fontResolutionLevelStrings; + private int fontResolutionLevel; + private float globalUiScale; private bool doUseAxisFontsFromGame; - private bool doAllowBigFontAtlas; private float fontGamma; private bool doToggleUiHide; private bool doToggleUiHideDuringCutscenes; @@ -97,7 +99,7 @@ namespace Dalamud.Interface.Internal.Windows this.globalUiScale = configuration.GlobalUiScale; this.fontGamma = configuration.FontGamma; this.doUseAxisFontsFromGame = configuration.UseAxisFontsFromGame; - this.doAllowBigFontAtlas = configuration.AllowBigFontAtlas; + this.fontResolutionLevel = configuration.FontResolutionLevel; this.doToggleUiHide = configuration.ToggleUiHide; this.doToggleUiHideDuringCutscenes = configuration.ToggleUiHideDuringCutscenes; this.doToggleUiHideDuringGpose = configuration.ToggleUiHideDuringGpose; @@ -120,6 +122,15 @@ namespace Dalamud.Interface.Internal.Windows this.doButtonsSystemMenu = configuration.DoButtonsSystemMenu; this.disableRmtFiltering = configuration.DisableRmtFiltering; + this.fontResolutionLevelStrings = new string[] + { + Loc.Localize("DalamudSettingsFontResolutionLevel0", "Least (1k x 1k texture)"), + Loc.Localize("DalamudSettingsFontResolutionLevel1", "Lesser (2k x 2k texture)"), + Loc.Localize("DalamudSettingsFontResolutionLevel2", "Normal (4k x 4k texture)"), + Loc.Localize("DalamudSettingsFontResolutionLevel3", "Better (8k x 8k texture)"), + Loc.Localize("DalamudSettingsFontResolutionLevel4", "Best (16k x 16k texture)"), + }; + this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray(); try { @@ -188,7 +199,7 @@ namespace Dalamud.Interface.Internal.Windows ImGui.GetIO().FontGlobalScale = configuration.GlobalUiScale; interfaceManager.FontGammaOverride = null; - interfaceManager.AllowBigFontAtlasOverride = null; + interfaceManager.FontResolutionLevelOverride = null; interfaceManager.UseAxisOverride = null; this.thirdRepoList = configuration.ThirdRepoList.Select(x => x.Clone()).ToList(); this.devPluginLocations = configuration.DevPluginLoadLocations.Select(x => x.Clone()).ToList(); @@ -296,13 +307,45 @@ namespace Dalamud.Interface.Internal.Windows ImGui.Text(Loc.Localize("DalamudSettingsGlobalUiScale", "Global UI Scale")); ImGui.SameLine(); ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 3); - if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "Reset") + "##DalamudSettingsGlobalUiScaleReset")) + if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "9.6pt") + "##DalamudSettingsGlobalUiScaleReset96")) + { + this.globalUiScale = 9.6f / 12.0f; + ImGui.GetIO().FontGlobalScale = this.globalUiScale; + interfaceManager.RebuildFonts(); + } + + ImGui.SameLine(); + if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "Reset (12pt)") + "##DalamudSettingsGlobalUiScaleReset12")) { this.globalUiScale = 1.0f; ImGui.GetIO().FontGlobalScale = this.globalUiScale; interfaceManager.RebuildFonts(); } + ImGui.SameLine(); + if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "14pt") + "##DalamudSettingsGlobalUiScaleReset14")) + { + this.globalUiScale = 14.0f / 12.0f; + ImGui.GetIO().FontGlobalScale = this.globalUiScale; + interfaceManager.RebuildFonts(); + } + + ImGui.SameLine(); + if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "18pt") + "##DalamudSettingsGlobalUiScaleReset18")) + { + this.globalUiScale = 18.0f / 12.0f; + ImGui.GetIO().FontGlobalScale = this.globalUiScale; + interfaceManager.RebuildFonts(); + } + + ImGui.SameLine(); + if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "36pt") + "##DalamudSettingsGlobalUiScaleReset36")) + { + this.globalUiScale = 36.0f / 12.0f; + ImGui.GetIO().FontGlobalScale = this.globalUiScale; + interfaceManager.RebuildFonts(); + } + if (ImGui.DragFloat("##DalamudSettingsGlobalUiScaleDrag", ref this.globalUiScale, 0.005f, MinScale, MaxScale, "%.2f")) { ImGui.GetIO().FontGlobalScale = this.globalUiScale; @@ -332,13 +375,17 @@ namespace Dalamud.Interface.Internal.Windows ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingToggleUiAxisFontsHint", "Use AXIS fonts (the game's main UI fonts) as default Dalamud font.")); - if (ImGui.Checkbox(Loc.Localize("DalamudSettingAllowBigFontAtlas", "Allow big font atlas"), ref this.doAllowBigFontAtlas)) + ImGui.Text(Loc.Localize("DalamudSettingsFontResolutionLevel", "Font resolution level")); + if (ImGui.Combo("##DalamudSettingsFontResolutionLevelCombo", ref this.fontResolutionLevel, this.fontResolutionLevelStrings, this.fontResolutionLevelStrings.Length)) { - interfaceManager.AllowBigFontAtlasOverride = this.doAllowBigFontAtlas; + interfaceManager.FontResolutionLevelOverride = this.fontResolutionLevel; interfaceManager.RebuildFonts(); } - ImGui.TextColored(ImGuiColors.DalamudGrey, string.Format(Loc.Localize("DalamudSettingAllowBigFontAtlas", "Displays text crisply, but may crash if your GPU does not support it.\nCurrent size: {0}px * {1}px"), ImGui.GetIO().Fonts.TexWidth, ImGui.GetIO().Fonts.TexHeight)); + ImGui.TextColored(ImGuiColors.DalamudGrey, string.Format( + Loc.Localize("DalamudSettingsFontResolutionLevel", "Your PC may not support loading all font into memory at maximum sizes, and it may crash. Adjust this option to try to show more crisp text.\nCurrent font atlas size is {0}px * {1}px."), + ImGui.GetIO().Fonts.TexWidth, + ImGui.GetIO().Fonts.TexHeight)); ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off"), ref this.doToggleUiHide); ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingToggleUiHideHint", "Hide any open windows by plugins when toggling the game overlay.")); @@ -867,7 +914,7 @@ namespace Dalamud.Interface.Internal.Windows configuration.ShowTsm = this.doTsm; configuration.UseAxisFontsFromGame = this.doUseAxisFontsFromGame; - configuration.AllowBigFontAtlas = this.doAllowBigFontAtlas; + configuration.FontResolutionLevel = this.fontResolutionLevel; configuration.FontGamma = this.fontGamma; // This is applied every frame in InterfaceManager::CheckViewportState() From a21cdc3eaa33b586ba4df6cbee114b67a9d68fd8 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Tue, 5 Apr 2022 15:47:27 +0900 Subject: [PATCH 03/15] Fix minor scaling bug --- Dalamud/Interface/Internal/InterfaceManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index fee865af3..3f6e65a1d 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -653,7 +653,7 @@ namespace Dalamud.Interface.Internal DefaultFont = ioFonts.AddFontDefault(fontConfig); fontsToUnscale.Add(DefaultFont); fontsToOverwriteFromAxis.Add(true); - fontsToReassignSizes.Add(disableBigFonts ? DefaultFontSizePx * fontLoadScale : null); + fontsToReassignSizes.Add(disableBigFonts ? DefaultFontSizePx : null); } else { @@ -758,14 +758,14 @@ namespace Dalamud.Interface.Internal sizedFont = ioFonts.AddFontDefault(fontConfig); fontsToUnscale.Add(sizedFont); fontsToOverwriteFromAxis.Add(true); - fontsToReassignSizes.Add(disableBigFonts ? fontLoadScale * fontSize : null); + fontsToReassignSizes.Add(disableBigFonts ? fontSize : null); } else { var rangeHandle = GCHandle.Alloc(flattenedRanges.ToArray(), GCHandleType.Pinned); garbageList.Add(rangeHandle); fontConfig.PixelSnapH = true; - sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, (disableBigFonts ? fontSize : DefaultFontSizePx + 1) * fontLoadScale, fontConfig, rangeHandle.AddrOfPinnedObject()); + sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, (disableBigFonts ? DefaultFontSizePx + 1 : fontSize) * fontLoadScale, fontConfig, rangeHandle.AddrOfPinnedObject()); fontsToUnscale.Add(sizedFont); fontsToOverwriteFromAxis.Add(false); fontsToReassignSizes.Add(disableBigFonts ? fontSize : null); @@ -849,7 +849,7 @@ namespace Dalamud.Interface.Internal } if (overwriteSize != null) - scale *= overwriteSize.Value / fontPtr->ConfigData->SizePixels; + scale *= fontLoadScale * overwriteSize.Value / fontPtr->ConfigData->SizePixels; if (scale != 1f) GameFontManager.UnscaleFont(font, 1 / scale, false); From 32ff56a3c5ae948b5340e243bdce02ee1e3789f4 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Tue, 5 Apr 2022 15:58:11 +0900 Subject: [PATCH 04/15] Warn about possible crashes --- Dalamud/Interface/Internal/Windows/SettingsWindow.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index 69202c523..a8aaa8e86 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -127,8 +127,8 @@ namespace Dalamud.Interface.Internal.Windows Loc.Localize("DalamudSettingsFontResolutionLevel0", "Least (1k x 1k texture)"), Loc.Localize("DalamudSettingsFontResolutionLevel1", "Lesser (2k x 2k texture)"), Loc.Localize("DalamudSettingsFontResolutionLevel2", "Normal (4k x 4k texture)"), - Loc.Localize("DalamudSettingsFontResolutionLevel3", "Better (8k x 8k texture)"), - Loc.Localize("DalamudSettingsFontResolutionLevel4", "Best (16k x 16k texture)"), + Loc.Localize("DalamudSettingsFontResolutionLevel3", "Better (8k x 8k texture, may crash your game)"), + Loc.Localize("DalamudSettingsFontResolutionLevel4", "Best (16k x 16k texture, may crash your game)"), }; this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray(); From 040a96e36b93d11651517b9378ae43560a8d695b Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 5 Apr 2022 18:14:15 +0200 Subject: [PATCH 05/15] chore: fix defaults for Universalis --- Dalamud/Configuration/Internal/DalamudConfiguration.cs | 2 +- Dalamud/Game/Network/Internal/NetworkHandlers.cs | 4 ++-- Dalamud/Interface/Internal/Windows/SettingsWindow.cs | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Dalamud/Configuration/Internal/DalamudConfiguration.cs b/Dalamud/Configuration/Internal/DalamudConfiguration.cs index e9209e2d0..de82d901a 100644 --- a/Dalamud/Configuration/Internal/DalamudConfiguration.cs +++ b/Dalamud/Configuration/Internal/DalamudConfiguration.cs @@ -298,7 +298,7 @@ namespace Dalamud.Configuration.Internal /// /// Gets or sets a value indicating whether or not market board data should be uploaded. /// - public bool DoMbCollect { get; set; } = false; + public bool IsMbCollect { get; set; } = true; /// /// Load a configuration from the provided path. diff --git a/Dalamud/Game/Network/Internal/NetworkHandlers.cs b/Dalamud/Game/Network/Internal/NetworkHandlers.cs index 8220a1473..e93d1164b 100644 --- a/Dalamud/Game/Network/Internal/NetworkHandlers.cs +++ b/Dalamud/Game/Network/Internal/NetworkHandlers.cs @@ -55,7 +55,7 @@ namespace Dalamud.Game.Network.Internal if (direction == NetworkMessageDirection.ZoneUp) { - if (configuration.DoMbCollect) + if (configuration.IsMbCollect) { if (opCode == dataManager.ClientOpCodes["MarketBoardPurchaseHandler"]) { @@ -73,7 +73,7 @@ namespace Dalamud.Game.Network.Internal return; } - if (configuration.DoMbCollect) + if (configuration.IsMbCollect) { if (opCode == dataManager.ServerOpCodes["MarketBoardItemRequestStart"]) { diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index b1f212d49..b8f2df1ae 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -92,7 +92,7 @@ namespace Dalamud.Interface.Internal.Windows this.doCfTaskBarFlash = configuration.DutyFinderTaskbarFlash; this.doCfChatMessage = configuration.DutyFinderChatMessage; - this.doMbCollect = configuration.DoMbCollect; + this.doMbCollect = configuration.IsMbCollect; this.globalUiScale = configuration.GlobalUiScale; this.fontGamma = configuration.FontGamma; @@ -284,6 +284,8 @@ namespace Dalamud.Interface.Internal.Windows ImGui.Checkbox(Loc.Localize("DalamudSettingsDisableRmtFiltering", "Disable RMT Filtering"), ref this.disableRmtFiltering); ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsDisableRmtFilteringMsgHint", "Disable dalamud's built-in RMT ad filtering.")); + ImGuiHelpers.ScaledDummy(5); + ImGui.Checkbox(Loc.Localize("DalamudSettingDoMbCollect", "Anonymously upload market board data"), ref this.doMbCollect); ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingDoMbCollectHint", "Anonymously provide data about in-game economics to Universalis when browsing the market board. This data can't be tied to you in any way and everyone benefits!")); } @@ -854,7 +856,7 @@ namespace Dalamud.Interface.Internal.Windows configuration.DutyFinderTaskbarFlash = this.doCfTaskBarFlash; configuration.DutyFinderChatMessage = this.doCfChatMessage; - configuration.DoMbCollect = this.doMbCollect; + configuration.IsMbCollect = this.doMbCollect; configuration.GlobalUiScale = this.globalUiScale; configuration.ToggleUiHide = this.doToggleUiHide; From 9dc8b62989cc5e172e3b59232ec64893032f25d7 Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 5 Apr 2022 18:24:09 +0200 Subject: [PATCH 06/15] chore: adjust text in settings, fix string id collisions --- .../Interface/Internal/Windows/SettingsWindow.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index 43d90cc68..cf21917ce 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -306,10 +306,10 @@ namespace Dalamud.Interface.Internal.Windows var interfaceManager = Service.Get(); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3); - ImGui.Text(Loc.Localize("DalamudSettingsGlobalUiScale", "Global UI Scale")); + ImGui.Text(Loc.Localize("DalamudSettingsGlobalUiScale", "Global Font Scale")); ImGui.SameLine(); ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 3); - if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "9.6pt") + "##DalamudSettingsGlobalUiScaleReset96")) + if (ImGui.Button(Loc.Localize("DalamudSettingsUiScalePreset6", "9.6pt") + "##DalamudSettingsGlobalUiScaleReset96")) { this.globalUiScale = 9.6f / 12.0f; ImGui.GetIO().FontGlobalScale = this.globalUiScale; @@ -317,7 +317,7 @@ namespace Dalamud.Interface.Internal.Windows } ImGui.SameLine(); - if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "Reset (12pt)") + "##DalamudSettingsGlobalUiScaleReset12")) + if (ImGui.Button(Loc.Localize("DalamudSettingsUiScalePreset12", "Reset (12pt)") + "##DalamudSettingsGlobalUiScaleReset12")) { this.globalUiScale = 1.0f; ImGui.GetIO().FontGlobalScale = this.globalUiScale; @@ -325,7 +325,7 @@ namespace Dalamud.Interface.Internal.Windows } ImGui.SameLine(); - if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "14pt") + "##DalamudSettingsGlobalUiScaleReset14")) + if (ImGui.Button(Loc.Localize("DalamudSettingsUiScalePreset14", "14pt") + "##DalamudSettingsGlobalUiScaleReset14")) { this.globalUiScale = 14.0f / 12.0f; ImGui.GetIO().FontGlobalScale = this.globalUiScale; @@ -333,7 +333,7 @@ namespace Dalamud.Interface.Internal.Windows } ImGui.SameLine(); - if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "18pt") + "##DalamudSettingsGlobalUiScaleReset18")) + if (ImGui.Button(Loc.Localize("DalamudSettingsUiScalePreset18", "18pt") + "##DalamudSettingsGlobalUiScaleReset18")) { this.globalUiScale = 18.0f / 12.0f; ImGui.GetIO().FontGlobalScale = this.globalUiScale; @@ -341,7 +341,7 @@ namespace Dalamud.Interface.Internal.Windows } ImGui.SameLine(); - if (ImGui.Button(Loc.Localize("DalamudSettingsIndividualConfigResetToDefaultValue", "36pt") + "##DalamudSettingsGlobalUiScaleReset36")) + if (ImGui.Button(Loc.Localize("DalamudSettingsUiScalePreset36", "36pt") + "##DalamudSettingsGlobalUiScaleReset36")) { this.globalUiScale = 36.0f / 12.0f; ImGui.GetIO().FontGlobalScale = this.globalUiScale; @@ -354,7 +354,7 @@ namespace Dalamud.Interface.Internal.Windows interfaceManager.RebuildFonts(); } - ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsGlobalUiScaleHint", "Scale all XIVLauncher UI elements - useful for 4K displays.")); + ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsGlobalUiScaleHint", "Scale text in all XIVLauncher UI elements - this is useful for 4K displays.")); ImGuiHelpers.ScaledDummy(10, 16); @@ -385,7 +385,7 @@ namespace Dalamud.Interface.Internal.Windows } ImGui.TextColored(ImGuiColors.DalamudGrey, string.Format( - Loc.Localize("DalamudSettingsFontResolutionLevel", "Your PC may not support loading all font into memory at maximum sizes, and it may crash. Adjust this option to try to show more crisp text.\nCurrent font atlas size is {0}px * {1}px."), + Loc.Localize("DalamudSettingsFontResolutionLevel", "This option allows Dalamud fonts to look better. If your game crashes when changing this option, your PC does not support high font resolutions in Dalamud - you will have to use a lower one.\nCurrent font atlas size is {0}px * {1}px."), ImGui.GetIO().Fonts.TexWidth, ImGui.GetIO().Fonts.TexHeight)); From 7bde86422104eb30a87291be525b55924ba26326 Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 5 Apr 2022 18:27:15 +0200 Subject: [PATCH 07/15] chore: fix warnings --- Dalamud/Interface/Internal/Windows/SettingsWindow.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index cf21917ce..f0f3911a0 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -30,6 +30,9 @@ namespace Dalamud.Interface.Internal.Windows private readonly string[] languages; private readonly string[] locLanguages; + + private readonly string[] fontResolutionLevelStrings; + private int langIndex; private XivChatType dalamudMessagesChatType; @@ -38,7 +41,6 @@ namespace Dalamud.Interface.Internal.Windows private bool doCfChatMessage; private bool doMbCollect; - private readonly string[] fontResolutionLevelStrings; private int fontResolutionLevel; private float globalUiScale; @@ -122,7 +124,7 @@ namespace Dalamud.Interface.Internal.Windows this.doButtonsSystemMenu = configuration.DoButtonsSystemMenu; this.disableRmtFiltering = configuration.DisableRmtFiltering; - this.fontResolutionLevelStrings = new string[] + this.fontResolutionLevelStrings = new[] { Loc.Localize("DalamudSettingsFontResolutionLevel0", "Least (1k x 1k texture)"), Loc.Localize("DalamudSettingsFontResolutionLevel1", "Lesser (2k x 2k texture)"), From fd7187f2631669870a8b9a02760d19ce5e21c2a1 Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 5 Apr 2022 18:27:47 +0200 Subject: [PATCH 08/15] build: 6.3.0.17 --- Dalamud/Dalamud.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index aac9922c8..8c3948a05 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -8,7 +8,7 @@ - 6.3.0.16 + 6.3.0.17 XIV Launcher addon framework $(DalamudVersion) $(DalamudVersion) From 7b4979ef810a35c784b7918c02d96518470bd1d5 Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 5 Apr 2022 18:38:44 +0200 Subject: [PATCH 09/15] chore: reorder settings some more --- .../Internal/Windows/SettingsWindow.cs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index f0f3911a0..27b0ba7c1 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -217,7 +217,7 @@ namespace Dalamud.Interface.Internal.Windows public override void Draw() { var windowSize = ImGui.GetWindowSize(); - ImGui.BeginChild("scrolling", new Vector2(windowSize.X - 5 - (5 * ImGuiHelpers.GlobalScale), windowSize.Y - 35 - (35 * ImGuiHelpers.GlobalScale)), false, ImGuiWindowFlags.HorizontalScrollbar); + ImGui.BeginChild("scrolling", new Vector2(windowSize.X - 5 - (5 * ImGuiHelpers.GlobalScale), windowSize.Y - 35 - (35 * ImGuiHelpers.GlobalScale)), false); if (ImGui.BeginTabBar("SetTabBar")) { @@ -300,7 +300,10 @@ namespace Dalamud.Interface.Internal.Windows ImGuiHelpers.ScaledDummy(5); ImGui.Checkbox(Loc.Localize("DalamudSettingDoMbCollect", "Anonymously upload market board data"), ref this.doMbCollect); - ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingDoMbCollectHint", "Anonymously provide data about in-game economics to Universalis when browsing the market board. This data can't be tied to you in any way and everyone benefits!")); + + ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudGrey); + ImGui.TextWrapped(Loc.Localize("DalamudSettingDoMbCollectHint", "Anonymously provide data about in-game economics to Universalis when browsing the market board. This data can't be tied to you in any way and everyone benefits!")); + ImGui.PopStyleColor(); } private void DrawLookAndFeelTab() @@ -367,9 +370,7 @@ namespace Dalamud.Interface.Internal.Windows ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsStyleEditorHint", "Modify the look & feel of Dalamud windows.")); - ImGuiHelpers.ScaledDummy(10, 16); - - ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingToggleUiHideOptOutNote", "Plugins may independently opt out of the settings below.")); + ImGuiHelpers.ScaledDummy(10); if (ImGui.Checkbox(Loc.Localize("DalamudSettingToggleAxisFonts", "Use AXIS fonts as default Dalamud font"), ref this.doUseAxisFontsFromGame)) { @@ -379,6 +380,8 @@ namespace Dalamud.Interface.Internal.Windows ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingToggleUiAxisFontsHint", "Use AXIS fonts (the game's main UI fonts) as default Dalamud font.")); + ImGuiHelpers.ScaledDummy(3); + ImGui.Text(Loc.Localize("DalamudSettingsFontResolutionLevel", "Font resolution level")); if (ImGui.Combo("##DalamudSettingsFontResolutionLevelCombo", ref this.fontResolutionLevel, this.fontResolutionLevelStrings, this.fontResolutionLevelStrings.Length)) { @@ -386,10 +389,18 @@ namespace Dalamud.Interface.Internal.Windows interfaceManager.RebuildFonts(); } - ImGui.TextColored(ImGuiColors.DalamudGrey, string.Format( + ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudGrey); + ImGui.TextWrapped(string.Format( Loc.Localize("DalamudSettingsFontResolutionLevel", "This option allows Dalamud fonts to look better. If your game crashes when changing this option, your PC does not support high font resolutions in Dalamud - you will have to use a lower one.\nCurrent font atlas size is {0}px * {1}px."), ImGui.GetIO().Fonts.TexWidth, ImGui.GetIO().Fonts.TexHeight)); + ImGui.PopStyleColor(); + + ImGuiHelpers.ScaledDummy(10); + + ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingToggleUiHideOptOutNote", "Plugins may independently opt out of the settings below.")); + + ImGuiHelpers.ScaledDummy(3); ImGui.Checkbox(Loc.Localize("DalamudSettingToggleUiHide", "Hide plugin UI when the game UI is toggled off"), ref this.doToggleUiHide); ImGui.TextColored(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingToggleUiHideHint", "Hide any open windows by plugins when toggling the game overlay.")); From a1e0727d01d375fc77bcb8956c7f211e8e67e25b Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 5 Apr 2022 18:39:13 +0200 Subject: [PATCH 10/15] build: 6.3.0.18 --- Dalamud/Dalamud.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index 8c3948a05..7000fda4a 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -8,7 +8,7 @@ - 6.3.0.17 + 6.3.0.18 XIV Launcher addon framework $(DalamudVersion) $(DalamudVersion) From 1c136539d837cf8ea6a3b0d9be0c62139c76d1b5 Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 5 Apr 2022 19:15:27 +0200 Subject: [PATCH 11/15] chore: fix another doubled up string key --- Dalamud/Interface/Internal/Windows/SettingsWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index 27b0ba7c1..1fc8a4586 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -391,7 +391,7 @@ namespace Dalamud.Interface.Internal.Windows ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudGrey); ImGui.TextWrapped(string.Format( - Loc.Localize("DalamudSettingsFontResolutionLevel", "This option allows Dalamud fonts to look better. If your game crashes when changing this option, your PC does not support high font resolutions in Dalamud - you will have to use a lower one.\nCurrent font atlas size is {0}px * {1}px."), + Loc.Localize("DalamudSettingsFontResolutionLevelHint", "This option allows Dalamud fonts to look better. If your game crashes when changing this option, your PC does not support high font resolutions in Dalamud - you will have to use a lower one.\nCurrent font atlas size is {0}px * {1}px."), ImGui.GetIO().Fonts.TexWidth, ImGui.GetIO().Fonts.TexHeight)); ImGui.PopStyleColor(); From b7a1303829150bc9aac0cc1aa2f908caf61cf809 Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 6 Apr 2022 02:23:32 +0200 Subject: [PATCH 12/15] chore: fix bad sentence structure in PluginInstallerWindow --- .../Internal/Windows/PluginInstaller/PluginInstallerWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index 45e5adb03..265dcb58d 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -2389,7 +2389,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller public static string FeedbackModal_Title => Loc.Localize("InstallerFeedback", "Send Feedback"); - public static string FeedbackModal_Text(string pluginName) => Loc.Localize("InstallerFeedbackInfo", "You can send feedback to the developer of \"{0}\" here.\nYou can include your Discord tag or email address if you wish to give them the opportunity to answer.\n\nIf you want to report an error with the problem, we recommend you to join the XIVLauncher discord server.").Format(pluginName); + public static string FeedbackModal_Text(string pluginName) => Loc.Localize("InstallerFeedbackInfo", "You can send feedback to the developer of \"{0}\" here.\nYou can include your Discord tag or email address if you wish to give them the opportunity to answer.\n\nIf you put your Discord name into the contact information field, please join the XIVLauncher discord server so we can get in touch.").Format(pluginName); public static string FeedbackModal_HasUpdate => Loc.Localize("InstallerFeedbackHasUpdate", "A new version of this plugin is available, please update before reporting bugs."); From a97fc42d1e7c6d70a1f503dc816aa3b148c68b43 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Thu, 7 Apr 2022 10:40:50 +0900 Subject: [PATCH 13/15] Fix font size problems --- .../Interface/GameFonts/GameFontManager.cs | 3 + .../Interface/Internal/InterfaceManager.cs | 190 ++++++++++-------- 2 files changed, 104 insertions(+), 89 deletions(-) diff --git a/Dalamud/Interface/GameFonts/GameFontManager.cs b/Dalamud/Interface/GameFonts/GameFontManager.cs index 056b22912..a376f508b 100644 --- a/Dalamud/Interface/GameFonts/GameFontManager.cs +++ b/Dalamud/Interface/GameFonts/GameFontManager.cs @@ -177,6 +177,9 @@ namespace Dalamud.Interface.GameFonts /// Whether to call target.BuildLookupTable(). public static void UnscaleFont(ImFontPtr fontPtr, float fontScale, bool rebuildLookupTable = true) { + if (fontScale == 1) + return; + unsafe { var font = fontPtr.NativePtr; diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index 3f6e65a1d..67a7027b3 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -55,7 +55,7 @@ namespace Dalamud.Interface.Internal private readonly string rtssPath; private readonly HashSet glyphRequests = new(); - private readonly List axisFontHandles = new(); + private readonly Dictionary loadedFontInfo = new(); private readonly Hook presentHook; private readonly Hook resizeBuffersHook; @@ -594,15 +594,48 @@ namespace Dalamud.Interface.Internal ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.ViewportsEnable; } + private unsafe class TargetFontModification : IDisposable + { + internal TargetFontModification(string name, AxisMode axis, float sizePx, float scale) + { + this.Name = name; + this.Axis = axis; + this.TargetSizePx = sizePx; + this.Scale = scale; + this.SourceAxis = Service.Get().NewFontRef(new(GameFontFamily.Axis, sizePx * scale * 3 / 4)); + } + + internal enum AxisMode + { + Suppress, + GameGlyphsOnly, + Overwrite, + } + + internal string Name { get; private init; } + + internal AxisMode Axis { get; private init; } + + internal float TargetSizePx { get; private init; } + + internal float Scale { get; private init; } + + internal GameFontHandle? SourceAxis { get; private init; } + + internal bool SourceAxisAvailable => this.SourceAxis != null && this.SourceAxis.ImFont.NativePtr != null; + + public void Dispose() + { + this.SourceAxis?.Dispose(); + } + } + private unsafe void SetupFonts(int scaler = 0) { var gameFontManager = Service.Get(); var dalamud = Service.Get(); var io = ImGui.GetIO(); var ioFonts = io.Fonts; - List fontsToUnscale = new(); - List fontsToOverwriteFromAxis = new(); - List fontsToReassignSizes = new(); var maxTexDimension = 1 << (10 + Math.Max(0, Math.Min(4, this.FontResolutionLevel))); var disableBigFonts = scaler != 0; @@ -615,13 +648,10 @@ namespace Dalamud.Interface.Internal Log.Verbose("[FONT] SetupFonts - 1"); - foreach (var v in this.axisFontHandles) - { - if (v != null) - v.Dispose(); - } + foreach (var v in this.loadedFontInfo) + v.Value.Dispose(); - this.axisFontHandles.Clear(); + this.loadedFontInfo.Clear(); Log.Verbose("[FONT] SetupFonts - 2"); @@ -643,17 +673,19 @@ namespace Dalamud.Interface.Internal // Default font Log.Verbose("[FONT] SetupFonts - Default font"); - this.axisFontHandles.Add(gameFontManager.NewFontRef(new(GameFontFamily.Axis, DefaultFontSizePt * fontLoadScale))); - Log.Verbose("[FONT] SetupFonts - Default corresponding AXIS size: {0}pt ({1}px)", this.axisFontHandles.Last().Style.SizePt, this.axisFontHandles.Last().Style.SizePx); + var fontInfo = new TargetFontModification( + "Default", + this.UseAxis ? TargetFontModification.AxisMode.Overwrite : TargetFontModification.AxisMode.GameGlyphsOnly, + this.UseAxis ? DefaultFontSizePx : DefaultFontSizePx + 1, + fontLoadScale); + Log.Verbose("[FONT] SetupFonts - Default corresponding AXIS size: {0}pt ({1}px)", fontInfo.SourceAxis.Style.SizePt, fontInfo.SourceAxis.Style.SizePx); if (this.UseAxis) { fontConfig.GlyphRanges = dummyRangeHandle.AddrOfPinnedObject(); - fontConfig.SizePixels = DefaultFontSizePx * fontLoadScale; + fontConfig.SizePixels = fontInfo.TargetSizePx; fontConfig.PixelSnapH = false; DefaultFont = ioFonts.AddFontDefault(fontConfig); - fontsToUnscale.Add(DefaultFont); - fontsToOverwriteFromAxis.Add(true); - fontsToReassignSizes.Add(disableBigFonts ? DefaultFontSizePx : null); + this.loadedFontInfo[DefaultFont] = fontInfo; } else { @@ -662,10 +694,8 @@ namespace Dalamud.Interface.Internal fontConfig.GlyphRanges = japaneseRangeHandle.AddrOfPinnedObject(); fontConfig.PixelSnapH = true; - DefaultFont = ioFonts.AddFontFromFileTTF(fontPathJp, (DefaultFontSizePx + 1) * fontLoadScale, fontConfig); - fontsToUnscale.Add(DefaultFont); - fontsToOverwriteFromAxis.Add(false); - fontsToReassignSizes.Add(null); + DefaultFont = ioFonts.AddFontFromFileTTF(fontPathJp, fontInfo.TargetSizePx * fontLoadScale, fontConfig); + this.loadedFontInfo[DefaultFont] = fontInfo; } // FontAwesome icon font @@ -681,10 +711,7 @@ namespace Dalamud.Interface.Internal fontConfig.GlyphRanges = iconRangeHandle.AddrOfPinnedObject(); fontConfig.PixelSnapH = true; IconFont = ioFonts.AddFontFromFileTTF(fontPathIcon, DefaultFontSizePx * fontLoadScale, fontConfig); - fontsToUnscale.Add(IconFont); - this.axisFontHandles.Add(null); - fontsToOverwriteFromAxis.Add(false); - fontsToReassignSizes.Add(null); + this.loadedFontInfo[IconFont] = new("Icon", TargetFontModification.AxisMode.GameGlyphsOnly, DefaultFontSizePx, fontLoadScale); } // Monospace font @@ -697,10 +724,7 @@ namespace Dalamud.Interface.Internal fontConfig.GlyphRanges = IntPtr.Zero; fontConfig.PixelSnapH = true; MonoFont = ioFonts.AddFontFromFileTTF(fontPathMono, DefaultFontSizePx * fontLoadScale, fontConfig); - fontsToUnscale.Add(MonoFont); - this.axisFontHandles.Add(null); - fontsToOverwriteFromAxis.Add(false); - fontsToReassignSizes.Add(null); + this.loadedFontInfo[MonoFont] = new("Mono", TargetFontModification.AxisMode.GameGlyphsOnly, DefaultFontSizePx, fontLoadScale); } // Default font but in requested size for requested glyphs @@ -748,31 +772,33 @@ namespace Dalamud.Interface.Internal flattenedRanges.Add(0); - ImFontPtr sizedFont; - this.axisFontHandles.Add(gameFontManager.NewFontRef(new(GameFontFamily.Axis, (disableBigFonts ? DefaultFontSizePt : fontSize * 3 / 4) * fontLoadScale))); + fontInfo = new( + $"Requested({fontSize}px)", + this.UseAxis ? TargetFontModification.AxisMode.Overwrite : TargetFontModification.AxisMode.GameGlyphsOnly, + fontSize, + fontLoadScale); if (this.UseAxis) { fontConfig.GlyphRanges = dummyRangeHandle.AddrOfPinnedObject(); - fontConfig.SizePixels = this.axisFontHandles.Last().Style.SizePx; + fontConfig.SizePixels = fontInfo.SourceAxis.Style.SizePx; fontConfig.PixelSnapH = false; - sizedFont = ioFonts.AddFontDefault(fontConfig); - fontsToUnscale.Add(sizedFont); - fontsToOverwriteFromAxis.Add(true); - fontsToReassignSizes.Add(disableBigFonts ? fontSize : null); + + var sizedFont = ioFonts.AddFontDefault(fontConfig); + this.loadedFontInfo[sizedFont] = fontInfo; + foreach (var request in requests) + request.FontInternal = sizedFont; } else { var rangeHandle = GCHandle.Alloc(flattenedRanges.ToArray(), GCHandleType.Pinned); garbageList.Add(rangeHandle); fontConfig.PixelSnapH = true; - sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, (disableBigFonts ? DefaultFontSizePx + 1 : fontSize) * fontLoadScale, fontConfig, rangeHandle.AddrOfPinnedObject()); - fontsToUnscale.Add(sizedFont); - fontsToOverwriteFromAxis.Add(false); - fontsToReassignSizes.Add(disableBigFonts ? fontSize : null); - } - foreach (var request in requests) - request.FontInternal = sizedFont; + var sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, (disableBigFonts ? DefaultFontSizePx + 1 : fontSize) * fontLoadScale, fontConfig, rangeHandle.AddrOfPinnedObject()); + this.loadedFontInfo[sizedFont] = fontInfo; + foreach (var request in requests) + request.FontInternal = sizedFont; + } } } @@ -786,11 +812,13 @@ namespace Dalamud.Interface.Internal for (int i = customFontFirstConfigIndex, i_ = ioFonts.ConfigData.Size; i < i_; i++) { - var configPtr = ioFonts.ConfigData[i].NativePtr; - configPtr->OversampleH = 1; - configPtr->OversampleV = 1; - if (disableBigFonts) - configPtr->SizePixels = DefaultFontSizePx * fontLoadScale; + var config = ioFonts.ConfigData[i]; + config.OversampleH = 1; + config.OversampleV = 1; + + var name = Encoding.UTF8.GetString((byte*)config.Name.Data, config.Name.Count).TrimEnd('\0'); + this.loadedFontInfo[config.DstFont.NativePtr] = new($"PluginRequest({name})", TargetFontModification.AxisMode.Suppress, config.SizePixels, 1); + config.SizePixels = (disableBigFonts ? DefaultFontSizePx : config.SizePixels) * fontLoadScale; } ioFonts.Build(); @@ -819,60 +847,44 @@ namespace Dalamud.Interface.Internal gameFontManager.AfterBuildFonts(); - for (var i = 0; i < fontsToUnscale.Count; i++) + foreach (var (font, mod) in this.loadedFontInfo) { - var font = fontsToUnscale[i]; - var fontPtr = font.NativePtr; - var correspondingAxis = this.axisFontHandles[i]; - var overwrite = fontsToOverwriteFromAxis[i]; - var overwriteSize = fontsToReassignSizes[i]; + var nameBytes = Encoding.UTF8.GetBytes(mod.Name + "\0"); + Marshal.Copy(nameBytes, 0, (IntPtr)font.ConfigData.Name.Data, Math.Min(nameBytes.Length, font.ConfigData.Name.Count)); - GameFontManager.UnscaleFont(font, fontLoadScale, false); + Log.Verbose("[FONT] {0}: Unscale with scale value of {1}", mod.Name, mod.Scale); + GameFontManager.UnscaleFont(font, mod.Scale, false); - if (correspondingAxis == null) - continue; - - var scale = 1f; - - if (overwrite) + if (mod.Axis == TargetFontModification.AxisMode.Overwrite) { - var srcPtr = correspondingAxis.ImFont.NativePtr; - scale = fontPtr->ConfigData->SizePixels / srcPtr->ConfigData->SizePixels / fontLoadScale; - fontPtr->FontSize = srcPtr->FontSize * scale; - fontPtr->Ascent = srcPtr->Ascent * scale; - fontPtr->Descent = srcPtr->Descent * scale; - fontPtr->FallbackChar = srcPtr->FallbackChar; - fontPtr->EllipsisChar = srcPtr->EllipsisChar; - GameFontManager.CopyGlyphsAcrossFonts(correspondingAxis.ImFont, font, false, false); - - scale = 1f; + Log.Verbose("[FONT] {0}: Overwrite from AXIS of size {1}px (was {2}px)", mod.Name, mod.SourceAxis.ImFont.FontSize, font.FontSize); + font.FontSize = mod.SourceAxis.ImFont.FontSize; + font.Ascent = mod.SourceAxis.ImFont.Ascent; + font.Descent = mod.SourceAxis.ImFont.Descent; + font.FallbackChar = mod.SourceAxis.ImFont.FallbackChar; + font.EllipsisChar = mod.SourceAxis.ImFont.EllipsisChar; + GameFontManager.CopyGlyphsAcrossFonts(mod.SourceAxis.ImFont, font, false, false); + } + else if (mod.Axis == TargetFontModification.AxisMode.GameGlyphsOnly) + { + Log.Verbose("[FONT] {0}: Overwrite game specific glyphs from AXIS of size {1}px", mod.Name, mod.SourceAxis.ImFont.FontSize, font.FontSize); + if (!this.UseAxis && font.NativePtr == DefaultFont.NativePtr) + mod.SourceAxis.ImFont.FontSize -= 1; + GameFontManager.CopyGlyphsAcrossFonts(mod.SourceAxis.ImFont, font, true, false, 0xE020, 0xE0DB); + if (!this.UseAxis && font.NativePtr == DefaultFont.NativePtr) + mod.SourceAxis.ImFont.FontSize += 1; } - if (overwriteSize != null) - scale *= fontLoadScale * overwriteSize.Value / fontPtr->ConfigData->SizePixels; - - if (scale != 1f) - GameFontManager.UnscaleFont(font, 1 / scale, false); - - Log.Verbose("[FONT] Font {0}: result size {1}", i, fontPtr->FontSize); - - if (!this.UseAxis && fontPtr == DefaultFont.NativePtr) - { - fontPtr->FontSize -= 1; - GameFontManager.CopyGlyphsAcrossFonts(correspondingAxis.ImFont, font, true, false, 0xE020, 0xE0DB); - fontPtr->FontSize += 1; - } - else - { - GameFontManager.CopyGlyphsAcrossFonts(correspondingAxis.ImFont, font, true, false, 0xE020, 0xE0DB); - } + Log.Verbose("[FONT] {0}: Resize from {1}px to {2}px", mod.Name, font.FontSize, mod.TargetSizePx); + GameFontManager.UnscaleFont(font, font.FontSize / mod.TargetSizePx, false); } // Fill missing glyphs in MonoFont from DefaultFont GameFontManager.CopyGlyphsAcrossFonts(DefaultFont, MonoFont, true, false); - foreach (var font in fontsToUnscale) + for (int i = 0, i_ = ioFonts.Fonts.Size; i < i_; i++) { + var font = ioFonts.Fonts[i]; font.FallbackChar = Fallback1Codepoint; font.BuildLookupTable(); } From 3062d2d930b8de8f53404bf309d9b9fade7d3c33 Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 11 Apr 2022 19:53:07 +0200 Subject: [PATCH 14/15] ci: support multiple tracks --- .github/workflows/main.yml | 39 +++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 70c0b33ea..09ab225ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,27 +49,44 @@ jobs: name: dalamud-artifact path: .\scratch + - name: Extract branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch + - name: Generate dalamud-distrib version file shell: pwsh + env: + GH_BRANCH: ${{ steps.extract_branch.outputs.branch }} run: | Compress-Archive .\scratch\* .\canary.zip # Recreate the release zip + $branchName = $env:GH_BRANCH + + if ($branchName -eq "master") { + $branchName = "stg" + } + $dllBytes = [System.IO.File]::ReadAllBytes("$(Get-Location)\scratch\Dalamud.dll") $assembly = [System.Reflection.Assembly]::Load($dllBytes) $newVersion = $assembly.GetCustomAttributes([System.Reflection.AssemblyMetadataAttribute]) | Where { $_.GetType() -eq [System.Reflection.AssemblyMetadataAttribute] } | Select -First 1 | Select -ExpandProperty "Value" Remove-Item -Force -Recurse .\scratch - - $versionData = Get-Content .\stg\version | ConvertFrom-Json - $oldVersion = $versionData.AssemblyVersion - if ($oldVersion -eq $newVersion) { - Remove-Item .\canary.zip - } else { - Move-Item -Force .\canary.zip .\stg\latest.zip - $versionData.AssemblyVersion = $newVersion - $versionData | ConvertTo-Json -Compress | Out-File .\stg\version - } - echo "DVER=${newVersion}" >> $Env:GITHUB_ENV + if (Test-Path -Path $branchName) { + $versionData = Get-Content ".\${branchName}\version" | ConvertFrom-Json + $oldVersion = $versionData.AssemblyVersion + if ($oldVersion -eq $newVersion) { + Remove-Item .\canary.zip + } else { + Move-Item -Force ".\canary.zip" ".\${branchName}\latest.zip" + $versionData.AssemblyVersion = $newVersion + $versionData | ConvertTo-Json -Compress | Out-File ".\${branchName}\version" + } + + echo "DVER=${newVersion}" >> $Env:GITHUB_ENV + } else { + Write-Host "Deployment folder doesn't exist. Not doing anything." + } - name: Commit changes shell: bash From a24e81bee3c2bc808091e40d8ea64f51ae9b1872 Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 11 Apr 2022 19:54:06 +0200 Subject: [PATCH 15/15] ci: add track name to commit --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09ab225ee..f6620cbc1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -93,6 +93,7 @@ jobs: env: DEPLOY_SSH: ${{ secrets.DEPLOY_SSH }} GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no" + GH_BRANCH: ${{ steps.extract_branch.outputs.branch }} run: | eval "$(ssh-agent -s)" ssh-add - <<< "${DEPLOY_SSH}" @@ -101,6 +102,6 @@ jobs: git config --global user.email "actions@github.com" git add . - git commit -m "[CI] Update staging for ${DVER}" || true + git commit -m "[CI] Update staging for ${DVER} on ${GH_BRANCH}" || true git push origin main || true