From b92a9c1ec9b7e8a39ff098d25dfda517a3338721 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sat, 13 May 2023 19:10:58 -0600 Subject: added about dialog and fixed squished text on stock linux --- .../serverfordummies/controllers/InfoController.kt | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/InfoController.kt (limited to 'app/src/main/kotlin/xyz/brysonsteck/serverfordummies/controllers/InfoController.kt') 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 -- cgit v1.2.3