refactor: update for api 9

This commit is contained in:
Anna 2023-09-28 20:53:50 -04:00
parent ffb3c8c437
commit 8cc324ba84
Signed by: anna
GPG Key ID: D0943384CD9F87D1
10 changed files with 40 additions and 49 deletions

View File

@ -1,9 +1,7 @@
using System.Diagnostics;
using System.Numerics;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Logging;
using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets;
using Newtonsoft.Json;
using OrangeGuidanceTomestone.Helpers;
@ -20,7 +18,7 @@ internal class Messages : IDisposable {
"bg/ex2/02_est_e3/common/vfx/eff/b0941trp1f_o.avfx",
};
private static string GetPath(DataManager data, Message message) {
private static string GetPath(IDataManager data, Message message) {
var glyph = message.Glyph;
if (glyph < 0 || glyph >= VfxPaths.Length) {
// not checking if this exists, but the check is really only for the
@ -105,7 +103,7 @@ internal class Messages : IDisposable {
private readonly Stopwatch _timer = new();
private void TerritoryChanged(object? sender, ushort e) {
private void TerritoryChanged(ushort territory) {
this._territoryChanged = true;
this.RemoveVfx();
}
@ -113,7 +111,7 @@ internal class Messages : IDisposable {
private ushort _lastTerritory;
private bool _territoryChanged;
private void DetermineIfSpawn(Framework framework) {
private void DetermineIfSpawn(IFramework framework) {
var current = this.Plugin.ClientState.TerritoryType;
var diffTerritory = current != this._lastTerritory;
@ -132,7 +130,7 @@ internal class Messages : IDisposable {
this._lastTerritory = current;
}
private void RemoveConditionally(Framework framework) {
private void RemoveConditionally(IFramework framework) {
var nowCutscene = this.CutsceneActive;
var cutsceneChanged = this._inCutscene != nowCutscene;
if (this.Plugin.Config.DisableInCutscene && cutsceneChanged) {
@ -157,24 +155,20 @@ internal class Messages : IDisposable {
this._inGpose = nowGpose;
}
private unsafe void HandleSpawnQueue(Framework framework) {
private unsafe void HandleSpawnQueue(IFramework framework) {
if (!this.SpawnQueue.TryDequeue(out var message)) {
return;
}
PluginLog.Debug($"spawning vfx for {message.Id}");
Plugin.Log.Debug($"spawning vfx for {message.Id}");
var rotation = Quaternion.CreateFromYawPitchRoll(message.Yaw, 0, 0);
var path = GetPath(this.Plugin.DataManager, message);
if (this.Plugin.Vfx.SpawnStatic(message.Id, path, message.Position, rotation) == null) {
PluginLog.Debug("trying again");
Plugin.Log.Debug("trying again");
this.SpawnQueue.Enqueue(message);
}
}
private void SpawnVfx(object? sender, EventArgs e) {
this.SpawnVfx();
}
internal void SpawnVfx() {
var territory = this.Plugin.ClientState.TerritoryType;
if (territory == 0 || this.Plugin.Config.BannedTerritories.Contains(territory)) {
@ -212,7 +206,7 @@ internal class Messages : IDisposable {
try {
await this.DownloadMessages(world, territory, ward, plot);
} catch (Exception ex) {
PluginLog.LogError(ex, $"Failed to get messages for territory {territory}");
Plugin.Log.Error(ex, $"Failed to get messages for territory {territory}");
}
});
}

View File

@ -16,7 +16,7 @@ internal unsafe class VfxReplacer : IDisposable {
internal VfxReplacer(Plugin plugin) {
this.Plugin = plugin;
SignatureHelper.Initialise(this);
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
this._readSqPackHook!.Enable();
}

View File

@ -39,10 +39,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,6 +1,5 @@
using System.Diagnostics;
using Dalamud.Game;
using Dalamud.Logging;
using Dalamud.Plugin.Services;
using OrangeGuidanceTomestone.Helpers;
namespace OrangeGuidanceTomestone;
@ -22,7 +21,7 @@ internal class Pinger : IDisposable {
this.Plugin.Framework.Update -= this.Ping;
}
private void Ping(Framework framework) {
private void Ping(IFramework framework) {
if (this.Stopwatch.Elapsed < TimeSpan.FromSeconds(this._waitSecs)) {
return;
}
@ -45,7 +44,7 @@ internal class Pinger : IDisposable {
);
if (!resp.IsSuccessStatusCode) {
PluginLog.LogWarning($"Failed to ping, status {resp.StatusCode}");
Plugin.Log.Warning($"Failed to ping, status {resp.StatusCode}");
}
});
}

View File

@ -1,42 +1,43 @@
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.IoC;
using Dalamud.IoC;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using OrangeGuidanceTomestone.MiniPenumbra;
using XivCommon;
namespace OrangeGuidanceTomestone;
public class Plugin : IDalamudPlugin {
public string Name => "Orange Guidance Tomestone";
internal static string Name => "Orange Guidance Tomestone";
[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 Condition Condition { get; init; }
internal ICondition Condition { 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 IGameInteropProvider GameInteropProvider { get; init; }
internal Configuration Config { get; }
internal XivCommonBase Common { get; }
@ -54,7 +55,7 @@ public class Plugin : IDalamudPlugin {
this.Config = this.Interface!.GetPluginConfig() as Configuration ?? new Configuration();
this.Common = new XivCommonBase();
this.Vfx = new Vfx();
this.Vfx = new Vfx(this);
this.Messages = new Messages(this);
this.Ui = new PluginUi(this);
this.VfxReplacer = new VfxReplacer(this);

View File

@ -41,13 +41,13 @@ public class PluginUi : IDisposable {
private void DrawModals() {
while (this.ToShow.TryDequeue(out var toShow)) {
ImGui.OpenPopup($"{this.Plugin.Name}##{toShow}");
ImGui.OpenPopup($"{Plugin.Name}##{toShow}");
}
var toRemove = -1;
for (var i = 0; i < this.Modals.Count; i++) {
var (id, text) = this.Modals[i];
if (!ImGui.BeginPopupModal($"{this.Plugin.Name}##{id}")) {
if (!ImGui.BeginPopupModal($"{Plugin.Name}##{id}")) {
continue;
}

View File

@ -26,7 +26,7 @@ internal class MainWindow {
}
ImGui.SetNextWindowSize(new Vector2(475, 350), ImGuiCond.FirstUseEver);
if (!ImGui.Begin(this.Plugin.Name, ref this.Visible)) {
if (!ImGui.Begin(Plugin.Name, ref this.Visible)) {
ImGui.End();
return;
}
@ -65,7 +65,7 @@ internal class MainWindow {
private void DrawApiKey() {
ImGui.PushTextWrapPos();
ImGui.TextUnformatted($"Somehow, {this.Plugin.Name} wasn't able to register you an account automatically.");
ImGui.TextUnformatted($"Somehow, {Plugin.Name} wasn't able to register you an account automatically.");
ImGui.TextUnformatted("Click the button below to try again.");
ImGui.PopTextWrapPos();

View File

@ -1,8 +1,8 @@
using System.Numerics;
using System.Text;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Interface.Internal;
using ImGuiNET;
using ImGuiScene;
using Newtonsoft.Json;
using OrangeGuidanceTomestone.Helpers;
@ -21,7 +21,7 @@ internal class Write : ITab {
private (int, int) _word2 = (-1, -1);
private int _glyph;
private List<TextureWrap> GlyphImages { get; } = new();
private List<IDalamudTextureWrap> GlyphImages { get; } = new();
private void LoadSignImages() {
for (var i = 0; i < Messages.VfxPaths.Length; i++) {

View File

@ -1,5 +1,6 @@
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using ImGuiNET;
using OrangeGuidanceTomestone.Helpers;

View File

@ -6,7 +6,7 @@ using Dalamud.Utility.Signatures;
namespace OrangeGuidanceTomestone;
internal unsafe class Vfx : IDisposable {
private static readonly byte[] Pool = Encoding.UTF8.GetBytes("Client.System.Scheduler.Instance.VfxObject");
private static readonly byte[] Pool = "Client.System.Scheduler.Instance.VfxObject"u8.ToArray();
[Signature("E8 ?? ?? ?? ?? F3 0F 10 35 ?? ?? ?? ?? 48 89 43 08")]
private delegate* unmanaged<byte*, byte*, VfxStruct*> _staticVfxCreate;
@ -19,8 +19,8 @@ internal unsafe class Vfx : IDisposable {
private Dictionary<Guid, IntPtr> Spawned { get; } = new();
internal Vfx() {
SignatureHelper.Initialise(this);
internal Vfx(Plugin plugin) {
plugin.GameInteropProvider.InitializeFromAttributes(this);
}
public void Dispose() {