diff --git a/Resources/assets/lang/en_US.lang b/Resources/assets/lang/en_US.lang index ac93863..e7ad1e5 100644 --- a/Resources/assets/lang/en_US.lang +++ b/Resources/assets/lang/en_US.lang @@ -1,6 +1,6 @@ gui.title=Unturned ID Generator-Version gui.button.start=Start Generate -gui.checkbox.workshop=Workshop Items? +gui.checkbox.workshop=Workshop Items? gui.processing=Processing.... gui.error=Sorry,the program ran into a error: gui.result.cost=Total Time: @@ -9,7 +9,7 @@ gui.button.filechoose=Select the game path gui.button.filechoose.select=Select gui.button.filechoose.title=Please select the root path of the game -result.null=None +result.null=#Not Found# unturned.animals=Animals unturned.item=Items unturned.objects=Objects diff --git a/Resources/assets/lang/zh_CN.lang b/Resources/assets/lang/zh_CN.lang index b9d0b00..606b73d 100644 --- a/Resources/assets/lang/zh_CN.lang +++ b/Resources/assets/lang/zh_CN.lang @@ -9,7 +9,7 @@ gui.button.filechoose=选择游戏目录 gui.button.filechoose.select=选择 gui.button.filechoose.title=请选择游戏根目录 -result.null=名称未定义 +result.null=#未找到# unturned.animals=动物 unturned.item=物品 unturned.objects=物体 diff --git a/src/gui/Displayer.java b/src/gui/Displayer.java index 58b9c33..32514f0 100644 --- a/src/gui/Displayer.java +++ b/src/gui/Displayer.java @@ -59,16 +59,19 @@ private static void setUIFont() { } } + private void reset() { + pm.setProgress(100); + selectButton.setEnabled(true); + startButton.setEnabled(true); + } private void initComponents() { - String version = "V3.8"; + String version = "V3.9"; //设置默认异常捕获 Thread.setDefaultUncaughtExceptionHandler((t, e) -> { out.append(getI18nText("gui.error") + "\n" + t.toString() + "\n"); e.printStackTrace(new PrintWriter(new OutputStreamWriter(new JTextAreaWithInputStream(out), StandardCharsets.UTF_8), true)); - pm.setProgress(100); - selectButton.setEnabled(true); - startButton.setEnabled(true); + reset(); }); //将UI设置在所有组件的前面 try { @@ -110,11 +113,13 @@ private void setUpComponents() { path.setText(pathChooser.getSelectedFile().getPath()); } }); - //设置输出区域 + //路径显示预排版 + path.setColumns(30); + //输出区域预排版 out.setRows(30); out.setEditable(false); - //设置进度条 - pm.setMillisToDecideToPopup(0); + //进度条预排版 + pm.setNote("awoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo"); //设置开始按钮事件 startButton.addActionListener((Action) -> { @@ -137,21 +142,25 @@ protected LinkedList doInBackground() throws IOException { class Visitor extends BATFileVisitor { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + if (pm.isCanceled()) { + reset(); + return FileVisitResult.TERMINATE; + } publish(file.toString()); super.visitFile(file, attrs); - return pm.isCanceled() ? FileVisitResult.TERMINATE : FileVisitResult.CONTINUE; + return FileVisitResult.CONTINUE; } } //游戏目录:...\steamapps\common\Unturned Path gamePath = Paths.get(path.getText()); - //创意工坊物品目录:...\steamapps\workshop\content\304930 - Path workshopPath = Paths.get(gamePath.toFile().getParentFile().getParentFile().getPath(), "workshop", "content", "304930"); //判断创意工坊 - if (workShopCheck.isSelected()) { + if (workShopCheck.isSelected() && gamePath.toFile().exists()) { + //创意工坊物品目录:...\steamapps\workshop\content\304930 + Path workshopPath = Paths.get(gamePath.toFile().getParentFile().getParentFile().getPath(), "workshop", "content", "304930"); return Visitor.visit(new Visitor(), gamePath, workshopPath); } else { - return Visitor.visit(new Visitor(), Paths.get(path.getText())); + return Visitor.visit(new Visitor(), gamePath); } } @@ -164,6 +173,9 @@ protected void process(List chunks) { pm.setNote(path); } } + else { + reset(); + } } @Override @@ -193,10 +205,12 @@ protected void done() { } } } - pm.setProgress(100); - selectButton.setEnabled(true); - startButton.setEnabled(true); } + else { + out.setText(getI18nText("result.null")); + } + + reset(); } }.execute(); }); diff --git a/src/io/BATFileVisitor.java b/src/io/BATFileVisitor.java index f020aed..38ef9ab 100644 --- a/src/io/BATFileVisitor.java +++ b/src/io/BATFileVisitor.java @@ -29,7 +29,7 @@ public static LinkedList visit(BATFileVisitor visitor, Path... if (visitor == null) { visitor = new BATFileVisitor(); } - logger.setLevel(Level.INFO); + logger.setLevel(Level.OFF); visitor.itemList.clear(); for (Path path : paths) { Files.walkFileTree(path, visitor); @@ -90,7 +90,7 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - if (file.endsWith("English.dat")) { + if (file.toFile().exists() && file.endsWith("English.dat")) { List info = new ArrayList<>(); String path = file.toString(); // 添加路径信息