feat: add some debug data collection buttons

This commit is contained in:
Anna 2021-03-03 18:05:43 -05:00
parent 51ccd9ea0f
commit c272dc5f85
3 changed files with 79 additions and 0 deletions

View File

@ -8,6 +8,10 @@ using System.Collections.Generic;
using System.Linq;
using Dalamud.Data;
using Lumina.Excel.GeneratedSheets;
#if DEBUG
using System.Text;
using NoSoliciting.Ml;
#endif
namespace NoSoliciting {
public class Message {
@ -74,6 +78,25 @@ namespace NoSoliciting {
TypeNameHandling = TypeNameHandling.None,
});
}
#if DEBUG
public StringBuilder ToCsv(StringBuilder? builder = null) {
builder ??= new StringBuilder();
var category = MessageCategoryExt.FromName(this.FilterReason) ?? MessageCategory.Normal;
builder.Append(category.ToModelName());
builder.Append(',');
builder.Append((int) this.ChatType);
builder.Append(",\"");
builder.Append(this.Content.TextValue
.Replace("\"", "\"\"")
.Replace("\r", " "));
builder.Append('"');
return builder;
}
#endif
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1028:Enum Storage should be Int32")]

View File

@ -27,6 +27,36 @@ namespace NoSoliciting.Ml {
_ => null,
};
#if DEBUG
public static string ToModelName(this MessageCategory category) => category switch {
MessageCategory.Trade => "TRADE",
MessageCategory.FreeCompany => "FC",
MessageCategory.Normal => "NORMAL",
MessageCategory.Phishing => "PHISH",
MessageCategory.RmtContent => "RMT_C",
MessageCategory.RmtGil => "RMT_G",
MessageCategory.Roleplaying => "RP",
MessageCategory.Static => "STATIC",
MessageCategory.Community => "COMMUNITY",
_ => throw new ArgumentException("Invalid category", nameof(category)),
};
public static MessageCategory? FromName(string? category) => category switch {
"Trade ads" => MessageCategory.Trade,
"Free Company ads" => MessageCategory.FreeCompany,
"Normal messages" => MessageCategory.Normal,
"Phishing messages" => MessageCategory.Phishing,
"RMT (content)" => MessageCategory.RmtContent,
"RMT (gil)" => MessageCategory.RmtGil,
"Roleplaying ads" => MessageCategory.Roleplaying,
"Static recruitment" => MessageCategory.Static,
"Community ads" => MessageCategory.Community,
_ => null,
};
#endif
public static string Name(this MessageCategory category) => category switch {
MessageCategory.Trade => "Trade ads",
MessageCategory.FreeCompany => "Free Company ads",

View File

@ -9,6 +9,9 @@ using System.Globalization;
using System.Linq;
using System.Net;
using System.Numerics;
#if DEBUG
using System.Text;
#endif
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using NoSoliciting.Ml;
@ -529,6 +532,22 @@ namespace NoSoliciting {
}
if (ImGui.BeginTabItem("Party Finder##pf-report")) {
#if DEBUG
if (ImGui.Button("Copy CSV")) {
var builder = new StringBuilder();
foreach (var message in this.Plugin.PartyFinderHistory) {
if (message.FilterReason == null) {
continue;
}
message.ToCsv(builder).Append('\n');
}
ImGui.SetClipboardText(builder.ToString());
}
#endif
float[] maxSizes = {0f, 0f, 0f};
if (ImGui.BeginChild("##pf-messages", new Vector2(-1, -1))) {
@ -643,6 +662,13 @@ namespace NoSoliciting {
ImGui.SetClipboardText(message.Content.TextValue);
}
#if DEBUG
ImGui.SameLine();
if (ImGui.Button("Copy CSV")) {
ImGui.SetClipboardText(message.ToCsv().ToString());
}
#endif
ImGui.SameLine();
EndPopup: