From dbf07745864884d3ff35dcc3bb3b86bcbee18ef6 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Thu, 30 Apr 2020 11:44:03 +0200 Subject: [PATCH] =?UTF-8?q?Legger=20til=20bedre=20beskrivelser=20av=20hva?= =?UTF-8?q?=20som=20blir=20ventet=20p=C3=A5=20p=C3=A5=20LoadingScreen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gamewrapper/screens/LoadingScreen.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/inf112/fiasko/roborally/gamewrapper/screens/LoadingScreen.java b/src/main/java/inf112/fiasko/roborally/gamewrapper/screens/LoadingScreen.java index 440cffc..224089d 100644 --- a/src/main/java/inf112/fiasko/roborally/gamewrapper/screens/LoadingScreen.java +++ b/src/main/java/inf112/fiasko/roborally/gamewrapper/screens/LoadingScreen.java @@ -34,7 +34,7 @@ public class LoadingScreen extends AbstractScreen { roboRallyWrapper.batch.setProjectionMatrix(camera.combined); roboRallyWrapper.batch.begin(); - roboRallyWrapper.font.draw(roboRallyWrapper.batch, "Loading...", applicationWidth / 2f - 380 / 2f, + roboRallyWrapper.font.draw(roboRallyWrapper.batch, getLoadingText(), applicationWidth / 2f - 380 / 2f, applicationHeight / 2f, 380, 1, true); roboRallyWrapper.batch.end(); @@ -44,6 +44,36 @@ public class LoadingScreen extends AbstractScreen { } } + /** + * Returns the correct loading text to display according to the game's state + * + * @return Text explaining what the game is waiting for + */ + private String getLoadingText() { + if (roboRallyWrapper.roboRallyGame == null) { + if (roboRallyWrapper.server == null) { + return "Waiting for host to start the game..."; + } + return "Loading..."; + } + System.out.println(roboRallyWrapper.roboRallyGame.getGameState()); + switch (roboRallyWrapper.roboRallyGame.getGameState()) { + case WAITING_FOR_OTHER_PLAYERS_PROGRAMS: + return "Waiting for other players to finish programming..."; + case WAITING_FOR_CARDS_FROM_SERVER: + return "Waiting for new cards from the server..."; + case BEGINNING_OF_GAME: + return "Initializing new turn..."; + case CHOOSING_CARDS: + return "Waiting for screen change..."; + case SKIP_STAY_IN_POWER_DOWN: + return "Waiting for players to choose whether to stay in power down..."; + default: + return "Waiting for something..."; + } + + } + /** * Changes to another screen depending on which state the game is in *