diff options
| author | ilotterytea <iltsu@alright.party> | 2024-05-29 19:08:37 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-05-29 19:08:37 +0500 |
| commit | ab2e0e35b3f6619cc8c5fa6e7b30d34e396cb1a9 (patch) | |
| tree | f9c07fced27ffeaab396c185c8bde8f61b870f8e /core/src/com/ilotterytea/maxoning/screens | |
| parent | 421d0f0a8472b3330b5ec4042d0511c423f7f8de (diff) | |
upd: menu layout
Diffstat (limited to 'core/src/com/ilotterytea/maxoning/screens')
| -rw-r--r-- | core/src/com/ilotterytea/maxoning/screens/MenuScreen.java | 577 |
1 files changed, 121 insertions, 456 deletions
diff --git a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java index 3c9245e..ec152cb 100644 --- a/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java +++ b/core/src/com/ilotterytea/maxoning/screens/MenuScreen.java @@ -5,79 +5,45 @@ import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.*; import com.badlogic.gdx.graphics.g2d.TextureAtlas; -import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.actions.RepeatAction; import com.badlogic.gdx.scenes.scene2d.ui.*; +import com.badlogic.gdx.scenes.scene2d.ui.Button; import com.badlogic.gdx.scenes.scene2d.ui.Image; -import com.badlogic.gdx.scenes.scene2d.ui.Label; -import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.utils.Align; -import com.badlogic.gdx.utils.viewport.FillViewport; +import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.ilotterytea.maxoning.MaxonConstants; import com.ilotterytea.maxoning.MaxonGame; -import com.ilotterytea.maxoning.anim.SpriteUtils; import com.ilotterytea.maxoning.player.MaxonSavegame; -import com.ilotterytea.maxoning.player.utils.PetUtils; import com.ilotterytea.maxoning.ui.*; import com.ilotterytea.maxoning.utils.I18N; import com.ilotterytea.maxoning.utils.serialization.GameDataSystem; -import java.awt.*; import java.util.ArrayList; -import java.util.Locale; public class MenuScreen implements Screen { + private final MaxonGame game; - final MaxonGame game; - - final Stage stage; - final Skin skin; - TextureAtlas brandAtlas, mainAtlas; - - Image brandLogo; - - final Music menuMusic; - - Table menuTable; - - TextButton startBtn; - ImageButton rArrowBtn, lArrowBtn; - Label savLabel; - final DebugInfo debugInfo; - + private final Stage stage; + private final Music menuMusic; MaxonSavegame sav; - ArrayList<SavegameInfo> savInfos; - ArrayList<Image> savImgs; - - int curSav; - SavegameInfo curSavInfo; - Image curSavImg; - - boolean inOptions = false; - - private final MovingChessBackground bg; - public MenuScreen(final MaxonGame game) { this.game = game; - savInfos = new ArrayList<>(); - savImgs = new ArrayList<>(); - curSav = -1; - // Stage and skin: - this.stage = new Stage(new FillViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); + this.stage = new Stage(new ScreenViewport()); this.stage.addAction(Actions.sequence(Actions.alpha(0.0f), Actions.alpha(1.0f, 1f))); - this.skin = game.assetManager.get("MainSpritesheet.skin", Skin.class); - brandAtlas = game.assetManager.get("sprites/gui/brand.atlas", TextureAtlas.class); - mainAtlas = game.assetManager.get("MainSpritesheet.atlas", TextureAtlas.class); + Skin skin = game.assetManager.get("MainSpritesheet.skin", Skin.class); + Skin widgetSkin = game.assetManager.get("sprites/gui/widgets.skin", Skin.class); + TextureAtlas brandAtlas = game.assetManager.get("sprites/gui/brand.atlas", TextureAtlas.class); + TextureAtlas widgetAtlas = game.assetManager.get("sprites/gui/widgets.atlas", TextureAtlas.class); sav = GameDataSystem.load("00.maxon"); @@ -85,53 +51,21 @@ public class MenuScreen implements Screen { this.menuMusic = game.assetManager.get("mus/menu/mus_menu_loop.ogg", Music.class); menuMusic.setLooping(true); - // // Menu table: - float iconSize = 64f, iconPad = 6f; - menuTable = new Table(); - menuTable.setSize(stage.getWidth() / 2f, iconSize); - menuTable.setPosition(0, 0); - menuTable.pad(iconPad); - menuTable.align(Align.bottomLeft); - - // Quit button: - ImageButton quitBtn = new ImageButton(skin, "quit"); + // - - - - - - U I - - - - - - + Table menuTable = new Table(); + menuTable.setFillParent(true); - quitBtn.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - Gdx.app.exit(); - } - }); - - menuTable.add(quitBtn).size(iconSize).pad(iconPad); - - // Options button: - ImageButton optBtn = new ImageButton(skin, "options"); - - optBtn.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - showOptions(); - } - }); + // - - - Brand - - - + Table brandTable = new Table(); - menuTable.add(optBtn).size(iconSize).pad(iconPad); + Image logo = new Image(brandAtlas.findRegion("brand")); - stage.addActor(menuTable); - - // // Logo: - brandLogo = new Image(brandAtlas.findRegion("brand")); - brandLogo.setPosition( - (stage.getWidth() / 2f) - (brandLogo.getWidth() / 2f), - stage.getHeight() - brandLogo.getHeight() * 1.2f - ); - - brandLogo.setOrigin( - brandLogo.getWidth() / 2f, - brandLogo.getHeight() / 2f + logo.setOrigin( + logo.getWidth() / 2f, + logo.getHeight() / 2f ); - brandLogo.addAction( + logo.addAction( Actions.repeat( RepeatAction.FOREVER, Actions.sequence( @@ -147,277 +81,43 @@ public class MenuScreen implements Screen { ) ); - stage.addActor(brandLogo); - - // Debug info: - debugInfo = new DebugInfo(skin, game.locale); - debugInfo.setPosition(4, (stage.getHeight() / 2f) + 128f); - if (game.prefs.getBoolean("debug")) stage.addActor(debugInfo); - - Gdx.input.setInputProcessor(new InputMultiplexer(stage)); - - // Generate background tiles: - this.bg = new MovingChessBackground( - 1, - 1, - stage.getWidth(), - stage.getHeight(), - skin.getDrawable("tile_01"), - skin.getDrawable("tile_02") - ); - - generateSaves(); - - updateCurrentVisualSavegame(false); - - // Save control buttons: - rArrowBtn = new ImageButton(skin, "right_arrow"); - rArrowBtn.setPosition( - stage.getWidth() - (rArrowBtn.getWidth() * 2), - (stage.getHeight() / 2f) - (rArrowBtn.getHeight() / 2f) - ); - rArrowBtn.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - if (!inOptions) updateCurrentVisualSavegame(false); - } - }); - - stage.addActor(rArrowBtn); - - - // Save control buttons: - lArrowBtn = new ImageButton(skin, "left_arrow"); - lArrowBtn.setPosition( - lArrowBtn.getWidth(), - (stage.getHeight() / 2f) - (lArrowBtn.getHeight() / 2f) - ); - lArrowBtn.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - if (!inOptions) updateCurrentVisualSavegame(true); - } - }); - - stage.addActor(lArrowBtn); - } - - @Override public void show() { - if (game.prefs.getBoolean("music", true)) menuMusic.play(); - - // Start to render: - render(Gdx.graphics.getDeltaTime()); - } - - @Override - public void render(float delta) { - Gdx.gl.glClearColor(1, 1, 1, 1f); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - - game.batch.begin(); - - bg.draw(game.batch); - - game.batch.end(); - - stage.act(delta); - stage.draw(); - } - - @Override - public void resize(int width, int height) { - bg.update(width, height); - - stage.getViewport().update(width, height, true); - } - - private void showOptions() { - inOptions = !inOptions; - - lArrowBtn.addAction(Actions.moveTo(-lArrowBtn.getWidth(), lArrowBtn.getY(), 1f, Interpolation.smoother)); - rArrowBtn.addAction(Actions.moveTo(stage.getWidth(), rArrowBtn.getY(), 1f, Interpolation.smoother)); - curSavInfo.addAction(Actions.moveTo(curSavInfo.getX(), -curSavInfo.getHeight(), 1f, Interpolation.smoother)); - curSavImg.addAction(Actions.moveTo(curSavImg.getX(), -curSavImg.getHeight(), 2f, Interpolation.smoother)); - menuTable.addAction(Actions.moveTo(menuTable.getX(), -menuTable.getY() - menuTable.getHeight() - 48f, 1f, Interpolation.smoother)); - - brandLogo.clearActions(); - brandLogo.addAction(Actions.moveTo(brandLogo.getX(), stage.getHeight() + brandLogo.getHeight(), 1f, Interpolation.smoother)); - - // Main options window: - final Table optionsTable = new Table(skin); - optionsTable.setBackground("bg"); - optionsTable.align(Align.top | Align.center); - optionsTable.setSize(768f, 640f); - optionsTable.setX((stage.getWidth() / 2f) - (optionsTable.getWidth() / 2f)); - stage.addActor(optionsTable); - - float paddingBottom = 10f; - - // Options title: - Label optTitle = new Label(game.locale.TranslatableText("options.title"), skin, "header_with_bg"); - optTitle.setAlignment(Align.center); - optionsTable.add(optTitle).width(optionsTable.getWidth()).row(); - - Table contentTable = new Table(); - contentTable.align(Align.top | Align.center); - contentTable.setWidth(optionsTable.getWidth()); - - // Scroll panel for options: - ScrollPane optScroll = new ScrollPane(contentTable); - optScroll.setScrollingDisabled(true, false); - optionsTable.add(optScroll).width(optionsTable.getWidth()).height(512f).padBottom(paddingBottom).row(); - - // - - - General category - - -: - Label genLabel = new Label(game.locale.TranslatableText("options.general"), skin, "subheader_with_bg"); - contentTable.add(genLabel).fillX().padBottom(paddingBottom).row(); - - Table genCategory = new Table(); - contentTable.add(genCategory).fillX().padBottom(paddingBottom).row(); - - // Show debug: - Label debLabel = new Label(game.locale.TranslatableText("options.debug"), skin); - debLabel.setAlignment(Align.left); - genCategory.add(debLabel).width(optionsTable.getWidth() / 2f).padBottom(paddingBottom); - - final TextButton debButton = new TextButton((game.prefs.getBoolean("debug", false)) ? "ON" : "OFF", skin); - - debButton.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - boolean value = game.prefs.getBoolean("debug", false); - - game.prefs.putBoolean("debug", !value); - - value = !value; - - if (value) stage.addActor(debugInfo); - else debugInfo.remove(); - - debButton.getLabel().setText((value) ? "ON" : "OFF"); - } - }); - - genCategory.add(debButton).width(optionsTable.getWidth() / 2f).padBottom(paddingBottom).row(); - - // - - - Audio category - - -: - Label audioLabel = new Label(game.locale.TranslatableText("options.audio"), skin, "subheader_with_bg"); - contentTable.add(audioLabel).fillX().padBottom(paddingBottom).row(); - - Table audioCategory = new Table(); - contentTable.add(audioCategory).fillX().padBottom(paddingBottom).row(); - - // Music: - Label musLabel = new Label(game.locale.TranslatableText("options.music"), skin); - musLabel.setAlignment(Align.left); - audioCategory.add(musLabel).width(optionsTable.getWidth() / 2f).padBottom(paddingBottom); - - final TextButton musButton = new TextButton((game.prefs.getBoolean("music", true)) ? "ON" : "OFF", skin); - - musButton.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - boolean value = game.prefs.getBoolean("music", true); - - game.prefs.putBoolean("music", !value); - - value = !value; + brandTable.add(logo); - if (value) menuMusic.play(); - else menuMusic.pause(); + // - - - Menu control (quit, options, etc.) - - - + Table controlTable = new Table(skin); + controlTable.align(Align.top | Align.center); + controlTable.pad(6f); - musButton.getLabel().setText((value) ? "ON" : "OFF"); - } - }); - - audioCategory.add(musButton).width(optionsTable.getWidth() / 2f).padBottom(paddingBottom).row(); + // Left part of menu control + Table leftGameControlTable = new Table(); + leftGameControlTable.align(Align.left); - // Sound: - Label sndLabel = new Label(game.locale.TranslatableText("options.sound"), skin); - sndLabel.setAlignment(Align.left); - audioCategory.add(sndLabel).width(optionsTable.getWidth() / 2f).padBottom(paddingBottom); + ImageButton quitButton = new ImageButton(widgetSkin, "quit"); - final TextButton sndButton = new TextButton((game.prefs.getBoolean("sfx", true)) ? "ON" : "OFF", skin); - - sndButton.addListener(new ClickListener() { + quitButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - boolean value = game.prefs.getBoolean("sfx", true); - - game.prefs.putBoolean("sfx", !value); - - value = !value; - - sndButton.getLabel().setText((value) ? "ON" : "OFF"); - } - }); - - audioCategory.add(sndButton).width(optionsTable.getWidth() / 2f).padBottom(paddingBottom).row(); - - // - - - Video category - - -: - Label videoLabel = new Label(game.locale.TranslatableText("options.video"), skin, "subheader_with_bg"); - contentTable.add(videoLabel).fillX().padBottom(paddingBottom).row(); - - Table videoCategory = new Table(); - contentTable.add(videoCategory).fillX().padBottom(paddingBottom).row(); - - // Vertical sync: - Label vscLabel = new Label(game.locale.TranslatableText("options.vsync"), skin); - vscLabel.setAlignment(Align.left); - videoCategory.add(vscLabel).width(optionsTable.getWidth() / 2f).padBottom(paddingBottom); - - final TextButton vscButton = new TextButton((game.prefs.getBoolean("vsync", true)) ? "ON" : "OFF", skin); - - vscButton.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - boolean value = game.prefs.getBoolean("vsync", true); - - game.prefs.putBoolean("vsync", !value); - - value = !value; - - Gdx.graphics.setVSync(value); - - vscButton.getLabel().setText((value) ? "ON" : "OFF"); + super.clicked(event, x, y); + Gdx.app.exit(); } }); - videoCategory.add(vscButton).width(optionsTable.getWidth() / 2f).padBottom(paddingBottom).row(); - - // Full screen: - Label fscLabel = new Label(game.locale.TranslatableText("options.fullscreen"), skin); - fscLabel.setAlignment(Align.left); - //videoCategory.add(fscLabel).width(optionsTable.getWidth() / 2f).padBottom(paddingBottom); + leftGameControlTable.add(quitButton).padRight(12f); - final TextButton fscButton = new TextButton((game.prefs.getBoolean("fullscreen", true)) ? "ON" : "OFF", skin); + // Right part of menu control + Table rightGameControlTable = new Table(); + rightGameControlTable.align(Align.right); - fscButton.addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - boolean value = game.prefs.getBoolean("fullscreen", true); - - game.prefs.putBoolean("fullscreen", !value); - - value = !value; - Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); - - if (value) Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); - else Gdx.graphics.setWindowedMode(dim.width, dim.height); - - fscButton.getLabel().setText((value) ? "ON" : "OFF"); - } - }); - - //videoCategory.add(fscButton).width(optionsTable.getWidth() / 2f).padBottom(paddingBottom).row(); - - // - - - Switch the language - - -: + // Localization String[] fh4Locale = game.locale.getFileHandle().nameWithoutExtension().split("_"); - Locale locale = new Locale(fh4Locale[0], fh4Locale[1]); - final TextButton langButton = new TextButton(game.locale.FormattedText("options.language", locale.getDisplayLanguage(), locale.getDisplayCountry()), skin); + String localeButtonStyleName = "locale_" + fh4Locale[0]; + ImageButton localeButton = new ImageButton(widgetSkin, localeButtonStyleName); - langButton.addListener(new ClickListener() { + localeButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { + super.clicked(event, x, y); + int index = 0; ArrayList<FileHandle> fhArray = new ArrayList<>(); fhArray.add(MaxonConstants.FILE_RU_RU); @@ -431,156 +131,121 @@ public class MenuScreen implements Screen { game.locale = new I18N(fhNext); game.prefs.putString("lang", fhNext.nameWithoutExtension()); + game.prefs.flush(); - String[] fh4Locale = fhNext.nameWithoutExtension().split("_"); - Locale locale = new Locale(fh4Locale[0], fh4Locale[1]); - - langButton.setText(game.locale.FormattedText("options.language", locale.getDisplayLanguage(), locale.getDisplayCountry())); game.setScreen(new SplashScreen(game)); menuMusic.stop(); } }); - contentTable.add(langButton).width(optionsTable.getWidth()).padBottom(paddingBottom).row(); - // Game info: - Label infLabel = new Label(String.format("%s-%s - %s", System.getProperty("os.name"), System.getProperty("os.arch"), MaxonConstants.GAME_VERSION), skin, "small-pixeled"); - infLabel.setAlignment(Align.center); - optionsTable.add(infLabel).maxWidth(optionsTable.getWidth() / 2f).row(); + rightGameControlTable.add(localeButton).padRight(16f); - // // Action buttons: - Table actTable = new Table(skin); - actTable.setBackground("fg"); - actTable.setWidth(optionsTable.getWidth()); - actTable.align(Align.right); - optionsTable.add(actTable).width(optionsTable.getWidth()).maxWidth(optionsTable.getWidth()).pad(5f); + // Music button + String musicButtonStyleName; - TextButton closeBtn = new TextButton("Back to main menu", skin); + if (game.prefs.getBoolean("music")) { + musicButtonStyleName = "music_on"; + menuMusic.play(); + } else { + musicButtonStyleName = "music_off"; + } - closeBtn.addListener(new ClickListener() { + ImageButton musicButton = new ImageButton(widgetSkin, musicButtonStyleName); + musicButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - inOptions = !inOptions; - optionsTable.addAction(Actions.moveTo(optionsTable.getX(), -stage.getHeight(), 2f, Interpolation.smoother)); + super.clicked(event, x, y); - brandLogo.clearActions(); - brandLogo.addAction( - Actions.sequence( - Actions.parallel( - Actions.rotateTo(0f, 1f), - Actions.moveTo( - (stage.getWidth() / 2f) - (brandLogo.getWidth() / 2f), - stage.getHeight() - brandLogo.getHeight() * 1.2f, - 1f, - Interpolation.fade - ) - ), - Actions.repeat( - RepeatAction.FOREVER, - Actions.sequence( - Actions.parallel( - Actions.rotateTo(-5f, 5f, Interpolation.smoother), - Actions.scaleTo(0.9f, 0.9f, 5f, Interpolation.smoother) - ), - Actions.parallel( - Actions.rotateTo(5f, 5f, Interpolation.smoother), - Actions.scaleTo(1.1f, 1.1f, 5f, Interpolation.smoother) - ) - ) - ) - ) - ); + Button.ButtonStyle style; + + if (game.prefs.getBoolean("music")) { + style = widgetSkin.get("music_off", ImageButton.ImageButtonStyle.class); + menuMusic.pause(); + } else { + style = widgetSkin.get("music_on", ImageButton.ImageButtonStyle.class); + menuMusic.play(); + } - lArrowBtn.addAction(Actions.moveTo(lArrowBtn.getWidth(), lArrowBtn.getY(), 1f, Interpolation.smoother)); - rArrowBtn.addAction(Actions.moveTo(stage.getWidth() - rArrowBtn.getWidth() * 2, rArrowBtn.getY(), 1f, Interpolation.smoother)); - curSavInfo.addAction(Actions.moveTo(curSavInfo.getX(), 6f, 1f, Interpolation.smoother)); - curSavImg.addAction(Actions.moveTo(curSavImg.getX(), (stage.getHeight() / 2f) - (curSavImg.getHeight() / 2f), 2f, Interpolation.smoother)); - menuTable.addAction(Actions.moveTo(menuTable.getX(), 0, 1f, Interpolation.smoother)); + game.prefs.putBoolean("music", !game.prefs.getBoolean("music")); + game.prefs.flush(); + + musicButton.setStyle(style); } }); + rightGameControlTable.add(musicButton).padRight(16f); - actTable.add(closeBtn).pad(5f); + // Resolution button + String resolutionButtonStyleName; - TextButton saveBtn = new TextButton("Apply", skin); + if (game.prefs.getBoolean("fullscreen")) { + resolutionButtonStyleName = "windowed"; + } else { + resolutionButtonStyleName = "fullscreen"; + } - saveBtn.addListener(new ClickListener() { + ImageButton resolutionButton = new ImageButton(widgetSkin, resolutionButtonStyleName); + resolutionButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - game.prefs.flush(); - } - }); - - actTable.add(saveBtn).pad(5f); - - optionsTable.setY(-optionsTable.getHeight()); - optionsTable.addAction(Actions.moveTo(optionsTable.getX(), (stage.getHeight() / 2f) - (optionsTable.getHeight() / 2f), 2f, Interpolation.smoother)); - } + super.clicked(event, x, y); - private void generateSaves() { - ArrayList<MaxonSavegame> saves = GameDataSystem.getSavegames(); - int i = -1; + Button.ButtonStyle style; - for (MaxonSavegame sav : saves) { - i++; + if (game.prefs.getBoolean("fullscreen")) { + style = widgetSkin.get("fullscreen", ImageButton.ImageButtonStyle.class); + Gdx.graphics.setWindowedMode(game.prefs.getInteger("width", 800), game.prefs.getInteger("height", 600)); + } else { + style = widgetSkin.get("windowed", ImageButton.ImageButtonStyle.class); + Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); + } - savInfos.add(new SavegameInfo(game, game.locale, skin, sav, i)); - savImgs.add(new Image( - PetUtils.animatedImageById(game.assetManager, sav.petId).getDrawable() - ) - ); - } + game.prefs.putBoolean("fullscreen", !game.prefs.getBoolean("fullscreen")); + game.prefs.flush(); - savInfos.add(new SavegameInfo(game, game.locale, skin, null, i + 1)); - savImgs.add(new Image( - mainAtlas.findRegion("unknown") - )); - } + resolutionButton.setStyle(style); + } + }); + rightGameControlTable.add(resolutionButton); - private void updateCurrentVisualSavegame(boolean indexNegative) { - if (indexNegative) curSav--; - else curSav++; + controlTable.add(leftGameControlTable).grow(); + controlTable.add(rightGameControlTable).grow(); - if (curSav < 0) { - curSav = savInfos.size() - 1; - } + // - - - Savegame - - - + Table savegameTable = new Table(); + SavegameWidget info = new SavegameWidget(this.game, skin, sav); - if (savInfos.size() - 1 < curSav || savImgs.size() - 1 < curSav) { - curSav = 0; - } + savegameTable.add(info).minSize(640f, 240f); - // Set the image: - if (curSavImg != null) { - curSavImg.remove(); - curSavImg.setSize( - curSavImg.getWidth() / 2f, - curSavImg.getHeight() / 2f - ); - } - curSavImg = savImgs.get(curSav); + // Adding tables into the main UI table + menuTable.add(brandTable).grow().row(); + menuTable.add(savegameTable).grow().row(); + menuTable.add(controlTable).growX(); - curSavImg.setSize( - curSavImg.getWidth() * 2f, - curSavImg.getHeight() * 2f - ); + this.stage.addActor(menuTable); - curSavImg.setPosition( - (stage.getWidth() / 2f) - (curSavImg.getWidth() / 2f), - (stage.getHeight() / 2f) - (curSavImg.getHeight() / 2f) - ); + Gdx.input.setInputProcessor(stage); + } - stage.addActor(curSavImg); + @Override public void show() { + if (game.prefs.getBoolean("music", true)) menuMusic.play(); - // Set the info: - if (curSavInfo != null) curSavInfo.remove(); + // Start to render: + render(Gdx.graphics.getDeltaTime()); + } - curSavInfo = savInfos.get(curSav); + @Override + public void render(float delta) { + Gdx.gl.glClearColor(1, 1, 1, 1f); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - curSavInfo.setPosition( - (stage.getWidth() / 2f) - (curSavInfo.getWidth() / 2f), - 6f - ); + stage.act(delta); + stage.draw(); + } - stage.addActor(curSavInfo); + @Override + public void resize(int width, int height) { + stage.getViewport().update(width, height, true); } @Override public void pause() {} |
