Commit 44b8f39d authored by Carl Johan Gützkow's avatar Carl Johan Gützkow 🎮
Browse files

Merge branch 'feat/styling' into 'master'

style: added colorscheme to front page

See merge request !29
parents f8df0c14 b9b9de77
Pipeline #183258 passed with stages
in 45 seconds
......@@ -54,7 +54,9 @@ public class App extends Application {
stage.show();
} catch (IOException | IllegalStateException e) {
new DialogBoxBuilder(ERROR)
.addHeader("Program could not be started. Expand the \"Show details\" button to see full stack trace.")
.addHeader("Program could not be started." +
"Expand the \"Show details\" button to see full stack trace. " +
"Error message: " + e.getMessage())
.addListMessage(
Arrays.stream(e.getStackTrace())
.map(String::valueOf)
......
......@@ -20,8 +20,8 @@ import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.text.Text;
import static javafx.scene.control.Alert.AlertType.*;
/**
......@@ -42,24 +42,24 @@ public class BattleController implements Initializable {
private Button resetArmiesButton, resetAndBattleButton;
@FXML
private Text armyOneImportPath, armyOneName, armyOneToString;
private Label armyOneImportPath, armyOneName, armyOneToString;
@FXML
private ListView<Unit> armyOneUnitsListView, armyTwoUnitsListView;
@FXML
private Text armyTwoImportPath, armyTwoName, armyTwoToString;
private Label armyTwoImportPath, armyTwoName, armyTwoToString;
private Text[] armyImportPathTexts;
private Text[] armyNameTexts;
private Text[] armySummaryTexts;
private Label[] armyImportPathLabels;
private Label[] armyNameLabels;
private Label[] armySummaryLabels;
private ListView[] armyUnitListViews;
@FXML
private ListView<String> attackList;
@FXML
private Text lastSimulation, score;
private Label lastSimulation, score;
private Army armyOne, armyTwo;
private Army[] armies;
......@@ -72,7 +72,7 @@ public class BattleController implements Initializable {
/**
* Helper method to import an army and
* display its information in the
* given text elements.
* given label elements.
*
* @param armyNumber - int - the selected army to import.
* 0 for army one and 1 for army two
......@@ -156,7 +156,7 @@ public class BattleController implements Initializable {
/**
* Run when clicking on reset armies.
* Deep copies the armies and creates a new battle.
* Also resets the labels and texts.
* Also resets the labels.
*
* @return result - boolean - true if the reset was a success, false otherwise
*/
......@@ -235,7 +235,7 @@ public class BattleController implements Initializable {
public void displayArmy(int armyNumber, Army army) throws NullPointerException {
if (army == null) throw new NullPointerException("Army is a a null object");
armyNameTexts[armyNumber].setText(army.getName());
armyNameLabels[armyNumber].setText(army.getName());
String armyRepresentation =
"Infantry units: " + army.getInfantryUnits().size() + "\n" +
......@@ -243,9 +243,9 @@ public class BattleController implements Initializable {
"Cavalry units: " + army.getCavalryUnits().size() + "\n" +
"Commander units: " + army.getCommanderUnits().size() + "\n";
armySummaryTexts[armyNumber].setText(armyRepresentation);
armySummaryLabels[armyNumber].setText(armyRepresentation);
armyImportPathTexts[armyNumber].setText(filePaths[armyNumber]);
armyImportPathLabels[armyNumber].setText(filePaths[armyNumber]);
armyUnitListViews[armyNumber].getItems().clear();
armyUnitListViews[armyNumber].getItems().addAll(army.getAllUnits());
......@@ -261,9 +261,9 @@ public class BattleController implements Initializable {
*/
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
armyNameTexts = new Text[] {armyOneName, armyTwoName};
armyImportPathTexts = new Text[] {armyOneImportPath, armyTwoImportPath};
armySummaryTexts = new Text[] {armyOneToString, armyTwoToString};
armyNameLabels = new Label[] {armyOneName, armyTwoName};
armyImportPathLabels = new Label[] {armyOneImportPath, armyTwoImportPath};
armySummaryLabels = new Label[] {armyOneToString, armyTwoToString};
armyUnitListViews = new ListView[] {armyOneUnitsListView, armyTwoUnitsListView};
armies = new Army[] {armyOne, armyTwo};
......
.root{
.root {
-fx-font-size: 20px;
-fx-font-family: "Arial";
-fx-base: #424c85;
-fx-accent: #c9c9c9;
-fx-control-inner-background: derive(-fx-base, 35%);
-fx-control-inner-background-alt: -fx-control-inner-background ;
}
.button, .choice-box, .titled-pane {
-fx-background-radius: 20px;
}
.button {
-fx-background-color: #a23645;
}
.button:hover {
-fx-background-color: #d75d88;
}
.choice-box {
-fx-background-color: #71c259;
}
.choice-box:hover {
-fx-background-color: #95c786;
}
.label {
-fx-text-fill: white;
}
.button .label {
-fx-text-fill: black;
}
.titled-pane > .title:hover {
-fx-color: -fx-base;
}
#hboxRoot {
-fx-background-color: linear-gradient(from 25% 25% to 100% 100%, #304ca8, #8e9ee0);
}
.list-view {
-fx-background-color: #5686c7;
}
.list-cell:even {
-fx-control-inner-background: derive(-fx-base, 25%);
-fx-border-color: grey;
-fx-font-family: "Arial";
}
.list-cell:odd {
-fx-control-inner-background: derive(-fx-base, 15%);
-fx-border-color: grey;
-fx-font-family: "Arial";
}
.list-cell:empty {
-fx-background-color: transparent;
-fx-border-color: transparent;
}
.list-cell {
-fx-border-color: transparent;
-fx-table-cell-border-color:transparent;
}
.scroll-bar{
-fx-background-color: derive(-fx-base,45%)
}
.separator *.line {
-fx-background-color: #3C3C3C;
-fx-border-style: solid;
-fx-border-width: 1px;
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<ScrollPane fitToHeight="true" fitToWidth="true" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="720.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="edu.ntnu.idatt2001.carljgu.client.BattleController">
<HBox alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308">
<VBox alignment="CENTER" maxWidth="1.7976931348623157E308" HBox.hgrow="ALWAYS">
<ScrollPane fitToHeight="true" fitToWidth="true" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="720.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="edu.ntnu.idatt2001.carljgu.client.BattleController">
<HBox fx:id="hboxRoot" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308">
<VBox alignment="CENTER" maxWidth="1.7976931348623157E308" minWidth="300.0" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets bottom="50.0" left="50.0" right="50.0" top="40.0" />
</HBox.margin>
<Text fx:id="armyOneName" strokeType="OUTSIDE" strokeWidth="0.0" text="No army selected" VBox.vgrow="ALWAYS">
<Label fx:id="armyOneName" alignment="CENTER" maxWidth="300" text="No army selected" textAlignment="CENTER" wrapText="true">
<font>
<Font name="Arial" size="36.0" />
</font>
<VBox.margin>
<Insets bottom="10.0" top="10.0" />
</VBox.margin>
</Text>
<Text fx:id="armyOneToString" strokeType="OUTSIDE" strokeWidth="0.0" text="Import an army" textAlignment="CENTER" wrappingWidth="250" VBox.vgrow="ALWAYS">
</Label>
<Label fx:id="armyOneToString" text="Import an army" textAlignment="CENTER" VBox.vgrow="ALWAYS">
<font>
<Font name="Arial" size="20.0" />
</font>
<VBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</VBox.margin>
</Text>
</Label>
<HBox alignment="CENTER">
<VBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
......@@ -52,14 +44,14 @@
</HBox.margin>
</Button>
</HBox>
<Text fx:id="armyOneImportPath" strokeType="OUTSIDE" VBox.vgrow="ALWAYS" strokeWidth="0.0" wrappingWidth="250">
<Label fx:id="armyOneImportPath" maxWidth="300" wrapText="true" VBox.vgrow="ALWAYS">
<font>
<Font name="Arial" size="18.0" />
</font>
<VBox.margin>
<Insets bottom="10.0" />
</VBox.margin>
</Text>
</Label>
<TitledPane animated="false" collapsible="false" maxHeight="500.0" text="Units" VBox.vgrow="ALWAYS">
<font>
<Font name="Arial" size="18.0" />
......@@ -79,16 +71,8 @@
<Insets bottom="40.0" />
</VBox.margin>
</Label>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="VS.">
<font>
<Font name="Arial" size="36.0" />
</font>
<VBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</VBox.margin>
</Text>
<HBox alignment="CENTER">
<Button mnemonicParsing="false" onAction="#resetArmies" text="Reset armies" fx:id="resetArmiesButton">
<Button fx:id="resetArmiesButton" mnemonicParsing="false" onAction="#resetArmies" text="Reset armies">
<font>
<Font name="Arial" size="20.0" />
</font>
......@@ -96,7 +80,7 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</HBox.margin>
</Button>
<Button mnemonicParsing="false" onAction="#runSimulation" text="Reset and battle" fx:id="resetAndBattleButton">
<Button fx:id="resetAndBattleButton" mnemonicParsing="false" onAction="#runSimulation" text="Reset and battle">
<font>
<Font name="Arial" size="20.0" />
</font>
......@@ -105,17 +89,16 @@
</HBox.margin>
</Button>
</HBox>
<HBox prefHeight="100.0" prefWidth="200.0" />
<HBox alignment="CENTER">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Choose terrain:">
<Label text="Choose terrain:">
<font>
<Font name="Arial" size="20.0" />
</font>
<HBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</HBox.margin>
</Text>
</Label>
<ChoiceBox fx:id="terrainChoiceBox" accessibleText="Choose terrain" prefWidth="200.0">
<HBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
......@@ -123,32 +106,32 @@
</ChoiceBox>
</children>
</HBox>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Last simulation:">
<Label text="Last simulation:">
<VBox.margin>
<Insets bottom="10.0" left="20.0" right="20.0" top="20.0" />
</VBox.margin>
<font>
<Font name="Arial" size="24.0" />
</font>
</Text>
<Text fx:id="lastSimulation" strokeType="OUTSIDE" strokeWidth="0.0" text="No simulation run">
</Label>
<Label fx:id="lastSimulation" text="No simulation run">
<font>
<Font name="Arial" size="20.0" />
</font>
</Text>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Times armies have won:">
</Label>
<Label text="Times armies have won:">
<font>
<Font name="Arial" size="24.0" />
</font>
<VBox.margin>
<Insets bottom="10.0" left="20.0" right="20.0" top="20.0" />
</VBox.margin>
</Text>
<Text fx:id="score" strokeType="OUTSIDE" strokeWidth="0.0" text="0 - 0">
</Label>
<Label fx:id="score" text="0 - 0">
<font>
<Font name="Arial" size="20.0" />
</font>
</Text>
</Label>
<TitledPane animated="false" collapsible="false" maxHeight="1.7976931348623157E308" minHeight="200.0" text="Simulation attack log. Earliest first" VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="20.0" />
......@@ -159,26 +142,26 @@
<ListView fx:id="attackList" />
</TitledPane>
</VBox>
<VBox alignment="CENTER" HBox.hgrow="ALWAYS">
<VBox alignment="CENTER" minWidth="300.0" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets bottom="40.0" left="40.0" right="40.0" top="40.0" />
</HBox.margin>
<Text fx:id="armyTwoName" strokeType="OUTSIDE" strokeWidth="0.0" text="No army selected" VBox.vgrow="ALWAYS">
<Label fx:id="armyTwoName" alignment="CENTER" maxWidth="300" text="No army selected" textAlignment="CENTER" wrapText="true">
<font>
<Font name="Arial" size="36.0" />
</font>
<VBox.margin>
<Insets bottom="10.0" top="10.0" />
</VBox.margin>
</Text>
<Text fx:id="armyTwoToString" strokeType="OUTSIDE" strokeWidth="0.0" text="Import an army" textAlignment="CENTER" wrappingWidth="250" VBox.vgrow="ALWAYS">
</Label>
<Label fx:id="armyTwoToString" text="Import an army" textAlignment="CENTER" VBox.vgrow="ALWAYS">
<font>
<Font name="Arial" size="20.0" />
</font>
<VBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</VBox.margin>
</Text>
</Label>
<HBox alignment="CENTER" maxWidth="1.7976931348623157E308">
<VBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
......@@ -195,14 +178,14 @@
</HBox.margin>
</Button>
</HBox>
<Text fx:id="armyTwoImportPath" strokeType="OUTSIDE" VBox.vgrow="ALWAYS" strokeWidth="0.0" wrappingWidth="250">
<Label fx:id="armyTwoImportPath" maxWidth="300" wrapText="true" VBox.vgrow="ALWAYS">
<font>
<Font name="Arial" size="18.0" />
</font>
<VBox.margin>
<Insets bottom="10.0" />
</VBox.margin>
</Text>
</Label>
<TitledPane animated="false" collapsible="false" maxHeight="500.0" text="Units" VBox.vgrow="ALWAYS">
<font>
<Font name="Arial" size="18.0" />
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment