Skip to content

Commit

Permalink
fix: Wrap category buttons if they would overflow the screen #220
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Oct 29, 2024
1 parent 884305e commit e082b07
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ private void updateCategoryFilters() {
}
filterButtons.clear();

int curX = 87;
int curY = -80;
final var categories = menu.getCategories();
for (final var category : categories) {
MarketFilterButton filterButton = new MarketFilterButton(width / 2 + 87, height / 2 + curY, menu, category, button -> {
MarketFilterButton filterButton = new MarketFilterButton(width / 2 + curX, height / 2 + curY, menu, category, button -> {
if (menu.getCurrentCategory().map(it -> it.equals(category)).orElse(false)) {
menu.setCategory(null);
} else {
Expand All @@ -104,6 +105,10 @@ private void updateCategoryFilters() {
filterButtons.add(filterButton);

curY += 20;
if (curY > 60) {
curY = -80;
curX += 20;
}
}
}

Expand Down

0 comments on commit e082b07

Please sign in to comment.