Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the Settings Panel #134

Merged
merged 2 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/main/java/app/controller/settings/SettingsGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ public abstract class SettingsGenerator
public static Settings mockSettings()
{
Settings settings = new Settings();
settings.setHeight(400);
settings.setWidth(300);
settings.addFurniture(new Rectangle2D(10, 10, 10, 10), FurnitureType.WALL);
settings.addFurniture(new Rectangle2D(30, 10, 10, 10), FurnitureType.GLASS);
settings.addFurniture(new Rectangle2D(10, 30, 10, 10), FurnitureType.TARGET);
settings.addFurniture(new Rectangle2D(30, 30, 10, 10), FurnitureType.TOWER);
settings.setName("best_map");
settings.setGameMode(1);
settings.setTimeStep(0.5);
settings.setScaling(0.1);
settings.setNoOfGuards(3);
settings.setNoOfIntruders(5);
settings.setWalkSpeedGuard(13.5);
settings.setWalkSpeedIntruder(15.0);
settings.setSprintSpeedGuard(21.5);
settings.setSprintSpeedIntruder(23);
return settings;
}

Expand Down
6 changes: 0 additions & 6 deletions src/main/java/app/view/mapBuilder/FurniturePane.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ public void loadButtons(VBox vbox)

vbox.getChildren().addAll(teleport, x, y);

// Spawn areas
Label spawns = new Label("Spwan Areas:");
Button aSpawn = new Button("Agent Spawn Area");
Button iSpawn = new Button("Intruder Spawn Area");
vbox.getChildren().addAll(spawns, aSpawn, iSpawn);

// Furniture type enums
Label furniture = new Label("Furniture Items:");
vbox.getChildren().add(furniture);
Expand Down
92 changes: 89 additions & 3 deletions src/main/java/app/view/mapBuilder/SettingsPane.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,103 @@
package app.view.mapBuilder;

import app.controller.settings.Settings;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;

public class SettingsPane extends StackPane // Might need to change this to extend something else
{
private StartMenu startMenu;
private Settings s;

public SettingsPane(StartMenu startMenu)
public SettingsPane(StartMenu startMenu, Settings s)
{
this.startMenu = startMenu;
this.s = s;

Label label = new Label("Settings Go Here");
this.getChildren().add(label);
// Labels displaying current settings information.
VBox vbox = new VBox(10);
Label header = new Label("Settings:");
header.setFont(Font.font("", FontWeight.BOLD, 24));

// Grid layout
GridPane grid = new GridPane();
grid.setVgap(10);
grid.setHgap(10);

// Labels
Label mapName = new Label("Map Name:");
mapName.setFont(new Font(16));
Label gameMode = new Label("Game Mode:");
gameMode.setFont(new Font(16));
Label timeStep = new Label("Time Step:");
timeStep.setFont(new Font(16));
Label scaling = new Label("Scaling:");
scaling.setFont(new Font(16));
Label noOfGuards = new Label("Number of Guards:");
noOfGuards.setFont(new Font(16));
Label noOfIntruders = new Label("Number of Intruders:");
noOfIntruders.setFont(new Font(16));
Label baseGuard = new Label("Walk speed Guard:");
baseGuard.setFont(new Font(16));
Label baseIntruder = new Label("Walk speed Intruder:");
baseIntruder.setFont(new Font(16));
Label sprintGuard = new Label("Sprint speed Guard:");
sprintGuard.setFont(new Font(16));
Label sprintIntruder = new Label("Sprint speed Intruder:");
sprintIntruder.setFont(new Font(16));

// Text Fields with current values editable.
TextField name = new TextField();
name.setText(s.getName());
TextField mode = new TextField();
mode.setText(""+s.getGameMode());
TextField step = new TextField();
step.setText(""+s.getTimeStep());
TextField scale = new TextField();
scale.setText(""+s.getScaling());
TextField noGuards = new TextField();
noGuards.setText(""+s.getNoOfGuards());
TextField noIntruders = new TextField();
noIntruders.setText(""+s.getNoOfIntruders());
TextField bGuard = new TextField();
bGuard.setText(""+s.getWalkSpeedGuard());
TextField bIntruder = new TextField();
bIntruder.setText(""+s.getWalkSpeedIntruder());
TextField sGuard = new TextField();
sGuard.setText(""+s.getSprintSpeedGuard());
TextField sIntruder = new TextField();
sIntruder.setText(""+s.getSprintSpeedIntruder());

// Add labels and fields to grid
grid.add(mapName, 0, 0);
grid.add(name, 1, 0);
grid.add(gameMode, 0, 1);
grid.add(mode, 1, 1);
grid.add(timeStep, 0, 2);
grid.add(step, 1, 2);
grid.add(scaling, 0, 3);
grid.add(scale, 1, 3);
grid.add(noOfGuards, 0, 4);
grid.add(noGuards, 1, 4);
grid.add(noOfIntruders, 0, 5);
grid.add(noIntruders, 1, 5);
grid.add(baseGuard, 0, 6);
grid.add(bGuard, 1, 6);
grid.add(baseIntruder, 0, 7);
grid.add(bIntruder, 1, 7);
grid.add(sprintGuard, 0, 8);
grid.add(sGuard, 1, 8);
grid.add(sprintIntruder, 0, 9);
grid.add(sIntruder, 1, 9);

vbox.getChildren().addAll(header, grid);
this.setMargin(vbox, new Insets(10, 10, 10, 10));
this.getChildren().addAll(vbox);
}
}
3 changes: 2 additions & 1 deletion src/main/java/app/view/mapBuilder/StartMenu.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.view.mapBuilder;

import app.App;
import app.controller.settings.SettingsGenerator;
import app.view.FileMenuBar;
import javafx.scene.layout.BorderPane;
import lombok.Getter;
Expand All @@ -15,7 +16,7 @@ public StartMenu(App app)
this.setTop(new FileMenuBar(app));
MapBuilder mb = new MapBuilder(this);
this.setLeft(new FurniturePane(this, mb));
this.setRight(new SettingsPane(this));
this.setRight(new SettingsPane(this, SettingsGenerator.mockSettings()));
this.setCenter(mb);
}
}