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

This commit is contained in:
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 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")
{
_plugin = plugin;
@ -42,7 +43,7 @@ internal sealed class MainWindow : Window
SizeConstraints = new WindowSizeConstraints
{
MinimumSize = new Vector2(350, 50),
MaximumSize = new Vector2(500, 500),
MaximumSize = new Vector2(500, 9999),
};
Flags = ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse;
@ -52,7 +53,7 @@ internal sealed class MainWindow : Window
public bool NearFabricationStation { get; set; }
public ButtonState State { get; set; } = ButtonState.None;
public bool IsDiscipleOfHand =>
private bool IsDiscipleOfHand =>
_clientState.LocalPlayer != null && _clientState.LocalPlayer.ClassJob.Id is >= 8 and <= 15;
public override void Draw()
@ -89,6 +90,7 @@ internal sealed class MainWindow : Window
_checkInventory = false;
}
}
ImGui.EndDisabled();
ImGui.SameLine();
@ -100,6 +102,7 @@ internal sealed class MainWindow : Window
Save();
}
ImGui.EndDisabled();
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled) && !ImGui.GetIO().KeyCtrl)
ImGui.SetTooltip(
@ -125,7 +128,8 @@ internal sealed class MainWindow : Window
_checkInventory = !_checkInventory;
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"))
{
State = ButtonState.Start;
@ -147,7 +151,7 @@ internal sealed class MainWindow : Window
ImGui.Text("Queue:");
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}");
var item = _configuration.ItemQueue[i];
@ -202,6 +206,7 @@ internal sealed class MainWindow : Window
ImGui.EndCombo();
}
ImGui.EndDisabled();
ImGui.Separator();
@ -294,7 +299,6 @@ internal sealed class MainWindow : Window
private void ShowErrorConditions()
{
if (!_plugin.WorkshopTerritories.Contains(_clientState.TerritoryType))
ImGui.TextColored(ImGuiColors.DalamudRed, "You are not in the Company Workshop.");
else if (!NearFabricationStation)

View File

@ -2,6 +2,7 @@
using System.Linq;
using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Game.Addon.Lifecycle.AddonArgTypes;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Workshoppa.GameData;
@ -110,6 +111,22 @@ partial class WorkshopPlugin
{
_pluginLog.Error(
$"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;
break;
}

View File

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

View File

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