Item selection scrolling

This commit is contained in:
Anuken 2020-02-11 11:55:38 -05:00
parent e173eb55ca
commit d1840e7c2a

View File

@ -12,6 +12,7 @@ import mindustry.ui.*;
import static mindustry.Vars.*;
public class ItemSelection{
private static float scrollPos = 0f;
public static <T extends UnlockableContent> void buildTable(Table table, Array<T> items, Prov<T> holder, Cons<T> 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);
}
}