mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merged with remote changes
This commit is contained in:
@@ -44,20 +44,23 @@ public class HeartbeatThread implements Runnable {
|
||||
* The delegate is notified if a player has disconnected
|
||||
*/
|
||||
private void sendHeartbeatToAllPlayers(){
|
||||
Message heartbeat = new Heartbeat(seqNum);
|
||||
for (Player player : GameState.getPlayers()){
|
||||
if (!player.getSocket().isConnected()) {
|
||||
playerLostConnection(player);
|
||||
}
|
||||
|
||||
try {
|
||||
player.getSocket().getOutputStream().write(heartbeat.getBuffer());
|
||||
} catch (IOException e) {
|
||||
playerLostConnection(player);
|
||||
try {
|
||||
Message heartbeat = new Heartbeat(seqNum);
|
||||
for (Player player : GameState.getPlayers()) {
|
||||
if (!player.getSocket().isConnected()) {
|
||||
playerLostConnection(player);
|
||||
}
|
||||
try {
|
||||
player.getSocket().getOutputStream().write(heartbeat.getBuffer());
|
||||
} catch (IOException e) {
|
||||
playerLostConnection(player);
|
||||
}
|
||||
}
|
||||
updateDelegate();
|
||||
seqNum++;
|
||||
} catch (NullPointerException ne) {
|
||||
// TODO: 4/09/17 Just ignoring this at the moment. Caused by players getting removed elsewhere.
|
||||
}
|
||||
updateDelegate();
|
||||
seqNum++;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -234,7 +234,6 @@ public class GameClient {
|
||||
|
||||
private void parsePackets() {
|
||||
while (socketThread.getPacketQueue().peek() != null) {
|
||||
System.out.println("PARSING PACKET");
|
||||
StreamPacket packet = socketThread.getPacketQueue().poll();
|
||||
switch (packet.getType()) {
|
||||
case RACE_STATUS:
|
||||
@@ -298,8 +297,6 @@ public class GameClient {
|
||||
case CHATTER_TEXT:
|
||||
Pair<Integer, String> playerIdMessagePair = StreamParser
|
||||
.extractChatterText(packet);
|
||||
|
||||
System.out.println("playerIdMessagePair = " + playerIdMessagePair);
|
||||
raceView.updateChatHistory(
|
||||
allBoatsMap.get(playerIdMessagePair.getKey()).getColour(),
|
||||
playerIdMessagePair.getValue()
|
||||
|
||||
@@ -574,7 +574,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
yachtSelectionComboBox.setItems(
|
||||
FXCollections.observableArrayList(participants.values())
|
||||
);
|
||||
//Null check is if the listener is fired but nothing selected
|
||||
yachtSelectionComboBox.valueProperty().addListener((obs, lastSelection, selectedBoat) -> {
|
||||
if (selectedBoat != null) {
|
||||
gameView.selectBoat(selectedBoat);
|
||||
@@ -677,7 +676,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
}
|
||||
|
||||
public void updateChatHistory(Paint playerColour, String newMessage) {
|
||||
// Platform.runLater(() -> chatHistory.appendText(newMessage + "\n\n"));
|
||||
Platform.runLater(() -> chatHistory.addMessage(playerColour, newMessage));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,18 @@ public class ChatHistory extends ScrollPane {
|
||||
this.setMaxWidth(Double.MAX_VALUE);
|
||||
this.setVbarPolicy(ScrollBarPolicy.ALWAYS);
|
||||
this.setHbarPolicy(ScrollBarPolicy.NEVER);
|
||||
textFlow.getChildren().addListener((ListChangeListener<Node>) c -> {
|
||||
this.setVvalue(1.0);
|
||||
});
|
||||
//This makes the window auto scroll.
|
||||
textFlow.getChildren().addListener((ListChangeListener<Node>) c ->
|
||||
this.setVvalue(1.0)
|
||||
);
|
||||
//This just makes it so that the ChatHistory is on focus it passes it off to the parent.
|
||||
this.parentProperty().addListener((obs, old, parent) ->
|
||||
this.focusedProperty().addListener((obsVal, oldVal, onFocus) -> {
|
||||
if (onFocus) {
|
||||
parent.requestFocus();
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user