mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +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.networking.RoboRallyServer;
|
||||||
import inf112.fiasko.roborally.objects.IRoboRallyGame;
|
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 class RoboRallyWrapper extends Game {
|
||||||
public SpriteBatch batch;
|
public SpriteBatch batch;
|
||||||
public BitmapFont font;
|
public BitmapFont font;
|
||||||
@ -24,7 +27,25 @@ public class RoboRallyWrapper extends Game {
|
|||||||
this.setScreen(screenManager.getStartMenuScreen(this));
|
this.setScreen(screenManager.getStartMenuScreen(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
batch.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) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
//Hard fail
|
//Hard fail
|
||||||
Gdx.app.error("Server error", "Server could not be started");
|
roboRallyWrapper.quit("Server could not be started");
|
||||||
Gdx.app.exit();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -77,7 +76,7 @@ public class StartMenuScreen extends AbstractScreen {
|
|||||||
quitButton.addListener(new InputListener() {
|
quitButton.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.app.exit();
|
roboRallyWrapper.quit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user