Update settings window layout again

This commit is contained in:
Asriel Camora
2023-07-23 03:20:09 +04:00
parent ec4466123c
commit 1f39be40c8
4 changed files with 97 additions and 60 deletions
+3 -3
View File
@@ -42,11 +42,11 @@ public class Configuration : IPluginConfiguration
public bool OverrideUncraftability { get; set; } = true; public bool OverrideUncraftability { get; set; } = true;
public bool HideUnlearnedActions { get; set; } = true; public bool HideUnlearnedActions { get; set; } = true;
public List<Macro> Macros { get; set; } = new(); public List<Macro> Macros { get; set; } = new();
public bool ConditionRandomness { get; set; } = true;
public SolverConfig SimulatorSolverConfig { get; set; } = SolverConfig.SimulatorDefault; public SolverConfig SimulatorSolverConfig { get; set; } = SolverConfig.SimulatorDefault;
public SolverConfig SynthHelperSolverConfig { get; set; } = SolverConfig.SynthHelperDefault; public SolverConfig SynthHelperSolverConfig { get; set; } = SolverConfig.SynthHelperDefault;
public bool ConditionRandomness { get; set; } = true; public bool EnableSynthHelper { get; set; } = true;
public bool EnableSynthesisHelper { get; set; } = true; public int SynthHelperStepCount { get; set; } = 5;
public int SynthesisHelperStepCount { get; set; } = 5;
public Simulator.Simulator CreateSimulator(SimulationState state) => public Simulator.Simulator CreateSimulator(SimulationState state) =>
ConditionRandomness ? ConditionRandomness ?
+2 -2
View File
@@ -61,7 +61,7 @@ public sealed unsafe partial class Craft : Window, IDisposable
var totalWidth = 300f; var totalWidth = 300f;
var actionsPerRow = 5; var actionsPerRow = 5;
var actionSize = new Vector2((totalWidth / actionsPerRow) - (ImGui.GetStyle().ItemSpacing.X * ((actionsPerRow + 1f) / actionsPerRow))); var actionSize = new Vector2((totalWidth / actionsPerRow) - (ImGui.GetStyle().ItemSpacing.X * ((actionsPerRow - 1f) / actionsPerRow)));
ImGui.PushStyleColor(ImGuiCol.Button, Vector4.Zero); ImGui.PushStyleColor(ImGuiCol.Button, Vector4.Zero);
ImGui.PushStyleColor(ImGuiCol.ButtonActive, Vector4.Zero); ImGui.PushStyleColor(ImGuiCol.ButtonActive, Vector4.Zero);
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, Vector4.Zero); ImGui.PushStyleColor(ImGuiCol.ButtonHovered, Vector4.Zero);
@@ -140,7 +140,7 @@ public sealed unsafe partial class Craft : Window, IDisposable
public override bool DrawConditions() public override bool DrawConditions()
{ {
if (!Config.EnableSynthesisHelper) if (!Config.EnableSynthHelper)
return false; return false;
var ret = DrawConditionsInner(); var ret = DrawConditionsInner();
+2 -2
View File
@@ -79,7 +79,7 @@ public sealed unsafe partial class Craft : Window, IDisposable
} }
else else
{ {
if (SolverActions.Count >= Config.SynthesisHelperStepCount) if (SolverActions.Count >= Config.SynthHelperStepCount)
{ {
StopSolve(); StopSolve();
return; return;
@@ -89,7 +89,7 @@ public sealed unsafe partial class Craft : Window, IDisposable
var (_, state) = SolverSim.Execute(SolverLatestState, action); var (_, state) = SolverSim.Execute(SolverLatestState, action);
SolverActions.Add((action, tooltip, state)); SolverActions.Add((action, tooltip, state));
if (SolverActions.Count >= Config.SynthesisHelperStepCount) if (SolverActions.Count >= Config.SynthHelperStepCount)
StopSolve(); StopSolve();
} }
} }
+90 -53
View File
@@ -89,20 +89,8 @@ public class Settings : Window
if (ImGui.BeginTabBar("settingsTabBar")) if (ImGui.BeginTabBar("settingsTabBar"))
{ {
DrawTabGeneral(); DrawTabGeneral();
DrawTabSimulator();
var config = Config.SimulatorSolverConfig; DrawTabSynthHelper();
DrawTabSolver("Solver (Simulator)", ref config, out var isDirty);
if (isDirty)
Config.SimulatorSolverConfig = config;
if (Config.EnableSynthesisHelper)
{
config = Config.SynthHelperSolverConfig;
DrawTabSolver("Solver (Synthesis Helper)", ref config, out isDirty);
if (isDirty)
Config.SynthHelperSolverConfig = config;
}
DrawTabAbout(); DrawTabAbout();
ImGui.EndTabBar(); ImGui.EndTabBar();
@@ -117,7 +105,7 @@ public class Settings : Window
var isDirty = false; var isDirty = false;
DrawOption( DrawOption(
"Override uncraftability warning", "Override Uncraftability Warning",
"Allow simulation for crafts that otherwise wouldn't\n" + "Allow simulation for crafts that otherwise wouldn't\n" +
"be able to be crafted with your current gear", "be able to be crafted with your current gear",
Config.OverrideUncraftability, Config.OverrideUncraftability,
@@ -125,61 +113,37 @@ public class Settings : Window
ref isDirty ref isDirty
); );
DrawOption(
"Show only learned actions",
"Don't show crafting actions that haven't been\n" +
"learned yet with your current job on the simulator sidebar",
Config.HideUnlearnedActions,
v => Config.HideUnlearnedActions = v,
ref isDirty
);
DrawOption(
"Condition randomness",
"Allows the simulator condition to fluctuate randomly like a real craft.\n" +
"Turns off when generating a macro.",
Config.ConditionRandomness,
v => Config.ConditionRandomness = v,
ref isDirty
);
DrawOption( DrawOption(
"Enable Synthesis Helper", "Enable Synthesis Helper",
"Adds a helper next to your synthesis window to help solve for the best craft.\n" + "Adds a helper next to your synthesis window to help solve for the best craft.\n" +
"Extremely useful for expert recipes, where the condition can greatly affect\n" + "Extremely useful for expert recipes, where the condition can greatly affect\n" +
"which actions you take.", "which actions you take.",
Config.EnableSynthesisHelper, Config.EnableSynthHelper,
v => Config.EnableSynthesisHelper = v, v => Config.EnableSynthHelper = v,
ref isDirty ref isDirty
); );
ImGui.BeginDisabled(!Config.EnableSynthesisHelper);
DrawOption(
"Synthesis Helper Step Count",
"The number of future actions to solve for during an in-game craft.",
Config.SynthesisHelperStepCount,
v => Config.SynthesisHelperStepCount = v,
ref isDirty
);
ImGui.EndDisabled();
if (isDirty) if (isDirty)
Config.Save(); Config.Save();
ImGui.EndTabItem(); ImGui.EndTabItem();
} }
private static void DrawTabSolver(string label, ref SolverConfig configRef, out bool isDirty) private static void DrawSolverConfig(ref SolverConfig configRef, SolverConfig defaultConfig, out bool isDirty)
{ {
isDirty = false; isDirty = false;
if (!ImGui.BeginTabItem(label))
return;
var config = configRef; var config = configRef;
ImGuiUtils.BeginGroupPanel("General"); ImGuiUtils.BeginGroupPanel("General");
ImGui.SetNextItemWidth(200);
if (ImGui.Button("Reset to Default"))
{
config = defaultConfig;
isDirty = true;
}
ImGui.SetNextItemWidth(200); ImGui.SetNextItemWidth(200);
if (ImGui.BeginCombo("Algorithm", GetAlgorithmName(config.Algorithm))) if (ImGui.BeginCombo("Algorithm", GetAlgorithmName(config.Algorithm)))
{ {
@@ -247,6 +211,7 @@ public class Settings : Window
ref isDirty ref isDirty
); );
ImGui.BeginDisabled(config.Algorithm is not (SolverAlgorithm.OneshotForked or SolverAlgorithm.StepwiseForked or SolverAlgorithm.StepwiseFurcated));
DrawOption( DrawOption(
"Fork Count", "Fork Count",
"Split the number of iterations across different solvers. In general,\n" + "Split the number of iterations across different solvers. In general,\n" +
@@ -260,7 +225,9 @@ public class Settings : Window
v => config = config with { ForkCount = v }, v => config = config with { ForkCount = v },
ref isDirty ref isDirty
); );
ImGui.EndDisabled();
ImGui.BeginDisabled(config.Algorithm is not SolverAlgorithm.StepwiseFurcated);
DrawOption( DrawOption(
"Furcated Action Count", "Furcated Action Count",
"On every craft step, pick this many top solutions and use them as\n" + "On every craft step, pick this many top solutions and use them as\n" +
@@ -271,6 +238,7 @@ public class Settings : Window
v => config = config with { FurcatedActionCount = v }, v => config = config with { FurcatedActionCount = v },
ref isDirty ref isDirty
); );
ImGui.EndDisabled();
ImGuiUtils.EndGroupPanel(); ImGuiUtils.EndGroupPanel();
@@ -353,6 +321,7 @@ public class Settings : Window
ref isDirty ref isDirty
); );
ImGui.SetNextItemWidth(200);
if (ImGui.Button("Normalize Weights")) if (ImGui.Button("Normalize Weights"))
{ {
var total = config.ScoreProgressBonus + var total = config.ScoreProgressBonus +
@@ -371,20 +340,88 @@ public class Settings : Window
isDirty = true; isDirty = true;
} }
if (ImGui.IsItemHovered()) if (ImGui.IsItemHovered())
ImGui.SetTooltip("Normalize all weights to add up to 1"); ImGui.SetTooltip("Normalize all weights to sum up to 1");
ImGuiUtils.EndGroupPanel(); ImGuiUtils.EndGroupPanel();
if (ImGui.Button("Reset")) if (isDirty)
configRef = config;
}
private static void DrawTabSimulator()
{
if (!ImGui.BeginTabItem("Simulator"))
return;
var isDirty = false;
DrawOption(
"Show Only Learned Actions",
"Don't show crafting actions that haven't been\n" +
"learned yet with your current job on the simulator sidebar",
Config.HideUnlearnedActions,
v => Config.HideUnlearnedActions = v,
ref isDirty
);
DrawOption(
"Condition Randomness",
"Allows the simulator condition to fluctuate randomly like a real craft.\n" +
"Turns off when generating a macro.",
Config.ConditionRandomness,
v => Config.ConditionRandomness = v,
ref isDirty
);
ImGuiHelpers.ScaledDummy(5);
ImGui.Separator();
ImGuiHelpers.ScaledDummy(5);
var solverConfig = Config.SimulatorSolverConfig;
DrawSolverConfig(ref solverConfig, SolverConfig.SimulatorDefault, out var isSolverDirty);
if (isSolverDirty)
{ {
config = new(); Config.SimulatorSolverConfig = solverConfig;
isDirty = true; isDirty = true;
} }
if (isDirty)
Config.Save();
ImGui.EndTabItem(); ImGui.EndTabItem();
}
private static void DrawTabSynthHelper()
{
if (!ImGui.BeginTabItem("Synthesis Helper"))
return;
var isDirty = false;
DrawOption(
"Step Count",
"The number of future actions to solve for during an in-game craft.",
Config.SynthHelperStepCount,
v => Config.SynthHelperStepCount = v,
ref isDirty
);
ImGuiHelpers.ScaledDummy(5);
ImGui.Separator();
ImGuiHelpers.ScaledDummy(5);
var solverConfig = Config.SynthHelperSolverConfig;
DrawSolverConfig(ref solverConfig, SolverConfig.SynthHelperDefault, out var isSolverDirty);
if (isSolverDirty)
{
Config.SynthHelperSolverConfig = solverConfig;
isDirty = true;
}
if (isDirty) if (isDirty)
configRef = config; Config.Save();
ImGui.EndTabItem();
} }
private static void DrawTabAbout() private static void DrawTabAbout()