Skip to content

Commit a1d7c55

Browse files
Refac
1 parent 572353e commit a1d7c55

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public class PacManGames_UI_Impl implements GameUI {
8080

8181
private final Map<String, GameUI_Config> configByGameVariant = new HashMap<>();
8282

83-
private MainScene mainScene;
83+
private final MainScene mainScene;
8484

8585
private final StartPagesView startPagesView;
8686
private final PlayView playView;
@@ -108,7 +108,11 @@ public PacManGames_UI_Impl(GameContext gameContext, Stage stage, double width, d
108108

109109
initPreferences();
110110

111-
createMainScene(width, height);
111+
mainScene = new MainScene(this, width, height);
112+
// First, check if a global action binding is defined for the key, if not, delegate the to the current view:
113+
mainScene.setOnKeyPressed(e -> runActionOrElse(
114+
globalActionBindings.matchingAction(theKeyboard).orElse(null),
115+
() -> currentView().handleKeyboardInput(this)));
112116

113117
stage.setScene(mainScene);
114118
stage.setMinWidth(MIN_STAGE_WIDTH);
@@ -192,15 +196,6 @@ private void initPreferences() {
192196
}
193197
}
194198

195-
private void createMainScene(double width, double height) {
196-
mainScene = new MainScene(this, width, height);
197-
// First, check if a global action binding is defined for the key,
198-
// if not, delegate the key press event to the current view
199-
mainScene.setOnKeyPressed(e -> runActionOrElse(
200-
globalActionBindings.matchingAction(theKeyboard).orElse(null),
201-
() -> currentView().handleKeyboardInput(this)));
202-
}
203-
204199
private void showView(PacManGames_View view) {
205200
requireNonNull(view);
206201

0 commit comments

Comments
 (0)