diff --git a/src/main/java/edu/ntnu/idatt2001/group_30/paths/controller/CreatePlayerController.java b/src/main/java/edu/ntnu/idatt2001/group_30/paths/controller/CreatePlayerController.java index 01c52afc3b17a81c271d52b77ff23a99784b43b8..8515eca9ec84886300f56842c17ad0e0768d209e 100644 --- a/src/main/java/edu/ntnu/idatt2001/group_30/paths/controller/CreatePlayerController.java +++ b/src/main/java/edu/ntnu/idatt2001/group_30/paths/controller/CreatePlayerController.java @@ -1,10 +1,10 @@ package edu.ntnu.idatt2001.group_30.paths.controller; -import edu.ntnu.idatt2001.group_30.paths.view.views.NewGameView; +import edu.ntnu.idatt2001.group_30.paths.view.views.LoadGameView; public class CreatePlayerController extends Controller { public CreatePlayerController() { - super(NewGameView.class); + super(LoadGameView.class); } } diff --git a/src/main/java/edu/ntnu/idatt2001/group_30/paths/controller/HomeController.java b/src/main/java/edu/ntnu/idatt2001/group_30/paths/controller/HomeController.java index d3090acb250e365cfea8c71a85cb03b675af5d05..6753105984aed797a257c8a781bf4a4921878ba7 100644 --- a/src/main/java/edu/ntnu/idatt2001/group_30/paths/controller/HomeController.java +++ b/src/main/java/edu/ntnu/idatt2001/group_30/paths/controller/HomeController.java @@ -2,7 +2,7 @@ package edu.ntnu.idatt2001.group_30.paths.controller; import edu.ntnu.idatt2001.group_30.paths.view.views.CreatePlayerView; import edu.ntnu.idatt2001.group_30.paths.view.views.HelpView; -import edu.ntnu.idatt2001.group_30.paths.view.views.NewGameView; +import edu.ntnu.idatt2001.group_30.paths.view.views.LoadGameView; import edu.ntnu.idatt2001.group_30.paths.view.views.PlaythroughView; /** @@ -16,7 +16,7 @@ public class HomeController extends Controller { * Creates a new HomeController. */ public HomeController() { - super(HelpView.class, NewGameView.class, CreatePlayerView.class, PlaythroughView.class); + super(HelpView.class, LoadGameView.class, CreatePlayerView.class, PlaythroughView.class); } /** diff --git a/src/main/java/edu/ntnu/idatt2001/group_30/paths/model/Story.java b/src/main/java/edu/ntnu/idatt2001/group_30/paths/model/Story.java index 6246e946b64ee55e7a60827b5526ee710a6d1a5f..f4aca83f1e195637c426ebd7a7cf3698975cbae2 100644 --- a/src/main/java/edu/ntnu/idatt2001/group_30/paths/model/Story.java +++ b/src/main/java/edu/ntnu/idatt2001/group_30/paths/model/Story.java @@ -13,7 +13,7 @@ import java.util.Objects; */ public class Story { - private final String title; + private String title; private final Map<Link, Passage> passages; private final Passage openingPassage; @@ -25,13 +25,7 @@ public class Story { * @throws IllegalArgumentException This exception is thrown if title or openingPassage is invalid */ public Story(String title, Passage openingPassage) throws IllegalArgumentException { - //if (title.isBlank() || !title.matches("[a-zA-Z]")) { - // throw new IllegalArgumentException("Title cannot be blank, empty, or contain special characters."); - //} - if (title.isBlank()) throw new IllegalArgumentException( - "Title cannot be blank, empty, or contain special characters." - ); - this.title = title; + setTitle(title); if (openingPassage == null) throw new IllegalArgumentException("Opening passage cannot be null"); this.openingPassage = openingPassage; this.passages = new HashMap<>(); @@ -107,6 +101,17 @@ public class Story { return title; } + /** + * This method sets the title of the story. + * @param title The new title of the story, given as a {@code String}. + */ + public void setTitle(String title) { + if (title.isBlank()) throw new IllegalArgumentException( + "Title cannot be blank, empty, or contain special characters." + ); + this.title = title; + } + /** * This method retrieves all the passages of a story. * @return All the passages of the Story as a {@code Collection<Passages>}. diff --git a/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/App.java b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/App.java index 8f18add2be461aff2bd711a220fe267c2aa003a8..6f149869142bbc25642d016dd475b994cc9083d1 100644 --- a/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/App.java +++ b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/App.java @@ -32,7 +32,7 @@ public class App extends Application { @Override public void start(Stage stage) { stage.initStyle(StageStyle.UTILITY); - stage.setAlwaysOnTop(true); + stage.setAlwaysOnTop(false); stage.setTitle("Paths"); /* initialize STAGE_MANAGER */ STAGE_MANAGER = StageManager.init(stage); diff --git a/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/components/common/DefaultInputField.java b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/components/common/DefaultInputField.java new file mode 100644 index 0000000000000000000000000000000000000000..464be737739b203e295e6149407939b8e12c2283 --- /dev/null +++ b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/components/common/DefaultInputField.java @@ -0,0 +1,27 @@ +package edu.ntnu.idatt2001.group_30.paths.view.components.common; + +import javafx.scene.control.TextField; +import javafx.scene.layout.HBox; +import javafx.scene.text.Text; + +/** + * This class contains methods to create different input fields with default layouts. + * + * @author Trym Hamer Gudvangen + */ +public class DefaultInputField { + + /** + * This method creates a text input field with a given label and prompt. + * @param label The label of the input field, given as a String. + * @param prompt The prompt of the input field, given as a String. + * @return An HBox containing the label and the input field. + */ + public static HBox inputWithLabelAndPrompt(String label, String prompt) { + Text labelText = new Text(label); + TextField textField = new TextField(); + textField.setPromptText(prompt); + return new HBox(labelText, textField); + } + +} diff --git a/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/components/table/PassageTable.java b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/components/table/PassageTable.java new file mode 100644 index 0000000000000000000000000000000000000000..1a3f146ea710fc6a8b20258008ee7219b2b48cb2 --- /dev/null +++ b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/components/table/PassageTable.java @@ -0,0 +1,14 @@ +package edu.ntnu.idatt2001.group_30.paths.view.components.table; + +public class PassageTable<Passage> extends TableDisplay<Passage> { + + /** + * This is a constructor which is used to construct a table for different passages. + * + * @param tableBuilder The builder used to construct a table, represented using an tableBuilder object. + */ + public PassageTable(Builder<Passage> tableBuilder) { + super(tableBuilder); + } + +} diff --git a/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/components/table/TableDisplay.java b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/components/table/TableDisplay.java index bd8a5d874cd8be3f42093127b6725ee0d6c9b8c1..dddc386a6d9719145838a910d7b78d521529a965 100644 --- a/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/components/table/TableDisplay.java +++ b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/components/table/TableDisplay.java @@ -1,10 +1,13 @@ package edu.ntnu.idatt2001.group_30.paths.view.components.table; +import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; +import java.util.function.Function; + /** * This class concerns itself with building a table view filled with the desired information in columns. It does so * by using a TableBuilder. @@ -47,6 +50,21 @@ public class TableDisplay<T> extends TableView<T> { return this; } + /** + * This method attaches a desired column {@link TableDisplayColumn#TableDisplayColumn(String, String)} to the + * tableview that is complex. + * @param infoHeader The name of the column, represented using a String. + * @param complexValueFunction The attribute the information will be extracted from, represented as a String. + * @return The builder itself is returned, represented as a Builder object. + */ + public Builder<T> addColumnWithComplexValue(String infoHeader, Function<T, String> complexValueFunction) { + TableColumn<T, String> column = new TableColumn<>(infoHeader); + column.setCellValueFactory(cellData -> new SimpleStringProperty(complexValueFunction.apply(cellData.getValue()))); + column.setStyle("-fx-alignment: CENTER"); + this.tableColumns.add(column); + return this; + } + /** * This method actually constructs the table by creating an TableDisplay object. * @return The table view, represented using an TableDisplay object. diff --git a/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/views/CreatePlayerView.java b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/views/CreatePlayerView.java index b7eb60f988d387c435faa4081d2f3c6ae4aa3d2d..7da1049a7e5cdc0560d88739bf02dae287303b32 100644 --- a/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/views/CreatePlayerView.java +++ b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/views/CreatePlayerView.java @@ -159,7 +159,7 @@ public class CreatePlayerView extends View<BorderPane> { ImageView characterImageView = new ImageView(characterImage); INSTANCE.setCharacterImageView(characterImageView); - createPlayerController.goTo(NewGameView.class).handle(event); + createPlayerController.goTo(LoadGameView.class).handle(event); } catch (Exception e) { AlertDialog.showWarning(e.getMessage()); } diff --git a/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/views/NewGameView.java b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/views/LoadGameView.java similarity index 97% rename from src/main/java/edu/ntnu/idatt2001/group_30/paths/view/views/NewGameView.java rename to src/main/java/edu/ntnu/idatt2001/group_30/paths/view/views/LoadGameView.java index e4a5469cff642c6e9e718b708df66e7649df3c17..9c070d5d048a37087cb8dcee72a6a413604b6dbf 100644 --- a/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/views/NewGameView.java +++ b/src/main/java/edu/ntnu/idatt2001/group_30/paths/view/views/LoadGameView.java @@ -25,7 +25,7 @@ import javafx.stage.FileChooser; * * @author Trym Hamer Gudvangen */ -public class NewGameView extends View<BorderPane> { +public class LoadGameView extends View<BorderPane> { private final NewGameController newGameController; @@ -37,7 +37,7 @@ public class NewGameView extends View<BorderPane> { * The constructor of the View class. * It creates a new instance of the Pane that the View wraps. */ - public NewGameView() { + public LoadGameView() { super(BorderPane.class); newGameController = new NewGameController(); @@ -141,6 +141,8 @@ public class NewGameView extends View<BorderPane> { } }); + newButton.setOnAction(newGameController.goTo(NewStoryView.class)); + return titlePane; } diff --git a/src/main/resources/stylesheet.css b/src/main/resources/stylesheet.css index 2d16dd20a814676381d110b5100cdbcad85c47eb..8aeae865e557fef7f334a291f96731308bd7f609 100644 --- a/src/main/resources/stylesheet.css +++ b/src/main/resources/stylesheet.css @@ -1,10 +1,36 @@ +* { + /*-fx-font-family: Arial;*/ + -fx-transition: all 0.3s ease-in-out; +} + .border-pane { background-color: #f5f5f5; } +.label { + -fx-font-size: 14px; + -fx-font-weight: bold; + -fx-padding: 5px; +} + +.text-field { + -fx-padding: 8px; + -fx-border-color: #ccc; + -fx-border-width: 1px; + -fx-border-radius: 5px; +} + + +.text-field:focused { + -fx-border-color: #0077ff; +} + + + #title { - -fx-font-size: 20px; + -fx-font-size: 22px; -fx-font-weight: bold; + -fx-color: #2c3e50; } #player-container, #goal-container { @@ -75,7 +101,6 @@ Button { -fx-border-color: #303f9f; -fx-border-width: 1px; -fx-padding: 10 20; - -fx-font-weight: bold; } Button:hover {