run and crawl buttons, no styling
This commit is contained in:
87
ide/src/main/kotlin/befide/ide/Main.kt
Normal file
87
ide/src/main/kotlin/befide/ide/Main.kt
Normal file
@@ -0,0 +1,87 @@
|
||||
package befide.ide
|
||||
|
||||
import befide.befunge.b93.B93Interpreter
|
||||
import befide.befunge.core.Interpreter
|
||||
import befide.befunge.state.Vec
|
||||
import javafx.animation.Animation
|
||||
import javafx.animation.Timeline
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import javafx.util.Duration
|
||||
import tornadofx.*
|
||||
|
||||
class EditorView : View("Befide") {
|
||||
private var interp: Interpreter = B93Interpreter()
|
||||
|
||||
private val textProperty = SimpleStringProperty("")
|
||||
private var text by textProperty
|
||||
|
||||
private val posProperty = SimpleObjectProperty<Vec>(Vec(0, 0))
|
||||
private var pos by posProperty
|
||||
|
||||
private var runTimeline: Timeline = timeline(false) {
|
||||
keyframe(Duration.seconds(0.0)) {
|
||||
setOnFinished {
|
||||
if (!interp.step())
|
||||
this@timeline.stop()
|
||||
}
|
||||
}
|
||||
keyframe(Duration.seconds(1.0)) {}
|
||||
|
||||
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 "-" })
|
||||
}
|
||||
|
||||
hbox {
|
||||
button("step") {
|
||||
setOnAction { interp.step() }
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
textarea(textProperty)
|
||||
}
|
||||
|
||||
init {
|
||||
text = """64+"!dlroW ,olleH">:#,_@"""
|
||||
}
|
||||
}
|
||||
|
||||
class MainApp : App(EditorView::class) {
|
||||
init {
|
||||
importStylesheet(resources["style.css"])
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,8 @@
|
||||
.lbl {
|
||||
-fx-text-fill: maroon;
|
||||
* {
|
||||
-fx-font-size: 14;
|
||||
-fx-font-fill: black;
|
||||
}
|
||||
|
||||
.val {
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
#heightLabel {
|
||||
-fx-font-style: italic;
|
||||
}
|
||||
|
||||
GridPane {
|
||||
-fx-font-size: 20px;
|
||||
-fx-font-family: Consolas, monospace;
|
||||
.text-area {
|
||||
-fx-font-family: monospace;
|
||||
}
|
||||
Reference in New Issue
Block a user