-
Notifications
You must be signed in to change notification settings - Fork 0
@co012/rpg 78 game end action #40
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package io.rpg.model.actions; | ||
|
|
||
| public class GameEndAction implements Action { | ||
| public final String description; | ||
|
|
||
| public GameEndAction(String description) { | ||
| this.description = description; | ||
| } | ||
|
|
||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package io.rpg.view; | ||
|
|
||
| import io.rpg.viewmodel.GameEndViewModel; | ||
| import java.io.IOException; | ||
| import javafx.scene.Parent; | ||
| import javafx.scene.Scene; | ||
|
|
||
| public class GameEndView extends Scene { | ||
| private GameEndViewModel viewModel; | ||
|
|
||
| private GameEndView(Parent parent) { | ||
| super(parent); | ||
| } | ||
|
|
||
| public static GameEndView load() { | ||
| GameEndViewModel viewModel; | ||
| try { | ||
| viewModel = GameEndViewModel.load(); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
|
Comment on lines
+19
to
+21
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the point of catching an exception, just to throw it again with a more general type, unless I'm missing something.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have to catch a RuntimeException |
||
| GameEndView view = new GameEndView(viewModel.getParent()); | ||
| view.viewModel = viewModel; | ||
| return view; | ||
| } | ||
|
|
||
| public void setDescription(String description) { | ||
| viewModel.setDescription(description); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package io.rpg.viewmodel; | ||
|
|
||
| import java.io.IOException; | ||
| import java.net.URL; | ||
| import java.util.Objects; | ||
| import javafx.fxml.FXML; | ||
| import javafx.fxml.FXMLLoader; | ||
| import javafx.scene.Parent; | ||
| import javafx.scene.control.Label; | ||
|
|
||
| public class GameEndViewModel { | ||
| public static final String GAME_END_VIEW_FXML = "game-end-view.fxml"; | ||
| private Parent parent; | ||
| @FXML private Label descriptionLabel; | ||
|
|
||
| public static GameEndViewModel load() throws IOException { | ||
| URL url = Objects.requireNonNull(GameEndViewModel.class.getResource(GAME_END_VIEW_FXML)); | ||
| FXMLLoader loader = new FXMLLoader(url); | ||
| Parent root = loader.load(); | ||
| GameEndViewModel viewModel = loader.getController(); | ||
| viewModel.parent = root; | ||
| return viewModel; | ||
| } | ||
|
|
||
| public Parent getParent() { | ||
| return parent; | ||
| } | ||
|
|
||
| public void setDescription(String description) { | ||
| descriptionLabel.setText(description); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <?import javafx.geometry.Insets?> | ||
| <?import javafx.scene.control.Label?> | ||
| <?import javafx.scene.layout.VBox?> | ||
| <?import javafx.scene.text.Font?> | ||
|
|
||
|
|
||
| <VBox fx:controller="io.rpg.viewmodel.GameEndViewModel" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" style="-fx-background-color: #1c1c1c;" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1"> | ||
| <children> | ||
| <Label text="GAME OVER" textFill="WHITE"> | ||
| <font> | ||
| <Font name="Sitka Small" size="72.0" /> | ||
| </font> | ||
| </Label> | ||
| <Label fx:id="descriptionLabel" alignment="CENTER" maxWidth="300.0" text="No description given." textAlignment="CENTER" textFill="#848484" wrapText="true"> | ||
| <font> | ||
| <Font name="Sitka Small" size="18.0" /> | ||
| </font> | ||
| </Label> | ||
| </children> | ||
| <padding> | ||
| <Insets bottom="25.0" left="25.0" right="25.0" top="25.0" /> | ||
| </padding> | ||
| </VBox> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.