Skip to content

Commit 34cc625

Browse files
Refac
1 parent 3d74060 commit 34cc625

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

pacman-ui/src/main/java/de/amr/pacmanfx/ui/PacManGames_UI_Impl.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import de.amr.pacmanfx.ui.layout.*;
1717
import de.amr.pacmanfx.ui.sound.SoundManager;
1818
import de.amr.pacmanfx.uilib.GameClock;
19+
import javafx.application.Platform;
1920
import javafx.beans.property.*;
2021
import javafx.scene.control.MenuItem;
2122
import javafx.scene.control.SeparatorMenuItem;
@@ -116,7 +117,7 @@ public PacManGames_UI_Impl(GameContext gameContext, Stage stage, double width, d
116117
playView = new PlayView(this, gameContext, mainScene);
117118

118119
theGameClock.setPausableAction(this::doSimulationStepAndUpdateGameScene);
119-
theGameClock.setPermanentAction(this::drawGameView);
120+
theGameClock.setPermanentAction(this::drawPlayView);
120121

121122
property3DWallHeight.set(thePrefs.getFloat("3d.obstacle.base_height"));
122123
property3DWallOpacity.set(thePrefs.getFloat("3d.obstacle.opacity"));
@@ -234,7 +235,7 @@ private void doSimulationStepAndUpdateGameScene() {
234235
}
235236
}
236237

237-
private void drawGameView() {
238+
private void drawPlayView() {
238239
try {
239240
playView.draw();
240241
} catch (Throwable x) {
@@ -282,12 +283,12 @@ private EditorView editorView() {
282283
@Override public DoubleProperty property3DWallHeight(){ return property3DWallHeight; }
283284
@Override public DoubleProperty property3DWallOpacity(){ return property3DWallOpacity; }
284285

285-
@Override public Optional<GameScene> currentGameScene() { return mainScene.currentGameScene(); }
286-
@Override public PacManGames_View currentView() { return mainScene.currentView(); }
286+
@Override public Optional<GameScene> currentGameScene() { return mainScene.currentGameScene(); }
287+
@Override public PacManGames_View currentView() { return mainScene.currentView(); }
287288

288-
@Override public Optional<EditorView> theEditorView() { return Optional.ofNullable(editorView); }
289-
@Override public PlayView thePlayView() { return playView; }
290-
@Override public StartPagesView theStartPagesView() { return startPagesView; }
289+
@Override public Optional<EditorView> theEditorView() { return Optional.ofNullable(editorView); }
290+
@Override public PlayView thePlayView() { return playView; }
291+
@Override public StartPagesView theStartPagesView() { return startPagesView; }
291292

292293
@Override
293294
public boolean isCurrentGameSceneID(String id) {
@@ -343,16 +344,10 @@ public void selectGameVariant(String gameVariant) {
343344
@Override
344345
public void show() {
345346
playView.dashboard().init(this);
346-
347-
startPagesView.currentStartPage().ifPresent(startPage -> {
348-
startPage.layoutRoot().requestFocus();
349-
startPage.onEnter(this); // sets game variant!
350-
});
351-
showView(startPagesView);
352-
347+
showStartView();
353348
theStage.centerOnScreen();
354349
theStage.show();
355-
theCustomDirWatchdog.startWatching();
350+
Platform.runLater(theCustomDirWatchdog::startWatching);
356351
}
357352

358353
@Override
@@ -384,8 +379,11 @@ public void showStartView() {
384379
theGameClock.setTargetFrameRate(Globals.NUM_TICKS_PER_SEC);
385380
theSound().stopAll();
386381
playView.dashboard().setVisible(false);
382+
startPagesView.currentStartPage().ifPresent(startPage -> {
383+
startPage.layoutRoot().requestFocus();
384+
startPage.onEnter(this); // sets game variant!
385+
});
387386
showView(startPagesView);
388-
startPagesView.currentStartPage().ifPresent(startPage -> startPage.layoutRoot().requestFocus());
389387
}
390388

391389
@Override

0 commit comments

Comments
 (0)