File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
src/main/kotlin/sc/gui/view Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 1
1
package sc.gui.view
2
2
3
+ import javafx.beans.InvalidationListener
3
4
import javafx.beans.binding.Bindings
4
5
import javafx.geometry.Insets
5
6
import javafx.geometry.Pos
@@ -82,6 +83,13 @@ class ControlView() : View() {
82
83
}
83
84
84
85
init {
86
+ val updatePauseState = {
87
+ if (clientController.controllingClient?.game?.isPaused!! ) {
88
+ playPauseButton.text = " Play"
89
+ } else {
90
+ playPauseButton.text = " Pause"
91
+ }
92
+ }
85
93
playPauseButton.setOnMouseClicked {
86
94
if (! gameController.gameStartedProperty().get()) {
87
95
gameController.gameStartedProperty().set(true )
@@ -90,15 +98,15 @@ class ControlView() : View() {
90
98
appController.changeViewTo(StartView ::class )
91
99
gameController.clearGame()
92
100
} else {
93
- if (clientController.controllingClient?.game?.isPaused!! ) {
94
- playPauseButton.text = " Pause"
95
- } else {
96
- playPauseButton.text = " Play"
97
- }
98
101
clientController.togglePause()
102
+ updatePauseState()
99
103
}
100
104
}
101
-
105
+
106
+ gameController.currentTurnProperty().addListener(InvalidationListener {
107
+ // When the game is paused externally e.g. when rewinding
108
+ updatePauseState()
109
+ })
102
110
gameController.gameStartedProperty().addListener { _, _, started ->
103
111
if (! started) {
104
112
playPauseButton.text = " Start"
You can’t perform that action at this time.
0 commit comments