1
0
Fork 0

Show errors if turn-in isn't possible (instead of only printing to log)

master v3.3
Liza 2023-10-30 01:44:42 +01:00
parent f3e0d8f17c
commit 309f07c3e9
Signed by: liza
GPG Key ID: 7199F8D727D55F67
4 changed files with 31 additions and 8 deletions

View File

@ -27,7 +27,8 @@ internal sealed class MainWindow : Window
private string _searchString = string.Empty; private string _searchString = string.Empty;
private bool _checkInventory; private bool _checkInventory;
public MainWindow(WorkshopPlugin plugin, DalamudPluginInterface pluginInterface, IClientState clientState, Configuration configuration, WorkshopCache workshopCache) public MainWindow(WorkshopPlugin plugin, DalamudPluginInterface pluginInterface, IClientState clientState,
Configuration configuration, WorkshopCache workshopCache)
: base("Workshoppa###WorkshoppaMainWindow") : base("Workshoppa###WorkshoppaMainWindow")
{ {
_plugin = plugin; _plugin = plugin;
@ -42,7 +43,7 @@ internal sealed class MainWindow : Window
SizeConstraints = new WindowSizeConstraints SizeConstraints = new WindowSizeConstraints
{ {
MinimumSize = new Vector2(350, 50), MinimumSize = new Vector2(350, 50),
MaximumSize = new Vector2(500, 500), MaximumSize = new Vector2(500, 9999),
}; };
Flags = ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse; Flags = ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse;
@ -52,7 +53,7 @@ internal sealed class MainWindow : Window
public bool NearFabricationStation { get; set; } public bool NearFabricationStation { get; set; }
public ButtonState State { get; set; } = ButtonState.None; public ButtonState State { get; set; } = ButtonState.None;
public bool IsDiscipleOfHand => private bool IsDiscipleOfHand =>
_clientState.LocalPlayer != null && _clientState.LocalPlayer.ClassJob.Id is >= 8 and <= 15; _clientState.LocalPlayer != null && _clientState.LocalPlayer.ClassJob.Id is >= 8 and <= 15;
public override void Draw() public override void Draw()
@ -89,6 +90,7 @@ internal sealed class MainWindow : Window
_checkInventory = false; _checkInventory = false;
} }
} }
ImGui.EndDisabled(); ImGui.EndDisabled();
ImGui.SameLine(); ImGui.SameLine();
@ -100,6 +102,7 @@ internal sealed class MainWindow : Window
Save(); Save();
} }
ImGui.EndDisabled(); ImGui.EndDisabled();
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled) && !ImGui.GetIO().KeyCtrl) if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled) && !ImGui.GetIO().KeyCtrl)
ImGui.SetTooltip( ImGui.SetTooltip(
@ -125,7 +128,8 @@ internal sealed class MainWindow : Window
_checkInventory = !_checkInventory; _checkInventory = !_checkInventory;
ImGui.SameLine(); ImGui.SameLine();
ImGui.BeginDisabled(!NearFabricationStation || _configuration.ItemQueue.Sum(x => x.Quantity) == 0 || _plugin.CurrentStage != Stage.Stopped || !IsDiscipleOfHand); 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;
@ -147,7 +151,7 @@ internal sealed class MainWindow : Window
ImGui.Text("Queue:"); ImGui.Text("Queue:");
ImGui.BeginDisabled(_plugin.CurrentStage != Stage.Stopped); ImGui.BeginDisabled(_plugin.CurrentStage != Stage.Stopped);
Configuration.QueuedItem? itemToRemove = null; 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}");
var item = _configuration.ItemQueue[i]; var item = _configuration.ItemQueue[i];
@ -202,6 +206,7 @@ internal sealed class MainWindow : Window
ImGui.EndCombo(); ImGui.EndCombo();
} }
ImGui.EndDisabled(); ImGui.EndDisabled();
ImGui.Separator(); ImGui.Separator();
@ -294,7 +299,6 @@ internal sealed class MainWindow : Window
private void ShowErrorConditions() private void ShowErrorConditions()
{ {
if (!_plugin.WorkshopTerritories.Contains(_clientState.TerritoryType)) if (!_plugin.WorkshopTerritories.Contains(_clientState.TerritoryType))
ImGui.TextColored(ImGuiColors.DalamudRed, "You are not in the Company Workshop."); ImGui.TextColored(ImGuiColors.DalamudRed, "You are not in the Company Workshop.");
else if (!NearFabricationStation) else if (!NearFabricationStation)

View File

@ -2,6 +2,7 @@
using System.Linq; using System.Linq;
using Dalamud.Game.Addon.Lifecycle; using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes; using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI; using FFXIVClientStructs.FFXIV.Component.GUI;
using Workshoppa.GameData; using Workshoppa.GameData;
@ -110,6 +111,22 @@ partial class WorkshopPlugin
{ {
_pluginLog.Error( _pluginLog.Error(
$"Can't contribute item {item.ItemId} to craft, couldn't find {item.ItemCountPerStep}x in a single inventory slot"); $"Can't contribute item {item.ItemId} to craft, couldn't find {item.ItemCountPerStep}x in a single inventory slot");
InventoryManager* inventoryManager = InventoryManager.Instance();
int itemCount = 0;
if (inventoryManager != null)
{
itemCount = inventoryManager->GetInventoryItemCount(item.ItemId, true, false, false) +
inventoryManager->GetInventoryItemCount(item.ItemId, false, false, false);
}
if (itemCount < item.ItemCountPerStep)
_chatGui.PrintError(
$"[Workshoppa] You don't have the needed {item.ItemCountPerStep}x {item.ItemName} to continue.");
else
_chatGui.PrintError(
$"[Workshoppa] You don't have {item.ItemCountPerStep}x {item.ItemName} in a single stack, you need to merge the items in your inventory manually to continue.");
CurrentStage = Stage.RequestStop; CurrentStage = Stage.RequestStop;
break; break;
} }

View File

@ -30,6 +30,7 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin
private readonly ICommandManager _commandManager; private readonly ICommandManager _commandManager;
private readonly IPluginLog _pluginLog; private readonly IPluginLog _pluginLog;
private readonly IAddonLifecycle _addonLifecycle; private readonly IAddonLifecycle _addonLifecycle;
private readonly IChatGui _chatGui;
private readonly Configuration _configuration; private readonly Configuration _configuration;
private readonly ExternalPluginHandler _externalPluginHandler; private readonly ExternalPluginHandler _externalPluginHandler;
@ -47,7 +48,7 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin
public WorkshopPlugin(DalamudPluginInterface pluginInterface, IGameGui gameGui, IFramework framework, public WorkshopPlugin(DalamudPluginInterface pluginInterface, IGameGui gameGui, IFramework framework,
ICondition condition, IClientState clientState, IObjectTable objectTable, IDataManager dataManager, ICondition condition, IClientState clientState, IObjectTable objectTable, IDataManager dataManager,
ICommandManager commandManager, IPluginLog pluginLog, IAddonLifecycle addonLifecycle) ICommandManager commandManager, IPluginLog pluginLog, IAddonLifecycle addonLifecycle, IChatGui chatGui)
{ {
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
_gameGui = gameGui; _gameGui = gameGui;
@ -58,6 +59,7 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin
_commandManager = commandManager; _commandManager = commandManager;
_pluginLog = pluginLog; _pluginLog = pluginLog;
_addonLifecycle = addonLifecycle; _addonLifecycle = addonLifecycle;
_chatGui = chatGui;
_externalPluginHandler = new ExternalPluginHandler(_pluginInterface, _framework, _pluginLog); _externalPluginHandler = new ExternalPluginHandler(_pluginInterface, _framework, _pluginLog);
_configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration(); _configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration();

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework> <TargetFramework>net7.0-windows</TargetFramework>
<Version>3.2</Version> <Version>3.3</Version>
<LangVersion>11.0</LangVersion> <LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>