|
16 | 16 | import de.amr.pacmanfx.ui.layout.*;
|
17 | 17 | import de.amr.pacmanfx.ui.sound.SoundManager;
|
18 | 18 | import de.amr.pacmanfx.uilib.GameClock;
|
| 19 | +import javafx.application.Platform; |
19 | 20 | import javafx.beans.property.*;
|
20 | 21 | import javafx.scene.control.MenuItem;
|
21 | 22 | import javafx.scene.control.SeparatorMenuItem;
|
@@ -116,7 +117,7 @@ public PacManGames_UI_Impl(GameContext gameContext, Stage stage, double width, d
|
116 | 117 | playView = new PlayView(this, gameContext, mainScene);
|
117 | 118 |
|
118 | 119 | theGameClock.setPausableAction(this::doSimulationStepAndUpdateGameScene);
|
119 |
| - theGameClock.setPermanentAction(this::drawGameView); |
| 120 | + theGameClock.setPermanentAction(this::drawPlayView); |
120 | 121 |
|
121 | 122 | property3DWallHeight.set(thePrefs.getFloat("3d.obstacle.base_height"));
|
122 | 123 | property3DWallOpacity.set(thePrefs.getFloat("3d.obstacle.opacity"));
|
@@ -234,7 +235,7 @@ private void doSimulationStepAndUpdateGameScene() {
|
234 | 235 | }
|
235 | 236 | }
|
236 | 237 |
|
237 |
| - private void drawGameView() { |
| 238 | + private void drawPlayView() { |
238 | 239 | try {
|
239 | 240 | playView.draw();
|
240 | 241 | } catch (Throwable x) {
|
@@ -282,12 +283,12 @@ private EditorView editorView() {
|
282 | 283 | @Override public DoubleProperty property3DWallHeight(){ return property3DWallHeight; }
|
283 | 284 | @Override public DoubleProperty property3DWallOpacity(){ return property3DWallOpacity; }
|
284 | 285 |
|
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(); } |
287 | 288 |
|
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; } |
291 | 292 |
|
292 | 293 | @Override
|
293 | 294 | public boolean isCurrentGameSceneID(String id) {
|
@@ -343,16 +344,10 @@ public void selectGameVariant(String gameVariant) {
|
343 | 344 | @Override
|
344 | 345 | public void show() {
|
345 | 346 | 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(); |
353 | 348 | theStage.centerOnScreen();
|
354 | 349 | theStage.show();
|
355 |
| - theCustomDirWatchdog.startWatching(); |
| 350 | + Platform.runLater(theCustomDirWatchdog::startWatching); |
356 | 351 | }
|
357 | 352 |
|
358 | 353 | @Override
|
@@ -384,8 +379,11 @@ public void showStartView() {
|
384 | 379 | theGameClock.setTargetFrameRate(Globals.NUM_TICKS_PER_SEC);
|
385 | 380 | theSound().stopAll();
|
386 | 381 | playView.dashboard().setVisible(false);
|
| 382 | + startPagesView.currentStartPage().ifPresent(startPage -> { |
| 383 | + startPage.layoutRoot().requestFocus(); |
| 384 | + startPage.onEnter(this); // sets game variant! |
| 385 | + }); |
387 | 386 | showView(startPagesView);
|
388 |
| - startPagesView.currentStartPage().ifPresent(startPage -> startPage.layoutRoot().requestFocus()); |
389 | 387 | }
|
390 | 388 |
|
391 | 389 | @Override
|
|
0 commit comments