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)) { println("hi") try { when { split[1].equals("email") -> { println("email") desktop.browse(URI("mailto:" + websites[split[0]])) } split[1].equals("website") -> { println("website") desktop.browse(URI(websites[split[0]])) } split[0].equals("source") -> { println("source") desktop.browse(URI(source)) } split[0].equals("license") -> { println("license") desktop.browse(URI(license)) } else -> { println("unknown") } } } catch (e: Exception) { println(e) } } println("done") } @FXML private fun closeInfo(e: ActionEvent) { val source = e.getSource() as Node val stage = source.getScene().getWindow() as Stage stage.close(); } }