From 236da6c94772c28b026880287929b862e8c43e02 Mon Sep 17 00:00:00 2001 From: Asriel Camora Date: Wed, 19 Jun 2024 14:34:51 -0700 Subject: [PATCH] Add ability to only simulate first synth helper action --- Craftimizer/Configuration.cs | 1 + Craftimizer/Utils/SimulatedMacro.cs | 5 +++-- Craftimizer/Windows/Settings.cs | 14 ++++++++++++-- Craftimizer/Windows/SynthHelper.cs | 6 +++--- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Craftimizer/Configuration.cs b/Craftimizer/Configuration.cs index 2add81a..cdbc00f 100644 --- a/Craftimizer/Configuration.cs +++ b/Craftimizer/Configuration.cs @@ -101,6 +101,7 @@ public class Configuration : IPluginConfiguration public bool ShowCommunityMacros { get; set; } = true; public bool SearchCommunityMacroAutomatically { get; set; } public int SynthHelperStepCount { get; set; } = 5; + public bool SynthHelperDisplayOnlyFirstStep { get; set; } public bool PinSynthHelperToWindow { get; set; } = true; public bool PinRecipeNoteToWindow { get; set; } = true; diff --git a/Craftimizer/Utils/SimulatedMacro.cs b/Craftimizer/Utils/SimulatedMacro.cs index 7a32d19..42ec62a 100644 --- a/Craftimizer/Utils/SimulatedMacro.cs +++ b/Craftimizer/Utils/SimulatedMacro.cs @@ -141,6 +141,7 @@ internal sealed class SimulatedMacro private object QueueLock { get; } = new(); private List QueuedSteps { get; set; } = []; + public SimulationState FirstState => Macro.Count > 0 ? Macro[0].State : InitialState; public SimulationState State => Macro.Count > 0 ? Macro[^1].State : InitialState; public IEnumerable Actions => Macro.Select(m => m.Action); @@ -155,9 +156,9 @@ internal sealed class SimulatedMacro } } - public Reliablity GetReliability(RecipeData recipeData) => + public Reliablity GetReliability(RecipeData recipeData, Index? idx = null) => Macro.Count > 0 ? - Macro[^1].GetReliability(InitialState, Macro.Select(m => m.Action), recipeData) : + Macro[idx ?? ^1].GetReliability(InitialState, Macro.Select(m => m.Action), recipeData) : new(InitialState, Array.Empty(), 0, recipeData); private void TryRecalculateFrom(int index) diff --git a/Craftimizer/Windows/Settings.cs b/Craftimizer/Windows/Settings.cs index 1edefd1..db488be 100644 --- a/Craftimizer/Windows/Settings.cs +++ b/Craftimizer/Windows/Settings.cs @@ -166,9 +166,9 @@ public sealed class Settings : Window, IDisposable { DrawTabGeneral(); DrawTabRecipeNote(); - DrawTabMacroEditor(); if (Config.EnableSynthHelper) DrawTabSynthHelper(); + DrawTabMacroEditor(); DrawTabAbout(); ImGui.EndTabBar(); @@ -885,9 +885,19 @@ public sealed class Settings : Window, IDisposable ref isDirty ); + DrawOption( + "Simulate Only First Step", + "Only the first step is simulated by default. You can still " + + "hover over the other steps to view their outcomes, but the " + + "reliability trials (when hovering over the macro stats) are hidden.", + Config.SynthHelperDisplayOnlyFirstStep, + v => Config.SynthHelperDisplayOnlyFirstStep = v, + ref isDirty + ); + DrawOption( "Step Count", - "The number of future actions to solve for during an in-game craft.", + "The minimum number of future steps to solve for during an in-game craft.", Config.SynthHelperStepCount, 1, 100, diff --git a/Craftimizer/Windows/SynthHelper.cs b/Craftimizer/Windows/SynthHelper.cs index 3eb70b7..704f7b0 100644 --- a/Craftimizer/Windows/SynthHelper.cs +++ b/Craftimizer/Windows/SynthHelper.cs @@ -218,7 +218,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable } private SimulationState? hoveredState; - private SimulationState DisplayedState => hoveredState ?? Macro.State; + private SimulationState DisplayedState => hoveredState ?? (Service.Configuration.SynthHelperDisplayOnlyFirstStep ? Macro.FirstState : Macro.State); private void DrawMacro() { var spacing = ImGui.GetStyle().ItemSpacing.X; @@ -278,7 +278,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable { ImGuiUtils.Tooltip($"{action.GetName(RecipeData!.ClassJob)}\n" + $"{actionBase.GetTooltip(CreateSim(lastState), true)}" + - $"{(canExecute && i == 0 ? "Click to Execute" : string.Empty)}"); + $"{(canExecute && i == 0 ? "Click or run /craftaction to Execute" : string.Empty)}"); hoveredState = state; } lastState = state; @@ -334,7 +334,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable } } - var reliability = Macro.GetReliability(RecipeData!); + var reliability = Macro.GetReliability(RecipeData!, Service.Configuration.SynthHelperDisplayOnlyFirstStep ? 0 : ^1); { var mainBars = new List() {