Merge branch 'net5'

This commit is contained in:
goaaats 2022-04-11 20:11:42 +02:00
commit f86d50975d
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
9 changed files with 280 additions and 149 deletions

View file

@ -49,33 +49,51 @@ 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
}
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
echo "DVER=${newVersion}" >> $Env:GITHUB_ENV
} else {
Write-Host "Deployment folder doesn't exist. Not doing anything."
}
- name: Commit changes
shell: bash
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}"
@ -84,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

View file

@ -144,9 +144,10 @@ namespace Dalamud.Configuration.Internal
public float FontGamma { get; set; } = 1.4f;
/// <summary>
/// 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).
/// </summary>
public bool AllowBigFontAtlas { get; set; } = false;
public int FontResolutionLevel { get; set; } = 2;
/// <summary>
/// Gets or sets a value indicating whether or not plugin UI should be hidden.
@ -298,7 +299,7 @@ namespace Dalamud.Configuration.Internal
/// <summary>
/// Gets or sets a value indicating whether or not market board data should be uploaded.
/// </summary>
public bool DoMbCollect { get; set; } = false;
public bool IsMbCollect { get; set; } = true;
/// <summary>
/// Load a configuration from the provided path.

View file

@ -8,7 +8,7 @@
</PropertyGroup>
<PropertyGroup Label="Feature">
<DalamudVersion>6.3.0.15</DalamudVersion>
<DalamudVersion>6.3.0.18</DalamudVersion>
<Description>XIV Launcher addon framework</Description>
<AssemblyVersion>$(DalamudVersion)</AssemblyVersion>
<Version>$(DalamudVersion)</Version>

View file

@ -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"])
{

View file

@ -177,6 +177,9 @@ namespace Dalamud.Interface.GameFonts
/// <param name="rebuildLookupTable">Whether to call target.BuildLookupTable().</param>
public static void UnscaleFont(ImFontPtr fontPtr, float fontScale, bool rebuildLookupTable = true)
{
if (fontScale == 1)
return;
unsafe
{
var font = fontPtr.NativePtr;
@ -289,7 +292,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 +308,7 @@ namespace Dalamud.Interface.GameFonts
continue;
var font = io.Fonts.AddFontDefault(fontConfig);
this.fonts[style] = font;
foreach (var glyph in fdt.Glyphs)
{

View file

@ -87,9 +87,9 @@ namespace Dalamud.Interface.GameFonts
};
/// <summary>
/// Gets the font size.
/// Gets the font size in point unit.
/// </summary>
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(),
};
/// <summary>
/// Gets the font size in pixel unit.
/// </summary>
public float SizePx => this.SizePt * 4 / 3;
/// <summary>
/// Gets or sets a value indicating whether this font is bold.
/// </summary>
@ -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;

View file

@ -55,7 +55,7 @@ namespace Dalamud.Interface.Internal
private readonly string rtssPath;
private readonly HashSet<SpecialGlyphRequest> glyphRequests = new();
private readonly List<GameFontHandle> axisFontHandles = new();
private readonly Dictionary<ImFontPtr, TargetFontModification> loadedFontInfo = new();
private readonly Hook<PresentDelegate> presentHook;
private readonly Hook<ResizeBuffersDelegate> resizeBuffersHook;
@ -216,14 +216,14 @@ namespace Dalamud.Interface.Internal
public float FontGamma => Math.Max(0.1f, this.FontGammaOverride.GetValueOrDefault(Service<DalamudConfiguration>.Get().FontGamma));
/// <summary>
/// Gets or sets a value indicating whether to override configuration for AllowBigFontAtlas.
/// Gets or sets a value indicating whether to override configuration for FontResolutionLevel.
/// </summary>
public bool? AllowBigFontAtlasOverride { get; set; } = null;
public int? FontResolutionLevelOverride { get; set; } = null;
/// <summary>
/// Gets a value indicating whether to allow big font atlas.
/// Gets a value indicating the level of font resolution.
/// </summary>
public bool AllowBigFontAtlas => this.AllowBigFontAtlasOverride ?? Service<DalamudConfiguration>.Get().AllowBigFontAtlas;
public int FontResolutionLevel => this.FontResolutionLevelOverride ?? Service<DalamudConfiguration>.Get().FontResolutionLevel;
/// <summary>
/// Enable this module.
@ -594,31 +594,64 @@ namespace Dalamud.Interface.Internal
ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.ViewportsEnable;
}
private unsafe void SetupFonts()
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<GameFontManager>.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<GameFontManager>.Get();
var dalamud = Service<Dalamud>.Get();
var io = ImGui.GetIO();
var ioFonts = io.Fonts;
var fontLoadScale = this.AllowBigFontAtlas ? io.FontGlobalScale : 1;
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;
List<ImFontPtr> fontsToUnscale = new();
List<bool> fontsToOverwriteFromAxis = new();
List<float?> fontsToReassignSizes = new();
this.fontBuildSignal.Reset();
ioFonts.Clear();
ioFonts.TexDesiredWidth = this.AllowBigFontAtlas ? 4096 : 2048;
ioFonts.TexDesiredWidth = maxTexDimension;
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");
@ -633,7 +666,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 +673,19 @@ 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)));
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(null);
this.loadedFontInfo[DefaultFont] = fontInfo;
}
else
{
@ -657,10 +693,9 @@ namespace Dalamud.Interface.Internal
garbageList.Add(japaneseRangeHandle);
fontConfig.GlyphRanges = japaneseRangeHandle.AddrOfPinnedObject();
DefaultFont = ioFonts.AddFontFromFileTTF(fontPathJp, (DefaultFontSizePx + 1) * fontLoadScale, fontConfig);
fontsToUnscale.Add(DefaultFont);
fontsToOverwriteFromAxis.Add(false);
fontsToReassignSizes.Add(null);
fontConfig.PixelSnapH = true;
DefaultFont = ioFonts.AddFontFromFileTTF(fontPathJp, fontInfo.TargetSizePx * fontLoadScale, fontConfig);
this.loadedFontInfo[DefaultFont] = fontInfo;
}
// FontAwesome icon font
@ -674,11 +709,9 @@ 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);
fontsToOverwriteFromAxis.Add(false);
fontsToReassignSizes.Add(null);
this.loadedFontInfo[IconFont] = new("Icon", TargetFontModification.AxisMode.GameGlyphsOnly, DefaultFontSizePx, fontLoadScale);
}
// Monospace font
@ -689,11 +722,9 @@ 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);
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
@ -741,45 +772,71 @@ 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)));
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.AllowBigFontAtlas ? fontSize : DefaultFontSizePx) * fontLoadScale;
sizedFont = ioFonts.AddFontDefault(fontConfig);
fontsToUnscale.Add(sizedFont);
fontsToOverwriteFromAxis.Add(true);
fontsToReassignSizes.Add(this.AllowBigFontAtlas ? null : fontSize);
fontConfig.SizePixels = fontInfo.SourceAxis.Style.SizePx;
fontConfig.PixelSnapH = false;
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);
sizedFont = ioFonts.AddFontFromFileTTF(fontPathJp, (this.AllowBigFontAtlas ? fontSize : DefaultFontSizePx + 1) * fontLoadScale, fontConfig, rangeHandle.AddrOfPinnedObject());
fontsToUnscale.Add(sizedFont);
fontsToOverwriteFromAxis.Add(false);
fontsToReassignSizes.Add(this.AllowBigFontAtlas ? null : fontSize);
}
fontConfig.PixelSnapH = true;
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;
}
}
}
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 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();
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)
@ -790,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 *= 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();
}

View file

@ -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.");

View file

@ -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,9 +41,10 @@ namespace Dalamud.Interface.Internal.Windows
private bool doCfChatMessage;
private bool doMbCollect;
private int fontResolutionLevel;
private float globalUiScale;
private bool doUseAxisFontsFromGame;
private bool doAllowBigFontAtlas;
private float fontGamma;
private bool doToggleUiHide;
private bool doToggleUiHideDuringCutscenes;
@ -92,12 +96,12 @@ 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;
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 +124,15 @@ namespace Dalamud.Interface.Internal.Windows
this.doButtonsSystemMenu = configuration.DoButtonsSystemMenu;
this.disableRmtFiltering = configuration.DisableRmtFiltering;
this.fontResolutionLevelStrings = new[]
{
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, may crash your game)"),
Loc.Localize("DalamudSettingsFontResolutionLevel4", "Best (16k x 16k texture, may crash your game)"),
};
this.languages = Localization.ApplicableLangCodes.Prepend("en").ToArray();
try
{
@ -188,7 +201,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();
@ -204,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"))
{
@ -284,8 +297,13 @@ 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!"));
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()
@ -293,23 +311,55 @@ namespace Dalamud.Interface.Internal.Windows
var interfaceManager = Service<InterfaceManager>.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", "Reset") + "##DalamudSettingsGlobalUiScaleReset"))
if (ImGui.Button(Loc.Localize("DalamudSettingsUiScalePreset6", "9.6pt") + "##DalamudSettingsGlobalUiScaleReset96"))
{
this.globalUiScale = 9.6f / 12.0f;
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
interfaceManager.RebuildFonts();
}
ImGui.SameLine();
if (ImGui.Button(Loc.Localize("DalamudSettingsUiScalePreset12", "Reset (12pt)") + "##DalamudSettingsGlobalUiScaleReset12"))
{
this.globalUiScale = 1.0f;
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
interfaceManager.RebuildFonts();
}
ImGui.SameLine();
if (ImGui.Button(Loc.Localize("DalamudSettingsUiScalePreset14", "14pt") + "##DalamudSettingsGlobalUiScaleReset14"))
{
this.globalUiScale = 14.0f / 12.0f;
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
interfaceManager.RebuildFonts();
}
ImGui.SameLine();
if (ImGui.Button(Loc.Localize("DalamudSettingsUiScalePreset18", "18pt") + "##DalamudSettingsGlobalUiScaleReset18"))
{
this.globalUiScale = 18.0f / 12.0f;
ImGui.GetIO().FontGlobalScale = this.globalUiScale;
interfaceManager.RebuildFonts();
}
ImGui.SameLine();
if (ImGui.Button(Loc.Localize("DalamudSettingsUiScalePreset36", "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;
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);
@ -320,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))
{
@ -332,13 +380,27 @@ 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))
ImGuiHelpers.ScaledDummy(3);
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.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudGrey);
ImGui.TextWrapped(string.Format(
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();
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."));
@ -854,7 +916,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;
@ -867,7 +929,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()