diff --git a/Battleship/src/main/java/com/utclo23/data/facade/IDataIHMMain.java b/Battleship/src/main/java/com/utclo23/data/facade/IDataIHMMain.java index 33691a43e70ac8ef502d1e5f390d1bf5921cac33..16beb4948e061bcb23011671b5608b78d86ccca6 100644 --- a/Battleship/src/main/java/com/utclo23/data/facade/IDataIHMMain.java +++ b/Battleship/src/main/java/com/utclo23/data/facade/IDataIHMMain.java @@ -205,4 +205,4 @@ public interface IDataIHMMain { * @throws DataException */ public int getNumberAbandonsBelgian() throws DataException; -} \ No newline at end of file +} diff --git a/Battleship/src/main/java/com/utclo23/ihmmain/controller/GameListController.java b/Battleship/src/main/java/com/utclo23/ihmmain/controller/GameListController.java index 082a45a2fe278b501f242ba70f84aca3674e5538..69e8bb8c82156ed9be89baa32fec60aa6f0e12aa 100644 --- a/Battleship/src/main/java/com/utclo23/ihmmain/controller/GameListController.java +++ b/Battleship/src/main/java/com/utclo23/ihmmain/controller/GameListController.java @@ -61,8 +61,9 @@ public class GameListController extends AbstractController{ private StatGame selectedGame; private TableView gameList; - private Boolean isLoading; + private boolean isLoading; private Game receivedGame; //game received with asynchronous load + private boolean isGameSelected; /** * Method called at the beginning of the application. @@ -74,6 +75,7 @@ public class GameListController extends AbstractController{ createGameListTableView(); addOnMoussClickEventOnGameList(); enableAllButtons(); + selectedGame = null; gameListPane.setFitToWidth(true); gameListPane.setFitToHeight(true); avatarImageView.setImage(super.retrievePlayerAvatar()); @@ -89,7 +91,7 @@ public class GameListController extends AbstractController{ @Override public void handle(MouseEvent event) { Node node = ((Node) event.getTarget()).getParent(); - TableRow row; + TableRow row = null; if(!(node instanceof TableView)){ if (node instanceof TableRow){ row = (TableRow) node; @@ -99,16 +101,20 @@ public class GameListController extends AbstractController{ if(node.getParent() instanceof TableRow){ row = (TableRow) node.getParent(); }else{ - row = (TableRow) node.getParent().getParent(); + if(node.getParent().getParent() instanceof TableRow){ + row = (TableRow) node.getParent().getParent(); + } } } - StatGame selected = (StatGame)row.getItem(); - selectedGame = selected; + if(row != null){ + StatGame selected = (StatGame)row.getItem(); + selectedGame = selected; + } } } }); } - + /** * Create the table of games. */ @@ -190,7 +196,6 @@ public class GameListController extends AbstractController{ }catch(Exception e){ e.printStackTrace(); } - ObservableList data = FXCollections.observableArrayList(newGameList); // Update the list in the GUI gameList.setItems(data); @@ -213,6 +218,8 @@ public class GameListController extends AbstractController{ if(selectedGame != null){ getFacade().iDataIHMMain.gameConnectionRequestGame(selectedGame.getId(), "player"); loadingScreen(); + }else{ + showSuccessPopup("Please select a game","Please select a game to join","Create a game or Find a friend and add his ip if you don't have any game in list"); } } @@ -227,6 +234,8 @@ public class GameListController extends AbstractController{ System.out.println("ihm main watch request"); getFacade().iDataIHMMain.gameConnectionRequestGame(selectedGame.getId(), "spectator"); loadingScreen(); + }else{ + showSuccessPopup("Please select a game","Please select a game to watch","Find a friend and add his ip if you don't have any game in list"); } } diff --git a/Battleship/src/main/java/com/utclo23/ihmmain/controller/PlayerListController.java b/Battleship/src/main/java/com/utclo23/ihmmain/controller/PlayerListController.java index 23ce0daae7c9d6767a121acd4987d349fa9955f2..885891fc195b627bd79517aece581c94d1a3f634 100755 --- a/Battleship/src/main/java/com/utclo23/ihmmain/controller/PlayerListController.java +++ b/Battleship/src/main/java/com/utclo23/ihmmain/controller/PlayerListController.java @@ -161,7 +161,7 @@ public class PlayerListController extends AbstractController{ PlayerProfileController.class.getName()).log( Level.INFO, "Waiting." ); - Thread.sleep(500); + Thread.sleep(200); } } catch (InterruptedException e) { } diff --git a/Battleship/src/main/java/com/utclo23/ihmmain/controller/PlayerProfileController.java b/Battleship/src/main/java/com/utclo23/ihmmain/controller/PlayerProfileController.java index 209891f2208e7675edd0bdd31fac8fd58f827ea7..b76464e793da8e683b98936d9e4a968991f5ce93 100755 --- a/Battleship/src/main/java/com/utclo23/ihmmain/controller/PlayerProfileController.java +++ b/Battleship/src/main/java/com/utclo23/ihmmain/controller/PlayerProfileController.java @@ -93,7 +93,6 @@ public class PlayerProfileController extends AbstractController{ private List dataBelgian; private List dataTotal; private SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); - @FXML @Override