forked from liza/Workshoppa
Include DoH condition, context menu to remove
This commit is contained in:
parent
9abcdaaa82
commit
37ca6aa3c9
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using Dalamud.Game.ClientState;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using Dalamud.Interface.Components;
|
using Dalamud.Interface.Components;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
@ -14,16 +15,18 @@ internal sealed class MainWindow : Window
|
|||||||
{
|
{
|
||||||
private readonly WorkshopPlugin _plugin;
|
private readonly WorkshopPlugin _plugin;
|
||||||
private readonly DalamudPluginInterface _pluginInterface;
|
private readonly DalamudPluginInterface _pluginInterface;
|
||||||
|
private readonly ClientState _clientState;
|
||||||
private readonly Configuration _configuration;
|
private readonly Configuration _configuration;
|
||||||
private readonly WorkshopCache _workshopCache;
|
private readonly WorkshopCache _workshopCache;
|
||||||
|
|
||||||
private string _searchString = string.Empty;
|
private string _searchString = string.Empty;
|
||||||
|
|
||||||
public MainWindow(WorkshopPlugin plugin, DalamudPluginInterface pluginInterface, Configuration configuration, WorkshopCache workshopCache)
|
public MainWindow(WorkshopPlugin plugin, DalamudPluginInterface pluginInterface, ClientState clientState, Configuration configuration, WorkshopCache workshopCache)
|
||||||
: base("Workshoppa###WorkshoppaMainWindow")
|
: base("Workshoppa###WorkshoppaMainWindow")
|
||||||
{
|
{
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
_pluginInterface = pluginInterface;
|
_pluginInterface = pluginInterface;
|
||||||
|
_clientState = clientState;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_workshopCache = workshopCache;
|
_workshopCache = workshopCache;
|
||||||
|
|
||||||
@ -42,6 +45,9 @@ internal sealed class MainWindow : Window
|
|||||||
public bool NearFabricationStation { get; set; } = false;
|
public bool NearFabricationStation { get; set; } = false;
|
||||||
public ButtonState State { get; set; } = ButtonState.None;
|
public ButtonState State { get; set; } = ButtonState.None;
|
||||||
|
|
||||||
|
public bool IsDiscipleOfHand =>
|
||||||
|
_clientState.LocalPlayer != null && _clientState.LocalPlayer.ClassJob.Id is >= 8 and <= 15;
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
var currentItem = _configuration.CurrentlyCraftedItem;
|
var currentItem = _configuration.CurrentlyCraftedItem;
|
||||||
@ -53,6 +59,7 @@ internal sealed class MainWindow : Window
|
|||||||
ImGui.BeginDisabled(!NearFabricationStation);
|
ImGui.BeginDisabled(!NearFabricationStation);
|
||||||
if (_plugin.CurrentStage == Stage.Stopped)
|
if (_plugin.CurrentStage == Stage.Stopped)
|
||||||
{
|
{
|
||||||
|
ImGui.BeginDisabled(!IsDiscipleOfHand);
|
||||||
if (currentItem.StartedCrafting)
|
if (currentItem.StartedCrafting)
|
||||||
{
|
{
|
||||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Play, "Resume"))
|
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Play, "Resume"))
|
||||||
@ -63,6 +70,7 @@ internal sealed class MainWindow : Window
|
|||||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Play, "Start Crafting"))
|
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Play, "Start Crafting"))
|
||||||
State = ButtonState.Start;
|
State = ButtonState.Start;
|
||||||
}
|
}
|
||||||
|
ImGui.EndDisabled();
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
ImGui.BeginDisabled(!ImGui.GetIO().KeyCtrl);
|
ImGui.BeginDisabled(!ImGui.GetIO().KeyCtrl);
|
||||||
@ -92,7 +100,7 @@ internal sealed class MainWindow : Window
|
|||||||
{
|
{
|
||||||
ImGui.Text("Currently Crafting: ---");
|
ImGui.Text("Currently Crafting: ---");
|
||||||
|
|
||||||
ImGui.BeginDisabled(!NearFabricationStation || _configuration.ItemQueue.Sum(x => x.Quantity) == 0 || _plugin.CurrentStage != Stage.Stopped);
|
ImGui.BeginDisabled(!NearFabricationStation || _configuration.ItemQueue.Sum(x => x.Quantity) == 0 || _plugin.CurrentStage != Stage.Stopped || !IsDiscipleOfHand);
|
||||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Play, "Start Crafting"))
|
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Play, "Start Crafting"))
|
||||||
State = ButtonState.Start;
|
State = ButtonState.Start;
|
||||||
ImGui.EndDisabled();
|
ImGui.EndDisabled();
|
||||||
@ -101,6 +109,7 @@ internal sealed class MainWindow : Window
|
|||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
ImGui.Text("Queue:");
|
ImGui.Text("Queue:");
|
||||||
ImGui.BeginDisabled(_plugin.CurrentStage != Stage.Stopped);
|
ImGui.BeginDisabled(_plugin.CurrentStage != Stage.Stopped);
|
||||||
|
Configuration.QueuedItem? itemToRemove = null;
|
||||||
for (int i = 0; i < _configuration.ItemQueue.Count; ++ i)
|
for (int i = 0; i < _configuration.ItemQueue.Count; ++ i)
|
||||||
{
|
{
|
||||||
ImGui.PushID($"ItemQueue{i}");
|
ImGui.PushID($"ItemQueue{i}");
|
||||||
@ -115,9 +124,24 @@ internal sealed class MainWindow : Window
|
|||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.OpenPopupOnItemClick($"###Context{i}");
|
||||||
|
if (ImGui.BeginPopupContextItem($"###Context{i}"))
|
||||||
|
{
|
||||||
|
if (ImGui.MenuItem($"Remove {craft.Name}"))
|
||||||
|
itemToRemove = item;
|
||||||
|
|
||||||
|
ImGui.EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.PopID();
|
ImGui.PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (itemToRemove != null)
|
||||||
|
{
|
||||||
|
_configuration.ItemQueue.Remove(itemToRemove);
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
|
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
|
||||||
if (ImGui.BeginCombo("##CraftSelection", "Add Craft..."))
|
if (ImGui.BeginCombo("##CraftSelection", "Add Craft..."))
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin
|
|||||||
_configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration();
|
_configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration();
|
||||||
_workshopCache = new WorkshopCache(dataManager);
|
_workshopCache = new WorkshopCache(dataManager);
|
||||||
|
|
||||||
_mainWindow = new(this, _pluginInterface, _configuration, _workshopCache) { IsOpen = true };
|
_mainWindow = new(this, _pluginInterface, _clientState, _configuration, _workshopCache) { IsOpen = true };
|
||||||
_windowSystem.AddWindow(_mainWindow);
|
_windowSystem.AddWindow(_mainWindow);
|
||||||
|
|
||||||
_pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
|
_pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
|
||||||
|
Loading…
Reference in New Issue
Block a user