refactor: update for api 9

This commit is contained in:
Anna 2023-09-28 21:07:21 -04:00
parent ff7a529b5a
commit d844798ce3
Signed by: anna
GPG Key ID: D0943384CD9F87D1
13 changed files with 45 additions and 45 deletions

View File

@ -9,7 +9,7 @@ namespace Glamaholic {
this.Plugin = plugin;
this.Plugin.CommandManager.AddHandler("/glamaholic", new CommandInfo(this.OnCommand) {
HelpMessage = $"Toggle visibility of the {this.Plugin.Name} window",
HelpMessage = $"Toggle visibility of the {Plugin.Name} window",
});
}

View File

@ -8,6 +8,7 @@ using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Memory;
using Dalamud.Plugin.Services;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
@ -72,8 +73,7 @@ namespace Glamaholic {
internal GameFunctions(Plugin plugin) {
this.Plugin = plugin;
SignatureHelper.Initialise(this);
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
this.Plugin.ChatGui.ChatMessage += this.OnChat;
this.Plugin.ClientState.Login += OnLogin;
@ -96,13 +96,13 @@ namespace Glamaholic {
}
}
private static void OnLogin(object? sender, EventArgs e) {
private static void OnLogin() {
_dresserContents = null;
}
private bool _wasEditing;
private void OnFrameworkUpdate(Dalamud.Game.Framework framework) {
private void OnFrameworkUpdate(IFramework framework1) {
var editing = Util.IsEditingPlate(this.Plugin.GameGui);
if (!this._wasEditing && editing) {
// cache dresser

View File

@ -35,10 +35,6 @@
<HintPath>$(DalamudLibPath)\ImGui.NET.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="ImGuiScene">
<HintPath>$(DalamudLibPath)\ImGuiScene.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Lumina">
<HintPath>$(DalamudLibPath)\Lumina.dll</HintPath>
<Private>false</Private>

View File

@ -1,40 +1,45 @@
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Game;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
namespace Glamaholic {
// ReSharper disable once ClassNeverInstantiated.Global
public class Plugin : IDalamudPlugin {
internal const string PluginName = "Glamaholic";
public string Name => PluginName;
internal static string Name => "Glamaholic";
[PluginService]
internal static IPluginLog Log { get; private set; }
[PluginService]
internal DalamudPluginInterface Interface { get; init; }
[PluginService]
internal ChatGui ChatGui { get; init; }
internal IChatGui ChatGui { get; init; }
[PluginService]
internal ClientState ClientState { get; init; }
internal IClientState ClientState { get; init; }
[PluginService]
internal CommandManager CommandManager { get; init; }
internal ICommandManager CommandManager { get; init; }
[PluginService]
internal DataManager DataManager { get; init; }
internal IDataManager DataManager { get; init; }
[PluginService]
internal Framework Framework { get; init; }
internal IFramework Framework { get; init; }
[PluginService]
internal GameGui GameGui { get; init; }
internal IGameGui GameGui { get; init; }
[PluginService]
internal SigScanner SigScanner { get; init; }
internal ISigScanner SigScanner { get; init; }
[PluginService]
internal ITextureProvider TextureProvider { get; init; }
[PluginService]
internal IGameInteropProvider GameInteropProvider { get; init; }
internal Configuration Config { get; }
internal GameFunctions Functions { get; }

View File

@ -1,17 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Interface.Internal;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using Glamaholic.Ui;
using Glamaholic.Ui.Helpers;
using ImGuiScene;
namespace Glamaholic {
internal class PluginUi : IDisposable {
internal Plugin Plugin { get; }
private Dictionary<ushort, TextureWrap> Icons { get; } = new();
private Dictionary<ushort, IDalamudTextureWrap> Icons { get; } = new();
private MainInterface MainInterface { get; }
private EditorHelper EditorHelper { get; }
@ -62,12 +62,12 @@ namespace Glamaholic {
this.MainInterface.Toggle();
}
internal TextureWrap? GetIcon(ushort id) {
internal IDalamudTextureWrap? GetIcon(ushort id) {
if (this.Icons.TryGetValue(id, out var cached)) {
return cached;
}
var icon = this.Plugin.DataManager.GetImGuiTextureIcon(id);
var icon = this.Plugin.TextureProvider.GetIcon(id);
if (icon == null) {
return null;
}

View File

@ -134,7 +134,7 @@ namespace Glamaholic.Ui {
var payload = new SeString(payloadList);
this.Ui.Plugin.ChatGui.PrintChat(new XivChatEntry {
this.Ui.Plugin.ChatGui.Print(new XivChatEntry {
Message = payload,
});
}

View File

@ -2,12 +2,12 @@
using System.Linq;
using System.Reflection;
using Dalamud;
using Dalamud.Data;
using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets;
namespace Glamaholic.Ui {
internal class FilterInfo {
private DataManager Data { get; }
private IDataManager Data { get; }
private uint MaxLevel { get; }
private string Query { get; }
@ -17,7 +17,7 @@ namespace Glamaholic.Ui {
private HashSet<uint> ItemIds { get; } = new();
private HashSet<string> ItemNames { get; } = new();
internal FilterInfo(DataManager data, string filter) {
internal FilterInfo(IDataManager data, string filter) {
this.Data = data;
var queryWords = new List<string>();

View File

@ -25,7 +25,7 @@ namespace Glamaholic.Ui.Helpers {
}
private void DrawDropdown() {
if (ImGui.Selectable($"Open {this.Ui.Plugin.Name}")) {
if (ImGui.Selectable($"Open {Plugin.Name}")) {
this.Ui.OpenMainInterface();
}

View File

@ -27,7 +27,7 @@ namespace Glamaholic.Ui.Helpers {
}
private void DrawDropdown() {
if (ImGui.Selectable($"Open {this.Ui.Plugin.Name}")) {
if (ImGui.Selectable($"Open {Plugin.Name}")) {
this.Ui.OpenMainInterface();
}

View File

@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Logging;
using Dalamud.Interface.Utility;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
@ -45,7 +44,7 @@ namespace Glamaholic.Ui.Helpers {
internal static float DropdownWidth() {
// arrow size is GetFrameHeight
return (ImGui.CalcTextSize(Plugin.PluginName).X + ImGui.GetStyle().ItemInnerSpacing.X * 2 + ImGui.GetFrameHeight()) * ImGuiHelpers.GlobalScale;
return (ImGui.CalcTextSize(Plugin.Name).X + ImGui.GetStyle().ItemInnerSpacing.X * 2 + ImGui.GetFrameHeight()) * ImGuiHelpers.GlobalScale;
}
internal class HelperStyles : IDisposable {
@ -76,11 +75,11 @@ namespace Glamaholic.Ui.Helpers {
}
ImGui.SetNextItemWidth(DropdownWidth());
if (ImGui.BeginCombo($"##{id}-combo", Plugin.PluginName)) {
if (ImGui.BeginCombo($"##{id}-combo", Plugin.Name)) {
try {
dropdown();
} catch (Exception ex) {
PluginLog.LogError(ex, "Error drawing helper combo");
Plugin.Log.Error(ex, "Error drawing helper combo");
}
ImGui.EndCombo();

View File

@ -34,7 +34,7 @@ namespace Glamaholic.Ui.Helpers {
}
private void DrawDropdown() {
if (ImGui.Selectable($"Open {this.Ui.Plugin.Name}")) {
if (ImGui.Selectable($"Open {Plugin.Name}")) {
this.Ui.OpenMainInterface();
}

View File

@ -9,7 +9,7 @@ using System.Threading.Tasks;
using Dalamud;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Logging;
using Dalamud.Interface.Utility;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using Newtonsoft.Json;
@ -91,7 +91,7 @@ namespace Glamaholic.Ui {
ImGui.SetNextWindowSize(new Vector2(415, 650), ImGuiCond.FirstUseEver);
if (!ImGui.Begin(this.Ui.Plugin.Name, ref this._visible, ImGuiWindowFlags.MenuBar)) {
if (!ImGui.Begin(Plugin.Name, ref this._visible, ImGuiWindowFlags.MenuBar)) {
ImGui.End();
return;
}
@ -132,7 +132,7 @@ namespace Glamaholic.Ui {
this.Ui.SwitchPlate(this.Ui.Plugin.Config.Plates.Count - 1);
}
} catch (Exception ex) {
PluginLog.LogWarning(ex, "Failed to import glamour plate");
Plugin.Log.Warning(ex, "Failed to import glamour plate");
}
}

View File

@ -1,6 +1,6 @@
using System;
using Dalamud.Game.Gui;
using Dalamud.Interface;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
@ -17,12 +17,12 @@ namespace Glamaholic {
return addon != null && addon->IsVisible;
}
private static unsafe bool IsOpen(GameGui gui, string name) {
private static unsafe bool IsOpen(IGameGui gui, string name) {
var addon = (AtkUnitBase*) gui.GetAddonByName(name, 1);
return IsOpen(addon);
}
internal static bool IsEditingPlate(GameGui gui) {
internal static bool IsEditingPlate(IGameGui gui) {
var plateOpen = IsOpen(gui, PlateAddon);
var boxOpen = IsOpen(gui, BoxAddon);
var armoireOpen = IsOpen(gui, ArmoireAddon);