refactor: move to net5

This commit is contained in:
Anna 2021-08-23 21:21:29 -04:00
parent 56b6d4aeaa
commit a9f18872f5
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
19 changed files with 155 additions and 216 deletions

View File

@ -11,13 +11,13 @@ namespace HUD_Manager {
public Commands(Plugin plugin) {
this.Plugin = plugin;
this.Plugin.Interface.CommandManager.AddHandler("/hudman", new CommandInfo(this.OnCommand) {
this.Plugin.CommandManager.AddHandler("/hudman", new CommandInfo(this.OnCommand) {
HelpMessage = "Open the HUD Manager settings or swap to layout name",
});
}
public void Dispose() {
this.Plugin.Interface.CommandManager.RemoveHandler("/hudman");
this.Plugin.CommandManager.RemoveHandler("/hudman");
}
private void OnCommand(string command, string args) {

View File

@ -4,7 +4,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using Dalamud.Plugin;
using Dalamud.Logging;
using HUD_Manager.Structs;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@ -42,7 +42,7 @@ namespace HUD_Manager.Configuration {
}
private static void WithEachLayout(JObject old, Action<JObject> action) {
foreach (var property in old["Layouts"].Children<JProperty>()) {
foreach (var property in old["Layouts"]!.Children<JProperty>()) {
if (property.Name == "$type") {
continue;
}
@ -55,7 +55,7 @@ namespace HUD_Manager.Configuration {
private static void WithEachElement(JObject old, Action<JObject> action) {
WithEachLayout(old, layout => {
var elements = (JObject) layout["Elements"];
var elements = (JObject) layout["Elements"]!;
foreach (var elementProp in elements.Children<JProperty>()) {
if (elementProp.Name == "$type") {
@ -71,7 +71,7 @@ namespace HUD_Manager.Configuration {
private static void MigrateV2(JObject old) {
WithEachElement(old, element => {
var bytes = element["Unknown4"].ToObject<byte[]>();
var bytes = element["Unknown4"]!.ToObject<byte[]>()!;
var options = new byte[4];
Buffer.BlockCopy(bytes, 0, options, 0, 4);
@ -92,7 +92,7 @@ namespace HUD_Manager.Configuration {
private static void MigrateV3(JObject old) {
WithEachElement(old, element => {
var measuredFrom = element["Unknown4"].ToObject<byte>();
var measuredFrom = element["Unknown4"]!.ToObject<byte>();
element.Remove("Unknown4");
element["MeasuredFrom"] = measuredFrom;
});
@ -102,7 +102,7 @@ namespace HUD_Manager.Configuration {
private static void MigrateV4(JObject old) {
WithEachLayout(old, layout => {
var oldPositions = (JObject) layout["Positions"];
var oldPositions = (JObject) layout["Positions"]!;
var windows = new Dictionary<string, Window>();
foreach (var elementProp in oldPositions.Children<JProperty>()) {
@ -114,8 +114,8 @@ namespace HUD_Manager.Configuration {
windows[elementProp.Name] = new Window(
WindowComponent.X | WindowComponent.Y,
new Vector2<short>(
position["X"].ToObject<short>(),
position["Y"].ToObject<short>()
position["X"]!.ToObject<short>(),
position["Y"]!.ToObject<short>()
)
);
}
@ -130,7 +130,7 @@ namespace HUD_Manager.Configuration {
}
private static string PluginConfig(string? pluginName = null) {
pluginName ??= Assembly.GetAssembly(typeof(Plugin)).GetName().Name;
pluginName ??= Assembly.GetAssembly(typeof(Plugin))!.GetName().Name;
return Path.Combine(new[] {
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"XIVLauncher",
@ -159,7 +159,7 @@ namespace HUD_Manager.Configuration {
goto DefaultConfig;
}
var config = JsonConvert.DeserializeObject<JObject>(text);
var config = JsonConvert.DeserializeObject<JObject>(text)!;
int GetVersion() {
if (config.TryGetValue("Version", out var token)) {
@ -180,7 +180,7 @@ namespace HUD_Manager.Configuration {
if (version == 1) {
var v1 = config.ToObject<ConfigV1>(new JsonSerializer {
TypeNameHandling = TypeNameHandling.None,
});
})!;
return Migrate(v1);
}
@ -206,7 +206,7 @@ namespace HUD_Manager.Configuration {
}
if (version == Config.LatestVersion) {
return config.ToObject<Config>();
return config.ToObject<Config>()!;
}
DefaultConfig:

View File

@ -1,4 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Resourcer/>
<Costura/>
</Weavers>

View File

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Component.GUI;
namespace HUD_Manager {
public class GameFunctions {
@ -22,9 +22,9 @@ namespace HUD_Manager {
public GameFunctions(Plugin plugin) {
this.Plugin = plugin;
var setPositionPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("4C 8B 89 ?? ?? ?? ?? 41 0F BF C0");
var setAlphaPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("F6 81 ?? ?? ?? ?? ?? 88 91 ?? ?? ?? ??");
var updatePositionPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 48 8B 8B ?? ?? ?? ?? 33 D2 48 8B 01 FF 90 ?? ?? ?? ??");
var setPositionPtr = this.Plugin.SigScanner.ScanText("4C 8B 89 ?? ?? ?? ?? 41 0F BF C0");
var setAlphaPtr = this.Plugin.SigScanner.ScanText("F6 81 ?? ?? ?? ?? ?? 88 91 ?? ?? ?? ??");
var updatePositionPtr = this.Plugin.SigScanner.ScanText("E8 ?? ?? ?? ?? 48 8B 8B ?? ?? ?? ?? 33 D2 48 8B 01 FF 90 ?? ?? ?? ??");
// var baseUiPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 0F BF D5");
this._setPosition = Marshal.GetDelegateForFunctionPointer<SetPositionDelegate>(setPositionPtr);
@ -33,50 +33,44 @@ namespace HUD_Manager {
}
public void SetAddonPosition(string uiName, short x, short y) {
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName(uiName, 1);
if (addon == null) {
var addon = this.Plugin.GameGui.GetAddonByName(uiName, 1);
if (addon == IntPtr.Zero) {
return;
}
var baseUi = this.Plugin.Interface.Framework.Gui.GetBaseUIObject();
var baseUi = this.Plugin.GameGui.GetUIModule();
var manager = Marshal.ReadIntPtr(baseUi + 0x20);
this._updateAddonPosition(
manager,
addon.Address,
addon,
1
);
this._setPosition(addon.Address, x, y);
this._setPosition(addon, x, y);
this._updateAddonPosition(
manager,
addon.Address,
addon,
0
);
}
public Vector2<short>? GetAddonPosition(string uiName) {
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName(uiName, 1);
if (addon == null) {
public unsafe Vector2<short>? GetAddonPosition(string uiName) {
var addon = this.Plugin.GameGui.GetAddonByName(uiName, 1);
if (addon == IntPtr.Zero) {
return null;
}
try {
var x = addon.X;
var y = addon.Y;
return new Vector2<short>(x, y);
} catch (KeyNotFoundException) {
return null;
}
var unit = (AtkUnitBase*) addon;
return new Vector2<short>(unit->X, unit->Y);
}
public void SetAddonAlpha(string name, byte alpha) {
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName(name, 1);
if (addon == null) {
var addon = this.Plugin.GameGui.GetAddonByName(name, 1);
if (addon == IntPtr.Zero) {
return;
}
this._setAlpha(addon.Address, alpha);
this._setAlpha(addon, alpha);
}
}
}

View File

@ -1,17 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net48</TargetFramework>
<TargetFramework>net5-windows</TargetFramework>
<Version>2.0.0.10</Version>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dalamud">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="FFXIVClientStructs">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\FFXIVClientStructs.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ImGui.NET">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\ImGui.NET.dll</HintPath>
<Private>False</Private>
@ -34,14 +40,10 @@
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody" Version="5.1.0" PrivateAssets="all"/>
<PackageReference Include="DalamudPackager" Version="1.2.1"/>
<PackageReference Include="Fody" Version="6.5.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="DalamudPackager" Version="2.1.2"/>
<PackageReference Include="Fody" Version="6.5.2" PrivateAssets="all"/>
<PackageReference Include="Resourcer.Fody" Version="1.8.0" PrivateAssets="all"/>
<PackageReference Include="YamlDotNet" Version="11.0.1"/>
<PackageReference Include="YamlDotNet" Version="11.2.1"/>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="help.yaml"/>

View File

@ -30,8 +30,8 @@ namespace HUD_Manager {
public Hud(Plugin plugin) {
this.Plugin = plugin;
var getFilePointerPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 48 85 C0 74 14 83 7B 44 00");
var setHudLayoutPtr = this.Plugin.Interface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 33 C0 EB 15");
var getFilePointerPtr = this.Plugin.SigScanner.ScanText("E8 ?? ?? ?? ?? 48 85 C0 74 14 83 7B 44 00");
var setHudLayoutPtr = this.Plugin.SigScanner.ScanText("E8 ?? ?? ?? ?? 33 C0 EB 15");
if (getFilePointerPtr != IntPtr.Zero) {
this._getFilePointer = Marshal.GetDelegateForFunctionPointer<GetFilePointerDelegate>(getFilePointerPtr);
}

View File

@ -1,94 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Dalamud.Plugin;
namespace HUD_Manager {
public class HudSwapMurderer {
private Plugin Plugin { get; }
public HudSwapMurderer(Plugin plugin) {
this.Plugin = plugin;
this.Murder();
Oppress();
}
/// <summary>
/// Kill any existing HudSwap instance.
/// </summary>
private void Murder() {
// get dalamud
var dalamudField = this.Plugin.Interface.GetType().GetField("dalamud", BindingFlags.Instance | BindingFlags.NonPublic);
var dalamud = (Dalamud.Dalamud?) dalamudField?.GetValue(this.Plugin.Interface);
if (dalamud == null) {
PluginLog.LogWarning("Could not kill HudSwap since Dalamud field was null");
return;
}
// get the plugin manager
var managerProp = dalamud.GetType().GetProperty("PluginManager", BindingFlags.Instance | BindingFlags.NonPublic);
var manager = managerProp?.GetValue(dalamud);
if (manager == null) {
PluginLog.LogWarning("Could not kill HudSwap since PluginManager property was null");
return;
}
// get the method to disable plugins
var disablePluginMethod = manager.GetType().GetMethod("DisablePlugin", BindingFlags.Instance | BindingFlags.Public);
if (disablePluginMethod == null) {
PluginLog.LogWarning("Could not kill HudSwap since DisablePlugin method was null");
return;
}
// get the list of plugins
var pluginsField = manager.GetType().GetProperty("Plugins", BindingFlags.Instance | BindingFlags.Public);
var plugins = (List<(IDalamudPlugin plugin, PluginDefinition def, DalamudPluginInterface PluginInterface, bool IsRaw)>?) pluginsField?.GetValue(manager);
if (plugins == null) {
PluginLog.LogWarning("Could not kill HudSwap since Plugins property was null");
return;
}
var hudSwapDefs = plugins
.Select(info => info.def)
.Where(def => def.InternalName == "HudSwap")
.ToArray();
foreach (var def in hudSwapDefs) {
disablePluginMethod.Invoke(manager, new object[] {def});
}
}
/// <summary>
/// Prevent HudSwap from ever rising again.
/// </summary>
private static void Oppress() {
var hudSwapInstallPath = Path.Combine(new[] {
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"XIVLauncher",
"installedPlugins",
"HudSwap",
});
if (!Directory.Exists(hudSwapInstallPath)) {
return;
}
foreach (var version in Directory.EnumerateDirectories(hudSwapInstallPath)) {
var disabledPath = Path.Combine(new[] {
hudSwapInstallPath,
version,
".disabled",
});
try {
File.Create(disabledPath).Dispose();
} catch (IOException ex) {
PluginLog.LogWarning($"Failed to oppress HudSwap {version}:\n{ex}");
}
}
}
}
}

View File

@ -5,16 +5,16 @@ using Lumina.Text;
namespace HUD_Manager.Lumina {
[Sheet("Hud")]
public class HudSheet : ExcelRow {
public string Name { get; set; } = null!;
public string ShortName { get; set; } = null!;
public string ShorterName { get; set; } = null!;
public SeString Name { get; set; } = null!;
public SeString ShortName { get; set; } = null!;
public SeString ShorterName { get; set; } = null!;
public override void PopulateData(RowParser parser, global::Lumina.GameData lumina, Language language) {
this.RowId = parser.Row;
this.SubRowId = parser.SubRow;
this.Name = parser.ReadColumn<SeString>(0);
this.ShortName = parser.ReadColumn<SeString>(1);
this.ShorterName = parser.ReadColumn<SeString>(2);
this.Name = parser.ReadColumn<SeString>(0)!;
this.ShortName = parser.ReadColumn<SeString>(1)!;
this.ShorterName = parser.ReadColumn<SeString>(2)!;
this.SheetLanguage = language;
this.SheetName = parser.Sheet.Name;

View File

@ -1,4 +1,11 @@
using System;
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.Plugin;
using HUD_Manager.Configuration;
using HUD_Manager.Ui;
@ -10,22 +17,40 @@ namespace HUD_Manager {
public class Plugin : IDalamudPlugin {
public string Name => "HUD Manager";
private Swapper Swapper { get; set; } = null!;
private Commands Commands { get; set; } = null!;
public DalamudPluginInterface Interface { get; private set; } = null!;
public Interface Ui { get; private set; } = null!;
public Hud Hud { get; private set; } = null!;
public Statuses Statuses { get; private set; } = null!;
public GameFunctions GameFunctions { get; private set; } = null!;
public Config Config { get; private set; } = null!;
public HelpFile Help { get; private set; } = null!;
[PluginService]
internal DalamudPluginInterface Interface { get; init; } = null!;
public void Initialize(DalamudPluginInterface pluginInterface) {
this.Interface = pluginInterface;
[PluginService]
internal ClientState ClientState { get; init; } = null!;
// it's time to do a murder
_ = new HudSwapMurderer(this);
[PluginService]
internal CommandManager CommandManager { get; init; } = null!;
[PluginService]
internal Condition Condition { get; init; } = null!;
[PluginService]
internal DataManager DataManager { get; init; } = null!;
[PluginService]
internal Framework Framework { get; init; } = null!;
[PluginService]
internal GameGui GameGui { get; init; } = null!;
[PluginService]
internal SigScanner SigScanner { get; init; } = null!;
private Swapper Swapper { get; }
private Commands Commands { get; }
public Interface Ui { get; }
public Hud Hud { get; }
public Statuses Statuses { get; }
public GameFunctions GameFunctions { get; }
public Config Config { get; }
public HelpFile Help { get; }
public Plugin() {
this.Config = Migrator.LoadConfig(this);
this.Config.Initialize(this.Interface);
this.Config.Save();

View File

@ -1,12 +1,13 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Actors.Types;
using Dalamud.Plugin;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
using Lumina.Excel.GeneratedSheets;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Condition = Dalamud.Game.ClientState.Conditions.Condition;
// TODO: Zone swaps?
@ -17,25 +18,25 @@ namespace HUD_Manager {
private readonly Dictionary<Status, bool> _condition = new();
private ClassJob? _job;
internal static byte GetStatus(Actor actor) {
internal static byte GetStatus(GameObject obj) {
// Updated: 5.5
// 40 57 48 83 EC 70 48 8B F9 E8 ?? ?? ?? ?? 81 BF ?? ?? ?? ?? ?? ?? ?? ??
const int offset = 0x19A0;
return Marshal.ReadByte(actor.Address + offset);
return Marshal.ReadByte(obj.Address + offset);
}
internal static byte GetOnlineStatus(Actor actor) {
internal static byte GetOnlineStatus(GameObject obj) {
// Updated: 5.5
// E8 ?? ?? ?? ?? 48 85 C0 75 54
const int offset = 0x197F;
return Marshal.ReadByte(actor.Address + offset);
return Marshal.ReadByte(obj.Address + offset);
}
internal static byte GetBardThing(Actor actor) {
internal static byte GetBardThing(GameObject obj) {
// Updated: 5.5
// E8 ?? ?? ?? ?? 48 8B CB E8 ?? ?? ?? ?? 0F B6 43 50
const int offset = 0x197C;
return Marshal.ReadByte(actor.Address + offset);
return Marshal.ReadByte(obj.Address + offset);
}
public Statuses(Plugin plugin) {
@ -49,7 +50,7 @@ namespace HUD_Manager {
var anyChanged = false;
var currentJob = this.Plugin.Interface.Data.GetExcelSheet<ClassJob>().GetRow(player.ClassJob.Id);
var currentJob = this.Plugin.DataManager.GetExcelSheet<ClassJob>()!.GetRow(player.ClassJob.Id);
if (this._job != null && this._job != currentJob) {
anyChanged = true;
}
@ -58,7 +59,7 @@ namespace HUD_Manager {
foreach (Status status in Enum.GetValues(typeof(Status))) {
var old = this._condition.ContainsKey(status) && this._condition[status];
this._condition[status] = status.Active(player, this.Plugin.Interface);
this._condition[status] = status.Active(player, this.Plugin.Condition);
anyChanged |= old != this._condition[status];
}
@ -66,14 +67,14 @@ namespace HUD_Manager {
}
private Guid CalculateCurrentHud() {
var player = this.Plugin.Interface.ClientState.LocalPlayer;
var player = this.Plugin.ClientState.LocalPlayer;
if (player == null) {
return Guid.Empty;
}
foreach (var match in this.Plugin.Config.HudConditionMatches) {
if ((!match.Status.HasValue || this._condition[match.Status.Value]) &&
(match.ClassJob == null || this._job?.Abbreviation == match.ClassJob)) {
(match.ClassJob == null || this._job?.Abbreviation?.ToString() == match.ClassJob)) {
return match.LayoutId;
}
}
@ -149,14 +150,14 @@ namespace HUD_Manager {
throw new ApplicationException($"No name was set up for {status}");
}
public static bool Active(this Status status, PlayerCharacter player, DalamudPluginInterface pi) {
public static bool Active(this Status status, PlayerCharacter player, Condition condition) {
if (player == null) {
throw new ArgumentNullException(nameof(player), "PlayerCharacter cannot be null");
}
if (status > 0) {
var flag = (ConditionFlag) status;
return pi.ClientState.Condition[flag];
return condition[flag];
}
switch (status) {

View File

@ -193,7 +193,7 @@ namespace HUD_Manager.Structs {
return kind.ToString();
}
var name = data.GetExcelSheet<HudSheet>().GetRow(id.Value).Name;
var name = data.GetExcelSheet<HudSheet>()!.GetRow(id.Value)!.Name.ToString();
uint? jobId = kind switch {
ElementKind.AetherflowGaugeSmn => 27,
@ -202,7 +202,7 @@ namespace HUD_Manager.Structs {
};
if (jobId != null) {
var abbr = data.GetExcelSheet<ClassJob>().GetRow(jobId.Value).Abbreviation;
var abbr = data.GetExcelSheet<ClassJob>()!.GetRow(jobId.Value)!.Abbreviation;
name += $" ({abbr})";
}

View File

@ -1,5 +1,5 @@
using System;
using Dalamud.Game.Internal;
using Dalamud.Game;
namespace HUD_Manager {
public class Swapper : IDisposable {
@ -8,19 +8,19 @@ namespace HUD_Manager {
public Swapper(Plugin plugin) {
this.Plugin = plugin;
this.Plugin.Interface.Framework.OnUpdateEvent += this.OnFrameworkUpdate;
this.Plugin.Framework.Update += this.OnFrameworkUpdate;
}
public void Dispose() {
this.Plugin.Interface.Framework.OnUpdateEvent -= this.OnFrameworkUpdate;
this.Plugin.Framework.Update -= this.OnFrameworkUpdate;
}
public void OnFrameworkUpdate(Framework framework) {
private void OnFrameworkUpdate(Framework framework) {
if (!this.Plugin.Config.SwapsEnabled || !this.Plugin.Config.UnderstandsRisks) {
return;
}
var player = this.Plugin.Interface.ClientState.LocalPlayer;
var player = this.Plugin.ClientState.LocalPlayer;
if (player == null) {
return;
}

View File

@ -1,9 +1,11 @@
using System;
#if DEBUG
using System;
using System.Linq;
using System.Runtime.InteropServices;
using Dalamud.Plugin;
using HUD_Manager.Structs;
using ImGuiNET;
#endif
namespace HUD_Manager.Ui {
#if DEBUG

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Dalamud.Interface;
using FFXIVClientStructs.FFXIV.Component.GUI;
using HUD_Manager.Configuration;
using HUD_Manager.Structs;
using HUD_Manager.Tree;
@ -50,10 +51,15 @@ namespace HUD_Manager.Ui.Editor {
goto EndTabItem;
}
var charConfig = this.Plugin.Interface.Framework.Gui.GetAddonByName("ConfigCharacter", 1);
if (charConfig != null && charConfig.Visible) {
ImGui.TextUnformatted("Please close the Character Configuration window before continuing.");
goto EndTabItem;
unsafe {
var charConfigPtr = this.Plugin.GameGui.GetAddonByName("ConfigCharacter", 1);
if (charConfigPtr != IntPtr.Zero) {
var charConfig = (AtkUnitBase*) charConfigPtr;
if (charConfig->IsVisible) {
ImGui.TextUnformatted("Please close the Character Configuration window before continuing.");
goto EndTabItem;
}
}
}
var update = false;

View File

@ -49,7 +49,7 @@ namespace HUD_Manager.Ui.Editor {
continue;
}
ImGui.TextUnformatted(element.Id.LocalisedName(this.Plugin.Interface.Data));
ImGui.TextUnformatted(element.Id.LocalisedName(this.Plugin.DataManager));
// determine if the window has moved and update if it has
var newPos = ImGuiExt.ConvertImGuiToGame(element, ImGui.GetWindowPos());

View File

@ -44,9 +44,9 @@ namespace HUD_Manager.Ui.Editor.Tabs {
if (ImGui.BeginPopup(Popups.AddElement)) {
var kinds = ElementKindExt.All()
.OrderBy(el => el.LocalisedName(this.Plugin.Interface.Data));
.OrderBy(el => el.LocalisedName(this.Plugin.DataManager));
foreach (var kind in kinds) {
if (!ImGui.Selectable($"{kind.LocalisedName(this.Plugin.Interface.Data)}##{kind}")) {
if (!ImGui.Selectable($"{kind.LocalisedName(this.Plugin.DataManager)}##{kind}")) {
continue;
}
@ -73,7 +73,7 @@ namespace HUD_Manager.Ui.Editor.Tabs {
var sortedElements = layout.Elements
.Where(entry => !ElementKindExt.Immutable.Contains(entry.Key))
.Select(entry => Tuple.Create(entry.Key, entry.Value, entry.Key.LocalisedName(this.Plugin.Interface.Data)))
.Select(entry => Tuple.Create(entry.Key, entry.Value, entry.Key.LocalisedName(this.Plugin.DataManager)))
.OrderBy(tuple => tuple.Item3);
foreach (var (kind, element, name) in sortedElements) {
if (this.Search != null && !name.ContainsIgnoreCase(this.Search)) {

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Numerics;
using Dalamud.Interface;
using FFXIVClientStructs.FFXIV.Component.GUI;
using HUD_Manager.Configuration;
using HUD_Manager.Structs;
using ImGuiNET;
@ -23,19 +24,22 @@ namespace HUD_Manager.Ui.Editor.Tabs {
ImGui.TextUnformatted("Windows must be open to add them");
ImGui.Separator();
foreach (var window in WindowKindExt.All) {
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName(window, 1);
var flags = addon?.Visible == true && !layout.Windows.ContainsKey(window)
? ImGuiSelectableFlags.None
: ImGuiSelectableFlags.Disabled;
unsafe {
foreach (var window in WindowKindExt.All) {
var addonPtr = this.Plugin.GameGui.GetAddonByName(window, 1);
var addon = (AtkUnitBase*) addonPtr;
var flags = addonPtr != IntPtr.Zero && addon->IsVisible && !layout.Windows.ContainsKey(window)
? ImGuiSelectableFlags.None
: ImGuiSelectableFlags.Disabled;
if (!ImGui.Selectable(window, false, flags)) {
continue;
}
if (!ImGui.Selectable(window, false, flags)) {
continue;
}
var pos = this.Plugin.GameFunctions.GetAddonPosition(window);
if (pos != null) {
layout.Windows.Add(window, new Window(pos));
var pos = this.Plugin.GameFunctions.GetAddonPosition(window);
if (pos != null) {
layout.Windows.Add(window, new Window(pos));
}
}
}

View File

@ -33,16 +33,20 @@ namespace HUD_Manager.Ui {
this.Debug = new Debug(plugin);
#endif
this.Plugin.Interface.UiBuilder.OnBuildUi += this.Draw;
this.Plugin.Interface.UiBuilder.OnOpenConfigUi += this.OpenConfig;
this.Plugin.Interface.UiBuilder.Draw += this.Draw;
this.Plugin.Interface.UiBuilder.OpenConfigUi += this.OpenConfig;
}
public void Dispose() {
this.Plugin.Interface.UiBuilder.OnOpenConfigUi -= this.OpenConfig;
this.Plugin.Interface.UiBuilder.OnBuildUi -= this.Draw;
this.Plugin.Interface.UiBuilder.OpenConfigUi -= this.OpenConfig;
this.Plugin.Interface.UiBuilder.Draw -= this.Draw;
}
internal void OpenConfig(bool toggle = false) {
private void OpenConfig() {
this.OpenConfig(false);
}
internal void OpenConfig(bool toggle) {
if (toggle) {
this.SettingsVisible = !this.SettingsVisible;
} else {
@ -50,10 +54,6 @@ namespace HUD_Manager.Ui {
}
}
private void OpenConfig(object sender, EventArgs e) {
this.OpenConfig();
}
private void Draw() {
if (!this.SettingsVisible) {
return;

View File

@ -28,7 +28,7 @@ namespace HUD_Manager.Ui {
this.Plugin.Config.SwapsEnabled = enabled;
this.Plugin.Config.Save();
this.Plugin.Statuses.SetHudLayout(this.Plugin.Interface.ClientState.LocalPlayer, true);
this.Plugin.Statuses.SetHudLayout(this.Plugin.ClientState.LocalPlayer, true);
}
ImGui.TextUnformatted("Note: Disable swaps when editing your HUD.");
@ -106,7 +106,7 @@ namespace HUD_Manager.Ui {
this._editingCondition.ClassJob = null;
}
foreach (var job in this.Plugin.Interface.Data.GetExcelSheet<ClassJob>().Skip(1)) {
foreach (var job in this.Plugin.DataManager.GetExcelSheet<ClassJob>()!.Skip(1)) {
if (ImGui.Selectable($"{job.Abbreviation}##condition-edit-job")) {
this._editingCondition.ClassJob = job.Abbreviation;
}
@ -247,7 +247,7 @@ namespace HUD_Manager.Ui {
return;
}
var player = this.Plugin.Interface.ClientState.LocalPlayer;
var player = this.Plugin.ClientState.LocalPlayer;
if (player == null || !this.Plugin.Config.SwapsEnabled) {
return;
}