Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
0161bd5479
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -19,6 +19,7 @@ jpackage \
|
|||
--name "Ace of Shades Launcher" \
|
||||
--app-version "1.0.0" \
|
||||
--description "Launcher app for Ace of Shades, a voxel-based first-person shooter." \
|
||||
--icon ../icon.ico \
|
||||
--linux-shortcut \
|
||||
--linux-deb-maintainer "andrewlalisofficial@gmail.com" \
|
||||
--linux-menu-group "Game" \
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
# This script prepares and runs the jpackage command to generate a Windows AOS Client installer.
|
||||
|
||||
$projectDir = $PSScriptRoot
|
||||
Push-Location $projectDir\target
|
||||
|
||||
# Remove existing file if it exists.
|
||||
Write-Output "Removing existing exe file."
|
||||
Get-ChildItem *.exe | ForEach-Object { Remove-Item -Path $_.FullName -Force }
|
||||
Write-Output "Done."
|
||||
|
||||
# Run the build
|
||||
Write-Output "Building the project."
|
||||
Push-Location $projectDir
|
||||
mvn clean package
|
||||
|
||||
# Get list of dependency modules that maven copied into the lib directory.
|
||||
Push-Location $projectDir\target
|
||||
$modules = Get-ChildItem -Path lib -Name | ForEach-Object { "lib\$_" }
|
||||
# Add our own main module.
|
||||
$mainModuleJar = Get-ChildItem -Name -Include "aos2-launcher-*.jar" -Exclude "*-jar-with-dependencies.jar"
|
||||
$modules += $mainModuleJar
|
||||
Write-Output "Found modules: $modules"
|
||||
$modulePath = $modules -join ';'
|
||||
|
||||
Write-Output "Running jpackage..."
|
||||
jpackage `
|
||||
--type msi `
|
||||
--name "Ace-of-Shades" `
|
||||
--app-version "1.0.0" `
|
||||
--description "Top-down 2D shooter game inspired by Ace of Spades." `
|
||||
--icon ..\icon.ico `
|
||||
--win-shortcut `
|
||||
--win-dir-chooser `
|
||||
--win-per-user-install `
|
||||
--win-menu `
|
||||
--win-shortcut `
|
||||
--win-menu-group "Game" `
|
||||
--module-path "$modulePath" `
|
||||
--module aos2_launcher/nl.andrewl.aos2_launcher.Launcher `
|
||||
--add-modules jdk.crypto.cryptoki
|
||||
|
||||
Write-Output "Done!"
|
|
@ -4,11 +4,9 @@ import javafx.application.Platform;
|
|||
import javafx.beans.binding.BooleanBinding;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ProgressBar;
|
||||
import javafx.scene.control.ProgressIndicator;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Window;
|
||||
import nl.andrewl.aos2_launcher.model.Profile;
|
||||
import nl.andrewl.aos2_launcher.model.ProfileSet;
|
||||
import nl.andrewl.aos2_launcher.model.ProgressReporter;
|
||||
|
@ -32,10 +30,11 @@ public class MainViewController implements ProgressReporter {
|
|||
@FXML public VBox progressVBox;
|
||||
@FXML public Label progressLabel;
|
||||
@FXML public ProgressBar progressBar;
|
||||
@FXML public TextField registryUrlField;
|
||||
|
||||
private final ProfileSet profileSet = new ProfileSet();
|
||||
|
||||
private final ServersFetcher serversFetcher = new ServersFetcher();
|
||||
private ServersFetcher serversFetcher;
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
|
@ -61,14 +60,24 @@ public class MainViewController implements ProgressReporter {
|
|||
|
||||
progressVBox.managedProperty().bind(progressVBox.visibleProperty());
|
||||
progressVBox.setVisible(false);
|
||||
refreshServers();
|
||||
|
||||
serversFetcher = new ServersFetcher(registryUrlField.textProperty());
|
||||
Platform.runLater(this::refreshServers);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void refreshServers() {
|
||||
serversFetcher.fetchServers()
|
||||
Window owner = this.profilesVBox.getScene().getWindow();
|
||||
serversFetcher.fetchServers(owner)
|
||||
.exceptionally(throwable -> {
|
||||
throwable.printStackTrace();
|
||||
Platform.runLater(() -> {
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setHeaderText("Couldn't fetch servers.");
|
||||
alert.setContentText("An error occurred, and the list of servers couldn't be fetched: " + throwable.getMessage() + ". Are you sure that you have the correct registry URL? Check the \"Servers\" tab.");
|
||||
alert.initOwner(owner);
|
||||
alert.show();
|
||||
});
|
||||
return new ArrayList<>();
|
||||
})
|
||||
.thenAccept(newServers -> Platform.runLater(() -> {
|
||||
|
|
|
@ -4,6 +4,11 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.stage.Window;
|
||||
import nl.andrewl.aos2_launcher.model.Server;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -16,18 +21,28 @@ import java.util.List;
|
|||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
class ServersFetcher {
|
||||
private static final String registryURL = "http://localhost:8080";
|
||||
|
||||
private final HttpClient httpClient;
|
||||
private final Gson gson;
|
||||
private final StringProperty registryUrl;
|
||||
|
||||
public ServersFetcher() {
|
||||
public ServersFetcher(StringProperty registryUrlProperty) {
|
||||
httpClient = HttpClient.newBuilder().build();
|
||||
gson = new Gson();
|
||||
this.registryUrl = new SimpleStringProperty("http://localhost:8080");
|
||||
registryUrl.bind(registryUrlProperty);
|
||||
}
|
||||
|
||||
public CompletableFuture<List<Server>> fetchServers() {
|
||||
HttpRequest req = HttpRequest.newBuilder(URI.create(registryURL + "/servers"))
|
||||
public CompletableFuture<List<Server>> fetchServers(Window owner) {
|
||||
if (registryUrl.get() == null || registryUrl.get().isBlank()) {
|
||||
Platform.runLater(() -> {
|
||||
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||
alert.setContentText("Invalid or missing registry URL. Can't fetch the list of servers.");
|
||||
alert.initOwner(owner);
|
||||
alert.show();
|
||||
});
|
||||
return CompletableFuture.completedFuture(new ArrayList<>());
|
||||
}
|
||||
HttpRequest req = HttpRequest.newBuilder(URI.create(registryUrl.get() + "/servers"))
|
||||
.GET()
|
||||
.timeout(Duration.ofSeconds(3))
|
||||
.header("Accept", "application/json")
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<VBox minHeight="300.0" minWidth="300.0" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nl.andrewl.aos2_launcher.MainViewController">
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<VBox minHeight="300.0" minWidth="300.0" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nl.andrewl.aos2_launcher.MainViewController">
|
||||
<TabPane tabClosingPolicy="UNAVAILABLE" VBox.vgrow="ALWAYS">
|
||||
<Tab text="Profiles">
|
||||
<VBox>
|
||||
|
@ -22,6 +23,7 @@
|
|||
<VBox>
|
||||
<HBox alignment="CENTER" styleClass="button-bar" VBox.vgrow="NEVER">
|
||||
<Button onAction="#refreshServers" text="Refresh" />
|
||||
<TextField fx:id="registryUrlField" prefWidth="300.0" promptText="Registry URL" text="http://localhost:8080" style="-fx-font-size: 10px;" />
|
||||
</HBox>
|
||||
<ScrollPane fitToWidth="true" VBox.vgrow="ALWAYS">
|
||||
<VBox fx:id="serversVBox" styleClass="banner-list" />
|
||||
|
@ -30,26 +32,19 @@
|
|||
</Tab>
|
||||
</TabPane>
|
||||
<HBox alignment="CENTER" styleClass="button-bar" VBox.vgrow="NEVER">
|
||||
<Button
|
||||
fx:id="playButton"
|
||||
mnemonicParsing="false"
|
||||
onAction="#play"
|
||||
text="Play"
|
||||
/>
|
||||
<Button fx:id="playButton" mnemonicParsing="false" onAction="#play" text="Play" />
|
||||
</HBox>
|
||||
<VBox fx:id="progressVBox" VBox.vgrow="NEVER">
|
||||
<AnchorPane VBox.vgrow="NEVER">
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
</padding>
|
||||
<Label fx:id="progressLabel" text="Work in progress..." AnchorPane.bottomAnchor="0.0"
|
||||
AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<Label fx:id="progressLabel" text="Work in progress..." AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<font>
|
||||
<Font size="10.0"/>
|
||||
<Font size="10.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<ProgressBar fx:id="progressBar" prefWidth="200.0" progress="0.0" AnchorPane.bottomAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
|
||||
<ProgressBar fx:id="progressBar" prefWidth="200.0" progress="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</AnchorPane>
|
||||
</VBox>
|
||||
</VBox>
|
||||
|
|
Loading…
Reference in New Issue