Add ability to only simulate first synth helper action

This commit is contained in:
Asriel Camora
2024-06-19 14:34:51 -07:00
parent 7ad073a7a3
commit 236da6c947
4 changed files with 19 additions and 7 deletions
+1
View File
@@ -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;
+3 -2
View File
@@ -141,6 +141,7 @@ internal sealed class SimulatedMacro
private object QueueLock { get; } = new();
private List<Step> 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<ActionType> 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<ActionType>(), 0, recipeData);
private void TryRecalculateFrom(int index)
+12 -2
View File
@@ -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,
+3 -3
View File
@@ -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<DynamicBars.BarData>()
{