Commit 220a2a68 authored by Matyáš Latner's avatar Matyáš Latner

Merge branch 'feature-optimalization' into 'devel'

Feature optimalization



See merge request !249
parents 7c136f04 dcdfc924
......@@ -37,6 +37,7 @@ public class MenuController extends Group implements Disposable {
private final Group screenDimmerLayer;
private final Actor screenDimmer;
private final Map<Class<? extends AbstractMenu>, AbstractMenu> menus;
private AbstractMenu[] menuCache;
private boolean loadingComplete = false;
......@@ -81,6 +82,7 @@ public class MenuController extends Group implements Disposable {
try {
AbstractMenu menu = menuClass.getConstructor(Float.class, Float.class).newInstance(getWidth() * MAIN_MENU_WIDTH_RATIO, getHeight());
menus.put(menuClass, menu);
cacheMenus();
menu.initMenuItems();
addActor(menu);
} catch (Exception e) {
......@@ -88,6 +90,15 @@ public class MenuController extends Group implements Disposable {
}
}
private void cacheMenus() {
menuCache = new AbstractMenu[menus.size()];
int index = 0;
for (AbstractMenu menu : menus.values()) {
menuCache[index] = menu;
index++;
}
}
public void doMenuAction(final Class<? extends AbstractMenu> menuClass, final AbstractMenu.MenuAction menuAction, final boolean animated, final boolean force) {
Gdx.app.postRunnable(new Runnable() {
......@@ -119,7 +130,8 @@ public class MenuController extends Group implements Disposable {
super.draw(batch, parentAlpha);
float openPercentage = 0;
for (AbstractMenu menu: menus.values()) {
for(AbstractMenu menu : menuCache) {
float menuOpenPercentage = menu.getMenuOpenPercentage();
if (menuOpenPercentage > openPercentage) {
openPercentage = menuOpenPercentage;
......
......@@ -434,8 +434,8 @@ public class GameMenuPage extends MenuPage {
// Paralax layers
// Back layer travels half the speed of scroll
// needed to make fade work
Color color = new Color(this.getColor().r, this.getColor().g, this.getColor().b, this.getColor().a * parentAlpha);
batch.setColor(color);
batch.setColor(getColor());
batch.getColor().a *= parentAlpha;
//Background rendering has been moved to PagedScrollPane class
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment