mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
feat: add "state" debugger to dalamud data window
This commit is contained in:
parent
8c7d2f8de0
commit
37b1a4fce9
4 changed files with 55 additions and 58 deletions
|
|
@ -192,7 +192,7 @@ namespace Dalamud {
|
||||||
}
|
}
|
||||||
if (ImGui.MenuItem("Open Data window"))
|
if (ImGui.MenuItem("Open Data window"))
|
||||||
{
|
{
|
||||||
this.dataWindow = new DalamudDataWindow(this.Data);
|
this.dataWindow = new DalamudDataWindow(this);
|
||||||
this.isImguiDrawDataWindow = true;
|
this.isImguiDrawDataWindow = true;
|
||||||
}
|
}
|
||||||
if (ImGui.MenuItem("Open Credits window")) {
|
if (ImGui.MenuItem("Open Credits window")) {
|
||||||
|
|
@ -313,11 +313,6 @@ namespace Dalamud {
|
||||||
HelpMessage = "Unmute a word or sentence. Usage: /xlunmute <word or sentence>"
|
HelpMessage = "Unmute a word or sentence. Usage: /xlunmute <word or sentence>"
|
||||||
});
|
});
|
||||||
|
|
||||||
CommandManager.AddHandler("/xldstate", new CommandInfo(OnDebugPrintGameStateCommand) {
|
|
||||||
HelpMessage = "Print parsed game state",
|
|
||||||
ShowInHelp = false
|
|
||||||
});
|
|
||||||
|
|
||||||
CommandManager.AddHandler("/ll", new CommandInfo(OnLastLinkCommand) {
|
CommandManager.AddHandler("/ll", new CommandInfo(OnLastLinkCommand) {
|
||||||
HelpMessage = "Open the last posted link in your default browser."
|
HelpMessage = "Open the last posted link in your default browser."
|
||||||
});
|
});
|
||||||
|
|
@ -360,8 +355,7 @@ namespace Dalamud {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.CommandManager.AddHandler("/xlcredits", new CommandInfo(OnOpenCreditsCommand) {
|
this.CommandManager.AddHandler("/xlcredits", new CommandInfo(OnOpenCreditsCommand) {
|
||||||
HelpMessage = "Opens the credits for dalamud.",
|
HelpMessage = "Opens the credits for dalamud."
|
||||||
ShowInHelp = false
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -455,29 +449,6 @@ namespace Dalamud {
|
||||||
Process.Start(ChatHandlers.LastLink);
|
Process.Start(ChatHandlers.LastLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDebugPrintGameStateCommand(string command, string arguments) {
|
|
||||||
Framework.Gui.Chat.Print(this.ClientState.Actors.Length + " entries");
|
|
||||||
Framework.Gui.Chat.Print(this.ClientState.LocalPlayer.Name);
|
|
||||||
Framework.Gui.Chat.Print(this.ClientState.LocalPlayer.CurrentWorld.Name);
|
|
||||||
Framework.Gui.Chat.Print(this.ClientState.LocalPlayer.HomeWorld.Name);
|
|
||||||
Framework.Gui.Chat.Print(this.ClientState.LocalContentId.ToString("X"));
|
|
||||||
Framework.Gui.Chat.Print(Framework.Gui.Chat.LastLinkedItemId.ToString());
|
|
||||||
|
|
||||||
for (var i = 0; i < this.ClientState.Actors.Length; i++) {
|
|
||||||
var actor = this.ClientState.Actors[i];
|
|
||||||
|
|
||||||
Log.Debug(actor.Name);
|
|
||||||
Framework.Gui.Chat.Print(
|
|
||||||
$"{i} - {actor.Name} - {actor.Position.X} {actor.Position.Y} {actor.Position.Z}");
|
|
||||||
|
|
||||||
if (actor is Npc npc)
|
|
||||||
Framework.Gui.Chat.Print($"DataId: {npc.DataId}");
|
|
||||||
|
|
||||||
if (actor is Chara chara)
|
|
||||||
Framework.Gui.Chat.Print(
|
|
||||||
$"Level: {chara.Level} ClassJob: {chara.ClassJob.Name} CHP: {chara.CurrentHp} MHP: {chara.MaxHp} CMP: {chara.CurrentMp} MMP: {chara.MaxMp}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void OnBotJoinCommand(string command, string arguments) {
|
private void OnBotJoinCommand(string command, string arguments) {
|
||||||
if (this.BotManager != null && this.BotManager.IsConnected)
|
if (this.BotManager != null && this.BotManager.IsConnected)
|
||||||
Process.Start(
|
Process.Start(
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Dalamud.Game.Internal {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A raw pointer to the instance of Client::Framework
|
/// A raw pointer to the instance of Client::Framework
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private FrameworkAddressResolver Address { get; }
|
public FrameworkAddressResolver Address { get; }
|
||||||
|
|
||||||
#region Subsystems
|
#region Subsystems
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@ using ImGuiScene;
|
||||||
namespace Dalamud.Interface
|
namespace Dalamud.Interface
|
||||||
{
|
{
|
||||||
class DalamudCreditsWindow : IDisposable {
|
class DalamudCreditsWindow : IDisposable {
|
||||||
private string creditsText = @"
|
private string creditsText = @$"
|
||||||
Dalamud
|
Dalamud
|
||||||
A FFXIV Hooking Framework
|
A FFXIV Hooking Framework
|
||||||
|
Version {typeof(Dalamud).Assembly.GetName().Version}
|
||||||
|
|
||||||
|
|
||||||
created by:
|
created by:
|
||||||
|
|
@ -40,11 +40,12 @@ Truci
|
||||||
Haplo
|
Haplo
|
||||||
|
|
||||||
Everyone in the XIVLauncher Discord server
|
Everyone in the XIVLauncher Discord server
|
||||||
|
Join us at: https://discord.gg/3NMcUV5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Licensed under AGPL
|
Licensed under AGPL
|
||||||
Read the code: https://github.com/goaaats/Dalamud
|
Contribute at: https://github.com/goaaats/Dalamud
|
||||||
|
|
||||||
|
|
||||||
Thank you for using XIVLauncher!
|
Thank you for using XIVLauncher!
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Text;
|
using Dalamud.Game.ClientState.Actors.Types;
|
||||||
using System.Threading.Tasks;
|
using Dalamud.Game.ClientState.Actors.Types.NonPlayer;
|
||||||
using Dalamud.Data;
|
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Dalamud.Interface
|
namespace Dalamud.Interface
|
||||||
{
|
{
|
||||||
class DalamudDataWindow {
|
class DalamudDataWindow {
|
||||||
private DataManager dataMgr;
|
private Dalamud dalamud;
|
||||||
|
|
||||||
private bool wasReady;
|
private bool wasReady;
|
||||||
private string serverOpString;
|
private string serverOpString;
|
||||||
|
|
@ -19,28 +15,26 @@ namespace Dalamud.Interface
|
||||||
|
|
||||||
private int currentKind;
|
private int currentKind;
|
||||||
|
|
||||||
public DalamudDataWindow(DataManager dataMgr) {
|
public DalamudDataWindow(Dalamud dalamud) {
|
||||||
this.dataMgr = dataMgr;
|
this.dalamud = dalamud;
|
||||||
|
|
||||||
Load();
|
Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Load() {
|
private void Load() {
|
||||||
if (this.dataMgr.IsDataReady)
|
if (this.dalamud.Data.IsDataReady)
|
||||||
{
|
{
|
||||||
this.serverOpString = JsonConvert.SerializeObject(this.dataMgr.ServerOpCodes, Formatting.Indented);
|
this.serverOpString = JsonConvert.SerializeObject(this.dalamud.Data.ServerOpCodes, Formatting.Indented);
|
||||||
this.wasReady = true;
|
this.wasReady = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Draw()
|
public bool Draw() {
|
||||||
{
|
|
||||||
ImGui.SetNextWindowSize(new Vector2(500, 500), ImGuiCond.Always);
|
ImGui.SetNextWindowSize(new Vector2(500, 500), ImGuiCond.Always);
|
||||||
|
|
||||||
var isOpen = true;
|
var isOpen = true;
|
||||||
|
|
||||||
if (!ImGui.Begin("Dalamud Data", ref isOpen, ImGuiWindowFlags.NoCollapse))
|
if (!ImGui.Begin("Dalamud Data", ref isOpen, ImGuiWindowFlags.NoCollapse)) {
|
||||||
{
|
|
||||||
ImGui.End();
|
ImGui.End();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +45,8 @@ namespace Dalamud.Interface
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
var copy = ImGui.Button("Copy all");
|
var copy = ImGui.Button("Copy all");
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
ImGui.Combo("Data kind", ref currentKind, new[] {"ServerOpCode", "ContentFinderCondition"}, 2);
|
ImGui.Combo("Data kind", ref this.currentKind, new[] {"ServerOpCode", "ContentFinderCondition", "State"},
|
||||||
|
3);
|
||||||
|
|
||||||
ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar);
|
ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar);
|
||||||
|
|
||||||
|
|
@ -60,17 +55,47 @@ namespace Dalamud.Interface
|
||||||
|
|
||||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
|
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
|
||||||
|
|
||||||
if (this.wasReady) {
|
if (this.wasReady)
|
||||||
switch (currentKind) {
|
switch (this.currentKind) {
|
||||||
case 0: ImGui.TextUnformatted(this.serverOpString);
|
case 0:
|
||||||
|
ImGui.TextUnformatted(this.serverOpString);
|
||||||
break;
|
break;
|
||||||
case 1: ImGui.TextUnformatted(this.cfcString);
|
case 1:
|
||||||
|
ImGui.TextUnformatted(this.cfcString);
|
||||||
|
break;
|
||||||
|
case 2: {
|
||||||
|
var stateString = string.Empty;
|
||||||
|
stateString += $"FrameworkBase: {this.dalamud.Framework.Address.BaseAddress.ToInt64():X}\n";
|
||||||
|
|
||||||
|
stateString += $"ActorTableLen: {this.dalamud.ClientState.Actors.Length}\n";
|
||||||
|
stateString += $"LocalPlayerName: {this.dalamud.ClientState.LocalPlayer.Name}\n";
|
||||||
|
stateString += $"CurrentWorldName: {this.dalamud.ClientState.LocalPlayer.CurrentWorld.Name}\n";
|
||||||
|
stateString += $"HomeWorldName: {this.dalamud.ClientState.LocalPlayer.HomeWorld.Name}\n";
|
||||||
|
stateString += $"LocalCID: {this.dalamud.ClientState.LocalContentId:X}\n";
|
||||||
|
stateString += $"LastLinkedItem: {this.dalamud.Framework.Gui.Chat.LastLinkedItemId.ToString()}\n";
|
||||||
|
|
||||||
|
for (var i = 0; i < this.dalamud.ClientState.Actors.Length; i++) {
|
||||||
|
var actor = this.dalamud.ClientState.Actors[i];
|
||||||
|
|
||||||
|
stateString +=
|
||||||
|
$" -> {i} - {actor.Name} - {actor.Position.X} {actor.Position.Y} {actor.Position.Z}\n";
|
||||||
|
|
||||||
|
if (actor is Npc npc)
|
||||||
|
stateString += $" DataId: {npc.DataId}\n";
|
||||||
|
|
||||||
|
if (actor is Chara chara)
|
||||||
|
stateString +=
|
||||||
|
$" Level: {chara.Level} ClassJob: {chara.ClassJob.Name} CHP: {chara.CurrentHp} MHP: {chara.MaxHp} CMP: {chara.CurrentMp} MMP: {chara.MaxMp}\n";
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.TextUnformatted(stateString);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
else
|
||||||
ImGui.TextUnformatted("Data not ready.");
|
ImGui.TextUnformatted("Data not ready.");
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.PopStyleVar();
|
ImGui.PopStyleVar();
|
||||||
|
|
||||||
ImGui.EndChild();
|
ImGui.EndChild();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue