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
|
||||
serai
|
||||
serai
|
||||
serai
|
||||
|
||||
@ -170,10 +170,10 @@ public class Game implements Runnable {
|
||||
if (gameOverCheck.equals(ClientGameInfoHandler.gameOverGhostsWin) && getOgGhost().getIsPlayer()) {
|
||||
OgGhostHighScore.addOgGhostWinner(getOgGhost().getName());
|
||||
}
|
||||
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby + "$");
|
||||
lobby.getAdmin().broadcastAnnouncementToLobby(gameOverCheck);
|
||||
isOngoing = false;
|
||||
Timer.ghostAfterVoteTimer();
|
||||
lobby.getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToLobby + "$");
|
||||
isOngoing = true;
|
||||
lobby.removeGameFromRunningGames(this);
|
||||
lobby.addGameToFinishedGames(this);
|
||||
|
||||
@ -383,15 +383,17 @@ public class Client {
|
||||
case GuiParameters.getMembersInLobby:
|
||||
updateLobbyMembers(data);
|
||||
break;
|
||||
//case GuiParameters.viewChangeToGame: (commented out due to compiling error)
|
||||
case GuiParameters.viewChangeToGame:
|
||||
chatApp.getLoungeSceneViewController().addGameView();
|
||||
//TODO
|
||||
//break; (commented out due to compiling error)
|
||||
//case GuiParameters.viewChangeToStart: (commented out due to compiling error)
|
||||
break;
|
||||
/*case GuiParameters.viewChangeToStart:
|
||||
//TODO
|
||||
//break; (commented out due to compiling error)
|
||||
//case GuiParameters.viewChangeToLobby: (commented out due to compiling error)
|
||||
break;*/
|
||||
case GuiParameters.viewChangeToLobby:
|
||||
chatApp.getLoungeSceneViewController().removeGameView();
|
||||
//TODO
|
||||
//break; (commented out due to compiling error)
|
||||
break;
|
||||
case GuiParameters.addNewMemberToLobby:
|
||||
addPlayerToLobby(data);
|
||||
break;
|
||||
|
||||
@ -29,6 +29,9 @@ public class ChatApp extends Application {
|
||||
private static LoungeSceneViewController loungeSceneViewController;
|
||||
private LoungeSceneViewController lSVController;
|
||||
|
||||
public Node chat;
|
||||
public Node game;
|
||||
|
||||
public ChatApp() {
|
||||
super();
|
||||
LOGGER.info("Empty ChatApp constructor got called: ");
|
||||
@ -96,6 +99,10 @@ public class ChatApp extends Application {
|
||||
return chatController;
|
||||
}
|
||||
|
||||
public LoungeSceneViewController getLoungeSceneViewController() {
|
||||
return loungeSceneViewController;
|
||||
}
|
||||
|
||||
public LoungeSceneViewController getlSVController() {
|
||||
return lSVController;
|
||||
}
|
||||
@ -122,20 +129,24 @@ public class ChatApp extends Application {
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
this.setcModel(clientModel);
|
||||
this.setGameC(gameController);
|
||||
this.setlSVController(loungeSceneViewController);
|
||||
|
||||
gameC.setClient(cModel);
|
||||
gameC.setGameStateModel(GameController.getGameStateModel());
|
||||
URL chatResource = ChatApp.class.getResource(
|
||||
"chat/ChatView.fxml");
|
||||
URL gameResource = ChatApp.class.getResource(
|
||||
"game/GameDayAll.fxml");
|
||||
try {
|
||||
URL chatResource = ChatApp.class.getResource("chat/ChatView.fxml");
|
||||
URL gameResource = ChatApp.class.getResource("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(
|
||||
"lounge/LoungeSceneView.fxml");
|
||||
try {
|
||||
Parent lounge = FXMLLoader.load(
|
||||
Objects.requireNonNull(loungeResource));
|
||||
Node chat = FXMLLoader.load(Objects.requireNonNull(chatResource));
|
||||
Node game = FXMLLoader.load(Objects.requireNonNull(gameResource));
|
||||
this.setlSVController(loungeSceneViewController);
|
||||
lSVController.setChatApp(this);
|
||||
// TODO bin chatController.getChatPaneRoot() border to root border for rezising
|
||||
Scene scene = new Scene(lounge);
|
||||
scene.setRoot(lounge);
|
||||
|
||||
@ -11,8 +11,10 @@ import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
@ -28,7 +30,6 @@ import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListCell;
|
||||
@ -50,9 +51,13 @@ public class LoungeSceneViewController implements Initializable {
|
||||
public static final BudaLogConfig l = new BudaLogConfig(LOGGER);
|
||||
|
||||
@FXML
|
||||
public Button leaveLobbyButton;
|
||||
private Button leaveLobbyButton;
|
||||
@FXML
|
||||
public Button newGameButton;
|
||||
private Button startGame;
|
||||
@FXML
|
||||
private Button newGameButton;
|
||||
@FXML
|
||||
private AnchorPane gameAnchorPane;
|
||||
@FXML
|
||||
private ListView<LobbyListItem> LobbyListView;
|
||||
@FXML
|
||||
@ -71,7 +76,8 @@ public class LoungeSceneViewController implements Initializable {
|
||||
private ToolBar NTtBToolBar;
|
||||
|
||||
public static ClientModel client;
|
||||
public static ChatApp chatApp;
|
||||
private static ChatApp chatApp;
|
||||
private ChatApp cApp;
|
||||
|
||||
ObservableList<ClientListItem> clients = FXCollections.observableArrayList();
|
||||
ObservableList<LobbyListItem> lobbies = FXCollections.observableArrayList();
|
||||
@ -84,6 +90,13 @@ public class LoungeSceneViewController implements Initializable {
|
||||
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.
|
||||
@ -95,6 +108,7 @@ public class LoungeSceneViewController implements Initializable {
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
ChatApp.setLoungeSceneViewController(this);
|
||||
setcApp(chatApp);
|
||||
ChangeNameButton.setOnAction(event -> changeName());
|
||||
LeaveServerButton.setOnAction(event -> leaveServer());
|
||||
newGameButton.setOnAction(event -> newGame());
|
||||
@ -264,20 +278,59 @@ public class LoungeSceneViewController implements Initializable {
|
||||
});
|
||||
|
||||
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) {
|
||||
ObservableList<ClientListItem> clientsLeft = ClientListView.getItems();
|
||||
public void addGameView(){
|
||||
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);
|
||||
this.ClientListView.setItems(names);
|
||||
for (ClientListItem gone : clientsLeft) {
|
||||
for (SimpleStringProperty gone : clientsLeft) {
|
||||
//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 player
|
||||
*/
|
||||
@ -312,12 +365,13 @@ public class LoungeSceneViewController implements Initializable {
|
||||
LobbyListView.getItems().add(item);
|
||||
}
|
||||
|
||||
private void joinGame(String lobbyID) {
|
||||
public void joinGame(String lobbyID) {
|
||||
client.getClient().sendMsgToServer(Protocol.joinLobby + "$" + lobbyID);
|
||||
}
|
||||
|
||||
private void startGame() {
|
||||
public void startGame() {
|
||||
client.getClient().sendMsgToServer(Protocol.startANewGame);
|
||||
//addGameView();
|
||||
}
|
||||
|
||||
public void leaveLobby() {
|
||||
|
||||
@ -104,7 +104,7 @@ public class JServerProtocolParser {
|
||||
break;
|
||||
case Protocol.leaveLobby:
|
||||
h.leaveLobby();
|
||||
//h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToStart + "$"); (commented out due to compiling error)
|
||||
h.sendMsgToClient(Protocol.printToGUI + "$" + GuiParameters.viewChangeToStart + "$");
|
||||
break;
|
||||
case Protocol.votedFor:
|
||||
LOGGER.debug("Made it here");
|
||||
@ -113,7 +113,7 @@ public class JServerProtocolParser {
|
||||
break;
|
||||
case Protocol.startANewGame:
|
||||
h.startNewGame();
|
||||
//h.sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToGame + "$"); (commented out due to compiling error)
|
||||
h.sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.viewChangeToGame + "$");
|
||||
break;
|
||||
case Protocol.listGames:
|
||||
h.listGames();
|
||||
|
||||
@ -22,7 +22,9 @@
|
||||
<center>
|
||||
<AnchorPane BorderPane.alignment="CENTER">
|
||||
<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>
|
||||
</AnchorPane>
|
||||
</center>
|
||||
|
||||
Reference in New Issue
Block a user