1
0
forked from liza/ARDiscard

Improve some conditions

This commit is contained in:
Liza 2023-09-16 16:19:08 +02:00
parent 6590db2a03
commit 9a23663c67
Signed by: liza
GPG Key ID: 7199F8D727D55F67
3 changed files with 17 additions and 4 deletions

View File

@ -23,6 +23,7 @@ public sealed class ItemCache
Rarity = item.Rarity, Rarity = item.Rarity,
IsUnique = item.IsUnique, IsUnique = item.IsUnique,
IsUntradable = item.IsUntradable, IsUntradable = item.IsUntradable,
IsIndisposable = item.IsIndisposable,
Level = item.LevelEquip, Level = item.LevelEquip,
UiCategory = item.ItemUICategory.Row, UiCategory = item.ItemUICategory.Row,
}; };
@ -31,7 +32,12 @@ public sealed class ItemCache
public IEnumerable<CachedItemInfo> AllItems => _items.Values; public IEnumerable<CachedItemInfo> AllItems => _items.Values;
public CachedItemInfo? GetItem(uint itemId) => _items[itemId]; public CachedItemInfo? GetItem(uint itemId)
{
if (_items.TryGetValue(itemId, out var item))
return item;
return null;
}
public string GetItemName(uint itemId) public string GetItemName(uint itemId)
{ {
@ -49,6 +55,12 @@ public sealed class ItemCache
public required byte Rarity { get; init; } public required byte Rarity { get; init; }
public required bool IsUnique { get; init; } public required bool IsUnique { get; init; }
public required bool IsUntradable { get; init; } public required bool IsUntradable { get; init; }
/// <summary>
/// Whether this item can be discarded at all. "Discard" is greyed out e.g. for the preorder EXP earrings.
/// </summary>
public required bool IsIndisposable { get; init; }
public required uint UiCategory { get; init; } public required uint UiCategory { get; init; }
} }
} }

View File

@ -65,7 +65,8 @@ public sealed class ConfigWindow : Window
} }
ImGui.SameLine(ImGui.GetWindowWidth() - 115 * ImGuiHelpers.GlobalScale); ImGui.SameLine(ImGui.GetWindowWidth() - 115 * ImGuiHelpers.GlobalScale);
ImGui.BeginDisabled(!_clientState.IsLoggedIn || !_condition[ConditionFlag.NormalConditions] || ImGui.BeginDisabled(!_clientState.IsLoggedIn ||
!(_condition[ConditionFlag.NormalConditions] || _condition[ConditionFlag.Mounted]) ||
DiscardNowClicked == null); DiscardNowClicked == null);
if (ImGui.Button("Preview Discards")) if (ImGui.Button("Preview Discards"))
DiscardNowClicked!.Invoke(this, EventArgs.Empty); DiscardNowClicked!.Invoke(this, EventArgs.Empty);
@ -343,7 +344,7 @@ public sealed class ConfigWindow : Window
if (_allItems == null) if (_allItems == null)
{ {
_allItems = _itemCache.AllItems _allItems = _itemCache.AllItems
.Where(x => !x.IsUnique && !x.IsUntradable) .Where(x => x is { IsUnique: false, IsUntradable: false, IsIndisposable: false })
.Where(x => x.UiCategory != UiCategories.Currency && x.UiCategory != UiCategories.Crystals && .Where(x => x.UiCategory != UiCategories.Currency && x.UiCategory != UiCategories.Crystals &&
x.UiCategory != UiCategories.Unobtainable) x.UiCategory != UiCategories.Unobtainable)
.Select(x => (x.ItemId, x.Name.ToString())) .Select(x => (x.ItemId, x.Name.ToString()))

View File

@ -80,7 +80,7 @@ public sealed class DiscardWindow : Window
ImGui.SameLine(ImGui.GetWindowWidth() - 160 * ImGuiHelpers.GlobalScale); ImGui.SameLine(ImGui.GetWindowWidth() - 160 * ImGuiHelpers.GlobalScale);
ImGui.BeginDisabled(Locked || ImGui.BeginDisabled(Locked ||
!_clientState.IsLoggedIn || !_clientState.IsLoggedIn ||
!_condition[ConditionFlag.NormalConditions] || !(_condition[ConditionFlag.NormalConditions] || _condition[ConditionFlag.Mounted]) ||
_displayedItems.Count(x => x.Selected) == 0 || _displayedItems.Count(x => x.Selected) == 0 ||
DiscardAllClicked == null); DiscardAllClicked == null);
if (ImGui.Button("Discard all selected items")) if (ImGui.Button("Discard all selected items"))