Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: deck: order lists correctly #287

Merged
merged 6 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion zzio/db/ItemRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public ItemRow(MappedDB mappedDB, Row row) : base(ModuleType.Item, mappedDB, row

public string Script => row.cells[4].String;

public int Unknown => row.cells[5].Integer;
// Not all itemRows have this value
public int Unknown => row.cells.Length >= 6 ? row.cells[5].Integer : 0;
}
12 changes: 7 additions & 5 deletions zzre/game/systems/ui/ScrDeck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,12 @@ private void CreateGridList(DefaultEcs.Entity entity, ref components.ui.ScrDeck

private IEnumerable<InventoryCard> AllCardsOfType(in components.ui.ScrDeck deck) => deck.ActiveTab switch
{
Tab.Items => deck.Inventory.Items,
Tab.Fairies => deck.Inventory.Fairies,
Tab.AttackSpells => deck.Inventory.AttackSpells,
Tab.SupportSpells => deck.Inventory.SupportSpells,
Tab.Items => deck.Inventory.Items
.OrderBy(c => mappedDB.GetItem(c.dbUID).Unknown switch { 1 => 0, 0 => 1, _ => 2 })
.ThenBy(c => c.cardId.EntityId),
Tab.Fairies => deck.Inventory.Fairies.OrderByDescending(c => c.level),
Tab.AttackSpells => deck.Inventory.AttackSpells.OrderBy(c => c.cardId.EntityId),
Tab.SupportSpells => deck.Inventory.SupportSpells.OrderBy(c => c.cardId.EntityId),
_ => Enumerable.Empty<InventoryCard>()
};

Expand Down Expand Up @@ -581,7 +583,7 @@ protected override void Update(
{
var slider = deck.ListSlider.Get<components.ui.Slider>();
var allCardsCount = AllCardsOfType(deck).Count();
var newScrollI = (int)MathF.Round(slider.Current.Y * (allCardsCount - 1));
var newScrollI = (int)MathF.Round(slider.Current.Y * (allCardsCount - 1) * (deck.IsGridMode ? ListRows : 1));
if (newScrollI != deck.Scroll)
{
deck.Scroll = newScrollI;
Expand Down
Loading