mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 13:53:40 +01:00
feat: add Data window
This commit is contained in:
parent
1ac738cd25
commit
a3f59a6d9f
2 changed files with 96 additions and 0 deletions
|
|
@ -158,10 +158,12 @@ namespace Dalamud {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private bool isImguiDrawLogWindow = false;
|
private bool isImguiDrawLogWindow = false;
|
||||||
|
private bool isImguiDrawDataWindow = false;
|
||||||
|
|
||||||
private bool neverDrawWelcome = false;
|
private bool neverDrawWelcome = false;
|
||||||
|
|
||||||
private DalamudLogWindow logWindow;
|
private DalamudLogWindow logWindow;
|
||||||
|
private DalamudDataWindow dataWindow;
|
||||||
|
|
||||||
private void BuildDalamudUi()
|
private void BuildDalamudUi()
|
||||||
{
|
{
|
||||||
|
|
@ -172,11 +174,17 @@ namespace Dalamud {
|
||||||
if (ImGui.BeginMenu("Dalamud"))
|
if (ImGui.BeginMenu("Dalamud"))
|
||||||
{
|
{
|
||||||
ImGui.MenuItem("Draw Dalamud dev menu", "", ref this.isImguiDrawDevMenu);
|
ImGui.MenuItem("Draw Dalamud dev menu", "", ref this.isImguiDrawDevMenu);
|
||||||
|
ImGui.Separator();
|
||||||
if (ImGui.MenuItem("Open Log window"))
|
if (ImGui.MenuItem("Open Log window"))
|
||||||
{
|
{
|
||||||
this.logWindow = new DalamudLogWindow();
|
this.logWindow = new DalamudLogWindow();
|
||||||
this.isImguiDrawLogWindow = true;
|
this.isImguiDrawLogWindow = true;
|
||||||
}
|
}
|
||||||
|
if (ImGui.MenuItem("Open Data window"))
|
||||||
|
{
|
||||||
|
this.dataWindow = new DalamudDataWindow(this.Data);
|
||||||
|
this.isImguiDrawDataWindow = true;
|
||||||
|
}
|
||||||
ImGui.MenuItem("Draw ImGui demo", "", ref this.isImguiDrawDemoWindow);
|
ImGui.MenuItem("Draw ImGui demo", "", ref this.isImguiDrawDemoWindow);
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
if (ImGui.MenuItem("Unload Dalamud"))
|
if (ImGui.MenuItem("Unload Dalamud"))
|
||||||
|
|
@ -214,6 +222,11 @@ namespace Dalamud {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.isImguiDrawDataWindow)
|
||||||
|
{
|
||||||
|
this.isImguiDrawDataWindow = this.dataWindow != null && this.dataWindow.Draw();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.isImguiDrawDemoWindow)
|
if (this.isImguiDrawDemoWindow)
|
||||||
ImGui.ShowDemoWindow();
|
ImGui.ShowDemoWindow();
|
||||||
|
|
||||||
|
|
|
||||||
83
Dalamud/Interface/DalamudDataWindow.cs
Normal file
83
Dalamud/Interface/DalamudDataWindow.cs
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Dalamud.Data;
|
||||||
|
using ImGuiNET;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Dalamud.Interface
|
||||||
|
{
|
||||||
|
class DalamudDataWindow {
|
||||||
|
private DataManager dataMgr;
|
||||||
|
|
||||||
|
private bool wasReady;
|
||||||
|
private string serverOpString;
|
||||||
|
private string cfcString;
|
||||||
|
|
||||||
|
private int currentKind;
|
||||||
|
|
||||||
|
public DalamudDataWindow(DataManager dataMgr) {
|
||||||
|
this.dataMgr = dataMgr;
|
||||||
|
|
||||||
|
Load();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Load() {
|
||||||
|
if (this.dataMgr.IsDataReady)
|
||||||
|
{
|
||||||
|
this.serverOpString = JsonConvert.SerializeObject(this.dataMgr.ServerOpCodes, Formatting.Indented);
|
||||||
|
this.cfcString = JsonConvert.SerializeObject(this.dataMgr.ContentFinderCondition, Formatting.Indented);
|
||||||
|
this.wasReady = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Draw()
|
||||||
|
{
|
||||||
|
ImGui.SetNextWindowSize(new Vector2(500, 500), ImGuiCond.Always);
|
||||||
|
|
||||||
|
var isOpen = true;
|
||||||
|
|
||||||
|
if (!ImGui.Begin("Dalamud Data", ref isOpen, ImGuiWindowFlags.NoCollapse))
|
||||||
|
{
|
||||||
|
ImGui.End();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main window
|
||||||
|
if (ImGui.Button("Force Reload"))
|
||||||
|
Load();
|
||||||
|
ImGui.SameLine();
|
||||||
|
var copy = ImGui.Button("Copy all");
|
||||||
|
ImGui.SameLine();
|
||||||
|
ImGui.Combo("Data kind", ref currentKind, new[] {"ServerOpCode", "ContentFinderCondition"}, 2);
|
||||||
|
|
||||||
|
ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar);
|
||||||
|
|
||||||
|
if (copy)
|
||||||
|
ImGui.LogToClipboard();
|
||||||
|
|
||||||
|
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
|
||||||
|
|
||||||
|
if (this.wasReady) {
|
||||||
|
switch (currentKind) {
|
||||||
|
case 0: ImGui.TextUnformatted(this.serverOpString);
|
||||||
|
break;
|
||||||
|
case 1: ImGui.TextUnformatted(this.cfcString);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ImGui.TextUnformatted("Data not ready.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.PopStyleVar();
|
||||||
|
|
||||||
|
ImGui.EndChild();
|
||||||
|
ImGui.End();
|
||||||
|
|
||||||
|
return isOpen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue