From d1840e7c2a46fc871d7fa3c53cb4a139457088ee Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 11 Feb 2020 11:55:38 -0500 Subject: [PATCH] Item selection scrolling --- .../mindustry/world/blocks/ItemSelection.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/world/blocks/ItemSelection.java b/core/src/mindustry/world/blocks/ItemSelection.java index 165dd1ee19..2f654d081b 100644 --- a/core/src/mindustry/world/blocks/ItemSelection.java +++ b/core/src/mindustry/world/blocks/ItemSelection.java @@ -12,6 +12,7 @@ import mindustry.ui.*; import static mindustry.Vars.*; public class ItemSelection{ + private static float scrollPos = 0f; public static void buildTable(Table table, Array items, Prov holder, Cons consumer){ @@ -35,6 +36,21 @@ public class ItemSelection{ } } - table.add(cont); + //add extra blank spaces so it looks nice + if(i % 4 != 0){ + int remaining = 4 - (i % 4); + for(int j = 0; j < remaining; j++){ + cont.addImage(Styles.black6); + } + } + + ScrollPane pane = new ScrollPane(cont, Styles.smallPane); + pane.setScrollingDisabled(true, false); + pane.setScrollYForce(scrollPos); + pane.update(() -> { + scrollPos = pane.getScrollY(); + }); + + table.add(pane).maxHeight(40 * 5); } }