Skip to content

Commit

Permalink
UI: book: add fairy buttons (#285)
Browse files Browse the repository at this point in the history
* UI: book: add fairy buttons

* Use .Contains() instead of loop
  • Loading branch information
AcipenserSturio authored Jan 25, 2024
1 parent a8923c6 commit d20602b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions zzre/game/systems/ui/ScrBookMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@ protected override void HandleOpen(in messages.ui.OpenBookMenu message)
.Build();

CreateTopButtons(preload, entity, inventory, IDOpenFairybook);
CreateFairyButtons(preload, entity, inventory);
}

private void CreateFairyButtons(UIPreloader preload, in DefaultEcs.Entity entity, Inventory inventory)
{
var fairies = db.Fairies.OrderBy(fairyRow => fairyRow.CardId.EntityId).ToArray();
for (int i = 0; i < fairies.Length; i++)
{
if (inventory.Contains(fairies[i].CardId))
{
var element = new components.ui.ElementId(1 + i);
preload.CreateButton(entity)
.With(element)
.With(Mid + new Vector2(226 + 45 * (i % 9), 66 + 45 * (i / 9)))
.With(new components.ui.ButtonTiles(fairies[i].CardId.EntityId))
.With(preload.Wiz000)
.Build();
}
}
}

protected override void Update(float timeElapsed, in DefaultEcs.Entity entity, ref components.ui.ScrBookMenu bookMenu)
Expand Down

0 comments on commit d20602b

Please sign in to comment.