mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
When a player connects to the server, lobby will now show their user id and profile instead of showing all the profile gif at the beginning,
#story[1055] #pair[hyi25, zyt10]
This commit is contained in:
@@ -153,7 +153,7 @@ public class ClientToServerThread implements Runnable {
|
|||||||
try {
|
try {
|
||||||
socket.close();
|
socket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("IO error in server thread upon trying to close socket");
|
clientLog("Failed to close the socket", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
package seng302.controllers;
|
package seng302.controllers;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.Inet4Address;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.NetworkInterface;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -84,6 +80,10 @@ public class LobbyController implements Initializable, Observer{
|
|||||||
private static ObservableList<String> seventhCompetitor = FXCollections.observableArrayList();
|
private static ObservableList<String> seventhCompetitor = FXCollections.observableArrayList();
|
||||||
private static ObservableList<String> eighthCompetitor = FXCollections.observableArrayList();
|
private static ObservableList<String> eighthCompetitor = FXCollections.observableArrayList();
|
||||||
private ClientStateQueryingRunnable clientStateQueryingRunnable;
|
private ClientStateQueryingRunnable clientStateQueryingRunnable;
|
||||||
|
private static List<ImageView> gifImageViews;
|
||||||
|
private static List<ListView> listViews;
|
||||||
|
|
||||||
|
private int MAX_NUM_PLAYERS = 8;
|
||||||
|
|
||||||
private Boolean switchedPane = false;
|
private Boolean switchedPane = false;
|
||||||
private MainServerThread mainServerThread;
|
private MainServerThread mainServerThread;
|
||||||
@@ -113,8 +113,18 @@ public class LobbyController implements Initializable, Observer{
|
|||||||
lobbyIpText.setText("Connected to IP: ");
|
lobbyIpText.setText("Connected to IP: ");
|
||||||
readyButton.setDisable(true);
|
readyButton.setDisable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gifImageViews = new ArrayList<>();
|
||||||
|
Collections.addAll(gifImageViews, firstImageView, secondImageView, thirdImageView, fourthImageView,
|
||||||
|
fifthImageView, sixthImageView, seventhImageView, eighthImageView);
|
||||||
|
listViews = new ArrayList<>();
|
||||||
|
Collections.addAll(listViews, firstListView, secondListView, thirdListView, fourthListView, fifthListView,
|
||||||
|
sixthListView, seventhListView, eighthListView);
|
||||||
|
competitors = new ArrayList<>();
|
||||||
|
Collections.addAll(competitors, firstCompetitor, secondCompetitor, thirdCompetitor,
|
||||||
|
fourthCompetitor, fifthCompetitor, sixthCompetitor, seventhCompetitor, eighthCompetitor);
|
||||||
|
|
||||||
initialiseListView();
|
initialiseListView();
|
||||||
// initialiseLobbyControllerThread();
|
|
||||||
initialiseImageView(); // parrot gif init
|
initialiseImageView(); // parrot gif init
|
||||||
|
|
||||||
// set up client state query thread, so that when it receives the race-started packet
|
// set up client state query thread, so that when it receives the race-started packet
|
||||||
@@ -142,45 +152,16 @@ public class LobbyController implements Initializable, Observer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initialiseListView() {
|
private void initialiseListView() {
|
||||||
firstListView.getItems().clear();
|
listViews.forEach(listView -> listView.getItems().clear());
|
||||||
secondListView.getItems().clear();
|
gifImageViews.forEach(gif -> gif.setVisible(false));
|
||||||
thirdListView.getItems().clear();
|
competitors.forEach(ol -> ol.removeAll());
|
||||||
fourthListView.getItems().clear();
|
|
||||||
fifthListView.getItems().clear();
|
|
||||||
sixthListView.getItems().clear();
|
|
||||||
seventhListView.getItems().clear();
|
|
||||||
eighthListView.getItems().clear();
|
|
||||||
|
|
||||||
competitors = new ArrayList<>();
|
List<Integer> ids = new ArrayList<>(ClientState.getBoats().keySet());
|
||||||
Collections.addAll(competitors, firstCompetitor, secondCompetitor, thirdCompetitor,
|
for (int i = 0; i < ids.size(); i++) {
|
||||||
fourthCompetitor, fifthCompetitor, sixthCompetitor, seventhCompetitor, eighthCompetitor);
|
competitors.get(i).add(String.format("Player ID: %d", ids.get(i)));
|
||||||
|
listViews.get(i).setItems(competitors.get(i));
|
||||||
for (ObservableList<String> ol : competitors) {
|
gifImageViews.get(i).setVisible(true);
|
||||||
ol.removeAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
firstCompetitor.add(ClientState.getClientSourceId());
|
|
||||||
|
|
||||||
int competitorIndex = 1;
|
|
||||||
for (Integer yachtId : ClientState.getBoats().keySet()) {
|
|
||||||
// break if there are more than 7 competitors
|
|
||||||
if (competitorIndex >= 8) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!yachtId.equals(Integer.parseInt(ClientState.getClientSourceId()))) {
|
|
||||||
competitors.get(competitorIndex).add(String.valueOf(yachtId));
|
|
||||||
competitorIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
firstListView.setItems(firstCompetitor);
|
|
||||||
secondListView.setItems(secondCompetitor);
|
|
||||||
thirdListView.setItems(thirdCompetitor);
|
|
||||||
fourthListView.setItems(fourthCompetitor);
|
|
||||||
fifthListView.setItems(fifthCompetitor);
|
|
||||||
sixthListView.setItems(sixthCompetitor);
|
|
||||||
seventhListView.setItems(seventhCompetitor);
|
|
||||||
eighthListView.setItems(eighthCompetitor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialiseLobbyControllerThread() {
|
private void initialiseLobbyControllerThread() {
|
||||||
|
|||||||
Reference in New Issue
Block a user