added about dialog and fixed squished text on stock linux

This commit is contained in:
Bryson Steck 2023-05-13 19:10:58 -06:00
parent 844a942267
commit b92a9c1ec9
5 changed files with 345 additions and 77 deletions

View file

@ -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();
}
}

View file

@ -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 = "<NONE>"
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()

View file

@ -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
}

View file

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?>
<?import javafx.scene.control.Hyperlink?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="358.0" prefWidth="398.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="xyz.brysonsteck.serverfordummies.controllers.InfoController">
<children>
<ImageView fitHeight="115.0" fitWidth="92.0" layoutX="30.0" layoutY="30.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@app.png" />
</image>
</ImageView>
<Label layoutX="146.0" layoutY="42.0" text="ServerCraft">
<font>
<Font name="System Bold" size="28.0" />
</font>
</Label>
<Label layoutX="146.0" layoutY="82.0" text="Version 1.0" />
<ButtonBar layoutY="318.0" prefHeight="40.0" prefWidth="398.0">
<buttons>
<Button mnemonicParsing="false" onAction="#closeInfo" text="Close" />
</buttons>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</ButtonBar>
<Label layoutX="52.0" layoutY="135.0" text="A graphical interface for creating Minecraft servers" textAlignment="CENTER" />
<TabPane layoutY="158.0" prefHeight="161.0" prefWidth="398.0" stylesheets="@css/info-tabs.css" tabClosingPolicy="UNAVAILABLE">
<tabs>
<Tab text="About">
<content>
<Pane prefHeight="200.0" prefWidth="200.0">
<children>
<Label alignment="TOP_LEFT" prefWidth="398.0" text="This program is for simple Minecraft servers, and expects that the user knows how to port forward.&#10;&#10;ServerCraft is free and open source under the GNU General Public License Version 3.0" wrapText="true">
<padding>
<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" text="License" />
<Hyperlink fx:id="_source" layoutX="189.0" layoutY="101.0" text="Source Code" />
</children>
<padding>
<Insets bottom="13.0" left="13.0" right="13.0" top="13.0" />
</padding>
</Pane>
</content>
</Tab>
<Tab text="Authors">
<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" />
<VBox>
<children>
<Label text="Bryson Steck" VBox.vgrow="ALWAYS">
<font>
<Font name="System Bold" size="16.0" />
</font>
</Label>
<Label text="Creator / Maintainer">
<padding>
<Insets top="4.0" />
</padding>
</Label>
<HBox>
<children>
<Hyperlink fx:id="bryson_website" onAction="#openHyperlink" text="Website">
<HBox.margin>
<Insets left="-3.0" top="2.0" />
</HBox.margin>
</Hyperlink>
<Separator orientation="VERTICAL">
<padding>
<Insets bottom="2.0" top="2.0" />
</padding>
</Separator>
<Hyperlink fx:id="bryson_email" onAction="#openHyperlink" text="Email">
<HBox.margin>
<Insets top="2.0" />
</HBox.margin>
</Hyperlink>
</children>
</HBox>
</children>
<padding>
<Insets bottom="13.0" left="13.0" right="13.0" top="13.0" />
</padding>
</VBox>
</children>
</Pane>
</content>
</Tab>
</tabs>
</TabPane>
</children>
</Pane>

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>
@ -60,7 +60,7 @@
<Insets bottom="7.0" left="7.0" right="7.0" top="7.0" />
</padding>
<children>
<Label text="World Name:">
<Label text="World Name:" HBox.hgrow="ALWAYS">
<font>
<Font name="System Bold" size="13.0" />
</font>
@ -86,7 +86,7 @@
<Insets bottom="5.0" left="5.0" right="5.0" top="6.0" />
</HBox.margin>
</Label>
<TextField fx:id="seedField" onInputMethodTextChanged="#onSeedChange" prefHeight="23.0" prefWidth="448.0" promptText="Leave empty for random seed">
<TextField fx:id="seedField" onInputMethodTextChanged="#onSeedChange" promptText="Leave empty for random seed" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets top="2.0" />
</HBox.margin>
@ -96,7 +96,7 @@
<Insets left="5.0" />
</HBox.margin>
</Separator>
<Label text="Server Port:">
<Label text="Server Port:" HBox.hgrow="ALWAYS">
<font>
<Font name="System Bold" size="13.0" />
</font>
@ -104,7 +104,7 @@
<Insets bottom="5.0" left="5.0" right="5.0" top="6.0" />
</HBox.margin>
</Label>
<Spinner fx:id="portSpinner" editable="true" onInputMethodTextChanged="#onPortChange" prefHeight="23.0" prefWidth="112.0">
<Spinner fx:id="portSpinner" editable="true" onInputMethodTextChanged="#onPortChange" prefWidth="95.0">
<HBox.margin>
<Insets top="2.0" />
</HBox.margin>
@ -125,21 +125,46 @@
<children>
<CheckBox fx:id="flightCheckbox" layoutX="14.0" layoutY="14.0" mnemonicParsing="false" onMouseClicked="#onCheckboxClick" text="Allow Flight" />
<CheckBox fx:id="netherCheckbox" layoutX="14.0" layoutY="42.0" mnemonicParsing="false" onMouseClicked="#onCheckboxClick" selected="true" text="Allow The Nether" />
<CheckBox fx:id="structuresCheckbox" alignment="TOP_LEFT" layoutX="14.0" layoutY="70.0" mnemonicParsing="false" onMouseClicked="#onCheckboxClick" prefHeight="45.0" prefWidth="231.0" selected="true" text="Generate Structures&#10;(such as villages and strongholds)" />
<CheckBox fx:id="structuresCheckbox" alignment="TOP_LEFT" layoutX="14.0" layoutY="70.0" mnemonicParsing="false" onMouseClicked="#onCheckboxClick" selected="true" text="Generate Structures&#10;(such as villages and strongholds)" />
<CheckBox fx:id="pvpCheckbox" layoutX="14.0" layoutY="109.0" mnemonicParsing="false" onMouseClicked="#onCheckboxClick" selected="true" text="Allow PvP" />
<CheckBox fx:id="whitelistCheckbox" alignment="TOP_LEFT" layoutX="14.0" layoutY="138.0" mnemonicParsing="false" onMouseClicked="#onCheckboxClick" prefHeight="45.0" prefWidth="231.0" text="Enable Whitelist&#10;(Only users you specify can join)" />
<Spinner fx:id="maxPlayerSpinner" editable="true" layoutX="130.0" layoutY="179.0" prefHeight="23.0" prefWidth="99.0">
<CheckBox fx:id="whitelistCheckbox" alignment="TOP_LEFT" layoutX="14.0" layoutY="138.0" mnemonicParsing="false" onMouseClicked="#onCheckboxClick" text="Enable Whitelist&#10;(Only users you specify can join)" />
<HBox layoutX="6.0" layoutY="174.0">
<children>
<Label text="Maximum Players:" HBox.hgrow="ALWAYS">
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</Label>
<Spinner fx:id="maxPlayerSpinner" editable="true" prefHeight="23.0" prefWidth="99.0">
<valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" initialValue="20" max="1000" min="0" />
</valueFactory>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</HBox.margin>
</Spinner>
<Label layoutX="14.0" layoutY="183.0" text="Maximum Players:" />
<Spinner fx:id="maxSizeSpinner" editable="true" layoutX="214.0" layoutY="212.0" prefHeight="23.0" prefWidth="155.0">
</children>
</HBox>
<HBox layoutX="6.0" layoutY="207.0">
<children>
<Label text="Maximum World Size (in blocks):" HBox.hgrow="ALWAYS">
<HBox.margin>
<Insets />
</HBox.margin>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</Label>
<Spinner fx:id="maxSizeSpinner" editable="true" prefHeight="23.0" prefWidth="155.0">
<valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" initialValue="29999984" max="29999984" min="1" />
</valueFactory>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</HBox.margin>
</Spinner>
<Label layoutX="14.0" layoutY="216.0" text="Maximum World Size (in blocks):" />
</children>
</HBox>
</children>
</AnchorPane>
</content>
@ -150,57 +175,116 @@
<children>
<CheckBox fx:id="cmdBlocksCheckbox" layoutX="14.0" layoutY="14.0" mnemonicParsing="false" onMouseClicked="#onCheckboxClick" text="Enable Command Blocks" />
<CheckBox fx:id="playerCountCheckbox" layoutX="14.0" layoutY="41.0" mnemonicParsing="false" onMouseClicked="#onCheckboxClick" text="Hide Online Player Count" />
<Spinner fx:id="memorySpinner" editable="true" layoutX="154.0" layoutY="69.0" prefHeight="23.0" prefWidth="99.0">
<valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" initialValue="1024" max="65536" min="512" />
</valueFactory>
</Spinner>
<Label ellipsisString="" layoutX="14.0" layoutY="73.0" text="Server Memory in MB:" textOverrun="CLIP">
<HBox layoutX="7.0" layoutY="65.0">
<children>
<Label ellipsisString="" text="Server Memory in MB:" textOverrun="CLIP" HBox.hgrow="ALWAYS">
<tooltip>
<Tooltip text="This is the amount of RAM that will get passed to Minecraft/the JVM.&#10;For simple servers, 1024 MB will be plenty.&#10;If you typically have more than 5 concurrent players, consider allocating more." />
</tooltip>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</Label>
<Spinner fx:id="spawnSpinner" editable="true" layoutX="172.0" layoutY="100.0" prefHeight="23.0" prefWidth="99.0">
<Spinner fx:id="memorySpinner" editable="true" prefHeight="23.0" prefWidth="99.0">
<valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" initialValue="16" max="29999984" min="0" />
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" initialValue="1024" max="65536" min="512" />
</valueFactory>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</HBox.margin>
</Spinner>
<Label layoutX="14.0" layoutY="104.0" text="Spawn Protection Radius:">
</children>
</HBox>
<HBox layoutX="7.0" layoutY="96.0">
<children>
<Label text="Spawn Protection Radius:" HBox.hgrow="ALWAYS">
<tooltip>
<Tooltip text="All blocks in a radius from 0,~,0 will be unbreakable. &#10;If you want to break blocks within spawn, change this value." />
</tooltip>
<HBox.margin>
<Insets />
</HBox.margin>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</Label>
<Spinner fx:id="simulationSpinner" editable="true" layoutX="147.0" layoutY="132.0" prefHeight="23.0" prefWidth="99.0">
<Spinner fx:id="spawnSpinner" editable="true" prefHeight="23.0" prefWidth="99.0">
<valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" initialValue="10" max="40" min="0" />
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" initialValue="16" max="29999984" min="0" />
</valueFactory>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</HBox.margin>
</Spinner>
<Label layoutX="14.0" layoutY="136.0" text="Simulation Distance:">
</children>
</HBox>
<HBox layoutX="7.0" layoutY="127.0">
<children>
<Label text="Simulation Distance:" HBox.hgrow="ALWAYS">
<tooltip>
<Tooltip text="The radius of chunks for each player where ticks will be updated.&#10;In other words, anything outside these circles, such as furnaces, mobs, etc, will not be updated or simulated." />
</tooltip>
<HBox.margin>
<Insets />
</HBox.margin>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</Label>
<Spinner fx:id="renderSpinner" editable="true" layoutX="124.0" layoutY="165.0" prefHeight="23.0" prefWidth="99.0">
<Spinner fx:id="simulationSpinner" editable="true" prefWidth="80.0">
<valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" initialValue="10" max="40" min="2" />
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" initialValue="10" max="40" min="0" />
</valueFactory>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</HBox.margin>
</Spinner>
<Label layoutX="14.0" layoutY="169.0" text="Render Distance:">
</children>
</HBox>
<HBox layoutX="7.0" layoutY="160.0">
<children>
<Label text="Render Distance:" HBox.hgrow="ALWAYS">
<tooltip>
<Tooltip text="The radius of chunks where the server will render the view distance.&#10;Any value higher on a client than what is set will be ignored.&#10;Higher values will be more demanding on the server." />
</tooltip>
<HBox.margin>
<Insets />
</HBox.margin>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</Label>
<Label layoutX="14.0" layoutY="203.0" text="Maximum Tick Time (in milliseconds):">
<Spinner fx:id="renderSpinner" editable="true" prefWidth="80.0">
<valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" initialValue="10" max="40" min="2" />
</valueFactory>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</HBox.margin>
</Spinner>
</children>
</HBox>
<HBox layoutX="7.0" layoutY="192.0">
<children>
<Label text="Maximum Tick Time (in milliseconds):" HBox.hgrow="ALWAYS">
<tooltip>
<Tooltip text="If the server cannot update ticks (i.e. &quot;lags&quot;) for longer than this amount of time, the server will shutdown.&#10;60000 ms (60 seconds) is the default." />
</tooltip>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
</Label>
<Spinner fx:id="maxTickSpinner" editable="true" layoutX="246.0" layoutY="199.0" prefHeight="23.0" prefWidth="99.0">
<Spinner fx:id="maxTickSpinner" editable="true">
<valueFactory>
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" initialValue="60000" max="180000" min="10000" />
</valueFactory>
<HBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</HBox.margin>
</Spinner>
</children>
</HBox>
</children>
</AnchorPane>
</content>
</TitledPane>
@ -241,11 +325,12 @@
</TitledPane>
</children>
</Pane>
<ButtonBar fx:id="buttonBar" buttonOrder="L+R" disable="true" layoutY="635.0" prefHeight="40.0" prefWidth="963.0">
<ButtonBar fx:id="buttonBar" buttonOrder="L+R" layoutY="635.0" prefHeight="40.0" prefWidth="963.0">
<buttons>
<Button fx:id="defaultsButton" mnemonicParsing="false" onMouseClicked="#onBuild" text="Reset to Defaults" ButtonBar.buttonData="LEFT" />
<Button fx:id="buildButton" mnemonicParsing="false" onMouseClicked="#onBuild" text="Build Server" ButtonBar.buttonData="RIGHT" />
<Button fx:id="startButton" defaultButton="true" mnemonicParsing="false" onMouseClicked="#onStart" prefWidth="120.0" text="Start Server" ButtonBar.buttonData="RIGHT" />
<Button fx:id="infoButton" mnemonicParsing="false" onMouseClicked="#onInfo" text="About ServerCraft" ButtonBar.buttonData="LEFT" />
<Button fx:id="defaultsButton" disable="true" mnemonicParsing="false" onMouseClicked="#onBuild" text="Reset to Defaults" ButtonBar.buttonData="LEFT" />
<Button fx:id="buildButton" disable="true" mnemonicParsing="false" onMouseClicked="#onBuild" text="Build Server" ButtonBar.buttonData="RIGHT" />
<Button fx:id="startButton" defaultButton="true" disable="true" mnemonicParsing="false" onMouseClicked="#onStart" prefWidth="120.0" text="Start Server" ButtonBar.buttonData="RIGHT" />
</buttons>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />