mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
- Deleted old controllers that didn't do anything anymore.
tags : #story[1245]
This commit is contained in:
@@ -44,7 +44,6 @@ import seng302.utilities.XMLGenerator;
|
|||||||
import seng302.utilities.XMLParser;
|
import seng302.utilities.XMLParser;
|
||||||
import seng302.visualiser.controllers.FinishScreenViewController;
|
import seng302.visualiser.controllers.FinishScreenViewController;
|
||||||
import seng302.visualiser.controllers.LobbyController;
|
import seng302.visualiser.controllers.LobbyController;
|
||||||
import seng302.visualiser.controllers.LobbyController_old;
|
|
||||||
import seng302.visualiser.controllers.RaceViewController;
|
import seng302.visualiser.controllers.RaceViewController;
|
||||||
import seng302.visualiser.controllers.ViewManager;
|
import seng302.visualiser.controllers.ViewManager;
|
||||||
|
|
||||||
@@ -201,23 +200,6 @@ public class GameClient {
|
|||||||
socketThread.addStreamObserver(this::parsePackets);
|
socketThread.addStreamObserver(this::parsePackets);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads a view of the lobby into the clients pane
|
|
||||||
*
|
|
||||||
* @return the lobby controller.
|
|
||||||
*/
|
|
||||||
private LobbyController_old loadLobby() {
|
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(
|
|
||||||
GameClient.class.getResource("/views/LobbyView.fxml"));
|
|
||||||
try {
|
|
||||||
holderPane.getChildren().clear();
|
|
||||||
holderPane.getChildren().add(fxmlLoader.load());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return fxmlLoader.getController();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadRaceView() {
|
private void loadRaceView() {
|
||||||
FXMLLoader fxmlLoader = loadFXMLToHolder("/views/RaceView.fxml");
|
FXMLLoader fxmlLoader = loadFXMLToHolder("/views/RaceView.fxml");
|
||||||
holderPane.getScene().setOnKeyPressed(this::keyPressed);
|
holderPane.getScene().setOnKeyPressed(this::keyPressed);
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
package seng302.visualiser.controllers;
|
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.control.ColorPicker;
|
|
||||||
import javafx.scene.control.TextField;
|
|
||||||
import javafx.scene.paint.Color;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import seng302.gameServer.messages.CustomizeRequestType;
|
|
||||||
import seng302.utilities.Sounds;
|
|
||||||
import seng302.visualiser.ClientToServerThread;
|
|
||||||
|
|
||||||
public class CustomizationController_old {
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private TextField nameField;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private ColorPicker boatColorPicker;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button customizeSubmit;
|
|
||||||
|
|
||||||
private LobbyController_old lc;
|
|
||||||
private ClientToServerThread socketThread;
|
|
||||||
private Stage windowStage;
|
|
||||||
|
|
||||||
public void initialize() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setServerThread(ClientToServerThread ctsThread) {
|
|
||||||
this.socketThread = ctsThread;
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void submitCustomization() {
|
|
||||||
Sounds.playButtonClick();
|
|
||||||
// System.out.println("Attempting to send");
|
|
||||||
socketThread.sendCustomizationRequest(CustomizeRequestType.NAME, nameField.getText().getBytes());
|
|
||||||
// TODO: 16/08/17 ajm412: Turn colors into byte array.
|
|
||||||
Color color = boatColorPicker.getValue();
|
|
||||||
|
|
||||||
short red = (short) (color.getRed() * 255);
|
|
||||||
short green = (short) (color.getGreen() * 255);
|
|
||||||
short blue = (short) (color.getBlue() * 255);
|
|
||||||
|
|
||||||
byte[] colorArray = new byte[3];
|
|
||||||
|
|
||||||
colorArray[0] = (byte) red;
|
|
||||||
colorArray[1] = (byte) green;
|
|
||||||
colorArray[2] = (byte) blue;
|
|
||||||
|
|
||||||
socketThread.sendCustomizationRequest(CustomizeRequestType.COLOR, colorArray);
|
|
||||||
lc.setPlayersColor(color);
|
|
||||||
windowStage.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLobbyController(LobbyController_old lc) {
|
|
||||||
this.lc = lc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStage(Stage stage) {
|
|
||||||
this.windowStage = stage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayerName(String name) {
|
|
||||||
this.nameField.setText(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayerColor(Color playerColor) {
|
|
||||||
this.boatColorPicker.setValue(playerColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -52,7 +52,6 @@ public class LobbyController implements Initializable {
|
|||||||
private Pane serverMap;
|
private Pane serverMap;
|
||||||
//---------FXML END---------//
|
//---------FXML END---------//
|
||||||
|
|
||||||
private List<LobbyController_old.LobbyCloseListener> lobbyListeners = new ArrayList<>();
|
|
||||||
private RaceState raceState;
|
private RaceState raceState;
|
||||||
private JFXDialog customizationDialog;
|
private JFXDialog customizationDialog;
|
||||||
public Color playersColor;
|
public Color playersColor;
|
||||||
@@ -216,6 +215,7 @@ public class LobbyController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void leaveLobby() {
|
private void leaveLobby() {
|
||||||
|
|
||||||
ViewManager.getInstance().getGameClient().stopGame();
|
ViewManager.getInstance().getGameClient().stopGame();
|
||||||
ViewManager.getInstance().goToStartView();
|
ViewManager.getInstance().goToStartView();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,249 +0,0 @@
|
|||||||
package seng302.visualiser.controllers;
|
|
||||||
|
|
||||||
import com.sun.media.jfxmedia.logging.Logger;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.collections.ListChangeListener;
|
|
||||||
import javafx.collections.ObservableList;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.Parent;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.control.Button;
|
|
||||||
import javafx.scene.control.TextArea;
|
|
||||||
import javafx.scene.image.Image;
|
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
import javafx.scene.paint.Color;
|
|
||||||
import javafx.scene.text.Text;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import seng302.gameServer.GameStages;
|
|
||||||
import seng302.gameServer.GameState;
|
|
||||||
import seng302.model.Colors;
|
|
||||||
import seng302.model.RaceState;
|
|
||||||
import seng302.visualiser.ClientToServerThread;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A class describing the actions of the lobby screen
|
|
||||||
* Created by wmu16 on 10/07/17.
|
|
||||||
*/
|
|
||||||
public class LobbyController_old {
|
|
||||||
|
|
||||||
public enum CloseStatus {
|
|
||||||
LEAVE,
|
|
||||||
READY
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface LobbyCloseListener {
|
|
||||||
void notify(CloseStatus exitCause);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Text lobbyIpText;
|
|
||||||
@FXML
|
|
||||||
private Button readyButton;
|
|
||||||
@FXML
|
|
||||||
private Button customizeButton;
|
|
||||||
@FXML
|
|
||||||
private TextArea playerOneTxt;
|
|
||||||
@FXML
|
|
||||||
private TextArea playerTwoTxt;
|
|
||||||
@FXML
|
|
||||||
private TextArea playerThreeTxt;
|
|
||||||
@FXML
|
|
||||||
private TextArea playerFourTxt;
|
|
||||||
@FXML
|
|
||||||
private TextArea playerFiveTxt;
|
|
||||||
@FXML
|
|
||||||
private TextArea playerSixTxt;
|
|
||||||
@FXML
|
|
||||||
private TextArea playerSevenTxt;
|
|
||||||
@FXML
|
|
||||||
private TextArea playerEightTxt;
|
|
||||||
@FXML
|
|
||||||
private ImageView firstImageView;
|
|
||||||
@FXML
|
|
||||||
private ImageView secondImageView;
|
|
||||||
@FXML
|
|
||||||
private ImageView thirdImageView;
|
|
||||||
@FXML
|
|
||||||
private ImageView fourthImageView;
|
|
||||||
@FXML
|
|
||||||
private ImageView fifthImageView;
|
|
||||||
@FXML
|
|
||||||
private ImageView sixthImageView;
|
|
||||||
@FXML
|
|
||||||
private ImageView seventhImageView;
|
|
||||||
@FXML
|
|
||||||
private ImageView eighthImageView;
|
|
||||||
@FXML
|
|
||||||
private Text timeUntilStart;
|
|
||||||
@FXML
|
|
||||||
private Text courseNameText;
|
|
||||||
|
|
||||||
private List<ImageView> imageViews = new ArrayList<>();
|
|
||||||
private List<TextArea> listViews = new ArrayList<>();
|
|
||||||
private RaceState raceState;
|
|
||||||
|
|
||||||
private ClientToServerThread socketThread;
|
|
||||||
|
|
||||||
private Stage customizeStage;
|
|
||||||
|
|
||||||
private Color playersColor;
|
|
||||||
|
|
||||||
private int MAX_NUM_PLAYERS = 8;
|
|
||||||
private Integer playerID;
|
|
||||||
|
|
||||||
private List<LobbyCloseListener> lobbyListeners = new ArrayList<>();
|
|
||||||
private ObservableList<String> players;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add all FXObjects to lists and initialize images.
|
|
||||||
*/
|
|
||||||
public void initialize() {
|
|
||||||
Collections.addAll(listViews,
|
|
||||||
playerOneTxt, playerTwoTxt, playerThreeTxt, playerFourTxt, playerFiveTxt, playerSixTxt,
|
|
||||||
playerSevenTxt, playerEightTxt
|
|
||||||
);
|
|
||||||
Collections.addAll(imageViews,
|
|
||||||
firstImageView, secondImageView, thirdImageView, fourthImageView,
|
|
||||||
fifthImageView, sixthImageView, seventhImageView, eighthImageView
|
|
||||||
);
|
|
||||||
initialiseImageView();
|
|
||||||
|
|
||||||
timeUntilStart.setText("Waiting For Host...");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates player names.
|
|
||||||
*/
|
|
||||||
private void updatePlayers() {
|
|
||||||
//Update players if one added.
|
|
||||||
for (int i = 0; i < players.size(); i++) {
|
|
||||||
listViews.get(i).setText(players.get(i));
|
|
||||||
if (playerID == (i + 1)) {
|
|
||||||
listViews.get(i).setText(listViews.get(i).getText() + " (YOU)");
|
|
||||||
}
|
|
||||||
imageViews.get(i).setVisible(true);
|
|
||||||
}
|
|
||||||
//Update empty text fields if player left.
|
|
||||||
for (int i = MAX_NUM_PLAYERS-1; i >= players.size(); i--) {
|
|
||||||
listViews.get(i).setText("");
|
|
||||||
imageViews.get(i).setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets all images and hides them till players join.
|
|
||||||
*/
|
|
||||||
private void initialiseImageView() {
|
|
||||||
for (ImageView viewer : imageViews) {
|
|
||||||
viewer.setImage(
|
|
||||||
new Image(
|
|
||||||
RaceViewController.class.getResourceAsStream(
|
|
||||||
"/pics/sail.png")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
viewer.setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void customize() {
|
|
||||||
Parent root;
|
|
||||||
try {
|
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(LobbyController_old.class.getResource("/views/customizeView.fxml"));
|
|
||||||
root = fxmlLoader.load();
|
|
||||||
root.getStylesheets().add("/css/master.css");
|
|
||||||
customizeStage = new Stage();
|
|
||||||
customizeStage.setTitle("Customize Boat");
|
|
||||||
customizeStage.setScene(new Scene(root, 700, 450));
|
|
||||||
CustomizationController_old cc = fxmlLoader.getController();
|
|
||||||
cc.setServerThread(this.socketThread);
|
|
||||||
cc.setPlayerName(this.players.get(playerID - 1));
|
|
||||||
|
|
||||||
if (this.playersColor == null) {
|
|
||||||
this.playersColor = Colors.getColor(playerID - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
cc.setPlayerColor(this.playersColor);
|
|
||||||
cc.setStage(customizeStage); // pass the stage through so it can be closed later.
|
|
||||||
cc.setLobbyController(this);
|
|
||||||
customizeStage.show();
|
|
||||||
} catch (IOException e) {
|
|
||||||
Logger.logMsg(4, "Failed to load Customization View from resources.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSocketThread(ClientToServerThread thread) {
|
|
||||||
this.socketThread = thread;
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void leaveLobbyButtonPressed() {
|
|
||||||
// TODO: 10/07/17 wmu16 - Finish function!
|
|
||||||
GameState.setCurrentStage(GameStages.CANCELLED);
|
|
||||||
// TODO: 20/07/17 wmu16 - Implement some way of terminating the game
|
|
||||||
for (LobbyCloseListener readyListener : lobbyListeners)
|
|
||||||
readyListener.notify(CloseStatus.LEAVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void readyButtonPressed() {
|
|
||||||
GameState.setCurrentStage(GameStages.PRE_RACE);
|
|
||||||
// Do countdown logic here
|
|
||||||
|
|
||||||
for (LobbyCloseListener readyListener : lobbyListeners)
|
|
||||||
readyListener.notify(CloseStatus.READY);
|
|
||||||
customizeButton.setDisable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle (String title) {
|
|
||||||
lobbyIpText.setText(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCourseName(String courseName){
|
|
||||||
courseNameText.setText(courseName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addCloseListener(LobbyCloseListener listener) {
|
|
||||||
lobbyListeners.add(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayerListSource (ObservableList<String> players) {
|
|
||||||
this.players = players;
|
|
||||||
players.addListener((ListChangeListener<? super String>) (lcl) ->
|
|
||||||
Platform.runLater(this::updatePlayers)
|
|
||||||
);
|
|
||||||
Platform.runLater(this::updatePlayers);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayerID(Integer id) {
|
|
||||||
playerID = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateRaceState(RaceState raceState){
|
|
||||||
this.raceState = raceState;
|
|
||||||
/*if (this.customizeStage != null) {
|
|
||||||
this.customizeStage.close();
|
|
||||||
}*/ // TODO: 17/08/17 ajm412: close the customization window if the host starts the game while customizing
|
|
||||||
if (!customizeButton.isDisabled()) {
|
|
||||||
customizeButton.setDisable(true);
|
|
||||||
}
|
|
||||||
timeUntilStart.setText("Starting in: " + raceState.getRaceTimeStr());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disableReadyButton () {
|
|
||||||
readyButton.setDisable(true);
|
|
||||||
readyButton.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO here newui
|
|
||||||
public void setPlayersColor(Color playerColor) {
|
|
||||||
this.playersColor = playerColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.ColorPicker?>
|
|
||||||
<?import javafx.scene.control.TextField?>
|
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
|
||||||
<?import javafx.scene.layout.GridPane?>
|
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
|
||||||
<?import javafx.scene.text.Text?>
|
|
||||||
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
|
|
||||||
prefHeight="400.0" prefWidth="600.0" style="-fx-background-color: #2C2c36;"
|
|
||||||
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
|
||||||
fx:controller="seng302.visualiser.controllers.CustomizationController_old">
|
|
||||||
<columnConstraints>
|
|
||||||
<ColumnConstraints fillWidth="false" halignment="CENTER" hgrow="SOMETIMES"
|
|
||||||
maxWidth="1.7976931348623157E308" minWidth="1.0" percentWidth="10.0" prefWidth="1.0"/>
|
|
||||||
<ColumnConstraints fillWidth="false" halignment="CENTER" hgrow="SOMETIMES" maxWidth="299.0"
|
|
||||||
minWidth="10.0" percentWidth="30.0" prefWidth="299.0"/>
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="299.0" minWidth="10.0" percentWidth="50.0"
|
|
||||||
prefWidth="154.0"/>
|
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="123.0" minWidth="0.0" percentWidth="10.0"
|
|
||||||
prefWidth="122.0"/>
|
|
||||||
</columnConstraints>
|
|
||||||
<rowConstraints>
|
|
||||||
<RowConstraints minHeight="10.0" percentHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
|
||||||
<RowConstraints minHeight="10.0" percentHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
|
||||||
</rowConstraints>
|
|
||||||
<children>
|
|
||||||
<TextField fx:id="nameField" maxWidth="200.0" minWidth="200.0" prefWidth="200.0"
|
|
||||||
GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1"
|
|
||||||
GridPane.valignment="CENTER"/>
|
|
||||||
<ColorPicker fx:id="boatColorPicker" prefWidth="200.0" style="-fx-background-color: eeeeee;"
|
|
||||||
GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="2"
|
|
||||||
GridPane.valignment="CENTER"/>
|
|
||||||
<Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="Player Name"
|
|
||||||
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
|
||||||
<Text fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="Boat Color"
|
|
||||||
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
|
||||||
<Button fx:id="customizeSubmit" mnemonicParsing="false" onAction="#submitCustomization"
|
|
||||||
text="Submit" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3"
|
|
||||||
GridPane.valignment="CENTER"/>
|
|
||||||
</children>
|
|
||||||
</GridPane>
|
|
||||||
Reference in New Issue
Block a user