|
|
|
|
@ -4,6 +4,8 @@ import javafx.application.Platform;
|
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
|
import javafx.scene.control.Alert;
|
|
|
|
|
import javafx.scene.control.ButtonType;
|
|
|
|
|
import javafx.scene.control.Label;
|
|
|
|
|
import javafx.scene.control.Slider;
|
|
|
|
|
import javafx.scene.image.Image;
|
|
|
|
|
import javafx.scene.image.ImageView;
|
|
|
|
|
import mock.app.Event;
|
|
|
|
|
@ -28,8 +30,12 @@ import java.util.logging.Logger;
|
|
|
|
|
*/
|
|
|
|
|
public class HostGameController extends Controller {
|
|
|
|
|
private @FXML ImageView mapImage;
|
|
|
|
|
private @FXML Slider sliderLength;
|
|
|
|
|
private @FXML Label lblLength;
|
|
|
|
|
private ArrayList<Image> listOfMaps;
|
|
|
|
|
private int currentMapIndex = 0;
|
|
|
|
|
private int selectedRaceLength; // in minutes
|
|
|
|
|
private final int MAX_RACE_LENGTH = 30; // in minutes
|
|
|
|
|
private DatagramSocket udpSocket;
|
|
|
|
|
private MatchBrowserInterface matchBrowserInterface;
|
|
|
|
|
|
|
|
|
|
@ -37,8 +43,33 @@ public class HostGameController extends Controller {
|
|
|
|
|
loadMaps();
|
|
|
|
|
this.udpSocket = MatchBrowserSingleton.getInstance().getUdpSocket();
|
|
|
|
|
this.matchBrowserInterface = MatchBrowserSingleton.getInstance().getMatchBrowserInterface();
|
|
|
|
|
setRaceLengthSlider();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets up the values and display for a slider object which allows a user
|
|
|
|
|
* to select how many minutes long they would like their race to be.
|
|
|
|
|
*/
|
|
|
|
|
private void setRaceLengthSlider(){
|
|
|
|
|
// set the listener to update the label
|
|
|
|
|
sliderLength.valueProperty().addListener((ov, old_val, new_val) -> {
|
|
|
|
|
selectedRaceLength = new_val.intValue();
|
|
|
|
|
if (selectedRaceLength == 1){
|
|
|
|
|
lblLength.setText(selectedRaceLength + " minute.");
|
|
|
|
|
} else {
|
|
|
|
|
lblLength.setText(selectedRaceLength + " minutes.");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// set values and marks to be displayed
|
|
|
|
|
sliderLength.setMin(2);
|
|
|
|
|
sliderLength.setMax(MAX_RACE_LENGTH);
|
|
|
|
|
sliderLength.setShowTickLabels(true);
|
|
|
|
|
sliderLength.setMajorTickUnit(MAX_RACE_LENGTH-1);
|
|
|
|
|
sliderLength.setBlockIncrement(1);
|
|
|
|
|
|
|
|
|
|
sliderLength.getStylesheets().add("/css/slider.css");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -64,7 +95,8 @@ public class HostGameController extends Controller {
|
|
|
|
|
*/
|
|
|
|
|
public void hostGamePressed() {
|
|
|
|
|
try {
|
|
|
|
|
App.game = new Event(false, currentMapIndex);
|
|
|
|
|
App.game = new Event(false, currentMapIndex,
|
|
|
|
|
selectedRaceLength*60*1000);
|
|
|
|
|
App.gameType = currentMapIndex;
|
|
|
|
|
|
|
|
|
|
HttpMatchBrowserHost matchBrowserHost = new HttpMatchBrowserHost();
|
|
|
|
|
|