Deleted more methods associated with the player list that are not needed anymore.
The ChatView is now directly added to the anchor pone in the "Bottom"Child of the BorderPane representing the LoungeSceneView.fxml Root
This commit is contained in:
parent
b605669395
commit
65303a4bb6
@ -368,10 +368,6 @@ public class Client {
|
||||
case GuiParameters.VoteIsOver:
|
||||
chatApp.getGameController().clearAllNoiseDisplay();
|
||||
break;
|
||||
case GuiParameters.listOfPLayers:
|
||||
updateListOfClients(data);
|
||||
//TODO
|
||||
break;
|
||||
case GuiParameters.getMembersInLobby:
|
||||
updateLobbyMembers(data);
|
||||
break;
|
||||
@ -392,9 +388,6 @@ public class Client {
|
||||
case GuiParameters.newLobbyCreated:
|
||||
makeNewLobby(data);
|
||||
break;
|
||||
case GuiParameters.newPlayerOnServer:
|
||||
addNewPlayerToGui(data);
|
||||
break;
|
||||
case GuiParameters.updateHighScore:
|
||||
chatApp.getLoungeSceneViewController().addHighScore(data);
|
||||
break;
|
||||
@ -422,11 +415,6 @@ public class Client {
|
||||
LOGGER.debug("Made it into removeLobbyFromGui()");
|
||||
}
|
||||
|
||||
private void addNewPlayerToGui(String data) {
|
||||
loungeSceneViewController.addClientToList(data);
|
||||
LOGGER.debug("addNewPlayerToGui() seems to have finished");
|
||||
}
|
||||
|
||||
private void makeNewLobby(String data) {
|
||||
String[] params = data.split(":");
|
||||
loungeSceneViewController.newLobby(params[0], params[1]);
|
||||
@ -457,14 +445,6 @@ public class Client {
|
||||
//TODO
|
||||
}
|
||||
|
||||
private void updateListOfClients(String data) {
|
||||
String[] arr = data.split(":");
|
||||
ObservableList<SimpleStringProperty> list = new SimpleListProperty<>();
|
||||
int n = arr.length;
|
||||
for (int i = 0; i < n; i = i + 1) {
|
||||
loungeSceneViewController.addClientToList(arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new thread, thad adds a message to notificationText in the gameController, waits 3
|
||||
|
||||
@ -61,10 +61,6 @@ public class LoungeSceneViewController implements Initializable {
|
||||
@FXML
|
||||
private SplitPane chatSplitPane;
|
||||
@FXML
|
||||
private AnchorPane chatAnchorPane;
|
||||
@FXML
|
||||
private AnchorPane otherNotificationAnchorPane;
|
||||
@FXML
|
||||
public Button highScoreButton;
|
||||
@FXML
|
||||
private Button leaveLobbyButton;
|
||||
@ -79,8 +75,6 @@ public class LoungeSceneViewController implements Initializable {
|
||||
@FXML
|
||||
public ListView<LobbyListItem> LobbyListView;
|
||||
@FXML
|
||||
public ListView<ClientListItem> ClientListView;
|
||||
@FXML
|
||||
private Button ChangeNameButton;
|
||||
@FXML
|
||||
private Button LeaveServerButton;
|
||||
@ -92,7 +86,6 @@ public class LoungeSceneViewController implements Initializable {
|
||||
private ToolBar NTtBToolBar;
|
||||
|
||||
public static ListView<LobbyListItem> lListView;
|
||||
public static ListView<ClientListItem> cListView;
|
||||
|
||||
public static ClientModel client;
|
||||
private static ChatApp chatApp;
|
||||
@ -145,92 +138,12 @@ public class LoungeSceneViewController implements Initializable {
|
||||
newGameButton.setOnAction(event -> newGame());
|
||||
LobbyListView.setVisible(true);
|
||||
lListView = LobbyListView;
|
||||
cListView = ClientListView;
|
||||
LOGGER.debug("Lobby in initialize" + LobbyListView);
|
||||
ClientListView.setVisible(true);
|
||||
ClientListView.setItems(clients);
|
||||
addChatView();
|
||||
addBackgroundDay();
|
||||
LOGGER.debug("cApp = " + cApp);
|
||||
LOGGER.debug("chatApp = " + chatApp);
|
||||
TrainAnimationDayController.setcApp(cApp);
|
||||
|
||||
ClientListView.setItems(clients);
|
||||
ClientListView.setCellFactory(param -> {
|
||||
ListCell<ClientListItem> cell = new ListCell<>() {
|
||||
Label name = new Label();
|
||||
Label id = new Label();
|
||||
HBox nameAndId = new HBox(name, id);
|
||||
|
||||
{
|
||||
nameAndId.setAlignment(Pos.CENTER_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* The updateItem method should not be called by developers, but it is the
|
||||
* best method for developers to override to allow for them to customise the
|
||||
* visuals of the cell. To clarify, developers should never call this method
|
||||
* in their code (they should leave it up to the UI control, such as the
|
||||
* {@link ListView} control) to call this method. However, the purpose of
|
||||
* having the updateItem method is so that developers, when specifying
|
||||
* custom cell factories (again, like the ListView {@link
|
||||
* ListView#cellFactoryProperty() cell factory}), the updateItem method can
|
||||
* be overridden to allow for complete customisation of the cell.
|
||||
*
|
||||
* <p>It is <strong>very important</strong> that subclasses
|
||||
* of Cell override the updateItem method properly, as failure to do so will
|
||||
* lead to issues such as blank cells or cells with unexpected content
|
||||
* appearing within them. Here is an example of how to properly override the
|
||||
* updateItem method:
|
||||
*
|
||||
* <pre>
|
||||
* protected void updateItem(T item, boolean empty) {
|
||||
* super.updateItem(item, empty);
|
||||
*
|
||||
* if (empty || item == null) {
|
||||
* setText(null);
|
||||
* setGraphic(null);
|
||||
* } else {
|
||||
* setText(item.toString());
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>Note in this code sample two important points:
|
||||
* <ol>
|
||||
* <li>We call the super.updateItem(T, boolean) method. If this is not
|
||||
* done, the item and empty properties are not correctly set, and you are
|
||||
* likely to end up with graphical issues.</li>
|
||||
* <li>We test for the <code>empty</code> condition, and if true, we
|
||||
* set the text and graphic properties to null. If we do not do this,
|
||||
* it is almost guaranteed that end users will see graphical artifacts
|
||||
* in cells unexpectedly.</li>
|
||||
* </ol>
|
||||
* @param item The new item for the cell.
|
||||
*
|
||||
* @param empty whether or not this cell represents data from the list. If
|
||||
* it is empty, then it does not represent any domain data, but
|
||||
* is a cell
|
||||
*/
|
||||
@Override
|
||||
protected void updateItem(ClientListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
LOGGER.debug("In updateItem(item, empty) Method. Else branch -> nonnull item");
|
||||
name.setText(item.getName());
|
||||
name.setTextFill(Color.BLACK);
|
||||
id.setText(String.valueOf(item.getId()));
|
||||
id.setTextFill(Color.BLACK);
|
||||
setGraphic(nameAndId);
|
||||
}
|
||||
}
|
||||
};
|
||||
return cell;
|
||||
});
|
||||
|
||||
LobbyListView.setItems(lobbies);
|
||||
LOGGER.debug("In Initialize 2 LobbyListView" + LobbyListView);
|
||||
LobbyListView.setCellFactory(param -> {
|
||||
@ -375,7 +288,7 @@ public class LoungeSceneViewController implements Initializable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
chatAnchorPane.getChildren().add(chatApp.chat);
|
||||
ChatArea.getChildren().add(chatApp.chat);
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Not yet initialized: chatAnchorPane");
|
||||
}
|
||||
@ -493,45 +406,6 @@ public class LoungeSceneViewController implements Initializable {
|
||||
client.getClient().sendMsgToServer(Protocol.clientQuitRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to add a new player to the list of players. "NPLOS" {@link ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters}
|
||||
*
|
||||
* @param s the information corresponding to to the client in String from
|
||||
*/
|
||||
public void addClientToList(String s) {
|
||||
ClientListItem cl = new ClientListItem(s);
|
||||
ClientListView = cListView;
|
||||
Platform.runLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
clients.add(cl);
|
||||
LOGGER.debug("in addClientToList() in run()");
|
||||
LOGGER.debug(cl.toString() + " in run()");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sould remove a client of a certain name from the ListView
|
||||
*
|
||||
* @param name the name of the client to be removed
|
||||
*/
|
||||
public void removeClientFromList(String name) {
|
||||
Iterator<ClientListItem> it = clients.iterator();
|
||||
while (it.hasNext()) {
|
||||
String uid = it.next().getName();
|
||||
if (uid.equals(name)) {
|
||||
it.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeClientFromLobby(String s) {
|
||||
//todo
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the create New Lobby Protocol message
|
||||
*/
|
||||
|
||||
@ -34,9 +34,13 @@
|
||||
</AnchorPane>
|
||||
</center>
|
||||
<bottom>
|
||||
<AnchorPane fx:id="ChatArea" pickOnBounds="false" BorderPane.alignment="CENTER">
|
||||
<AnchorPane fx:id="ChatArea" pickOnBounds="false" prefHeight="83.0" prefWidth="578.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<SplitPane fx:id="chatSplitPane" minHeight="50.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
<SplitPane fx:id="chatSplitPane" disable="true" dividerPositions="0.5" layoutY="-34.0" minHeight="50.0" prefHeight="46.0" prefWidth="578.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<items>
|
||||
<AnchorPane fx:id="ChatArea" prefHeight="200.0" prefWidth="200.0" />
|
||||
<AnchorPane prefHeight="200.0" prefWidth="200.0" />
|
||||
</items></SplitPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</bottom>
|
||||
@ -56,6 +60,5 @@
|
||||
</left>
|
||||
</BorderPane>
|
||||
<AnchorPane fx:id="gameDisplayAnchorPane" pickOnBounds="false" />
|
||||
<Line endX="100.0" startX="-100.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
||||
Reference in New Issue
Block a user