feat: add debug view
Also check generator return value. Also don't update friend list while in content.
This commit is contained in:
parent
8823597675
commit
c07c74924f
|
@ -85,7 +85,9 @@ namespace NominaOcculta {
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? GenerateName(int race, int clan, int gender) {
|
public string? GenerateName(int race, int clan, int gender) {
|
||||||
this.InternalGenerateName(race, clan, gender, this.First, this.Last);
|
if (this.InternalGenerateName(race, clan, gender, this.First, this.Last) == IntPtr.Zero) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var first = Marshal.PtrToStringUTF8(Marshal.ReadIntPtr(this.First));
|
var first = Marshal.PtrToStringUTF8(Marshal.ReadIntPtr(this.First));
|
||||||
var last = Marshal.PtrToStringUTF8(Marshal.ReadIntPtr(this.Last));
|
var last = Marshal.PtrToStringUTF8(Marshal.ReadIntPtr(this.Last));
|
||||||
|
|
|
@ -11,8 +11,13 @@ namespace NominaOcculta {
|
||||||
private Random Rng { get; } = new();
|
private Random Rng { get; } = new();
|
||||||
|
|
||||||
private Dictionary<(byte, byte, byte), Queue<string>> Names { get; } = new();
|
private Dictionary<(byte, byte, byte), Queue<string>> Names { get; } = new();
|
||||||
|
internal IReadOnlyDictionary<(byte, byte, byte), Queue<string>> ReadOnlyNames => this.Names;
|
||||||
|
|
||||||
private Dictionary<string, string> Replacements { get; } = new();
|
private Dictionary<string, string> Replacements { get; } = new();
|
||||||
|
internal IReadOnlyDictionary<string, string> ReadonlyReplacements => this.Replacements;
|
||||||
|
|
||||||
private Dictionary<string, (byte, byte, byte)?> LastSeenInfo { get; } = new();
|
private Dictionary<string, (byte, byte, byte)?> LastSeenInfo { get; } = new();
|
||||||
|
internal IReadOnlyDictionary<string, (byte, byte, byte)?> ReadOnlyLastSeenInfo => this.LastSeenInfo;
|
||||||
|
|
||||||
private readonly int _numRaces;
|
private readonly int _numRaces;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
using Dalamud.Game.ClientState.Objects.Enums;
|
using Dalamud.Game.ClientState.Objects.Enums;
|
||||||
using Dalamud.Game.ClientState.Objects.Types;
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
using Dalamud.Game.Text;
|
using Dalamud.Game.Text;
|
||||||
|
@ -38,8 +39,19 @@ namespace NominaOcculta {
|
||||||
this.Plugin.Framework.Update -= this.OnFrameworkUpdate;
|
this.Plugin.Framework.Update -= this.OnFrameworkUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly ConditionFlag[] DutyFlags = {
|
||||||
|
ConditionFlag.BoundByDuty,
|
||||||
|
ConditionFlag.BoundByDuty56,
|
||||||
|
ConditionFlag.BoundByDuty95,
|
||||||
|
ConditionFlag.BoundToDuty97,
|
||||||
|
};
|
||||||
|
|
||||||
|
private bool IsInDuty() {
|
||||||
|
return DutyFlags.Any(flag => this.Plugin.Condition[flag]);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnFrameworkUpdate(Framework framework) {
|
private void OnFrameworkUpdate(Framework framework) {
|
||||||
if (this.UpdateTimer.Elapsed < TimeSpan.FromSeconds(5)) {
|
if (this.UpdateTimer.Elapsed < TimeSpan.FromSeconds(5) || this.IsInDuty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using Dalamud.Data;
|
using Dalamud.Data;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Game.ClientState;
|
using Dalamud.Game.ClientState;
|
||||||
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
|
using Dalamud.Game.ClientState.Keys;
|
||||||
using Dalamud.Game.ClientState.Objects;
|
using Dalamud.Game.ClientState.Objects;
|
||||||
using Dalamud.Game.ClientState.Party;
|
using Dalamud.Game.ClientState.Party;
|
||||||
using Dalamud.Game.Command;
|
using Dalamud.Game.Command;
|
||||||
|
@ -25,12 +27,18 @@ namespace NominaOcculta {
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal CommandManager CommandManager { get; private init; }
|
internal CommandManager CommandManager { get; private init; }
|
||||||
|
|
||||||
|
[PluginService]
|
||||||
|
internal Condition Condition { get; private set; }
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal DataManager DataManager { get; private init; }
|
internal DataManager DataManager { get; private init; }
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal Framework Framework { get; private init; }
|
internal Framework Framework { get; private init; }
|
||||||
|
|
||||||
|
[PluginService]
|
||||||
|
internal KeyState KeyState { get; private init; }
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal PartyList PartyList { get; private init; }
|
internal PartyList PartyList { get; private init; }
|
||||||
|
|
||||||
|
@ -44,21 +52,23 @@ namespace NominaOcculta {
|
||||||
internal GameFunctions Functions { get; }
|
internal GameFunctions Functions { get; }
|
||||||
|
|
||||||
internal Configuration Config { get; }
|
internal Configuration Config { get; }
|
||||||
internal Commands Commands { get; }
|
private Commands Commands { get; }
|
||||||
internal NameRepository NameRepository { get; }
|
internal NameRepository NameRepository { get; }
|
||||||
internal Obscurer Obscurer { get; }
|
private Obscurer Obscurer { get; }
|
||||||
internal PluginUi Ui { get; }
|
internal PluginUi Ui { get; }
|
||||||
|
|
||||||
|
#pragma warning disable 8618
|
||||||
public Plugin() {
|
public Plugin() {
|
||||||
this.Common = new XivCommonBase(Hooks.NamePlates);
|
this.Common = new XivCommonBase(Hooks.NamePlates);
|
||||||
this.Functions = new GameFunctions(this);
|
this.Functions = new GameFunctions(this);
|
||||||
|
|
||||||
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
|
this.Config = this.Interface!.GetPluginConfig() as Configuration ?? new Configuration();
|
||||||
this.Ui = new PluginUi(this);
|
this.Ui = new PluginUi(this);
|
||||||
this.NameRepository = new NameRepository(this);
|
this.NameRepository = new NameRepository(this);
|
||||||
this.Obscurer = new Obscurer(this);
|
this.Obscurer = new Obscurer(this);
|
||||||
this.Commands = new Commands(this);
|
this.Commands = new Commands(this);
|
||||||
}
|
}
|
||||||
|
#pragma warning restore 8618
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
this.Commands.Dispose();
|
this.Commands.Dispose();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using Dalamud.Game.ClientState.Keys;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
namespace NominaOcculta {
|
namespace NominaOcculta {
|
||||||
|
@ -6,6 +7,7 @@ namespace NominaOcculta {
|
||||||
private Plugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
|
|
||||||
internal bool Visible;
|
internal bool Visible;
|
||||||
|
private bool _debug;
|
||||||
|
|
||||||
internal PluginUi(Plugin plugin) {
|
internal PluginUi(Plugin plugin) {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
|
@ -51,10 +53,80 @@ namespace NominaOcculta {
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
|
||||||
if (ImGui.Button("Reset names")) {
|
if (ImGui.Button("Reset names")) {
|
||||||
this.Plugin.NameRepository.Reset();
|
if (this.Plugin.KeyState[VirtualKey.CONTROL] && this.Plugin.KeyState[VirtualKey.SHIFT]) {
|
||||||
|
this._debug ^= true;
|
||||||
|
} else {
|
||||||
|
this.Plugin.NameRepository.Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._debug) {
|
||||||
|
if (ImGui.CollapsingHeader("Debug")) {
|
||||||
|
ImGui.PushID("debug");
|
||||||
|
try {
|
||||||
|
this.DrawDebug();
|
||||||
|
} finally {
|
||||||
|
ImGui.PopID();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawDebug() {
|
||||||
|
ImGui.TextUnformatted($"Initialised: {this.Plugin.NameRepository.Initialised}");
|
||||||
|
|
||||||
|
ImGui.Separator();
|
||||||
|
|
||||||
|
if (ImGui.TreeNode("Name queue")) {
|
||||||
|
foreach (var (info, queue) in this.Plugin.NameRepository.ReadOnlyNames) {
|
||||||
|
if (ImGui.CollapsingHeader($"{info}")) {
|
||||||
|
if (ImGui.BeginTable($"{info} table", 2)) {
|
||||||
|
foreach (var name in queue) {
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TextUnformatted(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.EndTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.TreeNode("Replacements")) {
|
||||||
|
if (ImGui.BeginTable("replacements", 2)) {
|
||||||
|
foreach (var (name, replacement) in this.Plugin.NameRepository.ReadonlyReplacements) {
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TextUnformatted(name);
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TextUnformatted(replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.EndTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.TreeNode("Last seen info")) {
|
||||||
|
if (ImGui.BeginTable("last seen info", 2)) {
|
||||||
|
foreach (var (name, info) in this.Plugin.NameRepository.ReadOnlyLastSeenInfo) {
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TextUnformatted(name);
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TextUnformatted($"{info}");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.EndTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.TreePop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue