mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 15:19:35 +01:00
Flytter ansvar for å avslutte spillet over til RoboRallyWrapper
This commit is contained in:
parent
944f9cd55c
commit
1ec0b1c843
@ -8,6 +8,9 @@ import inf112.fiasko.roborally.networking.RoboRallyClient;
|
||||
import inf112.fiasko.roborally.networking.RoboRallyServer;
|
||||
import inf112.fiasko.roborally.objects.IRoboRallyGame;
|
||||
|
||||
/**
|
||||
* This class acts as a wrapper around the different screens of the game
|
||||
*/
|
||||
public class RoboRallyWrapper extends Game {
|
||||
public SpriteBatch batch;
|
||||
public BitmapFont font;
|
||||
@ -24,7 +27,25 @@ public class RoboRallyWrapper extends Game {
|
||||
this.setScreen(screenManager.getStartMenuScreen(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
batch.dispose();
|
||||
font.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Quits the game after logging the input as an error
|
||||
* @param string The error causing the game to quit
|
||||
*/
|
||||
public void quit(String string) {
|
||||
Gdx.app.error("Critical", string);
|
||||
Gdx.app.exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Quits the game
|
||||
*/
|
||||
public void quit() {
|
||||
Gdx.app.exit();
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,7 @@ public class StartMenuScreen extends AbstractScreen {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
//Hard fail
|
||||
Gdx.app.error("Server error", "Server could not be started");
|
||||
Gdx.app.exit();
|
||||
roboRallyWrapper.quit("Server could not be started");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -77,7 +76,7 @@ public class StartMenuScreen extends AbstractScreen {
|
||||
quitButton.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||
Gdx.app.exit();
|
||||
roboRallyWrapper.quit();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user