refactor: update for api 9
This commit is contained in:
parent
ff7a529b5a
commit
d844798ce3
|
@ -9,7 +9,7 @@ namespace Glamaholic {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
|
|
||||||
this.Plugin.CommandManager.AddHandler("/glamaholic", new CommandInfo(this.OnCommand) {
|
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",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ using Dalamud.Game.Text;
|
||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||||
using Dalamud.Memory;
|
using Dalamud.Memory;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
using Dalamud.Utility.Signatures;
|
using Dalamud.Utility.Signatures;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||||
|
@ -72,8 +73,7 @@ namespace Glamaholic {
|
||||||
|
|
||||||
internal GameFunctions(Plugin plugin) {
|
internal GameFunctions(Plugin plugin) {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
|
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
|
||||||
SignatureHelper.Initialise(this);
|
|
||||||
|
|
||||||
this.Plugin.ChatGui.ChatMessage += this.OnChat;
|
this.Plugin.ChatGui.ChatMessage += this.OnChat;
|
||||||
this.Plugin.ClientState.Login += OnLogin;
|
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;
|
_dresserContents = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _wasEditing;
|
private bool _wasEditing;
|
||||||
|
|
||||||
private void OnFrameworkUpdate(Dalamud.Game.Framework framework) {
|
private void OnFrameworkUpdate(IFramework framework1) {
|
||||||
var editing = Util.IsEditingPlate(this.Plugin.GameGui);
|
var editing = Util.IsEditingPlate(this.Plugin.GameGui);
|
||||||
if (!this._wasEditing && editing) {
|
if (!this._wasEditing && editing) {
|
||||||
// cache dresser
|
// cache dresser
|
||||||
|
|
|
@ -35,10 +35,6 @@
|
||||||
<HintPath>$(DalamudLibPath)\ImGui.NET.dll</HintPath>
|
<HintPath>$(DalamudLibPath)\ImGui.NET.dll</HintPath>
|
||||||
<Private>false</Private>
|
<Private>false</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ImGuiScene">
|
|
||||||
<HintPath>$(DalamudLibPath)\ImGuiScene.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Lumina">
|
<Reference Include="Lumina">
|
||||||
<HintPath>$(DalamudLibPath)\Lumina.dll</HintPath>
|
<HintPath>$(DalamudLibPath)\Lumina.dll</HintPath>
|
||||||
<Private>false</Private>
|
<Private>false</Private>
|
||||||
|
|
|
@ -1,40 +1,45 @@
|
||||||
using Dalamud.Data;
|
using Dalamud.Game;
|
||||||
using Dalamud.Game;
|
|
||||||
using Dalamud.Game.ClientState;
|
|
||||||
using Dalamud.Game.Command;
|
|
||||||
using Dalamud.Game.Gui;
|
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
|
|
||||||
namespace Glamaholic {
|
namespace Glamaholic {
|
||||||
// ReSharper disable once ClassNeverInstantiated.Global
|
// ReSharper disable once ClassNeverInstantiated.Global
|
||||||
public class Plugin : IDalamudPlugin {
|
public class Plugin : IDalamudPlugin {
|
||||||
internal const string PluginName = "Glamaholic";
|
internal static string Name => "Glamaholic";
|
||||||
public string Name => PluginName;
|
|
||||||
|
[PluginService]
|
||||||
|
internal static IPluginLog Log { get; private set; }
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal DalamudPluginInterface Interface { get; init; }
|
internal DalamudPluginInterface Interface { get; init; }
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal ChatGui ChatGui { get; init; }
|
internal IChatGui ChatGui { get; init; }
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal ClientState ClientState { get; init; }
|
internal IClientState ClientState { get; init; }
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal CommandManager CommandManager { get; init; }
|
internal ICommandManager CommandManager { get; init; }
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal DataManager DataManager { get; init; }
|
internal IDataManager DataManager { get; init; }
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal Framework Framework { get; init; }
|
internal IFramework Framework { get; init; }
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal GameGui GameGui { get; init; }
|
internal IGameGui GameGui { get; init; }
|
||||||
|
|
||||||
[PluginService]
|
[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 Configuration Config { get; }
|
||||||
internal GameFunctions Functions { get; }
|
internal GameFunctions Functions { get; }
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Dalamud.Interface.Internal;
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||||
using Glamaholic.Ui;
|
using Glamaholic.Ui;
|
||||||
using Glamaholic.Ui.Helpers;
|
using Glamaholic.Ui.Helpers;
|
||||||
using ImGuiScene;
|
|
||||||
|
|
||||||
namespace Glamaholic {
|
namespace Glamaholic {
|
||||||
internal class PluginUi : IDisposable {
|
internal class PluginUi : IDisposable {
|
||||||
internal Plugin Plugin { get; }
|
internal Plugin Plugin { get; }
|
||||||
|
|
||||||
private Dictionary<ushort, TextureWrap> Icons { get; } = new();
|
private Dictionary<ushort, IDalamudTextureWrap> Icons { get; } = new();
|
||||||
|
|
||||||
private MainInterface MainInterface { get; }
|
private MainInterface MainInterface { get; }
|
||||||
private EditorHelper EditorHelper { get; }
|
private EditorHelper EditorHelper { get; }
|
||||||
|
@ -62,12 +62,12 @@ namespace Glamaholic {
|
||||||
this.MainInterface.Toggle();
|
this.MainInterface.Toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal TextureWrap? GetIcon(ushort id) {
|
internal IDalamudTextureWrap? GetIcon(ushort id) {
|
||||||
if (this.Icons.TryGetValue(id, out var cached)) {
|
if (this.Icons.TryGetValue(id, out var cached)) {
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
var icon = this.Plugin.DataManager.GetImGuiTextureIcon(id);
|
var icon = this.Plugin.TextureProvider.GetIcon(id);
|
||||||
if (icon == null) {
|
if (icon == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace Glamaholic.Ui {
|
||||||
|
|
||||||
var payload = new SeString(payloadList);
|
var payload = new SeString(payloadList);
|
||||||
|
|
||||||
this.Ui.Plugin.ChatGui.PrintChat(new XivChatEntry {
|
this.Ui.Plugin.ChatGui.Print(new XivChatEntry {
|
||||||
Message = payload,
|
Message = payload,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Dalamud;
|
using Dalamud;
|
||||||
using Dalamud.Data;
|
using Dalamud.Plugin.Services;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
namespace Glamaholic.Ui {
|
namespace Glamaholic.Ui {
|
||||||
internal class FilterInfo {
|
internal class FilterInfo {
|
||||||
private DataManager Data { get; }
|
private IDataManager Data { get; }
|
||||||
|
|
||||||
private uint MaxLevel { get; }
|
private uint MaxLevel { get; }
|
||||||
private string Query { get; }
|
private string Query { get; }
|
||||||
|
@ -17,7 +17,7 @@ namespace Glamaholic.Ui {
|
||||||
private HashSet<uint> ItemIds { get; } = new();
|
private HashSet<uint> ItemIds { get; } = new();
|
||||||
private HashSet<string> ItemNames { get; } = new();
|
private HashSet<string> ItemNames { get; } = new();
|
||||||
|
|
||||||
internal FilterInfo(DataManager data, string filter) {
|
internal FilterInfo(IDataManager data, string filter) {
|
||||||
this.Data = data;
|
this.Data = data;
|
||||||
|
|
||||||
var queryWords = new List<string>();
|
var queryWords = new List<string>();
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace Glamaholic.Ui.Helpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawDropdown() {
|
private void DrawDropdown() {
|
||||||
if (ImGui.Selectable($"Open {this.Ui.Plugin.Name}")) {
|
if (ImGui.Selectable($"Open {Plugin.Name}")) {
|
||||||
this.Ui.OpenMainInterface();
|
this.Ui.OpenMainInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace Glamaholic.Ui.Helpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawDropdown() {
|
private void DrawDropdown() {
|
||||||
if (ImGui.Selectable($"Open {this.Ui.Plugin.Name}")) {
|
if (ImGui.Selectable($"Open {Plugin.Name}")) {
|
||||||
this.Ui.OpenMainInterface();
|
this.Ui.OpenMainInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface.Utility;
|
||||||
using Dalamud.Logging;
|
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ namespace Glamaholic.Ui.Helpers {
|
||||||
|
|
||||||
internal static float DropdownWidth() {
|
internal static float DropdownWidth() {
|
||||||
// arrow size is GetFrameHeight
|
// 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 {
|
internal class HelperStyles : IDisposable {
|
||||||
|
@ -76,11 +75,11 @@ namespace Glamaholic.Ui.Helpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SetNextItemWidth(DropdownWidth());
|
ImGui.SetNextItemWidth(DropdownWidth());
|
||||||
if (ImGui.BeginCombo($"##{id}-combo", Plugin.PluginName)) {
|
if (ImGui.BeginCombo($"##{id}-combo", Plugin.Name)) {
|
||||||
try {
|
try {
|
||||||
dropdown();
|
dropdown();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
PluginLog.LogError(ex, "Error drawing helper combo");
|
Plugin.Log.Error(ex, "Error drawing helper combo");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndCombo();
|
ImGui.EndCombo();
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace Glamaholic.Ui.Helpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawDropdown() {
|
private void DrawDropdown() {
|
||||||
if (ImGui.Selectable($"Open {this.Ui.Plugin.Name}")) {
|
if (ImGui.Selectable($"Open {Plugin.Name}")) {
|
||||||
this.Ui.OpenMainInterface();
|
this.Ui.OpenMainInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
||||||
using Dalamud;
|
using Dalamud;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using Dalamud.Interface.Colors;
|
using Dalamud.Interface.Colors;
|
||||||
using Dalamud.Logging;
|
using Dalamud.Interface.Utility;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
@ -91,7 +91,7 @@ namespace Glamaholic.Ui {
|
||||||
|
|
||||||
ImGui.SetNextWindowSize(new Vector2(415, 650), ImGuiCond.FirstUseEver);
|
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();
|
ImGui.End();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ namespace Glamaholic.Ui {
|
||||||
this.Ui.SwitchPlate(this.Ui.Plugin.Config.Plates.Count - 1);
|
this.Ui.SwitchPlate(this.Ui.Plugin.Config.Plates.Count - 1);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
PluginLog.LogWarning(ex, "Failed to import glamour plate");
|
Plugin.Log.Warning(ex, "Failed to import glamour plate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using Dalamud.Game.Gui;
|
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
@ -17,12 +17,12 @@ namespace Glamaholic {
|
||||||
return addon != null && addon->IsVisible;
|
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);
|
var addon = (AtkUnitBase*) gui.GetAddonByName(name, 1);
|
||||||
return IsOpen(addon);
|
return IsOpen(addon);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool IsEditingPlate(GameGui gui) {
|
internal static bool IsEditingPlate(IGameGui gui) {
|
||||||
var plateOpen = IsOpen(gui, PlateAddon);
|
var plateOpen = IsOpen(gui, PlateAddon);
|
||||||
var boxOpen = IsOpen(gui, BoxAddon);
|
var boxOpen = IsOpen(gui, BoxAddon);
|
||||||
var armoireOpen = IsOpen(gui, ArmoireAddon);
|
var armoireOpen = IsOpen(gui, ArmoireAddon);
|
||||||
|
|
Loading…
Reference in New Issue