Automatically scroll to the currently used theme

This commit is contained in:
Lonami Exo 2017-05-09 16:39:59 +02:00
parent 347382dd69
commit 3b1124d77c
3 changed files with 20 additions and 2 deletions

View file

@ -8,7 +8,7 @@
"8be9fdff",
"ff5555ff",
"ff79c6ff",
"ffb86cf"
"ffb86cff"
],
"empty_cell": "44475aff",
"cells": [

View file

@ -100,6 +100,10 @@ public class ThemeCard extends Actor {
usedThemeUpdated();
}
public boolean isUsed() {
return Klooni.theme.getName().equals(theme.getName());
}
void performBuy() {
Klooni.buyTheme(theme);
use();

View file

@ -144,11 +144,25 @@ class CustomizeScreen implements Screen {
themesGroup.addActor(card);
}
table.add(new ScrollPane(themesGroup)).expand().fill();
final ScrollPane themesScroll = new ScrollPane(themesGroup);
table.add(themesScroll).expand().fill();
// Show the current money row
table.row();
table.add(buyBand).expandX().fillX();
// Scroll to the currently selected theme
table.layout();
for (Actor a : themesGroup.getChildren()) {
ThemeCard c = (ThemeCard)a;
if (c.isUsed()) {
themesScroll.scrollTo(
c.getX(), c.getY() + c.getHeight(),
c.getWidth(), c.getHeight());
break;
}
c.usedThemeUpdated();
}
}
//endregion