Turn-In window: Enabling/disabling & Sorting items
This commit is contained in:
parent
af3ada80c8
commit
5c973395c0
@ -24,6 +24,7 @@ internal sealed class Configuration : IPluginConfiguration
|
||||
{
|
||||
public uint ItemId { get; set; }
|
||||
public int Limit { get; set; }
|
||||
public bool Enabled { get; set; } = true;
|
||||
}
|
||||
|
||||
public bool AddVentureIfNoItemToPurchaseSelected()
|
||||
|
@ -72,7 +72,8 @@ internal sealed class TurnInWindow : Window
|
||||
|
||||
var rank = _plugin.GetGrandCompanyRank();
|
||||
return ItemsWrapper.GetItemsToPurchase()
|
||||
.Where(x => x.ItemId != 0)
|
||||
.Where(x => x.ItemId != GcRewardItem.None.ItemId)
|
||||
.Where(x => x.Enabled)
|
||||
.Select(x => new { Item = x, Reward = _gcRewardsCache.GetReward(x.ItemId) })
|
||||
.Where(x => x.Reward.GrandCompanies.Contains(grandCompany))
|
||||
.Where(x => x.Reward.RequiredRank <= rank)
|
||||
@ -191,10 +192,23 @@ internal sealed class TurnInWindow : Window
|
||||
}
|
||||
|
||||
int? itemToRemove = null;
|
||||
Configuration.PurchasePriority? itemToAdd = null;
|
||||
int indexToAdd = 0;
|
||||
for (int i = 0; i < itemsWrapper.GetItemsToPurchase().Count; ++i)
|
||||
{
|
||||
ImGui.PushID($"ItemToBuy{i}");
|
||||
var item = itemsWrapper.GetItemsToPurchase()[i];
|
||||
bool enabled = item.Enabled;
|
||||
ImGui.PushID($"Enable{i}");
|
||||
if (ImGui.Checkbox("", ref enabled))
|
||||
{
|
||||
item.Enabled = enabled;
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
ImGui.PopID();
|
||||
|
||||
ImGui.SameLine(0, 3);
|
||||
ImGui.BeginDisabled(!enabled);
|
||||
int comboValueIndex = comboValues.FindIndex(x => x.ItemId == item.ItemId);
|
||||
if (comboValueIndex < 0)
|
||||
{
|
||||
@ -211,13 +225,37 @@ internal sealed class TurnInWindow : Window
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
ImGui.EndDisabled();
|
||||
|
||||
if (itemsWrapper.GetItemsToPurchase().Count >= 2)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
if (ImGuiComponents.IconButton($"##Up{i}", FontAwesomeIcon.ArrowUp))
|
||||
{
|
||||
itemToAdd = item;
|
||||
if (i > 0)
|
||||
indexToAdd = i - 1;
|
||||
else
|
||||
indexToAdd = itemsWrapper.GetItemsToPurchase().Count - 1;
|
||||
}
|
||||
|
||||
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();
|
||||
if (ImGuiComponents.IconButton($"###Remove{i}", FontAwesomeIcon.Times))
|
||||
itemToRemove = i;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
ImGui.Indent(27);
|
||||
if (comboValueIndex > 0)
|
||||
{
|
||||
@ -257,9 +295,18 @@ internal sealed class TurnInWindow : Window
|
||||
}
|
||||
|
||||
ImGui.Unindent(27);
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
if (itemToAdd != null)
|
||||
{
|
||||
itemsWrapper.Remove(itemToAdd);
|
||||
itemsWrapper.Insert(indexToAdd, itemToAdd);
|
||||
itemsWrapper.Save();
|
||||
}
|
||||
|
||||
if (itemToRemove != null)
|
||||
{
|
||||
itemsWrapper.RemoveAt(itemToRemove.Value);
|
||||
@ -270,9 +317,25 @@ internal sealed class TurnInWindow : Window
|
||||
itemsWrapper.GetItemsToPurchase().All(y => x != y.ItemId)))
|
||||
{
|
||||
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Plus, "Add Item"))
|
||||
ImGui.OpenPopup("##AddItem");
|
||||
|
||||
if (ImGui.BeginPopupContextItem("##AddItem", ImGuiPopupFlags.NoOpenOverItems))
|
||||
{
|
||||
itemsWrapper.Add(new Configuration.PurchasePriority { ItemId = GcRewardItem.None.ItemId, Limit = 0 });
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -310,6 +373,8 @@ internal sealed class TurnInWindow : Window
|
||||
|
||||
IReadOnlyList<Configuration.PurchasePriority> GetItemsToPurchase();
|
||||
void Add(Configuration.PurchasePriority purchasePriority);
|
||||
void Insert(int index, Configuration.PurchasePriority purchasePriority);
|
||||
void Remove(Configuration.PurchasePriority purchasePriority);
|
||||
void RemoveAt(int index);
|
||||
void Save();
|
||||
}
|
||||
@ -334,6 +399,12 @@ internal sealed class TurnInWindow : Window
|
||||
public void Add(Configuration.PurchasePriority purchasePriority)
|
||||
=> _characterConfiguration.ItemsToPurchase.Add(purchasePriority);
|
||||
|
||||
public void Insert(int index, Configuration.PurchasePriority purchasePriority)
|
||||
=> _characterConfiguration.ItemsToPurchase.Insert(index, purchasePriority);
|
||||
|
||||
public void Remove(Configuration.PurchasePriority purchasePriority)
|
||||
=> _characterConfiguration.ItemsToPurchase.Remove(purchasePriority);
|
||||
|
||||
public void RemoveAt(int index)
|
||||
=> _characterConfiguration.ItemsToPurchase.RemoveAt(index);
|
||||
|
||||
@ -360,6 +431,12 @@ internal sealed class TurnInWindow : Window
|
||||
public void Add(Configuration.PurchasePriority purchasePriority)
|
||||
=> _configuration.ItemsToPurchase.Add(purchasePriority);
|
||||
|
||||
public void Insert(int index, Configuration.PurchasePriority purchasePriority)
|
||||
=> _configuration.ItemsToPurchase.Insert(index, purchasePriority);
|
||||
|
||||
public void Remove(Configuration.PurchasePriority purchasePriority)
|
||||
=> _configuration.ItemsToPurchase.Remove(purchasePriority);
|
||||
|
||||
public void RemoveAt(int index)
|
||||
=> _configuration.ItemsToPurchase.RemoveAt(index);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user