added a select option for selectiong maps in the lobby screen

This commit is contained in:
Tobydrama 2020-04-23 12:21:41 +02:00
parent 1548165b01
commit 5edcb56b5d

View File

@ -6,6 +6,9 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; 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;
@ -44,6 +47,25 @@ public class LobbyScreen extends AbstractScreen {
startGameButton.setX(applicationWidth / 2f - startGameButton.getWidth() / 2f); startGameButton.setX(applicationWidth / 2f - startGameButton.getWidth() / 2f);
this.roboRallyWrapper = roboRallyWrapper; this.roboRallyWrapper = roboRallyWrapper;
camera.setToOrtho(false, applicationWidth, applicationHeight); camera.setToOrtho(false, applicationWidth, applicationHeight);
Skin skin=new Skin(Gdx.files.internal("uiskin.json"));
Dialog dialog = new Dialog("Setting", skin);
final SelectBox<String> selectBox= new SelectBox<>(skin);
selectBox.setItems("Dizzy_Dash","Checkmate","Risky_Exchange");
selectBox.setPosition(Gdx.graphics.getWidth()/2f-100,Gdx.graphics.getHeight()/2f-100);
selectBox.setSize(200,50);
dialog.getContentTable().defaults().pad(10);
dialog.getContentTable().add(selectBox);
stage.addActor(selectBox);
startGameButton.addListener(new InputListener() { startGameButton.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) {
@ -52,13 +74,14 @@ public class LobbyScreen extends AbstractScreen {
List<Player> playerList = IOUtil.playerGenerator(playerNames, List<Player> playerList = IOUtil.playerGenerator(playerNames,
roboRallyWrapper.server.getRobotID()); roboRallyWrapper.server.getRobotID());
for (Connection connection : playerNames.keySet()) { for (Connection connection : playerNames.keySet()) {
roboRallyWrapper.server.sendToClient(connection, new GameStartInfoResponse("Checkmate.txt" roboRallyWrapper.server.sendToClient(connection, new GameStartInfoResponse(selectBox.getSelected()+".txt"
, playerList, playerNames.get(connection))); , playerList, playerNames.get(connection)));
} }
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(roboRallyWrapper)); roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(roboRallyWrapper));
return true; return true;
} }
}); });
Gdx.input.setInputProcessor(stage);
stage.setViewport(viewport); stage.setViewport(viewport);
} }
@ -84,6 +107,7 @@ public class LobbyScreen extends AbstractScreen {
true); true);
roboRallyWrapper.batch.end(); roboRallyWrapper.batch.end();
stage.draw(); stage.draw();
stage.act();
} }