Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GZYangKui committed Jan 30, 2023
1 parent 220195e commit c74d37b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 22 deletions.
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
# nes4j

![Build status](https://github.com/GZYangKui/nes4j/actions/workflows/maven.yml/badge.svg)
![Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue)
<div align="center">
<img src="build/icon/nes4j.png" alt="Nes4j logo" width="200" height="auto" />
<h1>Nes4j</h1>
<p>Nintendo red and white simulator</p>
</div>

<div align="center">
<h3>
<a href="https://gitee.com/navigatorCode/nes4j/blob/master/README.md">English Document</a>
</h3>
<h3>
<a href="https://github.com/GZYangKui/nes4j">github repository</a>
</h3>
<img src="https://github.com/GZYangKui/nes4j/actions/workflows/maven.yml/badge.svg" alt="Build status"/>
<img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="Apache 2.0"/>
<img src="https://img.shields.io/badge/I18n-Support-orange.svg" alt="I18n support"/>
<br/>
</div>

![nes4j](https://github.com/GZYangKui/nes4j-example/blob/master/video/32328_1673422550.gif?raw=true)


![nes4j](SNAPSHOTS/Main.png)
![DuckTables](SNAPSHOTS/DuckTables.png)
![Super Mario](SNAPSHOTS/Super%20Mario.png)
## Project introduction

**nes4j**The Nintendo Red and White Machine Simulator is implemented in Java language, mainly
Expand Down
9 changes: 6 additions & 3 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<img src="build/icon/nes4j.png" alt="Nes4j logo" width="200" height="auto" />
<h1>Nes4j</h1>
<p>任天堂红白机模拟器</p>
![Build status](https://github.com/GZYangKui/nes4j/actions/workflows/maven.yml/badge.svg)
![Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue)
</div>

<div align="center">
Expand All @@ -13,12 +11,17 @@
<h3>
<a href="https://github.com/GZYangKui/nes4j">github仓库</a>
</h3>
<img src="https://github.com/GZYangKui/nes4j/actions/workflows/maven.yml/badge.svg" alt="Build status"/>
<img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="Apache 2.0"/>
<img src="https://img.shields.io/badge/I18n-Support-orange.svg" alt="I18n support"/>
<br/>
</div>


<br/>

![nes4j](SNAPSHOTS/Main.png)
![DuckTables](SNAPSHOTS/DuckTables.png)
![Super Mario](SNAPSHOTS/Super%20Mario.png)

## 项目介绍

Expand Down
Binary file added SNAPSHOTS/Main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions app/src/main/java/cn/navclub/nes4j/app/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

import cn.navclub.nes4j.app.config.NESConfig;
import cn.navclub.nes4j.app.util.JsonUtil;
import cn.navclub.nes4j.app.util.OSUtil;
import cn.navclub.nes4j.app.util.StrUtil;
import cn.navclub.nes4j.bin.logging.LoggerFactory;
import cn.navclub.nes4j.bin.logging.LoggerDelegate;
import javafx.application.Application;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;

public class Launcher {
private static final LoggerDelegate log = LoggerFactory.logger(Launcher.class);

private static final String DEFAULT_CONFIG_PATH = "config/config.json";
private static final String DEFAULT_CONFIG_PATH = OSUtil.workstation() + "config.json";

public static void main(String[] args) throws Exception {
//Register global catch thread exception
Expand All @@ -27,9 +29,9 @@ public static void main(String[] args) throws Exception {


/**
* 加载本地配置文件
* Load test environment config
*
* @param args 程序启动参数
* @param args Program args
*/
protected static NESConfig loadLocalConfig(String[] args) throws Exception {
var map = StrUtil.args2Map(args);
Expand Down
24 changes: 17 additions & 7 deletions app/src/main/java/cn/navclub/nes4j/app/util/OSUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,37 @@ public static String userHome(String subdir) {
return String.format("%s%s", path, subdir);
}

public static Path workstation() {
var file = new File(userHome("nes4j"));
public static String workstation() {
return workstation(null);
}

public static String workstation(String subdir) {
final File file;
if (StrUtil.isNotBlank(subdir)) {
file = new File(String.format("%s%s%s", userHome("nes4j"), File.separator, subdir));
} else {
file = new File(userHome("nes4j"));
}
if (!file.exists()) {
var ok = file.mkdir();
var ok = file.mkdirs();
if (!ok) {
log.warning("Create work path:{} fail.", file.getAbsolutePath());
}
}
return file.toPath();
return file.getAbsolutePath() + File.separator;
}

public static Optional<File> mkdirAssort(String assort) {
var path = workstation();
var str = String.format("%s%s%s", path, File.separator, assort);
var path = workstation("rom");
var str = String.format("%s%s", path, assort);
var file = new File(str);
var ok = file.mkdir();
if (log.isDebugEnabled()) {
if (!ok) {
file = null;
}
log.debug("Create target assort:{} result:{}", assort, ok);
assert file != null;
log.debug("Create target assort:{} result:{}", file.getAbsolutePath(), ok);
}
return Optional.ofNullable(file);
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/cn/navclub/nes4j/app/view/GameHall.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void preExecute() {
@Override
@SuppressWarnings("all")
public List<File> execute(Object... params) {
var path = Path.of(OSUtil.workstation().toString(), params[0].toString());
var path = Path.of(OSUtil.workstation("rom"), params[0].toString());
var file = path.toFile();
if (!file.exists() || file.listFiles() == null) {
return List.of();
Expand Down Expand Up @@ -126,7 +126,7 @@ private boolean requestRun(Message<File> message) {
}

private void loadAssort() {
var file = OSUtil.workstation().toFile();
var file = new File(OSUtil.workstation("rom"));
var list = file.listFiles();
if (list == null) {
return;
Expand All @@ -144,7 +144,7 @@ private void loadAssort() {
* otherwise visit <a href="https://github.com">github</a>.</p>
*/
@FXML
public void github() {
public void repository() {
final String uri;
var tid = TimeZone.getDefault().getID();
if (tid.toLowerCase().contains("shanghai")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<Label styleClass="prefix,help"/>
</graphic>
</Button>
<Button onAction="#github" text="%nes4j.repository">
<Button onAction="#repository" text="%nes4j.repository">
<graphic>
<Label styleClass="prefix,github"/>
</graphic>
Expand Down

0 comments on commit c74d37b

Please sign in to comment.