Rydder opp i koden og forbedrer visning av noen feilmeldinger

This commit is contained in:
Kristian Knarvik 2020-05-05 20:04:08 +02:00
parent 061e94d876
commit adc3dd5e2c
6 changed files with 17 additions and 15 deletions

View File

@ -25,6 +25,7 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
private final boolean host; private final boolean host;
private final String playerName; private final String playerName;
private final RoboRallyServer server; private final RoboRallyServer server;
private final Boolean testingMode;
private Phase phase; private Phase phase;
private Board gameBoard; private Board gameBoard;
private List<BoardElementContainer<Tile>> repairTiles; private List<BoardElementContainer<Tile>> repairTiles;
@ -34,15 +35,14 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
private List<ProgrammingCard> program; private List<ProgrammingCard> program;
private ProgrammingCardDeck playerHand; private ProgrammingCardDeck playerHand;
private ProgrammingCardDeck extraCards; private ProgrammingCardDeck extraCards;
private final Boolean testingMode;
/** /**
* Instantiates a new Robo Rally game * Instantiates a new Robo Rally game
* *
* @param playerList A list of all the players participating in the game * @param playerList A list of all the players participating in the game
* @param boardName The playerName of the board to use * @param boardName The playerName of the board to use
* @param playerName The name of the player of this instance of the game * @param playerName The name of the player of this instance of the game
* @param server The server if this player is host. Should be null otherwise * @param server The server if this player is host. Should be null otherwise
* @param testingMode Whether the game should use the test deck rather than the proper deck * @param testingMode Whether the game should use the test deck rather than the proper deck
*/ */
public RoboRallyGame(List<Player> playerList, String boardName, String playerName, public RoboRallyGame(List<Player> playerList, String boardName, String playerName,

View File

@ -4,10 +4,12 @@ import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Disposable;
import inf112.fiasko.roborally.networking.RoboRallyClient; import inf112.fiasko.roborally.networking.RoboRallyClient;
import inf112.fiasko.roborally.networking.RoboRallyServer; import inf112.fiasko.roborally.networking.RoboRallyServer;
import inf112.fiasko.roborally.objects.InteractableGame; import inf112.fiasko.roborally.objects.InteractableGame;
import inf112.fiasko.roborally.objects.RoboRallyGame; import inf112.fiasko.roborally.objects.RoboRallyGame;
import inf112.fiasko.roborally.utility.TextureConverterUtil;
/** /**
* This class acts as a wrapper around the different screens of the game * This class acts as a wrapper around the different screens of the game
@ -35,6 +37,9 @@ public class RoboRallyWrapper extends Game implements RoboRallyUI {
public void dispose() { public void dispose() {
batch.dispose(); batch.dispose();
font.dispose(); font.dispose();
for (Disposable disposable : TextureConverterUtil.getDisposableElements()) {
disposable.dispose();
}
} }
@Override @Override
@ -47,14 +52,10 @@ public class RoboRallyWrapper extends Game implements RoboRallyUI {
this.roboRallyGame = game; this.roboRallyGame = game;
} }
/** @Override
* Quits the game after logging the input as an error
*
* @param string The error causing the game to quit
*/
public void quit(String string) { public void quit(String string) {
Gdx.app.error("Critical", string); Gdx.app.error("Critical", string);
Gdx.app.exit(); quit();
} }
@Override @Override

View File

@ -39,8 +39,8 @@ public class CardChoiceScreen extends InteractiveScreen {
private final ShapeRenderer shapeRenderer; private final ShapeRenderer shapeRenderer;
private final List<CardRectangle> chosenCards; private final List<CardRectangle> chosenCards;
private final int maxCards; private final int maxCards;
private long timerStarted;
private final InteractableGame game; private final InteractableGame game;
private long timerStarted;
/** /**
* Instantiates a new card choice screen * Instantiates a new card choice screen

View File

@ -77,7 +77,8 @@ public class IPAddressScreen extends AbstractScreen {
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getUsernameScreen(roboRallyWrapper)); roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getUsernameScreen(roboRallyWrapper));
} catch (IOException | NumberFormatException ex) { } catch (IOException | NumberFormatException ex) {
JOptionPane.showMessageDialog(null, "Could not connect to the server." JOptionPane.showMessageDialog(null, "Could not connect to the server."
+ " Please make sure the ip address you typed is correct, and that the server is online."); + " Please make sure the ip address you typed is correct, and that the server is online.",
"Error", JOptionPane.ERROR_MESSAGE);
} }
} }
}); });

View File

@ -42,7 +42,7 @@ public class UsernameScreen extends AbstractScreen {
public void touchUp(InputEvent e, float x, float y, int point, int button) { public void touchUp(InputEvent e, float x, float y, int point, int button) {
if (nameInvalid(textInput.getText())) { if (nameInvalid(textInput.getText())) {
JOptionPane.showMessageDialog(null, "Username must be unique, not " + JOptionPane.showMessageDialog(null, "Username must be unique, not " +
"empty and less than 21 characters."); "empty and less than 21 characters.", "Error", JOptionPane.ERROR_MESSAGE);
return; return;
} }
if (roboRallyWrapper.server == null) { if (roboRallyWrapper.server == null) {

View File

@ -39,7 +39,7 @@ public final class DeckLoaderUtil {
* Loads programming cards from a file * Loads programming cards from a file
* *
* @param cardFile The file containing the cards to load * @param cardFile The file containing the cards to load
* @return A deck of programming cards * @return A deck of programming cards
* @throws IOException If the programming cards file is invalid * @throws IOException If the programming cards file is invalid
*/ */
private static ProgrammingCardDeck loadProgrammingCardsDeck(String cardFile) throws IOException { private static ProgrammingCardDeck loadProgrammingCardsDeck(String cardFile) throws IOException {