From b94be6a77cd492936582d81fafeb6bdbf8346875 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Thu, 19 Oct 2023 21:18:51 +0200 Subject: [PATCH] Revert changes to opening the crafting log --- Workshoppa/WorkshopPlugin.CraftingLog.cs | 6 +++ Workshoppa/WorkshopPlugin.SelectString.cs | 63 ----------------------- Workshoppa/WorkshopPlugin.SelectYesNo.cs | 9 ++++ Workshoppa/WorkshopPlugin.cs | 6 +-- Workshoppa/Workshoppa.csproj | 2 +- 5 files changed, 18 insertions(+), 68 deletions(-) delete mode 100644 Workshoppa/WorkshopPlugin.SelectString.cs diff --git a/Workshoppa/WorkshopPlugin.CraftingLog.cs b/Workshoppa/WorkshopPlugin.CraftingLog.cs index 67b59ff..bad3a43 100644 --- a/Workshoppa/WorkshopPlugin.CraftingLog.cs +++ b/Workshoppa/WorkshopPlugin.CraftingLog.cs @@ -45,6 +45,12 @@ partial class WorkshopPlugin CurrentStage = Stage.TargetFabricationStation; } + private void OpenCraftingLog() + { + if (SelectSelectString("craftlog", 0, s => s == _gameStrings.ViewCraftingLog)) + CurrentStage = Stage.SelectCraftCategory; + } + private unsafe void SelectCraftCategory() { AtkUnitBase* addonCraftingLog = GetCompanyCraftingLogAddon(); diff --git a/Workshoppa/WorkshopPlugin.SelectString.cs b/Workshoppa/WorkshopPlugin.SelectString.cs deleted file mode 100644 index 462521f..0000000 --- a/Workshoppa/WorkshopPlugin.SelectString.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using Dalamud.Game.Addon.Lifecycle; -using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; -using Dalamud.Memory; -using FFXIVClientStructs.FFXIV.Client.UI; - -namespace Workshoppa; - -partial class WorkshopPlugin -{ - private unsafe void SelectStringPostSetup(AddonEvent type, AddonArgs args) - { - _pluginLog.Verbose("SelectString post-setup"); - - string desiredText; - Action followUp; - if (CurrentStage == Stage.OpenCraftingLog) - { - desiredText = _gameStrings.ViewCraftingLog; - followUp = OpenCraftingLogFollowUp; - } - else - return; - - _pluginLog.Verbose($"Looking for '{desiredText}' in prompt"); - AddonSelectString* addonSelectString = (AddonSelectString*)args.Addon; - int entries = addonSelectString->PopupMenu.PopupMenu.EntryCount; - - for (int i = 0; i < entries; ++i) - { - var textPointer = addonSelectString->PopupMenu.PopupMenu.EntryNames[i]; - if (textPointer == null) - continue; - - var text = MemoryHelper.ReadSeStringNullTerminated((nint)textPointer).ToString(); - _pluginLog.Verbose($" Choice {i} → {text}"); - if (text == desiredText) - { - _pluginLog.Information($"Selecting choice {i} ({text})"); - addonSelectString->AtkUnitBase.FireCallbackInt(i); - - followUp(); - return; - } - } - - _pluginLog.Verbose($"Text '{desiredText}' was not found in prompt."); - } - - private void OpenCraftingLogFollowUp() - { - CurrentStage = Stage.SelectCraftCategory; - } - - private void ConfirmCollectProductFollowUp() - { - _configuration.CurrentlyCraftedItem = null; - _pluginInterface.SavePluginConfig(_configuration); - - CurrentStage = Stage.TakeItemFromQueue; - _continueAt = DateTime.Now.AddSeconds(0.5); - } -} diff --git a/Workshoppa/WorkshopPlugin.SelectYesNo.cs b/Workshoppa/WorkshopPlugin.SelectYesNo.cs index c12a420..e6a907c 100644 --- a/Workshoppa/WorkshopPlugin.SelectYesNo.cs +++ b/Workshoppa/WorkshopPlugin.SelectYesNo.cs @@ -53,4 +53,13 @@ partial class WorkshopPlugin } } } + + private void ConfirmCollectProductFollowUp() + { + _configuration.CurrentlyCraftedItem = null; + _pluginInterface.SavePluginConfig(_configuration); + + CurrentStage = Stage.TakeItemFromQueue; + _continueAt = DateTime.Now.AddSeconds(0.5); + } } diff --git a/Workshoppa/WorkshopPlugin.cs b/Workshoppa/WorkshopPlugin.cs index 340c913..7ffdbec 100644 --- a/Workshoppa/WorkshopPlugin.cs +++ b/Workshoppa/WorkshopPlugin.cs @@ -80,7 +80,6 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin HelpMessage = "Open UI" }); - _addonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectString", SelectStringPostSetup); _addonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesNoPostSetup); _addonLifecycle.RegisterListener(AddonEvent.PostSetup, "Request", RequestPostSetup); _addonLifecycle.RegisterListener(AddonEvent.PostRefresh, "Request", RequestPostRefresh); @@ -170,7 +169,7 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin break; case Stage.OpenCraftingLog: - // see SelectStringPostSetup + OpenCraftingLog(); break; case Stage.SelectCraftCategory: @@ -215,7 +214,7 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin break; case Stage.ConfirmCollectProduct: - // see SelectStringPostSetup + // see SelectYesNoPostSetup break; case Stage.Stopped: @@ -250,7 +249,6 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin _addonLifecycle.UnregisterListener(AddonEvent.PostRefresh, "Request", RequestPostRefresh); _addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "Request", RequestPostSetup); _addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesNoPostSetup); - _addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "SelectString", SelectStringPostSetup); _commandManager.RemoveHandler("/ws"); _pluginInterface.UiBuilder.Draw -= _windowSystem.Draw; _pluginInterface.UiBuilder.OpenConfigUi -= _configWindow.Toggle; diff --git a/Workshoppa/Workshoppa.csproj b/Workshoppa/Workshoppa.csproj index cf1b526..d2bff72 100644 --- a/Workshoppa/Workshoppa.csproj +++ b/Workshoppa/Workshoppa.csproj @@ -1,7 +1,7 @@ net7.0-windows - 3.0 + 3.1 11.0 enable true