Revert changes to opening the crafting log

This commit is contained in:
Liza 2023-10-19 21:18:51 +02:00
parent 8a29673e0d
commit b94be6a77c
Signed by: liza
GPG Key ID: 7199F8D727D55F67
5 changed files with 18 additions and 68 deletions

View File

@ -45,6 +45,12 @@ partial class WorkshopPlugin
CurrentStage = Stage.TargetFabricationStation; CurrentStage = Stage.TargetFabricationStation;
} }
private void OpenCraftingLog()
{
if (SelectSelectString("craftlog", 0, s => s == _gameStrings.ViewCraftingLog))
CurrentStage = Stage.SelectCraftCategory;
}
private unsafe void SelectCraftCategory() private unsafe void SelectCraftCategory()
{ {
AtkUnitBase* addonCraftingLog = GetCompanyCraftingLogAddon(); AtkUnitBase* addonCraftingLog = GetCompanyCraftingLogAddon();

View File

@ -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);
}
}

View File

@ -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);
}
} }

View File

@ -80,7 +80,6 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin
HelpMessage = "Open UI" HelpMessage = "Open UI"
}); });
_addonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectString", SelectStringPostSetup);
_addonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesNoPostSetup); _addonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesNoPostSetup);
_addonLifecycle.RegisterListener(AddonEvent.PostSetup, "Request", RequestPostSetup); _addonLifecycle.RegisterListener(AddonEvent.PostSetup, "Request", RequestPostSetup);
_addonLifecycle.RegisterListener(AddonEvent.PostRefresh, "Request", RequestPostRefresh); _addonLifecycle.RegisterListener(AddonEvent.PostRefresh, "Request", RequestPostRefresh);
@ -170,7 +169,7 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin
break; break;
case Stage.OpenCraftingLog: case Stage.OpenCraftingLog:
// see SelectStringPostSetup OpenCraftingLog();
break; break;
case Stage.SelectCraftCategory: case Stage.SelectCraftCategory:
@ -215,7 +214,7 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin
break; break;
case Stage.ConfirmCollectProduct: case Stage.ConfirmCollectProduct:
// see SelectStringPostSetup // see SelectYesNoPostSetup
break; break;
case Stage.Stopped: case Stage.Stopped:
@ -250,7 +249,6 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin
_addonLifecycle.UnregisterListener(AddonEvent.PostRefresh, "Request", RequestPostRefresh); _addonLifecycle.UnregisterListener(AddonEvent.PostRefresh, "Request", RequestPostRefresh);
_addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "Request", RequestPostSetup); _addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "Request", RequestPostSetup);
_addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesNoPostSetup); _addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesNoPostSetup);
_addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "SelectString", SelectStringPostSetup);
_commandManager.RemoveHandler("/ws"); _commandManager.RemoveHandler("/ws");
_pluginInterface.UiBuilder.Draw -= _windowSystem.Draw; _pluginInterface.UiBuilder.Draw -= _windowSystem.Draw;
_pluginInterface.UiBuilder.OpenConfigUi -= _configWindow.Toggle; _pluginInterface.UiBuilder.OpenConfigUi -= _configWindow.Toggle;

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework> <TargetFramework>net7.0-windows</TargetFramework>
<Version>3.0</Version> <Version>3.1</Version>
<LangVersion>11.0</LangVersion> <LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>