From b92a9c1ec9b7e8a39ff098d25dfda517a3338721 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sat, 13 May 2023 19:10:58 -0600 Subject: [PATCH] added about dialog and fixed squished text on stock linux --- .../controllers/InfoController.kt | 51 ++++ .../{ => controllers}/PrimaryController.kt | 27 +- .../serverfordummies/css/info-tabs.css | 5 + .../brysonsteck/serverfordummies/info.fxml | 108 ++++++++ .../brysonsteck/serverfordummies/primary.fxml | 231 ++++++++++++------ 5 files changed, 345 insertions(+), 77 deletions(-) create mode 100644 app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/InfoController.kt rename app/src/main/kotlin/xyz/brysonsteck/serverfordummies/{ => controllers}/PrimaryController.kt (95%) create mode 100644 app/src/main/resources/xyz/brysonsteck/serverfordummies/css/info-tabs.css create mode 100644 app/src/main/resources/xyz/brysonsteck/serverfordummies/info.fxml diff --git a/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/InfoController.kt b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/InfoController.kt new file mode 100644 index 0000000..b91d3e2 --- /dev/null +++ b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/InfoController.kt @@ -0,0 +1,51 @@ +package xyz.brysonsteck.serverfordummies.controllers + +import javafx.fxml.FXML +import javafx.application.Platform +import javafx.scene.Node +import javafx.scene.control.Hyperlink +import javafx.stage.Stage +import javafx.event.ActionEvent +import java.awt.Desktop +import java.net.URI + +class InfoController { + private val emails = mapOf( + "bryson" to "me@brysonsteck.xyz" + ) + private val websites = mapOf( + "bryson" to "https://brysonsteck.xyz" + ) + private val source = "https://codeberg.org/brysonsteck/ServerCraft" + private val license = "https://www.gnu.org/licenses/gpl-3.0.html" + + @FXML + private fun openHyperlink(e: ActionEvent) { + val link = e.source as Hyperlink + link.isVisited = false + val split = link.id.split('_') + + val desktop = Desktop.getDesktop() + if (desktop.isSupported(Desktop.Action.BROWSE)) { + try { + when { + split[1].equals("email") -> { + desktop.browse(URI("mailto:" + websites[split[0]])) + } + else -> { + desktop.browse(URI(websites[split[0]])) + } + } + } catch (e: Exception) { + println(e) + } + } + } + + @FXML + private fun closeInfo(e: ActionEvent) { + val source = e.getSource() as Node + val stage = source.getScene().getWindow() as Stage + stage.close(); + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/PrimaryController.kt b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/PrimaryController.kt similarity index 95% rename from app/src/main/kotlin/xyz/brysonsteck/serverfordummies/PrimaryController.kt rename to app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/PrimaryController.kt index 4939a26..d854138 100644 --- a/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/PrimaryController.kt +++ b/app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/PrimaryController.kt @@ -1,4 +1,4 @@ -package xyz.brysonsteck.serverfordummies +package xyz.brysonsteck.serverfordummies.controllers import kotlinx.coroutines.* import kotlinx.coroutines.javafx.JavaFx @@ -20,6 +20,7 @@ import javafx.concurrent.Task import javafx.beans.property.BooleanProperty import javafx.collections.FXCollections import javafx.fxml.FXML +import javafx.fxml.FXMLLoader import javafx.geometry.Insets import javafx.scene.control.Button import javafx.scene.control.ChoiceBox @@ -53,6 +54,7 @@ import org.rauschig.jarchivelib.* import Download import xyz.brysonsteck.serverfordummies.server.Server +import xyz.brysonsteck.serverfordummies.App class PrimaryController { @FXML @@ -170,12 +172,15 @@ class PrimaryController { if (res) { parentPane.isDisable = false worldSettingsPane.isDisable = false - buttonBar.isDisable = false + buildButton.isDisable = false + defaultsButton.isDisable = false } else { currentDirectoryLabel.text = "" parentPane.isDisable = true worldSettingsPane.isDisable = true - buttonBar.isDisable = true + startButton.isDisable = true + buildButton.isDisable = true + defaultsButton.isDisable = true } } } @@ -209,6 +214,18 @@ class PrimaryController { } + @FXML + private fun onInfo() { + val stage = Stage() + val scene = Scene(FXMLLoader(App().javaClass.getResource("info.fxml")).load(), 398.0, 358.0) + stage.icons.add(Image(App().javaClass.getResourceAsStream("app-256x256.png"))) + stage.setResizable(false) + stage.initModality(Modality.APPLICATION_MODAL); + stage.title = "About ServerCraft" + stage.scene = scene + stage.show() + } + @FXML private fun onBuild() { if (building) { @@ -425,7 +442,8 @@ class PrimaryController { imagePane.scaleX = 0.7 imagePane.scaleY = 0.7 imagePane.children.add(ImageView(icon)) - val label = Label("Do you agree to the terms of the Minecraft\nEnd User License Agreement?") + val label = Label("Do you agree to the terms of the Minecraft End User License Agreement?") + label.isWrapText = true label.layoutX = 115.0 label.layoutY = 40.0 val buttonBar = ButtonBar() @@ -485,6 +503,7 @@ class PrimaryController { imagePane.scaleY = 0.7 imagePane.children.add(ImageView(icon)) val label = Label(msg) + label.isWrapText = true label.layoutX = 115.0 label.layoutY = if (type == "warning") {10.0} else {40.0} val buttonBar = ButtonBar() diff --git a/app/src/main/resources/xyz/brysonsteck/serverfordummies/css/info-tabs.css b/app/src/main/resources/xyz/brysonsteck/serverfordummies/css/info-tabs.css new file mode 100644 index 0000000..023b0c1 --- /dev/null +++ b/app/src/main/resources/xyz/brysonsteck/serverfordummies/css/info-tabs.css @@ -0,0 +1,5 @@ +.tab-pane>*.tab-header-area>*.tab-header-background { + -fx-background-color: "#F4F4F4"; + -fx-border-color: "#DCDCDC"; + -fx-border-width: 0 0 1 0 +} \ No newline at end of file diff --git a/app/src/main/resources/xyz/brysonsteck/serverfordummies/info.fxml b/app/src/main/resources/xyz/brysonsteck/serverfordummies/info.fxml new file mode 100644 index 0000000..978bc5c --- /dev/null +++ b/app/src/main/resources/xyz/brysonsteck/serverfordummies/info.fxml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +