partially separated dialogs
This commit is contained in:
parent
d1bf5734bf
commit
b2ffd5fc3f
5 changed files with 131 additions and 54 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -7,3 +7,6 @@ bin
|
|||
|
||||
# Ignore VSCode settings
|
||||
.vscode
|
||||
|
||||
# ignore local releases dir for Codeberg releases
|
||||
releases
|
||||
|
|
14
docs/features.md
Normal file
14
docs/features.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Features
|
||||
|
||||
Here are all the features currently implemented/planned for ServerCraft:
|
||||
|
||||
* [X] Change `server.properties` file
|
||||
* [X] Adapt controls based on what properties are found
|
||||
* [X] Save server-specific settings in subdirectory
|
||||
* [X] Allow changing memory passed into JVM
|
||||
* [ ] Manage port forwarding automatically using UPnP
|
||||
* [ ] Create system to check for updates
|
||||
* [ ] Add and remove Spigot server mods/plugins
|
||||
* [ ] Create servers of any Minecraft version >= 1.8
|
||||
* [ ] "Advanced mode" with all settings editable
|
||||
* [ ] Recognize existing server jars and give option to run them instead
|
|
@ -57,6 +57,7 @@ import org.rauschig.jarchivelib.*
|
|||
import xyz.brysonsteck.ServerCraft.server.Server
|
||||
import xyz.brysonsteck.ServerCraft.server.Download
|
||||
import xyz.brysonsteck.ServerCraft.App
|
||||
import xyz.brysonsteck.ServerCraft.dialogs.Dialog
|
||||
|
||||
class PrimaryController {
|
||||
@FXML
|
||||
|
@ -681,60 +682,7 @@ class PrimaryController {
|
|||
}
|
||||
|
||||
private fun createDialog(type: String, msg: String, yes: String = "Yes", no: String = "No", hold: Boolean = true): Boolean {
|
||||
var result = false
|
||||
val resources = App().javaClass.getResource("icons/$type.png")
|
||||
val dialog = Stage()
|
||||
dialog.icons.add(Image(App().javaClass.getResourceAsStream("app.png")))
|
||||
dialog.setResizable(false)
|
||||
dialog.initModality(Modality.APPLICATION_MODAL);
|
||||
dialog.title = directory
|
||||
val scenePane = Pane()
|
||||
val dialogScene = Scene(scenePane, 400.0, 150.0);
|
||||
val imagePane = Pane()
|
||||
val icon = Image("$resources")
|
||||
imagePane.layoutX = 14.0
|
||||
imagePane.layoutY = 14.0
|
||||
imagePane.scaleX = 0.7
|
||||
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()
|
||||
buttonBar.padding = Insets(10.0, 10.0, 10.0, 10.0)
|
||||
buttonBar.layoutX = 0.0
|
||||
buttonBar.layoutY = 107.0
|
||||
buttonBar.prefWidth = 400.0
|
||||
val noButton = Button(no)
|
||||
noButton.onAction = EventHandler<ActionEvent>() {
|
||||
if (hold) {
|
||||
result = false
|
||||
} else {
|
||||
asyncResult = false
|
||||
}
|
||||
dialog.hide()
|
||||
}
|
||||
val yesButton = Button(yes)
|
||||
yesButton.onAction = EventHandler<ActionEvent>() {
|
||||
if (hold) {
|
||||
result = true
|
||||
} else {
|
||||
asyncResult = true
|
||||
}
|
||||
dialog.hide()
|
||||
}
|
||||
yesButton.isDefaultButton = true
|
||||
buttonBar.buttons.add(noButton)
|
||||
buttonBar.buttons.add(yesButton)
|
||||
scenePane.children.addAll(imagePane, label, buttonBar)
|
||||
dialog.setScene(dialogScene);
|
||||
if (hold) {
|
||||
dialog.showAndWait();
|
||||
} else {
|
||||
dialog.show();
|
||||
}
|
||||
return result
|
||||
return Dialog(type, directory, msg, yes, no, null, hold).show()
|
||||
}
|
||||
|
||||
private fun loadServerDir(dir: String): Boolean {
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
package xyz.brysonsteck.ServerCraft.dialogs
|
||||
|
||||
import javafx.scene.control.Button
|
||||
import javafx.scene.control.Label
|
||||
import javafx.scene.control.ButtonBar
|
||||
import javafx.scene.image.Image
|
||||
import javafx.scene.image.ImageView
|
||||
import javafx.scene.layout.Pane
|
||||
import javafx.scene.Scene
|
||||
import javafx.stage.Stage
|
||||
import javafx.stage.Modality
|
||||
import javafx.geometry.Insets
|
||||
import javafx.event.EventHandler
|
||||
import javafx.event.ActionEvent
|
||||
import xyz.brysonsteck.ServerCraft.App
|
||||
|
||||
open class Dialog {
|
||||
private var result = false
|
||||
|
||||
private val type: String
|
||||
private val title: String
|
||||
private val msg: String
|
||||
private val yes: String
|
||||
private val no: String
|
||||
private val neutral: Button?
|
||||
private val hold: Boolean
|
||||
|
||||
constructor(type: String,
|
||||
title: String,
|
||||
msg: String,
|
||||
yes: String = "Yes",
|
||||
no: String = "No",
|
||||
neutral: Button?,
|
||||
hold: Boolean = true) {
|
||||
this.type = type
|
||||
this.title = title
|
||||
this.msg = msg
|
||||
this.yes = yes
|
||||
this.no = no
|
||||
this.neutral = neutral
|
||||
this.hold = hold
|
||||
}
|
||||
|
||||
public fun show(): Boolean {
|
||||
val resources = App().javaClass.getResource("icons/$type.png")
|
||||
val dialog = Stage()
|
||||
dialog.icons.add(Image(App().javaClass.getResourceAsStream("app.png")))
|
||||
dialog.setResizable(false)
|
||||
dialog.initModality(Modality.APPLICATION_MODAL);
|
||||
dialog.title = title
|
||||
val scenePane = Pane()
|
||||
val dialogScene = Scene(scenePane, 400.0, 150.0);
|
||||
val imagePane = Pane()
|
||||
val icon = Image("$resources")
|
||||
imagePane.layoutX = 14.0
|
||||
imagePane.layoutY = 14.0
|
||||
imagePane.scaleX = 0.7
|
||||
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()
|
||||
buttonBar.padding = Insets(10.0, 10.0, 10.0, 10.0)
|
||||
buttonBar.layoutX = 0.0
|
||||
buttonBar.layoutY = 107.0
|
||||
buttonBar.prefWidth = 400.0
|
||||
val noButton = Button(no)
|
||||
noButton.onAction = EventHandler<ActionEvent>() {
|
||||
result = false
|
||||
dialog.hide()
|
||||
}
|
||||
val yesButton = Button(yes)
|
||||
yesButton.onAction = EventHandler<ActionEvent>() {
|
||||
result = true
|
||||
dialog.hide()
|
||||
}
|
||||
yesButton.isDefaultButton = true
|
||||
buttonBar.buttons.add(noButton)
|
||||
buttonBar.buttons.add(yesButton)
|
||||
scenePane.children.addAll(imagePane, label, buttonBar)
|
||||
ButtonBar.setButtonData(noButton, ButtonBar.ButtonData.RIGHT)
|
||||
ButtonBar.setButtonData(yesButton, ButtonBar.ButtonData.RIGHT)
|
||||
buttonBar.buttons.add(noButton)
|
||||
buttonBar.buttons.add(yesButton)
|
||||
dialog.setScene(dialogScene);
|
||||
if (hold) {
|
||||
dialog.showAndWait();
|
||||
} else {
|
||||
dialog.show();
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package xyz.brysonsteck.ServerCraft.dialogs
|
||||
|
||||
import xyz.brysonsteck.ServerCraft.dialogs.Dialog
|
||||
import javafx.scene.control.Button
|
||||
|
||||
class EulaDialog: Dialog {
|
||||
|
||||
constructor(type: String,
|
||||
title: String,
|
||||
msg: String,
|
||||
yes: String = "Yes",
|
||||
no: String = "No",
|
||||
neutral: Button?,
|
||||
hold: Boolean = true) : super(type, title, msg, yes, no, neutral, hold)
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue