mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 17:37:58 -04:00
Show start progress not always on top, do not open gui while starting, fix window blocking
This commit is contained in:
parent
2c74ed6637
commit
f080432749
@ -143,8 +143,6 @@ public final class Minosoft {
|
|||||||
|
|
||||||
}, "ModLoading", "", Priorities.NORMAL, TaskImportance.REQUIRED));
|
}, "ModLoading", "", Priorities.NORMAL, TaskImportance.REQUIRED));
|
||||||
|
|
||||||
taskWorker.addTask(new Task(progress -> Launcher.start(), "Launcher", "", Priorities.HIGH, TaskImportance.OPTIONAL, "Minosoft Language", "JavaFx Toolkit"));
|
|
||||||
|
|
||||||
taskWorker.addTask(new Task(progress -> {
|
taskWorker.addTask(new Task(progress -> {
|
||||||
progress.countUp();
|
progress.countUp();
|
||||||
AssetsManager.downloadAllAssets(progress);
|
AssetsManager.downloadAllAssets(progress);
|
||||||
@ -168,6 +166,12 @@ public final class Minosoft {
|
|||||||
}, "Game Window", "", Priorities.NORMAL, TaskImportance.REQUIRED, "Assets"));
|
}, "Game Window", "", Priorities.NORMAL, TaskImportance.REQUIRED, "Assets"));
|
||||||
|
|
||||||
taskWorker.work(startStatusLatch);
|
taskWorker.work(startStatusLatch);
|
||||||
|
try {
|
||||||
|
startStatusLatch.waitUntilZero();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
Launcher.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkClientToken() {
|
public static void checkClientToken() {
|
||||||
|
@ -36,7 +36,7 @@ public class Launcher {
|
|||||||
private static Stage stage;
|
private static Stage stage;
|
||||||
private static boolean exit = false;
|
private static boolean exit = false;
|
||||||
|
|
||||||
public static void start() throws Exception {
|
public static void start() {
|
||||||
Log.info("Starting launcher...");
|
Log.info("Starting launcher...");
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
@ -89,7 +89,11 @@ public class Launcher {
|
|||||||
}
|
}
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
});
|
});
|
||||||
latch.await();
|
try {
|
||||||
|
latch.await();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
Log.info("Launcher started!");
|
Log.info("Launcher started!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,4 +105,8 @@ public class Launcher {
|
|||||||
|
|
||||||
Platform.runLater(() -> stage.close());
|
Platform.runLater(() -> stage.close());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Stage getStage() {
|
||||||
|
return stage;
|
||||||
|
}
|
||||||
}
|
}
|
@ -23,6 +23,7 @@ import javafx.scene.control.Dialog;
|
|||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.ProgressBar;
|
import javafx.scene.control.ProgressBar;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
@ -30,7 +31,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
|
|
||||||
public class StartProgressWindow extends Application {
|
public class StartProgressWindow extends Application {
|
||||||
public static CountDownLatch toolkitLatch = new CountDownLatch(2); // 2 if not started, 1 if started, 2 if loaded
|
public static CountDownLatch toolkitLatch = new CountDownLatch(2); // 2 if not started, 1 if started, 2 if loaded
|
||||||
private static Dialog<Boolean> progressDialog;
|
public static Dialog<Boolean> progressDialog;
|
||||||
private static boolean exit = false;
|
private static boolean exit = false;
|
||||||
|
|
||||||
public static void show(CountUpAndDownLatch progress) {
|
public static void show(CountUpAndDownLatch progress) {
|
||||||
@ -53,13 +54,12 @@ public class StartProgressWindow extends Application {
|
|||||||
grid.add(progressBar.get(), 0, 0);
|
grid.add(progressBar.get(), 0, 0);
|
||||||
grid.add(progressLabel.get(), 1, 0);
|
grid.add(progressLabel.get(), 1, 0);
|
||||||
progressDialog.getDialogPane().setContent(grid);
|
progressDialog.getDialogPane().setContent(grid);
|
||||||
|
Stage stage = (Stage) progressDialog.getDialogPane().getScene().getWindow();
|
||||||
|
stage.initModality(Modality.APPLICATION_MODAL);
|
||||||
if (exit) {
|
if (exit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
progressDialog.show();
|
progressDialog.show();
|
||||||
|
|
||||||
Stage stage = (Stage) progressDialog.getDialogPane().getScene().getWindow();
|
|
||||||
stage.setAlwaysOnTop(true);
|
|
||||||
stage.toFront();
|
stage.toFront();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -17,6 +17,7 @@ import de.bixilon.minosoft.modding.loading.Priorities;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class Task {
|
public class Task {
|
||||||
@ -57,6 +58,15 @@ public class Task {
|
|||||||
this.dependsOns = dependsOn;
|
this.dependsOns = dependsOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task(TaskCallable task, String taskName, String taskDescription, Priorities priority, TaskImportance importance, List<Task> dependsOn) {
|
||||||
|
this.task = task;
|
||||||
|
this.taskName = taskName;
|
||||||
|
this.taskDescription = taskDescription;
|
||||||
|
this.priority = priority;
|
||||||
|
this.importance = importance;
|
||||||
|
dependsOn.forEach((dependency) -> this.dependsOns.add(dependency.getTaskName()));
|
||||||
|
}
|
||||||
|
|
||||||
public Task(TaskCallable task, String taskName, String taskDescription, Priorities priority, TaskImportance importance, String... dependsOn) {
|
public Task(TaskCallable task, String taskName, String taskDescription, Priorities priority, TaskImportance importance, String... dependsOn) {
|
||||||
this.task = task;
|
this.task = task;
|
||||||
this.taskName = taskName;
|
this.taskName = taskName;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user