turns out it just doesnt work on linux, reverting and organizing

This commit is contained in:
Bryson Steck 2023-05-14 13:37:55 -06:00
parent efd5388d33
commit 8fbd006b49
8 changed files with 59 additions and 35 deletions

View file

@ -15,7 +15,7 @@ class App : Application() {
override fun start(stage: Stage) {
var scene = Scene(loadFXML("primary"), 963.0, 713.0)
stage.icons.add(Image(this.javaClass.getResourceAsStream("app-256x256.png")))
stage.icons.add(Image(this.javaClass.getResourceAsStream("app.png")))
stage.setResizable(false)
stage.title = "Server For Dummies"
stage.scene = scene

View file

@ -23,39 +23,47 @@ class InfoController {
private fun openHyperlink(e: ActionEvent) {
val link = e.source as Hyperlink
link.isVisited = false
val split = link.id.split('_')
val split = link.id.split('_').toMutableList()
split.add("")
val os = System.getProperty("os.name").lowercase()
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]]))
if (!os.contains("linux")) {
desktop.browse(URI("mailto:" + emails[split[0]]))
} else {
Runtime.getRuntime().exec("xdg-open mailto:" + emails[split[0]])
}
}
split[1].equals("website") -> {
println("website")
if (!os.contains("linux")) {
desktop.browse(URI(websites[split[0]]))
} else {
Runtime.getRuntime().exec("xdg-open " + websites[split[0]])
}
}
split[0].equals("source") -> {
println("source")
if (!os.contains("linux")) {
desktop.browse(URI(source))
} else {
Runtime.getRuntime().exec("xdg-open " + source)
}
}
split[0].equals("license") -> {
println("license")
if (!os.contains("linux")) {
desktop.browse(URI(license))
} else {
Runtime.getRuntime().exec("xdg-open " + license)
}
else -> {
println("unknown")
}
}
} catch (e: Exception) {
println(e)
}
}
println("done")
}
@FXML
private fun closeInfo(e: ActionEvent) {

View file

@ -1,4 +1,4 @@
package xyz.brysonsteck.serverfordummies
package xyz.brysonsteck.serverfordummies.controllers
import kotlinx.coroutines.*
import kotlinx.coroutines.javafx.JavaFx
@ -52,8 +52,8 @@ import javafx.stage.Stage
import javafx.event.EventHandler
import org.rauschig.jarchivelib.*
import Download
import xyz.brysonsteck.serverfordummies.server.Server
import xyz.brysonsteck.serverfordummies.server.Download
import xyz.brysonsteck.serverfordummies.App
class PrimaryController {
@ -218,7 +218,7 @@ class PrimaryController {
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.icons.add(Image(App().javaClass.getResourceAsStream("app.png")))
stage.setResizable(false)
stage.initModality(Modality.APPLICATION_MODAL);
stage.title = "About ServerCraft"
@ -400,6 +400,10 @@ class PrimaryController {
var line = br.readLine()
while (line != null) {
if (asyncResult) {
withContext(Dispatchers.JavaFx) {
statusBar.text = "Killing Minecraft server..."
startButton.isDisable = true
}
proc.destroy()
}
println(line);
@ -420,6 +424,7 @@ class PrimaryController {
parentPane.isDisable = false
buildButton.isDisable = false
defaultsButton.isDisable = false
startButton.isDisable = false
startButton.text = "Start Server"
started = false
}
@ -430,6 +435,7 @@ class PrimaryController {
var result = false
val resources = App().javaClass.getResource("icons/warning.png")
val dialog = Stage()
dialog.icons.add(Image(this.javaClass.getResourceAsStream("app.png")))
dialog.setResizable(false)
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.title = directory
@ -467,12 +473,19 @@ class PrimaryController {
eula.onMouseClicked = EventHandler<MouseEvent>() {
val desktop = Desktop.getDesktop()
if (desktop.isSupported(Desktop.Action.BROWSE)) {
println("made it!")
// most likely running on Windows or macOS
try {
desktop.browse(URI("https://account.mojang.com/documents/minecraft_eula"))
} catch (e: Exception) {
println(e)
}
} else {
// assume running on linux
try {
Runtime.getRuntime().exec("xdg-open https://account.mojang.com/documents/minecraft_eula");
} catch (e: Exception) {
println(e)
}
}
}
ButtonBar.setButtonData(eula, ButtonBar.ButtonData.LEFT)
@ -491,6 +504,7 @@ class PrimaryController {
var result = false
val resources = App().javaClass.getResource("icons/$type.png")
val dialog = Stage()
dialog.icons.add(Image(this.javaClass.getResourceAsStream("app.png")))
dialog.setResizable(false)
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.title = directory

View file

@ -1,3 +1,5 @@
package xyz.brysonsteck.serverfordummies.server
import java.io.*;
import java.net.*;
import java.util.*;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 585 KiB

After

Width:  |  Height:  |  Size: 73 KiB

View file

@ -48,8 +48,8 @@
<Insets bottom="13.0" left="13.0" right="13.0" top="13.0" />
</padding>
</Label>
<Hyperlink fx:id="license" layoutX="127.0" layoutY="101.0" onAction="#openHyperlink" text="License" />
<Hyperlink fx:id="source" layoutX="189.0" layoutY="101.0" onAction="#openHyperlink" text="Source Code" />
<Hyperlink fx:id="license" layoutX="127.0" layoutY="110.0" onAction="#openHyperlink" text="License" />
<Hyperlink fx:id="source" layoutX="189.0" layoutY="110.0" onAction="#openHyperlink" text="Source Code" />
</children>
<padding>
<Insets bottom="13.0" left="13.0" right="13.0" top="13.0" />
@ -61,7 +61,7 @@
<content>
<Pane prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="107.0" layoutY="101.0" text="Want to join the list? Contribute!" textAlignment="CENTER" />
<Label layoutX="78.0" layoutY="109.0" text="Want to join the list? Contribute with a PR!" textAlignment="CENTER" />
<VBox>
<children>
<Label text="Bryson Steck" VBox.vgrow="ALWAYS">

View file

@ -20,7 +20,7 @@
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.text.Font?>
<Pane fx:id="primary" maxHeight="713.0" maxWidth="963.0" minHeight="713.0" minWidth="963.0" prefHeight="713.0" prefWidth="963.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="xyz.brysonsteck.serverfordummies.PrimaryController">
<Pane fx:id="primary" maxHeight="713.0" maxWidth="963.0" minHeight="713.0" minWidth="963.0" prefHeight="713.0" prefWidth="963.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="xyz.brysonsteck.serverfordummies.controllers.PrimaryController">
<children>
<HBox fx:id="directoryPane" prefHeight="39.0" prefWidth="963.0">
<children>