Update settings window with tab bar/notebook layout, add about page
This commit is contained in:
@@ -25,6 +25,10 @@
|
|||||||
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
|
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
|
||||||
<DalamudLibPath>$(DALAMUD_HOME)/</DalamudLibPath>
|
<DalamudLibPath>$(DALAMUD_HOME)/</DalamudLibPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="../icon.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DalamudPackager" Version="2.1.11" />
|
<PackageReference Include="DalamudPackager" Version="2.1.11" />
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ using Craftimizer.Utils;
|
|||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
|
using ImGuiScene;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
using System.Reflection;
|
||||||
using ClassJob = Craftimizer.Simulator.ClassJob;
|
using ClassJob = Craftimizer.Simulator.ClassJob;
|
||||||
|
|
||||||
namespace Craftimizer.Plugin;
|
namespace Craftimizer.Plugin;
|
||||||
@@ -12,6 +14,10 @@ namespace Craftimizer.Plugin;
|
|||||||
public sealed class Plugin : IDalamudPlugin
|
public sealed class Plugin : IDalamudPlugin
|
||||||
{
|
{
|
||||||
public string Name => "Craftimizer";
|
public string Name => "Craftimizer";
|
||||||
|
public string Version { get; }
|
||||||
|
public string Author { get; }
|
||||||
|
public string Configuration { get; }
|
||||||
|
public TextureWrap Icon { get; }
|
||||||
|
|
||||||
public WindowSystem WindowSystem { get; }
|
public WindowSystem WindowSystem { get; }
|
||||||
public Settings SettingsWindow { get; }
|
public Settings SettingsWindow { get; }
|
||||||
@@ -28,6 +34,18 @@ public sealed class Plugin : IDalamudPlugin
|
|||||||
pluginInterface.Create<Service>();
|
pluginInterface.Create<Service>();
|
||||||
Service.Configuration = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
Service.Configuration = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||||
|
|
||||||
|
var assembly = Assembly.GetExecutingAssembly();
|
||||||
|
Version = assembly.GetCustomAttribute<AssemblyVersionAttribute>()!.Version;
|
||||||
|
Author = assembly.GetCustomAttribute<AssemblyCompanyAttribute>()!.Company;
|
||||||
|
Configuration = assembly.GetCustomAttribute<AssemblyConfigurationAttribute>()!.Configuration;
|
||||||
|
byte[] iconData;
|
||||||
|
using (var stream = assembly.GetManifestResourceStream("Craftimizer.icon.png")!)
|
||||||
|
{
|
||||||
|
iconData = new byte[stream.Length];
|
||||||
|
_ = stream.Read(iconData);
|
||||||
|
}
|
||||||
|
Icon = Service.PluginInterface.UiBuilder.LoadImage(iconData);
|
||||||
|
|
||||||
Hooks = new();
|
Hooks = new();
|
||||||
RecipeNote = new();
|
RecipeNote = new();
|
||||||
WindowSystem = new(Name);
|
WindowSystem = new(Name);
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ using Dalamud.Interface;
|
|||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System;
|
using System;
|
||||||
|
using Craftimizer.Solver.Crafty;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Craftimizer.Plugin.Windows;
|
namespace Craftimizer.Plugin.Windows;
|
||||||
|
|
||||||
@@ -85,7 +88,33 @@ public class Settings : Window
|
|||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
ImGuiUtils.BeginGroupPanel("General");
|
if (ImGui.BeginTabBar("settingsTabBar"))
|
||||||
|
{
|
||||||
|
DrawTabGeneral();
|
||||||
|
|
||||||
|
var config = Config.SimulatorSolverConfig;
|
||||||
|
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();
|
||||||
|
|
||||||
|
ImGui.EndTabBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DrawTabGeneral()
|
||||||
|
{
|
||||||
|
if (!ImGui.BeginTabItem("General"))
|
||||||
|
return;
|
||||||
|
|
||||||
var isDirty = false;
|
var isDirty = false;
|
||||||
|
|
||||||
@@ -136,25 +165,33 @@ public class Settings : Window
|
|||||||
);
|
);
|
||||||
ImGui.EndDisabled();
|
ImGui.EndDisabled();
|
||||||
|
|
||||||
ImGuiUtils.EndGroupPanel();
|
if (isDirty)
|
||||||
|
Config.Save();
|
||||||
|
|
||||||
ImGuiUtils.BeginGroupPanel("Solver");
|
ImGui.EndTabItem();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.Text("Credit to altosock's ");
|
private static void DrawTabSolver(string label, ref SolverConfig configRef, out bool isDirty)
|
||||||
ImGui.SameLine(0, 0);
|
{
|
||||||
ImGuiUtils.Hyperlink("Craftingway", "https://craftingway.app");
|
isDirty = false;
|
||||||
ImGui.SameLine(0, 0);
|
|
||||||
ImGui.Text(" for the original algorithm");
|
|
||||||
|
|
||||||
ImGuiHelpers.ScaledDummy(5);
|
if (!ImGui.BeginTabItem(label))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var config = configRef;
|
||||||
|
|
||||||
|
ImGuiUtils.BeginGroupPanel("General");
|
||||||
|
|
||||||
ImGui.SetNextItemWidth(200);
|
ImGui.SetNextItemWidth(200);
|
||||||
if (ImGui.BeginCombo("Algorithm", GetAlgorithmName(Config.SolverAlgorithm)))
|
if (ImGui.BeginCombo("Algorithm", GetAlgorithmName(config.Algorithm)))
|
||||||
{
|
{
|
||||||
foreach (var alg in Enum.GetValues<SolverAlgorithm>())
|
foreach (var alg in Enum.GetValues<SolverAlgorithm>())
|
||||||
{
|
{
|
||||||
if (ImGui.Selectable(GetAlgorithmName(alg), Config.SolverAlgorithm == alg))
|
if (ImGui.Selectable(GetAlgorithmName(alg), config.Algorithm == alg))
|
||||||
Config.SolverAlgorithm = alg;
|
{
|
||||||
|
config = config with { Algorithm = alg };
|
||||||
|
isDirty = true;
|
||||||
|
}
|
||||||
if (ImGui.IsItemHovered())
|
if (ImGui.IsItemHovered())
|
||||||
ImGui.SetTooltip(GetAlgorithmTooltip(alg));
|
ImGui.SetTooltip(GetAlgorithmTooltip(alg));
|
||||||
}
|
}
|
||||||
@@ -168,9 +205,6 @@ public class Settings : Window
|
|||||||
"results, especially for very difficult crafts."
|
"results, especially for very difficult crafts."
|
||||||
);
|
);
|
||||||
|
|
||||||
var config = Config.SolverConfig;
|
|
||||||
var isSolverDirty = false;
|
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
"Iterations",
|
"Iterations",
|
||||||
"The total number of iterations to run per crafting step.\n" +
|
"The total number of iterations to run per crafting step.\n" +
|
||||||
@@ -179,7 +213,7 @@ public class Settings : Window
|
|||||||
"as necessary to get a more favorable outcome.",
|
"as necessary to get a more favorable outcome.",
|
||||||
config.Iterations,
|
config.Iterations,
|
||||||
v => config = config with { Iterations = v },
|
v => config = config with { Iterations = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
@@ -191,7 +225,7 @@ public class Settings : Window
|
|||||||
"on useless extra steps.",
|
"on useless extra steps.",
|
||||||
config.MaxStepCount,
|
config.MaxStepCount,
|
||||||
v => config = config with { MaxStepCount = v },
|
v => config = config with { MaxStepCount = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
@@ -201,7 +235,7 @@ public class Settings : Window
|
|||||||
"moves will mostly be decided at random.",
|
"moves will mostly be decided at random.",
|
||||||
config.ExplorationConstant,
|
config.ExplorationConstant,
|
||||||
v => config = config with { ExplorationConstant = v },
|
v => config = config with { ExplorationConstant = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
@@ -212,7 +246,7 @@ public class Settings : Window
|
|||||||
"1 uses their best outcome achieved so far.",
|
"1 uses their best outcome achieved so far.",
|
||||||
config.MaxScoreWeightingConstant,
|
config.MaxScoreWeightingConstant,
|
||||||
v => config = config with { MaxScoreWeightingConstant = v },
|
v => config = config with { MaxScoreWeightingConstant = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
@@ -226,7 +260,7 @@ public class Settings : Window
|
|||||||
"(Only used in the Forked and Furcated algorithms)",
|
"(Only used in the Forked and Furcated algorithms)",
|
||||||
config.ForkCount,
|
config.ForkCount,
|
||||||
v => config = config with { ForkCount = v },
|
v => config = config with { ForkCount = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
@@ -237,12 +271,12 @@ public class Settings : Window
|
|||||||
"(Only used in the Stepwise Furcated algorithm)",
|
"(Only used in the Stepwise Furcated algorithm)",
|
||||||
config.FurcatedActionCount,
|
config.FurcatedActionCount,
|
||||||
v => config = config with { FurcatedActionCount = v },
|
v => config = config with { FurcatedActionCount = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
ImGuiUtils.EndGroupPanel();
|
ImGuiUtils.EndGroupPanel();
|
||||||
|
|
||||||
ImGuiUtils.BeginGroupPanel("Solver (Advanced)");
|
ImGuiUtils.BeginGroupPanel("Advanced");
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
"Score Storage Threshold",
|
"Score Storage Threshold",
|
||||||
@@ -251,7 +285,7 @@ public class Settings : Window
|
|||||||
"Only change this value if you absolutely know what you're doing.",
|
"Only change this value if you absolutely know what you're doing.",
|
||||||
config.ScoreStorageThreshold,
|
config.ScoreStorageThreshold,
|
||||||
v => config = config with { ScoreStorageThreshold = v },
|
v => config = config with { ScoreStorageThreshold = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
@@ -261,7 +295,7 @@ public class Settings : Window
|
|||||||
"this value if you absolutely know what you're doing.",
|
"this value if you absolutely know what you're doing.",
|
||||||
config.MaxRolloutStepCount,
|
config.MaxRolloutStepCount,
|
||||||
v => config = config with { MaxRolloutStepCount = v },
|
v => config = config with { MaxRolloutStepCount = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
@@ -271,12 +305,12 @@ public class Settings : Window
|
|||||||
"better macro at the cost of not finding an extremely creative one.",
|
"better macro at the cost of not finding an extremely creative one.",
|
||||||
config.StrictActions,
|
config.StrictActions,
|
||||||
v => config = config with { StrictActions = v },
|
v => config = config with { StrictActions = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
ImGuiUtils.EndGroupPanel();
|
ImGuiUtils.EndGroupPanel();
|
||||||
|
|
||||||
ImGuiUtils.BeginGroupPanel("Solver Score Weights (Advanced)");
|
ImGuiUtils.BeginGroupPanel("Score Weights (Advanced)");
|
||||||
ImGui.TextWrapped("All values should add up to 1. Otherwise, the Score Storage Threshold should be changed.");
|
ImGui.TextWrapped("All values should add up to 1. Otherwise, the Score Storage Threshold should be changed.");
|
||||||
ImGuiHelpers.ScaledDummy(10);
|
ImGuiHelpers.ScaledDummy(10);
|
||||||
|
|
||||||
@@ -285,7 +319,7 @@ public class Settings : Window
|
|||||||
"Amount of weight to give to the craft's progress.",
|
"Amount of weight to give to the craft's progress.",
|
||||||
config.ScoreProgressBonus,
|
config.ScoreProgressBonus,
|
||||||
v => config = config with { ScoreProgressBonus = v },
|
v => config = config with { ScoreProgressBonus = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
@@ -293,7 +327,7 @@ public class Settings : Window
|
|||||||
"Amount of weight to give to the craft's quality.",
|
"Amount of weight to give to the craft's quality.",
|
||||||
config.ScoreQualityBonus,
|
config.ScoreQualityBonus,
|
||||||
v => config = config with { ScoreQualityBonus = v },
|
v => config = config with { ScoreQualityBonus = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
@@ -301,7 +335,7 @@ public class Settings : Window
|
|||||||
"Amount of weight to give to the craft's remaining durability.",
|
"Amount of weight to give to the craft's remaining durability.",
|
||||||
config.ScoreDurabilityBonus,
|
config.ScoreDurabilityBonus,
|
||||||
v => config = config with { ScoreDurabilityBonus = v },
|
v => config = config with { ScoreDurabilityBonus = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
@@ -309,7 +343,7 @@ public class Settings : Window
|
|||||||
"Amount of weight to give to the craft's remaining CP.",
|
"Amount of weight to give to the craft's remaining CP.",
|
||||||
config.ScoreCPBonus,
|
config.ScoreCPBonus,
|
||||||
v => config = config with { ScoreCPBonus = v },
|
v => config = config with { ScoreCPBonus = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
@@ -318,7 +352,7 @@ public class Settings : Window
|
|||||||
"the step count, the higher the score.",
|
"the step count, the higher the score.",
|
||||||
config.ScoreFewerStepsBonus,
|
config.ScoreFewerStepsBonus,
|
||||||
v => config = config with { ScoreFewerStepsBonus = v },
|
v => config = config with { ScoreFewerStepsBonus = v },
|
||||||
ref isSolverDirty
|
ref isDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ImGui.Button("Normalize Weights"))
|
if (ImGui.Button("Normalize Weights"))
|
||||||
@@ -336,26 +370,50 @@ public class Settings : Window
|
|||||||
ScoreCPBonus = config.ScoreCPBonus / total,
|
ScoreCPBonus = config.ScoreCPBonus / total,
|
||||||
ScoreFewerStepsBonus = config.ScoreFewerStepsBonus / total
|
ScoreFewerStepsBonus = config.ScoreFewerStepsBonus / total
|
||||||
};
|
};
|
||||||
isSolverDirty = 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 add up to 1");
|
||||||
|
|
||||||
ImGuiUtils.EndGroupPanel();
|
ImGuiUtils.EndGroupPanel();
|
||||||
|
|
||||||
if (ImGui.Button("Reset Solver Settings"))
|
if (ImGui.Button("Reset"))
|
||||||
{
|
{
|
||||||
config = new();
|
config = new();
|
||||||
isSolverDirty = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSolverDirty)
|
|
||||||
{
|
|
||||||
Config.SolverConfig = config;
|
|
||||||
isDirty = true;
|
isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.EndTabItem();
|
||||||
|
|
||||||
if (isDirty)
|
if (isDirty)
|
||||||
Config.Save();
|
configRef = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DrawTabAbout()
|
||||||
|
{
|
||||||
|
var plugin = Service.Plugin;
|
||||||
|
var icon = plugin.Icon;
|
||||||
|
|
||||||
|
ImGui.BeginTable("settingsAboutTable", 2);
|
||||||
|
ImGui.TableSetupColumn("", ImGuiTableColumnFlags.WidthFixed, icon.Width);
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.Image(icon.ImGuiHandle, new(icon.Width, icon.Height));
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.Text($"{plugin.Name} v{plugin.Version} {plugin.Configuration}");
|
||||||
|
ImGui.Text($"By {plugin.Author} (");
|
||||||
|
ImGui.SameLine(0, 0);
|
||||||
|
ImGuiUtils.Hyperlink("WorkingRobot", "https://github.com/WorkingRobot");
|
||||||
|
ImGui.SameLine(0, 0);
|
||||||
|
ImGui.Text(")");
|
||||||
|
|
||||||
|
ImGui.EndTable();
|
||||||
|
|
||||||
|
ImGui.Text("Credit to altosock's ");
|
||||||
|
ImGui.SameLine(0, 0);
|
||||||
|
ImGuiUtils.Hyperlink("Craftingway", "https://craftingway.app");
|
||||||
|
ImGui.SameLine(0, 0);
|
||||||
|
ImGui.Text(" for the original solver algorithm");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user