Commit d55ba504 authored by Quentin DRUAULT-AUBIN's avatar Quentin DRUAULT-AUBIN
Browse files

Connection lost

parent 10d88054
......@@ -225,7 +225,7 @@ public class IHMTableFacade implements IIHMTableToIHMMain, IIHMTableToData {
*/
@Override
public void connectionLostWithOpponent() {
throw new UnsupportedOperationException(EXCEPTION_MESSAGE);
controller.popupConnectionLost();
}
/**
......
......@@ -395,7 +395,6 @@ public class InGameGUIController {
updateStatsPannel();
// Get the current player.
// currentPlayer = facade.getFacadeData().getGame().getCurrentPlayer();
}
/**
......@@ -1153,4 +1152,28 @@ public class InGameGUIController {
node.getStyleClass().add("inGameGUI_destroyed_cell");
}
}
/**
* Popup displayed when the opponent lost his connection.
*/
public void popupConnectionLost() {
// Create the popup.
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Connection lost");
alert.setHeaderText("Connection has been lost with your opponent");
alert.setContentText("Do you want to save this game?");
Optional<ButtonType> result = alert.showAndWait();
// Click on OK.
if (result.get() == ButtonType.OK){
// TODO: save the game.
}
try {
// Go back to the menu.
facade.getFacadeIHMMain().toMenu();
} catch (IOException ex) {
Logger.getLogger(InGameGUIController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment