-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from IDATT2003-gruppe06/feat/prettify
Merge Feat/prettify into dev
- Loading branch information
Showing
7 changed files
with
695 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package millions.view; | ||
|
|
||
| import java.math.BigDecimal; | ||
| import javafx.application.Platform; | ||
| import javafx.geometry.HPos; | ||
| import javafx.geometry.Insets; | ||
| import javafx.geometry.Pos; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.control.Label; | ||
| import javafx.scene.control.Separator; | ||
| import javafx.scene.layout.ColumnConstraints; | ||
| import javafx.scene.layout.GridPane; | ||
| import javafx.scene.layout.HBox; | ||
| import javafx.scene.layout.Priority; | ||
| import javafx.scene.layout.VBox; | ||
| import millions.model.Player; | ||
|
|
||
| public class ExitView extends VBox { | ||
|
|
||
| public ExitView(Player player) { | ||
| setSpacing(16); | ||
| setAlignment(Pos.CENTER); | ||
| setPadding(new Insets(60)); | ||
|
|
||
| Label title = new Label("GAME OVER"); | ||
| title.getStyleClass().add("game-over-title"); | ||
| HBox titleRow = new HBox(title); | ||
| titleRow.setAlignment(Pos.CENTER); | ||
| titleRow.setMaxWidth(Double.MAX_VALUE); | ||
|
|
||
| Separator sep = new Separator(); | ||
| sep.setMaxWidth(320); | ||
|
|
||
| Label weeks = new Label(String.valueOf(player.getTransactionArchive().countDistinctWeeks())); | ||
| Label trades = | ||
| new Label(String.valueOf(player.getTransactionArchive().getTransactions().size())); | ||
| Label netWorth = new Label(ViewUtils.formatMoney(player.getNetWorth())); | ||
|
|
||
| BigDecimal profit = player.getNetWorth().subtract(player.getStartingMoneh()); | ||
| String sign = profit.compareTo(BigDecimal.ZERO) >= 0 ? "+" : ""; | ||
| Label netProfit = new Label(sign + ViewUtils.formatMoney(profit)); | ||
| netProfit | ||
| .getStyleClass() | ||
| .add(profit.compareTo(BigDecimal.ZERO) >= 0 ? "status-success" : "status-error"); | ||
|
|
||
| GridPane stats = new GridPane(); | ||
| stats.setHgap(24); | ||
| stats.setVgap(12); | ||
| ColumnConstraints labelCol = new ColumnConstraints(); | ||
| labelCol.setHalignment(HPos.RIGHT); | ||
| labelCol.setHgrow(Priority.NEVER); | ||
| ColumnConstraints valueCol = new ColumnConstraints(); | ||
| valueCol.setHalignment(HPos.LEFT); | ||
| valueCol.setHgrow(Priority.ALWAYS); | ||
| stats.getColumnConstraints().addAll(labelCol, valueCol); | ||
|
|
||
| stats.addRow(0, statlabel("Weeks traded"), weeks); | ||
| stats.addRow(1, statlabel("Trades made"), trades); | ||
| stats.addRow(2, statlabel("Final net worth"), netWorth); | ||
| stats.addRow(3, statlabel("Total profit"), netProfit); | ||
|
|
||
| for (Label l : new Label[] {weeks, trades, netWorth, netProfit}) { | ||
| l.getStyleClass().add("stat-value"); | ||
| } | ||
|
|
||
| Button quitButton = new Button("Quit"); | ||
| quitButton.getStyleClass().add("btn-primary"); | ||
| quitButton.setPrefWidth(160); | ||
| quitButton.setOnAction(event -> Platform.exit()); | ||
|
|
||
| getChildren().addAll(titleRow, sep, stats, quitButton); | ||
| } | ||
|
|
||
| private static Label statlabel(String text) { | ||
| Label l = new Label(text); | ||
| l.getStyleClass().add("section-title"); | ||
| return l; | ||
| } | ||
| } |
Oops, something went wrong.