refactor: move to net5

This commit is contained in:
Anna 2021-08-23 14:00:00 -04:00
parent 8e43dfa96d
commit 62c690c908
8 changed files with 80 additions and 70 deletions

View File

@ -8,13 +8,13 @@ namespace Namingway {
internal Commands(Plugin plugin) {
this.Plugin = plugin;
this.Plugin.Interface.CommandManager.AddHandler("/namingway", new CommandInfo(this.OnCommand) {
this.Plugin.CommandManager.AddHandler("/namingway", new CommandInfo(this.OnCommand) {
HelpMessage = "Opens the Namingway interface",
});
}
public void Dispose() {
this.Plugin.Interface.CommandManager.RemoveHandler("/namingway");
this.Plugin.CommandManager.RemoveHandler("/namingway");
}
private void OnCommand(string command, string arguments) {

View File

@ -1,20 +0,0 @@
using Dalamud.Plugin;
namespace Namingway {
// ReSharper disable once UnusedType.Global
public class DalamudPlugin : IDalamudPlugin {
internal const string PluginName = "Namingway";
public string Name => PluginName;
private Plugin? Plugin { get; set; }
public void Initialize(DalamudPluginInterface pluginInterface) {
this.Plugin = new Plugin(pluginInterface);
}
public void Dispose() {
this.Plugin?.Dispose();
}
}
}

View File

@ -2,41 +2,46 @@
<PropertyGroup>
<Version>1.1.1</Version>
<TargetFramework>net48</TargetFramework>
<TargetFramework>net5-windows</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dalamud">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\5.2.7.0\Dalamud.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ImGui.NET">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\5.2.7.0\ImGui.NET.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\ImGui.NET.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ImGuiScene">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\5.2.7.0\ImGuiScene.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\ImGuiScene.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Lumina">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\5.2.7.0\Lumina.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Lumina.Excel">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\5.2.7.0\Lumina.Excel.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.Excel.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\5.2.7.0\Newtonsoft.Json.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Newtonsoft.Json.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="1.2.2"/>
<PackageReference Include="DalamudPackager" Version="2.1.2"/>
</ItemGroup>
<ItemGroup>
<Content Include="..\icon.png" Link="images/icon.png" CopyToOutputDirectory="PreserveNewest" Visible="false"/>
</ItemGroup>
</Project>

View File

@ -1,3 +1,5 @@
author: ascclemens
name: Namingway
punchline: Rename abilities and status effects.
description: Rename abilities and status effects.
repo_url: https://git.sr.ht/~jkcclemens/Namingway

View File

@ -1,18 +1,36 @@
using System;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.Command;
using Dalamud.IoC;
using Dalamud.Plugin;
namespace Namingway {
internal class Plugin : IDisposable {
internal DalamudPluginInterface Interface { get; }
// ReSharper disable once ClassNeverInstantiated.Global
public class Plugin : IDalamudPlugin {
public string Name => "Namingway";
[PluginService]
internal DalamudPluginInterface Interface { get; init; } = null!;
[PluginService]
internal ClientState ClientState { get; init; } = null!;
[PluginService]
internal CommandManager CommandManager { get; init; } = null!;
[PluginService]
internal DataManager DataManager { get; init; } = null!;
[PluginService]
internal SigScanner SigScanner { get; init; } = null!;
internal Configuration Config { get; }
internal Renamer Renamer { get; }
internal PluginUi Ui { get; }
private Commands Commands { get; }
internal Plugin(DalamudPluginInterface pluginInterface) {
this.Interface = pluginInterface;
public Plugin() {
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
this.Config.UpdateActive();

View File

@ -26,23 +26,23 @@ namespace Namingway {
internal PluginUi(Plugin plugin) {
this.Plugin = plugin;
this.Plugin.Interface.UiBuilder.OnBuildUi += this.Draw;
this.Plugin.Interface.UiBuilder.OnOpenConfigUi += this.OnOpenConfig;
this.Plugin.Interface.UiBuilder.Draw += this.Draw;
this.Plugin.Interface.UiBuilder.OpenConfigUi += this.OnOpenConfig;
this.FilterActions();
this.FilterStatuses();
}
public void Dispose() {
this.Plugin.Interface.UiBuilder.OnOpenConfigUi -= this.OnOpenConfig;
this.Plugin.Interface.UiBuilder.OnBuildUi -= this.Draw;
this.Plugin.Interface.UiBuilder.OpenConfigUi -= this.OnOpenConfig;
this.Plugin.Interface.UiBuilder.Draw -= this.Draw;
foreach (var icon in this.Icons.Values) {
icon.Dispose();
}
}
private void OnOpenConfig(object sender, EventArgs e) {
private void OnOpenConfig() {
this.DrawSettings = true;
}
@ -54,7 +54,7 @@ namespace Namingway {
}
ImGui.SetNextWindowSize(new Vector2(450, 400), ImGuiCond.FirstUseEver);
if (!ImGui.Begin(DalamudPlugin.PluginName, ref this.DrawSettings, ImGuiWindowFlags.MenuBar)) {
if (!ImGui.Begin(this.Plugin.Name, ref this.DrawSettings, ImGuiWindowFlags.MenuBar)) {
ImGui.End();
return;
}
@ -223,8 +223,8 @@ namespace Namingway {
ImGui.TableHeadersRow();
foreach (var entry in pack.Actions) {
var action = this.Plugin.Interface.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow(entry.Key);
foreach (var (id, name) in pack.Actions) {
var action = this.Plugin.DataManager.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>()!.GetRow(id);
if (action == null) {
continue;
}
@ -236,7 +236,7 @@ namespace Namingway {
ImGui.TextUnformatted(GetActionName(action));
ImGui.TableNextColumn();
ImGui.TextUnformatted(entry.Value);
ImGui.TextUnformatted(name);
}
ImGui.EndTable();
@ -253,8 +253,8 @@ namespace Namingway {
ImGui.TableHeadersRow();
foreach (var entry in pack.Statuses) {
var status = this.Plugin.Interface.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Status>().GetRow(entry.Key);
foreach (var (id, name) in pack.Statuses) {
var status = this.Plugin.DataManager.GetExcelSheet<Lumina.Excel.GeneratedSheets.Status>()!.GetRow(id);
if (status == null) {
continue;
}
@ -266,7 +266,7 @@ namespace Namingway {
ImGui.TextUnformatted(status.Name.ToString());
ImGui.TableNextColumn();
ImGui.TextUnformatted(entry.Value);
ImGui.TextUnformatted(name);
}
ImGui.EndTable();
@ -322,8 +322,8 @@ namespace Namingway {
var remove = 0u;
foreach (var entry in pack.Actions) {
var action = this.Plugin.Interface.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow(entry.Key);
foreach (var (id, name) in pack.Actions) {
var action = this.Plugin.DataManager.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>()!.GetRow(id);
if (action == null) {
continue;
}
@ -335,11 +335,11 @@ namespace Namingway {
ImGui.TextUnformatted(GetActionName(action));
ImGui.TableNextColumn();
ImGui.TextUnformatted(entry.Value);
ImGui.TextUnformatted(name);
ImGui.TableNextColumn();
if (Util.IconButton(FontAwesomeIcon.Trash, $"action-{entry.Key}")) {
remove = entry.Key;
if (Util.IconButton(FontAwesomeIcon.Trash, $"action-{id}")) {
remove = id;
}
}
@ -349,7 +349,7 @@ namespace Namingway {
var editAction = this._editActionId == 0
? null
: this.Plugin.Interface.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow(this._editActionId);
: this.Plugin.DataManager.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>()!.GetRow(this._editActionId);
ImGui.TableNextColumn();
if (editAction != null) {
this.DrawIcon(editAction.Icon, new Vector2(ImGui.GetTextLineHeightWithSpacing()));
@ -433,8 +433,8 @@ namespace Namingway {
var remove = 0u;
foreach (var entry in pack.Statuses) {
var status = this.Plugin.Interface.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Status>().GetRow(entry.Key);
foreach (var (id, name) in pack.Statuses) {
var status = this.Plugin.DataManager.GetExcelSheet<Lumina.Excel.GeneratedSheets.Status>()!.GetRow(id);
if (status == null) {
continue;
}
@ -446,11 +446,11 @@ namespace Namingway {
ImGui.TextUnformatted(status.Name.ToString());
ImGui.TableNextColumn();
ImGui.TextUnformatted(entry.Value);
ImGui.TextUnformatted(name);
ImGui.TableNextColumn();
if (Util.IconButton(FontAwesomeIcon.Trash, $"status-{entry.Key}")) {
remove = entry.Key;
if (Util.IconButton(FontAwesomeIcon.Trash, $"status-{id}")) {
remove = id;
}
}
@ -460,7 +460,7 @@ namespace Namingway {
var editStatus = this._editStatusId == 0
? null
: this.Plugin.Interface.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Status>().GetRow(this._editStatusId);
: this.Plugin.DataManager.GetExcelSheet<Lumina.Excel.GeneratedSheets.Status>()!.GetRow(this._editStatusId);
ImGui.TableNextColumn();
if (editStatus != null) {
this.DrawRatioIcon(editStatus.Icon);
@ -537,7 +537,7 @@ namespace Namingway {
private void FilterActions() {
if (this.Indirections.Count == 0) {
foreach (var indirection in this.Plugin.Interface.Data.GetExcelSheet<ActionIndirection>()) {
foreach (var indirection in this.Plugin.DataManager.GetExcelSheet<ActionIndirection>()!) {
if (indirection.Name.Row == 0) {
continue;
}
@ -547,7 +547,7 @@ namespace Namingway {
}
if (this.ZadnorActions.Count == 0) {
foreach (var myc in this.Plugin.Interface.Data.GetExcelSheet<MYCTemporaryItem>()) {
foreach (var myc in this.Plugin.DataManager.GetExcelSheet<MYCTemporaryItem>()!) {
if (myc.Action.Row == 0) {
continue;
}
@ -557,7 +557,7 @@ namespace Namingway {
}
if (this.EurekaActions.Count == 0) {
foreach (var eureka in this.Plugin.Interface.Data.GetExcelSheet<EurekaMagiaAction>()) {
foreach (var eureka in this.Plugin.DataManager.GetExcelSheet<EurekaMagiaAction>()!) {
if (eureka.Action.Row == 0) {
continue;
}
@ -568,7 +568,7 @@ namespace Namingway {
this.FilteredActions.Clear();
foreach (var action in this.Plugin.Interface.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>()) {
foreach (var action in this.Plugin.DataManager.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>()!) {
if (this.Plugin.Config.OnlyPlayerActions && !action.IsPlayerAction) {
var allow = this.Indirections.TryGetValue(action.RowId, out var indirection) && indirection.ClassJob.Row != uint.MaxValue
|| this.ZadnorActions.Contains(action.RowId)
@ -583,6 +583,7 @@ namespace Namingway {
continue;
}
// ReSharper disable once ConstantConditionalAccessQualifier
if (this.Plugin.Config.OnlyPlayerActions && (action.ClassJobCategory.Value?.Name?.RawString?.Length ?? 0) == 0) {
continue;
}
@ -598,7 +599,7 @@ namespace Namingway {
private void FilterStatuses() {
this.FilteredStatuses.Clear();
foreach (var status in this.Plugin.Interface.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Status>()) {
foreach (var status in this.Plugin.DataManager.GetExcelSheet<Lumina.Excel.GeneratedSheets.Status>()!) {
if (status.Icon == 0) {
continue;
}
@ -622,11 +623,15 @@ namespace Namingway {
}
try {
wrap = this.Plugin.Interface.Data.GetImGuiTextureIcon(this.Plugin.Interface.ClientState.ClientLanguage, (int) id);
wrap = this.Plugin.DataManager.GetImGuiTextureIcon(this.Plugin.ClientState.ClientLanguage, id);
} catch (NullReferenceException) {
return null;
}
if (wrap == null) {
return null;
}
this.Icons[id] = wrap;
return wrap;

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using Dalamud.Hooking;
using Dalamud.Plugin;
using Dalamud.Logging;
namespace Namingway {
internal class Renamer : IDisposable {
@ -27,7 +27,7 @@ namespace Namingway {
internal Renamer(Plugin plugin) {
this.Plugin = plugin;
if (this.Plugin.Interface.TargetModuleScanner.TryScanText(Signatures.GetAbilitySheet, out var abilityPtr)) {
if (this.Plugin.SigScanner.TryScanText(Signatures.GetAbilitySheet, out var abilityPtr)) {
this.GetAbilitySheet = Marshal.GetDelegateForFunctionPointer<GetAbilitySheetDelegate>(abilityPtr);
}
@ -36,7 +36,7 @@ namespace Namingway {
// this.GetAbilitySheetHook.Enable();
// }
if (this.Plugin.Interface.TargetModuleScanner.TryScanText(Signatures.GetStatusSheet, out var statusPtr)) {
if (this.Plugin.SigScanner.TryScanText(Signatures.GetStatusSheet, out var statusPtr)) {
this.GetStatusSheetHook = new Hook<GetStatusSheetDelegate>(statusPtr, this.GetStatusSheetDetour);
this.GetStatusSheetHook.Enable();
}
@ -52,7 +52,7 @@ namespace Namingway {
}
internal void RestoreAbility(uint abilityId) {
var name = this.Plugin.Interface.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow(abilityId)?.Name;
var name = this.Plugin.DataManager.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>()!.GetRow(abilityId)?.Name;
if (name == null) {
return;
}

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB