mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 11:17:11 +07:00
Item selection scrolling
This commit is contained in:
parent
e173eb55ca
commit
d1840e7c2a
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user