refactor: move to net5
This commit is contained in:
parent
23b627de1b
commit
35fa5a2d86
@ -32,7 +32,7 @@ namespace Macrology {
|
||||
this.OnMacroCancelCommand(args);
|
||||
break;
|
||||
default:
|
||||
this.Plugin.Interface.Framework.Gui.Chat.PrintError($"The command {command} was passed to Macrology, but there is no handler available.");
|
||||
this.Plugin.ChatGui.PrintError($"The command {command} was passed to Macrology, but there is no handler available.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -44,13 +44,13 @@ namespace Macrology {
|
||||
private void OnMacroCommand(string args) {
|
||||
var first = args.Trim().Split(' ').FirstOrDefault() ?? "";
|
||||
if (!Guid.TryParse(first, out var id)) {
|
||||
this.Plugin.Interface.Framework.Gui.Chat.PrintError("First argument must be the UUID of the macro to execute.");
|
||||
this.Plugin.ChatGui.PrintError("First argument must be the UUID of the macro to execute.");
|
||||
return;
|
||||
}
|
||||
|
||||
var macro = this.Plugin.Config.FindMacro(id);
|
||||
if (macro == null) {
|
||||
this.Plugin.Interface.Framework.Gui.Chat.PrintError($"No macro with ID {id} found.");
|
||||
this.Plugin.ChatGui.PrintError($"No macro with ID {id} found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -68,19 +68,19 @@ namespace Macrology {
|
||||
}
|
||||
|
||||
if (!Guid.TryParse(first, out var id)) {
|
||||
this.Plugin.Interface.Framework.Gui.Chat.PrintError("First argument must either be \"all\" or the UUID of the macro to cancel.");
|
||||
this.Plugin.ChatGui.PrintError("First argument must either be \"all\" or the UUID of the macro to cancel.");
|
||||
return;
|
||||
}
|
||||
|
||||
var macro = this.Plugin.Config.FindMacro(id);
|
||||
if (macro == null) {
|
||||
this.Plugin.Interface.Framework.Gui.Chat.PrintError($"No macro with ID {id} found.");
|
||||
this.Plugin.ChatGui.PrintError($"No macro with ID {id} found.");
|
||||
return;
|
||||
}
|
||||
|
||||
var entry = this.Plugin.MacroHandler.Running.FirstOrDefault(e => e.Value.Id == id);
|
||||
var entry = this.Plugin.MacroHandler.Running.FirstOrDefault(e => e.Value?.Id == id);
|
||||
if (entry.Value == null) {
|
||||
this.Plugin.Interface.Framework.Gui.Chat.PrintError($"That macro is not running.");
|
||||
this.Plugin.ChatGui.PrintError("That macro is not running.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Plugin;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Dalamud.Logging;
|
||||
|
||||
namespace Macrology {
|
||||
[Serializable]
|
||||
public class Configuration : IPluginConfiguration {
|
||||
private Macrology Plugin { get; set; } = null!;
|
||||
|
||||
@ -136,7 +137,7 @@ namespace Macrology {
|
||||
return objectType == typeof(INode);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
|
||||
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) {
|
||||
throw new InvalidOperationException("Use default serialization.");
|
||||
}
|
||||
|
||||
@ -148,16 +149,16 @@ namespace Macrology {
|
||||
INode node;
|
||||
if (jsonObject.ContainsKey("Contents")) {
|
||||
node = new Macro(
|
||||
jsonObject["Id"].ToObject<Guid>(),
|
||||
jsonObject["Name"].ToObject<string>(),
|
||||
jsonObject["Contents"].ToObject<string>()
|
||||
jsonObject["Id"]!.ToObject<Guid>(),
|
||||
jsonObject["Name"]!.ToObject<string>()!,
|
||||
jsonObject["Contents"]!.ToObject<string>()!
|
||||
);
|
||||
}
|
||||
else {
|
||||
node = new Folder(
|
||||
jsonObject["Id"].ToObject<Guid>(),
|
||||
jsonObject["Name"].ToObject<string>(),
|
||||
(List<INode>) this.ReadJson(jsonObject["Children"].CreateReader(), typeof(List<INode>), null, serializer)
|
||||
jsonObject["Id"]!.ToObject<Guid>(),
|
||||
jsonObject["Name"]!.ToObject<string>()!,
|
||||
(List<INode>) this.ReadJson(jsonObject["Children"]!.CreateReader(), typeof(List<INode>), null, serializer)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<Target Name="PackagePlugin" AfterTargets="ILRepacker" Condition="'$(Configuration)' == 'Release'">
|
||||
<Target Name="PackagePlugin" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
|
||||
<DalamudPackager
|
||||
ProjectDir="$(ProjectDir)"
|
||||
OutputPath="$(OutputPath)"
|
||||
AssemblyName="$(AssemblyName)"
|
||||
VersionComponents="3"
|
||||
MakeZip="true"
|
||||
Include="Macrology.dll;Macrology.pdb;Macrology.json"/>
|
||||
MakeZip="true"/>
|
||||
</Target>
|
||||
</Project>
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Target Name="ILRepacker" AfterTargets="Build">
|
||||
<ItemGroup>
|
||||
<InputAssemblies Include="$(OutputPath)\$(AssemblyName).dll"/>
|
||||
<InputAssemblies Include="$(OutputPath)\*.dll"
|
||||
Exclude="$(OutputPath)\$(AssemblyName).dll"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ILRepack
|
||||
Parallel="true"
|
||||
Internalize="false"
|
||||
InputAssemblies="@(InputAssemblies)"
|
||||
TargetKind="Dll"
|
||||
TargetPlatformVersion="v4"
|
||||
LibraryPath="$(OutputPath);$(AppData)\XIVLauncher\addon\Hooks\dev"
|
||||
OutputFile="$(OutputPath)\$(AssemblyName).dll"/>
|
||||
</Target>
|
||||
</Project>
|
@ -1,11 +1,11 @@
|
||||
using Dalamud.Game.Internal;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Game;
|
||||
|
||||
namespace Macrology {
|
||||
public class MacroHandler {
|
||||
@ -21,13 +21,13 @@ namespace Macrology {
|
||||
|
||||
private Macrology Plugin { get; }
|
||||
private readonly Channel<string> _commands = Channel.CreateUnbounded<string>();
|
||||
public ConcurrentDictionary<Guid, Macro> Running { get; } = new();
|
||||
public ConcurrentDictionary<Guid, Macro?> Running { get; } = new();
|
||||
private readonly ConcurrentDictionary<Guid, bool> _cancelled = new();
|
||||
private readonly ConcurrentDictionary<Guid, bool> _paused = new();
|
||||
|
||||
public MacroHandler(Macrology plugin) {
|
||||
this.Plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "Macrology cannot be null");
|
||||
this._ready = this.Plugin.Interface.ClientState.LocalPlayer != null;
|
||||
this._ready = this.Plugin.ClientState.LocalPlayer != null;
|
||||
}
|
||||
|
||||
private static string[] ExtractCommands(string macro) {
|
||||
@ -138,7 +138,7 @@ namespace Macrology {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void OnFrameworkUpdate(Framework framework) {
|
||||
public void OnFrameworkUpdate(Framework framework1) {
|
||||
// get a message to send, but discard it if we're not ready
|
||||
if (!this._commands.Reader.TryRead(out var command) || !this._ready) {
|
||||
return;
|
||||
@ -165,11 +165,11 @@ namespace Macrology {
|
||||
return TimeSpan.FromSeconds(seconds);
|
||||
}
|
||||
|
||||
internal void OnLogin(object sender, EventArgs args) {
|
||||
internal void OnLogin(object? sender, EventArgs args) {
|
||||
this._ready = true;
|
||||
}
|
||||
|
||||
internal void OnLogout(object sender, EventArgs args) {
|
||||
internal void OnLogout(object? sender, EventArgs args) {
|
||||
this._ready = false;
|
||||
|
||||
foreach (var id in this.Running.Keys) {
|
||||
|
@ -1,6 +1,10 @@
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Plugin;
|
||||
using System;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Game.ClientState;
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.IoC;
|
||||
using XivCommon;
|
||||
|
||||
namespace Macrology {
|
||||
@ -9,30 +13,43 @@ namespace Macrology {
|
||||
|
||||
public string Name => "Macrology";
|
||||
|
||||
public DalamudPluginInterface Interface { get; private set; } = null!;
|
||||
public XivCommonBase Common { get; private set; } = null!;
|
||||
public PluginUi Ui { get; private set; } = null!;
|
||||
public MacroHandler MacroHandler { get; private set; } = null!;
|
||||
public Configuration Config { get; private set; } = null!;
|
||||
private Commands Commands { get; set; } = null!;
|
||||
[PluginService]
|
||||
internal DalamudPluginInterface Interface { get; private init; } = null!;
|
||||
|
||||
public void Initialize(DalamudPluginInterface pluginInterface) {
|
||||
this.Interface = pluginInterface ?? throw new ArgumentNullException(nameof(pluginInterface), "DalamudPluginInterface cannot be null");
|
||||
this.Common = new XivCommonBase(this.Interface);
|
||||
[PluginService]
|
||||
internal ChatGui ChatGui { get; private init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal ClientState ClientState { get; private init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal CommandManager CommandManager { get; private init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal Framework Framework { get; private init; } = null!;
|
||||
|
||||
public XivCommonBase Common { get; }
|
||||
public PluginUi Ui { get; }
|
||||
public MacroHandler MacroHandler { get; }
|
||||
public Configuration Config { get; }
|
||||
private Commands Commands { get; }
|
||||
|
||||
public Macrology() {
|
||||
this.Common = new XivCommonBase();
|
||||
this.Ui = new PluginUi(this);
|
||||
this.MacroHandler = new MacroHandler(this);
|
||||
this.Config = Configuration.Load(this) ?? new Configuration();
|
||||
this.Config.Initialise(this);
|
||||
this.Commands = new Commands(this);
|
||||
|
||||
this.Interface.UiBuilder.OnBuildUi += this.Ui.Draw;
|
||||
this.Interface.UiBuilder.OnOpenConfigUi += this.Ui.OpenSettings;
|
||||
this.Interface.Framework.OnUpdateEvent += this.MacroHandler.OnFrameworkUpdate;
|
||||
this.Interface.ClientState.OnLogin += this.MacroHandler.OnLogin;
|
||||
this.Interface.ClientState.OnLogout += this.MacroHandler.OnLogout;
|
||||
foreach (var entry in Commands.Descriptions) {
|
||||
this.Interface.CommandManager.AddHandler(entry.Key, new CommandInfo(this.Commands.OnCommand) {
|
||||
HelpMessage = entry.Value,
|
||||
this.Interface.UiBuilder.Draw += this.Ui.Draw;
|
||||
this.Interface.UiBuilder.OpenConfigUi += this.Ui.OpenSettings;
|
||||
this.Framework.Update += this.MacroHandler.OnFrameworkUpdate;
|
||||
this.ClientState.Login += this.MacroHandler.OnLogin;
|
||||
this.ClientState.Logout += this.MacroHandler.OnLogout;
|
||||
foreach (var (name, desc) in Commands.Descriptions) {
|
||||
this.CommandManager.AddHandler(name, new CommandInfo(this.Commands.OnCommand) {
|
||||
HelpMessage = desc,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -43,13 +60,13 @@ namespace Macrology {
|
||||
}
|
||||
|
||||
if (disposing) {
|
||||
this.Interface.UiBuilder.OnBuildUi -= this.Ui.Draw;
|
||||
this.Interface.UiBuilder.OnOpenConfigUi -= this.Ui.OpenSettings;
|
||||
this.Interface.Framework.OnUpdateEvent -= this.MacroHandler.OnFrameworkUpdate;
|
||||
this.Interface.ClientState.OnLogin -= this.MacroHandler.OnLogin;
|
||||
this.Interface.ClientState.OnLogout -= this.MacroHandler.OnLogout;
|
||||
this.Interface.UiBuilder.Draw -= this.Ui.Draw;
|
||||
this.Interface.UiBuilder.OpenConfigUi -= this.Ui.OpenSettings;
|
||||
this.Framework.Update -= this.MacroHandler.OnFrameworkUpdate;
|
||||
this.ClientState.Login -= this.MacroHandler.OnLogin;
|
||||
this.ClientState.Logout -= this.MacroHandler.OnLogout;
|
||||
foreach (var command in Commands.Descriptions.Keys) {
|
||||
this.Interface.CommandManager.RemoveHandler(command);
|
||||
this.CommandManager.RemoveHandler(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,10 @@
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>1.0.0</Version>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<TargetFramework>net5-windows</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Dalamud">
|
||||
@ -26,9 +28,8 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DalamudPackager" Version="1.2.1"/>
|
||||
<PackageReference Include="ILRepack.Lib.MSBuild.Task" Version="2.0.18.2"/>
|
||||
<PackageReference Include="System.Threading.Channels" Version="5.0.0"/>
|
||||
<PackageReference Include="XivCommon" Version="1.2.0"/>
|
||||
<PackageReference Include="DalamudPackager" Version="2.1.2" />
|
||||
<PackageReference Include="System.Threading.Channels" Version="5.0.0" />
|
||||
<PackageReference Include="XivCommon" Version="3.0.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,5 +1,6 @@
|
||||
author: ascclemens
|
||||
name: Macrology
|
||||
punchline: Adds a better macro system to the game.
|
||||
description: |-
|
||||
Adds a better macro system to the game.
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace Macrology {
|
||||
this.Plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "Macrology cannot be null");
|
||||
}
|
||||
|
||||
public void OpenSettings(object sender, EventArgs e) {
|
||||
public void OpenSettings() {
|
||||
this.SettingsVisible = true;
|
||||
}
|
||||
|
||||
@ -83,21 +83,25 @@ namespace Macrology {
|
||||
ImGui.Text("Running macros");
|
||||
ImGui.PushItemWidth(-1f);
|
||||
if (ImGui.BeginListBox("##running-macros")) {
|
||||
foreach (var entry in this.Plugin.MacroHandler.Running) {
|
||||
var name = $"{entry.Value.Name}";
|
||||
if (this._showIdents) {
|
||||
var ident = entry.Key.ToString();
|
||||
name += $" ({ident.Substring(ident.Length - 7)})";
|
||||
foreach (var (id, value) in this.Plugin.MacroHandler.Running) {
|
||||
if (value == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.Plugin.MacroHandler.IsPaused(entry.Key)) {
|
||||
var name = $"{value.Name}";
|
||||
if (this._showIdents) {
|
||||
var ident = id.ToString();
|
||||
name += $" ({ident[^7..]})";
|
||||
}
|
||||
|
||||
if (this.Plugin.MacroHandler.IsPaused(id)) {
|
||||
name += " (paused)";
|
||||
}
|
||||
|
||||
var cancelled = this.Plugin.MacroHandler.IsCancelled(entry.Key);
|
||||
var cancelled = this.Plugin.MacroHandler.IsCancelled(id);
|
||||
var flags = cancelled ? ImGuiSelectableFlags.Disabled : ImGuiSelectableFlags.None;
|
||||
if (ImGui.Selectable($"{name}##{entry.Key}", this.RunningChoice == entry.Key, flags)) {
|
||||
this.RunningChoice = entry.Key;
|
||||
if (ImGui.Selectable($"{name}##{id}", this.RunningChoice == id, flags)) {
|
||||
this.RunningChoice = id;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user