mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
la til username og ipaddress screen
This commit is contained in:
parent
5573d571bc
commit
25da1cb9fa
@ -2,7 +2,6 @@ package inf112.fiasko.roborally.game_wrapper;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input;
|
import com.badlogic.gdx.Input;
|
||||||
import com.badlogic.gdx.Screen;
|
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
@ -20,54 +19,30 @@ public class StartMenuScreen extends AbstractScreen {
|
|||||||
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 TextButton serverButton;
|
||||||
|
private TextButton clientButton;
|
||||||
|
private TextButton quitButton;
|
||||||
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);
|
||||||
stage = new Stage();
|
stage = new Stage();
|
||||||
|
serverButton = new SimpleButton("Create", roboRallyWrapper.font).getButton();
|
||||||
TextButton serverButton = new SimpleButton("Create", roboRallyWrapper.font).getButton();
|
|
||||||
stage.addActor(serverButton);
|
stage.addActor(serverButton);
|
||||||
serverButton.setY(applicationHeight/2f);
|
serverButton.setY(applicationHeight/2f);
|
||||||
serverButton.setX(applicationWidth/2f);
|
serverButton.setX(applicationWidth/2f);
|
||||||
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) {
|
||||||
Gdx.input.getTextInput(nameInputServer, "Name input", "input name her", "");
|
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getPowerDownScreen(roboRallyWrapper));
|
||||||
return true; // Here do stuff
|
return true; // Here do stuff
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
TextButton clientButton = new SimpleButton("Join", roboRallyWrapper.font).getButton();
|
clientButton = new SimpleButton("Join", roboRallyWrapper.font).getButton();
|
||||||
stage.addActor(clientButton);
|
stage.addActor(clientButton);
|
||||||
clientButton.setY(applicationHeight/2f);
|
clientButton.setY(applicationHeight/2f);
|
||||||
clientButton.setX(applicationWidth/2f+serverButton.getWidth()+20);
|
clientButton.setX(applicationWidth/2f+serverButton.getWidth()+20);
|
||||||
@ -76,12 +51,12 @@ public class StartMenuScreen extends AbstractScreen {
|
|||||||
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) {
|
||||||
Gdx.input.getTextInput(nameInputClient, "Name input", "input name her", "");
|
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getIPAddressScreen(roboRallyWrapper));
|
||||||
return true;// Here we do stuff
|
return true;// Here we do stuff
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
TextButton quitButton = new SimpleButton("Quit", roboRallyWrapper.font).getButton();
|
quitButton = new SimpleButton("Quit", roboRallyWrapper.font).getButton();
|
||||||
stage.addActor(quitButton);
|
stage.addActor(quitButton);
|
||||||
quitButton.setY(applicationHeight/2f);
|
quitButton.setY(applicationHeight/2f);
|
||||||
quitButton.setX(applicationWidth/2f+serverButton.getWidth()+40+clientButton.getWidth());
|
quitButton.setX(applicationWidth/2f+serverButton.getWidth()+40+clientButton.getWidth());
|
||||||
@ -94,7 +69,6 @@ public class StartMenuScreen extends AbstractScreen {
|
|||||||
return true;//her we do stuff
|
return true;//her we do stuff
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -115,5 +89,4 @@ public class StartMenuScreen extends AbstractScreen {
|
|||||||
public void resize(int width, int height) {
|
public void resize(int width, int height) {
|
||||||
viewport.update(width, height);
|
viewport.update(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user