diff --git a/NoSoliciting.Tests/DefinitionsTests/Global.FreeCompany.cs b/NoSoliciting.Tests/DefinitionsTests/Global.FreeCompany.cs index 771ffdd..d72bcfa 100644 --- a/NoSoliciting.Tests/DefinitionsTests/Global.FreeCompany.cs +++ b/NoSoliciting.Tests/DefinitionsTests/Global.FreeCompany.cs @@ -6,7 +6,7 @@ namespace NoSoliciting.Tests.DefinitionsTests.Global { this.Def = fixture.defs.Global["free_company"]; } - public static object[][] DataPositives => DefUtils.DataFromMessages(new TestMessage[] { + public static object[][] DataPositives => DefUtils.DataFromMessages(new[] { // chat new TestMessage(ChatType.Shout, "PhD: Phantasy Degree is a Rank 30 FC with a Large plot, 24/7 FC/EXP Buffs. There are NO Level Restrictions to join, we take new and old players. Ask to join or apply."), new TestMessage(ChatType.Shout, "Wind up fc is a small company looking for new/seasoned adventures to join! If you need help with the msq/clear the latest raid well do our best to help! Send a tell/app to join"), @@ -40,7 +40,7 @@ namespace NoSoliciting.Tests.DefinitionsTests.Global { new TestMessage("Sol Verinia FC is recruiting! We accept all levels, looking for active members. We look forward to you becoming one of the spire."), }); - public static object[][] DataNegatives => DefUtils.DataFromMessages(new TestMessage[] { + public static object[][] DataNegatives => DefUtils.DataFromMessages(new[] { new TestMessage("Static recruit. Not hardcore. Discord needed. tues-thurs 11:30pmEST. Join if you have questions."), new TestMessage("LF new LGBT friends to chill with in Eorzea! Join up, let's chat, and hang out. I have discord as well :)"), new TestMessage("(Bored)Lovely Au Ra woman [Famfrit] available to be RP girlfriend/wife for long term or short term. Send tell if in need."), diff --git a/NoSoliciting.Tests/DefinitionsTests/PartyFinder.RMT.cs b/NoSoliciting.Tests/DefinitionsTests/PartyFinder.RMT.cs index 5e2ff1a..0575b27 100644 --- a/NoSoliciting.Tests/DefinitionsTests/PartyFinder.RMT.cs +++ b/NoSoliciting.Tests/DefinitionsTests/PartyFinder.RMT.cs @@ -6,7 +6,7 @@ namespace NoSoliciting.Tests.DefinitionsTests.PartyFinder { this.Def = fixture.defs.PartyFinder["rmt"]; } - public static object[][] DataPositives => DefUtils.DataFromStrings(new string[] { + public static object[][] DataPositives => DefUtils.DataFromStrings(new[] { "「Best Prices」《 Shiva Unreal ★ Warrior of Light ★ Ultimates ★ Eden's Verse i500/i505", "「 MINMAXØ 」 SALES ≪ ❶ Savage 一 ❷ Ultimates 一 ❸ Mounts Etc. ≫ World #1 teams, instant delivery. Discord → azrael#6447", "「」™️ Found it Cheaper? We will beat it! $elling EdenVerse, BLU, Ultimates, Primals, Discord: Valentine#5943", @@ -22,7 +22,7 @@ namespace NoSoliciting.Tests.DefinitionsTests.PartyFinder { "☀5.4 Pre-orders☀Savage☀Trials☀Ultimates☀BLU 「DISCORD」⇒ Meliora#2500", }); - public static object[][] DataNegatives => DefUtils.DataFromStrings(new string[] { + public static object[][] DataNegatives => DefUtils.DataFromStrings(new[] { "Doing Art commission of your charactet with good price! more info add me on discord: d0uglaz#7409 ♥", "Selling HQ 490 DoH/DoL sets, just in time for the Ishgard restoration project. Cheaper than MB, Whipser or join for info.", "Looking to sell medium odder otter walls(2mil) join or tell.", diff --git a/NoSoliciting/FilterUtil.cs b/NoSoliciting/FilterUtil.cs index 10825da..51f254c 100644 --- a/NoSoliciting/FilterUtil.cs +++ b/NoSoliciting/FilterUtil.cs @@ -15,7 +15,6 @@ namespace NoSoliciting { ['\ue057'] = "3", ['\ue058'] = "4", ['\ue059'] = "5", - ['\ue099'] = "10", ['\ue09a'] = "11", ['\ue09b'] = "12", @@ -93,9 +92,10 @@ namespace NoSoliciting { continue; } - AppendNormal: + AppendNormal: builder.Append(c); } + input = builder.ToString(); // NFKD unicode normalisation @@ -128,27 +128,53 @@ namespace NoSoliciting { if (cat.MainHand != 0) { return Slot.MainHand; - } else if (cat.Head != 0) { + } + + if (cat.Head != 0) { return Slot.Head; - } else if (cat.Body != 0) { + } + + if (cat.Body != 0) { return Slot.Chest; - } else if (cat.Gloves != 0) { + } + + if (cat.Gloves != 0) { return Slot.Hands; - } else if (cat.Waist != 0) { + } + + if (cat.Waist != 0) { return Slot.Waist; - } else if (cat.Legs != 0) { + } + + if (cat.Legs != 0) { return Slot.Legs; - } else if (cat.Feet != 0) { + } + + if (cat.Feet != 0) { return Slot.Feet; - } else if (cat.OffHand != 0) { + } + + if (cat.OffHand != 0) { return Slot.OffHand; - } else if (cat.Ears != 0) { + } + + if (cat.Ears != 0) { return Slot.Earrings; - } else if (cat.Neck != 0) { + } + + if (cat.Neck != 0) { return Slot.Neck; - } else if (cat.FingerL != 0) { + } + + if (cat.Wrists != 0) { + return Slot.Wrist; + } + + if (cat.FingerL != 0) { return Slot.RingL; - } else if (cat.FingerR != 0) { + } + + if (cat.FingerR != 0) { return Slot.RingR; } diff --git a/NoSoliciting/NoSoliciting.csproj b/NoSoliciting/NoSoliciting.csproj index f8b5eef..65bfe97 100644 --- a/NoSoliciting/NoSoliciting.csproj +++ b/NoSoliciting/NoSoliciting.csproj @@ -55,9 +55,9 @@ False $(AppData)\XIVLauncher\addon\Hooks\Lumina.dll - + False - $(AppData)\XIVLauncher\addon\Hooks\Lumina.Generated.dll + $(AppData)\XIVLauncher\addon\Hooks\Lumina.Excel.dll False diff --git a/NoSoliciting/Plugin.cs b/NoSoliciting/Plugin.cs index 2193b0f..18f9d22 100644 --- a/NoSoliciting/Plugin.cs +++ b/NoSoliciting/Plugin.cs @@ -18,10 +18,10 @@ namespace NoSoliciting { public Definitions Definitions { get; private set; } private readonly List messageHistory = new List(); - public IReadOnlyCollection MessageHistory { get => this.messageHistory; } + public IEnumerable MessageHistory { get => this.messageHistory; } private readonly List partyFinderHistory = new List(); - public IReadOnlyCollection PartyFinderHistory { get => this.partyFinderHistory; } + public IEnumerable PartyFinderHistory { get => this.partyFinderHistory; } public void Initialize(DalamudPluginInterface pluginInterface) { this.Interface = pluginInterface ?? throw new ArgumentNullException(nameof(pluginInterface), "DalamudPluginInterface cannot be null"); diff --git a/NoSoliciting/PluginUI.cs b/NoSoliciting/PluginUI.cs index 79dfbe0..8501697 100644 --- a/NoSoliciting/PluginUI.cs +++ b/NoSoliciting/PluginUI.cs @@ -15,7 +15,7 @@ using System.Threading.Tasks; namespace NoSoliciting { public class PluginUI { private readonly Plugin plugin; - private bool resizeWindow = false; + private bool resizeWindow; private ReportStatus lastReportStatus = ReportStatus.None; private bool _showSettings; @@ -175,11 +175,13 @@ namespace NoSoliciting { substrings[i] = input; } } + ImGui.SameLine(); ImGui.PushFont(UiBuilder.IconFont); if (ImGui.Button($"{FontAwesomeIcon.Trash.ToIconString()}##{name}-substring-{i}-remove")) { substrings.RemoveAt(i); } + ImGui.PopFont(); } @@ -187,6 +189,7 @@ namespace NoSoliciting { if (ImGui.Button($"{FontAwesomeIcon.Plus.ToIconString()}##{name}-substring-add")) { substrings.Add(""); } + ImGui.PopFont(); ImGui.EndChild(); @@ -205,15 +208,18 @@ namespace NoSoliciting { } catch (ArgumentException) { valid = false; } + if (valid && input.Length != 0) { regexes[i] = input; } } + ImGui.SameLine(); ImGui.PushFont(UiBuilder.IconFont); if (ImGui.Button($"{FontAwesomeIcon.Trash.ToIconString()}##{name}-regex-{i}-remove")) { regexes.RemoveAt(i); } + ImGui.PopFont(); } @@ -221,6 +227,7 @@ namespace NoSoliciting { if (ImGui.Button($"{FontAwesomeIcon.Plus.ToIconString()}##{name}-regex-add")) { regexes.Add(""); } + ImGui.PopFont(); ImGui.EndChild(); @@ -270,7 +277,7 @@ namespace NoSoliciting { if (ImGui.BeginTabBar("##report-tabs")) { if (ImGui.BeginTabItem("Chat##chat-report")) { - float[] maxSizes = { 0f, 0f, 0f, 0f }; + float[] maxSizes = {0f, 0f, 0f, 0f}; if (ImGui.BeginChild("##chat-messages", new Vector2(-1, -1))) { ImGui.Columns(5); @@ -299,9 +306,11 @@ namespace NoSoliciting { this.SetUpReportModal(message); } + for (int idx = 0; idx < maxSizes.Length; idx++) { ImGui.SetColumnWidth(idx, maxSizes[idx] + ImGui.GetStyle().ItemSpacing.X * 2); } + ImGui.Columns(1); ImGui.EndChild(); @@ -311,7 +320,7 @@ namespace NoSoliciting { } if (ImGui.BeginTabItem("Party Finder##pf-report")) { - float[] maxSizes = { 0f, 0f, 0f }; + float[] maxSizes = {0f, 0f, 0f}; if (ImGui.BeginChild("##pf-messages", new Vector2(-1, -1))) { ImGui.Columns(4); @@ -340,13 +349,16 @@ namespace NoSoliciting { this.SetUpReportModal(message); } + for (int idx = 0; idx < maxSizes.Length; idx++) { ImGui.SetColumnWidth(idx, maxSizes[idx] + ImGui.GetStyle().ItemSpacing.X * 2); } + ImGui.Columns(1); ImGui.EndChild(); } + ImGui.EndTabItem(); } @@ -388,9 +400,8 @@ namespace NoSoliciting { using WebClient client = new WebClient(); this.lastReportStatus = ReportStatus.InProgress; resp = await client.UploadStringTaskAsync(this.plugin.Definitions.ReportUrl, message.ToJson()).ConfigureAwait(true); -#pragma warning disable CA1031 // Do not catch general exception types } catch (Exception) { } -#pragma warning restore CA1031 // Do not catch general exception types + this.lastReportStatus = resp == "{\"message\":\"ok\"}" ? ReportStatus.Successful : ReportStatus.Failure; PluginLog.Log($"Report sent. Response: {resp}"); }); @@ -426,14 +437,17 @@ namespace NoSoliciting { if (last) { ImGui.PushTextWrapPos(); } + ImGui.TextUnformatted(arg); if (last) { ImGui.PopTextWrapPos(); } + clicked = clicked || ImGui.IsItemClicked(); if (!last) { maxSizes[i] = Math.Max(maxSizes[i], ImGui.CalcTextSize(arg).X); } + ImGui.NextColumn(); }