Updated the HostGame now has images for the maps and the map can be picked
#story[1193]
This commit is contained in:
@@ -78,12 +78,22 @@ public class Event {
|
|||||||
* @param singlePlayer Whether or not to create a single player event.
|
* @param singlePlayer Whether or not to create a single player event.
|
||||||
* @throws EventConstructionException Thrown if we cannot create an Event for any reason.
|
* @throws EventConstructionException Thrown if we cannot create an Event for any reason.
|
||||||
*/
|
*/
|
||||||
public Event(boolean singlePlayer) throws EventConstructionException {
|
public Event(boolean singlePlayer, int mapIndex) throws EventConstructionException {
|
||||||
|
|
||||||
System.out.println(XMLUtilities.validateXML(this.getClass().getClassLoader().getResource("mock/mockXML/iMapLayout.xml").toString()
|
System.out.println(XMLUtilities.validateXML(this.getClass().getClassLoader().getResource("mock/mockXML/iMapLayout.xml").toString()
|
||||||
, this.getClass().getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd")));
|
, this.getClass().getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd")));
|
||||||
//String raceXMLFile = "mock/mockXML/raceTest.xml";
|
|
||||||
String raceXMLFile = "mock/mockXML/iMapLayout.xml";
|
String raceXMLFile;
|
||||||
|
switch (mapIndex){
|
||||||
|
case 0:raceXMLFile = "mock/mockXML/raceTest.xml";
|
||||||
|
break;
|
||||||
|
case 1:raceXMLFile = "mock/mockXML/oMapLayout.xml";
|
||||||
|
break;
|
||||||
|
case 2: raceXMLFile = "mock/mockXML/iMapLayout.xml";
|
||||||
|
break;
|
||||||
|
default:raceXMLFile = "mock/mockXML/raceTest.xml";
|
||||||
|
|
||||||
|
}
|
||||||
String boatsXMLFile = "mock/mockXML/boatTest.xml";
|
String boatsXMLFile = "mock/mockXML/boatTest.xml";
|
||||||
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
|
String regattaXMLFile = "mock/mockXML/regattaTest.xml";
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package visualiser.Controllers;
|
|||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import mock.app.Event;
|
import mock.app.Event;
|
||||||
@@ -18,6 +19,8 @@ import javax.xml.parsers.ParserConfigurationException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -48,9 +51,17 @@ public class HostController extends Controller {
|
|||||||
|
|
||||||
private Event game;
|
private Event game;
|
||||||
|
|
||||||
|
private ArrayList<Image> listOfMaps;
|
||||||
|
private int currentMapIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@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{
|
public void hostGamePressed() throws IOException{
|
||||||
try {
|
try {
|
||||||
this.game = new Event(false);
|
this.game = new Event(false, currentMapIndex);
|
||||||
connectSocket("localhost", 4942);
|
connectSocket("localhost", 4942);
|
||||||
} catch (EventConstructionException e) {
|
} catch (EventConstructionException e) {
|
||||||
Logger.getGlobal().log(Level.SEVERE, "Could not create Event.", e);
|
Logger.getGlobal().log(Level.SEVERE, "Could not create Event.", e);
|
||||||
@@ -100,4 +111,21 @@ public class HostController extends Controller {
|
|||||||
parent.enterTitle();
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="170.0" minWidth="10.0" prefWidth="170.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="170.0" minWidth="10.0" prefWidth="170.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="60.0" minHeight="60.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="453.0" minHeight="10.0" prefHeight="435.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="435.0" vgrow="SOMETIMES" />
|
||||||
<RowConstraints maxHeight="194.0" minHeight="10.0" prefHeight="50.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="60.0" minHeight="60.0" prefHeight="50.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Button fx:id="hostGameBtn" mnemonicParsing="false" onAction="#hostGamePressed" text="Start Game" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER">
|
<Button fx:id="hostGameBtn" mnemonicParsing="false" onAction="#hostGamePressed" text="Start Game" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER">
|
||||||
@@ -43,13 +43,9 @@
|
|||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
</GridPane.margin></Button>
|
</GridPane.margin></Button>
|
||||||
<ImageView fx:id="mapImage" fitHeight="500.0" fitWidth="450.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS">
|
<ImageView fx:id="mapImage" fitHeight="500.0" fitWidth="450.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" GridPane.valignment="CENTER" GridPane.vgrow="ALWAYS" />
|
||||||
<image>
|
<Button fx:id="previousButton" maxHeight="25.0" maxWidth="80.0" mnemonicParsing="false" onAction="#previousImage" text="Previous" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
|
||||||
<Image url="@../../images/AC35_Racecourse_MAP.jpg" />
|
<Button fx:id="nextButton" maxHeight="25.0" maxWidth="80.0" mnemonicParsing="false" onAction="#nextImage" text="Next" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
|
||||||
</image>
|
|
||||||
</ImageView>
|
|
||||||
<Button fx:id="previousButton" maxHeight="25.0" maxWidth="80.0" mnemonicParsing="false" text="Previous" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
|
|
||||||
<Button fx:id="nextButton" maxHeight="25.0" maxWidth="80.0" mnemonicParsing="false" text="Next" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
|
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
Reference in New Issue
Block a user