public GameplayMenuWindow( final GameplayScreen screen, Skin skin, final IRemovedListener listener) { super("Quit", skin); final TextButton okButton = new TextButton("OK", skin); okButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { screen.exit(true); listener.removed(); } }); final TextButton cancelButton = new TextButton("Cancel", skin); cancelButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { GameplayMenuWindow.this.remove(); listener.removed(); } }); Label quitLabel = new Label( "Are you sure you want to quit? You will lose half the money you gained in the level!", skin); quitLabel.setWrap(true); quitLabel.setAlignment(Align.center); add(quitLabel).colspan(2).width(Gdx.graphics.getWidth() / 3f); row(); add(okButton); add(cancelButton); pack(); setX(Gdx.graphics.getWidth() / 2f - getWidth() / 2f); setY(Gdx.graphics.getHeight() / 2f - getHeight() / 2f); }
public Window returnScreen() { final TextButton ts = new TextButton("Return to Title Screen", skin, "default"); ts.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.setScreen(new SplashScreen(game)); } }); final TextButton qd = new TextButton("Quit to Desktop", skin, "default"); qd.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.exit(); } }); final Window win = new Window("Return Menu", skin); win.setWidth(200); win.setHeight(90); win.setMovable(true); win.setPosition( Gdx.graphics.getWidth() / 2 - 100, Gdx.graphics.getHeight() / 2 - win.getHeight() / 2); win.defaults().space(5); win.row().fill().expandX(); win.add(ts); win.row().fill(); win.add(qd); return win; }
public Window ghostPanel() { if (HW4.stop) return null; float offset = 100; final TextButton atk = new TextButton("Action", skin, "default"); final TextButton pat = new TextButton("Patrol", skin, "default"); final TextButton def = new TextButton("Defend", skin, "default"); final TextButton upg = new TextButton("Flee", skin, "default"); atk.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { atk.setColor(Color.DARK_GRAY); // set to white to get color back pat.setColor(Color.WHITE); SelectionManager._instance.setCurrCommand(commandType.Action, atk); // waitForLeftMouse(atk); return true; } }); def.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { SelectionManager._instance.issueDefendCommand(); } }); pat.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { pat.setColor(Color.DARK_GRAY); // set to white to get color back atk.setColor(Color.WHITE); SelectionManager._instance.setCurrCommand(commandType.Patrol, pat); return true; } }); upg.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { SelectionManager._instance.issueFleeCommand(); } }); final Window win = new Window("Ghost Unit Actions", skin); win.setWidth(230); win.setHeight(90); win.setMovable(false); win.setPosition(Gdx.graphics.getWidth() / 2 - 115, 0); win.defaults().space(5); win.row().fill().expandX(); win.add(atk, def); win.row().fill(); win.add(pat, upg); return win; }
@Override public void show() { exitButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { AfterGameScreen.this.game.setScreen(new MenuScreen(game)); } }); playButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Preferences prefs = Gdx.app.getPreferences("com.meataminers.brave-miner-defender.settings"); String playerName = prefs.getString("playerName", ""); int selectedCharacter = prefs.getInteger("selectedCharacter", 0); int selectedVillage = prefs.getInteger("selectedVillage", 0); int selectedDifficulty = prefs.getInteger("selectedDifficulty", 1); PlayingInformation info = new PlayingInformation(); // TODO: ODKOMENTOWAC PONIZSZE I UZUPELNIC GAMECONSTANTS ORAZ ABSTRACTHERO // (IMPLEMENTACJA) - todo skopiowane z beforeGameScreena info.setHero(selectedCharacter); // pierwszy jest do Villages, drugi jest do T³a Village info.setVillage(selectedVillage, selectedVillage); AfterGameScreen.this.game.setScreen(new LevelScreen(game, info, audioManager)); } }); Gdx.input.setInputProcessor(stage); }
@Override public void show() { super.show(); table = new Table(); table.setFillParent(true); TextButtonStyle bStyle = new TextButtonStyle(); bStyle.font = Cache.getFont(48); bStyle.fontColor = Color.LIGHT_GRAY; final TextButton buttonPlay = new TextButton("PLAY", bStyle); buttonPlay.pad(20); table.add(buttonPlay); table.row(); final TextButton buttonCredits = new TextButton("CREDITS", bStyle); buttonCredits.pad(20); table.add(buttonCredits); table.row(); final TextButton buttonExit = new TextButton("EXIT", bStyle); buttonExit.pad(20); table.add(buttonExit); table.pad(150, 0, 0, 0); getStage().addActor(table); buttonPlay.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { onExit(new LevelSelect(getGame()), buttonPlay, buttonCredits, buttonExit); } }); buttonCredits.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { onExit(new Credits(getGame()), buttonPlay, buttonCredits, buttonExit); } }); buttonExit.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.exit(); } }); Tween.set(buttonPlay, ActorAccessor.ALPHA).target(0).start(getTweenManager()); Tween.to(buttonPlay, ActorAccessor.ALPHA, 1).target(1).start(getTweenManager()); Tween.set(buttonCredits, ActorAccessor.ALPHA).target(0).start(getTweenManager()); Tween.to(buttonCredits, ActorAccessor.ALPHA, 1).target(1).delay(0.1f).start(getTweenManager()); Tween.set(buttonExit, ActorAccessor.ALPHA).target(0).start(getTweenManager()); Tween.to(buttonExit, ActorAccessor.ALPHA, 1).target(1).delay(0.2f).start(getTweenManager()); Gdx.input.setInputProcessor(new InputMultiplexer(getStage(), new TouchDetector(this))); }
public void showSheepMessageButtons() { if (sheepGame.isLosing()) { setupLoseButtons(); } else if (sheepGame.isWinning()) { setupWinButtons(); } else if (sheepGame.lastMessage()) { bottomMenu.clearChildren(); TextButton start = new TextButton("Start Level", assetHolder.buttonStyle); start.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.removeSheepMessage(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); bottomMenu .add(start) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); } else { bottomMenu.clearChildren(); TextButton next = new TextButton("Next", assetHolder.buttonStyle); next.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.removeSheepMessage(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); bottomMenu .add(next) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); } }
@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(); }
@Override public void show() { super.show(); // retrieve the custom skin for our 2D widgets Skin skin = super.getSkin(); // create the table actor and add it to the stage table = super.getTable(); table.setWidth(stage.getWidth()); table.setHeight(stage.getHeight()); table.pad(10).defaults().spaceBottom(10).space(5); table.row().fill().expandX(); AtlasRegion splashRegion = getAtlas().findRegion("splash-screen/menulogo"); Image logo = new Image(splashRegion); table.add(logo).fill(false); table.row(); table.pad(10).defaults().spaceBottom(10); TextButton continueButton = new TextButton("Continue", skin); continueButton.setVisible(false); continueButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { // game.setScreen( new StartGameScreen( game ) ); } }); table.add(continueButton).size(300, 60).uniform().spaceBottom(10); table.row(); table.pad(10).defaults().spaceBottom(10); TextButton newGameButton = new TextButton("New game", skin); newGameButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { // TODO: Move it back to char select screen // game.setScreen( new CharSelectScreen( game ) ); if (Unsealed.DEBUG) game.setScreen(new BattleScreen(game)); else game.setScreen(new SplashScreen(game)); } }); table.add(newGameButton).size(300, 60).uniform().spaceBottom(10); table.row(); table.pad(10).defaults().spaceBottom(10); // TextButton optionsButton = new TextButton( "Options", skin ); // optionsButton.setDisabled(true); // optionsButton.addListener( new ClickListener() { // @Override // public void clicked(InputEvent event, float x, float y ) { // game.setScreen( new OptionsScreen( game ) ); // } // } ); // table.add(optionsButton).size( 300, 60 ).uniform().spaceBottom(10); }
public void create() { stage = new Stage(); Gdx.input.setInputProcessor(stage); Skin skin = new Skin(Gdx.files.internal("data/uiskin.json")); Label nameLabel = new Label("Name:", skin); TextField nameText = new TextField("", skin); Label addressLabel = new Label("Address:", skin); TextField addressText = new TextField("", skin); Table table = new Table(); stage.addActor(table); table.setSize(260, 195); table.setPosition(190, 142); // table.align(Align.right | Align.bottom); table.debug(); TextureRegion upRegion = skin.getRegion("default-slider-knob"); TextureRegion downRegion = skin.getRegion("default-slider-knob"); BitmapFont buttonFont = skin.getFont("default-font"); TextButton button = new TextButton("Button 1", skin); button.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { System.out.println("touchDown 1"); return false; } }); table.add(button); // table.setTouchable(Touchable.disabled); Table table2 = new Table(); stage.addActor(table2); table2.setFillParent(true); table2.bottom(); TextButton button2 = new TextButton("Button 2", skin); button2.addListener( new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { System.out.println("2!"); } }); button2.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { System.out.println("touchDown 2"); return false; } }); table2.add(button2); }
public void addRetryButtons(Table table) { TextButton retry = new TextButton("Restart Level", assetHolder.buttonStyle); retry.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.unpauseOverlay(); gOverlay.retryLevel(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); table .add(retry) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); table.row(); TextButton selectLevel = new TextButton("Main Menu", assetHolder.buttonStyle); selectLevel.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.unpauseOverlay(); gOverlay.toMainMenu(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); table .add(selectLevel) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); table.row(); if (assetHolder.levelLoader.currentLevelHasHelp()) addHelpButton(table); }
@Override public void setUpInterface(Table table) { // TODO: Move this to the skin. ScrollPane.ScrollPaneStyle style = new ScrollPane.ScrollPaneStyle(); table.pad(20); Label header = new Label(game.getLocale().get("main.about"), game.getSkin(), "bold"); table.add(header).expandX().align(Align.center).height(80).row(); innerContainer = new Table(); ScrollPane scroll = new ScrollPane(innerContainer, style); table.add(scroll).expand().fill().align(Align.top).row(); innerContainer.defaults().fill().expand(); screen = SCREEN_CREDITS; updateScrollPane(); final TextButton changeButton = new TextButton(game.getLocale().get("about.license"), game.getSkin()); changeButton.addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (screen == SCREEN_CREDITS) { screen = SCREEN_LICENSE; changeButton.setText(game.getLocale().get("about.credits")); updateScrollPane(); } else { screen = SCREEN_CREDITS; changeButton.setText(game.getLocale().get("about.license")); updateScrollPane(); } game.player.playSound(SoundPlayer.SoundCode.SELECT); event.cancel(); } }); Table buttonRow = new Table(); buttonRow.defaults().fill().expand().width(Value.maxWidth).space(10); buttonRow.add(changeButton); TextButton backButton = new TextButton(game.getLocale().get("core.back"), game.getSkin()); buttonRow.add(backButton).row(); backButton.addListener(new ScreenPopper(game)); table.add(buttonRow).expandX().fillX().height(60).padTop(20).align(Align.bottom).row(); }
public Option() { selection_ = StateMEnuEnum.OPTION; values_ = GlobalValues.getInstance(); // creation zone affichage du menu stage = new Stage(new ScreenViewport()); // boutons et label layout_table = new Table(); layout_table.setSize(values_.get_width(), values_.get_width()); retour_ = new TextButton("Retour", values_.get_Skin()); // init du bouton retour retour_.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { selection_ = StateMEnuEnum.MENU; } }); layout_table.add(retour_).width(values_.get_width()).pad(10); stage.addActor(layout_table); // Gdx.input.setInputProcessor(stage); }
@Override public AbstractWidget createWidget(Controller controller) { Skin skin = controller.getApplicationAssets().getSkin(); LinearLayout bottomLayout = new LinearLayout(false); label = new Label("Stopped", skin); bottomLayout.add(label); SelectBox<String> selectBox = new SelectBox<String>(skin); selectBox.setItems( "Just", "a", "drop", "down", "list", "to", "check", "that", "UI", "doesn't", "freeze"); TextButton textButton = new TextButton("Run", skin); textButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.postRunnable(launchBackgroundProcess); } }); bottomLayout.add(selectBox); bottomLayout.add(textButton); return bottomLayout; }
public void addResumeButton(Table table) { TextButton resume = new TextButton("Resume", assetHolder.buttonStyle); resume.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.unpauseOverlay(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); table .add(resume) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); table.row(); }
public void setupWinButtons() { bottomMenu.clearChildren(); if (assetHolder.levelLoader.areMoveLevels()) { TextButton nextLevel = new TextButton("Next Level", assetHolder.buttonStyle); nextLevel.addListener( new InputListener() { private GameOverlay gOverlay; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { gOverlay.unpauseOverlay(); gOverlay.nextLevel(); } public InputListener setSceneChanger(GameOverlay s) { this.gOverlay = s; return this; } }.setSceneChanger(this)); bottomMenu .add(nextLevel) .height(assetHolder.getPercentHeightInt(assetHolder.buttonHeight)) .width(assetHolder.getPercentWidthInt(assetHolder.buttonWidth)) .pad(10); bottomMenu.row(); } addRetryButtons(bottomMenu); }
private void fillTable() { StyleHelper helper = StyleHelper.getInstance(); Table scrollTable = new Table(); ImageButton newProfile = new ImageButton( helper.getImageButtonStyle("widgets/icon-plus")); newProfile.addListener(new NewProfileClickListener()); scrollTable.defaults().width(500).height(100).space(10); scrollTable.padTop(30); for (Profile profile : profileController.getAllProfiles()) { TextButton profileButton = new TextButton(profile.getName(), helper.getTextButtonStyle()); scrollTable.add(profileButton); scrollTable.row(); profileButton.addListener(new ChangeProfileClickListener()); } scrollTable.add(newProfile); scrollTable.padBottom(15); ScrollPane scrollPane = new ScrollPane(scrollTable); table.add(scrollPane).expand().fill(); }
public SettingsScreen(AbstractScreen parentScreen) { super(parentScreen); initFitViewport(); // final AbstractAuthService authService = // mAdapter.getPlatformServices().getAuthService(); mBgStage.loadImage(this, "Bg/menu/settings-bg.jpg"); BackButton.create(this, MainMenuScreen.class); mSettings = new LocalSettings(); final CheckBox cbSounds = new CheckBox("", RM.getCheckBoxStyle()); cbSounds.setBounds(20, 500, SES.BUTTON_HEIGHT, SES.BUTTON_HEIGHT); cbSounds.setChecked(mSettings.getSoundEnabled()); mStage.addActor(cbSounds); cbSounds.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { mSettings.setSoundEnabled(cbSounds.isChecked()); mSettings.flush(); } }); Label lblSounds = new Label("Sound effects", RM.getLabelStyle()); lblSounds.setBounds(120, 500, 200, SES.BUTTON_HEIGHT); mStage.addActor(lblSounds); final CheckBox cbMusic = new CheckBox("", RM.getCheckBoxStyle()); cbMusic.setBounds(20, 400, SES.BUTTON_HEIGHT, SES.BUTTON_HEIGHT); cbMusic.setChecked(mSettings.getMusicEnabled()); mStage.addActor(cbMusic); cbMusic.addListener( new ClickListener() { public void clicked(InputEvent event, float x, float y) { mSettings.setMusicEnabled(cbMusic.isChecked()); mSettings.flush(); } }); Label lblMusic = new Label("Music", RM.getLabelStyle()); lblMusic.setBounds(120, 400, 200, SES.BUTTON_HEIGHT); mStage.addActor(lblMusic); TextButton btnGooglePlayLink = new TextButton("GooglePlay", RM.getTextButtonStyle()); btnGooglePlayLink.setBounds(SES.buttonRight(), 20, SES.BUTTON_WIDTH, SES.BUTTON_HEIGHT); mStage.addActor(btnGooglePlayLink); btnGooglePlayLink.addListener( new ClickListener() { public void clicked(InputEvent event, float x, float y) {} }); }
@Override public void show() { super.show(); // retrieve the default table actor Table table = super.getTable(); stage.clear(); // atlas = new TextureAtlas(Gdx.files.internal("assets/data/uiskin.atlas")); // skin = new Skin(Gdx.files.internal("assets/data/uiskin.json")); Label label = new Label("Jamkhed", getSkin()); Button bouton1 = new Button(getSkin()); bouton1.add("Start Game"); bouton1.addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { game.setScreen(game.getStartGameScreen()); Gdx.app.log(Jamkhed.LOG, "Allez HOP ACTION"); } }); TextButton bouton2 = new TextButton("Options", getSkin()); bouton2.addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { game.setScreen(new OptionsScreen(game)); Gdx.app.log(Jamkhed.LOG, "Allez HOP Options"); } }); Button bouton3 = new Button(getSkin()); bouton3.add("Hall Of Fame"); bouton3.addListener( new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Gdx.app.log(Jamkhed.LOG, "Allez HOP Classement"); } }); table.add(label).spaceBottom(20); table.row(); table.add(bouton1).width(150).spaceBottom(10); table.row(); table.add(bouton2).width(150).spaceBottom(10); table.row(); table.add(bouton3).width(150); table.row(); stage.addActor(table); }
public UIHelper() { stage = new Stage(); uiSkin = new Skin(Gdx.files.internal("data/uiskin.json")); loadTouchpad(); final TextButton button = new TextButton("place team", uiSkin, "default"); float width = Gdx.graphics.getWidth(); float height = Gdx.graphics.getHeight(); button.setWidth(100); button.setHeight(50); button.setPosition(width - 120, 20); button.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { placeTeam = !placeTeam; if (placeTeam) button.setText("ACTIVE"); else button.setText("place team"); } }); final TextButton button2 = new TextButton("place enemy", uiSkin, "default"); button2.setWidth(100); button2.setHeight(50); button2.setPosition(width - 240, 20); button2.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { placeEnemy = !placeEnemy; if (placeEnemy) button2.setText("ACTIVE"); else button2.setText("place enemy"); } }); stage.addActor(button); stage.addActor(button2); }
public Quitter() { selection_ = StateMEnuEnum.QUITTER; values_ = GlobalValues.getInstance(); skin_bouton = values_.get_Skin(); layout_table = new Table(); layout_table.setSize(values_.get_width(), values_.get_width()); // creation zone affichage du menu stage = new Stage(new ScreenViewport()); // boutons et label oui_bouton = new TextButton("Oui", skin_bouton); // init du bouton Jeu non_bouton = new TextButton("Non", skin_bouton); // init du bouton Option label_quitter = new Label("Voulez vous quitter?", skin_bouton); // création des listenners oui_bouton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.exit(); } }); non_bouton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { selection_ = StateMEnuEnum.MENU; } }); // placement des boutons layout_table.add(label_quitter).width(values_.get_width()).pad(10); layout_table.row(); layout_table.add(oui_bouton).width(values_.get_width()).pad(10); layout_table.row(); layout_table.add(non_bouton).width(values_.get_width()).pad(10); stage.addActor(layout_table); // activation de la zone // Gdx.input.setInputProcessor(stage); }
private void popButtons() { VerticalGroup listNoob = new VerticalGroup(); VerticalGroup listHardcore = new VerticalGroup(); VerticalGroup listOther = new VerticalGroup(); int y_init = Gdx.graphics.getHeight() - 100; int x_init = 70; int counter = 0; for (Constants.achiev_types type : Constants.achiev_types.values()) { AchievBtn btn = new AchievBtn(type.toString(), StylesManager.skin, type); btn.setBounds(x_init, y_init, 150, 35); y_init -= 40; list.add(btn); if (counter < 20) listNoob.addActor(btn); else if (counter < 40) listHardcore.addActor(btn); else listOther.addActor(btn); counter++; } // add back button final TextButton btn = new TextButton("Back", StylesManager.btnGray); btn.setBounds(Gdx.graphics.getWidth() / 2 - 75, 20, 150, 35); btn.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (x < btn.getWidth() && x > 0 && y < btn.getHeight() && y > 0) maingame.setScreen(maingame.questsScreen); } }); table.addActor(btn); ScrollPane sp1 = new ScrollPane(listNoob, StylesManager.skin); ScrollPane sp2 = new ScrollPane(listHardcore, StylesManager.skin); ScrollPane sp3 = new ScrollPane(listOther, StylesManager.skin); setSP(sp1); sp1.setPosition(73, 92); table.addActor(sp1); setSP(sp2); sp2.setPosition(72 + 212, 92); table.addActor(sp2); setSP(sp3); sp3.setPosition(71 + 2 * 212, 92); table.addActor(sp3); }
@Override public void show() { skin = Assets.getSkin(); ui = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); Gdx.input.setInputProcessor(ui); window = new Window("window", skin) { protected void drawBackground(SpriteBatch batch, float parentAlpha) {} }; window.setBounds(0, 0, ui.getWidth(), ui.getHeight()); window.setMovable(false); window.setColor(0, 0, 0, 0.8f); // window.debug(); window.defaults().spaceBottom(10); window.row().fill().expandX(); final CheckBox bloom = new CheckBox("Enable Bloom", skin); bloom.addListener( new InputListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); boolean b = bloom.isChecked(); game.setBloom(b); Util.setBloomOption(b); } }); bloom.setChecked(Util.getBloomOption()); window.add(bloom).fill(0f, 0f); final TextButton button = new TextButton("Done", skin); button.addListener( new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { game.startMainMenu(); return true; } }); window.add(button).fill(0f, 0f); ui.addActor(window); }
public StartScreen(SpaceSim game) { this.game = game; background = new Texture(Gdx.files.internal("bg5.jpg")); batch = new SpriteBatch(); stage = new Stage(); heading = "Space Simulator"; Gdx.input.setInputProcessor(stage); FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/Philosopher-Regular.ttf")); FreeTypeFontParameter parameter = new FreeTypeFontParameter(); buttonFont = generator.generateFont(parameter); buttonFont.setColor(1, 1, 1, 1); parameter.size = 72; headingFont = generator.generateFont(parameter); headingFont.setColor(1, 1, 1, 1); generator.dispose(); GlyphLayout layout = new GlyphLayout(headingFont, heading); headingX = (int) ((Gdx.graphics.getWidth() / 2) - (layout.width / 2)); headingY = 550; this.skin = new Skin(); this.skin.add("default", buttonFont); Pixmap pixmap = new Pixmap(200, 50, Pixmap.Format.RGB888); pixmap.setColor(Color.WHITE); pixmap.fill(); this.skin.add("background", new Texture(pixmap)); TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle(); textButtonStyle.up = this.skin.newDrawable("background", Color.GRAY); textButtonStyle.over = this.skin.newDrawable("background", Color.LIGHT_GRAY); textButtonStyle.font = this.skin.getFont("default"); this.skin.add("default", textButtonStyle); TextButton startButton = new TextButton("Start", this.skin); startButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { StartScreen.this.game.setScreen(new GalaxyMapScreen(StartScreen.this.game)); }; }); startButton.setPosition((Gdx.graphics.getWidth() / 2) - (startButton.getWidth() / 2), 300); this.stage.addActor(startButton); }
@Override public void resize(int width, int height) { if (stage == null) { stage = new Stage(width, height, true); } stage.clear(); Gdx.input.setInputProcessor(stage); TextButtonStyle butStyle = new TextButtonStyle(); butStyle.up = butSkin.getDrawable("butdown"); butStyle.down = butSkin.getDrawable("butup"); butStyle.font = font1; LabelStyle labelStyle = new LabelStyle(); labelStyle.font = font1; mainButton = new TextButton("Start Game!", butStyle); closeButton = new TextButton("Do nothing", butStyle); mainButton.setWidth(400); mainButton.setHeight(100); mainButton.setX(Gdx.graphics.getWidth() / 2 - mainButton.getWidth() / 2); mainButton.setY(Gdx.graphics.getHeight() / 2 - 2 * (mainButton.getHeight() / 1.2f)); closeButton.setWidth(400); closeButton.setHeight(100); closeButton.setX(Gdx.graphics.getWidth() / 2 - closeButton.getWidth() / 2); closeButton.setY( Gdx.graphics.getHeight() / 2 - 2 * (closeButton.getHeight() / 1.2f) - (closeButton.getHeight() + 5)); mainButton.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { System.out.println("down"); return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { golf.setCall(false); // disable splash screen after first use golf.setScreen(golf.hole, 1); } }); stage.addActor(mainButton); stage.addActor(closeButton); }
private void chkSource() { File f = new File(workPath + "/Android_GUI"); if (f.exists()) { btnRunLibGdx.setText("download and copy latest LibGdx (nightly)"); btnRunLibGdx.removeListener(selectTrunkListener); btnRunLibGdx.addListener(runListenerLibGdx); WorkPathFound = 1; writeMsg("Trunk folder found"); } else { btnRunLibGdx.setText("select 'Trunk' folder"); btnRunLibGdx.addListener(selectTrunkListener); WorkPathFound = 0; writeMsg("Trunk folder not found, please select"); } File fi = new File(workPath + "/LibgdxPacker"); if (fi.exists()) { ImageWorkPathFound = true; imageWorkPath = workPath; WorkPathFound++; } else ImageWorkPathFound = false; layout(); }
public void chatWindow() { chatSend.addListener( new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Label label = new Label(validate(chatInput.getText()), skin); label.setWrap(false); System.err.println(label.getText()); cont.add(label); // msg.add(validate(chatInput.getText())); } }); table.row(); table.add(chatInput); table.add(chatSend); table.row(); }
public MathsScreen(Game g) { game = g; stage = new Stage(); Gdx.input.setInputProcessor(stage); // get input from our stage num1 = MathUtils.random(10, 100); // libgdx easy random numbers :) num2 = MathUtils.random(10, 100); ans = num1 * num2; Skin skin = new Skin( Gdx.files.internal( "uiskin.json")); // set what the UI elements are going to look like, libgdx provides // file abstraction to make it easy to access files on any platform question = new Label( "What is the area of a rectangle of " + num1 + " by " + num2, skin); // Create a label element question.setPosition(100, 500); // Position it stage.addActor(question); // Add the lable to the stage answer = new TextField("", skin); // Create a textfield element answer.setPosition(300, 340); // Position it stage.addActor(answer); // Add it to the stage feedback = new Label("", skin); // Create a label element feedback.setPosition(300, 150); // Position it stage.addActor(feedback); // Add the lable to the stage check = new TextButton("Check your answer", skin); check.setPosition(300, 200); check.addListener( new ClickListener() // add the listener as an anonymous? method, inline method { // autocomplete the code below by typing clicked and then ctrl + space, modify to add our // own btClicked method public void clicked(InputEvent e, float x, float y) { btnClicked(); } }); stage.addActor(check); }
@Override public void show() { super.show(); Table table = new Table(mSkin); table.setFillParent(true); mStage.addActor(table); for (NetGame game : mGames) { final TextButton button = new TextButton(game.getId(), mSkin); table.add(button).size(350, 50).uniform().spaceBottom(10); table.row(); button.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); } }); } }
public void show() { stage = new Stage(); Gdx.input.setInputProcessor(stage); atlas = new TextureAtlas("ui/atlas.pack"); skin = new Skin(Gdx.files.internal("ui/menuSkin.json"), atlas); Texture chipBg = new Texture(Gdx.files.internal("img/chips.png")); stage.addActor(new Image(chipBg)); table = new Table(skin); table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); table.bottom().right(); backButton = new TextButton("BACK", skin); backButton.addListener( new ClickListener() { public void clicked(InputEvent event, float x, float y) { ((Game) Gdx.app.getApplicationListener()).setScreen(new PotatoMenu()); } }); backButton.pad(10); table.add(backButton).bottom().right(); ; stage.addActor(table); tweenManager = new TweenManager(); Tween.registerAccessor(Actor.class, new ActorAccessor()); tweenManager.update(Gdx.graphics.getDeltaTime()); stage.addAction(sequence(moveTo(0, stage.getHeight()), moveTo(0, 0, .5f))); }
public void setupGUI() { stage = new Stage(); skin = new Skin(Gdx.files.internal("uiskin.json")); table = new Table(skin); // table.setBounds(0, 0, Gdx.graphics.getWidth(), // Gdx.graphics.getHeight()); // table.setClip(true); Gdx.input.setInputProcessor(stage); // defaultStyle.over = skin.getDrawable("button.hover"); TextButton fullScreenButton = new TextButton("Toglle Full Screen", skin, "default"); fullScreenButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Config.fullscreen = !Config.fullscreen; } }); // fullScreenButton.setFillParent(true); TextButton saveSettingsButton = new TextButton("Save settings", skin, "default"); saveSettingsButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Config.reload(); show(); } }); Container<TextButton> saveSettingContainer = new Container<TextButton>(saveSettingsButton); saveSettingContainer.padTop(Value.percentHeight(.6f, table)); TextButton backButton = new TextButton("Go back", skin, "default"); backButton.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Screens.setScreen(Screens.MAIN_MENU_SCREEN); } }); VerticalGroup buttons1 = new VerticalGroup(); buttons1.fill(); buttons1.addActor(fullScreenButton); VerticalGroup buttons2 = new VerticalGroup(); buttons2.fill(); buttons2.addActor(saveSettingsButton); buttons2.addActor(backButton); // buttons.setPosition(Gdx.graphics.getWidth()/4, // Gdx.graphics.getHeight()/5); VerticalGroup resolution = new VerticalGroup(); ButtonGroup<TextButton> buttonGroup = new ButtonGroup<>(); buttonGroup.setMaxCheckCount(1); resolution.fill(); transparentSkin = new Skin(new TextureAtlas("select.pack")); TextButtonStyle transparent = new TextButtonStyle(); transparent.checked = transparentSkin.getDrawable("checked"); transparent.up = transparentSkin.getDrawable("up"); transparent.font = FontUtil.generateFont(Color.WHITE, 20); addResolutions(buttonGroup, transparent); for (TextButton b : buttonGroup.getButtons()) { resolution.addActor(b); } resolution.right(); ScrollPane resolScroll = new ScrollPane(resolution); resolScroll.setHeight(700); Label fullScreenLabel = new Label("", skin); fullScreenLabel.addAction( Actions.forever( new Action() { @Override public boolean act(float delta) { if (Config.fullscreen) { fullScreenLabel.setColor(Color.GREEN); fullScreenLabel.setText("on"); } else { fullScreenLabel.setColor(Color.RED); fullScreenLabel.setText("off"); } return true; } })); table.setFillParent(true); Table left = new Table(); left.add(buttons1).spaceBottom(Value.percentHeight(.6f, table)); left.add(fullScreenLabel).top(); left.row(); // left.row(); left.add(buttons2); // table.add(buttons1.left()).left(); table.add(left).left().padLeft(Value.percentWidth(0.1f, table)).expandX(); // table.add(fullScreenLabel).top().spaceRight(Value.percentWidth(.5f, // table)); table.add(resolScroll).right().padRight(Value.percentWidth(0.1f, table)); // table.row(); // table.add(buttons2).bottom().left(); // table.center(); stage.addActor(table); if (Config.debug) table.setDebug(true); }