@Override public void create() { w = Gdx.graphics.getWidth(); h = Gdx.graphics.getHeight(); margin = 10; stage = new Stage(); Gdx.input.setInputProcessor(stage); Skin skin = new Skin(Gdx.files.internal("data/uiskin.json")); FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf")); BitmapFont font15 = generator.generateFont(15); generator.dispose(); LabelStyle lblStyle = new LabelStyle(skin.get(LabelStyle.class)); lblStyle.font = font15; lblStyle.fontColor = Color.BLACK; lblStyle.background = null; LabelStyle lblOutStyle = new LabelStyle(skin.get(LabelStyle.class)); lblOutStyle.font = font15; lblOutStyle.fontColor = Color.BLACK; lblOutStyle.background = new ColorDrawable(new HSV_Color(Color.WHITE)); TextButtonStyle btnStyle = skin.get(TextButtonStyle.class); btnStyle.font = font15; btnStyle.fontColor = Color.BLACK; lblMsg = new Label(Msg, lblStyle); stage.addActor(lblMsg); lblOut = new Label("", lblOutStyle); // lblOut = new Label("", lblStyle); lblOut.setText(" "); stage.addActor(lblOut); btnRunLibGdx = new TextButton("", btnStyle); stage.addActor(btnRunLibGdx); btnRunTranslations = new TextButton("download and copy latest translations", btnStyle); btnRunTranslations.addListener(runListenerTranslations); stage.addActor(btnRunTranslations); btnRunTexturePacker = new TextButton("Pack and copy Texture Images", btnStyle); btnRunTexturePacker.addListener(runListenerTexture); stage.addActor(btnRunTexturePacker); TeePrintStream tee = new TeePrintStream(System.out); System.setOut(tee); chkSource(); layout(); }
public MenuItem(Menu parentMenu, String text, Skin skin) { this.parentMenu = parentMenu; style = skin.get(MenuItemStyle.class); labelStyle = new LabelStyle(); labelStyle.font = style.font; labelStyle.fontColor = style.fontColor; this.label = new Label(text, labelStyle); contextMenu = new ContextMenu(skin); contextMenu.setVisible(false); addActor(this.label); addActor(contextMenu); addListener( new ClickListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (contextMenu.isVisible()) { MenuItem.this.parentMenu.selected(null, true); } else { MenuItem.this.parentMenu.selected(MenuItem.this, true); } event.stop(); return false; } @Override public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { MenuItem.this.parentMenu.selected(MenuItem.this, false); } }); }
@Override public void setStyle(ButtonStyle style) { if (!(style instanceof MenuItemStyle)) throw new IllegalArgumentException("style must be a MenuItemStyle."); super.setStyle(style); this.style = (MenuItemStyle) style; if (label != null) { TextButtonStyle textButtonStyle = (TextButtonStyle) style; LabelStyle labelStyle = label.getStyle(); labelStyle.font = textButtonStyle.font; labelStyle.fontColor = textButtonStyle.fontColor; label.setStyle(labelStyle); } }
public void setStyle(ButtonStyle style) { if (!(style instanceof ImageTextButtonStyle)) throw new IllegalArgumentException("style must be a ImageTextButtonStyle."); super.setStyle(style); this.style = (ImageTextButtonStyle) style; if (image != null) updateImage(); if (label != null) { ImageTextButtonStyle textButtonStyle = (ImageTextButtonStyle) style; LabelStyle labelStyle = label.getStyle(); labelStyle.font = textButtonStyle.font; labelStyle.fontColor = textButtonStyle.fontColor; label.setStyle(labelStyle); } }
@Override public void setDisabled(boolean isDisabled) { this.disabled = isDisabled; labelStyle.fontColor = disabled && style.fontColorDisabled != null ? style.fontColorDisabled : style.fontColor; }
@Override public void start() { super.start(); if (this.type == FinalStage.TYPE_GAME_OVER) { StageScreen.getInstance().getTracker().trackScreen("gameOverScreen"); } else { StageScreen.getInstance().getTracker().trackScreen("gameWinScreen"); } this.music = Manager.getInstance().get(musicFile, Music.class); this.music.setVolume(Settings.getInstance().getMusicVolume()); this.music.play(); TextureAtlas atlas = Manager.getInstance().get("img/menu.pack", TextureAtlas.class); LabelStyle headerStyle = new LabelStyle(); headerStyle.font = Config.getInstance().headerFont; headerStyle.fontColor = Config.getInstance().textColor; String labelText = (type == FinalStage.TYPE_GAME_OVER) ? "game.over" : "game.win"; Label text = new Label(Translator.getInstance().translate(labelText), headerStyle); text.setBounds( 50, 150, Config.getInstance().gameWidth - 100, Config.getInstance().gameHeight - 150); text.setAlignment(Align.center); text.setWrap(true); text.getColor().a = 0; text.addAction(fadeIn(2f)); this.addActor(text); AtlasRegion btnBg = atlas.findRegion("btn-bg"); AtlasRegion btnBgTouched = atlas.findRegion("btn-bg-touched"); Color btnColor = new Color(1, 1, 1, 1); Color btnColorTouched = new Color(0.5f, 0.5f, 0.5f, 1); TextButton newGame = new TextButton( btnBg, btnBgTouched, Translator.getInstance().translate("btn.new.game"), Config.getInstance().bigFont, btnColor, btnColorTouched); newGame.setHeight(btnHeight); newGame.setPosition(50, 50); newGame.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { StageScreen.getInstance().setStage(new SlideStage(SlideStage.TYPE_INTRO)); } }); this.addActor(newGame); TextButton exit = new TextButton( btnBg, btnBgTouched, Translator.getInstance().translate("btn.exit"), Config.getInstance().bigFont, btnColor, btnColorTouched); exit.setHeight(btnHeight); exit.setPosition(Config.getInstance().gameWidth - exit.getWidth() - 50, 50); exit.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { StageScreen.getInstance().setStage(new MenuStage()); } }); this.addActor(exit); }