Add simulator window
This commit is contained in:
@@ -20,13 +20,6 @@
|
||||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\Data\goat.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Visible>false</Visible>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
|
||||
@@ -9,6 +10,8 @@ public sealed class Plugin : IDalamudPlugin
|
||||
public string Name => "Craftimizer";
|
||||
|
||||
public Configuration Configuration { get; }
|
||||
public WindowSystem WindowSystem { get; } = new("Craftimizer");
|
||||
public SimulatorWindow SimulatorWindow { get; }
|
||||
|
||||
public Plugin(
|
||||
[RequiredVersion("1.0")] DalamudPluginInterface pluginInterface)
|
||||
@@ -17,12 +20,17 @@ public sealed class Plugin : IDalamudPlugin
|
||||
|
||||
Configuration = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||
|
||||
SimulatorWindow = new SimulatorWindow();
|
||||
WindowSystem.AddWindow(SimulatorWindow);
|
||||
|
||||
Service.CommandManager.AddHandler("/craft", new CommandInfo(OnCommand)
|
||||
{
|
||||
HelpMessage = "A useful message to display in /xlhelp"
|
||||
});
|
||||
|
||||
//PluginInterface.UiBuilder.OpenConfigUi += () { };
|
||||
Service.PluginInterface.UiBuilder.Draw += WindowSystem.Draw;
|
||||
Service.PluginInterface.UiBuilder.OpenConfigUi += () => SimulatorWindow.IsOpen = true;
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using Craftimizer.Simulator;
|
||||
using Craftimizer.Simulator.Actions;
|
||||
using Dalamud.Interface.Components;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Craftimizer.Plugin;
|
||||
|
||||
public class SimulatorWindow : Window
|
||||
{
|
||||
public Simulation Simulation { get; }
|
||||
public BaseAction[] AvailableActions { get; }
|
||||
|
||||
public SimulatorWindow() : base("Craftimizer")
|
||||
{
|
||||
SizeConstraints = new WindowSizeConstraints()
|
||||
{
|
||||
MinimumSize = new Vector2(400, 400),
|
||||
MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
|
||||
};
|
||||
|
||||
Simulation = new(new CharacterStats { Craftsmanship = 4041, Control = 905, CP = 609, Level = 90 }, LuminaSheets.RecipeSheet.GetRow(35573)!);
|
||||
AvailableActions = BaseAction.Actions.Select(a => (Activator.CreateInstance(a, Simulation)! as BaseAction)!).ToArray();
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
ImGui.BeginTable("CraftimizerTable", 2, ImGuiTableFlags.Resizable);
|
||||
ImGui.TableSetupColumn("CraftimizerActionsColumn", ImGuiTableColumnFlags.WidthFixed, 300);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.BeginChild("CraftimizerActions", Vector2.Zero, true, ImGuiWindowFlags.NoDecoration);
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
|
||||
foreach(var action in AvailableActions)
|
||||
{
|
||||
ImGui.BeginDisabled(!action.CanUse);
|
||||
if (ImGui.ImageButton(action.GetIcon(ClassJob.Carpenter).ImGuiHandle, new Vector2(ImGui.GetFontSize() * 4)))
|
||||
Simulation.Execute(action);
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(action.GetName(ClassJob.Carpenter));
|
||||
ImGui.EndDisabled();
|
||||
ImGui.SameLine();
|
||||
}
|
||||
ImGui.PopStyleVar();
|
||||
ImGui.EndChild();
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.BeginChild("CraftimizerSimulator", Vector2.Zero, true, ImGuiWindowFlags.NoDecoration);
|
||||
ImGui.EndChild();
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user