diff --git a/README.md b/README.md index 94922aa3..29d735c0 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,24 @@ the future, see the [corresponding issue](https://github.com/marvk/vatprism/issu #### Linux -Currently, there is no support for native linux binaries. It is still possible to run VATprism, though you are going to +If you are using Arch Linux or any derivatives, you can use the third-party [vatprism](https://aur.archlinux.org/packages/vatprism) +package on the AUR. + +Using `yay` as your AUR helper... +``` +yay -Sy vatprism +``` + +Using no AUR helper... +``` +git clone https://aur.archlinux.org/vatprism.git && cd vatprism +makepkg -si +``` +It is still possible to run VATprism on other distros, though you are going to have to compile it yourself. For this, please refer to the [Build](#build) section of this readme. -If there is demand for Linux native binaries in the future, I will think about adding support. Feel free to -request [Linux](https://github.com/marvk/vatprism/issues/31) builds via the linked issue. +If there is demand for more Linux native binaries in the future, I will think about adding support. Feel free to +request different [Linux](https://github.com/marvk/vatprism/issues/31) builds via the linked issue. ## Build diff --git a/src/main/java/net/marvk/fs/vatsim/map/data/ConfigFilePreferences.java b/src/main/java/net/marvk/fs/vatsim/map/data/ConfigFilePreferences.java index 140ed6e7..28598435 100644 --- a/src/main/java/net/marvk/fs/vatsim/map/data/ConfigFilePreferences.java +++ b/src/main/java/net/marvk/fs/vatsim/map/data/ConfigFilePreferences.java @@ -63,6 +63,7 @@ public ConfigFilePreferences(@Named("userConfigDir") final Path path, @Named("co booleanProperty("general.prereleases", false); booleanProperty("general.delete_old_logs", true); stringProperty("meta.version", "0.0.0"); + stringProperty("meta.install_method", "default"); booleanProperty("ui.auto_color", true); booleanProperty("ui.auto_shade", true); diff --git a/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java b/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java index 486dfe02..7e3df2cc 100644 --- a/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java +++ b/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java @@ -2,6 +2,7 @@ import de.saxsys.mvvmfx.FxmlView; import de.saxsys.mvvmfx.InjectViewModel; +import de.saxsys.mvvmfx.internal.viewloader.DependencyInjector; import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.input.MouseButton; @@ -10,11 +11,15 @@ import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Window; +import lombok.extern.log4j.Log4j2; import net.marvk.fs.vatsim.map.api.VersionResponse; +import net.marvk.fs.vatsim.map.data.Preferences; +import java.io.File; import java.time.LocalDate; import java.util.Base64; +@Log4j2 public class PreloaderView implements FxmlView { @FXML private Label header; @@ -47,6 +52,8 @@ public class PreloaderView implements FxmlView { private PreloaderViewModel viewModel; public void initialize() { + final Preferences prefs = DependencyInjector.getInstance().getInstanceOf(Preferences.class); + viewModel.progressPropertyWritable().bindBidirectional(progressBar.progressProperty()); task.textProperty().bind(viewModel.taskDescriptionProperty()); error.textProperty().bind(viewModel.errorProperty()); @@ -65,9 +72,14 @@ public void initialize() { }); versionAndName.setText(viewModel.getVersionAndName()); + checkInstallMethod(prefs); + viewModel.versionResponseProperty().addListener((observable, oldValue, response) -> { if (response != null && response.getResult() == VersionResponse.Result.OUTDATED) { - showNewVersionDialog(response); + switch (prefs.stringProperty("meta.install_method").get()) { + case "aur" -> showNewVersionDialog(response, "the Arch User Repository"); + default -> showNewVersionDialog(response); + } } }); @@ -81,7 +93,7 @@ private void showNewVersionDialog(final VersionResponse response) { final Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.initOwner(taskHolder.getScene().getWindow()); alert.setTitle("New Version Available!"); - alert.setHeaderText("A new Version of VATprism (%s) is available.".formatted(response.getLatestVersion())); + alert.setHeaderText("A new version of VATprism (%s) is available.".formatted(response.getLatestVersion())); alert.setContentText("Would you like to download the latest version?"); alert.getButtonTypes().setAll(download, postpone); final TextArea textArea = new TextArea(response.getChangelog()); @@ -104,6 +116,29 @@ private void showNewVersionDialog(final VersionResponse response) { .ifPresent(e -> viewModel.downloadNewVersion()); } + private void showNewVersionDialog(final VersionResponse response, final String alt) { + final ButtonType close = new ButtonType("Close"); + + final Alert alert = new Alert(Alert.AlertType.INFORMATION); + alert.initOwner(taskHolder.getScene().getWindow()); + alert.setTitle("New Version Available!"); + alert.setHeaderText("A new version of VATprism (%s) is available.".formatted(response.getLatestVersion())); + alert.setContentText("Please update using " + alt + "."); + alert.getButtonTypes().setAll(close); + final TextArea textArea = new TextArea(response.getChangelog()); + textArea.setEditable(false); + textArea.setWrapText(true); + textArea.setPrefHeight(100); + final VBox changelogBox = new VBox(new Label("Changelog:"), textArea); + alert.getDialogPane().setExpandableContent(changelogBox); + alert.getDialogPane().setExpanded(true); + final Window window = alert.getDialogPane().getScene().getWindow(); + window.setOnCloseRequest(e -> window.hide()); + + ((Button) alert.getDialogPane().lookupButton(close)).setDefaultButton(true); + alert.showAndWait(); + } + @FXML private void goToIssuePage(final MouseEvent event) { if (event.getButton() == MouseButton.PRIMARY) { @@ -128,4 +163,14 @@ private void checkSpecial() { private static String decode(final String s) { return new String(Base64.getDecoder().decode(s)); } + + private void checkInstallMethod(Preferences prefs) { + final String os = System.getProperty("os.name"); + String method = "default"; + if (os.contains("nix") || os.contains("nux")) { + method = new File("/etc/vatprism/aur").exists() ? "aur" : "default"; + } + prefs.stringProperty("meta.install_method").set(method); + log.info("Install method - " + method); + } }