@@ -58,6 +58,9 @@ public class MenuScreen extends ScreenAdapter implements BladeScreen {
58
58
private Button credits ;
59
59
private Button help ;
60
60
private Button debug ;
61
+
62
+ private final Table menuButtonTable = new Table ();
63
+ private final Table iconStackTable = new Table ();
61
64
62
65
public MenuScreen () {
63
66
}
@@ -101,7 +104,7 @@ public void show() {
101
104
final Skin skin = ui .getSkin ();
102
105
final World world = World .getInstance ();
103
106
104
- final MenuScreenStyle style = skin . get ( MenuScreenStyle . class );
107
+ final MenuScreenStyle style = getStyle ( );
105
108
final BitmapFont f = skin .get (style .textButtonStyle , TextButtonStyle .class ).font ;
106
109
float buttonWidth = f .getCapHeight () * 15f ;
107
110
@@ -115,14 +118,11 @@ public void show() {
115
118
bg = new TextureRegionDrawable (new TextureRegion (bgTexFile ));
116
119
}
117
120
118
- final Table table = new Table ();
119
- table .setFillParent (true );
120
- table .center ();
121
-
121
+ menuButtonTable .clear ();
122
122
if (bg != null )
123
- table .setBackground (bg );
123
+ menuButtonTable .setBackground (bg );
124
124
125
- table .addListener (new InputListener () {
125
+ menuButtonTable .addListener (new InputListener () {
126
126
@ Override
127
127
public boolean keyUp (InputEvent event , int keycode ) {
128
128
if (keycode == Input .Keys .ESCAPE || keycode == Input .Keys .BACK )
@@ -133,9 +133,9 @@ public boolean keyUp(InputEvent event, int keycode) {
133
133
}
134
134
});
135
135
136
- table .defaults ().pad (BUTTON_PADDING ).width (buttonWidth );
136
+ menuButtonTable .defaults ().pad (BUTTON_PADDING ).width (buttonWidth );
137
137
138
- stage .setKeyboardFocus (table );
138
+ stage .setKeyboardFocus (menuButtonTable );
139
139
140
140
if (style .showTitle ) {
141
141
@@ -144,8 +144,8 @@ public boolean keyUp(InputEvent event, int keycode) {
144
144
145
145
title .setAlignment (Align .center );
146
146
147
- table .add (title ).padBottom (DPIUtils .getMarginSize () * 2 );
148
- table .row ();
147
+ menuButtonTable .add (title ).padBottom (DPIUtils .getMarginSize () * 2 );
148
+ menuButtonTable .row ();
149
149
}
150
150
151
151
if (world .savedGameExists () || world .getCurrentScene () != null ) {
@@ -164,7 +164,7 @@ public void clicked(InputEvent event, float x, float y) {
164
164
}
165
165
});
166
166
167
- table .add (continueGame );
167
+ menuButtonTable .add (continueGame );
168
168
}
169
169
170
170
TextButton newGame = new TextButton (I18N .getString ("ui.new" ), skin , style .textButtonStyle );
@@ -211,8 +211,8 @@ protected void result(Object object) {
211
211
}
212
212
});
213
213
214
- table .row ();
215
- table .add (newGame );
214
+ menuButtonTable .row ();
215
+ menuButtonTable .add (newGame );
216
216
217
217
TextButton loadGame = new TextButton (I18N .getString ("ui.load" ), skin , style .textButtonStyle );
218
218
loadGame .addListener (new ClickListener () {
@@ -221,20 +221,8 @@ public void clicked(InputEvent event, float x, float y) {
221
221
}
222
222
});
223
223
224
- table .row ();
225
- table .add (loadGame );
226
-
227
- // if (world.getCurrentScene() != null) {
228
- // TextButton saveGame = new TextButton(I18N.getString("ui.save"), skin, style.textButtonStyle);
229
- // saveGame.addListener(new ClickListener() {
230
- // public void clicked(InputEvent event, float x, float y) {
231
- // ui.setCurrentScreen(Screens.SAVE_GAME_SCREEN);
232
- // }
233
- // });
234
- //
235
- // table.row();
236
- // table.add(saveGame);
237
- // }
224
+ menuButtonTable .row ();
225
+ menuButtonTable .add (loadGame );
238
226
239
227
TextButton quit = new TextButton (I18N .getString ("ui.quit" ), skin , style .textButtonStyle );
240
228
quit .addListener (new ClickListener () {
@@ -243,12 +231,12 @@ public void clicked(InputEvent event, float x, float y) {
243
231
}
244
232
});
245
233
246
- table .row ();
247
- table .add (quit );
234
+ menuButtonTable .row ();
235
+ menuButtonTable .add (quit );
248
236
249
- table .pack ();
237
+ menuButtonTable .pack ();
250
238
251
- stage .addActor (table );
239
+ stage .addActor (menuButtonTable );
252
240
253
241
// BOTTOM-RIGHT BUTTON STACK
254
242
credits = new Button (skin , "credits" );
@@ -274,23 +262,23 @@ public void clicked(InputEvent event, float x, float y) {
274
262
}
275
263
});
276
264
277
- Table buttonStack = new Table ();
278
- buttonStack .defaults ().pad (DPIUtils .getSpacing ()).size (DPIUtils .getPrefButtonSize (),
265
+ iconStackTable . clear ();
266
+ iconStackTable .defaults ().pad (DPIUtils .getSpacing ()).size (DPIUtils .getPrefButtonSize (),
279
267
DPIUtils .getPrefButtonSize ());
280
- buttonStack .pad (DPIUtils .getMarginSize () * 2 );
268
+ iconStackTable .pad (DPIUtils .getMarginSize () * 2 );
281
269
282
270
if (EngineLogger .debugMode () && world .getCurrentScene () != null ) {
283
- buttonStack .add (debug );
284
- buttonStack .row ();
271
+ iconStackTable .add (debug );
272
+ iconStackTable .row ();
285
273
}
286
274
287
- buttonStack .add (help );
288
- buttonStack .row ();
289
- buttonStack .add (credits );
290
- buttonStack .bottom ().right ();
291
- buttonStack .setFillParent (true );
292
- buttonStack .pack ();
293
- stage .addActor (buttonStack );
275
+ iconStackTable .add (help );
276
+ iconStackTable .row ();
277
+ iconStackTable .add (credits );
278
+ iconStackTable .bottom ().right ();
279
+ iconStackTable .setFillParent (true );
280
+ iconStackTable .pack ();
281
+ stage .addActor (iconStackTable );
294
282
295
283
Label version = new Label ("v" + Config .getProperty (Config .VERSION_PROP , " unspecified" ), skin );
296
284
version .setPosition (DPIUtils .getMarginSize (), DPIUtils .getMarginSize ());
@@ -309,6 +297,22 @@ public void clicked(InputEvent event, float x, float y) {
309
297
310
298
Gdx .input .setInputProcessor (stage );
311
299
}
300
+
301
+ protected Table getMenuButtonTable () {
302
+ return menuButtonTable ;
303
+ }
304
+
305
+ protected Table getIconStackTable () {
306
+ return iconStackTable ;
307
+ }
308
+
309
+ protected UI getUI () {
310
+ return ui ;
311
+ }
312
+
313
+ protected MenuScreenStyle getStyle () {
314
+ return ui .getSkin ().get (MenuScreenStyle .class );
315
+ }
312
316
313
317
@ Override
314
318
public void hide () {
@@ -318,6 +322,9 @@ public void hide() {
318
322
@ Override
319
323
public void setUI (UI ui ) {
320
324
this .ui = ui ;
325
+
326
+ menuButtonTable .setFillParent (true );
327
+ menuButtonTable .center ();
321
328
}
322
329
323
330
/** The style for the MenuScreen */
0 commit comments