From ed70d65bc4cc6359913c5e51c5415bdcabd870e9 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 23 Oct 2026 18:30:12 +0200 Subject: [PATCH] Size particle choice menus by their options Lists that fit on one page get one row per nine options plus the bottom bar, so a condition with three options opens a two row menu. Longer lists keep the paged 6 row menu. --- .../steamwar/lobby/particle/gui/Pickers.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/LobbySystem/src/de/steamwar/lobby/particle/gui/Pickers.java b/LobbySystem/src/de/steamwar/lobby/particle/gui/Pickers.java index 28ba9bf0..88ca01f0 100644 --- a/LobbySystem/src/de/steamwar/lobby/particle/gui/Pickers.java +++ b/LobbySystem/src/de/steamwar/lobby/particle/gui/Pickers.java @@ -19,6 +19,7 @@ package de.steamwar.lobby.particle.gui; +import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import de.steamwar.lobby.particle.UnlockContext; @@ -100,7 +101,24 @@ class Pickers { open(player, msg("PARTICLE_SLOT_ICON_TITLE", player), list, onPick, onBack); } + // Lists that fit on one page get just enough rows for their options plus the bottom bar private void open(Player player, String title, List> list, Consumer onPick, Runnable onBack) { + if (list.size() <= SIZE - 9) { + int size = (Math.max(1, (list.size() + 8) / 9) + 1) * 9; + SWInventory inventory = new SWInventory(player, size, title); + for (int i = 0; i < list.size(); i++) { + T value = list.get(i).getObject(); + inventory.setItem(i, list.get(i).getItem().getItemStack(), clickType -> { + if (value != null) onPick.accept(value); + }); + } + inventory.setItem(BottomBar.position(size, BottomBar.BACK), new SWItem(Material.ARROW, msg("PARTICLE_BACK", player), clickType -> onBack.run())); + BottomBar.fillUnused(inventory, size, false); + SlotEditor.fill(inventory, 0, size); + inventory.open(); + return; + } + SWListInv inventory = new SWListInv<>(player, title, false, list, (clickType, value) -> { if (value != null) onPick.accept(value); });