set keyboard focus on change to music selection page

This commit is contained in:
Harrison Deng 2017-11-07 17:19:18 -06:00
parent e65769f392
commit 16992e1345
3 changed files with 28 additions and 4 deletions

View File

@ -20,6 +20,7 @@ import zero1hd.rhythmbullet.audio.SongListController;
import zero1hd.rhythmbullet.graphics.ui.components.MusicControls;
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
import zero1hd.rhythmbullet.graphics.ui.components.TitleBarVisualizer;
import zero1hd.rhythmbullet.screens.MainMenu;
public class MainPage extends Page implements Observer {
private Label versionLabel;
@ -34,7 +35,7 @@ public class MainPage extends Page implements Observer {
private MusicControls musicControls;
private ScrollText scrollText;
public MainPage(RhythmBullet core, Vector3 targetPosition, SongListController sc) {
public MainPage(RhythmBullet core, Vector3 targetPosition, SongListController sc, MainMenu mm) {
this.sc = sc;
setTextureBackground(core.getAssetManager().get("gradients.atlas", TextureAtlas.class).findRegion("red-linear"));
@ -57,7 +58,7 @@ public class MainPage extends Page implements Observer {
@Override
public void changed(ChangeEvent event, Actor actor) {
targetPosition.x = Gdx.graphics.getWidth()*1.5f;
Gdx.input.setInputProcessor(getStage());
getStage().setKeyboardFocus(mm.getMusicSelectionPage());
}
});
table.add(playButton).width(Gdx.graphics.getWidth()*0.2f);

View File

@ -119,7 +119,6 @@ public class MusicSelectionPage extends Page {
index = songTable.getChildren().size;
}
deselectAll();
//ez broken casting.
((MusicSelectable)songTable.getChildren().get(index)).select();
scrollbar.scrollTo(currentlySelected.getX(), currentlySelected.getY(), currentlySelected.getWidth(), currentlySelected.getHeight());
}

View File

@ -80,7 +80,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter, Observ
public void postTransition() {
attemptLoadShaders();
mainPage = new MainPage(core, cameraPosition, sc);
mainPage = new MainPage(core, cameraPosition, sc, this);
mainPage.setPosition(0, 0);
stage.addActor(mainPage);
//End main menu
@ -373,4 +373,28 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter, Observ
musicSelectionPage.refresh();
}
}
public MainPage getMainPage() {
return mainPage;
}
public CreditsPage getCreditsPage() {
return creditsPage;
}
public VideoOptionsPage getGraphicsPage() {
return graphicsPage;
}
public KeybindOptionsPage getKeybindPage() {
return keybindPage;
}
public MusicSelectionPage getMusicSelectionPage() {
return musicSelectionPage;
}
public OptionsPage getOptionsPage() {
return optionsPage;
}
}