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: book: add fairy buttons #285

Merged
merged 2 commits into from
Jan 25, 2024
Merged
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
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
Loading