ソースを参照

Added stylesheet and custom font

Ondřej Schlaichert 8 ヶ月 前
コミット
1dfd3230fe

+ 2 - 0
src/main/java/eu/oschl/gui/ActionProcessor.java

@@ -40,6 +40,8 @@ public class ActionProcessor extends Observable {
      * @throws InvalidActionId if the action ID is not found or is invalid
      */
     public void executeAction(String id, String[] args) throws InvalidActionId {
+        Output.clear();
+
         for (Action action : actions) {
             if (action.getId().equals(id)) {
                 action.execute(args);

+ 9 - 2
src/main/java/eu/oschl/gui/Output.java

@@ -20,7 +20,7 @@ public class Output {
     public static void print(String message, Color color) {
         var text = new Text(message);
         text.setFill(color);
-        outputElement.getChildren().add(new Text(message));
+        outputElement.getChildren().add(text);
     }
 
     /**
@@ -29,7 +29,7 @@ public class Output {
      * @param message the message to print
      */
     public static void print(String message) {
-        print(message, Color.BLACK);
+        print(message, Color.WHITE);
     }
 
     /**
@@ -38,4 +38,11 @@ public class Output {
     public static void printLine() {
         print("\n");
     }
+
+    /**
+     * Clears the output element.
+     */
+    public static void clear() {
+        outputElement.getChildren().clear();
+    }
 }

+ 5 - 0
src/main/java/eu/oschl/gui/Session.java

@@ -7,6 +7,7 @@ import javafx.scene.Scene;
 import javafx.stage.Stage;
 
 import java.io.IOException;
+import java.util.Objects;
 
 public class Session extends Application {
     private static Game game;
@@ -33,6 +34,10 @@ public class Session extends Application {
     public void start(Stage stage) throws IOException {
         FXMLLoader fxmlLoader = new FXMLLoader(Session.class.getResource("game.fxml"));
         Scene scene = new Scene(fxmlLoader.load(), 1280, 720);
+
+        String cssPath = Objects.requireNonNull(Session.class.getResource("css/style.css")).toExternalForm();
+        scene.getStylesheets().add(cssPath);
+
         stage.setTitle("Schmorn");
         stage.setScene(scene);
         stage.show();

+ 3 - 3
src/main/java/eu/oschl/gui/actions/Explore.java

@@ -32,9 +32,9 @@ public class Explore implements Action {
         var objects = room.getObjects();
         var passages = room.getPassages();
 
-        Output.print(room.getName(), Color.BLUEVIOLET);
+        Output.print(room.getName(), Color.ALICEBLUE);
         Output.printLine();
-        Output.print(room.getDescription(), Color.BLUE);
+        Output.print(room.getDescription(), Color.LIGHTBLUE);
 
         if (room.getEnemy().isPresent()) {
             if (room.getEnemy().get().isAlive()) {
@@ -96,7 +96,7 @@ public class Explore implements Action {
 
                 if (passage.isSeeThrough() || passage.getOtherRoom(room).wasEntered()) {
                     Output.print(" - leading to ");
-                    Output.print(passage.getOtherRoom(room).getName(), Color.BLUE);
+                    Output.print(passage.getOtherRoom(room).getName(), Color.LIGHTBLUE);
                 } else {
                     Output.print(" - it's impossible to see what's on the other side", Color.RED);
                 }

+ 50 - 0
src/main/resources/eu/oschl/gui/css/style.css

@@ -0,0 +1,50 @@
+@font-face {
+	font-family: "Iosevka Slab";
+	src: url("fonts/SGr-IosevkaSlab-Regular.ttc");
+}
+
+.root {
+	-fx-background-color: #2e2e2e;
+	-fx-font-family: "Iosevka Slab", serif;
+	-fx-font-size: 1.6em;
+}
+
+.scroll-pane {
+	-fx-background-color: #2e2e2e;
+}
+
+.scroll-pane > .viewport {
+	-fx-background-color: #2e2e2e;
+}
+
+.text-flow {
+	-fx-background-color: #2e2e2e;
+}
+
+.text, .label {
+	-fx-fill: #cccccc;
+	-fx-text-fill: #cccccc;
+}
+
+.label, .text {
+	-fx-fill: #cccccc;
+	-fx-text-fill: #cccccc;
+}
+
+.vbox, .grid-pane, .scroll-pane {
+	-fx-background-color: #2e2e2e;
+}
+
+.button {
+	-fx-background-color: #555555;
+	-fx-text-fill: white;
+	-fx-border-color: #444444;
+}
+
+.button:hover {
+	-fx-background-color: #666666;
+}
+
+.button:focused {
+	-fx-border-color: #007bff;
+}

BIN
src/main/resources/eu/oschl/gui/fonts/SGr-IosevkaSlab-Regular.ttc