Merge remote-tracking branch 'origin/master' into net9-rollup

This commit is contained in:
github-actions[bot] 2024-12-17 15:57:14 +00:00
commit f9bdceb662
15 changed files with 747 additions and 764 deletions

View file

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

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -9,6 +9,7 @@ using Dalamud.Logging.Internal;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using Dalamud.Utility; using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Control; using FFXIVClientStructs.FFXIV.Client.Game.Control;
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel; using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
using FFXIVClientStructs.FFXIV.Client.System.String; using FFXIVClientStructs.FFXIV.Client.System.String;
@ -16,6 +17,7 @@ using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Common.Component.BGCollision; using FFXIVClientStructs.FFXIV.Common.Component.BGCollision;
using FFXIVClientStructs.FFXIV.Component.GUI; using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET; using ImGuiNET;
using Vector2 = System.Numerics.Vector2; using Vector2 = System.Numerics.Vector2;
@ -34,7 +36,6 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
private readonly GameGuiAddressResolver address; private readonly GameGuiAddressResolver address;
private readonly Hook<SetGlobalBgmDelegate> setGlobalBgmHook;
private readonly Hook<AgentItemDetail.Delegates.Update> handleItemHoverHook; private readonly Hook<AgentItemDetail.Delegates.Update> handleItemHoverHook;
private readonly Hook<AgentItemDetail.Delegates.ReceiveEvent> handleItemOutHook; private readonly Hook<AgentItemDetail.Delegates.ReceiveEvent> handleItemOutHook;
private readonly Hook<AgentActionDetail.Delegates.HandleActionHover> handleActionHoverHook; private readonly Hook<AgentActionDetail.Delegates.HandleActionHover> handleActionHoverHook;
@ -50,12 +51,8 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
this.address.Setup(sigScanner); this.address.Setup(sigScanner);
Log.Verbose("===== G A M E G U I ====="); Log.Verbose("===== G A M E G U I =====");
Log.Verbose($"GameGuiManager address {Util.DescribeAddress(this.address.BaseAddress)}");
Log.Verbose($"SetGlobalBgm address {Util.DescribeAddress(this.address.SetGlobalBgm)}");
Log.Verbose($"HandleImm address {Util.DescribeAddress(this.address.HandleImm)}"); Log.Verbose($"HandleImm address {Util.DescribeAddress(this.address.HandleImm)}");
this.setGlobalBgmHook = Hook<SetGlobalBgmDelegate>.FromAddress(this.address.SetGlobalBgm, this.HandleSetGlobalBgmDetour);
this.handleItemHoverHook = Hook<AgentItemDetail.Delegates.Update>.FromAddress((nint)AgentItemDetail.StaticVirtualTablePointer->Update, this.HandleItemHoverDetour); this.handleItemHoverHook = Hook<AgentItemDetail.Delegates.Update>.FromAddress((nint)AgentItemDetail.StaticVirtualTablePointer->Update, this.HandleItemHoverDetour);
this.handleItemOutHook = Hook<AgentItemDetail.Delegates.ReceiveEvent>.FromAddress((nint)AgentItemDetail.StaticVirtualTablePointer->ReceiveEvent, this.HandleItemOutDetour); this.handleItemOutHook = Hook<AgentItemDetail.Delegates.ReceiveEvent>.FromAddress((nint)AgentItemDetail.StaticVirtualTablePointer->ReceiveEvent, this.HandleItemOutDetour);
@ -68,7 +65,6 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
this.utf8StringFromSequenceHook = Hook<Utf8String.Delegates.Ctor_FromSequence>.FromAddress(Utf8String.Addresses.Ctor_FromSequence.Value, this.Utf8StringFromSequenceDetour); this.utf8StringFromSequenceHook = Hook<Utf8String.Delegates.Ctor_FromSequence>.FromAddress(Utf8String.Addresses.Ctor_FromSequence.Value, this.Utf8StringFromSequenceDetour);
this.setGlobalBgmHook.Enable();
this.handleItemHoverHook.Enable(); this.handleItemHoverHook.Enable();
this.handleItemOutHook.Enable(); this.handleItemOutHook.Enable();
this.handleImmHook.Enable(); this.handleImmHook.Enable();
@ -80,9 +76,6 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
// Hooked delegates // Hooked delegates
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
private delegate IntPtr SetGlobalBgmDelegate(ushort bgmKey, byte a2, uint a3, uint a4, uint a5, byte a6);
[UnmanagedFunctionPointer(CallingConvention.ThisCall)] [UnmanagedFunctionPointer(CallingConvention.ThisCall)]
private delegate char HandleImmDelegate(IntPtr framework, char a2, byte a3); private delegate char HandleImmDelegate(IntPtr framework, char a2, byte a3);
@ -254,7 +247,6 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
/// </summary> /// </summary>
void IInternalDisposableService.DisposeService() void IInternalDisposableService.DisposeService()
{ {
this.setGlobalBgmHook.Dispose();
this.handleItemHoverHook.Dispose(); this.handleItemHoverHook.Dispose();
this.handleItemOutHook.Dispose(); this.handleItemOutHook.Dispose();
this.handleImmHook.Dispose(); this.handleImmHook.Dispose();
@ -265,25 +257,23 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
} }
/// <summary> /// <summary>
/// Indicates if the game is on the title screen. /// Indicates if the game is in the lobby scene (title screen, chara select, chara make, aesthetician etc.).
/// </summary> /// </summary>
/// <returns>A value indicating whether or not the game is on the title screen.</returns> /// <returns>A value indicating whether or not the game is in the lobby scene.</returns>
internal bool IsOnTitleScreen() internal bool IsInLobby() => RaptureAtkModule.Instance()->CurrentUIScene.StartsWith("LobbyMain"u8);
{
var charaSelect = this.GetAddonByName("CharaSelect");
var charaMake = this.GetAddonByName("CharaMake");
var titleDcWorldMap = this.GetAddonByName("TitleDCWorldMap");
if (charaMake != nint.Zero || charaSelect != nint.Zero || titleDcWorldMap != nint.Zero)
return false;
return !Service<ClientState.ClientState>.Get().IsLoggedIn;
}
/// <summary> /// <summary>
/// Set the current background music. /// Sets the current background music.
/// </summary> /// </summary>
/// <param name="bgmKey">The background music key.</param> /// <param name="bgmId">The BGM row id.</param>
internal void SetBgm(ushort bgmKey) => this.setGlobalBgmHook.Original(bgmKey, 0, 0, 0, 0, 0); /// <param name="sceneId">The BGM scene index. Defaults to MiniGame scene to avoid conflicts.</param>
internal void SetBgm(ushort bgmId, uint sceneId = 2) => BGMSystem.SetBGM(bgmId, sceneId);
/// <summary>
/// Resets the current background music.
/// </summary>
/// <param name="sceneId">The BGM scene index.</param>
internal void ResetBgm(uint sceneId = 2) => BGMSystem.Instance()->ResetBGM(sceneId);
/// <summary> /// <summary>
/// Reset the stored "UI hide" state. /// Reset the stored "UI hide" state.
@ -293,15 +283,6 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
this.GameUiHidden = false; this.GameUiHidden = false;
} }
private IntPtr HandleSetGlobalBgmDetour(ushort bgmKey, byte a2, uint a3, uint a4, uint a5, byte a6)
{
var retVal = this.setGlobalBgmHook.Original(bgmKey, a2, a3, a4, a5, a6);
Log.Verbose("SetGlobalBgm: {0} {1} {2} {3} {4} {5} -> {6}", bgmKey, a2, a3, a4, a5, a6, retVal);
return retVal;
}
private void HandleItemHoverDetour(AgentItemDetail* thisPtr, uint frameCount) private void HandleItemHoverDetour(AgentItemDetail* thisPtr, uint frameCount)
{ {
this.handleItemHoverHook.Original(thisPtr, frameCount); this.handleItemHoverHook.Original(thisPtr, frameCount);

View file

@ -5,16 +5,6 @@ namespace Dalamud.Game.Gui;
/// </summary> /// </summary>
internal sealed class GameGuiAddressResolver : BaseAddressResolver internal sealed class GameGuiAddressResolver : BaseAddressResolver
{ {
/// <summary>
/// Gets the base address of the native GuiManager class.
/// </summary>
public IntPtr BaseAddress { get; private set; }
/// <summary>
/// Gets the address of the native SetGlobalBgm method.
/// </summary>
public IntPtr SetGlobalBgm { get; private set; }
/// <summary> /// <summary>
/// Gets the address of the native HandleImm method. /// Gets the address of the native HandleImm method.
/// </summary> /// </summary>
@ -23,7 +13,6 @@ internal sealed class GameGuiAddressResolver : BaseAddressResolver
/// <inheritdoc/> /// <inheritdoc/>
protected override void Setup64Bit(ISigScanner sig) protected override void Setup64Bit(ISigScanner sig)
{ {
this.SetGlobalBgm = sig.ScanText("E8 ?? ?? ?? ?? 8B 2F"); // unnamed in CS
this.HandleImm = sig.ScanText("E8 ?? ?? ?? ?? 84 C0 75 10 48 83 FF 09"); // unnamed in CS this.HandleImm = sig.ScanText("E8 ?? ?? ?? ?? 84 C0 75 10 48 83 FF 09"); // unnamed in CS
} }
} }

View file

@ -328,9 +328,22 @@ internal unsafe class NamePlateUpdateHandler : INamePlateUpdateHandler
public ulong GameObjectId => this.gameObjectId ??= this.NamePlateInfo->ObjectId; public ulong GameObjectId => this.gameObjectId ??= this.NamePlateInfo->ObjectId;
/// <inheritdoc/> /// <inheritdoc/>
public IGameObject? GameObject => this.gameObject ??= this.context.ObjectTable[ public IGameObject? GameObject
this.context.Ui3DModule->NamePlateObjectInfoPointers[this.ArrayIndex] {
.Value->GameObject->ObjectIndex]; get
{
if (this.GameObjectId == 0xE0000000)
{
// Skipping Ui3DModule lookup for invalid nameplate (NamePlateInfo->ObjectId is 0xE0000000). This
// prevents crashes around certain Doman Reconstruction cutscenes.
return null;
}
return this.gameObject ??= this.context.ObjectTable[
this.context.Ui3DModule->NamePlateObjectInfoPointers[this.ArrayIndex]
.Value->GameObject->ObjectIndex];
}
}
/// <inheritdoc/> /// <inheritdoc/>
public IBattleChara? BattleChara => this.GameObject as IBattleChara; public IBattleChara? BattleChara => this.GameObject as IBattleChara;

View file

@ -12,7 +12,7 @@ public static class XivChatTypeExtensions
/// </summary> /// </summary>
/// <param name="chatType">The chat type.</param> /// <param name="chatType">The chat type.</param>
/// <returns>The info attribute.</returns> /// <returns>The info attribute.</returns>
public static XivChatTypeInfoAttribute GetDetails(this XivChatType chatType) public static XivChatTypeInfoAttribute? GetDetails(this XivChatType chatType)
{ {
return chatType.GetAttribute<XivChatTypeInfoAttribute>(); return chatType.GetAttribute<XivChatTypeInfoAttribute>();
} }

View file

@ -266,7 +266,7 @@ internal class DalamudCommands : IServiceType
else else
{ {
// Revert to the original BGM by specifying an invalid one // Revert to the original BGM by specifying an invalid one
gameGui.SetBgm(9999); gameGui.ResetBgm();
} }
} }

View file

@ -60,9 +60,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
EdgeStrength = 1f, EdgeStrength = 1f,
}; };
#pragma warning disable SeStringRenderer
ImGuiHelpers.SeStringWrapped(this.NodeText.AsSpan(), style); ImGuiHelpers.SeStringWrapped(this.NodeText.AsSpan(), style);
#pragma warning restore SeStringRenderer
} }
catch catch
{ {

View file

@ -12,8 +12,6 @@ using Lumina.Text.ReadOnly;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets; namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
#pragma warning disable SeStringRenderer
/// <summary> /// <summary>
/// Widget for displaying AtkArrayData. /// Widget for displaying AtkArrayData.
/// </summary> /// </summary>

View file

@ -18,8 +18,6 @@ using Lumina.Excel.Sheets;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets; namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
#pragma warning disable SeStringRenderer
/// <summary> /// <summary>
/// Widget for displaying inventory data. /// Widget for displaying inventory data.
/// </summary> /// </summary>

View file

@ -23,8 +23,6 @@ using Lumina.Text.ReadOnly;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets; namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
#pragma warning disable SeStringRenderer
/// <summary> /// <summary>
/// Widget for displaying Addon Data. /// Widget for displaying Addon Data.
/// </summary> /// </summary>

View file

@ -1,4 +1,4 @@
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
@ -194,6 +194,7 @@ Contribute at: https://github.com/goatcorp/Dalamud
private readonly IFontAtlas privateAtlas; private readonly IFontAtlas privateAtlas;
private string creditsText; private string creditsText;
private bool isBgmSet;
private bool resetNow = false; private bool resetNow = false;
private IDalamudTextureWrap? logoTexture; private IDalamudTextureWrap? logoTexture;
@ -222,10 +223,13 @@ Contribute at: https://github.com/goatcorp/Dalamud
this.creditsText = string.Format(CreditsTextTempl, typeof(Dalamud).Assembly.GetName().Version, pluginCredits, Util.GetGitHashClientStructs()); this.creditsText = string.Format(CreditsTextTempl, typeof(Dalamud).Assembly.GetName().Version, pluginCredits, Util.GetGitHashClientStructs());
var gg = Service<GameGui>.Get(); var gameGui = Service<GameGui>.Get();
if (!gg.IsOnTitleScreen() && UIState.Instance() != null) var playerState = PlayerState.Instance();
if (!gameGui.IsInLobby() && playerState != null)
{ {
gg.SetBgm((ushort)(UIState.Instance()->PlayerState.MaxExpansion > 3 ? 833 : 132)); gameGui.SetBgm((ushort)(playerState->MaxExpansion > 3 ? 833 : 132));
this.isBgmSet = true;
} }
this.creditsThrottler.Restart(); this.creditsThrottler.Restart();
@ -242,9 +246,15 @@ Contribute at: https://github.com/goatcorp/Dalamud
{ {
this.creditsThrottler.Reset(); this.creditsThrottler.Reset();
var gg = Service<GameGui>.Get(); if (this.isBgmSet)
if (!gg.IsOnTitleScreen()) {
gg.SetBgm(9999); var gameGui = Service<GameGui>.Get();
if (!gameGui.IsInLobby())
gameGui.ResetBgm();
this.isBgmSet = false;
}
Service<DalamudInterface>.Get().SetCreditsDarkeningAnimation(false); Service<DalamudInterface>.Get().SetCreditsDarkeningAnimation(false);
} }

View file

@ -212,7 +212,6 @@ public static class ImGuiHelpers
/// <returns>Interaction result of the rendered text.</returns> /// <returns>Interaction result of the rendered text.</returns>
/// <remarks>This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel. /// <remarks>This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel.
/// The function definition is stable; only in the next API version a function may be removed.</remarks> /// The function definition is stable; only in the next API version a function may be removed.</remarks>
[Experimental("SeStringRenderer")]
public static SeStringDrawResult SeStringWrapped( public static SeStringDrawResult SeStringWrapped(
ReadOnlySpan<byte> sss, ReadOnlySpan<byte> sss,
scoped in SeStringDrawParams style = default, scoped in SeStringDrawParams style = default,
@ -229,7 +228,6 @@ public static class ImGuiHelpers
/// <returns>Interaction result of the rendered text.</returns> /// <returns>Interaction result of the rendered text.</returns>
/// <remarks>This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel. /// <remarks>This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel.
/// The function definition is stable; only in the next API version a function may be removed.</remarks> /// The function definition is stable; only in the next API version a function may be removed.</remarks>
[Experimental("SeStringRenderer")]
public static SeStringDrawResult CompileSeStringWrapped( public static SeStringDrawResult CompileSeStringWrapped(
string text, string text,
scoped in SeStringDrawParams style = default, scoped in SeStringDrawParams style = default,

@ -1 +1 @@
Subproject commit d4778799d378fe66099fd337f55849acf1f16dcd Subproject commit df03181ccbbbfead3db116b59359dae4a31cb07d