refactor: update for api 9
This commit is contained in:
parent
24564a6928
commit
49b16463bb
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFramework>net7.0-windows</TargetFramework>
|
||||||
<Version>1.0.1</Version>
|
<Version>1.0.2</Version>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<RootNamespace>PeepingTom.Ipc</RootNamespace>
|
<RootNamespace>PeepingTom.Ipc</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Dalamud.Game.ClientState.Objects;
|
|
||||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace PeepingTom.Ipc {
|
namespace PeepingTom.Ipc {
|
||||||
|
@ -29,7 +29,7 @@ namespace PeepingTom.Ipc {
|
||||||
this.When = when;
|
this.When = when;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerCharacter? GetPlayerCharacter(ObjectTable objectTable) {
|
public PlayerCharacter? GetPlayerCharacter(IObjectTable objectTable) {
|
||||||
return objectTable.FirstOrDefault(actor => actor.ObjectId == this.ObjectId && actor is PlayerCharacter) as PlayerCharacter;
|
return objectTable.FirstOrDefault(actor => actor.ObjectId == this.ObjectId && actor is PlayerCharacter) as PlayerCharacter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,12 @@ using PeepingTom.Ipc.To;
|
||||||
|
|
||||||
namespace PeepingTom {
|
namespace PeepingTom {
|
||||||
internal class IpcManager : IDisposable {
|
internal class IpcManager : IDisposable {
|
||||||
private PeepingTomPlugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
|
|
||||||
private ICallGateProvider<IFromMessage, object> Provider { get; }
|
private ICallGateProvider<IFromMessage, object> Provider { get; }
|
||||||
private ICallGateSubscriber<IToMessage, object> Subscriber { get; }
|
private ICallGateSubscriber<IToMessage, object> Subscriber { get; }
|
||||||
|
|
||||||
internal IpcManager(PeepingTomPlugin plugin) {
|
internal IpcManager(Plugin plugin) {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
|
|
||||||
this.Provider = this.Plugin.Interface.GetIpcProvider<IFromMessage, object>(IpcInfo.FromRegistrationName);
|
this.Provider = this.Plugin.Interface.GetIpcProvider<IFromMessage, object>(IpcInfo.FromRegistrationName);
|
||||||
|
|
|
@ -1,58 +1,54 @@
|
||||||
using Dalamud.Game.Command;
|
using Dalamud.Game.Command;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Dalamud.Data;
|
|
||||||
using Dalamud.Game;
|
|
||||||
using Dalamud.Game.ClientState;
|
|
||||||
using Dalamud.Game.ClientState.Objects;
|
using Dalamud.Game.ClientState.Objects;
|
||||||
using Dalamud.Game.Gui;
|
|
||||||
using Dalamud.Game.Gui.Toast;
|
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.Logging;
|
using Dalamud.Plugin.Services;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
using PeepingTom.Resources;
|
using PeepingTom.Resources;
|
||||||
using XivCommon;
|
using XivCommon;
|
||||||
using Condition = Dalamud.Game.ClientState.Conditions.Condition;
|
|
||||||
|
|
||||||
namespace PeepingTom {
|
namespace PeepingTom {
|
||||||
// ReSharper disable once ClassNeverInstantiated.Global
|
// ReSharper disable once ClassNeverInstantiated.Global
|
||||||
public class PeepingTomPlugin : IDalamudPlugin {
|
public class Plugin : IDalamudPlugin {
|
||||||
public string Name => "Peeping Tom";
|
internal static string Name => "Peeping Tom";
|
||||||
|
|
||||||
|
[PluginService]
|
||||||
|
internal static IPluginLog Log { get; private set; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal DalamudPluginInterface Interface { get; init; } = null!;
|
internal DalamudPluginInterface Interface { get; init; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal ChatGui ChatGui { get; init; } = null!;
|
internal IChatGui ChatGui { get; init; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal ClientState ClientState { get; init; } = null!;
|
internal IClientState ClientState { get; init; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
private CommandManager CommandManager { get; init; } = null!;
|
private ICommandManager CommandManager { get; init; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal Condition Condition { get; init; } = null!;
|
internal ICondition Condition { get; init; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal DataManager DataManager { get; init; } = null!;
|
internal IDataManager DataManager { get; init; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal Framework Framework { get; init; } = null!;
|
internal IFramework Framework { get; init; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal GameGui GameGui { get; init; } = null!;
|
internal IGameGui GameGui { get; init; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal ObjectTable ObjectTable { get; init; } = null!;
|
internal IObjectTable ObjectTable { get; init; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal TargetManager TargetManager { get; init; } = null!;
|
internal ITargetManager TargetManager { get; init; } = null!;
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal ToastGui ToastGui { get; init; } = null!;
|
internal IToastGui ToastGui { get; init; } = null!;
|
||||||
|
|
||||||
internal Configuration Config { get; }
|
internal Configuration Config { get; }
|
||||||
internal PluginUi Ui { get; }
|
internal PluginUi Ui { get; }
|
||||||
|
@ -62,7 +58,7 @@ namespace PeepingTom {
|
||||||
|
|
||||||
internal bool InPvp { get; private set; }
|
internal bool InPvp { get; private set; }
|
||||||
|
|
||||||
public PeepingTomPlugin() {
|
public Plugin() {
|
||||||
this.Common = new XivCommonBase();
|
this.Common = new XivCommonBase();
|
||||||
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
|
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||||
this.Config.Initialize(this.Interface);
|
this.Config.Initialize(this.Interface);
|
||||||
|
@ -110,12 +106,12 @@ namespace PeepingTom {
|
||||||
Language.Culture = new CultureInfo(langCode);
|
Language.Culture = new CultureInfo(langCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTerritoryChange(object? sender, ushort e) {
|
private void OnTerritoryChange(ushort e) {
|
||||||
try {
|
try {
|
||||||
var territory = this.DataManager.GetExcelSheet<TerritoryType>()!.GetRow(e);
|
var territory = this.DataManager.GetExcelSheet<TerritoryType>()!.GetRow(e);
|
||||||
this.InPvp = territory?.IsPvpZone == true;
|
this.InPvp = territory?.IsPvpZone == true;
|
||||||
} catch (KeyNotFoundException) {
|
} catch (KeyNotFoundException) {
|
||||||
PluginLog.Warning("Could not get territory for current zone");
|
Log.Warning("Could not get territory for current zone");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +123,7 @@ namespace PeepingTom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLogin(object? sender, EventArgs args) {
|
private void OnLogin() {
|
||||||
if (!this.Config.OpenOnLogin) {
|
if (!this.Config.OpenOnLogin) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +131,7 @@ namespace PeepingTom {
|
||||||
this.Ui.WantsOpen = true;
|
this.Ui.WantsOpen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLogout(object? sender, EventArgs args) {
|
private void OnLogout() {
|
||||||
this.Ui.WantsOpen = false;
|
this.Ui.WantsOpen = false;
|
||||||
this.Watcher.ClearPrevious();
|
this.Watcher.ClearPrevious();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,13 @@ using Dalamud.Game.ClientState.Objects.Types;
|
||||||
using Dalamud.Game.Text;
|
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.Interface;
|
using Dalamud.Interface.Utility;
|
||||||
using PeepingTom.Ipc;
|
using PeepingTom.Ipc;
|
||||||
using PeepingTom.Resources;
|
using PeepingTom.Resources;
|
||||||
|
|
||||||
namespace PeepingTom {
|
namespace PeepingTom {
|
||||||
internal class PluginUi : IDisposable {
|
internal class PluginUi : IDisposable {
|
||||||
private PeepingTomPlugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
|
|
||||||
private uint? PreviousFocus { get; set; } = new();
|
private uint? PreviousFocus { get; set; } = new();
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace PeepingTom {
|
||||||
set => this._settingsOpen = value;
|
set => this._settingsOpen = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginUi(PeepingTomPlugin plugin) {
|
public PluginUi(Plugin plugin) {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ namespace PeepingTom {
|
||||||
|
|
||||||
private void ShowSettings() {
|
private void ShowSettings() {
|
||||||
ImGui.SetNextWindowSize(new Vector2(700, 250));
|
ImGui.SetNextWindowSize(new Vector2(700, 250));
|
||||||
var windowTitle = string.Format(Language.SettingsTitle, this.Plugin.Name);
|
var windowTitle = string.Format(Language.SettingsTitle, Plugin.Name);
|
||||||
if (!ImGui.Begin($"{windowTitle}###ptom-settings", ref this._settingsOpen, ImGuiWindowFlags.NoResize)) {
|
if (!ImGui.Begin($"{windowTitle}###ptom-settings", ref this._settingsOpen, ImGuiWindowFlags.NoResize)) {
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
return;
|
return;
|
||||||
|
@ -392,7 +392,7 @@ namespace PeepingTom {
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.SetNextWindowSize(new Vector2(290, 195), ImGuiCond.FirstUseEver);
|
ImGui.SetNextWindowSize(new Vector2(290, 195), ImGuiCond.FirstUseEver);
|
||||||
if (!ImGui.Begin(this.Plugin.Name, ref this._wantsOpen, flags)) {
|
if (!ImGui.Begin(Plugin.Name, ref this._wantsOpen, flags)) {
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -522,7 +522,7 @@ namespace PeepingTom {
|
||||||
} else {
|
} else {
|
||||||
var payload = new PlayerPayload(targeter.Name.TextValue, targeter.HomeWorldId);
|
var payload = new PlayerPayload(targeter.Name.TextValue, targeter.HomeWorldId);
|
||||||
Payload[] payloads = { payload };
|
Payload[] payloads = { payload };
|
||||||
this.Plugin.ChatGui.PrintChat(new XivChatEntry {
|
this.Plugin.ChatGui.Print(new XivChatEntry {
|
||||||
Message = new SeString(payloads),
|
Message = new SeString(payloads),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,17 +6,16 @@ using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Dalamud.Game;
|
|
||||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||||
using Dalamud.Game.ClientState.Objects.Types;
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
using Dalamud.Game.Text;
|
using Dalamud.Game.Text;
|
||||||
using Dalamud.Logging;
|
using Dalamud.Plugin.Services;
|
||||||
using PeepingTom.Ipc;
|
using PeepingTom.Ipc;
|
||||||
using PeepingTom.Resources;
|
using PeepingTom.Resources;
|
||||||
|
|
||||||
namespace PeepingTom {
|
namespace PeepingTom {
|
||||||
internal class TargetWatcher : IDisposable {
|
internal class TargetWatcher : IDisposable {
|
||||||
private PeepingTomPlugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
|
|
||||||
private Stopwatch UpdateWatch { get; } = new();
|
private Stopwatch UpdateWatch { get; } = new();
|
||||||
private Stopwatch? SoundWatch { get; set; }
|
private Stopwatch? SoundWatch { get; set; }
|
||||||
|
@ -30,7 +29,7 @@ namespace PeepingTom {
|
||||||
|
|
||||||
public IReadOnlyCollection<Targeter> PreviousTargeters => this.Previous;
|
public IReadOnlyCollection<Targeter> PreviousTargeters => this.Previous;
|
||||||
|
|
||||||
public TargetWatcher(PeepingTomPlugin plugin) {
|
public TargetWatcher(Plugin plugin) {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
this.UpdateWatch.Start();
|
this.UpdateWatch.Start();
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ namespace PeepingTom {
|
||||||
this.Previous.Clear();
|
this.Previous.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFrameworkUpdate(Framework framework) {
|
private void OnFrameworkUpdate(IFramework framework1) {
|
||||||
if (this.Plugin.InPvp) {
|
if (this.Plugin.InPvp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +67,7 @@ namespace PeepingTom {
|
||||||
try {
|
try {
|
||||||
this.Plugin.IpcManager.SendNewTargeter(newTargeter);
|
this.Plugin.IpcManager.SendNewTargeter(newTargeter);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
PluginLog.LogError(ex, "Failed to send IPC message");
|
Plugin.Log.Error(ex, "Failed to send IPC message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +75,7 @@ namespace PeepingTom {
|
||||||
try {
|
try {
|
||||||
this.Plugin.IpcManager.SendStoppedTargeting(stopped);
|
this.Plugin.IpcManager.SendStoppedTargeting(stopped);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
PluginLog.LogError(ex, "Failed to send IPC message");
|
Plugin.Log.Error(ex, "Failed to send IPC message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,15 +194,15 @@ namespace PeepingTom {
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
PluginLog.LogError(ex, "Exception playing sound");
|
Plugin.Log.Error(ex, "Exception playing sound");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).Start();
|
}).Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SendError(string message) {
|
private void SendError(string message) {
|
||||||
this.Plugin.ChatGui.PrintChat(new XivChatEntry {
|
this.Plugin.ChatGui.Print(new XivChatEntry {
|
||||||
Message = $"[{this.Plugin.Name}] {message}",
|
Message = $"[{Plugin.Name}] {message}",
|
||||||
Type = XivChatType.ErrorMessage,
|
Type = XivChatType.ErrorMessage,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue