Automatically scroll to the currently used theme
This commit is contained in:
parent
347382dd69
commit
3b1124d77c
3 changed files with 20 additions and 2 deletions
|
@ -8,7 +8,7 @@
|
|||
"8be9fdff",
|
||||
"ff5555ff",
|
||||
"ff79c6ff",
|
||||
"ffb86cf"
|
||||
"ffb86cff"
|
||||
],
|
||||
"empty_cell": "44475aff",
|
||||
"cells": [
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue