Skip to content

Commit

Permalink
Beautify the program interface
Browse files Browse the repository at this point in the history
  • Loading branch information
GZYangKui committed Jan 12, 2023
1 parent cfd3aa4 commit 164d250
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 7 deletions.
17 changes: 13 additions & 4 deletions app/src/main/java/cn/navclub/nes4j/app/INes.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package cn.navclub.nes4j.app;

import cn.navclub.nes4j.app.config.EventBusAddress;
import cn.navclub.nes4j.app.config.NESConfig;
import cn.navclub.nes4j.app.util.JsonUtil;
import cn.navclub.nes4j.app.util.StrUtil;
import cn.navclub.nes4j.app.view.GameHall;
import cn.navclub.nes4j.bin.eventbus.EventBus;
import javafx.application.Application;

import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ResourceBundle;

@Slf4j
Expand All @@ -30,9 +27,21 @@ public class INes extends Application {

@Override
public void start(Stage stage) {
this.localEventBus();
new GameHall(stage);
}

/**
* Register app internal event-bus
*/
public void localEventBus() {
//Open uri use system default browser
eventBus.<String>listener(EventBusAddress.OPEN_URI, message -> {
getHostServices().showDocument(message.body());
return null;
});
}

public static String localeValue(String key) {
return localeValue(key, false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package cn.navclub.nes4j.app.config;

public class EventBusAddress {
public static final String OPEN_URI = "nes4j:app:uri";
}
6 changes: 6 additions & 0 deletions app/src/main/java/cn/navclub/nes4j/app/view/GameHall.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cn.navclub.nes4j.app.INes;
import cn.navclub.nes4j.app.assets.FXResource;
import cn.navclub.nes4j.app.concurrent.TaskService;
import cn.navclub.nes4j.app.config.EventBusAddress;
import cn.navclub.nes4j.app.control.GameTray;
import cn.navclub.nes4j.app.dialog.DNesHeader;
import cn.navclub.nes4j.bin.eventbus.Message;
Expand Down Expand Up @@ -116,6 +117,11 @@ protected List<File> call() {
};
}

@FXML
public void github() {
INes.eventBus.publish(EventBusAddress.OPEN_URI, "https://github.com/GZYangKui/nes4j");
}

@FXML
public void exit() {
Platform.exit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
-fx-background-color: -nes4j-game-hall-navbar;
}

.navbar {
-fx-pref-height: 4em;
.navbar * {
-fx-font-size: 1.1em;
}

.x-box {
Expand Down Expand Up @@ -49,6 +49,10 @@
-fx-text-fill: -nes4j-game-tray-hover-text-color;
}

.assort {
-fx-max-width: 9em;
}

.assort .list-cell {
-fx-background-color: -nes4j-game-hall-list-view;
-fx-focus-traversable: false;
Expand All @@ -59,3 +63,53 @@
-fx-background-color: -nes4j-game-hall-list-cell-active;
}

.navbar .left-box, .navbar .right-box {
-fx-spacing: .7em;
-fx-padding: 0 .1em;
}

.navbar .left-box {
-fx-alignment: CENTER-LEFT;
}

.navbar .right-box {
-fx-alignment: CENTER-RIGHT;
}

.navbar .button {
-fx-padding: 0;
-fx-background-color: transparent;
-fx-text-fill: -nes4j-game-hall-text-fill;
}

.navbar .button:hover {
-fx-text-fill: -nes4j-game-hall-list-cell-text;
}

.navbar .button:hover .prefix {
-fx-background-color: -nes4j-game-hall-list-cell-text;
}

.navbar .button .prefix {
-fx-pref-width: 1em;
-fx-background-color: -nes4j-game-hall-text-fill;
}

.navbar .button .donate {
-fx-shape: "M832 296.6H660.1l20.5-21.2c29-29.8 29-78.2 0-108.1-14.5-14.9-33.5-22.4-52.5-22.4s-38 7.4-52.4 22.4L504 241.6l-73.7-79.3c-14.5-15.5-33.5-23.2-52.5-23.2s-38 7.7-52.5 23.2c-29 31-29 81.4 0 112.4l20.4 21.9H174.3c-19.6 0-35.5 16.3-35.5 36.3v144c0 20.1 15.9 36.3 35.5 36.3h23.4v298.5c0 20 15.8 36.2 35.3 36.2h539.9c19.5 0 35.3-16.2 35.3-36.2V660.1v-8-21.3-8.7-6-10.9-9.3-82.7H832c19.6 0 35.5-16.2 35.5-36.3v-21.7-119.7-2.7c-0.1-19.9-15.9-36.2-35.5-36.2z m-213.8-88.3c3.5-3.6 7.3-4.3 10-4.3s6.5 0.8 10.1 4.4c6.8 7 6.8 18.9 0 25.9l-39.8 41h-44.9l64.6-67z m-249.7-5.7c3.5-3.7 7-4.5 9.3-4.5 2.3 0 5.8 0.8 9.3 4.6l69 74.2h-47.9l-39.7-42.5c-7.7-8.3-7.7-23.4 0-31.8zM197.9 355.7h275.7v98.4H197.9v-98.4z m58.9 157.5h216.9v275.7H256.8V513.2z m492.3 139V789H532.7V513.2h216.4v139z m59.3-198.1H532.7v-98.4h275.6v98.4z";
}

.navbar .button .setting {
-fx-shape: "M512 328c-100.8 0-184 83.2-184 184S411.2 696 512 696 696 612.8 696 512 612.8 328 512 328z m0 320c-75.2 0-136-60.8-136-136s60.8-136 136-136 136 60.8 136 136-60.8 136-136 136z M857.6 572.8c-20.8-12.8-33.6-35.2-33.6-60.8s12.8-46.4 33.6-60.8c14.4-9.6 20.8-27.2 16-44.8-8-27.2-19.2-52.8-32-76.8-8-14.4-25.6-24-43.2-19.2-24 4.8-48-1.6-65.6-19.2-17.6-17.6-24-41.6-19.2-65.6 3.2-16-4.8-33.6-19.2-43.2-24-14.4-51.2-24-76.8-32-16-4.8-35.2 1.6-44.8 16-12.8 20.8-35.2 33.6-60.8 33.6s-46.4-12.8-60.8-33.6c-9.6-14.4-27.2-20.8-44.8-16-27.2 8-52.8 19.2-76.8 32-14.4 8-24 25.6-19.2 43.2 4.8 24-1.6 49.6-19.2 65.6-17.6 17.6-41.6 24-65.6 19.2-16-3.2-33.6 4.8-43.2 19.2-14.4 24-24 51.2-32 76.8-4.8 16 1.6 35.2 16 44.8 20.8 12.8 33.6 35.2 33.6 60.8s-12.8 46.4-33.6 60.8c-14.4 9.6-20.8 27.2-16 44.8 8 27.2 19.2 52.8 32 76.8 8 14.4 25.6 22.4 43.2 19.2 24-4.8 49.6 1.6 65.6 19.2 17.6 17.6 24 41.6 19.2 65.6-3.2 16 4.8 33.6 19.2 43.2 24 14.4 51.2 24 76.8 32 16 4.8 35.2-1.6 44.8-16 12.8-20.8 35.2-33.6 60.8-33.6s46.4 12.8 60.8 33.6c8 11.2 20.8 17.6 33.6 17.6 3.2 0 8 0 11.2-1.6 27.2-8 52.8-19.2 76.8-32 14.4-8 24-25.6 19.2-43.2-4.8-24 1.6-49.6 19.2-65.6 17.6-17.6 41.6-24 65.6-19.2 16 3.2 33.6-4.8 43.2-19.2 14.4-24 24-51.2 32-76.8 4.8-17.6-1.6-35.2-16-44.8z m-56 92.8c-38.4-6.4-76.8 6.4-104 33.6-27.2 27.2-40 65.6-33.6 104-17.6 9.6-36.8 17.6-56 24-22.4-30.4-57.6-49.6-97.6-49.6-38.4 0-73.6 17.6-97.6 49.6-19.2-6.4-38.4-14.4-56-24 6.4-38.4-6.4-76.8-33.6-104-27.2-27.2-65.6-40-104-33.6-9.6-17.6-17.6-36.8-24-56 30.4-22.4 49.6-57.6 49.6-97.6 0-38.4-17.6-73.6-49.6-97.6 6.4-19.2 14.4-38.4 24-56 38.4 6.4 76.8-6.4 104-33.6 27.2-27.2 40-65.6 33.6-104 17.6-9.6 36.8-17.6 56-24 22.4 30.4 57.6 49.6 97.6 49.6 38.4 0 73.6-17.6 97.6-49.6 19.2 6.4 38.4 14.4 56 24-6.4 38.4 6.4 76.8 33.6 104 27.2 27.2 65.6 40 104 33.6 9.6 17.6 17.6 36.8 24 56-30.4 22.4-49.6 57.6-49.6 97.6 0 38.4 17.6 73.6 49.6 97.6-6.4 19.2-14.4 38.4-24 56z";
}

.navbar .button .github {
-fx-shape: "M512 42.666667A464.64 464.64 0 0 0 42.666667 502.186667 460.373333 460.373333 0 0 0 363.52 938.666667c23.466667 4.266667 32-9.813333 32-22.186667v-78.08c-130.56 27.733333-158.293333-61.44-158.293333-61.44a122.026667 122.026667 0 0 0-52.053334-67.413333c-42.666667-28.16 3.413333-27.733333 3.413334-27.733334a98.56 98.56 0 0 1 71.68 47.36 101.12 101.12 0 0 0 136.533333 37.973334 99.413333 99.413333 0 0 1 29.866667-61.44c-104.106667-11.52-213.333333-50.773333-213.333334-226.986667a177.066667 177.066667 0 0 1 47.36-124.16 161.28 161.28 0 0 1 4.693334-121.173333s39.68-12.373333 128 46.933333a455.68 455.68 0 0 1 234.666666 0c89.6-59.306667 128-46.933333 128-46.933333a161.28 161.28 0 0 1 4.693334 121.173333A177.066667 177.066667 0 0 1 810.666667 477.866667c0 176.64-110.08 215.466667-213.333334 226.986666a106.666667 106.666667 0 0 1 32 85.333334v125.866666c0 14.933333 8.533333 26.88 32 22.186667A460.8 460.8 0 0 0 981.333333 502.186667 464.64 464.64 0 0 0 512 42.666667";
}

.navbar .button .back {
-fx-shape: "M341.333334 512 597.333334 170.666666 682.666666 170.666666 426.666666 512 682.666666 853.333336 597.333334 853.333336 341.333334 512Z";
}



Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<?import cn.navclub.nes4j.app.event.NodeDragEvent?>
<?import cn.navclub.nes4j.app.control.SearchTextField?>
<?import javafx.scene.shape.Circle?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<BorderPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml" stylesheets="@../css/GameHallStyle.css">
<fx:define>
Expand All @@ -26,7 +28,31 @@
<center>
<VBox styleClass="content">
<HBox fx:id="navbar" styleClass="navbar" NodeDragEvent.bind="">
<SearchTextField/>
<HBox styleClass="left-box">
<Button>
<graphic>
<Label styleClass="prefix,back"/>
</graphic>
</Button>
<SearchTextField/>
</HBox>
<HBox HBox.hgrow="ALWAYS" styleClass="right-box">
<Button text="%nes4j.donate">
<graphic>
<Label styleClass="prefix,donate"/>
</graphic>
</Button>
<Button text="%nes4j.setting">
<graphic>
<Label styleClass="prefix,setting"/>
</graphic>
</Button>
<Button onAction="#github">
<graphic>
<Label styleClass="prefix,github"/>
</graphic>
</Button>
</HBox>
</HBox>
<StackPane VBox.vgrow="ALWAYS">
<ScrollPane fitToHeight="true" fitToWidth="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ nes4j.search=search
nes4j.debug=Debug
nes4j.reset=Reset
nes4j.handle=Handle
nes4j.donate=Donate
nes4j.pplay=Play/Pause
nes4j.setting=Setting
nes4j.palette=Palette
nes4j.options=Options
nes4j.emulator=Emulator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ nes4j.run=运行
nes4j.debug=调试
nes4j.search=搜索
nes4j.handle=手柄
nes4j.donate=捐赠
nes4j.setting=设置
nes4j.palette=画布
nes4j.options=选项
nes4j.emulator=模拟器
Expand Down

0 comments on commit 164d250

Please sign in to comment.