@Override public void show() { isMuted = game.prefs.getBoolean("settingsMute"); doVibrate = game.prefs.getBoolean("settingsVibrate"); bigFont = game.manager.get("big_font.ttf", BitmapFont.class); mediumFont = game.manager.get("medium_font.ttf", BitmapFont.class); logoTexture = game.manager.get("logo.png", Texture.class); logoTextureHorizontal = game.manager.get("logo_horizontal.png", Texture.class); levelsTexture = game.manager.get("levels_icon.png", Texture.class); levelsTexturePressed = game.manager.get("levels_icon_pressed.png", Texture.class); randomTexture = game.manager.get("random_icon.png", Texture.class); randomTexturePressed = game.manager.get("random_icon_pressed.png", Texture.class); shopTexture = game.manager.get("shop_icon.png", Texture.class); shopTexturePressed = game.manager.get("shop_icon_pressed.png", Texture.class); settingsTexture = game.manager.get("settings_icon.png", Texture.class); settingsTexturePressed = game.manager.get("settings_icon_pressed.png", Texture.class); clickSound = game.manager.get("click.mp3", Sound.class); logoTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); logoTextureHorizontal.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); levelsTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); levelsTexturePressed.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); randomTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); randomTexturePressed.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); shopTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); shopTexturePressed.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); settingsTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); settingsTexturePressed.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); levelsButtonStyle = new ImageButton.ImageButtonStyle(); levelsButtonStyle.imageUp = new TextureRegionDrawable(new TextureRegion(levelsTexture)); levelsButtonStyle.imageDown = new TextureRegionDrawable(new TextureRegion(levelsTexturePressed)); randomButtonStyle = new ImageButton.ImageButtonStyle(); randomButtonStyle.imageUp = new TextureRegionDrawable(new TextureRegion(randomTexture)); randomButtonStyle.imageDown = new TextureRegionDrawable(new TextureRegion(randomTexturePressed)); shopButtonStyle = new ImageButton.ImageButtonStyle(); shopButtonStyle.imageUp = new TextureRegionDrawable(new TextureRegion(shopTexture)); shopButtonStyle.imageDown = new TextureRegionDrawable(new TextureRegion(shopTexturePressed)); settingsButtonStyle = new ImageButton.ImageButtonStyle(); settingsButtonStyle.imageUp = new TextureRegionDrawable(new TextureRegion(settingsTexture)); settingsButtonStyle.imageDown = new TextureRegionDrawable(new TextureRegion(settingsTexturePressed)); labelStyleBig = new Label.LabelStyle(); labelStyleBig.font = bigFont; labelStyleMedium = new Label.LabelStyle(); labelStyleMedium.font = mediumFont; stage = new Stage(new ScreenViewport()); stage.addListener( new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { if (keycode == Input.Keys.BACK || keycode == Input.Keys.BACKSPACE) { GDXButtonDialog dialog = game.dialogs.newDialog(GDXButtonDialog.class); dialog.setTitle("Are you sure?"); dialog.setMessage("Are you sure you want to exit?"); dialog.setClickListener( new ButtonClickListener() { @Override public void click(int button) { if (button == 1) { Gdx.app.exit(); } } }); dialog.addButton("No"); dialog.addButton("Yes"); dialog.build().show(); } return true; } }); stage.setDebugAll(false); Gdx.input.setInputProcessor(stage); Gdx.input.setCatchBackKey(true); Image logoImage = new Image(logoTexture); Image logoImageHorizontal = new Image(logoTextureHorizontal); logoImage.setScaling(Scaling.fit); logoImageHorizontal.setScaling(Scaling.fit); ImageButton levelsButton = new ImageButton(levelsButtonStyle); levelsButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!isMuted) { clickSound.play(); } if (doVibrate) { Gdx.input.vibrate(25); } game.setScreen(new LevelSelectScreen(game)); } }); Label levelsLabel = new Label("Levels", labelStyleMedium); ImageButton randomButton = new ImageButton(randomButtonStyle); randomButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!isMuted) { clickSound.play(); } if (doVibrate) { Gdx.input.vibrate(25); } game.setScreen(new GameScreen(game, game.randomLevel())); } }); Label randomLabel = new Label("Random", labelStyleMedium); ImageButton shopButton = new ImageButton(shopButtonStyle); shopButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!isMuted) { clickSound.play(); } if (doVibrate) { Gdx.input.vibrate(25); } game.setScreen(new ShopScreen(game)); } }); Label shopLabel = new Label("Shop", labelStyleMedium); ImageButton settingsButton = new ImageButton(settingsButtonStyle); settingsButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!isMuted) { clickSound.play(); } if (doVibrate) { Gdx.input.vibrate(25); } game.setScreen(new SettingsScreen(game)); } }); Label settingsLabel = new Label("Settings", labelStyleMedium); table = new Table(); table.setFillParent(true); table .add(logoImage) .colspan(2) .size(game.sizeModifier * 950) .padTop(game.sizeModifier * -75f) .padBottom(game.sizeModifier * -160f); table.row(); table.add(levelsButton).size(game.sizeModifier * 250).padRight(game.sizeModifier * -30); table.add(randomButton).size(game.sizeModifier * 250).padLeft(game.sizeModifier * -30); table.row(); table .add(levelsLabel) .padBottom(game.sizeModifier * 120) .padRight(game.sizeModifier * -30) .top(); table .add(randomLabel) .padBottom(game.sizeModifier * 120) .padLeft(game.sizeModifier * -30) .top(); table.row(); table.add(shopButton).size(game.sizeModifier * 250).padRight(game.sizeModifier * -30); table.add(settingsButton).size(game.sizeModifier * 260).padLeft(game.sizeModifier * -30); table.row(); table.add(shopLabel).expand().padRight(game.sizeModifier * -30).top(); table.add(settingsLabel).expand().padLeft(game.sizeModifier * -30).top(); stage.addActor(table); }
public static void configureSkin(Skin skin) { if (skin == null) { return; } loadResources(skin); loadLabels(skin); loadButtons(skin); ScrollPane.ScrollPaneStyle scrollPaneStyle = new ScrollPane.ScrollPaneStyle(); scrollPaneStyle.background = skin.newDrawable("white", Color.BLACK); scrollPaneStyle.hScroll = skin.newDrawable("white8x1", Color.GRAY); scrollPaneStyle.hScrollKnob = skin.newDrawable("white8x1", Color.WHITE); scrollPaneStyle.vScroll = skin.newDrawable("white1x8", Color.GRAY); scrollPaneStyle.vScrollKnob = skin.newDrawable("white1x8", Color.WHITE); scrollPaneStyle.corner = skin.newDrawable("white", Color.GRAY); skin.add("default", scrollPaneStyle); CheckBox.CheckBoxStyle checkBoxStyle = new CheckBox.CheckBoxStyle(); checkBoxStyle.font = skin.getFont("default"); checkBoxStyle.fontColor = Color.BLACK; checkBoxStyle.checkboxOn = skin.getDrawable("checkbox.on"); checkBoxStyle.checkboxOnDisabled = skin.getDrawable("checkbox.on.disabled"); checkBoxStyle.checkboxOff = skin.getDrawable("checkbox.off"); checkBoxStyle.checkboxOffDisabled = skin.getDrawable("checkbox.off.disabled"); skin.add("default", checkBoxStyle); checkBoxStyle = new CheckBox.CheckBoxStyle(); checkBoxStyle.font = skin.getFont("default"); checkBoxStyle.fontColor = Color.BLACK; checkBoxStyle.checkboxOn = skin.getDrawable("checkbox.on.slider.horizontal"); // checkBoxStyle.checkboxOnDisabled = skin.getDrawable("checkbox.on.disabled"); checkBoxStyle.checkboxOff = skin.getDrawable("checkbox.off.slider.horizontal"); // checkBoxStyle.checkboxOffDisabled = skin.getDrawable("checkbox.off.disabled"); skin.add("slider.horizontal", checkBoxStyle); Window.WindowStyle dialogStyle = new Window.WindowStyle(); dialogStyle.background = skin.newDrawable("window"); dialogStyle.stageBackground = skin.newDrawable("white", Color.valueOf("00000080")); dialogStyle.titleFont = skin.getFont("medium"); dialogStyle.titleFontColor = Color.BLACK; skin.add("default", dialogStyle); ImageButton.ImageButtonStyle upButtonStyle = new ImageButton.ImageButtonStyle(); upButtonStyle.imageUp = skin.getDrawable("arrow.up"); upButtonStyle.imageDown = skin.getDrawable("arrow.up"); upButtonStyle.imageDisabled = skin.getDrawable("arrow.up.disabled"); skin.add("arrow.up", upButtonStyle); ImageButton.ImageButtonStyle downButtonStyle = new ImageButton.ImageButtonStyle(); downButtonStyle.imageUp = skin.getDrawable("arrow.down"); downButtonStyle.imageDown = skin.getDrawable("arrow.down"); downButtonStyle.imageDisabled = skin.getDrawable("arrow.down.disabled"); skin.add("arrow.down", downButtonStyle); ImageButton.ImageButtonStyle radioButtonStyle = new ImageButton.ImageButtonStyle(); radioButtonStyle.imageUp = skin.getDrawable("radiobutton.off"); radioButtonStyle.imageOver = skin.getDrawable("radiobutton.off.over"); radioButtonStyle.imageChecked = skin.getDrawable("radiobutton.on"); radioButtonStyle.imageCheckedOver = skin.getDrawable("radiobutton.on.over"); radioButtonStyle.imageDisabled = skin.getDrawable("radiobutton.disabled"); skin.add("radiobutton", radioButtonStyle); }
protected Skin getSkin() { TextureAtlas atlasUiMenu = new TextureAtlas("icons.pack"); if (skin == null) { skin = new Skin(atlasUiMenu); playButtonStyle = new ImageButton.ImageButtonStyle(); playButtonStyle.up = skin.getDrawable("New Game"); playButtonStyle.down = skin.getDrawable("New Game selected"); playButtonStyle.over = skin.getDrawable("New Game"); playButtonStyle.pressedOffsetX = 1; playButtonStyle.pressedOffsetY = -1; optionButtonStyle = new ImageButton.ImageButtonStyle(); optionButtonStyle = new ImageButton.ImageButtonStyle(); optionButtonStyle.up = skin.getDrawable("Options"); optionButtonStyle.down = skin.getDrawable("Options selected"); optionButtonStyle.over = skin.getDrawable("Options"); optionButtonStyle.pressedOffsetX = 1; optionButtonStyle.pressedOffsetY = -1; continueButtonStyle = new ImageButton.ImageButtonStyle(); continueButtonStyle = new ImageButton.ImageButtonStyle(); continueButtonStyle.up = skin.getDrawable("Continue"); continueButtonStyle.down = skin.getDrawable("Continue selected"); continueButtonStyle.over = skin.getDrawable("Continue"); continueButtonStyle.pressedOffsetX = 1; continueButtonStyle.pressedOffsetY = -1; quitButtonStyle = new ImageButton.ImageButtonStyle(); quitButtonStyle = new ImageButton.ImageButtonStyle(); quitButtonStyle.up = skin.getDrawable("Quit"); quitButtonStyle.down = skin.getDrawable("Quit selected"); quitButtonStyle.over = skin.getDrawable("Quit"); quitButtonStyle.pressedOffsetX = 1; quitButtonStyle.pressedOffsetY = -1; } return skin; }