Skip to content

Commit

Permalink
Add New Feature
Browse files Browse the repository at this point in the history
  • Loading branch information
isHarryh committed Mar 9, 2023
1 parent 99af0a7 commit b6ef359
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion core/src/com/isharryh/arkpets/ArkPets.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ else if (BehaviorEnemy5.match(cha.anim_list))
"This model only contains the animation below:\n" + Arrays.toString(cha.anim_list));
throw new RuntimeException("Launch ArkPets failed due to unsupported model.");
}
Gdx.app.log("info", "AP:Use "+behavior.getClass().getName());
Gdx.app.log("info", "AP:Use " + behavior.getClass().getName());
cha.setAnimation(behavior.defaultAnim());
// 6.Tray icon setup
tray = new ArkTray(this);
Expand Down
31 changes: 18 additions & 13 deletions desktop/src/com/isharryh/arkpets/ArkHomeFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.isharryh.arkpets.utils.JavaProcess;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
Expand Down Expand Up @@ -33,9 +34,12 @@ public void start(Stage stage) throws Exception {
// Set handler for internal start button.
Button startBtn = (Button)root.lookup("#Start-btn");
startBtn.setOnAction(e -> {
stage.close();
// When request to launch ArkPets
startArkPets();
Platform.exit();
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
}
});
// Setup scene and show primary stage.
Scene scene = new Scene(root);
Expand All @@ -49,20 +53,21 @@ public void start(Stage stage) throws Exception {
}



/** Run the EmbeddedLauncher to launch the ArkPets app.
* It will run in multi-threading mode provided by JavaFX,
* so this method must be invoked in {@code FXApplicationThread}.
* @see com.isharryh.arkpets.EmbeddedLauncher
* @see javafx.concurrent.Task
*/
public void startArkPets() {
try {
JavaProcess.exec(EmbeddedLauncher.class, false);
} catch (IOException e) {
System.err.println("[error] CAUGHT: IOException");
e.printStackTrace();
} catch (InterruptedException e) {
System.err.println("[error] CAUGHT: InterruptedException");
e.printStackTrace();
}
Task<Boolean> task = new Task<Boolean>() {
@Override
protected Boolean call() throws IOException, InterruptedException {
JavaProcess.exec(EmbeddedLauncher.class, false);
return true;
}
};
Thread thread = new Thread(task);
thread.start();
}

}
2 changes: 1 addition & 1 deletion desktop/src/com/isharryh/arkpets/utils/ArgPending.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean judge(String[] args) {
String command = null;
boolean specified = false;

for (String arg: args) {
for (String arg : args) {
if (arg != null) {
if (specified) {
if (arg.indexOf(argPrefix) != 0)
Expand Down

0 comments on commit b6ef359

Please sign in to comment.