Skip to content

Commit

Permalink
merge net5
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Jul 11, 2022
2 parents 69c4e95 + 414812b commit c1dac8d
Show file tree
Hide file tree
Showing 34 changed files with 420 additions and 386 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
} else {
Move-Item -Force ".\canary.zip" ".\${branchName}\latest.zip"
$versionData.AssemblyVersion = $newVersion
$versionData | add-member -Force -Name "GitSha" $newVersion -MemberType NoteProperty
$versionData | ConvertTo-Json -Compress | Out-File ".\${branchName}\version"
}
Expand Down
4 changes: 2 additions & 2 deletions Dalamud.Injector/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ private static int ProcessLaunchCommand(List<string> args, DalamudStartInfo dala
}
catch (Exception)
{
gamePath = @"C:\Program Files (x86)\SquareEnix\FINAL FANTASY XIV - A Realm Reborn\game\ffxiv_dx11.exe";
Log.Warning("Failed to read launcherConfigV3.json. Using default game installation path: {0}", gamePath);
Log.Error("Failed to read launcherConfigV3.json to get the set-up game path, please specify one using -g");
return -1;
}

if (!File.Exists(gamePath))
Expand Down
22 changes: 0 additions & 22 deletions Dalamud/Configuration/Internal/DalamudConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ namespace Dalamud.Configuration.Internal
[Serializable]
internal sealed class DalamudConfiguration : IServiceType
{
/// <summary>
/// Currently used beta key for Dalamud staging builds.
/// </summary>
public const string DalamudCurrentBetaKey = "If you read this you are a beta tester for the awesome .NET 6 version of Dalamud! Hell yeah!";

private static readonly JsonSerializerSettings SerializerSettings = new()
{
TypeNameHandling = TypeNameHandling.All,
Expand All @@ -44,12 +39,6 @@ internal sealed class DalamudConfiguration : IServiceType
/// </summary>
public event DalamudConfigurationSavedDelegate DalamudConfigurationSaved;

/// <summary>
/// Gets a value indicating whether or not Dalamud staging is enabled.
/// </summary>
[JsonIgnore]
public bool IsConventionalStaging => this.DalamudBetaKey == DalamudCurrentBetaKey;

/// <summary>
/// Gets or sets a list of muted works.
/// </summary>
Expand Down Expand Up @@ -144,17 +133,6 @@ internal sealed class DalamudConfiguration : IServiceType
/// </summary>
public float FontGammaLevel { get; set; } = 1.4f;

/// <summary>
/// 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 int FontResolutionLevel { get; set; } = 2;

/// <summary>
/// Gets or sets a value indicating whether to disable font fallback notice.
/// </summary>
public bool DisableFontFallbackNotice { get; set; } = false;

/// <summary>
/// Gets or sets a value indicating whether or not plugin UI should be hidden.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Dalamud/Dalamud.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<PropertyGroup Label="Feature">
<DalamudVersion>6.4.0.31</DalamudVersion>
<DalamudVersion>6.4.0.33</DalamudVersion>
<Description>XIV Launcher addon framework</Description>
<AssemblyVersion>$(DalamudVersion)</AssemblyVersion>
<Version>$(DalamudVersion)</Version>
Expand Down
1 change: 1 addition & 0 deletions Dalamud/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Dalamud.Logging.Internal;
using Dalamud.Support;
using Dalamud.Utility;
using ImGuiNET;
using Newtonsoft.Json;
using PInvoke;
using Serilog;
Expand Down
1 change: 0 additions & 1 deletion Dalamud/Game/ChatHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

using CheapLoc;
using Dalamud.Configuration.Internal;
using Dalamud.Data;
using Dalamud.Game.Gui;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
Expand Down
3 changes: 1 addition & 2 deletions Dalamud/Game/ClientState/ClientState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Runtime.InteropServices;

using Dalamud.Data;
Expand Down Expand Up @@ -105,7 +104,7 @@ private ClientState(SigScanner sigScanner, DalamudStartInfo startInfo)
/// <summary>
/// Gets the local player character, if one is present.
/// </summary>
public PlayerCharacter? LocalPlayer => Service<ObjectTable>.GetNullable()?.FirstOrDefault() as PlayerCharacter;
public PlayerCharacter? LocalPlayer => Service<ObjectTable>.GetNullable()?[0] as PlayerCharacter;

/// <summary>
/// Gets the content ID of the local character.
Expand Down
6 changes: 0 additions & 6 deletions Dalamud/Game/Gui/GameGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
using System.Numerics;
using System.Runtime.InteropServices;

using Dalamud.Configuration.Internal;
using Dalamud.Game.Gui.ContextMenus;
using Dalamud.Game.Gui.Dtr;
using Dalamud.Game.Gui.FlyText;
using Dalamud.Game.Gui.PartyFinder;
using Dalamud.Game.Gui.Toast;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Hooking;
using Dalamud.Interface;
Expand Down
12 changes: 9 additions & 3 deletions Dalamud/Game/Gui/PartyFinder/Types/ConditionFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ public enum ConditionFlags : uint
/// <summary>
/// No duty condition.
/// </summary>
None = 1,
None = 1 << 0,

/// <summary>
/// The duty complete condition.
/// </summary>
DutyComplete = 2,
DutyComplete = 1 << 1,

/// <summary>
/// The duty complete (weekly reward unclaimed) condition. This condition is
/// only available for savage fights prior to echo release.
/// </summary>
DutyCompleteWeeklyRewardUnclaimed = 1 << 3,

/// <summary>
/// The duty incomplete condition.
/// </summary>
DutyIncomplete = 4,
DutyIncomplete = 1 << 2,
}
}
1 change: 1 addition & 0 deletions Dalamud/Game/Internal/AntiDebug.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;

using Dalamud.Configuration.Internal;
using Serilog;

Expand Down
1 change: 0 additions & 1 deletion Dalamud/Game/Network/Internal/WinSockHandlers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Net.Sockets;
using System.Runtime.InteropServices;

Expand Down
5 changes: 1 addition & 4 deletions Dalamud/Hooking/Hook.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using Dalamud.Configuration.Internal;

using Dalamud.Hooking.Internal;
using Dalamud.Memory;
using Reloaded.Hooks;

namespace Dalamud.Hooking
{
Expand Down
4 changes: 0 additions & 4 deletions Dalamud/Hooking/Internal/PeHeader.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

#pragma warning disable
namespace Dalamud.Hooking.Internal
Expand Down
73 changes: 50 additions & 23 deletions Dalamud/Interface/GameFonts/GameFontManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using ImGuiNET;
using Lumina.Data.Files;
using Serilog;
using static Dalamud.Interface.ImGuiHelpers;

namespace Dalamud.Interface.GameFonts
{
Expand Down Expand Up @@ -39,7 +40,6 @@ internal class GameFontManager : IServiceType
private readonly Dictionary<GameFontStyle, Dictionary<char, Tuple<int, FdtReader.FontTableEntry>>> glyphRectIds = new();

private bool isBetweenBuildFontsAndRightAfterImGuiIoFontsBuild = false;
private bool isBuildingAsFallbackFontMode = false;

[ServiceManager.ServiceConstructor]
private GameFontManager(DataManager dataManager)
Expand Down Expand Up @@ -134,15 +134,18 @@ public static void UnscaleFont(ImFontPtr fontPtr, float fontScale, bool rebuildL
unsafe
{
var font = fontPtr.NativePtr;
for (int i = 0, i_ = font->IndexAdvanceX.Size; i < i_; ++i)
((float*)font->IndexAdvanceX.Data)[i] /= fontScale;
font->FallbackAdvanceX /= fontScale;
for (int i = 0, i_ = font->IndexedHotData.Size; i < i_; ++i)
{
font->IndexedHotData.Ref<ImFontGlyphHotDataReal>(i).AdvanceX /= fontScale;
font->IndexedHotData.Ref<ImFontGlyphHotDataReal>(i).OccupiedWidth /= fontScale;
}

font->FontSize /= fontScale;
font->Ascent /= fontScale;
font->Descent /= fontScale;
if (font->ConfigData != null)
font->ConfigData->SizePixels /= fontScale;
var glyphs = (ImGuiHelpers.ImFontGlyphReal*)font->Glyphs.Data;
var glyphs = (ImFontGlyphReal*)font->Glyphs.Data;
for (int i = 0, i_ = font->Glyphs.Size; i < i_; i++)
{
var glyph = &glyphs[i];
Expand All @@ -152,6 +155,11 @@ public static void UnscaleFont(ImFontPtr fontPtr, float fontScale, bool rebuildL
glyph->Y1 /= fontScale;
glyph->AdvanceX /= fontScale;
}

for (int i = 0, i_ = font->KerningPairs.Size; i < i_; i++)
font->KerningPairs.Ref<ImFontKerningPair>(i).AdvanceXAdjustment /= fontScale;
for (int i = 0, i_ = font->FrequentKerningPairs.Size; i < i_; i++)
font->FrequentKerningPairs.Ref<float>(i) /= fontScale;
}

if (rebuildLookupTable)
Expand Down Expand Up @@ -244,17 +252,18 @@ public void CopyGlyphsAcrossFonts(GameFontStyle source, GameFontStyle target, bo
/// <summary>
/// Build fonts before plugins do something more. To be called from InterfaceManager.
/// </summary>
/// <param name="forceMinSize">Whether to load fonts in minimum sizes.</param>
public void BuildFonts(bool forceMinSize)
public void BuildFonts()
{
this.isBuildingAsFallbackFontMode = forceMinSize;
this.isBetweenBuildFontsAndRightAfterImGuiIoFontsBuild = true;

this.glyphRectIds.Clear();
this.fonts.Clear();

foreach (var style in this.fontUseCounter.Keys)
this.EnsureFont(style);
lock (this.syncRoot)
{
foreach (var style in this.fontUseCounter.Keys)
this.EnsureFont(style);
}
}

/// <summary>
Expand All @@ -279,13 +288,21 @@ public unsafe void AfterBuildFonts()
{
var interfaceManager = Service<InterfaceManager>.Get();
var ioFonts = ImGui.GetIO().Fonts;
ioFonts.GetTexDataAsRGBA32(out byte* pixels8, out var width, out var height);
var pixels32 = (uint*)pixels8;
var fontGamma = interfaceManager.FontGamma;

var pixels8s = new byte*[ioFonts.Textures.Size];
var pixels32s = new uint*[ioFonts.Textures.Size];
var widths = new int[ioFonts.Textures.Size];
var heights = new int[ioFonts.Textures.Size];
for (var i = 0; i < pixels8s.Length; i++)
{
ioFonts.GetTexDataAsRGBA32(i, out pixels8s[i], out widths[i], out heights[i]);
pixels32s[i] = (uint*)pixels8s[i];
}

foreach (var (style, font) in this.fonts)
{
var fdt = this.fdts[(int)(this.isBuildingAsFallbackFontMode ? style.FamilyWithMinimumSize : style.FamilyAndSize)];
var fdt = this.fdts[(int)style.FamilyAndSize];
var scale = style.SizePt / fdt.FontHeader.Size;
var fontPtr = font.NativePtr;

Expand All @@ -302,7 +319,10 @@ public unsafe void AfterBuildFonts()
var glyph = font.FindGlyphNoFallback(fallbackCharCandidate);
if ((IntPtr)glyph.NativePtr != IntPtr.Zero)
{
font.SetFallbackChar(fallbackCharCandidate);
var ptr = font.NativePtr;
ptr->FallbackChar = fallbackCharCandidate;
ptr->FallbackGlyph = glyph.NativePtr;
ptr->FallbackHotData = (ImFontGlyphHotData*)ptr->IndexedHotData.Address<ImFontGlyphHotDataReal>(fallbackCharCandidate);
break;
}
}
Expand All @@ -323,7 +343,11 @@ public unsafe void AfterBuildFonts()

foreach (var (c, (rectId, glyph)) in this.glyphRectIds[style])
{
var rc = ioFonts.GetCustomRectByIndex(rectId);
var rc = (ImFontAtlasCustomRectReal*)ioFonts.GetCustomRectByIndex(rectId).NativePtr;
var pixels8 = pixels8s[rc->TextureIndex];
var pixels32 = pixels32s[rc->TextureIndex];
var width = widths[rc->TextureIndex];
var height = heights[rc->TextureIndex];
var sourceBuffer = this.texturePixels[glyph.TextureFileIndex];
var sourceBufferDelta = glyph.TextureChannelByteIndex;
var widthAdjustment = style.CalculateBaseWidthAdjustment(fdt, glyph);
Expand All @@ -334,7 +358,7 @@ public unsafe void AfterBuildFonts()
for (var x = 0; x < glyph.BoundingWidth; x++)
{
var a = sourceBuffer[sourceBufferDelta + (4 * (((glyph.TextureOffsetY + y) * fdt.FontHeader.TextureWidth) + glyph.TextureOffsetX + x))];
pixels32[((rc.Y + y) * width) + rc.X + x] = (uint)(a << 24) | 0xFFFFFFu;
pixels32[((rc->Y + y) * width) + rc->X + x] = (uint)(a << 24) | 0xFFFFFFu;
}
}
}
Expand All @@ -343,7 +367,7 @@ public unsafe void AfterBuildFonts()
for (var y = 0; y < glyph.BoundingHeight; y++)
{
for (var x = 0; x < glyph.BoundingWidth + widthAdjustment; x++)
pixels32[((rc.Y + y) * width) + rc.X + x] = 0xFFFFFFu;
pixels32[((rc->Y + y) * width) + rc->X + x] = 0xFFFFFFu;
}

for (int xbold = 0, xbold_ = Math.Max(1, (int)Math.Ceiling(style.Weight + 1)); xbold < xbold_; xbold++)
Expand All @@ -364,7 +388,7 @@ public unsafe void AfterBuildFonts()
var a1 = sourceBuffer[sourceBufferDelta + (4 * sourcePixelIndex)];
var a2 = x == glyph.BoundingWidth - 1 ? 0 : sourceBuffer[sourceBufferDelta + (4 * (sourcePixelIndex + 1))];
var n = (a1 * xness) + (a2 * (1 - xness));
var targetOffset = ((rc.Y + y) * width) + rc.X + x + xDeltaInt;
var targetOffset = ((rc->Y + y) * width) + rc->X + x + xDeltaInt;
pixels8[(targetOffset * 4) + 3] = Math.Max(pixels8[(targetOffset * 4) + 3], (byte)(boldStrength * n));
}
}
Expand All @@ -374,9 +398,9 @@ public unsafe void AfterBuildFonts()
if (Math.Abs(fontGamma - 1.4f) >= 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)
for (int y = rc.Y, y_ = rc.Y + rc.Height; y < y_; y++)
for (int y = rc->Y, y_ = rc->Y + rc->Height; y < y_; y++)
{
for (int x = rc.X, x_ = rc.X + rc.Width; x < x_; x++)
for (int x = rc->X, x_ = rc->X + rc->Width; x < x_; x++)
{
var i = (((y * width) + x) * 4) + 3;
pixels8[i] = (byte)(Math.Pow(pixels8[i] / 255.0f, 1.4f / fontGamma) * 255.0f);
Expand Down Expand Up @@ -409,7 +433,7 @@ private unsafe void EnsureFont(GameFontStyle style)
{
var rectIds = this.glyphRectIds[style] = new();

var fdt = this.fdts[(int)(this.isBuildingAsFallbackFontMode ? style.FamilyWithMinimumSize : style.FamilyAndSize)];
var fdt = this.fdts[(int)style.FamilyAndSize];
if (fdt == null)
return;

Expand All @@ -435,12 +459,15 @@ private unsafe void EnsureFont(GameFontStyle style)
io.Fonts.AddCustomRectFontGlyph(
font,
c,
glyph.BoundingWidth + widthAdjustment + 1,
glyph.BoundingHeight + 1,
glyph.BoundingWidth + widthAdjustment,
glyph.BoundingHeight,
glyph.AdvanceWidth,
new Vector2(0, glyph.CurrentOffsetY)),
glyph);
}

foreach (var kernPair in fdt.Distances)
font.AddKerningPair(kernPair.Left, kernPair.Right, kernPair.RightOffset);
}
}
}
4 changes: 2 additions & 2 deletions Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,13 @@ private unsafe void DrawFileListView(Vector2 size)

if (this.pathInputActivated)
{
if (ImGui.IsKeyReleased(ImGui.GetKeyIndex(ImGuiKey.Enter)))
if (ImGui.IsKeyReleased(ImGuiKey.Enter))
{
if (Directory.Exists(this.pathInputBuffer)) this.SetPath(this.pathInputBuffer);
this.pathInputActivated = false;
}

if (ImGui.IsKeyReleased(ImGui.GetKeyIndex(ImGuiKey.Escape)))
if (ImGui.IsKeyReleased(ImGuiKey.Escape))
{
this.pathInputActivated = false;
}
Expand Down
Loading

0 comments on commit c1dac8d

Please sign in to comment.