mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-21 15:27:43 +01:00
feat: add "enter command" debug feature to DalamudLogWindow to test commands on the title screen
This commit is contained in:
parent
a72536603b
commit
474294d604
4 changed files with 31 additions and 4 deletions
|
|
@ -212,7 +212,7 @@ namespace Dalamud {
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
if (ImGui.MenuItem("Open Log window"))
|
if (ImGui.MenuItem("Open Log window"))
|
||||||
{
|
{
|
||||||
this.logWindow = new DalamudLogWindow();
|
this.logWindow = new DalamudLogWindow(CommandManager);
|
||||||
this.isImguiDrawLogWindow = true;
|
this.isImguiDrawLogWindow = true;
|
||||||
}
|
}
|
||||||
if (ImGui.BeginMenu("Set log level..."))
|
if (ImGui.BeginMenu("Set log level..."))
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,12 @@ namespace Dalamud.Game.Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ProcessCommand(string content) {
|
/// <summary>
|
||||||
|
/// Process a command in full.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="content">The full command string.</param>
|
||||||
|
/// <returns>True if the command was found and dispatched.</returns>
|
||||||
|
public bool ProcessCommand(string content) {
|
||||||
string command;
|
string command;
|
||||||
string argument;
|
string argument;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ namespace Dalamud.Game.Internal.Gui {
|
||||||
var parsedSender = SeString.Parse(sender.RawData);
|
var parsedSender = SeString.Parse(sender.RawData);
|
||||||
var parsedMessage = SeString.Parse(message.RawData);
|
var parsedMessage = SeString.Parse(message.RawData);
|
||||||
|
|
||||||
|
Log.Verbose("[CHATGUI][{0}][{1}]", parsedSender.TextValue, parsedMessage.TextValue);
|
||||||
|
|
||||||
//Log.Debug($"HandlePrintMessageDetour {manager} - [{chattype}] [{BitConverter.ToString(message.RawData).Replace("-", " ")}] {message.Value} from {senderName.Value}");
|
//Log.Debug($"HandlePrintMessageDetour {manager} - [{chattype}] [{BitConverter.ToString(message.RawData).Replace("-", " ")}] {message.Value} from {senderName.Value}");
|
||||||
|
|
||||||
var originalMessageData = (byte[]) message.RawData.Clone();
|
var originalMessageData = (byte[]) message.RawData.Clone();
|
||||||
|
|
@ -113,7 +115,7 @@ namespace Dalamud.Game.Internal.Gui {
|
||||||
Log.Verbose("SeString was edited, taking precedence over StdString edit.");
|
Log.Verbose("SeString was edited, taking precedence over StdString edit.");
|
||||||
message.RawData = newEdited;
|
message.RawData = newEdited;
|
||||||
}
|
}
|
||||||
Log.Debug($"\nOLD: {BitConverter.ToString(originalMessageData)}\nNEW: {BitConverter.ToString(newEdited)}");
|
//Log.Debug($"\nOLD: {BitConverter.ToString(originalMessageData)}\nNEW: {BitConverter.ToString(newEdited)}");
|
||||||
|
|
||||||
var messagePtr = pMessage;
|
var messagePtr = pMessage;
|
||||||
OwnedStdString allocatedString = null;
|
OwnedStdString allocatedString = null;
|
||||||
|
|
@ -173,12 +175,14 @@ namespace Dalamud.Game.Internal.Gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Print(string message) {
|
public void Print(string message) {
|
||||||
|
Log.Verbose("[CHATGUI PRINT]{0}", message);
|
||||||
PrintChat(new XivChatEntry {
|
PrintChat(new XivChatEntry {
|
||||||
MessageBytes = Encoding.UTF8.GetBytes(message)
|
MessageBytes = Encoding.UTF8.GetBytes(message)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrintError(string message) {
|
public void PrintError(string message) {
|
||||||
|
Log.Verbose("[CHATGUI PRINT ERROR]{0}", message);
|
||||||
PrintChat(new XivChatEntry {
|
PrintChat(new XivChatEntry {
|
||||||
MessageBytes = Encoding.UTF8.GetBytes(message),
|
MessageBytes = Encoding.UTF8.GetBytes(message),
|
||||||
Type = XivChatType.Urgent
|
Type = XivChatType.Urgent
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,21 @@ using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Dalamud.Game.Command;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace Dalamud.Interface
|
namespace Dalamud.Interface
|
||||||
{
|
{
|
||||||
class DalamudLogWindow : IDisposable {
|
class DalamudLogWindow : IDisposable {
|
||||||
|
private readonly CommandManager commandManager;
|
||||||
private bool autoScroll = true;
|
private bool autoScroll = true;
|
||||||
private string logText = string.Empty;
|
private string logText = string.Empty;
|
||||||
|
|
||||||
public DalamudLogWindow() {
|
private string commandText = string.Empty;
|
||||||
|
|
||||||
|
public DalamudLogWindow(CommandManager commandManager) {
|
||||||
|
this.commandManager = commandManager;
|
||||||
SerilogEventSink.Instance.OnLogLine += Serilog_OnLogLine;
|
SerilogEventSink.Instance.OnLogLine += Serilog_OnLogLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,6 +65,18 @@ namespace Dalamud.Interface
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
var copy = ImGui.Button("Copy");
|
var copy = ImGui.Button("Copy");
|
||||||
|
|
||||||
|
ImGui.Text("Enter command: ");
|
||||||
|
ImGui.SameLine();
|
||||||
|
ImGui.InputText("##commandbox", ref this.commandText, 255);
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (ImGui.Button("Send")) {
|
||||||
|
if (this.commandManager.ProcessCommand(this.commandText)) {
|
||||||
|
Log.Information("Command was dispatched.");
|
||||||
|
} else {
|
||||||
|
Log.Information("Command {0} not registered.", this.commandText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar);
|
ImGui.BeginChild("scrolling", new Vector2(0, 0), false, ImGuiWindowFlags.HorizontalScrollbar);
|
||||||
|
|
||||||
if (clear)
|
if (clear)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue