feat: make gamedata optional in datawindow

This commit is contained in:
goat 2020-12-08 15:01:07 +01:00
parent 5b77aa87b0
commit bd57865868

View file

@ -34,6 +34,8 @@ namespace Dalamud.Interface
private int inputAddonIndex;
private Addon resultAddon;
private bool resolveGameData = false;
public DalamudDataWindow(Dalamud dalamud) {
this.dalamud = dalamud;
@ -66,6 +68,7 @@ namespace Dalamud.Interface
ImGui.SameLine();
ImGui.Combo("Data kind", ref this.currentKind, new[] {"ServerOpCode", "Address", "Actor Table", "Font Test", "Party List", "Plugin IPC", "Condition", "Gauge", "Command", "Client UI"},
10);
ImGui.Checkbox("Resolve GameData", ref this.resolveGameData);
ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar);
@ -74,6 +77,7 @@ namespace Dalamud.Interface
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
try {
if (this.wasReady)
switch (this.currentKind) {
case 0:
@ -84,7 +88,8 @@ namespace Dalamud.Interface
foreach (var debugScannedValue in BaseAddressResolver.DebugScannedValues) {
ImGui.TextUnformatted($"{debugScannedValue.Key}");
foreach (var valueTuple in debugScannedValue.Value) {
ImGui.TextUnformatted($" {valueTuple.Item1} - 0x{valueTuple.Item2.ToInt64():x}");
ImGui.TextUnformatted(
$" {valueTuple.Item1} - 0x{valueTuple.Item2.ToInt64():x}");
ImGui.SameLine();
if (ImGui.Button("C")) {
@ -105,16 +110,22 @@ namespace Dalamud.Interface
} else if (this.dalamud.ClientState.LocalPlayer == null) {
ImGui.TextUnformatted("LocalPlayer null.");
} else {
stateString += $"FrameworkBase: {this.dalamud.Framework.Address.BaseAddress.ToInt64():X}\n";
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.GameData.Name}\n";
stateString += $"HomeWorldName: {this.dalamud.ClientState.LocalPlayer.HomeWorld.GameData.Name}\n";
stateString +=
$"CurrentWorldName: {(this.resolveGameData ? this.dalamud.ClientState.LocalPlayer.CurrentWorld.GameData.Name : this.dalamud.ClientState.LocalPlayer.CurrentWorld.Id.ToString())}\n";
stateString +=
$"HomeWorldName: {(this.resolveGameData ? this.dalamud.ClientState.LocalPlayer.HomeWorld.GameData.Name : this.dalamud.ClientState.LocalPlayer.HomeWorld.Id.ToString())}\n";
stateString += $"LocalCID: {this.dalamud.ClientState.LocalContentId:X}\n";
stateString += $"LastLinkedItem: {this.dalamud.Framework.Gui.Chat.LastLinkedItemId.ToString()}\n";
stateString +=
$"LastLinkedItem: {this.dalamud.Framework.Gui.Chat.LastLinkedItemId.ToString()}\n";
stateString += $"TerritoryType: {this.dalamud.ClientState.TerritoryType}\n\n";
ImGui.TextUnformatted(stateString);
ImGui.Checkbox("Draw actors on screen", ref this.drawActors);
ImGui.SliderFloat("Draw Distance", ref this.maxActorDrawDistance, 2f, 40f);
@ -124,41 +135,53 @@ namespace Dalamud.Interface
if (actor == null)
continue;
stateString +=
var actorString =
$"{actor.Address.ToInt64():X}:{actor.ActorId:X}[{i}] - {actor.ObjectKind} - {actor.Name} - X{actor.Position.X} Y{actor.Position.Y} Z{actor.Position.Z} D{actor.YalmDistanceX} R{actor.Rotation} - Target: {actor.TargetActorID:X}\n";
if (actor is Npc npc)
stateString += $" DataId: {npc.DataId} NameId:{npc.NameId}\n";
actorString += $" DataId: {npc.DataId} NameId:{npc.NameId}\n";
if (actor is Chara chara)
stateString +=
$" Level: {chara.Level} ClassJob: {chara.ClassJob.GameData.Name} CHP: {chara.CurrentHp} MHP: {chara.MaxHp} CMP: {chara.CurrentMp} MMP: {chara.MaxMp}\n Customize: {BitConverter.ToString(chara.Customize).Replace("-", " ")}\n";
actorString +=
$" Level: {chara.Level} ClassJob: {(this.resolveGameData ? chara.ClassJob.GameData.Name : chara.ClassJob.Id.ToString())} CHP: {chara.CurrentHp} MHP: {chara.MaxHp} CMP: {chara.CurrentMp} MMP: {chara.MaxMp}\n Customize: {BitConverter.ToString(chara.Customize).Replace("-", " ")}\n";
if (actor is PlayerCharacter pc)
stateString +=
$" HomeWorld: {pc.HomeWorld.GameData.Name} CurrentWorld: {pc.CurrentWorld.GameData.Name} FC: {pc.CompanyTag}\n";
actorString +=
$" HomeWorld: {(this.resolveGameData ? pc.HomeWorld.GameData.Name : pc.HomeWorld.Id.ToString())} CurrentWorld: {(this.resolveGameData ? pc.CurrentWorld.GameData.Name : pc.CurrentWorld.Id.ToString())} FC: {pc.CompanyTag}\n";
if (this.drawActors && this.dalamud.Framework.Gui.WorldToScreen(actor.Position, out var screenCoords)) {
ImGui.TextUnformatted(actorString);
ImGui.SameLine();
if (ImGui.Button("C")) {
ImGui.SetClipboardText(actor.Address.ToInt64().ToString("X"));
}
if (this.drawActors &&
this.dalamud.Framework.Gui.WorldToScreen(actor.Position, out var screenCoords)
) {
ImGui.PushID("ActorWindow" + i);
ImGui.SetNextWindowPos(new Vector2(screenCoords.X, screenCoords.Y));
if (actor.YalmDistanceX > this.maxActorDrawDistance)
continue;
ImGui.SetNextWindowBgAlpha(Math.Max(1f - (actor.YalmDistanceX / this.maxActorDrawDistance), 0.2f));
ImGui.SetNextWindowBgAlpha(
Math.Max(1f - (actor.YalmDistanceX / this.maxActorDrawDistance), 0.2f));
if (ImGui.Begin("Actor" + i,
ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.AlwaysAutoResize |
ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoMouseInputs |
ImGuiWindowFlags.NoDecoration |
ImGuiWindowFlags.AlwaysAutoResize |
ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoMove |
ImGuiWindowFlags.NoMouseInputs |
ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNav)) {
ImGui.Text($"{actor.Address.ToInt64():X}:{actor.ActorId:X}[{i}] - {actor.ObjectKind} - {actor.Name}");
ImGui.Text(
$"{actor.Address.ToInt64():X}:{actor.ActorId:X}[{i}] - {actor.ObjectKind} - {actor.Name}");
ImGui.End();
}
ImGui.PopID();
}
}
}
ImGui.TextUnformatted(stateString);
}
break;
@ -171,7 +194,8 @@ namespace Dalamud.Interface
ImGui.TextUnformatted(specialChars);
foreach (var fontAwesomeIcon in Enum.GetValues(typeof(FontAwesomeIcon)).Cast<FontAwesomeIcon>()) {
foreach (var fontAwesomeIcon in Enum.GetValues(typeof(FontAwesomeIcon))
.Cast<FontAwesomeIcon>()) {
ImGui.Text(((int) fontAwesomeIcon.ToIconChar()).ToString("X") + " - ");
ImGui.SameLine();
@ -179,6 +203,7 @@ namespace Dalamud.Interface
ImGui.Text(fontAwesomeIcon.ToIconString());
ImGui.PopFont();
}
break;
// Party
@ -209,15 +234,19 @@ namespace Dalamud.Interface
// Subscriptions
case 5:
var i1 = new DalamudPluginInterface(this.dalamud, "DalamudTestSub", null, PluginLoadReason.Boot);
var i2 = new DalamudPluginInterface(this.dalamud, "DalamudTestPub", null, PluginLoadReason.Boot);
var i1 = new DalamudPluginInterface(this.dalamud, "DalamudTestSub", null,
PluginLoadReason.Boot);
var i2 = new DalamudPluginInterface(this.dalamud, "DalamudTestPub", null,
PluginLoadReason.Boot);
if (ImGui.Button("Add test sub")) i1.Subscribe("DalamudTestPub", o => {
if (ImGui.Button("Add test sub"))
i1.Subscribe("DalamudTestPub", o => {
dynamic msg = o;
Log.Debug(msg.Expand);
});
if (ImGui.Button("Add test sub any")) i1.SubscribeAny((o, a) => {
if (ImGui.Button("Add test sub any"))
i1.SubscribeAny((o, a) => {
dynamic msg = a;
Log.Debug($"From {o}: {msg.Expand}");
});
@ -233,8 +262,7 @@ namespace Dalamud.Interface
}
// This doesn't actually work, so don't mind it - impl relies on plugins being registered in PluginManager
if (ImGui.Button("Send test message any"))
{
if (ImGui.Button("Send test message any")) {
dynamic testMsg = new ExpandoObject();
testMsg.Expand = "dong";
i2.SendMessage("DalamudTestSub", testMsg);
@ -243,6 +271,7 @@ namespace Dalamud.Interface
foreach (var sub in this.dalamud.PluginManager.IpcSubscriptions) {
ImGui.Text($"Source:{sub.SourcePluginName} Sub:{sub.SubPluginName}");
}
break;
// Condition
@ -256,13 +285,11 @@ namespace Dalamud.Interface
var didAny = false;
for (var i = 0; i < Condition.MaxConditionEntries; i++)
{
var typedCondition = (ConditionFlag)i;
for (var i = 0; i < Condition.MaxConditionEntries; i++) {
var typedCondition = (ConditionFlag) i;
var cond = this.dalamud.ClientState.Condition[typedCondition];
if (!cond)
{
if (!cond) {
continue;
}
@ -271,8 +298,7 @@ namespace Dalamud.Interface
ImGui.Text($"ID: {i} Enum: {typedCondition}");
}
if (!didAny)
{
if (!didAny) {
ImGui.Text("None. Talk to a shop NPC or visit a market board to find out more!!!!!!!");
}
@ -286,7 +312,8 @@ namespace Dalamud.Interface
case 8:
foreach (var command in this.dalamud.CommandManager.Commands) {
ImGui.Text($"{command.Key}\n -> {command.Value.HelpMessage}\n -> In help: {command.Value.ShowInHelp}\n\n");
ImGui.Text(
$"{command.Key}\n -> {command.Value.HelpMessage}\n -> In help: {command.Value.ShowInHelp}\n\n");
}
break;
@ -297,11 +324,13 @@ namespace Dalamud.Interface
if (ImGui.Button("Get Addon")) {
this.resultAddon =
this.dalamud.Framework.Gui.GetAddonByName(this.inputAddonName, this.inputAddonIndex);
this.dalamud.Framework.Gui.GetAddonByName(
this.inputAddonName, this.inputAddonIndex);
}
if (this.resultAddon != null) {
ImGui.TextUnformatted($"{this.resultAddon.Name} - 0x{this.resultAddon.Address.ToInt64():x}\n v:{this.resultAddon.Visible} x:{this.resultAddon.X} y:{this.resultAddon.Y} s:{this.resultAddon.Scale}, w:{this.resultAddon.Width}, h:{this.resultAddon.Height}");
ImGui.TextUnformatted(
$"{this.resultAddon.Name} - 0x{this.resultAddon.Address.ToInt64():x}\n v:{this.resultAddon.Visible} x:{this.resultAddon.X} y:{this.resultAddon.Y} s:{this.resultAddon.Scale}, w:{this.resultAddon.Width}, h:{this.resultAddon.Height}");
}
if (ImGui.Button("Get Base UI object")) {
@ -314,6 +343,9 @@ namespace Dalamud.Interface
}
else
ImGui.TextUnformatted("Data not ready.");
} catch (Exception ex) {
ImGui.TextUnformatted(ex.ToString());
}
ImGui.PopStyleVar();