Merge remote-tracking branch 'origin/Application' into Application
# Conflicts: # src/main/java/ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/lounge/LoungeSceneViewController.java
This commit is contained in:
commit
0abf86731a
@ -1,3 +1,4 @@
|
|||||||
B
|
B
|
||||||
serai
|
serai
|
||||||
serai
|
serai
|
||||||
|
serai
|
||||||
|
|||||||
@ -170,10 +170,10 @@ public class Game implements Runnable {
|
|||||||
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) && getOgGhost().getIsPlayer()) {
|
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) && getOgGhost().getIsPlayer()) {
|
||||||
OgGhostHighScore.addOgGhostWinner(getOgGhost().getName());
|
OgGhostHighScore.addOgGhostWinner(getOgGhost().getName());
|
||||||
}
|
}
|
||||||
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby + "$");
|
|
||||||
lobby.getAdmin().broadcastAnnouncementToLobby(gameOverCheck);
|
lobby.getAdmin().broadcastAnnouncementToLobby(gameOverCheck);
|
||||||
isOngoing = false;
|
isOngoing = false;
|
||||||
Timer.ghostAfterVoteTimer();
|
Timer.ghostAfterVoteTimer();
|
||||||
|
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby + "$");
|
||||||
isOngoing = true;
|
isOngoing = true;
|
||||||
lobby.removeGameFromRunningGames(this);
|
lobby.removeGameFromRunningGames(this);
|
||||||
lobby.addGameToFinishedGames(this);
|
lobby.addGameToFinishedGames(this);
|
||||||
|
|||||||
@ -383,15 +383,17 @@ public class Client {
|
|||||||
case GuiParameters.getMembersInLobby:
|
case GuiParameters.getMembersInLobby:
|
||||||
updateLobbyMembers(data);
|
updateLobbyMembers(data);
|
||||||
break;
|
break;
|
||||||
//case GuiParameters.viewChangeToGame: (commented out due to compiling error)
|
case GuiParameters.viewChangeToGame:
|
||||||
|
chatApp.getLoungeSceneViewController().addGameView();
|
||||||
//TODO
|
//TODO
|
||||||
//break; (commented out due to compiling error)
|
break;
|
||||||
//case GuiParameters.viewChangeToStart: (commented out due to compiling error)
|
/*case GuiParameters.viewChangeToStart:
|
||||||
//TODO
|
//TODO
|
||||||
//break; (commented out due to compiling error)
|
break;*/
|
||||||
//case GuiParameters.viewChangeToLobby: (commented out due to compiling error)
|
case GuiParameters.viewChangeToLobby:
|
||||||
|
chatApp.getLoungeSceneViewController().removeGameView();
|
||||||
//TODO
|
//TODO
|
||||||
//break; (commented out due to compiling error)
|
break;
|
||||||
case GuiParameters.addNewMemberToLobby:
|
case GuiParameters.addNewMemberToLobby:
|
||||||
addPlayerToLobby(data);
|
addPlayerToLobby(data);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -29,6 +29,9 @@ public class ChatApp extends Application {
|
|||||||
private static LoungeSceneViewController loungeSceneViewController;
|
private static LoungeSceneViewController loungeSceneViewController;
|
||||||
private LoungeSceneViewController lSVController;
|
private LoungeSceneViewController lSVController;
|
||||||
|
|
||||||
|
public Node chat;
|
||||||
|
public Node game;
|
||||||
|
|
||||||
public ChatApp() {
|
public ChatApp() {
|
||||||
super();
|
super();
|
||||||
LOGGER.info("Empty ChatApp constructor got called: ");
|
LOGGER.info("Empty ChatApp constructor got called: ");
|
||||||
@ -96,6 +99,10 @@ public class ChatApp extends Application {
|
|||||||
return chatController;
|
return chatController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LoungeSceneViewController getLoungeSceneViewController() {
|
||||||
|
return loungeSceneViewController;
|
||||||
|
}
|
||||||
|
|
||||||
public LoungeSceneViewController getlSVController() {
|
public LoungeSceneViewController getlSVController() {
|
||||||
return lSVController;
|
return lSVController;
|
||||||
}
|
}
|
||||||
@ -122,20 +129,24 @@ public class ChatApp extends Application {
|
|||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
this.setcModel(clientModel);
|
this.setcModel(clientModel);
|
||||||
this.setGameC(gameController);
|
this.setGameC(gameController);
|
||||||
this.setlSVController(loungeSceneViewController);
|
|
||||||
gameC.setClient(cModel);
|
gameC.setClient(cModel);
|
||||||
gameC.setGameStateModel(GameController.getGameStateModel());
|
gameC.setGameStateModel(GameController.getGameStateModel());
|
||||||
URL chatResource = ChatApp.class.getResource(
|
try {
|
||||||
"chat/ChatView.fxml");
|
URL chatResource = ChatApp.class.getResource("chat/ChatView.fxml");
|
||||||
URL gameResource = ChatApp.class.getResource(
|
URL gameResource = ChatApp.class.getResource("game/GameDayAll.fxml");
|
||||||
"game/GameDayAll.fxml");
|
this.chat = FXMLLoader.load(Objects.requireNonNull(chatResource));
|
||||||
|
this.game = FXMLLoader.load(Objects.requireNonNull(gameResource));
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.warn(e.getMessage());
|
||||||
|
}
|
||||||
URL loungeResource = ChatApp.class.getResource(
|
URL loungeResource = ChatApp.class.getResource(
|
||||||
"lounge/LoungeSceneView.fxml");
|
"lounge/LoungeSceneView.fxml");
|
||||||
try {
|
try {
|
||||||
Parent lounge = FXMLLoader.load(
|
Parent lounge = FXMLLoader.load(
|
||||||
Objects.requireNonNull(loungeResource));
|
Objects.requireNonNull(loungeResource));
|
||||||
Node chat = FXMLLoader.load(Objects.requireNonNull(chatResource));
|
this.setlSVController(loungeSceneViewController);
|
||||||
Node game = FXMLLoader.load(Objects.requireNonNull(gameResource));
|
lSVController.setChatApp(this);
|
||||||
// TODO bin chatController.getChatPaneRoot() border to root border for rezising
|
// TODO bin chatController.getChatPaneRoot() border to root border for rezising
|
||||||
Scene scene = new Scene(lounge);
|
Scene scene = new Scene(lounge);
|
||||||
scene.setRoot(lounge);
|
scene.setRoot(lounge);
|
||||||
|
|||||||
@ -11,8 +11,10 @@ import java.net.URL;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.beans.binding.StringBinding;
|
import javafx.beans.binding.StringBinding;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
@ -28,7 +30,6 @@ import javafx.event.ActionEvent;
|
|||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.geometry.Pos;
|
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.ListCell;
|
import javafx.scene.control.ListCell;
|
||||||
@ -50,9 +51,13 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public Button leaveLobbyButton;
|
private Button leaveLobbyButton;
|
||||||
@FXML
|
@FXML
|
||||||
public Button newGameButton;
|
private Button startGame;
|
||||||
|
@FXML
|
||||||
|
private Button newGameButton;
|
||||||
|
@FXML
|
||||||
|
private AnchorPane gameAnchorPane;
|
||||||
@FXML
|
@FXML
|
||||||
private ListView<LobbyListItem> LobbyListView;
|
private ListView<LobbyListItem> LobbyListView;
|
||||||
@FXML
|
@FXML
|
||||||
@ -71,7 +76,8 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
private ToolBar NTtBToolBar;
|
private ToolBar NTtBToolBar;
|
||||||
|
|
||||||
public static ClientModel client;
|
public static ClientModel client;
|
||||||
public static ChatApp chatApp;
|
private static ChatApp chatApp;
|
||||||
|
private ChatApp cApp;
|
||||||
|
|
||||||
ObservableList<ClientListItem> clients = FXCollections.observableArrayList();
|
ObservableList<ClientListItem> clients = FXCollections.observableArrayList();
|
||||||
ObservableList<LobbyListItem> lobbies = FXCollections.observableArrayList();
|
ObservableList<LobbyListItem> lobbies = FXCollections.observableArrayList();
|
||||||
@ -84,6 +90,13 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
lobbyToMemberssMap = FXCollections.observableHashMap();
|
lobbyToMemberssMap = FXCollections.observableHashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setChatApp(ChatApp chatApp) {
|
||||||
|
LoungeSceneViewController.chatApp = chatApp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setcApp(ChatApp cApp) {
|
||||||
|
this.cApp = cApp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to initialize a controller after its root element has been completely processed.
|
* Called to initialize a controller after its root element has been completely processed.
|
||||||
@ -95,6 +108,7 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
ChatApp.setLoungeSceneViewController(this);
|
ChatApp.setLoungeSceneViewController(this);
|
||||||
|
setcApp(chatApp);
|
||||||
ChangeNameButton.setOnAction(event -> changeName());
|
ChangeNameButton.setOnAction(event -> changeName());
|
||||||
LeaveServerButton.setOnAction(event -> leaveServer());
|
LeaveServerButton.setOnAction(event -> leaveServer());
|
||||||
newGameButton.setOnAction(event -> newGame());
|
newGameButton.setOnAction(event -> newGame());
|
||||||
@ -264,20 +278,59 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
});
|
});
|
||||||
|
|
||||||
LobbyListView.setPlaceholder(new Text("No open lobbies!"));
|
LobbyListView.setPlaceholder(new Text("No open lobbies!"));
|
||||||
|
client.getAllClients().addListener(new ListChangeListener<SimpleStringProperty>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Change<? extends SimpleStringProperty> c) {
|
||||||
|
List<SimpleStringProperty> removed = (List<SimpleStringProperty>) c.getRemoved();
|
||||||
|
for(SimpleStringProperty player: removed) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateClientListView(ObservableList<ClientListItem> names) {
|
public void addGameView(){
|
||||||
ObservableList<ClientListItem> clientsLeft = ClientListView.getItems();
|
Platform.runLater(new Runnable(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
newGameButton.setVisible(false);
|
||||||
|
startGame.setVisible(false);
|
||||||
|
gameAnchorPane.getChildren().add(chatApp.game);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.debug("Not yet initialized");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeGameView(){
|
||||||
|
Platform.runLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
newGameButton.setVisible(true);
|
||||||
|
startGame.setVisible(true);
|
||||||
|
gameAnchorPane.getChildren().clear();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOGGER.debug("Not yet initialized");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateClientListView(ObservableList<SimpleStringProperty> names) {
|
||||||
|
ObservableList<SimpleStringProperty> clientsLeft = ClientListView.getItems();
|
||||||
clientsLeft.removeAll(names);
|
clientsLeft.removeAll(names);
|
||||||
this.ClientListView.setItems(names);
|
this.ClientListView.setItems(names);
|
||||||
for (ClientListItem gone : clientsLeft) {
|
for (SimpleStringProperty gone : clientsLeft) {
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds players to a lobby "NMEMB" {@link ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters}
|
* Adds players to a lobby
|
||||||
*
|
* "NMEMB" {@link ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters}
|
||||||
* @param lobbyID
|
* @param lobbyID
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
@ -312,12 +365,13 @@ public class LoungeSceneViewController implements Initializable {
|
|||||||
LobbyListView.getItems().add(item);
|
LobbyListView.getItems().add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void joinGame(String lobbyID) {
|
public void joinGame(String lobbyID) {
|
||||||
client.getClient().sendMsgToServer(Protocol.joinLobby + "$" + lobbyID);
|
client.getClient().sendMsgToServer(Protocol.joinLobby + "$" + lobbyID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startGame() {
|
public void startGame() {
|
||||||
client.getClient().sendMsgToServer(Protocol.startANewGame);
|
client.getClient().sendMsgToServer(Protocol.startANewGame);
|
||||||
|
//addGameView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leaveLobby() {
|
public void leaveLobby() {
|
||||||
|
|||||||
@ -104,7 +104,7 @@ public class JServerProtocolParser {
|
|||||||
break;
|
break;
|
||||||
case Protocol.leaveLobby:
|
case Protocol.leaveLobby:
|
||||||
h.leaveLobby();
|
h.leaveLobby();
|
||||||
//h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToStart + "$"); (commented out due to compiling error)
|
h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToStart + "$");
|
||||||
break;
|
break;
|
||||||
case Protocol.votedFor:
|
case Protocol.votedFor:
|
||||||
LOGGER.debug("Made it here");
|
LOGGER.debug("Made it here");
|
||||||
@ -113,7 +113,7 @@ public class JServerProtocolParser {
|
|||||||
break;
|
break;
|
||||||
case Protocol.startANewGame:
|
case Protocol.startANewGame:
|
||||||
h.startNewGame();
|
h.startNewGame();
|
||||||
//h.sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToGame + "$"); (commented out due to compiling error)
|
h.sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToGame + "$");
|
||||||
break;
|
break;
|
||||||
case Protocol.listGames:
|
case Protocol.listGames:
|
||||||
h.listGames();
|
h.listGames();
|
||||||
|
|||||||
@ -22,7 +22,9 @@
|
|||||||
<center>
|
<center>
|
||||||
<AnchorPane BorderPane.alignment="CENTER">
|
<AnchorPane BorderPane.alignment="CENTER">
|
||||||
<children>
|
<children>
|
||||||
<Button fx:id="newGameButton" layoutX="136.0" layoutY="105.0" mnemonicParsing="false" text="New Game" />
|
<Button fx:id="newGameButton" layoutX="136.0" layoutY="105.0" mnemonicParsing="false" text="New Lobby" />
|
||||||
|
<AnchorPane fx:id="gameAnchorPane" />
|
||||||
|
<Button fx:id="startGame" layoutX="136.0" layoutY="141.0" mnemonicParsing="false" onAction="#startGame" text="Start Game" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</center>
|
</center>
|
||||||
|
|||||||
Reference in New Issue
Block a user