basic gui structure
This commit is contained in:
@@ -2,24 +2,37 @@ package befide.ide
|
||||
|
||||
import befide.befunge.b93.B93Interpreter
|
||||
import befide.befunge.core.Interpreter
|
||||
import befide.befunge.state.Vec
|
||||
import befide.befunge.core.Pointer
|
||||
import javafx.animation.Animation
|
||||
import javafx.animation.Timeline
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import javafx.util.Duration
|
||||
import tornadofx.*
|
||||
import tornadofx.getValue
|
||||
import tornadofx.setValue
|
||||
|
||||
class EditorView : View("Befide") {
|
||||
private var interp: Interpreter = B93Interpreter()
|
||||
class IOView(val interp: Interpreter) : View() {
|
||||
val textProperty = SimpleStringProperty("")
|
||||
var text by textProperty
|
||||
|
||||
private val textProperty = SimpleStringProperty("")
|
||||
private var text by textProperty
|
||||
init {
|
||||
// add listeners to interp, handle streams, idk
|
||||
}
|
||||
|
||||
private val posProperty = SimpleObjectProperty<Vec>(Vec(0, 0))
|
||||
private var pos by posProperty
|
||||
override val root = vbox {
|
||||
textarea(textProperty) {
|
||||
// width, height, idk
|
||||
prefHeight = 200.0
|
||||
}
|
||||
textfield {
|
||||
|
||||
private var runTimeline: Timeline = timeline(false) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ActionView(val interp: Interpreter) : View() {
|
||||
var runTimeline: Timeline = timeline(false) {
|
||||
keyframe(Duration.seconds(0.0)) {
|
||||
setOnFinished {
|
||||
if (!interp.step())
|
||||
@@ -31,52 +44,83 @@ class EditorView : View("Befide") {
|
||||
cycleCount = Animation.INDEFINITE
|
||||
}
|
||||
|
||||
init {
|
||||
interp.fungeChanged += { text = interp.funge.toString() }
|
||||
textProperty.addListener { _, _, newValue -> interp.funge.setString(newValue) }
|
||||
interp.ipChanged += { pos = it.to.pos }
|
||||
}
|
||||
|
||||
override val root = vbox {
|
||||
label {
|
||||
bind(posProperty.stringBinding { if (it != null) "${it.x} ${it.y}" else "-" })
|
||||
override val root = hbox {
|
||||
button("step") {
|
||||
setOnAction { interp.step() }
|
||||
}
|
||||
|
||||
hbox {
|
||||
button("step") {
|
||||
setOnAction { interp.step() }
|
||||
}
|
||||
button("reset") {
|
||||
setOnAction { interp.reset() }
|
||||
}
|
||||
|
||||
button("reset") {
|
||||
setOnAction { interp.reset() }
|
||||
}
|
||||
|
||||
button("run") {
|
||||
setOnAction {
|
||||
runTimeline.rate = 1000.0
|
||||
runTimeline.playFromStart()
|
||||
}
|
||||
}
|
||||
|
||||
button("crawl") {
|
||||
setOnAction {
|
||||
runTimeline.rate = 2.0
|
||||
runTimeline.playFromStart()
|
||||
}
|
||||
}
|
||||
|
||||
button("stop") {
|
||||
setOnAction {
|
||||
runTimeline.stop()
|
||||
}
|
||||
button("run") {
|
||||
setOnAction {
|
||||
runTimeline.rate = 1000.0
|
||||
runTimeline.playFromStart()
|
||||
}
|
||||
}
|
||||
|
||||
textarea(textProperty)
|
||||
button("crawl") {
|
||||
setOnAction {
|
||||
runTimeline.rate = 2.0
|
||||
runTimeline.playFromStart()
|
||||
}
|
||||
}
|
||||
|
||||
button("stop") {
|
||||
setOnAction {
|
||||
runTimeline.stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CodeView(val interp: Interpreter) : View() {
|
||||
val srcProperty = SimpleStringProperty("")
|
||||
var src by srcProperty
|
||||
|
||||
init {
|
||||
interp.fungeChanged += { src = interp.funge.toString() }
|
||||
srcProperty.addListener { _, _, newValue -> interp.funge.setString(newValue) }
|
||||
}
|
||||
|
||||
override val root = textarea(srcProperty) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class StackView(val interp: Interpreter) : View() {
|
||||
override val root = textarea {
|
||||
prefWidth = 100.0
|
||||
}
|
||||
}
|
||||
|
||||
class EditorView : View("Befide") {
|
||||
private var interp: Interpreter = B93Interpreter()
|
||||
|
||||
private val codeView = CodeView(interp)
|
||||
private val actionView = ActionView(interp)
|
||||
private val stackView = StackView(interp)
|
||||
private val ioView = IOView(interp)
|
||||
|
||||
override val root = borderpane {
|
||||
addClass("editor-root")
|
||||
|
||||
top { add(actionView) }
|
||||
|
||||
center {
|
||||
add(codeView)
|
||||
}
|
||||
|
||||
right {
|
||||
add(stackView)
|
||||
}
|
||||
|
||||
bottom { add(ioView) }
|
||||
}
|
||||
|
||||
init {
|
||||
text = """64+"!dlroW ,olleH">:#,_@"""
|
||||
codeView.src = """64+"!dlroW ,olleH">:#,_@"""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
|
||||
.text-area {
|
||||
-fx-font-family: monospace;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user