mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-23 08:17:47 +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
|
|
@ -7,10 +7,10 @@ using ImGuiScene;
|
|||
namespace Dalamud.Interface
|
||||
{
|
||||
class DalamudCreditsWindow : IDisposable {
|
||||
private string creditsText = @"
|
||||
private string creditsText = @$"
|
||||
Dalamud
|
||||
A FFXIV Hooking Framework
|
||||
|
||||
Version {typeof(Dalamud).Assembly.GetName().Version}
|
||||
|
||||
|
||||
created by:
|
||||
|
|
@ -40,11 +40,12 @@ Truci
|
|||
Haplo
|
||||
|
||||
Everyone in the XIVLauncher Discord server
|
||||
Join us at: https://discord.gg/3NMcUV5
|
||||
|
||||
|
||||
|
||||
Licensed under AGPL
|
||||
Read the code: https://github.com/goaaats/Dalamud
|
||||
Contribute at: https://github.com/goaaats/Dalamud
|
||||
|
||||
|
||||
Thank you for using XIVLauncher!
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Data;
|
||||
using Dalamud.Game.ClientState.Actors.Types;
|
||||
using Dalamud.Game.ClientState.Actors.Types.NonPlayer;
|
||||
using ImGuiNET;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dalamud.Interface
|
||||
{
|
||||
class DalamudDataWindow {
|
||||
private DataManager dataMgr;
|
||||
private Dalamud dalamud;
|
||||
|
||||
private bool wasReady;
|
||||
private string serverOpString;
|
||||
|
|
@ -19,28 +15,26 @@ namespace Dalamud.Interface
|
|||
|
||||
private int currentKind;
|
||||
|
||||
public DalamudDataWindow(DataManager dataMgr) {
|
||||
this.dataMgr = dataMgr;
|
||||
public DalamudDataWindow(Dalamud dalamud) {
|
||||
this.dalamud = dalamud;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Draw()
|
||||
{
|
||||
public bool Draw() {
|
||||
ImGui.SetNextWindowSize(new Vector2(500, 500), ImGuiCond.Always);
|
||||
|
||||
var isOpen = true;
|
||||
|
||||
if (!ImGui.Begin("Dalamud Data", ref isOpen, ImGuiWindowFlags.NoCollapse))
|
||||
{
|
||||
if (!ImGui.Begin("Dalamud Data", ref isOpen, ImGuiWindowFlags.NoCollapse)) {
|
||||
ImGui.End();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -51,7 +45,8 @@ namespace Dalamud.Interface
|
|||
ImGui.SameLine();
|
||||
var copy = ImGui.Button("Copy all");
|
||||
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);
|
||||
|
||||
|
|
@ -60,17 +55,47 @@ namespace Dalamud.Interface
|
|||
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
|
||||
|
||||
if (this.wasReady) {
|
||||
switch (currentKind) {
|
||||
case 0: ImGui.TextUnformatted(this.serverOpString);
|
||||
if (this.wasReady)
|
||||
switch (this.currentKind) {
|
||||
case 0:
|
||||
ImGui.TextUnformatted(this.serverOpString);
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
else
|
||||
ImGui.TextUnformatted("Data not ready.");
|
||||
}
|
||||
|
||||
|
||||
ImGui.PopStyleVar();
|
||||
|
||||
ImGui.EndChild();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue