diff --git a/src/main/java/app/view/mapBuilder/FurniturePane.java b/src/main/java/app/view/mapBuilder/FurniturePane.java index 0207d15e..2d00e185 100644 --- a/src/main/java/app/view/mapBuilder/FurniturePane.java +++ b/src/main/java/app/view/mapBuilder/FurniturePane.java @@ -2,25 +2,18 @@ import app.controller.settings.Settings; import app.model.furniture.FurnitureType; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.geometry.Insets; -import javafx.geometry.Rectangle2D; -import javafx.scene.control.*; +import javafx.scene.control.Button; +import javafx.scene.control.Label; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import lombok.Getter; -import lombok.Setter; - -import java.util.ArrayDeque; public class FurniturePane extends StackPane { @Getter private FurnitureType currentType; @Getter private boolean portal = false; - private TextField x; - private TextField y; private StartMenu startMenu; private DisplayPane displayPane; private final int BUTTON_WIDTH = 140; @@ -36,7 +29,18 @@ public FurniturePane(StartMenu startMenu, DisplayPane displayPane) this.getChildren().addAll(vbox); } - public void loadButtons(VBox vbox) + public void getSettings(Settings s) + { + for(MbObject object : displayPane.getObjects()) + { + if(object.getType() == FurnitureType.PORTAL) + s.addTeleport(object.getRect(), object.getTeleportTo(), object.getRotation()); + else + s.addFurniture(object.getRect(), object.getType()); + } + } + + private void loadButtons(VBox vbox) { // Furniture type enums Label furniture = new Label("Furniture Items:"); @@ -67,15 +71,4 @@ private void handleActionEvent(ActionEvent e, FurnitureType type) { currentType = type; } - - public void getSettings(Settings s) - { - for(MbObject object : displayPane.getObjects()) - { - if(object.getType() == FurnitureType.PORTAL) - s.addTeleport(object.getRect(), object.getTeleportTo(), object.getRotation()); - else - s.addFurniture(object.getRect(), object.getType()); - } - } } diff --git a/src/main/java/app/view/mapBuilder/SettingsPane.java b/src/main/java/app/view/mapBuilder/SettingsPane.java index 2379356c..2236281f 100644 --- a/src/main/java/app/view/mapBuilder/SettingsPane.java +++ b/src/main/java/app/view/mapBuilder/SettingsPane.java @@ -1,6 +1,7 @@ package app.view.mapBuilder; import app.controller.settings.Settings; +import app.controller.settings.SettingsGenerator; import javafx.geometry.Insets; import javafx.scene.control.Label; import javafx.scene.control.TextField; @@ -13,7 +14,6 @@ public class SettingsPane extends StackPane { private StartMenu startMenu; - private Settings s; private TextField name; private TextField mode; private TextField w; @@ -25,10 +25,10 @@ public class SettingsPane extends StackPane private TextField sGuard; private TextField sIntruder; - public SettingsPane(StartMenu startMenu, Settings s) + public SettingsPane(StartMenu startMenu) { this.startMenu = startMenu; - this.s = s; + Settings s = SettingsGenerator.mockSettings();; this.setPrefWidth(300); // Labels displaying current settings information. @@ -138,17 +138,19 @@ public int getMapHeight() return Integer.parseInt(h.getText()); } - public void getSettings() + public Settings getSettings() { - s.setName(name.getText()); - s.setGameMode(Integer.parseInt(mode.getText())); - s.setWidth(Integer.parseInt(w.getText())); - s.setHeight(Integer.parseInt(h.getText())); - s.setNoOfGuards(Integer.parseInt(noGuards.getText())); - s.setNoOfIntruders(Integer.parseInt(noIntruders.getText())); - s.setWalkSpeedGuard(Double.parseDouble(bGuard.getText())); - s.setWalkSpeedIntruder(Double.parseDouble(bIntruder.getText())); - s.setSprintSpeedGuard(Double.parseDouble(sGuard.getText())); - s.setWalkSpeedIntruder(Double.parseDouble(sIntruder.getText())); + Settings settings = new Settings(); + settings.setName(name.getText()); + settings.setGameMode(Integer.parseInt(mode.getText())); + settings.setWidth(Integer.parseInt(w.getText())); + settings.setHeight(Integer.parseInt(h.getText())); + settings.setNoOfGuards(Integer.parseInt(noGuards.getText())); + settings.setNoOfIntruders(Integer.parseInt(noIntruders.getText())); + settings.setWalkSpeedGuard(Double.parseDouble(bGuard.getText())); + settings.setWalkSpeedIntruder(Double.parseDouble(bIntruder.getText())); + settings.setSprintSpeedGuard(Double.parseDouble(sGuard.getText())); + settings.setWalkSpeedIntruder(Double.parseDouble(sIntruder.getText())); + return settings; } } diff --git a/src/main/java/app/view/mapBuilder/StartMenu.java b/src/main/java/app/view/mapBuilder/StartMenu.java index f74c25d5..b1b88051 100644 --- a/src/main/java/app/view/mapBuilder/StartMenu.java +++ b/src/main/java/app/view/mapBuilder/StartMenu.java @@ -3,7 +3,6 @@ import app.App; import app.controller.io.FileManager; import app.controller.settings.Settings; -import app.controller.settings.SettingsGenerator; import app.view.Alert; import app.view.FileMenuBar; import javafx.scene.layout.BorderPane; @@ -15,13 +14,11 @@ public class StartMenu extends BorderPane @Getter private FurniturePane furniturePane; @Getter private DisplayPane displayPane; @Getter private SettingsPane settingsPane; - private Settings settings; public StartMenu(App app) { this.app = app; - settings = SettingsGenerator.mockSettings(); - settingsPane = new SettingsPane(this, settings); + settingsPane = new SettingsPane(this); displayPane = new DisplayPane(this); furniturePane = new FurniturePane(this, displayPane); @@ -43,16 +40,16 @@ public int getMapHeight() public void saveSettings() { + Settings settings = settingsPane.getSettings(); furniturePane.getSettings(settings); - settingsPane.getSettings(); FileManager.saveSettings(settings, settings.getName()); Alert.displayAlert("Done!", "The map file was successfully created."); } public void saveSettingsAndOpen() { + Settings settings = settingsPane.getSettings(); furniturePane.getSettings(settings); - settingsPane.getSettings(); FileManager.saveSettings(settings, settings.getName()); String fileName = settings.getName(); app.gotoSimulation(fileName);