feat: add "enter command" debug feature to DalamudLogWindow to test commands on the title screen

This commit is contained in:
goat 2020-04-24 20:29:41 +02:00
parent a72536603b
commit 474294d604
4 changed files with 31 additions and 4 deletions

View file

@ -212,7 +212,7 @@ namespace Dalamud {
ImGui.Separator();
if (ImGui.MenuItem("Open Log window"))
{
this.logWindow = new DalamudLogWindow();
this.logWindow = new DalamudLogWindow(CommandManager);
this.isImguiDrawLogWindow = true;
}
if (ImGui.BeginMenu("Set log level..."))

View file

@ -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 argument;

View file

@ -97,6 +97,8 @@ namespace Dalamud.Game.Internal.Gui {
var parsedSender = SeString.Parse(sender.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}");
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.");
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;
OwnedStdString allocatedString = null;
@ -173,12 +175,14 @@ namespace Dalamud.Game.Internal.Gui {
}
public void Print(string message) {
Log.Verbose("[CHATGUI PRINT]{0}", message);
PrintChat(new XivChatEntry {
MessageBytes = Encoding.UTF8.GetBytes(message)
});
}
public void PrintError(string message) {
Log.Verbose("[CHATGUI PRINT ERROR]{0}", message);
PrintChat(new XivChatEntry {
MessageBytes = Encoding.UTF8.GetBytes(message),
Type = XivChatType.Urgent

View file

@ -4,15 +4,21 @@ using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using Dalamud.Game.Command;
using ImGuiNET;
using Serilog;
namespace Dalamud.Interface
{
class DalamudLogWindow : IDisposable {
private readonly CommandManager commandManager;
private bool autoScroll = true;
private string logText = string.Empty;
public DalamudLogWindow() {
private string commandText = string.Empty;
public DalamudLogWindow(CommandManager commandManager) {
this.commandManager = commandManager;
SerilogEventSink.Instance.OnLogLine += Serilog_OnLogLine;
}
@ -59,6 +65,18 @@ namespace Dalamud.Interface
ImGui.SameLine();
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);
if (clear)