resize doesn't switch back to main page now
This commit is contained in:
parent
75387661d2
commit
d07ecc32f8
@ -20,6 +20,7 @@ public class Page extends Group implements Disposable {
|
||||
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
setTouchable(Touchable.childrenOnly);
|
||||
setToBasePosition();
|
||||
setName(getClass().getSimpleName());
|
||||
}
|
||||
|
||||
public Page(int baseXPos, int baseYPos, String titleText, Skin skin) {
|
||||
|
@ -25,7 +25,7 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
private Stage stage;
|
||||
private Vector3 cameraPosition;
|
||||
private PageChangeListeners listeners;
|
||||
|
||||
private String selectedPage;
|
||||
private MainPage mainPage;
|
||||
private OptionsPage optionsPage;
|
||||
private KeybindPage keybindPage;
|
||||
@ -75,12 +75,11 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
} else {
|
||||
draw();
|
||||
}
|
||||
|
||||
}
|
||||
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
||||
stage.getCamera().position.lerp(cameraPosition, 0.15f);
|
||||
stage.getViewport().apply();
|
||||
}
|
||||
}
|
||||
super.render(delta);
|
||||
}
|
||||
|
||||
@ -135,6 +134,15 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
stage.addActor(analysisPage);
|
||||
|
||||
musicController.getMusicList().attemptAsyncSearch(false);
|
||||
|
||||
if (selectedPage != null) {
|
||||
for (Actor actor : stage.getActors().items) {
|
||||
if (actor.getName().equals(selectedPage)) {
|
||||
setDisplayedPage((Page) actor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -159,8 +167,6 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
stage.getViewport().update(width, height, false);
|
||||
cameraPosition.x = width/2;
|
||||
cameraPosition.y = height/2;
|
||||
super.resize(width, height);
|
||||
}
|
||||
|
||||
@ -174,7 +180,9 @@ public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
}
|
||||
|
||||
public void setDisplayedPage(Page page) {
|
||||
Gdx.app.debug("Mainscreen", "Switching to " + page.getName());
|
||||
page.setCameraPositionToPage(cameraPosition);
|
||||
this.selectedPage = page.getName();
|
||||
}
|
||||
|
||||
private class PageChangeListeners {
|
||||
|
Loading…
Reference in New Issue
Block a user