forked from SteamWar/SteamWar
Give particle menus a shared bottom bar
Back, use, add, rename, icon, particle count and delete or reset now sit in the same column of the last row in every particle menu, and columns a menu does not use show a barrier.
This commit is contained in:
@@ -41,7 +41,10 @@ import static de.steamwar.lobby.particle.gui.ParticleGuiText.*;
|
||||
@UtilityClass
|
||||
class ValueEditors {
|
||||
|
||||
private final int BACK = 18;
|
||||
private final int SIZE = 27;
|
||||
private final int BACK = BottomBar.position(SIZE, BottomBar.BACK);
|
||||
private final int ADD = BottomBar.position(SIZE, BottomBar.ADD);
|
||||
private final int RESET = BottomBar.position(SIZE, BottomBar.RESET);
|
||||
|
||||
// Buttons step the value down or up; clicking the value itself lets the player type one
|
||||
void editNumber(Player player, String title, Supplier<Double> current, double step, double min, double max, double defaultValue, boolean integer,
|
||||
@@ -49,7 +52,7 @@ class ValueEditors {
|
||||
double value = current.get();
|
||||
Runnable reopen = () -> editNumber(player, title, current, step, min, max, defaultValue, integer, apply, back);
|
||||
|
||||
SWInventory inventory = new SWInventory(player, 27, "§0" + strip(title));
|
||||
SWInventory inventory = new SWInventory(player, SIZE, "§0" + strip(title));
|
||||
inventory.setItem(10, stepItem(player, Material.RED_CONCRETE, -10 * step, step, value, min, max, integer, apply, reopen));
|
||||
inventory.setItem(11, stepItem(player, Material.RED_STAINED_GLASS_PANE, -step, step, value, min, max, integer, apply, reopen));
|
||||
inventory.setItem(15, stepItem(player, Material.LIME_STAINED_GLASS_PANE, step, step, value, min, max, integer, apply, reopen));
|
||||
@@ -72,11 +75,12 @@ class ValueEditors {
|
||||
}));
|
||||
|
||||
inventory.setItem(BACK, new SWItem(Material.ARROW, msg("PARTICLE_BACK", player), clickType -> back.run()));
|
||||
inventory.setItem(22, new SWItem(Material.STRUCTURE_VOID, msg("PARTICLE_VALUE_RESET", player, number(defaultValue)), clickType -> {
|
||||
inventory.setItem(RESET, new SWItem(Material.STRUCTURE_VOID, msg("PARTICLE_VALUE_RESET", player, number(defaultValue)), clickType -> {
|
||||
apply.test(defaultValue);
|
||||
reopen.run();
|
||||
}));
|
||||
SlotEditor.fill(inventory, 0, 27);
|
||||
BottomBar.fillUnused(inventory, SIZE, false);
|
||||
SlotEditor.fill(inventory, 0, SIZE);
|
||||
inventory.open();
|
||||
}
|
||||
|
||||
@@ -95,7 +99,7 @@ class ValueEditors {
|
||||
List<Color> colors = current.get();
|
||||
Runnable reopen = () -> editColors(player, current, maxColors, apply, back);
|
||||
|
||||
SWInventory inventory = new SWInventory(player, 27, msg("PARTICLE_COLOR_EDITOR", player));
|
||||
SWInventory inventory = new SWInventory(player, SIZE, msg("PARTICLE_COLOR_EDITOR", player));
|
||||
for (int i = 0; i < colors.size() && i < 9; i++) {
|
||||
int position = i;
|
||||
Color color = colors.get(i);
|
||||
@@ -114,18 +118,19 @@ class ValueEditors {
|
||||
|
||||
inventory.setItem(BACK, new SWItem(Material.ARROW, msg("PARTICLE_BACK", player), clickType -> back.run()));
|
||||
if (colors.size() < maxColors) {
|
||||
inventory.setItem(21, new SWItem(Material.NETHER_STAR, msg("PARTICLE_COLOR_ADD", player), clickType -> Pickers.color(player, color -> {
|
||||
inventory.setItem(ADD, new SWItem(Material.NETHER_STAR, msg("PARTICLE_COLOR_ADD", player), clickType -> Pickers.color(player, color -> {
|
||||
List<Color> next = new ArrayList<>(colors);
|
||||
next.add(color);
|
||||
apply.test(next);
|
||||
reopen.run();
|
||||
}, reopen)));
|
||||
}
|
||||
inventory.setItem(23, new SWItem(Material.WHITE_DYE, msg("PARTICLE_COLOR_RANDOM", player), clickType -> {
|
||||
inventory.setItem(RESET, new SWItem(Material.WHITE_DYE, msg("PARTICLE_COLOR_RANDOM", player), clickType -> {
|
||||
apply.test(List.of());
|
||||
reopen.run();
|
||||
}));
|
||||
SlotEditor.fill(inventory, 0, 27);
|
||||
BottomBar.fillUnused(inventory, SIZE, false);
|
||||
SlotEditor.fill(inventory, 0, SIZE);
|
||||
inventory.open();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user