Implement synthhelper settings
This commit is contained in:
@@ -192,12 +192,13 @@ internal sealed class SimulatedMacro
|
||||
state = Macro[i].Recalculate(sim, state);
|
||||
}
|
||||
|
||||
public void Enqueue(ActionType action)
|
||||
public int Enqueue(ActionType action)
|
||||
{
|
||||
lock (QueueLock)
|
||||
{
|
||||
var lastState = QueuedSteps.Count > 0 ? QueuedSteps[^1].State : State;
|
||||
QueuedSteps.Add(new(action, CreateSim(), lastState, out _));
|
||||
return QueuedSteps.Count + Macro.Count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1554,7 +1554,7 @@ public sealed class MacroEditor : Window, IDisposable
|
||||
using (SolverObject = new Solver.Solver(config, state) { Token = token })
|
||||
{
|
||||
SolverObject.OnLog += Log.Debug;
|
||||
SolverObject.OnNewAction += Macro.Enqueue;
|
||||
SolverObject.OnNewAction += a => Macro.Enqueue(a);
|
||||
SolverObject.Start();
|
||||
_ = SolverObject.GetTask().GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ public sealed class Settings : Window, IDisposable
|
||||
{
|
||||
DrawTabGeneral();
|
||||
DrawTabSimulator();
|
||||
//if (Config.EnableSynthHelper)
|
||||
// DrawTabSynthHelper();
|
||||
if (Config.EnableSynthHelper)
|
||||
DrawTabSynthHelper();
|
||||
DrawTabAbout();
|
||||
|
||||
ImGui.EndTabBar();
|
||||
@@ -173,10 +173,6 @@ public sealed class Settings : Window, IDisposable
|
||||
|
||||
var isDirty = false;
|
||||
|
||||
|
||||
using (var g = ImRaii.Group())
|
||||
{
|
||||
using var d = ImRaii.Disabled();
|
||||
DrawOption(
|
||||
"Enable Synthesis Helper",
|
||||
"Adds a helper next to your synthesis window to help solve for the best craft.\n" +
|
||||
@@ -186,9 +182,6 @@ public sealed class Settings : Window, IDisposable
|
||||
v => Config.EnableSynthHelper = v,
|
||||
ref isDirty
|
||||
);
|
||||
}
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Disabled temporarily for testing");
|
||||
|
||||
DrawOption(
|
||||
"Show Only One Macro Stat in Crafting Log",
|
||||
|
||||
@@ -153,7 +153,6 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
var pos = new Vector2(unit.X, unit.Y);
|
||||
var size = new Vector2(unit.WindowNode->AtkResNode.Width, unit.WindowNode->AtkResNode.Height) * scale;
|
||||
|
||||
var node = unit.GetNodeById(46);
|
||||
var offset = 5;
|
||||
|
||||
Position = ImGuiHelpers.MainViewport.Pos + pos + new Vector2(size.X, offset * scale);
|
||||
@@ -206,7 +205,6 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
}
|
||||
if (ImGui.ImageButton(action.GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize), default, Vector2.One, 0, default, failedAction ? new(1, 1, 1, ImGui.GetStyle().DisabledAlpha) : Vector4.One))
|
||||
{
|
||||
Log.Debug($"Clicked {action.GetName(RecipeData.ClassJob)} [{i}]");
|
||||
if (i == 0)
|
||||
Chat.SendMessage($"/ac \"{action.GetName(RecipeData.ClassJob)}\"");
|
||||
}
|
||||
@@ -220,7 +218,8 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
lastState = state;
|
||||
}
|
||||
|
||||
for (var i = 0; i < 2; ++i)
|
||||
var rows = (int)Math.Max(1, MathF.Ceiling(Service.Configuration.SynthHelperStepCount / itemsPerRow));
|
||||
for (var i = 0; i < rows; ++i)
|
||||
{
|
||||
if (Macro.Count <= i * itemsPerRow)
|
||||
ImGui.Dummy(new(0, imageSize));
|
||||
@@ -524,7 +523,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
using (HelperTaskObject = new Solver.Solver(config, state) { Token = token })
|
||||
{
|
||||
HelperTaskObject.OnLog += Log.Debug;
|
||||
HelperTaskObject.OnNewAction += Macro.Enqueue;
|
||||
HelperTaskObject.OnNewAction += EnqueueAction;
|
||||
HelperTaskObject.Start();
|
||||
_ = HelperTaskObject.GetTask().GetAwaiter().GetResult();
|
||||
}
|
||||
@@ -532,6 +531,12 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
token.ThrowIfCancellationRequested();
|
||||
}
|
||||
|
||||
private void EnqueueAction(ActionType action)
|
||||
{
|
||||
if (Macro.Enqueue(action) >= Service.Configuration.SynthHelperStepCount)
|
||||
HelperTaskTokenSource?.Cancel();
|
||||
}
|
||||
|
||||
private static Sim CreateSim(in SimulationState state) =>
|
||||
Service.Configuration.ConditionRandomness ? new Sim() { State = state } : new SimNoRandom() { State = state };
|
||||
|
||||
|
||||
@@ -64,9 +64,6 @@ public readonly record struct SolverConfig
|
||||
|
||||
public static readonly SolverConfig SynthHelperDefault = new SolverConfig() with
|
||||
{
|
||||
Iterations = 300000,
|
||||
ForkCount = Environment.ProcessorCount - 1, // Keep one for the game thread
|
||||
FurcatedActionCount = Environment.ProcessorCount / 2,
|
||||
Algorithm = SolverAlgorithm.StepwiseForked
|
||||
// Add properties if necessary
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user