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