mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-08 02:59:36 +01:00
Using the abstract screen to clean up StartMenuScreen
This commit is contained in:
parent
953079a220
commit
86a69e78cc
@ -12,7 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
|||||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||||
|
|
||||||
public class StartMenuScreen implements Screen {
|
public class StartMenuScreen extends AbstractScreen {
|
||||||
private final RoboRallyWrapper roboRallyWrapper;
|
private final RoboRallyWrapper roboRallyWrapper;
|
||||||
|
|
||||||
private final OrthographicCamera camera;
|
private final OrthographicCamera camera;
|
||||||
@ -20,7 +20,6 @@ public class StartMenuScreen implements Screen {
|
|||||||
private final Stage stage;
|
private final Stage stage;
|
||||||
private final int applicationWidth = 600;
|
private final int applicationWidth = 600;
|
||||||
private final int applicationHeight = 800;
|
private final int applicationHeight = 800;
|
||||||
private Boolean press = false;
|
|
||||||
public StartMenuScreen(final RoboRallyWrapper roboRallyWrapper) {
|
public StartMenuScreen(final RoboRallyWrapper roboRallyWrapper) {
|
||||||
camera = new OrthographicCamera();
|
camera = new OrthographicCamera();
|
||||||
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
||||||
@ -33,13 +32,38 @@ public class StartMenuScreen implements Screen {
|
|||||||
this.roboRallyWrapper = roboRallyWrapper;
|
this.roboRallyWrapper = roboRallyWrapper;
|
||||||
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
||||||
Gdx.input.setInputProcessor(stage);
|
Gdx.input.setInputProcessor(stage);
|
||||||
|
Input.TextInputListener nameInputClient = new Input.TextInputListener() {
|
||||||
|
@Override
|
||||||
|
public void input(String name) {
|
||||||
|
//TODO: do something with the name
|
||||||
|
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getMainMenuScreen(roboRallyWrapper));
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void canceled() {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Input.TextInputListener nameInputServer = new Input.TextInputListener() {
|
||||||
|
@Override
|
||||||
|
public void input(String name) {
|
||||||
|
//TODO: do something with the name
|
||||||
|
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(roboRallyWrapper));
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void canceled() {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
serverButton.addListener(new InputListener() {
|
serverButton.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||||
MyTextInputListener nameinput = new MyTextInputListener();
|
Gdx.input.getTextInput(nameInputServer, "Name input", "input name her", "");
|
||||||
Gdx.input.getTextInput(nameinput, "Name input", "input name her", "");
|
return true; // Here do stuff
|
||||||
press = true;
|
|
||||||
return true;//her we do stuff
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,11 +76,8 @@ public class StartMenuScreen implements Screen {
|
|||||||
clientButton.addListener(new InputListener() {
|
clientButton.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||||
press = true;
|
Gdx.input.getTextInput(nameInputClient, "Name input", "input name her", "");
|
||||||
MyTextInputListener nameinput = new MyTextInputListener();
|
return true;// Here we do stuff
|
||||||
Gdx.input.getTextInput(nameinput, "Name input", "input name her", "");
|
|
||||||
|
|
||||||
return true;//her we do stuff
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -76,11 +97,6 @@ public class StartMenuScreen implements Screen {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show() {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
|
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
|
||||||
@ -93,11 +109,6 @@ public class StartMenuScreen implements Screen {
|
|||||||
applicationWidth/2f-380/2f,applicationHeight/2f +100,380, 1, true);
|
applicationWidth/2f-380/2f,applicationHeight/2f +100,380, 1, true);
|
||||||
roboRallyWrapper.batch.end();
|
roboRallyWrapper.batch.end();
|
||||||
stage.draw();
|
stage.draw();
|
||||||
|
|
||||||
if (press){
|
|
||||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper));
|
|
||||||
dispose();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -105,24 +116,4 @@ public class StartMenuScreen implements Screen {
|
|||||||
viewport.update(width, height);
|
viewport.update(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void pause() {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resume() {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
//Nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user