Compare commits
No commits in common. "master" and "master" have entirely different histories.
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Game.Text;
|
||||
@ -11,13 +9,10 @@ namespace Deliveroo;
|
||||
|
||||
internal sealed class Configuration : IPluginConfiguration
|
||||
{
|
||||
public int Version { get; set; } = 2;
|
||||
public int Version { get; set; } = 1;
|
||||
|
||||
[Obsolete]
|
||||
public List<uint> ItemsAvailableForPurchase { get; set; } = [];
|
||||
|
||||
public List<PurchaseOption> ItemsAvailableToPurchase { get; set; } = [];
|
||||
public List<PurchasePriority> ItemsToPurchase { get; set; } = [];
|
||||
public List<uint> ItemsAvailableForPurchase { get; set; } = new();
|
||||
public List<PurchasePriority> ItemsToPurchase { get; set; } = new();
|
||||
|
||||
public int ReservedSealCount { get; set; }
|
||||
public bool ReserveDifferentSealCountAtMaxRank { get; set; }
|
||||
@ -32,18 +27,8 @@ internal sealed class Configuration : IPluginConfiguration
|
||||
public WindowConfig TurnInWindowConfig { get; } = new();
|
||||
public WindowConfig ConfigWindowConfig { get; } = new();
|
||||
|
||||
internal sealed class PurchaseOption
|
||||
{
|
||||
public uint ItemId { get; set; }
|
||||
public bool SameQuantityForAllLists { get; set; }
|
||||
public int GlobalLimit { get; set; }
|
||||
}
|
||||
|
||||
internal sealed class PurchasePriority
|
||||
{
|
||||
[JsonIgnore]
|
||||
public Guid InternalId { get; } = Guid.NewGuid();
|
||||
|
||||
public uint ItemId { get; set; }
|
||||
public int Limit { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
@ -69,9 +54,9 @@ internal sealed class Configuration : IPluginConfiguration
|
||||
|
||||
public bool AddVentureIfNoItemToPurchaseSelected()
|
||||
{
|
||||
if (ItemsAvailableToPurchase.Count == 0)
|
||||
if (ItemsAvailableForPurchase.Count == 0)
|
||||
{
|
||||
ItemsAvailableToPurchase.Add(new PurchaseOption { ItemId = ItemIds.Venture });
|
||||
ItemsAvailableForPurchase.Add(ItemIds.Venture);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<Project Sdk="Dalamud.NET.Sdk/9.0.2">
|
||||
<PropertyGroup>
|
||||
<Version>5.5</Version>
|
||||
<Version>5.2</Version>
|
||||
<OutputPath>dist</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Game.Addon.Lifecycle;
|
||||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
@ -75,8 +74,6 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
_keyState = keyState;
|
||||
|
||||
_configuration = (Configuration?)_pluginInterface.GetPluginConfig() ?? new Configuration();
|
||||
MigrateConfiguration();
|
||||
|
||||
_gameStrings = new GameStrings(dataManager, _pluginLog);
|
||||
_externalPluginHandler = new ExternalPluginHandler(_pluginInterface, gameConfig, _configuration, _pluginLog);
|
||||
_gameFunctions = new GameFunctions(objectTable, _clientState, targetManager, dataManager,
|
||||
@ -117,23 +114,6 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
|
||||
_addonLifecycle.RegisterListener(AddonEvent.PostSetup, "GrandCompanySupplyReward", GrandCompanySupplyRewardPostSetup);
|
||||
}
|
||||
|
||||
private void MigrateConfiguration()
|
||||
{
|
||||
#pragma warning disable CS0612 // Type or member is obsolete
|
||||
if (_configuration.Version == 1)
|
||||
{
|
||||
_configuration.ItemsAvailableToPurchase = _configuration.ItemsAvailableForPurchase.Select(x =>
|
||||
new Configuration.PurchaseOption
|
||||
{
|
||||
ItemId = x,
|
||||
SameQuantityForAllLists = false,
|
||||
}).ToList();
|
||||
_configuration.Version = 2;
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
}
|
||||
#pragma warning restore CS0612 // Type or member is obsolete
|
||||
}
|
||||
|
||||
private void ChatMessage(XivChatType type, int timestamp, ref SeString sender, ref SeString message,
|
||||
ref bool isHandled)
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
];
|
||||
|
||||
private string _searchString = string.Empty;
|
||||
private Configuration.PurchaseOption? _dragDropSource;
|
||||
private uint _dragDropSource;
|
||||
|
||||
public ConfigWindow(IDalamudPluginInterface pluginInterface, DeliverooPlugin plugin, Configuration configuration,
|
||||
GcRewardsCache gcRewardsCache, IClientState clientState, IPluginLog pluginLog, IconCache iconCache,
|
||||
@ -89,20 +89,20 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
{
|
||||
if (ImGui.BeginTabItem("Items for Auto-Buy"))
|
||||
{
|
||||
Configuration.PurchaseOption? itemToRemove = null;
|
||||
Configuration.PurchaseOption? itemToAdd = null;
|
||||
uint? itemToRemove = null;
|
||||
uint? itemToAdd = null;
|
||||
int indexToAdd = 0;
|
||||
if (ImGui.BeginChild("Items", new Vector2(-1, -ImGui.GetFrameHeightWithSpacing()), true,
|
||||
ImGuiWindowFlags.NoSavedSettings))
|
||||
{
|
||||
for (int i = 0; i < _configuration.ItemsAvailableToPurchase.Count; ++i)
|
||||
for (int i = 0; i < _configuration.ItemsAvailableForPurchase.Count; ++i)
|
||||
{
|
||||
var purchaseOption = _configuration.ItemsAvailableToPurchase[i];
|
||||
uint itemId = _configuration.ItemsAvailableForPurchase[i];
|
||||
ImGui.PushID($"###Item{i}");
|
||||
ImGui.BeginDisabled(
|
||||
_configuration.ItemsAvailableToPurchase.Count == 1 && purchaseOption.ItemId == ItemIds.Venture);
|
||||
_configuration.ItemsAvailableForPurchase.Count == 1 && itemId == ItemIds.Venture);
|
||||
|
||||
var item = _itemLookup[purchaseOption.ItemId];
|
||||
var item = _itemLookup[itemId];
|
||||
var icon = _iconCache.GetIcon(item.IconId);
|
||||
Vector2 pos = ImGui.GetCursorPos();
|
||||
Vector2 iconSize = new Vector2(ImGui.GetTextLineHeight() + ImGui.GetStyle().ItemSpacing.Y);
|
||||
@ -114,26 +114,26 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
ImGui.GetStyle().ItemSpacing.Y / 2));
|
||||
}
|
||||
|
||||
ImGui.Selectable($"{item.Name}{(item.Limited ? $" {SeIconChar.Hyadelyn.ToIconString()}" : "")}{(purchaseOption.SameQuantityForAllLists ? $" {((SeIconChar)57412).ToIconString()} (Limit: {purchaseOption.GlobalLimit:N0})" : "")}",
|
||||
ImGui.Selectable($"{item.Name}{(item.Limited ? $" {SeIconChar.Hyadelyn.ToIconString()}" : "")}",
|
||||
false, ImGuiSelectableFlags.SpanAllColumns);
|
||||
|
||||
if (ImGui.BeginDragDropSource())
|
||||
{
|
||||
ImGui.SetDragDropPayload("DeliverooDragDrop", nint.Zero, 0);
|
||||
_dragDropSource = purchaseOption;
|
||||
_dragDropSource = itemId;
|
||||
|
||||
ImGui.EndDragDropSource();
|
||||
}
|
||||
|
||||
if (ImGui.BeginDragDropTarget())
|
||||
{
|
||||
if (_dragDropSource != null &&
|
||||
if (_dragDropSource > 0 &&
|
||||
ImGui.AcceptDragDropPayload("DeliverooDragDrop").NativePtr != null)
|
||||
{
|
||||
itemToAdd = _dragDropSource;
|
||||
indexToAdd = i;
|
||||
|
||||
_dragDropSource = null;
|
||||
_dragDropSource = 0;
|
||||
}
|
||||
|
||||
ImGui.EndDragDropTarget();
|
||||
@ -142,16 +142,8 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
ImGui.OpenPopupOnItemClick($"###ctx{i}", ImGuiPopupFlags.MouseButtonRight);
|
||||
if (ImGui.BeginPopup($"###ctx{i}"))
|
||||
{
|
||||
bool sameQuantityForAllLists = purchaseOption.SameQuantityForAllLists;
|
||||
if (ImGui.MenuItem("Use same quantity for global and character-specific lists", null,
|
||||
ref sameQuantityForAllLists))
|
||||
{
|
||||
purchaseOption.SameQuantityForAllLists = sameQuantityForAllLists;
|
||||
Save();
|
||||
}
|
||||
|
||||
if (ImGui.MenuItem($"Remove {_itemLookup[purchaseOption.ItemId].Name}"))
|
||||
itemToRemove = purchaseOption;
|
||||
if (ImGui.Selectable($"Remove {_itemLookup[itemId].Name}"))
|
||||
itemToRemove = itemId;
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
@ -174,20 +166,20 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
|
||||
if (itemToRemove != null)
|
||||
{
|
||||
_configuration.ItemsAvailableToPurchase.Remove(itemToRemove);
|
||||
_configuration.ItemsAvailableForPurchase.Remove(itemToRemove.Value);
|
||||
Save();
|
||||
}
|
||||
|
||||
if (itemToAdd != null)
|
||||
{
|
||||
_configuration.ItemsAvailableToPurchase.Remove(itemToAdd);
|
||||
_configuration.ItemsAvailableToPurchase.Insert(indexToAdd, itemToAdd);
|
||||
_configuration.ItemsAvailableForPurchase.Remove(itemToAdd.Value);
|
||||
_configuration.ItemsAvailableForPurchase.Insert(indexToAdd, itemToAdd.Value);
|
||||
Save();
|
||||
}
|
||||
|
||||
List<(uint ItemId, string Name, ushort IconId, bool Limited)> comboValues = _gcRewardsCache.Rewards
|
||||
.Where(x => x.SubCategory is RewardSubCategory.Materials or RewardSubCategory.Materiel)
|
||||
.Where(x => _configuration.ItemsAvailableToPurchase.All(y => y.ItemId != x.ItemId))
|
||||
.Where(x => !_configuration.ItemsAvailableForPurchase.Contains(x.ItemId))
|
||||
.Select(x => (x.ItemId, x.Name, x.IconId, x.Limited))
|
||||
.OrderBy(x => x.Name)
|
||||
.ThenBy(x => x.GetHashCode())
|
||||
@ -217,7 +209,7 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
$"{item.Name}{(item.Limited ? $" {SeIconChar.Hyadelyn.ToIconString()}" : "")}##SelectVenture{item.IconId}");
|
||||
if (addThis || addFirst)
|
||||
{
|
||||
_configuration.ItemsAvailableToPurchase.Add(new Configuration.PurchaseOption { ItemId = item.ItemId });
|
||||
_configuration.ItemsAvailableForPurchase.Add(item.ItemId);
|
||||
|
||||
if (addFirst)
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Colors;
|
||||
using Dalamud.Interface.Components;
|
||||
@ -57,7 +56,6 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig
|
||||
private readonly GameFunctions _gameFunctions;
|
||||
|
||||
private bool _state;
|
||||
private Guid? _draggedItem;
|
||||
|
||||
public TurnInWindow(DeliverooPlugin plugin, IDalamudPluginInterface pluginInterface, Configuration configuration,
|
||||
ICondition condition, IClientState clientState, GcRewardsCache gcRewardsCache, ConfigWindow configWindow,
|
||||
@ -150,16 +148,13 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig
|
||||
.Where(x => x.Reward.RequiredRank <= rank)
|
||||
.Select(x =>
|
||||
{
|
||||
var purchaseOption = _configuration.ItemsAvailableToPurchase.Where(y => y.SameQuantityForAllLists)
|
||||
.FirstOrDefault(y => y.ItemId == x.Item.ItemId);
|
||||
int limit = purchaseOption?.GlobalLimit ?? x.Item.Limit;
|
||||
var request = new PurchaseItemRequest
|
||||
{
|
||||
ItemId = x.Item.ItemId,
|
||||
Name = x.Reward.Name,
|
||||
EffectiveLimit = CalculateEffectiveLimit(
|
||||
x.Item.ItemId,
|
||||
limit <= 0 ? uint.MaxValue : (uint)limit,
|
||||
x.Item.Limit <= 0 ? uint.MaxValue : (uint)x.Item.Limit,
|
||||
x.Reward.StackSize,
|
||||
x.Reward.InventoryLimit),
|
||||
SealCost = x.Reward.SealCost,
|
||||
@ -344,20 +339,13 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig
|
||||
{
|
||||
(GcRewardItem.None, GcRewardItem.None.Name, GcRewardItem.None.Name),
|
||||
};
|
||||
foreach (Configuration.PurchaseOption purchaseOption in _configuration.ItemsAvailableToPurchase)
|
||||
foreach (uint itemId in _configuration.ItemsAvailableForPurchase)
|
||||
{
|
||||
var gcReward = _gcRewardsCache.GetReward(purchaseOption.ItemId);
|
||||
int itemCountWithoutRetainers = _gameFunctions.GetItemCount(purchaseOption.ItemId, false);
|
||||
int itemCountWithRetainers = _gameFunctions.GetItemCount(purchaseOption.ItemId, true);
|
||||
var gcReward = _gcRewardsCache.GetReward(itemId);
|
||||
int itemCountWithoutRetainers = _gameFunctions.GetItemCount(itemId, false);
|
||||
int itemCountWithRetainers = _gameFunctions.GetItemCount(itemId, true);
|
||||
string itemNameWithoutRetainers = gcReward.Name;
|
||||
string itemNameWithRetainers = gcReward.Name;
|
||||
|
||||
if (purchaseOption.SameQuantityForAllLists)
|
||||
{
|
||||
itemNameWithoutRetainers += $" {((SeIconChar)57412).ToIconString()}";
|
||||
itemNameWithRetainers += $" {((SeIconChar)57412).ToIconString()}";
|
||||
}
|
||||
|
||||
if (itemCountWithoutRetainers > 0)
|
||||
itemNameWithoutRetainers += $" ({itemCountWithoutRetainers:N0})";
|
||||
if (itemCountWithRetainers > 0)
|
||||
@ -371,89 +359,11 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
Configuration.PurchasePriority? itemToRemove = null;
|
||||
int? itemToRemove = null;
|
||||
Configuration.PurchasePriority? itemToAdd = null;
|
||||
int indexToAdd = 0;
|
||||
|
||||
float width = ImGui.GetContentRegionAvail().X;
|
||||
List<(Vector2 TopLeft, Vector2 BottomRight)> itemPositions = [];
|
||||
|
||||
for (int i = 0; i < itemsWrapper.GetItemsToPurchase().Count; ++i)
|
||||
{
|
||||
DrawItemToBuy(grandCompany, i, itemsWrapper, comboValues, width, ref itemToRemove, itemPositions);
|
||||
}
|
||||
|
||||
if (!ImGui.IsMouseDragging(ImGuiMouseButton.Left))
|
||||
_draggedItem = null;
|
||||
else if (_draggedItem != null)
|
||||
{
|
||||
var items = itemsWrapper.GetItemsToPurchase().ToList();
|
||||
var draggedItem = items.Single(x => x.InternalId == _draggedItem);
|
||||
int oldIndex = items.IndexOf(draggedItem);
|
||||
|
||||
var (topLeft, bottomRight) = itemPositions[oldIndex];
|
||||
ImGui.GetWindowDrawList().AddRect(topLeft, bottomRight, ImGui.GetColorU32(ImGuiColors.DalamudGrey), 3f,
|
||||
ImDrawFlags.RoundCornersAll);
|
||||
|
||||
int newIndex = itemPositions.FindIndex(x => ImGui.IsMouseHoveringRect(x.TopLeft, x.BottomRight, true));
|
||||
if (newIndex >= 0 && oldIndex != newIndex)
|
||||
{
|
||||
itemToAdd = items.Single(x => x.InternalId == _draggedItem);
|
||||
indexToAdd = newIndex;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemToRemove != null)
|
||||
{
|
||||
itemsWrapper.Remove(itemToRemove);
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
if (itemToAdd != null)
|
||||
{
|
||||
itemsWrapper.Remove(itemToAdd);
|
||||
itemsWrapper.Insert(indexToAdd, itemToAdd);
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
if (_configuration.ItemsAvailableToPurchase.Any(x =>
|
||||
itemsWrapper.GetItemsToPurchase().All(y => x.ItemId != y.ItemId)))
|
||||
{
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Plus, "Add Item"))
|
||||
ImGui.OpenPopup("##AddItem");
|
||||
|
||||
if (ImGui.BeginPopupContextItem("##AddItem", ImGuiPopupFlags.NoOpenOverItems))
|
||||
{
|
||||
foreach (var purchaseOption in _configuration.ItemsAvailableToPurchase.Distinct())
|
||||
{
|
||||
if (_gcRewardsCache.RewardLookup.TryGetValue(purchaseOption.ItemId, out var reward))
|
||||
{
|
||||
if (ImGui.MenuItem($"{reward.Name}##{purchaseOption.ItemId}"))
|
||||
{
|
||||
itemsWrapper.Add(new Configuration.PurchasePriority
|
||||
{ ItemId = purchaseOption.ItemId, Limit = 0 });
|
||||
itemsWrapper.Save();
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Cog, "Configure available Items"))
|
||||
_configWindow.IsOpen = true;
|
||||
}
|
||||
|
||||
private void DrawItemToBuy(GrandCompany grandCompany, int i, IItemsToPurchase itemsWrapper,
|
||||
List<(GcRewardItem Item, string NameWithoutRetainers, string NameWithRetainers)> comboValues, float width,
|
||||
ref Configuration.PurchasePriority? itemToRemove, List<(Vector2 TopLeft, Vector2 BottomRight)> itemPositions)
|
||||
{
|
||||
Vector2 topLeft = ImGui.GetCursorScreenPos() + new Vector2(0, -ImGui.GetStyle().ItemSpacing.Y / 2);
|
||||
|
||||
ImGui.PushID($"ItemToBuy{i}");
|
||||
Configuration.PurchasePriority item = itemsWrapper.GetItemsToPurchase()[i];
|
||||
|
||||
@ -527,16 +437,6 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig
|
||||
|
||||
indentX = ImGui.GetCursorPosX() - indentX;
|
||||
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.SetNextItemWidth(width -
|
||||
ImGui.GetStyle().WindowPadding.X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.Circle.ToIconString()).X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.ArrowsUpDown.ToIconString()).X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.Times.ToIconString()).X -
|
||||
ImGui.GetStyle().FramePadding.X * 8 -
|
||||
ImGui.GetStyle().ItemSpacing.X * 2 - 3 * 3);
|
||||
ImGui.PopFont();
|
||||
|
||||
if (ImGui.Combo("", ref comboValueIndex,
|
||||
comboValues.Select(x => item.CheckRetainerInventory ? x.NameWithRetainers : x.NameWithoutRetainers)
|
||||
.ToArray(), comboValues.Count))
|
||||
@ -550,72 +450,48 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig
|
||||
|
||||
if (itemsWrapper.GetItemsToPurchase().Count >= 2)
|
||||
{
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.SameLine(ImGui.GetContentRegionAvail().X +
|
||||
ImGui.GetStyle().WindowPadding.X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.ArrowsUpDown.ToIconString()).X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.Times.ToIconString()).X -
|
||||
ImGui.GetStyle().FramePadding.X * 4 -
|
||||
ImGui.GetStyle().ItemSpacing.X);
|
||||
ImGui.PopFont();
|
||||
|
||||
if (_draggedItem == item.InternalId)
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButton($"##Up{i}", FontAwesomeIcon.ArrowUp))
|
||||
{
|
||||
ImGuiComponents.IconButton("##Move", FontAwesomeIcon.ArrowsUpDown,
|
||||
ImGui.ColorConvertU32ToFloat4(ImGui.GetColorU32(ImGuiCol.ButtonActive)));
|
||||
}
|
||||
itemToAdd = item;
|
||||
if (i > 0)
|
||||
indexToAdd = i - 1;
|
||||
else
|
||||
ImGuiComponents.IconButton("##Move", FontAwesomeIcon.ArrowsUpDown);
|
||||
indexToAdd = itemsWrapper.GetItemsToPurchase().Count - 1;
|
||||
}
|
||||
|
||||
if (_draggedItem == null && ImGui.IsItemActive() && ImGui.IsMouseDragging(ImGuiMouseButton.Left))
|
||||
_draggedItem = item.InternalId;
|
||||
ImGui.SameLine(0, 0);
|
||||
if (ImGuiComponents.IconButton($"##Down{i}", FontAwesomeIcon.ArrowDown))
|
||||
{
|
||||
itemToAdd = item;
|
||||
if (i < itemsWrapper.GetItemsToPurchase().Count - 1)
|
||||
indexToAdd = i + 1;
|
||||
else
|
||||
indexToAdd = 0;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.PushFont(UiBuilder.IconFont);
|
||||
ImGui.SameLine(ImGui.GetContentRegionAvail().X +
|
||||
ImGui.GetStyle().WindowPadding.X -
|
||||
ImGui.CalcTextSize(FontAwesomeIcon.Times.ToIconString()).X -
|
||||
ImGui.GetStyle().FramePadding.X * 2);
|
||||
ImGui.PopFont();
|
||||
}
|
||||
|
||||
if (ImGuiComponents.IconButton($"###Remove{i}", FontAwesomeIcon.Times))
|
||||
itemToRemove = item;
|
||||
itemToRemove = i;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
ImGui.Indent(indentX);
|
||||
if (comboValueIndex > 0)
|
||||
{
|
||||
var purchaseOption =
|
||||
_configuration.ItemsAvailableToPurchase
|
||||
.Where(x => x.SameQuantityForAllLists)
|
||||
.FirstOrDefault(x => x.ItemId == item.ItemId);
|
||||
|
||||
ImGui.SetNextItemWidth(ImGuiHelpers.GlobalScale * 130);
|
||||
int limit = Math.Min(purchaseOption?.GlobalLimit ?? item.Limit, (int)comboItem.Item.InventoryLimit);
|
||||
int limit = Math.Min(item.Limit, (int)comboItem.Item.InventoryLimit);
|
||||
int stepSize = comboItem.Item.StackSize < 99 ? 1 : 50;
|
||||
string label = item.Type == Configuration.PurchaseType.KeepStocked
|
||||
? "Maximum items to buy"
|
||||
: "Remaining items to buy";
|
||||
if (ImGui.InputInt(label, ref limit, stepSize, stepSize * 10))
|
||||
{
|
||||
int newLimit = Math.Min(Math.Max(0, limit), (int)comboItem.Item.InventoryLimit);
|
||||
if (purchaseOption != null)
|
||||
{
|
||||
purchaseOption.GlobalLimit = newLimit;
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Limit = newLimit;
|
||||
item.Limit = Math.Min(Math.Max(0, limit), (int)comboItem.Item.InventoryLimit);
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item.Limit != 0)
|
||||
{
|
||||
item.Limit = 0;
|
||||
@ -640,10 +516,49 @@ internal sealed class TurnInWindow : LWindow, IPersistableWindowConfig
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
Vector2 bottomRight = new Vector2(topLeft.X + width,
|
||||
ImGui.GetCursorScreenPos().Y - ImGui.GetStyle().ItemSpacing.Y + 2);
|
||||
itemPositions.Add((topLeft, bottomRight));
|
||||
if (itemToAdd != null)
|
||||
{
|
||||
itemsWrapper.Remove(itemToAdd);
|
||||
itemsWrapper.Insert(indexToAdd, itemToAdd);
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
if (itemToRemove != null)
|
||||
{
|
||||
itemsWrapper.RemoveAt(itemToRemove.Value);
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
if (_configuration.ItemsAvailableForPurchase.Any(x =>
|
||||
itemsWrapper.GetItemsToPurchase().All(y => x != y.ItemId)))
|
||||
{
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Plus, "Add Item"))
|
||||
ImGui.OpenPopup("##AddItem");
|
||||
|
||||
if (ImGui.BeginPopupContextItem("##AddItem", ImGuiPopupFlags.NoOpenOverItems))
|
||||
{
|
||||
foreach (var itemId in _configuration.ItemsAvailableForPurchase.Distinct())
|
||||
{
|
||||
if (_gcRewardsCache.RewardLookup.TryGetValue(itemId, out var reward))
|
||||
{
|
||||
if (ImGui.MenuItem($"{reward.Name}##{itemId}"))
|
||||
{
|
||||
itemsWrapper.Add(new Configuration.PurchasePriority { ItemId = itemId, Limit = 0 });
|
||||
itemsWrapper.Save();
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Cog, "Configure available Items"))
|
||||
_configWindow.IsOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe uint CalculateEffectiveLimit(uint itemId, uint limit, uint stackSize, uint inventoryLimit)
|
||||
|
Loading…
Reference in New Issue
Block a user