@@ -80,7 +80,7 @@ public class PacManGames_UI_Impl implements GameUI {
80
80
81
81
private final Map <String , GameUI_Config > configByGameVariant = new HashMap <>();
82
82
83
- private MainScene mainScene ;
83
+ private final MainScene mainScene ;
84
84
85
85
private final StartPagesView startPagesView ;
86
86
private final PlayView playView ;
@@ -108,7 +108,11 @@ public PacManGames_UI_Impl(GameContext gameContext, Stage stage, double width, d
108
108
109
109
initPreferences ();
110
110
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 )));
112
116
113
117
stage .setScene (mainScene );
114
118
stage .setMinWidth (MIN_STAGE_WIDTH );
@@ -192,15 +196,6 @@ private void initPreferences() {
192
196
}
193
197
}
194
198
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
-
204
199
private void showView (PacManGames_View view ) {
205
200
requireNonNull (view );
206
201
0 commit comments