mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Merge pull request #1343 from goatcorp/v9-rollup
This commit is contained in:
commit
d807257670
36 changed files with 1337 additions and 279 deletions
|
|
@ -6,7 +6,9 @@ using Dalamud.Game.Command;
|
|||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Logging;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility;
|
||||
using Serilog;
|
||||
|
||||
namespace Dalamud.CorePlugin
|
||||
{
|
||||
|
|
@ -55,7 +57,7 @@ namespace Dalamud.CorePlugin
|
|||
/// </summary>
|
||||
/// <param name="pluginInterface">Dalamud plugin interface.</param>
|
||||
/// <param name="log">Logging service.</param>
|
||||
public PluginImpl(DalamudPluginInterface pluginInterface, PluginLog log)
|
||||
public PluginImpl(DalamudPluginInterface pluginInterface, IPluginLog log)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -66,6 +68,7 @@ namespace Dalamud.CorePlugin
|
|||
|
||||
this.Interface.UiBuilder.Draw += this.OnDraw;
|
||||
this.Interface.UiBuilder.OpenConfigUi += this.OnOpenConfigUi;
|
||||
this.Interface.UiBuilder.OpenMainUi += this.OnOpenMainUi;
|
||||
|
||||
Service<CommandManager>.Get().AddHandler("/coreplug", new(this.OnCommand) { HelpMessage = $"Access the {this.Name} plugin." });
|
||||
|
||||
|
|
@ -143,6 +146,11 @@ namespace Dalamud.CorePlugin
|
|||
// this.window.IsOpen = true;
|
||||
}
|
||||
|
||||
private void OnOpenMainUi()
|
||||
{
|
||||
Log.Verbose("Opened main UI");
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,11 @@ internal sealed class DalamudConfiguration : IServiceType
|
|||
/// </summary>
|
||||
public List<ThirdPartyRepoSettings> ThirdRepoList { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether or not a disclaimer regarding third-party repos has been dismissed.
|
||||
/// </summary>
|
||||
public bool? ThirdRepoSpeedbumpDismissed { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of hidden plugins.
|
||||
/// </summary>
|
||||
|
|
|
|||
156
Dalamud/Game/AddonLifecycle/AddonLifecycle.cs
Normal file
156
Dalamud/Game/AddonLifecycle/AddonLifecycle.cs
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
using System;
|
||||
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.IoC.Internal;
|
||||
using Dalamud.Logging.Internal;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace Dalamud.Game.AddonLifecycle;
|
||||
|
||||
/// <summary>
|
||||
/// This class provides events for in-game addon lifecycles.
|
||||
/// </summary>
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.EarlyLoadedService]
|
||||
internal unsafe class AddonLifecycle : IDisposable, IServiceType, IAddonLifecycle
|
||||
{
|
||||
private static readonly ModuleLog Log = new("AddonLifecycle");
|
||||
private readonly AddonLifecycleAddressResolver address;
|
||||
private readonly Hook<AddonSetupDelegate> onAddonSetupHook;
|
||||
private readonly Hook<AddonFinalizeDelegate> onAddonFinalizeHook;
|
||||
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private AddonLifecycle(SigScanner sigScanner)
|
||||
{
|
||||
this.address = new AddonLifecycleAddressResolver();
|
||||
this.address.Setup(sigScanner);
|
||||
|
||||
this.onAddonSetupHook = Hook<AddonSetupDelegate>.FromAddress(this.address.AddonSetup, this.OnAddonSetup);
|
||||
this.onAddonFinalizeHook = Hook<AddonFinalizeDelegate>.FromAddress(this.address.AddonFinalize, this.OnAddonFinalize);
|
||||
}
|
||||
|
||||
private delegate nint AddonSetupDelegate(AtkUnitBase* addon);
|
||||
|
||||
private delegate void AddonFinalizeDelegate(AtkUnitManager* unitManager, AtkUnitBase** atkUnitBase);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event Action<IAddonLifecycle.AddonArgs>? AddonPreSetup;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event Action<IAddonLifecycle.AddonArgs>? AddonPostSetup;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event Action<IAddonLifecycle.AddonArgs>? AddonPreFinalize;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
this.onAddonSetupHook.Dispose();
|
||||
this.onAddonFinalizeHook.Dispose();
|
||||
}
|
||||
|
||||
[ServiceManager.CallWhenServicesReady]
|
||||
private void ContinueConstruction()
|
||||
{
|
||||
this.onAddonSetupHook.Enable();
|
||||
this.onAddonFinalizeHook.Enable();
|
||||
}
|
||||
|
||||
private nint OnAddonSetup(AtkUnitBase* addon)
|
||||
{
|
||||
if (addon is null)
|
||||
return this.onAddonSetupHook.Original(addon);
|
||||
|
||||
try
|
||||
{
|
||||
this.AddonPreSetup?.Invoke(new IAddonLifecycle.AddonArgs { Addon = (nint)addon });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e, "Exception in OnAddonSetup pre-setup invoke.");
|
||||
}
|
||||
|
||||
var result = this.onAddonSetupHook.Original(addon);
|
||||
|
||||
try
|
||||
{
|
||||
this.AddonPostSetup?.Invoke(new IAddonLifecycle.AddonArgs { Addon = (nint)addon });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e, "Exception in OnAddonSetup post-setup invoke.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void OnAddonFinalize(AtkUnitManager* unitManager, AtkUnitBase** atkUnitBase)
|
||||
{
|
||||
if (atkUnitBase is null || atkUnitBase[0] is null)
|
||||
{
|
||||
this.onAddonFinalizeHook.Original(unitManager, atkUnitBase);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
this.AddonPreFinalize?.Invoke(new IAddonLifecycle.AddonArgs { Addon = (nint)atkUnitBase[0] });
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e, "Exception in OnAddonFinalize pre-finalize invoke.");
|
||||
}
|
||||
|
||||
this.onAddonFinalizeHook.Original(unitManager, atkUnitBase);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plugin-scoped version of a AddonLifecycle service.
|
||||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.ScopedService]
|
||||
#pragma warning disable SA1015
|
||||
[ResolveVia<IAddonLifecycle>]
|
||||
#pragma warning restore SA1015
|
||||
internal class AddonLifecyclePluginScoped : IDisposable, IServiceType, IAddonLifecycle
|
||||
{
|
||||
[ServiceManager.ServiceDependency]
|
||||
private readonly AddonLifecycle addonLifecycleService = Service<AddonLifecycle>.Get();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddonLifecyclePluginScoped"/> class.
|
||||
/// </summary>
|
||||
public AddonLifecyclePluginScoped()
|
||||
{
|
||||
this.addonLifecycleService.AddonPreSetup += this.AddonPreSetupForward;
|
||||
this.addonLifecycleService.AddonPostSetup += this.AddonPostSetupForward;
|
||||
this.addonLifecycleService.AddonPreFinalize += this.AddonPreFinalizeForward;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event Action<IAddonLifecycle.AddonArgs>? AddonPreSetup;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event Action<IAddonLifecycle.AddonArgs>? AddonPostSetup;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event Action<IAddonLifecycle.AddonArgs>? AddonPreFinalize;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
this.addonLifecycleService.AddonPreSetup -= this.AddonPreSetupForward;
|
||||
this.addonLifecycleService.AddonPostSetup -= this.AddonPostSetupForward;
|
||||
this.addonLifecycleService.AddonPreFinalize -= this.AddonPreFinalizeForward;
|
||||
}
|
||||
|
||||
private void AddonPreSetupForward(IAddonLifecycle.AddonArgs args) => this.AddonPreSetup?.Invoke(args);
|
||||
|
||||
private void AddonPostSetupForward(IAddonLifecycle.AddonArgs args) => this.AddonPostSetup?.Invoke(args);
|
||||
|
||||
private void AddonPreFinalizeForward(IAddonLifecycle.AddonArgs args) => this.AddonPreFinalize?.Invoke(args);
|
||||
}
|
||||
27
Dalamud/Game/AddonLifecycle/AddonLifecycleAddressResolver.cs
Normal file
27
Dalamud/Game/AddonLifecycle/AddonLifecycleAddressResolver.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
namespace Dalamud.Game.AddonLifecycle;
|
||||
|
||||
/// <summary>
|
||||
/// AddonLifecycleService memory address resolver.
|
||||
/// </summary>
|
||||
internal class AddonLifecycleAddressResolver : BaseAddressResolver
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the address of the addon setup hook invoked by the atkunitmanager.
|
||||
/// </summary>
|
||||
public nint AddonSetup { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the address of the addon finalize hook invoked by the atkunitmanager.
|
||||
/// </summary>
|
||||
public nint AddonFinalize { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Scan for and setup any configured address pointers.
|
||||
/// </summary>
|
||||
/// <param name="sig">The signature scanner to facilitate setup.</param>
|
||||
protected override void Setup64Bit(SigScanner sig)
|
||||
{
|
||||
this.AddonSetup = sig.ScanText("E8 ?? ?? ?? ?? 8B 83 ?? ?? ?? ?? C1 E8 14");
|
||||
this.AddonFinalize = sig.ScanText("E8 ?? ?? ?? ?? 48 8B 7C 24 ?? 41 8B C6");
|
||||
}
|
||||
}
|
||||
|
|
@ -70,6 +70,20 @@ public sealed unsafe class TargetManager : IServiceType, ITargetManager
|
|||
set => this.SetSoftTarget(value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public GameObject? GPoseTarget
|
||||
{
|
||||
get => this.objectTable.CreateObjectReference((IntPtr)Struct->GPoseTarget);
|
||||
set => Struct->GPoseTarget = (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)value?.Address;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public GameObject? MouseOverNameplateTarget
|
||||
{
|
||||
get => this.objectTable.CreateObjectReference((IntPtr)Struct->MouseOverNameplateTarget);
|
||||
set => Struct->MouseOverNameplateTarget = (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)value?.Address;
|
||||
}
|
||||
|
||||
private FFXIVClientStructs.FFXIV.Client.Game.Control.TargetSystem* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Control.TargetSystem*)this.Address;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -206,9 +206,9 @@ public abstract partial class Payload
|
|||
case SeStringChunkType.Icon:
|
||||
payload = new IconPayload();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
Log.Verbose("Unhandled SeStringChunkType: {0}", chunkType);
|
||||
// Log.Verbose("Unhandled SeStringChunkType: {0}", chunkType);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -307,6 +307,11 @@ public abstract partial class Payload
|
|||
/// </summary>
|
||||
protected enum SeStringChunkType
|
||||
{
|
||||
/// <summary>
|
||||
/// See the <see cref="NewLinePayload"/>.
|
||||
/// </summary>
|
||||
NewLine = 0x10,
|
||||
|
||||
/// <summary>
|
||||
/// See the <see cref="IconPayload"/> class.
|
||||
/// </summary>
|
||||
|
|
@ -317,11 +322,6 @@ public abstract partial class Payload
|
|||
/// </summary>
|
||||
EmphasisItalic = 0x1A,
|
||||
|
||||
/// <summary>
|
||||
/// See the <see cref="NewLinePayload"/>.
|
||||
/// </summary>
|
||||
NewLine = 0x10,
|
||||
|
||||
/// <summary>
|
||||
/// See the <see cref="SeHyphenPayload"/> class.
|
||||
/// </summary>
|
||||
|
|
|
|||
261
Dalamud/Interface/ColorHelpers.cs
Normal file
261
Dalamud/Interface/ColorHelpers.cs
Normal file
|
|
@ -0,0 +1,261 @@
|
|||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Dalamud.Interface;
|
||||
|
||||
/// <summary>
|
||||
/// Class containing various methods for manipulating colors.
|
||||
/// </summary>
|
||||
public static class ColorHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Pack a vector4 color into a uint for use in ImGui APIs.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to pack.</param>
|
||||
/// <returns>The packed color.</returns>
|
||||
public static uint RgbaVector4ToUint(Vector4 color)
|
||||
{
|
||||
var r = (byte)(color.X * 255);
|
||||
var g = (byte)(color.Y * 255);
|
||||
var b = (byte)(color.Z * 255);
|
||||
var a = (byte)(color.W * 255);
|
||||
|
||||
return (uint)((a << 24) | (b << 16) | (g << 8) | r);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a RGBA color in the range of 0.f to 1.f to a uint.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to pack.</param>
|
||||
/// <returns>The packed color.</returns>
|
||||
public static Vector4 RgbaUintToVector4(uint color)
|
||||
{
|
||||
var r = (color & 0x000000FF) / 255f;
|
||||
var g = ((color & 0x0000FF00) >> 8) / 255f;
|
||||
var b = ((color & 0x00FF0000) >> 16) / 255f;
|
||||
var a = ((color & 0xFF000000) >> 24) / 255f;
|
||||
|
||||
return new Vector4(r, g, b, a);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a RGBA color in the range of 0.f to 1.f to a HSV color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to convert.</param>
|
||||
/// <returns>The color in a HSV representation.</returns>
|
||||
public static HsvaColor RgbaToHsv(Vector4 color)
|
||||
{
|
||||
var r = color.X;
|
||||
var g = color.Y;
|
||||
var b = color.Z;
|
||||
|
||||
var max = Math.Max(r, Math.Max(g, b));
|
||||
var min = Math.Min(r, Math.Min(g, b));
|
||||
|
||||
var h = max;
|
||||
var s = max;
|
||||
var v = max;
|
||||
|
||||
var d = max - min;
|
||||
s = max == 0 ? 0 : d / max;
|
||||
|
||||
if (max == min)
|
||||
{
|
||||
h = 0; // achromatic
|
||||
}
|
||||
else
|
||||
{
|
||||
if (max == r)
|
||||
{
|
||||
h = ((g - b) / d) + (g < b ? 6 : 0);
|
||||
}
|
||||
else if (max == g)
|
||||
{
|
||||
h = ((b - r) / d) + 2;
|
||||
}
|
||||
else if (max == b)
|
||||
{
|
||||
h = ((r - g) / d) + 4;
|
||||
}
|
||||
|
||||
h /= 6;
|
||||
}
|
||||
|
||||
return new HsvaColor(h, s, v, color.W);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a HSV color to a RGBA color in the range of 0.f to 1.f.
|
||||
/// </summary>
|
||||
/// <param name="hsv">The color to convert.</param>
|
||||
/// <returns>The RGB color.</returns>
|
||||
public static Vector4 HsvToRgb(HsvaColor hsv)
|
||||
{
|
||||
var h = hsv.H;
|
||||
var s = hsv.S;
|
||||
var v = hsv.V;
|
||||
|
||||
var r = 0f;
|
||||
var g = 0f;
|
||||
var b = 0f;
|
||||
|
||||
var i = (int)Math.Floor(h * 6);
|
||||
var f = (h * 6) - i;
|
||||
var p = v * (1 - s);
|
||||
var q = v * (1 - (f * s));
|
||||
var t = v * (1 - ((1 - f) * s));
|
||||
|
||||
switch (i % 6)
|
||||
{
|
||||
case 0:
|
||||
r = v;
|
||||
g = t;
|
||||
b = p;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
r = q;
|
||||
g = v;
|
||||
b = p;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
r = p;
|
||||
g = v;
|
||||
b = t;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
r = p;
|
||||
g = q;
|
||||
b = v;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
r = t;
|
||||
g = p;
|
||||
b = v;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
r = v;
|
||||
g = p;
|
||||
b = q;
|
||||
break;
|
||||
}
|
||||
|
||||
return new Vector4(r, g, b, hsv.A);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lighten a color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to lighten.</param>
|
||||
/// <param name="amount">The amount to lighten.</param>
|
||||
/// <returns>The lightened color.</returns>
|
||||
public static Vector4 Lighten(this Vector4 color, float amount)
|
||||
{
|
||||
var hsv = RgbaToHsv(color);
|
||||
hsv.V += amount;
|
||||
return HsvToRgb(hsv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lighten a color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to lighten.</param>
|
||||
/// <param name="amount">The amount to lighten.</param>
|
||||
/// <returns>The lightened color.</returns>
|
||||
public static uint Lighten(uint color, float amount)
|
||||
=> RgbaVector4ToUint(Lighten(RgbaUintToVector4(color), amount));
|
||||
|
||||
/// <summary>
|
||||
/// Darken a color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to lighten.</param>
|
||||
/// <param name="amount">The amount to lighten.</param>
|
||||
/// <returns>The darkened color.</returns>
|
||||
public static Vector4 Darken(this Vector4 color, float amount)
|
||||
{
|
||||
var hsv = RgbaToHsv(color);
|
||||
hsv.V -= amount;
|
||||
return HsvToRgb(hsv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Darken a color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to lighten.</param>
|
||||
/// <param name="amount">The amount to lighten.</param>
|
||||
/// <returns>The darkened color.</returns>
|
||||
public static uint Darken(uint color, float amount)
|
||||
=> RgbaVector4ToUint(Darken(RgbaUintToVector4(color), amount));
|
||||
|
||||
/// <summary>
|
||||
/// Saturate a color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to lighten.</param>
|
||||
/// <param name="amount">The amount to lighten.</param>
|
||||
/// <returns>The saturated color.</returns>
|
||||
public static Vector4 Saturate(this Vector4 color, float amount)
|
||||
{
|
||||
var hsv = RgbaToHsv(color);
|
||||
hsv.S += amount;
|
||||
return HsvToRgb(hsv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saturate a color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to lighten.</param>
|
||||
/// <param name="amount">The amount to lighten.</param>
|
||||
/// <returns>The saturated color.</returns>
|
||||
public static uint Saturate(uint color, float amount)
|
||||
=> RgbaVector4ToUint(Saturate(RgbaUintToVector4(color), amount));
|
||||
|
||||
/// <summary>
|
||||
/// Desaturate a color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to lighten.</param>
|
||||
/// <param name="amount">The amount to lighten.</param>
|
||||
/// <returns>The desaturated color.</returns>
|
||||
public static Vector4 Desaturate(this Vector4 color, float amount)
|
||||
{
|
||||
var hsv = RgbaToHsv(color);
|
||||
hsv.S -= amount;
|
||||
return HsvToRgb(hsv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Desaturate a color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to lighten.</param>
|
||||
/// <param name="amount">The amount to lighten.</param>
|
||||
/// <returns>The desaturated color.</returns>
|
||||
public static uint Desaturate(uint color, float amount)
|
||||
=> RgbaVector4ToUint(Desaturate(RgbaUintToVector4(color), amount));
|
||||
|
||||
/// <summary>
|
||||
/// Fade a color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to lighten.</param>
|
||||
/// <param name="amount">The amount to lighten.</param>
|
||||
/// <returns>The faded color.</returns>
|
||||
public static Vector4 Fade(this Vector4 color, float amount)
|
||||
{
|
||||
var hsv = RgbaToHsv(color);
|
||||
hsv.A -= amount;
|
||||
return HsvToRgb(hsv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fade a color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color to lighten.</param>
|
||||
/// <param name="amount">The amount to lighten.</param>
|
||||
/// <returns>The faded color.</returns>
|
||||
public static uint Fade(uint color, float amount)
|
||||
=> RgbaVector4ToUint(Fade(RgbaUintToVector4(color), amount));
|
||||
|
||||
public record struct HsvaColor(float H, float S, float V, float A);
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
using Dalamud.Interface.Utility;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Components;
|
||||
|
|
@ -119,4 +121,71 @@ public static partial class ImGuiComponents
|
|||
|
||||
return button;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IconButton component to use an icon as a button with color options.
|
||||
/// </summary>
|
||||
/// <param name="icon">Icon to show.</param>
|
||||
/// <param name="text">Text to show.</param>
|
||||
/// <param name="defaultColor">The default color of the button.</param>
|
||||
/// <param name="activeColor">The color of the button when active.</param>
|
||||
/// <param name="hoveredColor">The color of the button when hovered.</param>
|
||||
/// <returns>Indicator if button is clicked.</returns>
|
||||
public static bool IconButtonWithText(FontAwesomeIcon icon, string text, Vector4? defaultColor = null, Vector4? activeColor = null, Vector4? hoveredColor = null)
|
||||
{
|
||||
var numColors = 0;
|
||||
|
||||
if (defaultColor.HasValue)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Button, defaultColor.Value);
|
||||
numColors++;
|
||||
}
|
||||
|
||||
if (activeColor.HasValue)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonActive, activeColor.Value);
|
||||
numColors++;
|
||||
}
|
||||
|
||||
if (hoveredColor.HasValue)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, hoveredColor.Value);
|
||||
numColors++;
|
||||
}
|
||||
|
||||
ImGui.PushID(text);
|
||||
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
var iconSize = ImGui.CalcTextSize(icon.ToIconString());
|
||||
ImGui.PopFont();
|
||||
|
||||
var textSize = ImGui.CalcTextSize(text);
|
||||
var dl = ImGui.GetWindowDrawList();
|
||||
var cursor = ImGui.GetCursorScreenPos();
|
||||
|
||||
var iconPadding = 3 * ImGuiHelpers.GlobalScale;
|
||||
|
||||
// Draw an ImGui button with the icon and text
|
||||
var buttonWidth = iconSize.X + textSize.X + (ImGui.GetStyle().FramePadding.X * 2) + iconPadding;
|
||||
var buttonHeight = Math.Max(iconSize.Y, textSize.Y) + (ImGui.GetStyle().FramePadding.Y * 2);
|
||||
var button = ImGui.Button(string.Empty, new Vector2(buttonWidth, buttonHeight));
|
||||
|
||||
// Draw the icon on the window drawlist
|
||||
var iconPos = new Vector2(cursor.X + ImGui.GetStyle().FramePadding.X, cursor.Y + ImGui.GetStyle().FramePadding.Y);
|
||||
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
dl.AddText(iconPos, ImGui.GetColorU32(ImGuiCol.Text), icon.ToIconString());
|
||||
ImGui.PopFont();
|
||||
|
||||
// Draw the text on the window drawlist
|
||||
var textPos = new Vector2(iconPos.X + iconSize.X + iconPadding, cursor.Y + ImGui.GetStyle().FramePadding.Y);
|
||||
dl.AddText(textPos, ImGui.GetColorU32(ImGuiCol.Text), text);
|
||||
|
||||
ImGui.PopID();
|
||||
|
||||
if (numColors > 0)
|
||||
ImGui.PopStyleColor(numColors);
|
||||
|
||||
return button;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ internal partial class DragDropManager
|
|||
public static extern int RevokeDragDrop(nint hwnd);
|
||||
|
||||
[DllImport("shell32.dll")]
|
||||
public static extern int DragQueryFile(IntPtr hDrop, uint iFile, StringBuilder lpszFile, int cch);
|
||||
public static extern int DragQueryFileW(IntPtr hDrop, uint iFile, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpszFile, int cch);
|
||||
}
|
||||
}
|
||||
#pragma warning restore SA1600 // Elements should be documented
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ internal partial class DragDropManager : DragDropManager.IDropTarget
|
|||
try
|
||||
{
|
||||
data.GetData(ref this.formatEtc, out var stgMedium);
|
||||
var numFiles = DragDropInterop.DragQueryFile(stgMedium.unionmember, uint.MaxValue, new StringBuilder(), 0);
|
||||
var numFiles = DragDropInterop.DragQueryFileW(stgMedium.unionmember, uint.MaxValue, new StringBuilder(), 0);
|
||||
var files = new string[numFiles];
|
||||
var sb = new StringBuilder(1024);
|
||||
var directoryCount = 0;
|
||||
|
|
@ -212,11 +212,11 @@ internal partial class DragDropManager : DragDropManager.IDropTarget
|
|||
for (var i = 0u; i < numFiles; ++i)
|
||||
{
|
||||
sb.Clear();
|
||||
var ret = DragDropInterop.DragQueryFile(stgMedium.unionmember, i, sb, sb.Capacity);
|
||||
var ret = DragDropInterop.DragQueryFileW(stgMedium.unionmember, i, sb, sb.Capacity);
|
||||
if (ret >= sb.Capacity)
|
||||
{
|
||||
sb.Capacity = ret + 1;
|
||||
ret = DragDropInterop.DragQueryFile(stgMedium.unionmember, i, sb, sb.Capacity);
|
||||
ret = DragDropInterop.DragQueryFileW(stgMedium.unionmember, i, sb, sb.Capacity);
|
||||
}
|
||||
|
||||
if (ret > 0 && ret < sb.Capacity)
|
||||
|
|
|
|||
|
|
@ -525,7 +525,8 @@ internal class DalamudInterface : IDisposable, IServiceType
|
|||
|
||||
private void DrawCreditsDarkeningAnimation()
|
||||
{
|
||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.WindowRounding, 0f);
|
||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.WindowRounding | ImGuiStyleVar.WindowBorderSize, 0f);
|
||||
using var color = ImRaii.PushColor(ImGuiCol.WindowBg, new Vector4(0, 0, 0, 0));
|
||||
|
||||
ImGui.SetNextWindowPos(new Vector2(0, 0));
|
||||
ImGui.SetNextWindowSize(ImGuiHelpers.MainViewport.Size);
|
||||
|
|
|
|||
|
|
@ -231,6 +231,40 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
|||
return this.im.LoadImageFromDxgiFormat(buffer.RawData, pitch, buffer.Width, buffer.Height, (Format)dxgiFormat);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string GetSubstitutedPath(string originalPath)
|
||||
{
|
||||
if (this.InterceptTexDataLoad == null)
|
||||
return originalPath;
|
||||
|
||||
string? interceptPath = null;
|
||||
this.InterceptTexDataLoad.Invoke(originalPath, ref interceptPath);
|
||||
|
||||
if (interceptPath != null)
|
||||
{
|
||||
Log.Verbose("Intercept: {OriginalPath} => {ReplacePath}", originalPath, interceptPath);
|
||||
return interceptPath;
|
||||
}
|
||||
|
||||
return originalPath;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void InvalidatePaths(IEnumerable<string> paths)
|
||||
{
|
||||
lock (this.activeTextures)
|
||||
{
|
||||
foreach (var path in paths)
|
||||
{
|
||||
if (!this.activeTextures.TryGetValue(path, out var info) || info == null)
|
||||
continue;
|
||||
|
||||
info.Wrap?.Dispose();
|
||||
info.Wrap = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
|
|
@ -251,110 +285,102 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
|||
/// Get texture info.
|
||||
/// </summary>
|
||||
/// <param name="path">Path to the texture.</param>
|
||||
/// <param name="refresh">Whether or not the texture should be reloaded if it was unloaded.</param>
|
||||
/// <param name="rethrow">
|
||||
/// If true, exceptions caused by texture load will not be caught.
|
||||
/// If false, exceptions will be caught and a dummy texture will be returned to prevent plugins from using invalid texture handles.
|
||||
/// </param>
|
||||
/// <returns>Info object storing texture metadata.</returns>
|
||||
internal TextureInfo GetInfo(string path, bool refresh = true, bool rethrow = false)
|
||||
internal TextureInfo GetInfo(string path, bool rethrow = false)
|
||||
{
|
||||
TextureInfo? info;
|
||||
lock (this.activeTextures)
|
||||
{
|
||||
this.activeTextures.TryGetValue(path, out info);
|
||||
if (!this.activeTextures.TryGetValue(path, out info))
|
||||
{
|
||||
Debug.Assert(rethrow, "This should never run when getting outside of creator");
|
||||
|
||||
info = new TextureInfo();
|
||||
this.activeTextures.Add(path, info);
|
||||
}
|
||||
|
||||
if (info == null)
|
||||
throw new Exception("null info in activeTextures");
|
||||
}
|
||||
|
||||
if (info == null)
|
||||
{
|
||||
info = new TextureInfo();
|
||||
lock (this.activeTextures)
|
||||
{
|
||||
if (!this.activeTextures.TryAdd(path, info))
|
||||
Log.Warning("Texture {Path} tracked twice", path);
|
||||
}
|
||||
}
|
||||
|
||||
if (refresh && info.KeepAliveCount == 0)
|
||||
if (info.KeepAliveCount == 0)
|
||||
info.LastAccess = DateTime.UtcNow;
|
||||
|
||||
if (info is { Wrap: not null })
|
||||
return info;
|
||||
|
||||
if (refresh)
|
||||
{
|
||||
if (!this.im.IsReady)
|
||||
if (!this.im.IsReady)
|
||||
throw new InvalidOperationException("Cannot create textures before scene is ready");
|
||||
|
||||
string? interceptPath = null;
|
||||
this.InterceptTexDataLoad?.Invoke(path, ref interceptPath);
|
||||
|
||||
if (interceptPath != null)
|
||||
// Substitute the path here for loading, instead of when getting the respective TextureInfo
|
||||
path = this.GetSubstitutedPath(path);
|
||||
|
||||
TextureWrap? wrap;
|
||||
try
|
||||
{
|
||||
// We want to load this from the disk, probably, if the path has a root
|
||||
// Not sure if this can cause issues with e.g. network drives, might have to rethink
|
||||
// and add a flag instead if it does.
|
||||
if (Path.IsPathRooted(path))
|
||||
{
|
||||
Log.Verbose("Intercept: {OriginalPath} => {ReplacePath}", path, interceptPath);
|
||||
path = interceptPath;
|
||||
}
|
||||
|
||||
TextureWrap? wrap;
|
||||
try
|
||||
{
|
||||
// We want to load this from the disk, probably, if the path has a root
|
||||
// Not sure if this can cause issues with e.g. network drives, might have to rethink
|
||||
// and add a flag instead if it does.
|
||||
if (Path.IsPathRooted(path))
|
||||
if (Path.GetExtension(path) == ".tex")
|
||||
{
|
||||
if (Path.GetExtension(path) == ".tex")
|
||||
{
|
||||
// Attempt to load via Lumina
|
||||
var file = this.dataManager.GameData.GetFileFromDisk<TexFile>(path);
|
||||
wrap = this.GetTexture(file);
|
||||
Log.Verbose("Texture {Path} loaded FS via Lumina", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Attempt to load image
|
||||
wrap = this.im.LoadImage(path);
|
||||
Log.Verbose("Texture {Path} loaded FS via LoadImage", path);
|
||||
}
|
||||
// Attempt to load via Lumina
|
||||
var file = this.dataManager.GameData.GetFileFromDisk<TexFile>(path);
|
||||
wrap = this.GetTexture(file);
|
||||
Log.Verbose("Texture {Path} loaded FS via Lumina", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load regularly from dats
|
||||
var file = this.dataManager.GetFile<TexFile>(path);
|
||||
if (file == null)
|
||||
throw new Exception("Could not load TexFile from dat.");
|
||||
|
||||
wrap = this.GetTexture(file);
|
||||
Log.Verbose("Texture {Path} loaded from SqPack", path);
|
||||
// Attempt to load image
|
||||
wrap = this.im.LoadImage(path);
|
||||
Log.Verbose("Texture {Path} loaded FS via LoadImage", path);
|
||||
}
|
||||
|
||||
if (wrap == null)
|
||||
throw new Exception("Could not create texture");
|
||||
|
||||
// TODO: We could support this, but I don't think it's worth it at the moment.
|
||||
var extents = new Vector2(wrap.Width, wrap.Height);
|
||||
if (info.Extents != Vector2.Zero && info.Extents != extents)
|
||||
Log.Warning("Texture at {Path} changed size between reloads, this is currently not supported.", path);
|
||||
|
||||
info.Extents = extents;
|
||||
}
|
||||
catch (Exception e)
|
||||
else
|
||||
{
|
||||
Log.Error(e, "Could not load texture from {Path}", path);
|
||||
|
||||
// When creating the texture initially, we want to be able to pass errors back to the plugin
|
||||
if (rethrow)
|
||||
throw;
|
||||
|
||||
// This means that the load failed due to circumstances outside of our control,
|
||||
// and we can't do anything about it. Return a dummy texture so that the plugin still
|
||||
// has something to draw.
|
||||
wrap = this.fallbackTextureWrap;
|
||||
// Load regularly from dats
|
||||
var file = this.dataManager.GetFile<TexFile>(path);
|
||||
if (file == null)
|
||||
throw new Exception("Could not load TexFile from dat.");
|
||||
|
||||
wrap = this.GetTexture(file);
|
||||
Log.Verbose("Texture {Path} loaded from SqPack", path);
|
||||
}
|
||||
|
||||
if (wrap == null)
|
||||
throw new Exception("Could not create texture");
|
||||
|
||||
info.Wrap = wrap;
|
||||
// TODO: We could support this, but I don't think it's worth it at the moment.
|
||||
var extents = new Vector2(wrap.Width, wrap.Height);
|
||||
if (info.Extents != Vector2.Zero && info.Extents != extents)
|
||||
Log.Warning("Texture at {Path} changed size between reloads, this is currently not supported.", path);
|
||||
|
||||
info.Extents = extents;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e, "Could not load texture from {Path}", path);
|
||||
|
||||
// When creating the texture initially, we want to be able to pass errors back to the plugin
|
||||
if (rethrow)
|
||||
throw;
|
||||
|
||||
// This means that the load failed due to circumstances outside of our control,
|
||||
// and we can't do anything about it. Return a dummy texture so that the plugin still
|
||||
// has something to draw.
|
||||
wrap = this.fallbackTextureWrap;
|
||||
|
||||
// Prevent divide-by-zero
|
||||
if (info.Extents == Vector2.Zero)
|
||||
info.Extents = Vector2.One;
|
||||
}
|
||||
|
||||
info.Wrap = wrap;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
@ -366,15 +392,23 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
|||
/// <param name="keepAlive">Whether or not this handle was created in keep-alive mode.</param>
|
||||
internal void NotifyTextureDisposed(string path, bool keepAlive)
|
||||
{
|
||||
var info = this.GetInfo(path, false);
|
||||
info.RefCount--;
|
||||
lock (this.activeTextures)
|
||||
{
|
||||
if (!this.activeTextures.TryGetValue(path, out var info))
|
||||
{
|
||||
Log.Warning("Disposing texture that didn't exist: {Path}", path);
|
||||
return;
|
||||
}
|
||||
|
||||
info.RefCount--;
|
||||
|
||||
if (keepAlive)
|
||||
info.KeepAliveCount--;
|
||||
if (keepAlive)
|
||||
info.KeepAliveCount--;
|
||||
|
||||
// Clean it up by the next update. If it's re-requested in-between, we don't reload it.
|
||||
if (info.RefCount <= 0)
|
||||
info.LastAccess = default;
|
||||
// Clean it up by the next update. If it's re-requested in-between, we don't reload it.
|
||||
if (info.RefCount <= 0)
|
||||
info.LastAccess = default;
|
||||
}
|
||||
}
|
||||
|
||||
private static string FormatIconPath(uint iconId, string? type, bool highResolution)
|
||||
|
|
@ -390,15 +424,22 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
|
|||
|
||||
private TextureManagerTextureWrap? CreateWrap(string path, bool keepAlive)
|
||||
{
|
||||
// This will create the texture.
|
||||
// That's fine, it's probably used immediately and this will let the plugin catch load errors.
|
||||
var info = this.GetInfo(path, rethrow: true);
|
||||
info.RefCount++;
|
||||
lock (this.activeTextures)
|
||||
{
|
||||
// This will create the texture.
|
||||
// That's fine, it's probably used immediately and this will let the plugin catch load errors.
|
||||
var info = this.GetInfo(path, rethrow: true);
|
||||
|
||||
if (keepAlive)
|
||||
info.KeepAliveCount++;
|
||||
// We need to increase the refcounts here while locking the collection!
|
||||
// Otherwise, if this is loaded from a task, cleanup might already try to delete it
|
||||
// before it can be increased.
|
||||
info.RefCount++;
|
||||
|
||||
return new TextureManagerTextureWrap(path, info.Extents, keepAlive, this);
|
||||
if (keepAlive)
|
||||
info.KeepAliveCount++;
|
||||
|
||||
return new TextureManagerTextureWrap(path, info.Extents, keepAlive, this);
|
||||
}
|
||||
}
|
||||
|
||||
private void FrameworkOnUpdate(Framework fw)
|
||||
|
|
@ -588,7 +629,9 @@ internal class TextureManagerTextureWrap : IDalamudTextureWrap
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IntPtr ImGuiHandle => this.manager.GetInfo(this.path).Wrap!.ImGuiHandle;
|
||||
public IntPtr ImGuiHandle => !this.IsDisposed ?
|
||||
this.manager.GetInfo(this.path).Wrap!.ImGuiHandle :
|
||||
throw new InvalidOperationException("Texture already disposed. You may not render it.");
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int Width { get; private set; }
|
||||
|
|
|
|||
|
|
@ -64,6 +64,12 @@ internal class TargetWidget : IDataWindowWidget
|
|||
|
||||
if (targetMgr.SoftTarget != null)
|
||||
Util.PrintGameObject(targetMgr.SoftTarget, "SoftTarget", this.resolveGameData);
|
||||
|
||||
if (targetMgr.GPoseTarget != null)
|
||||
Util.PrintGameObject(targetMgr.GPoseTarget, "GPoseTarget", this.resolveGameData);
|
||||
|
||||
if (targetMgr.MouseOverNameplateTarget != null)
|
||||
Util.PrintGameObject(targetMgr.MouseOverNameplateTarget, "MouseOverNameplateTarget", this.resolveGameData);
|
||||
|
||||
if (ImGui.Button("Clear CT"))
|
||||
targetMgr.Target = null;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
|||
using Dalamud.Networking.Http;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Utility;
|
||||
using Serilog;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows.PluginInstaller;
|
||||
|
||||
|
|
@ -44,27 +45,35 @@ internal class DalamudChangelogManager
|
|||
this.Changelogs = null;
|
||||
|
||||
var dalamudChangelogs = await client.GetFromJsonAsync<List<DalamudChangelog>>(DalamudChangelogUrl);
|
||||
var changelogs = dalamudChangelogs.Select(x => new DalamudChangelogEntry(x)).Cast<IChangelogEntry>();
|
||||
var changelogs = dalamudChangelogs.Select(x => new DalamudChangelogEntry(x)).Cast<IChangelogEntry>().ToList();
|
||||
|
||||
foreach (var plugin in this.manager.InstalledPlugins)
|
||||
{
|
||||
if (!plugin.IsThirdParty)
|
||||
if (!plugin.IsThirdParty && !plugin.IsDev)
|
||||
{
|
||||
var pluginChangelogs = await client.GetFromJsonAsync<PluginHistory>(string.Format(
|
||||
PluginChangelogUrl,
|
||||
plugin.Manifest.InternalName,
|
||||
plugin.Manifest.Dip17Channel));
|
||||
try
|
||||
{
|
||||
var pluginChangelogs = await client.GetFromJsonAsync<PluginHistory>(string.Format(
|
||||
PluginChangelogUrl,
|
||||
plugin.Manifest.InternalName,
|
||||
plugin.Manifest.Dip17Channel));
|
||||
|
||||
changelogs = changelogs.Concat(pluginChangelogs.Versions
|
||||
.Where(x => x.Dip17Track == plugin.Manifest.Dip17Channel)
|
||||
.Select(x => new PluginChangelogEntry(plugin, x)));
|
||||
changelogs.AddRange(pluginChangelogs.Versions
|
||||
.Where(x => x.Dip17Track ==
|
||||
plugin.Manifest.Dip17Channel)
|
||||
.Select(x => new PluginChangelogEntry(plugin, x)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Failed to load changelog for {PluginName}", plugin.Manifest.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.Manifest.Changelog.IsNullOrWhitespace())
|
||||
continue;
|
||||
|
||||
changelogs = changelogs.Append(new PluginChangelogEntry(plugin));
|
||||
changelogs.Add(new PluginChangelogEntry(plugin));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,9 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
|
||||
private OperationStatus installStatus = OperationStatus.Idle;
|
||||
private OperationStatus updateStatus = OperationStatus.Idle;
|
||||
|
||||
private OperationStatus enableDisableStatus = OperationStatus.Idle;
|
||||
private Guid enableDisableWorkingPluginId = Guid.Empty;
|
||||
|
||||
private LoadingIndicatorKind loadingIndicatorKind = LoadingIndicatorKind.Unknown;
|
||||
|
||||
|
|
@ -968,7 +970,14 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
{
|
||||
this.dalamudChangelogRefreshTaskCts = new CancellationTokenSource();
|
||||
this.dalamudChangelogRefreshTask =
|
||||
Task.Run(this.dalamudChangelogManager.ReloadChangelogAsync, this.dalamudChangelogRefreshTaskCts.Token);
|
||||
Task.Run(this.dalamudChangelogManager.ReloadChangelogAsync, this.dalamudChangelogRefreshTaskCts.Token)
|
||||
.ContinueWith(t =>
|
||||
{
|
||||
if (!t.IsCompletedSuccessfully)
|
||||
{
|
||||
Log.Error(t.Exception, "Failed to load changelogs.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
@ -1431,7 +1440,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
ImGui.Button($"{buttonText}##{buttonText}testing");
|
||||
}
|
||||
|
||||
this.DrawVisitRepoUrlButton("https://google.com");
|
||||
this.DrawVisitRepoUrlButton("https://google.com", true);
|
||||
|
||||
if (this.testerImages != null)
|
||||
{
|
||||
|
|
@ -1948,6 +1957,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
}
|
||||
else
|
||||
{
|
||||
using var color = ImRaii.PushColor(ImGuiCol.Button, ImGuiColors.DalamudRed.Darken(0.3f).Fade(0.4f));
|
||||
var buttonText = Locs.PluginButton_InstallVersion(versionString);
|
||||
if (ImGui.Button($"{buttonText}##{buttonText}{index}"))
|
||||
{
|
||||
|
|
@ -1955,11 +1965,19 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
this.DrawVisitRepoUrlButton(manifest.RepoUrl);
|
||||
ImGui.SameLine();
|
||||
ImGuiHelpers.ScaledDummy(10);
|
||||
ImGui.SameLine();
|
||||
|
||||
this.DrawVisitRepoUrlButton(manifest.RepoUrl, true);
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiHelpers.ScaledDummy(3);
|
||||
ImGui.SameLine();
|
||||
|
||||
if (!manifest.SourceRepo.IsThirdParty && manifest.AcceptsFeedback)
|
||||
{
|
||||
this.DrawSendFeedbackButton(manifest, false);
|
||||
this.DrawSendFeedbackButton(manifest, false, true);
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
|
|
@ -2143,6 +2161,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
|
||||
ImGui.PushID($"installed{index}{plugin.Manifest.InternalName}");
|
||||
var hasChangelog = !plugin.Manifest.Changelog.IsNullOrEmpty();
|
||||
var didDrawChangelogInsideCollapsible = false;
|
||||
|
||||
if (this.DrawPluginCollapsingHeader(label, plugin, plugin.Manifest, plugin.IsThirdParty, trouble, availablePluginUpdate != default, false, false, plugin.IsOrphaned, () => this.DrawInstalledPluginContextMenu(plugin, testingOptIn), index))
|
||||
{
|
||||
|
|
@ -2220,18 +2239,20 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
{
|
||||
ImGuiHelpers.SafeTextWrapped($"{command.Key} → {command.Value.HelpMessage}");
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(3);
|
||||
}
|
||||
}
|
||||
|
||||
// Controls
|
||||
this.DrawPluginControlButton(plugin, availablePluginUpdate);
|
||||
this.DrawDevPluginButtons(plugin);
|
||||
this.DrawVisitRepoUrlButton(plugin.Manifest.RepoUrl, false);
|
||||
this.DrawDeletePluginButton(plugin);
|
||||
this.DrawVisitRepoUrlButton(plugin.Manifest.RepoUrl);
|
||||
|
||||
if (canFeedback)
|
||||
{
|
||||
this.DrawSendFeedbackButton(plugin.Manifest, plugin.IsTesting);
|
||||
this.DrawSendFeedbackButton(plugin.Manifest, plugin.IsTesting, false);
|
||||
}
|
||||
|
||||
if (availablePluginUpdate != default && !plugin.IsDev)
|
||||
|
|
@ -2251,6 +2272,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
{
|
||||
if (ImGui.TreeNode(Locs.PluginBody_CurrentChangeLog(plugin.EffectiveVersion)))
|
||||
{
|
||||
didDrawChangelogInsideCollapsible = true;
|
||||
this.DrawInstalledPluginChangelog(plugin.Manifest);
|
||||
ImGui.TreePop();
|
||||
}
|
||||
|
|
@ -2267,7 +2289,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
if (thisWasUpdated && hasChangelog)
|
||||
if (thisWasUpdated && hasChangelog && !didDrawChangelogInsideCollapsible)
|
||||
{
|
||||
this.DrawInstalledPluginChangelog(plugin.Manifest);
|
||||
}
|
||||
|
|
@ -2360,6 +2382,10 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
var config = Service<DalamudConfiguration>.Get();
|
||||
|
||||
var applicableForProfiles = plugin.Manifest.SupportsProfiles && !plugin.IsDev;
|
||||
var profilesThatWantThisPlugin = profileManager.Profiles
|
||||
.Where(x => x.WantsPlugin(plugin.InternalName) != null)
|
||||
.ToArray();
|
||||
var isInSingleProfile = profilesThatWantThisPlugin.Length == 1;
|
||||
var isDefaultPlugin = profileManager.IsInDefaultProfile(plugin.Manifest.InternalName);
|
||||
|
||||
// Disable everything if the updater is running or another plugin is operating
|
||||
|
|
@ -2443,6 +2469,10 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
var inMultipleProfiles = !isDefaultPlugin && !isInSingleProfile;
|
||||
var inSingleNonDefaultProfileWhichIsDisabled =
|
||||
isInSingleProfile && !profilesThatWantThisPlugin.First().IsEnabled;
|
||||
|
||||
if (plugin.State is PluginState.UnloadError or PluginState.LoadError or PluginState.DependencyResolutionFailed && !plugin.IsDev)
|
||||
{
|
||||
ImGuiComponents.DisabledButton(FontAwesomeIcon.Frown);
|
||||
|
|
@ -2450,80 +2480,83 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(Locs.PluginButtonToolTip_UnloadFailed);
|
||||
}
|
||||
else if (disabled || !isDefaultPlugin)
|
||||
else if (this.enableDisableStatus == OperationStatus.InProgress && this.enableDisableWorkingPluginId == plugin.Manifest.WorkingPluginId)
|
||||
{
|
||||
ImGuiComponents.DisabledToggleButton(toggleId, this.loadingIndicatorKind == LoadingIndicatorKind.EnablingSingle);
|
||||
}
|
||||
else if (disabled || inMultipleProfiles || inSingleNonDefaultProfileWhichIsDisabled)
|
||||
{
|
||||
ImGuiComponents.DisabledToggleButton(toggleId, isLoadedAndUnloadable);
|
||||
|
||||
if (!isDefaultPlugin && ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(Locs.PluginButtonToolTip_NeedsToBeInDefault);
|
||||
if (inMultipleProfiles && ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(Locs.PluginButtonToolTip_NeedsToBeInSingleProfile);
|
||||
else if (inSingleNonDefaultProfileWhichIsDisabled && ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(Locs.PluginButtonToolTip_SingleProfileDisabled(profilesThatWantThisPlugin.First().Name));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ImGuiComponents.ToggleButton(toggleId, ref isLoadedAndUnloadable))
|
||||
{
|
||||
// TODO: We can technically let profile manager take care of unloading/loading the plugin, but we should figure out error handling first.
|
||||
var applicableProfile = profilesThatWantThisPlugin.First();
|
||||
Log.Verbose("Switching {InternalName} in {Profile} to {State}",
|
||||
plugin.InternalName, applicableProfile, isLoadedAndUnloadable);
|
||||
|
||||
try
|
||||
{
|
||||
// Reload the devPlugin manifest if it's a dev plugin
|
||||
// The plugin might rely on changed values in the manifest
|
||||
if (plugin.IsDev)
|
||||
{
|
||||
plugin.ReloadManifest();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Could not reload DevPlugin manifest");
|
||||
}
|
||||
|
||||
// NOTE: We don't use the profile manager to actually handle loading/unloading here,
|
||||
// because that might cause us to show an error if a plugin we don't actually care about
|
||||
// fails to load/unload. Instead, we just do it ourselves and then update the profile.
|
||||
// There is probably a smarter way to handle this, but it's probably more code.
|
||||
if (!isLoadedAndUnloadable)
|
||||
{
|
||||
this.enableDisableStatus = OperationStatus.InProgress;
|
||||
this.loadingIndicatorKind = LoadingIndicatorKind.DisablingSingle;
|
||||
this.enableDisableWorkingPluginId = plugin.Manifest.WorkingPluginId;
|
||||
|
||||
Task.Run(() =>
|
||||
Task.Run(async () =>
|
||||
{
|
||||
if (plugin.IsDev)
|
||||
{
|
||||
plugin.ReloadManifest();
|
||||
}
|
||||
|
||||
var unloadTask = Task.Run(() => plugin.UnloadAsync())
|
||||
.ContinueWith(this.DisplayErrorContinuation, Locs.ErrorModal_UnloadFail(plugin.Name));
|
||||
|
||||
unloadTask.Wait();
|
||||
if (!unloadTask.Result)
|
||||
{
|
||||
this.enableDisableStatus = OperationStatus.Complete;
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Work this out
|
||||
Task.Run(() => profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.InternalName, false, false))
|
||||
.GetAwaiter().GetResult();
|
||||
this.enableDisableStatus = OperationStatus.Complete;
|
||||
await plugin.UnloadAsync();
|
||||
await applicableProfile.AddOrUpdateAsync(
|
||||
plugin.Manifest.InternalName, false, false);
|
||||
|
||||
notifications.AddNotification(Locs.Notifications_PluginDisabled(plugin.Manifest.Name), Locs.Notifications_PluginDisabledTitle, NotificationType.Success);
|
||||
}).ContinueWith(t =>
|
||||
{
|
||||
this.enableDisableStatus = OperationStatus.Complete;
|
||||
this.DisplayErrorContinuation(t, Locs.ErrorModal_UnloadFail(plugin.Name));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var enabler = new Task(() =>
|
||||
async Task Enabler()
|
||||
{
|
||||
this.enableDisableStatus = OperationStatus.InProgress;
|
||||
this.loadingIndicatorKind = LoadingIndicatorKind.EnablingSingle;
|
||||
this.enableDisableWorkingPluginId = plugin.Manifest.WorkingPluginId;
|
||||
|
||||
if (plugin.IsDev)
|
||||
{
|
||||
plugin.ReloadManifest();
|
||||
}
|
||||
await applicableProfile.AddOrUpdateAsync(plugin.Manifest.InternalName, true, false);
|
||||
await plugin.LoadAsync(PluginLoadReason.Installer);
|
||||
|
||||
// TODO: Work this out
|
||||
Task.Run(() => profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.InternalName, true, false))
|
||||
.GetAwaiter().GetResult();
|
||||
notifications.AddNotification(Locs.Notifications_PluginEnabled(plugin.Manifest.Name), Locs.Notifications_PluginEnabledTitle, NotificationType.Success);
|
||||
}
|
||||
|
||||
var loadTask = Task.Run(() => plugin.LoadAsync(PluginLoadReason.Installer))
|
||||
.ContinueWith(
|
||||
this.DisplayErrorContinuation,
|
||||
Locs.ErrorModal_LoadFail(plugin.Name));
|
||||
|
||||
loadTask.Wait();
|
||||
var continuation = (Task t) =>
|
||||
{
|
||||
this.enableDisableStatus = OperationStatus.Complete;
|
||||
|
||||
if (!loadTask.Result)
|
||||
return;
|
||||
|
||||
notifications.AddNotification(
|
||||
Locs.Notifications_PluginEnabled(plugin.Manifest.Name),
|
||||
Locs.Notifications_PluginEnabledTitle,
|
||||
NotificationType.Success);
|
||||
});
|
||||
this.DisplayErrorContinuation(t, Locs.ErrorModal_LoadFail(plugin.Name));
|
||||
};
|
||||
|
||||
if (availableUpdate != default && !availableUpdate.InstalledPlugin.IsDev)
|
||||
{
|
||||
|
|
@ -2533,17 +2566,19 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
|
||||
if (shouldUpdate)
|
||||
{
|
||||
// We need to update the profile right here, because PM will not enable the plugin otherwise
|
||||
await applicableProfile.AddOrUpdateAsync(plugin.InternalName, true, false);
|
||||
await this.UpdateSinglePlugin(availableUpdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
enabler.Start();
|
||||
_ = Task.Run(Enabler).ContinueWith(continuation);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
enabler.Start();
|
||||
_ = Task.Run(Enabler).ContinueWith(continuation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2558,6 +2593,9 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
{
|
||||
// Only if the plugin isn't broken.
|
||||
this.DrawOpenPluginSettingsButton(plugin);
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGuiHelpers.ScaledDummy(5, 0);
|
||||
}
|
||||
|
||||
if (applicableForProfiles && config.ProfilesEnabled)
|
||||
|
|
@ -2622,10 +2660,39 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
|
||||
private void DrawOpenPluginSettingsButton(LocalPlugin plugin)
|
||||
{
|
||||
if (plugin.DalamudInterface?.UiBuilder?.HasConfigUi ?? false)
|
||||
var hasMainUi = plugin.DalamudInterface?.UiBuilder.HasMainUi ?? false;
|
||||
var hasConfig = plugin.DalamudInterface?.UiBuilder.HasConfigUi ?? false;
|
||||
if (hasMainUi)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Cog))
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.ArrowUpRightFromSquare, Locs.PluginButton_OpenUi))
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.DalamudInterface.UiBuilder.OpenMain();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Error during OpenMain(): {plugin.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip(Locs.PluginButtonToolTip_OpenUi);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasConfig)
|
||||
{
|
||||
if (hasMainUi)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGuiHelpers.ScaledDummy(5, 0);
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Cog, Locs.PluginButton_OpenSettings))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -2633,7 +2700,7 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Error during OpenConfigUi: {plugin.Name}");
|
||||
Log.Error(ex, $"Error during OpenConfig: {plugin.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2644,10 +2711,15 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawSendFeedbackButton(IPluginManifest manifest, bool isTesting)
|
||||
private void DrawSendFeedbackButton(IPluginManifest manifest, bool isTesting, bool big)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Comment))
|
||||
|
||||
var clicked = big ?
|
||||
ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Comment, Locs.FeedbackModal_Title) :
|
||||
ImGuiComponents.IconButton(FontAwesomeIcon.Comment);
|
||||
|
||||
if (clicked)
|
||||
{
|
||||
this.feedbackPlugin = manifest;
|
||||
this.feedbackModalOnNextFrame = true;
|
||||
|
|
@ -2793,12 +2865,16 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawVisitRepoUrlButton(string? repoUrl)
|
||||
private void DrawVisitRepoUrlButton(string? repoUrl, bool big)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(repoUrl) && repoUrl.StartsWith("https://"))
|
||||
{
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.Globe))
|
||||
|
||||
var clicked = big ?
|
||||
ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Globe, "Open website") :
|
||||
ImGuiComponents.IconButton(FontAwesomeIcon.Globe);
|
||||
if (clicked)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -3221,12 +3297,18 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
public static string PluginButton_Unload => Loc.Localize("InstallerUnload", "Unload");
|
||||
|
||||
public static string PluginButton_SafeMode => Loc.Localize("InstallerSafeModeButton", "Can't change in safe mode");
|
||||
|
||||
public static string PluginButton_OpenUi => Loc.Localize("InstallerOpenPluginUi", "Open");
|
||||
|
||||
public static string PluginButton_OpenSettings => Loc.Localize("InstallerOpenPluginSettings", "Settings");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Plugin button tooltips
|
||||
|
||||
public static string PluginButtonToolTip_OpenUi => Loc.Localize("InstallerTooltipOpenUi", "Open this plugin's interface");
|
||||
|
||||
public static string PluginButtonToolTip_OpenConfiguration => Loc.Localize("InstallerOpenConfig", "Open Configuration");
|
||||
public static string PluginButtonToolTip_OpenConfiguration => Loc.Localize("InstallerTooltipOpenConfig", "Open this plugin's settings");
|
||||
|
||||
public static string PluginButtonToolTip_PickProfiles => Loc.Localize("InstallerPickProfiles", "Pick collections for this plugin");
|
||||
|
||||
|
|
@ -3253,6 +3335,10 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
public static string PluginButtonToolTip_UnloadFailed => Loc.Localize("InstallerLoadUnloadFailedTooltip", "Plugin load/unload failed, please restart your game and try again.");
|
||||
|
||||
public static string PluginButtonToolTip_NeedsToBeInDefault => Loc.Localize("InstallerUnloadNeedsToBeInDefault", "This plugin is in one or more collections. If you want to enable or disable it, please do so by enabling or disabling the collections it is in.\nIf you want to manage it manually, remove it from all collections.");
|
||||
|
||||
public static string PluginButtonToolTip_NeedsToBeInSingleProfile => Loc.Localize("InstallerUnloadNeedsToBeInSingleProfile", "This plugin is in more than one collection. If you want to enable or disable it, please do so by enabling or disabling the collections it is in.\nIf you want to manage it here, make sure it is only in a single collection.");
|
||||
|
||||
public static string PluginButtonToolTip_SingleProfileDisabled(string name) => Loc.Localize("InstallerSingleProfileDisabled", "The collection '{0}' which contains this plugin is disabled.\nPlease enable it in the collections manager to toggle the plugin individually.").Format(name);
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ internal class ProfileManagerWidget
|
|||
private void DrawTutorial(string modalTitle)
|
||||
{
|
||||
var open = true;
|
||||
ImGui.SetNextWindowSize(new Vector2(450, 350), ImGuiCond.Appearing);
|
||||
ImGui.SetNextWindowSize(new Vector2(650, 550), ImGuiCond.Appearing);
|
||||
using (var popup = ImRaii.PopupModal(modalTitle, ref open))
|
||||
{
|
||||
if (popup)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,14 @@ public abstract class SettingsEntry
|
|||
/// </summary>
|
||||
public abstract void Draw();
|
||||
|
||||
/// <summary>
|
||||
/// Function to be called when the tab is opened.
|
||||
/// </summary>
|
||||
public virtual void OnOpen()
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Function to be called when the tab is closed.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,10 @@ public abstract class SettingsTab : IDisposable
|
|||
|
||||
public virtual void OnOpen()
|
||||
{
|
||||
// ignored
|
||||
foreach (var settingsEntry in this.Entries)
|
||||
{
|
||||
settingsEntry.OnOpen();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnClose()
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class SettingsTabExperimental : SettingsTab
|
|||
c => c.DoPluginTest,
|
||||
(v, c) => c.DoPluginTest = v),
|
||||
new HintSettingsEntry(
|
||||
Loc.Localize("DalamudSettingsPluginTestWarning", "Testing plugins may not have been vetted before being published. Please only enable this if you are aware of the risks."),
|
||||
Loc.Localize("DalamudSettingsPluginTestWarning", "Testing plugins may contain bugs or crash your game. Please only enable this if you are aware of the risks."),
|
||||
ImGuiColors.DalamudRed),
|
||||
|
||||
new GapSettingsEntry(5),
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ using Dalamud.Interface.Components;
|
|||
using Dalamud.Interface.Utility;
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Utility;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows.Settings.Widgets;
|
||||
|
|
@ -24,7 +25,13 @@ public class ThirdRepoSettingsEntry : SettingsEntry
|
|||
private bool thirdRepoListChanged;
|
||||
private string thirdRepoTempUrl = string.Empty;
|
||||
private string thirdRepoAddError = string.Empty;
|
||||
private DateTime timeSinceOpened;
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
this.timeSinceOpened = DateTime.Now;
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
this.thirdRepoList =
|
||||
|
|
@ -52,6 +59,8 @@ public class ThirdRepoSettingsEntry : SettingsEntry
|
|||
|
||||
public override void Draw()
|
||||
{
|
||||
var config = Service<DalamudConfiguration>.Get();
|
||||
|
||||
using var id = ImRaii.PushId("thirdRepo");
|
||||
ImGui.TextUnformatted(Loc.Localize("DalamudSettingsCustomRepo", "Custom Plugin Repositories"));
|
||||
if (this.thirdRepoListChanged)
|
||||
|
|
@ -62,12 +71,58 @@ public class ThirdRepoSettingsEntry : SettingsEntry
|
|||
ImGui.TextUnformatted(Loc.Localize("DalamudSettingsChanged", "(Changed)"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingCustomRepoHint", "Add custom plugin repositories."));
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudRed, Loc.Localize("DalamudSettingCustomRepoWarning", "We cannot take any responsibility for third-party plugins and repositories."));
|
||||
|
||||
ImGuiHelpers.ScaledDummy(2);
|
||||
|
||||
config.ThirdRepoSpeedbumpDismissed ??= config.ThirdRepoList.Any(x => x.IsEnabled);
|
||||
var disclaimerDismissed = config.ThirdRepoSpeedbumpDismissed.Value;
|
||||
|
||||
ImGui.PushFont(InterfaceManager.IconFont);
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudRed, FontAwesomeIcon.ExclamationTriangle.ToIconString());
|
||||
ImGui.PopFont();
|
||||
ImGui.SameLine();
|
||||
ImGuiHelpers.ScaledDummy(2);
|
||||
ImGui.SameLine();
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudRed, Loc.Localize("DalamudSettingCustomRepoWarningReadThis", "READ THIS FIRST!"));
|
||||
ImGui.SameLine();
|
||||
ImGuiHelpers.ScaledDummy(2);
|
||||
ImGui.SameLine();
|
||||
ImGui.PushFont(InterfaceManager.IconFont);
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudRed, FontAwesomeIcon.ExclamationTriangle.ToIconString());
|
||||
ImGui.PopFont();
|
||||
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudRed, Loc.Localize("DalamudSettingCustomRepoWarning", "We cannot take any responsibility for custom plugins and repositories."));
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudRed, Loc.Localize("DalamudSettingCustomRepoWarning5", "If someone told you to copy/paste something here, it's very possible that you are being scammed or taken advantage of."));
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudRed, Loc.Localize("DalamudSettingCustomRepoWarning2", "Plugins have full control over your PC, like any other program, and may cause harm or crashes."));
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudRed, Loc.Localize("DalamudSettingCustomRepoWarning4", "They can delete your character, upload your family photos and burn down your house."));
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudRed, Loc.Localize("DalamudSettingCustomRepoWarning3", "Please make absolutely sure that you only install third-party plugins from developers you trust."));
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudRed, Loc.Localize("DalamudSettingCustomRepoWarning4", "They can delete your character, steal your FC or Discord account, and burn down your house."));
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudRed, Loc.Localize("DalamudSettingCustomRepoWarning3", "Please make absolutely sure that you only install plugins from developers you trust."));
|
||||
|
||||
if (!disclaimerDismissed)
|
||||
{
|
||||
const int speedbumpTime = 15;
|
||||
var elapsed = DateTime.Now - this.timeSinceOpened;
|
||||
if (elapsed < TimeSpan.FromSeconds(speedbumpTime))
|
||||
{
|
||||
ImGui.BeginDisabled();
|
||||
ImGui.Button(
|
||||
Loc.Localize("DalamudSettingCustomRepoWarningPleaseWait", "Please wait {0} seconds...").Format(speedbumpTime - elapsed.Seconds));
|
||||
ImGui.EndDisabled();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ImGui.Button(Loc.Localize("DalamudSettingCustomRepoWarningIReadIt", "Ok, I have read and understood this warning")))
|
||||
{
|
||||
config.ThirdRepoSpeedbumpDismissed = true;
|
||||
config.QueueSave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiHelpers.ScaledDummy(2);
|
||||
|
||||
using var disabled = ImRaii.Disabled(!disclaimerDismissed);
|
||||
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
|
||||
|
|
|
|||
|
|
@ -98,16 +98,17 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
|||
public override void Draw()
|
||||
{
|
||||
var scale = ImGui.GetIO().FontGlobalScale;
|
||||
|
||||
var tsm = Service<TitleScreenMenu>.Get();
|
||||
var entries = Service<TitleScreenMenu>.Get().Entries
|
||||
.OrderByDescending(x => x.IsInternal)
|
||||
.ToList();
|
||||
|
||||
switch (this.state)
|
||||
{
|
||||
case State.Show:
|
||||
{
|
||||
for (var i = 0; i < tsm.Entries.Count; i++)
|
||||
for (var i = 0; i < entries.Count; i++)
|
||||
{
|
||||
var entry = tsm.Entries[i];
|
||||
var entry = entries[i];
|
||||
|
||||
if (!this.moveEasings.TryGetValue(entry.Id, out var moveEasing))
|
||||
{
|
||||
|
|
@ -173,9 +174,9 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
|||
|
||||
using (ImRaii.PushStyle(ImGuiStyleVar.Alpha, (float)this.fadeOutEasing.Value))
|
||||
{
|
||||
for (var i = 0; i < tsm.Entries.Count; i++)
|
||||
for (var i = 0; i < entries.Count; i++)
|
||||
{
|
||||
var entry = tsm.Entries[i];
|
||||
var entry = entries[i];
|
||||
|
||||
var finalPos = (i + 1) * this.shadeTexture.Height * scale;
|
||||
|
||||
|
|
@ -206,7 +207,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
|||
|
||||
case State.Hide:
|
||||
{
|
||||
if (this.DrawEntry(tsm.Entries[0], true, false, true, true, false))
|
||||
if (this.DrawEntry(entries[0], true, false, true, true, false))
|
||||
{
|
||||
this.state = State.Show;
|
||||
}
|
||||
|
|
@ -218,7 +219,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
var srcText = tsm.Entries.Select(e => e.Name).ToHashSet();
|
||||
var srcText = entries.Select(e => e.Name).ToHashSet();
|
||||
var keys = this.specialGlyphRequests.Keys.ToHashSet();
|
||||
keys.RemoveWhere(x => srcText.Contains(x));
|
||||
foreach (var key in keys)
|
||||
|
|
|
|||
|
|
@ -121,7 +121,10 @@ public class TitleScreenMenu : IServiceType
|
|||
|
||||
lock (this.entries)
|
||||
{
|
||||
var entry = new TitleScreenMenuEntry(null, priority, text, texture, onTriggered);
|
||||
var entry = new TitleScreenMenuEntry(null, priority, text, texture, onTriggered)
|
||||
{
|
||||
IsInternal = true,
|
||||
};
|
||||
this.entries.Add(entry);
|
||||
return entry;
|
||||
}
|
||||
|
|
@ -148,7 +151,10 @@ public class TitleScreenMenu : IServiceType
|
|||
var priority = entriesOfAssembly.Any()
|
||||
? unchecked(entriesOfAssembly.Select(x => x.Priority).Max() + 1)
|
||||
: 0;
|
||||
var entry = new TitleScreenMenuEntry(null, priority, text, texture, onTriggered);
|
||||
var entry = new TitleScreenMenuEntry(null, priority, text, texture, onTriggered)
|
||||
{
|
||||
IsInternal = true,
|
||||
};
|
||||
this.entries.Add(entry);
|
||||
return entry;
|
||||
}
|
||||
|
|
@ -192,6 +198,11 @@ public class TitleScreenMenu : IServiceType
|
|||
/// Gets or sets the texture of this entry.
|
||||
/// </summary>
|
||||
public TextureWrap Texture { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether or not this entry is internal.
|
||||
/// </summary>
|
||||
internal bool IsInternal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the calling assembly of this entry.
|
||||
|
|
|
|||
|
|
@ -69,6 +69,11 @@ public sealed class UiBuilder : IDisposable
|
|||
/// Event that is fired when the plugin should open its configuration interface.
|
||||
/// </summary>
|
||||
public event Action OpenConfigUi;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is fired when the plugin should open its main interface.
|
||||
/// </summary>
|
||||
public event Action OpenMainUi;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an action that is called any time ImGui fonts need to be rebuilt.<br/>
|
||||
|
|
@ -212,6 +217,11 @@ public sealed class UiBuilder : IDisposable
|
|||
/// </summary>
|
||||
internal bool HasConfigUi => this.OpenConfigUi != null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this UiBuilder has a configuration UI registered.
|
||||
/// </summary>
|
||||
internal bool HasMainUi => this.OpenMainUi != null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time this plugin took to draw on the last frame.
|
||||
/// </summary>
|
||||
|
|
@ -409,6 +419,14 @@ public sealed class UiBuilder : IDisposable
|
|||
{
|
||||
this.OpenConfigUi?.InvokeSafely();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Open the registered configuration UI, if it exists.
|
||||
/// </summary>
|
||||
internal void OpenMain()
|
||||
{
|
||||
this.OpenMainUi?.InvokeSafely();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notify this UiBuilder about plugin UI being hidden.
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public class ModuleLog
|
|||
/// <param name="exception">The exception that caused the error.</param>
|
||||
/// <param name="messageTemplate">The message template.</param>
|
||||
/// <param name="values">Values to log.</param>
|
||||
public void Error(Exception exception, string messageTemplate, params object[] values)
|
||||
public void Error(Exception? exception, string messageTemplate, params object[] values)
|
||||
=> this.WriteLog(LogEventLevel.Error, messageTemplate, exception, values);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.IoC.Internal;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
|
||||
|
|
@ -12,29 +9,9 @@ namespace Dalamud.Logging;
|
|||
/// <summary>
|
||||
/// Class offering various static methods to allow for logging in plugins.
|
||||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.ScopedService]
|
||||
public class PluginLog : IServiceType, IDisposable
|
||||
public static class PluginLog
|
||||
{
|
||||
private readonly LocalPlugin plugin;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginLog"/> class.
|
||||
/// Do not use this ctor, inject PluginLog instead.
|
||||
/// </summary>
|
||||
/// <param name="plugin">The plugin this service is scoped for.</param>
|
||||
internal PluginLog(LocalPlugin plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a prefix appended to log messages.
|
||||
/// </summary>
|
||||
public string? LogPrefix { get; set; } = null;
|
||||
|
||||
#region Legacy static "Log" prefixed Serilog style methods
|
||||
#region "Log" prefixed Serilog style methods
|
||||
|
||||
/// <summary>
|
||||
/// Log a templated message to the in-game debug log.
|
||||
|
|
@ -157,7 +134,7 @@ public class PluginLog : IServiceType, IDisposable
|
|||
|
||||
#endregion
|
||||
|
||||
#region Legacy static Serilog style methods
|
||||
#region Serilog style methods
|
||||
|
||||
/// <summary>
|
||||
/// Log a templated verbose message to the in-game debug log.
|
||||
|
|
@ -277,25 +254,6 @@ public class PluginLog : IServiceType, IDisposable
|
|||
public static void LogRaw(LogEventLevel level, Exception? exception, string messageTemplate, params object[] values)
|
||||
=> WriteLog(Assembly.GetCallingAssembly().GetName().Name, level, messageTemplate, exception, values);
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
#region New instanced methods
|
||||
|
||||
/// <summary>
|
||||
/// Log some information.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
internal void Information(string message)
|
||||
{
|
||||
Serilog.Log.Information($"[{this.plugin.InternalName}] {this.LogPrefix} {message}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static ILogger GetPluginLogger(string? pluginName)
|
||||
{
|
||||
return Serilog.Log.ForContext("SourceContext", pluginName ?? string.Empty);
|
||||
|
|
@ -314,24 +272,3 @@ public class PluginLog : IServiceType, IDisposable
|
|||
values);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class offering logging services, for a specific type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to log for.</typeparam>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.ScopedService]
|
||||
public class PluginLog<T> : PluginLog
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginLog{T}"/> class.
|
||||
/// Do not use this ctor, inject PluginLog instead.
|
||||
/// </summary>
|
||||
/// <param name="plugin">The plugin this service is scoped for.</param>
|
||||
internal PluginLog(LocalPlugin plugin)
|
||||
: base(plugin)
|
||||
{
|
||||
this.LogPrefix = typeof(T).Name;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
130
Dalamud/Logging/ScopedPluginLogService.cs
Normal file
130
Dalamud/Logging/ScopedPluginLogService.cs
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
using System;
|
||||
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.IoC.Internal;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Serilog;
|
||||
using Serilog.Core;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Dalamud.Logging;
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of <see cref="IPluginLog"/>.
|
||||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.ScopedService]
|
||||
#pragma warning disable SA1015
|
||||
[ResolveVia<IPluginLog>]
|
||||
#pragma warning restore SA1015
|
||||
public class ScopedPluginLogService : IServiceType, IPluginLog, IDisposable
|
||||
{
|
||||
private readonly LocalPlugin localPlugin;
|
||||
|
||||
private readonly LoggingLevelSwitch levelSwitch;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScopedPluginLogService"/> class.
|
||||
/// </summary>
|
||||
/// <param name="localPlugin">The plugin that owns this service.</param>
|
||||
internal ScopedPluginLogService(LocalPlugin localPlugin)
|
||||
{
|
||||
this.localPlugin = localPlugin;
|
||||
|
||||
this.levelSwitch = new LoggingLevelSwitch(this.GetDefaultLevel());
|
||||
|
||||
var loggerConfiguration = new LoggerConfiguration()
|
||||
.Enrich.WithProperty("Dalamud.PluginName", localPlugin.InternalName)
|
||||
.MinimumLevel.ControlledBy(this.levelSwitch)
|
||||
.WriteTo.Logger(Log.Logger);
|
||||
|
||||
this.Logger = loggerConfiguration.CreateLogger();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public LogEventLevel MinimumLogLevel
|
||||
{
|
||||
get => this.levelSwitch.MinimumLevel;
|
||||
set => this.levelSwitch.MinimumLevel = value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ILogger Logger { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Fatal(string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Fatal, null, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Fatal(Exception? exception, string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Fatal, exception, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Error(string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Error, null, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Error(Exception? exception, string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Error, exception, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Warning(string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Warning, null, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Warning(Exception? exception, string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Warning, exception, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Information(string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Information, null, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Information(Exception? exception, string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Information, exception, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Debug(string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Debug, null, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Debug(Exception? exception, string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Debug, exception, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Verbose(string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Verbose, null, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Verbose(Exception? exception, string messageTemplate, params object[] values) =>
|
||||
this.Write(LogEventLevel.Verbose, exception, messageTemplate, values);
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(LogEventLevel level, Exception? exception, string messageTemplate, params object[] values)
|
||||
{
|
||||
this.Logger.Write(
|
||||
level,
|
||||
exception: exception,
|
||||
messageTemplate: $"[{this.localPlugin.InternalName}] {messageTemplate}",
|
||||
values);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default log level for this plugin.
|
||||
/// </summary>
|
||||
/// <returns>A log level.</returns>
|
||||
private LogEventLevel GetDefaultLevel()
|
||||
{
|
||||
// TODO: Add some way to save log levels to a config. Or let plugins handle it?
|
||||
|
||||
return this.localPlugin.IsDev ? LogEventLevel.Verbose : LogEventLevel.Debug;
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ public sealed class DalamudPluginInterface : IDisposable
|
|||
|
||||
this.configs = Service<PluginManager>.Get().PluginConfigs;
|
||||
this.Reason = reason;
|
||||
this.SourceRepository = this.IsDev ? LocalPluginManifest.FlagDevPlugin : plugin.Manifest.InstalledFromUrl;
|
||||
this.SourceRepository = this.IsDev ? SpecialPluginSource.DevPlugin : plugin.Manifest.InstalledFromUrl;
|
||||
this.IsTesting = plugin.IsTesting;
|
||||
|
||||
this.LoadTime = DateTime.Now;
|
||||
|
|
@ -118,8 +118,8 @@ public sealed class DalamudPluginInterface : IDisposable
|
|||
/// Gets the repository from which this plugin was installed.
|
||||
///
|
||||
/// If a plugin was installed from the official/main repository, this will return the value of
|
||||
/// <see cref="LocalPluginManifest.FlagMainRepo"/>. Developer plugins will return the value of
|
||||
/// <see cref="LocalPluginManifest.FlagDevPlugin"/>.
|
||||
/// <see cref="SpecialPluginSource.MainRepo"/>. Developer plugins will return the value of
|
||||
/// <see cref="SpecialPluginSource.DevPlugin"/>.
|
||||
/// </summary>
|
||||
public string SourceRepository { get; }
|
||||
|
||||
|
|
|
|||
|
|
@ -862,7 +862,7 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
}
|
||||
|
||||
// Document the url the plugin was installed from
|
||||
manifest.InstalledFromUrl = repoManifest.SourceRepo.IsThirdParty ? repoManifest.SourceRepo.PluginMasterUrl : LocalPluginManifest.FlagMainRepo;
|
||||
manifest.InstalledFromUrl = repoManifest.SourceRepo.IsThirdParty ? repoManifest.SourceRepo.PluginMasterUrl : SpecialPluginSource.MainRepo;
|
||||
|
||||
manifest.Save(manifestFile, "installation");
|
||||
|
||||
|
|
|
|||
|
|
@ -232,4 +232,7 @@ internal class Profile
|
|||
if (apply)
|
||||
await this.manager.ApplyAllWantStatesAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString() => $"{this.Guid} ({this.Name})";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,18 +13,6 @@ namespace Dalamud.Plugin.Internal.Types.Manifest;
|
|||
/// </summary>
|
||||
internal record LocalPluginManifest : PluginManifest, ILocalPluginManifest
|
||||
{
|
||||
/// <summary>
|
||||
/// Flag indicating that a plugin was installed from the official repo.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public const string FlagMainRepo = "OFFICIAL";
|
||||
|
||||
/// <summary>
|
||||
/// Flag indicating that a plugin is a dev plugin..
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public const string FlagDevPlugin = "DEVPLUGIN";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the plugin is disabled and should not be loaded.
|
||||
/// This value supersedes the ".disabled" file functionality and should not be included in the plugin master.
|
||||
|
|
@ -51,7 +39,7 @@ internal record LocalPluginManifest : PluginManifest, ILocalPluginManifest
|
|||
/// Gets a value indicating whether this manifest is associated with a plugin that was installed from a third party
|
||||
/// repo. Unless the manifest has been manually modified, this is determined by the InstalledFromUrl being null.
|
||||
/// </summary>
|
||||
public bool IsThirdParty => !this.InstalledFromUrl.IsNullOrEmpty() && this.InstalledFromUrl != FlagMainRepo;
|
||||
public bool IsThirdParty => !this.InstalledFromUrl.IsNullOrEmpty() && this.InstalledFromUrl != SpecialPluginSource.MainRepo;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the effective version of this plugin.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
namespace Dalamud.Plugin.Internal.Types.Manifest;
|
||||
|
||||
/// <summary>
|
||||
/// A fake enum representing "special" sources for plugins.
|
||||
/// </summary>
|
||||
public static class SpecialPluginSource
|
||||
{
|
||||
/// <summary>
|
||||
/// Indication that this plugin came from the official Dalamud repository.
|
||||
/// </summary>
|
||||
public const string MainRepo = "OFFICIAL";
|
||||
|
||||
/// <summary>
|
||||
/// Indication that this plugin is loaded as a dev plugin. See also <see cref="DalamudPluginInterface.IsDev"/>.
|
||||
/// </summary>
|
||||
public const string DevPlugin = "DEVPLUGIN";
|
||||
}
|
||||
45
Dalamud/Plugin/Services/IAddonLifecycle.cs
Normal file
45
Dalamud/Plugin/Services/IAddonLifecycle.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
|
||||
using Dalamud.Memory;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
|
||||
namespace Dalamud.Plugin.Services;
|
||||
|
||||
/// <summary>
|
||||
/// This class provides events for in-game addon lifecycles.
|
||||
/// </summary>
|
||||
public interface IAddonLifecycle
|
||||
{
|
||||
/// <summary>
|
||||
/// Event that fires before an addon is being setup.
|
||||
/// </summary>
|
||||
public event Action<AddonArgs> AddonPreSetup;
|
||||
|
||||
/// <summary>
|
||||
/// Event that fires after an addon is done being setup.
|
||||
/// </summary>
|
||||
public event Action<AddonArgs> AddonPostSetup;
|
||||
|
||||
/// <summary>
|
||||
/// Event that fires before an addon is being finalized.
|
||||
/// </summary>
|
||||
public event Action<AddonArgs> AddonPreFinalize;
|
||||
|
||||
/// <summary>
|
||||
/// Addon argument data for use in event subscribers.
|
||||
/// </summary>
|
||||
public unsafe class AddonArgs
|
||||
{
|
||||
private string? addonName;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the addon this args referrers to.
|
||||
/// </summary>
|
||||
public string AddonName => this.Addon == nint.Zero ? "NullAddon" : this.addonName ??= MemoryHelper.ReadString((nint)((AtkUnitBase*)this.Addon)->Name, 0x20);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pointer to the addons AtkUnitBase.
|
||||
/// </summary>
|
||||
required public nint Addon { get; init; }
|
||||
}
|
||||
}
|
||||
128
Dalamud/Plugin/Services/IPluginLog.cs
Normal file
128
Dalamud/Plugin/Services/IPluginLog.cs
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
using System;
|
||||
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Dalamud.Plugin.Services;
|
||||
|
||||
/// <summary>
|
||||
/// An opinionated service to handle logging for plugins.
|
||||
/// </summary>
|
||||
public interface IPluginLog
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum log level that will be recorded from this plugin to Dalamud's logs. This may be set
|
||||
/// by either the plugin or by Dalamud itself.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Defaults to <see cref="LogEventLevel.Debug"/> for downloaded plugins, and <see cref="LogEventLevel.Verbose"/>
|
||||
/// for dev plugins.
|
||||
/// </remarks>
|
||||
LogEventLevel MinimumLogLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an instance of the Serilog <see cref="ILogger"/> for advanced use cases. The provided logger will handle
|
||||
/// tagging all log messages with the appropriate context variables and properties.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Not currently part of public API - will be added after some formatter work has been completed.
|
||||
/// </remarks>
|
||||
internal ILogger Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Log a <see cref="LogEventLevel.Fatal" /> message to the Dalamud log for this plugin. This log level should be
|
||||
/// used primarily for unrecoverable errors or critical faults in a plugin.
|
||||
/// </summary>
|
||||
/// <param name="messageTemplate">Message template describing the event.</param>
|
||||
/// <param name="values">Objects positionally formatted into the message template.</param>
|
||||
void Fatal(string messageTemplate, params object[] values);
|
||||
|
||||
/// <inheritdoc cref="Fatal(string,object[])"/>
|
||||
/// <param name="exception">An (optional) exception that should be recorded alongside this event.</param>
|
||||
void Fatal(Exception? exception, string messageTemplate, params object[] values);
|
||||
|
||||
/// <summary>
|
||||
/// Log a <see cref="LogEventLevel.Error" /> message to the Dalamud log for this plugin. This log level should be
|
||||
/// used for recoverable errors or faults that impact plugin functionality.
|
||||
/// </summary>
|
||||
/// <param name="messageTemplate">Message template describing the event.</param>
|
||||
/// <param name="values">Objects positionally formatted into the message template.</param>
|
||||
void Error(string messageTemplate, params object[] values);
|
||||
|
||||
/// <inheritdoc cref="Error(string,object[])"/>
|
||||
/// <param name="exception">An (optional) exception that should be recorded alongside this event.</param>
|
||||
void Error(Exception? exception, string messageTemplate, params object[] values);
|
||||
|
||||
/// <summary>
|
||||
/// Log a <see cref="LogEventLevel.Warning" /> message to the Dalamud log for this plugin. This log level should be
|
||||
/// used for user error, potential problems, or high-importance messages that should be logged.
|
||||
/// </summary>
|
||||
/// <param name="messageTemplate">Message template describing the event.</param>
|
||||
/// <param name="values">Objects positionally formatted into the message template.</param>
|
||||
void Warning(string messageTemplate, params object[] values);
|
||||
|
||||
/// <inheritdoc cref="Warning(string,object[])"/>
|
||||
/// <param name="exception">An (optional) exception that should be recorded alongside this event.</param>
|
||||
void Warning(Exception? exception, string messageTemplate, params object[] values);
|
||||
|
||||
/// <summary>
|
||||
/// Log an <see cref="LogEventLevel.Information" /> message to the Dalamud log for this plugin. This log level
|
||||
/// should be used for general plugin operations and other relevant information to track a plugin's behavior.
|
||||
/// </summary>
|
||||
/// <param name="messageTemplate">Message template describing the event.</param>
|
||||
/// <param name="values">Objects positionally formatted into the message template.</param>
|
||||
void Information(string messageTemplate, params object[] values);
|
||||
|
||||
/// <inheritdoc cref="Information(string,object[])"/>
|
||||
/// <param name="exception">An (optional) exception that should be recorded alongside this event.</param>
|
||||
void Information(Exception? exception, string messageTemplate, params object[] values);
|
||||
|
||||
/// <summary>
|
||||
/// Log a <see cref="LogEventLevel.Debug" /> message to the Dalamud log for this plugin. This log level should be
|
||||
/// used for messages or information that aid with debugging or tracing a plugin's operations, but should not be
|
||||
/// recorded unless requested.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// By default, this log level is below the default log level of Dalamud. Messages logged at this level will not be
|
||||
/// recorded unless the global log level is specifically set to Debug or lower. If information should be generally
|
||||
/// or easily accessible for support purposes without the user taking additional action, consider using the
|
||||
/// Information level instead. Developers should <em>not</em> use this log level where it can be triggered on a
|
||||
/// per-frame basis.
|
||||
/// </remarks>
|
||||
/// <param name="messageTemplate">Message template describing the event.</param>
|
||||
/// <param name="values">Objects positionally formatted into the message template.</param>
|
||||
void Debug(string messageTemplate, params object[] values);
|
||||
|
||||
/// <inheritdoc cref="Debug(string,object[])"/>
|
||||
/// <param name="exception">An (optional) exception that should be recorded alongside this event.</param>
|
||||
void Debug(Exception? exception, string messageTemplate, params object[] values);
|
||||
|
||||
/// <summary>
|
||||
/// Log a <see cref="LogEventLevel.Verbose" /> message to the Dalamud log for this plugin. This log level is
|
||||
/// intended almost primarily for development purposes and detailed tracing of a plugin's operations. Verbose logs
|
||||
/// should not be used to expose information useful for support purposes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// By default, this log level is below the default log level of Dalamud. Messages logged at this level will not be
|
||||
/// recorded unless the global log level is specifically set to Verbose. Release plugins must also set the
|
||||
/// <see cref="MinimumLogLevel"/> to <see cref="LogEventLevel.Verbose"/> to use this level, and should only do so
|
||||
/// upon specific user request (e.g. a "Enable Troubleshooting Logs" button).
|
||||
/// </remarks>
|
||||
/// <param name="messageTemplate">Message template describing the event.</param>
|
||||
/// <param name="values">Objects positionally formatted into the message template.</param>
|
||||
void Verbose(string messageTemplate, params object[] values);
|
||||
|
||||
/// <inheritdoc cref="Verbose(string,object[])"/>
|
||||
/// <param name="exception">An (optional) exception that should be recorded alongside this event.</param>
|
||||
void Verbose(Exception? exception, string messageTemplate, params object[] values);
|
||||
|
||||
/// <summary>
|
||||
/// Write a raw log event to the plugin's log. Used for interoperability with other log systems, as well as
|
||||
/// advanced use cases.
|
||||
/// </summary>
|
||||
/// <param name="level">The log level for this event.</param>
|
||||
/// <param name="exception">An (optional) exception that should be recorded alongside this event.</param>
|
||||
/// <param name="messageTemplate">Message template describing the event.</param>
|
||||
/// <param name="values">Objects positionally formatted into the message template.</param>
|
||||
void Write(LogEventLevel level, Exception? exception, string messageTemplate, params object[] values);
|
||||
}
|
||||
|
|
@ -41,4 +41,16 @@ public interface ITargetManager
|
|||
/// Set to null to clear the target.
|
||||
/// </summary>
|
||||
public GameObject? SoftTarget { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the gpose target.
|
||||
/// Set to null to clear the target.
|
||||
/// </summary>
|
||||
public GameObject? GPoseTarget { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the mouseover nameplate target.
|
||||
/// Set to null to clear the target.
|
||||
/// </summary>
|
||||
public GameObject? MouseOverNameplateTarget { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
namespace Dalamud.Plugin.Services;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Dalamud.Plugin.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Service that grants you the ability to replace texture data that is to be loaded by Dalamud.
|
||||
|
|
@ -17,4 +19,19 @@ public interface ITextureSubstitutionProvider
|
|||
/// Event that will be called once Dalamud wants to load texture data.
|
||||
/// </summary>
|
||||
public event TextureDataInterceptorDelegate? InterceptTexDataLoad;
|
||||
|
||||
/// <summary>
|
||||
/// Get a path that may be substituted by a subscriber to ITextureSubstitutionProvider.
|
||||
/// </summary>
|
||||
/// <param name="originalPath">The original path to substitute.</param>
|
||||
/// <returns>The original path, if no subscriber is registered or there is no substitution, or the substituted path.</returns>
|
||||
public string GetSubstitutedPath(string originalPath);
|
||||
|
||||
/// <summary>
|
||||
/// Notify Dalamud about substitution status for files at the specified VFS paths changing.
|
||||
/// You should call this with all paths that were either previously substituted and are no longer,
|
||||
/// and paths that are newly substituted.
|
||||
/// </summary>
|
||||
/// <param name="paths">The paths with a changed substitution status.</param>
|
||||
public void InvalidatePaths(IEnumerable<string> paths);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 155511a61559c529719d3810eaf8fb9336482878
|
||||
Subproject commit ada62e7ae60de220d1f950b03ddb8d66e9e10daf
|
||||
Loading…
Add table
Add a link
Reference in a new issue