|
|
|
|
@ -3,6 +3,7 @@ package visualiser.Controllers;
|
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
|
import javafx.scene.control.TextField;
|
|
|
|
|
import javafx.scene.image.Image;
|
|
|
|
|
import javafx.scene.image.ImageView;
|
|
|
|
|
import javafx.scene.layout.AnchorPane;
|
|
|
|
|
import mock.app.Event;
|
|
|
|
|
@ -18,6 +19,8 @@ import javax.xml.parsers.ParserConfigurationException;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.Socket;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.ResourceBundle;
|
|
|
|
|
import java.util.logging.Level;
|
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
@ -48,9 +51,17 @@ public class HostController extends Controller {
|
|
|
|
|
|
|
|
|
|
private Event game;
|
|
|
|
|
|
|
|
|
|
private ArrayList<Image> listOfMaps;
|
|
|
|
|
private int currentMapIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void initialize(URL location, ResourceBundle resources) {
|
|
|
|
|
public void initialize(URL location, ResourceBundle resources){
|
|
|
|
|
Image ac35Map = new Image(getClass().getClassLoader().getResourceAsStream("images/AC35_Racecourse_MAP.png"));
|
|
|
|
|
Image oMap = new Image(getClass().getClassLoader().getResourceAsStream("images/oMapLayout.png"));
|
|
|
|
|
|
|
|
|
|
listOfMaps = new ArrayList(Arrays.asList(ac35Map, oMap));
|
|
|
|
|
mapImage.setImage(listOfMaps.get(currentMapIndex));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -59,7 +70,7 @@ public class HostController extends Controller {
|
|
|
|
|
*/
|
|
|
|
|
public void hostGamePressed() throws IOException{
|
|
|
|
|
try {
|
|
|
|
|
this.game = new Event(false);
|
|
|
|
|
this.game = new Event(false, currentMapIndex);
|
|
|
|
|
connectSocket("localhost", 4942);
|
|
|
|
|
} catch (EventConstructionException e) {
|
|
|
|
|
Logger.getGlobal().log(Level.SEVERE, "Could not create Event.", e);
|
|
|
|
|
@ -100,4 +111,21 @@ public class HostController extends Controller {
|
|
|
|
|
parent.enterTitle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void nextImage(){
|
|
|
|
|
increaseIndex();
|
|
|
|
|
mapImage.setImage(listOfMaps.get(currentMapIndex));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void previousImage(){
|
|
|
|
|
decreaseIndex();
|
|
|
|
|
mapImage.setImage(listOfMaps.get(currentMapIndex));
|
|
|
|
|
}
|
|
|
|
|
private void increaseIndex(){
|
|
|
|
|
currentMapIndex = (currentMapIndex + 1)%listOfMaps.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void decreaseIndex(){
|
|
|
|
|
currentMapIndex = ((((currentMapIndex - 1)%listOfMaps.size())+listOfMaps.size())%listOfMaps.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|