public void create() { stage = new Stage(); Gdx.input.setInputProcessor(stage); root = new Table(); root.setFillParent(true); stage.addActor(root); skin = new Skin(Gdx.files.internal("data/uiskin.json")); Table labels = new Table(); root.add(new ScrollPane(labels, skin)).expand().fill(); root.row(); root.add(drawnLabel = new Label("", skin)); for (int i = 0; i < count; i++) { labels.add( new Label("Label: " + i, skin) { public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); drawn++; } }); labels.row(); } }
private Table makeGameFileRow(final FileHandle gameSaveFile) { GameSave towerData; try { towerData = GameSaveFactory.readMetadata(gameSaveFile.read()); } catch (Exception e) { Gdx.app.log(TAG, "Failed to parse file.", e); return null; } FileHandle imageFile = Gdx.files.external(TowerConsts.GAME_SAVE_DIRECTORY + gameSaveFile.name() + ".png"); Actor imageActor = null; if (imageFile.exists()) { try { imageActor = new Image(loadTowerImage(imageFile), Scaling.fit, Align.top); } catch (Exception ignored) { imageActor = null; } } if (imageActor == null) { imageActor = FontManager.Default.makeLabel("No image."); } Table fileRow = new Table(); fileRow.defaults().fillX().pad(Display.devicePixel(10)).space(Display.devicePixel(10)); fileRow.row(); fileRow.add(imageActor).width(Display.devicePixel(64)).height(Display.devicePixel(64)).center(); fileRow.add(makeGameFileInfoBox(fileRow, gameSaveFile, towerData)).expandX().top(); fileRow.row().fillX(); fileRow.add(new HorizontalRule(Color.DARK_GRAY, 2)).colspan(2); return fileRow; }
@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))); }
@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); }
@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 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); }
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 IntroScreen(final DirectedGame game) { super(game); rootTable = new Table(); rootTable.setFillParent(true); final Actor logo = new Image(Assets.assetsManager.get(Assets.HEADMADE_LOGO, Texture.class)); // logo.setOrigin(logo.getWidth() / 2, logo.getHeight() / 2); // logo.scaleBy(2f); logo.setColor(Color.BLACK); rootTable.add(logo).center().expand(); rootTable.row(); // rootTable.setDebug(true); this.stage.addActor(rootTable); stage.addListener( new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { if (keycode == Keys.ESCAPE) { Gdx.app.exit(); return true; } return super.keyDown(event, keycode); } }); Assets.instance.loadAll(); }
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); }
public FinalDialogueScreen(final ButtonGame game) { this.game = game; stage = new Stage(new ScreenViewport()); dialogueLabel = new Label("", Resources.Skin()); dialogueLabel.setWrap(true); dialogueLabel.setColor(Color.CYAN); leftPerson = new Image(new Texture(Gdx.files.internal("graphics/CaptainCalamari.png"))); leftPerson.setVisible(false); rightPerson = new Image(new Texture(Gdx.files.internal("graphics/JimmyTwoButton.png"))); leftPerson.setScaling(Scaling.none); rightPerson.setScaling(Scaling.none); stage.addListener( new InputListener() { @Override public boolean touchDown( InputEvent event, float screenX, float screenY, int pointer, int button) { if (count < maxCount) { count = advanceDialogue(count); } else { game.startLevel(Level.get(game, 10)); } return true; } }); Table table = new Table(); table.setFillParent(true); table.align(Align.top); table.add().height(50).colspan(3).center(); table.row(); table.add(leftPerson); table.add(); // .width(20); table.add(rightPerson); table.row(); table.add().colspan(3).height(50); table.row(); table.add(dialogueLabel).width(600).colspan(3).center(); if (Resources.DEBUG) { table.setDebug(true); } stage.addActor(table); }
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); }
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(); }
private void arrangingTheScreen() { container .add(imageTitle) .width(Constant.WIDTH_SCREEN) .height((Constant.CONSTANT_HEIGHT_TITLE)) .padBottom(CONSTANT_PAD_BOTTOM); container.row(); containerFirstRow .add(userField) .width(Constant.CONSTANT_WIDTH_FIELD_AND_BUTTON) .height(Constant.CONSTANT_HEIGHT_FIELD_AND_BUTTON) .padBottom(CONSTANT_PAD_BOTTOM) .padRight(Constant.CONSTANT_PAD_LEFT_AND_RIGHT); containerFirstRow .add(passwordField) .width(Constant.CONSTANT_WIDTH_FIELD_AND_BUTTON) .height(Constant.CONSTANT_HEIGHT_FIELD_AND_BUTTON) .padBottom(CONSTANT_PAD_BOTTOM) .padLeft(Constant.CONSTANT_PAD_LEFT_AND_RIGHT); container.add(containerFirstRow); container.row(); containerSecondRow .add(emailField) .width(Constant.CONSTANT_WIDTH_FIELD_AND_BUTTON) .height(Constant.CONSTANT_HEIGHT_FIELD_AND_BUTTON) .padBottom(CONSTANT_PAD_BOTTOM) .padRight(Constant.CONSTANT_PAD_LEFT_AND_RIGHT); containerSecondRow .add(passwordCheckField) .width(Constant.CONSTANT_WIDTH_FIELD_AND_BUTTON) .height(Constant.CONSTANT_HEIGHT_FIELD_AND_BUTTON) .padBottom(CONSTANT_PAD_BOTTOM) .padLeft(Constant.CONSTANT_PAD_LEFT_AND_RIGHT); container.add(containerSecondRow); container.row(); container.add(registerButton); stage.addActor(container); }
private void createTable() { // TODO: add actual high-scores table = new Table(game.getSkin()); table.defaults().width(150).height(35).pad(1); table.setFillParent(true); table.add(game.getLanguage().getString("menu.high.scores")).colspan(2).center().height(50); table.row(); table.add("Name#1"); table.add("10000"); table.row(); table.add("Name#2"); table.add("10000"); table.row(); table.add("Name#3"); table.add("10000"); table.row(); table.add("Name#4"); table.add("10000"); table.row(); table.add("Name#5"); table.add("10000"); table.row(); table.add("Name#6"); table.add("10000"); table.row(); table.add("Name#7"); table.add("10000"); table.row(); table.add("Name#8"); table.add("10000"); table.row(); table.add("Name#9"); table.add("10000"); table.row(); table.add("Name#10"); table.add("10000"); }
public void addProperty(String name, String value, Types type) { table.row(); table.add(new Label(name, skin)).expandX().left(); if (type == Types.BOOLEAN) { SelectBox<String> sb = new SelectBox<String>(skin); sb.setItems(BOOLEAN_VALUES); if (value != null) sb.setSelected(value); sb.setName(name); table.add(sb).expandX().left(); sb.addListener( new ChangeListener() { @SuppressWarnings("unchecked") @Override public void changed(ChangeEvent event, Actor actor) { updateModel(actor.getName(), ((SelectBox<String>) actor).getSelected()); } }); } else { TextField tf = new TextField(value == null ? "" : value, skin); tf.setName(name); table.add(tf).expandX().left(); if (type == Types.INTEGER) tf.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter()); tf.setTextFieldListener( new TextFieldListener() { @Override public void keyTyped(TextField actor, char c) { updateModel(actor.getName(), ((TextField) actor).getText()); } }); // tf.addListener(new FocusListener() { // // @Override // public void keyboardFocusChanged (FocusEvent event, Actor actor, boolean focused) { // if(!focused) // updateModel(actor.getName(), ((TextField)actor).getText()); // } // }); } }
public Hud(SpriteBatch sb) { // define our tracking variables worldTimer = 300; timeCount = 0; score = 0; // setup the HUD viewport using a new camera seperate from our gamecam // define our stage using that viewport and our games spritebatch viewport = new FitViewport(MarioBros.V_WIDTH, MarioBros.V_HEIGHT, new OrthographicCamera()); stage = new Stage(viewport, sb); // define a table used to organize our hud's labels Table table = new Table(); // Top-Align table table.top(); // make the table fill the entire stage table.setFillParent(true); // define our labels using the String, and a Label style consisting of a font and color countdownLabel = new Label( String.format("%03d", worldTimer), new Label.LabelStyle(new BitmapFont(), Color.WHITE)); scoreLabel = new Label( String.format("%06d", score), new Label.LabelStyle(new BitmapFont(), Color.WHITE)); timeLabel = new Label("TIME", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); levelLabel = new Label("1-1", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); worldLabel = new Label("WORLD", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); marioLabel = new Label("MARIO", new Label.LabelStyle(new BitmapFont(), Color.WHITE)); // add our labels to our table, padding the top, and giving them all equal width with expandX table.add(marioLabel).expandX().padTop(10); table.add(worldLabel).expandX().padTop(10); table.add(timeLabel).expandX().padTop(10); // add a second row to our table table.row(); table.add(scoreLabel).expandX(); table.add(levelLabel).expandX(); table.add(countdownLabel).expandX(); // add our table to the stage stage.addActor(table); }
public void scoreTop() { Label[][] label = new Label[10][2]; String[] score = new String[10]; Window window = new Dialog("Server doesnt respond", skin); // window.setSize(500, 500); // score = db.getTopScore(); try { for (int i = 0; i < 10; i++) { if (score[i].length() > 4) { label[i][0] = new Label(score[i].substring(0, 4) + " ", skin); label[i][1] = new Label(score[i].substring(4, score[i].length()), skin); } else label[i][1] = new Label("Empty", skin); table.add(label[i][0]); table.add(label[i][1]); table.row(); } } catch (Exception e) { e.printStackTrace(); } Button accept = new TextButton("Accept", skin); window.setPosition(Gdx.graphics.getWidth() / 2 - 150, Gdx.graphics.getHeight() / 2 - 50); window.debug(); window.setMovable(false); // window.setTitle("Error communication"); window.add(table).fill(); // window.setSize(300,400); window.addListener( new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { stage.clear(); } }); stage.addActor(window); }
@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 AlertDialog(String titleText, Style style) { this.style = style; // debug(); setFillParent(true); setVisible(false); window = new Table(); // window.debug(); window.setBackground(style.background); window.pad(style.vPad, style.hPad, style.vPad, style.hPad); // title title = new Label(titleText, style.title); window.add(title); window.row(); add(window); row(); actionsGroup = new DialogActionsGroup(style.actionsGroup); add(actionsGroup).center(); }
private void buttonInit() { Button newGameButton; Button.ButtonStyle buttonStyle; buttonStyle = new Button.ButtonStyle(); buttonStyle.up = GameResource.getInstance().getDrawable("new_button"); buttonStyle.down = GameResource.getInstance().getDrawable("new_button_pressed"); newGameButton = new Button(buttonStyle); newGameButton.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) { music.stop(); currentGame.setScreen(currentGame.gameScreen); // currentGame.setScreen(currentGame.loadingScreen); } }); Button loadGameButton; buttonStyle = new Button.ButtonStyle(); buttonStyle.up = GameResource.getInstance().getDrawable("load_button"); buttonStyle.down = GameResource.getInstance().getDrawable("load_button_pressed"); loadGameButton = new Button(buttonStyle); loadGameButton.addListener( new InputListener() { public void touchUp(InputEvent event, float x, float y, int pointer, int button) { // load logic } }); table.add(newGameButton).padRight(80).padBottom(20).width(150).height(70); table.row(); table.add(loadGameButton).padRight(80).width(150).height(70); }
public void initTable() { table = new Table(); table.setWidth(getWidth()); table.setFillParent(true); table.center(); table.debug(); titleLabel = new TransparentBackgroundLabel(this.game, "", skin, "default_label"); // Make it bigger titleLabel.setFontScale(1.0f); titleLabel.setWrap(true); titleLabel.setAlignment(Align.center); definitionLabel = new TransparentBackgroundLabel(this.game, "", skin, "default_label"); definitionLabel.setFontScale(0.6f); definitionLabel.setWrap(true); definitionLabel.setAlignment(Align.center); table .add(titleLabel) .center() .expand() .width(getWidth() * 0.9f) .padTop(70f) .height(getHeight() * 0.10f); table.row(); table .add(definitionLabel) .center() .top() .expand() .width(getWidth() * 0.9f) .maxHeight(getHeight() * 0.7f) .spaceBottom(150f); this.addActor(table); }
public TasktableActor(DragAndDrop dragAndDrop, Skin skin) { super("Aktivitäten", skin); Table table = new Table(); setTable(skin, table, "scrollPaneWindowTasksCalendar"); for (Slot slot : tasktable.getSlots()) { SlotActor slotActor = new SlotActor(skin, slot); dragAndDrop.addSource(new SlotSource(slotActor)); dragAndDrop.addTarget(new SlotTarget(slotActor)); dragAndDrop.setDragActorPosition( -CalendarScreen.WIDTHTASK / 2, CalendarScreen.HEIGHTTASK / 2); table.add(slotActor).width(CalendarScreen.WIDTHTASK).height(CalendarScreen.HEIGHTTASK); table.row().padTop(5); } getScrollTable().setFlickScroll(false); getScrollTable().setFadeScrollBars(false); setBounds(AppMain.WIDTH - 212, 70, 210, AppMain.HEIGHT - 72); setMovable(false); pad(8); }
@Override public void show() { // BackButton Handeling Drawable menuDrawable = new TextureRegionDrawable( new TextureRegion(new Texture(Gdx.files.internal("images/backgroundlevel.png")))); backGImage = new Image(menuDrawable, Scaling.stretch); backGImage.setFillParent(true); stage.addActor(backGImage); skin = new Skin(Gdx.files.internal("ui/JsonFiles/uiskin.json")); skin.add( "top", new TextureRegionDrawable( new TextureRegion( new Texture(Gdx.files.internal("images/levelscreen.png")), 153, 88, 150, 150)), Drawable.class); skin.add( "lockedlevel", new TextureRegionDrawable( new TextureRegion( new Texture(Gdx.files.internal("images/levelscreen.png")), 1, 88, 150, 150)), Drawable.class); skin.add( "star-filled", new TextureRegionDrawable( new TextureRegion( new Texture(Gdx.files.internal("images/levelscreen.png")), 1, 1, 90, 85)), Drawable.class); skin.add( "star-unfilled", new TextureRegionDrawable( new TextureRegion( new Texture(Gdx.files.internal("images/levelscreen.png")), 93, 1, 90, 85)), Drawable.class); // skin.add("star-filled", skin.newDrawable("white", Color.YELLOW), // Drawable.class); // skin.add("star-unfilled", skin.newDrawable("white", Color.GRAY), // Drawable.class); Gdx.input.setInputProcessor(stage); container = new Table(); stage.addActor(container); container.setFillParent(true); PagedScrollPane scroll = new PagedScrollPane(); scroll.setFlingTime(0.4f); scroll.setPageSpacing(80); int c = 1; for (int l = 0; l < 2; l++) { Table levels = new Table().pad(0); levels.defaults().pad(0, 20, 0, 15); for (int y = 0; y < 2; y++) { levels.row(); for (int x = 0; x < 3; x++) { levels.add(getLevelButton(c++)).fill().expand().size(63, 88); } } scroll.addPage(levels); } container.add(scroll).expand().fill(); // backGImage.addAction(parallel(moveTo(250, 250, 2, bounceOut), // color(Color.RED, 6), delay(0.5f), rotateTo(180, 5, swing))); backGImage.addAction( repeat(1, (sequence(scaleTo(2, 2, 0.8f), scaleTo(1, 1, 0.8f), delay(1.9f))))); InputProcessor backProcessor = new InputAdapter() { @Override public boolean keyDown(int keycode) { if ((keycode == Keys.ESCAPE) || (keycode == Keys.BACK)) game.setScreen(game.getMenuScreen()); return false; } }; InputMultiplexer multiplexer = new InputMultiplexer(stage, backProcessor); Gdx.input.setInputProcessor(multiplexer); Gdx.input.setCatchBackKey(true); }
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); }
public HotbarInventoryView( Stage stage, Skin skin, Inventory hotbarInventory, Inventory inventory, DragAndDrop dragAndDrop, OreClient client) { m_skin = skin; m_inventory = inventory; m_client = client; m_stage = stage; m_hotbarInventory = hotbarInventory; // attach to the inventory model m_hotbarInventory.addListener(this); container = new Table(m_skin); container.setFillParent(true); container.top().left().setSize(800, 100); container.padLeft(10).padTop(10); container.defaults().space(4); stage.addActor(container); Image dragImage = new Image(); dragImage.setSize(32, 32); for (byte i = 0; i < Inventory.maxHotbarSlots; ++i) { Image slotImage = new Image(); SlotElement element = new SlotElement(); m_slots[i] = element; element.itemImage = slotImage; Table slotTable = new Table(m_skin); element.table = slotTable; slotTable.setTouchable(Touchable.enabled); slotTable.addListener(new SlotClickListener(this, i)); slotTable.addListener(new SlotInputListener(this, i)); slotTable.add(slotImage); slotTable.background("default-pane"); slotTable.row(); Label itemCount = new Label(null, m_skin); slotTable.add(itemCount).bottom().fill(); element.itemCountLabel = itemCount; // container.add(slotTable).size(50, 50); container.add(slotTable).fill().size(50, 50); setHotbarSlotVisible(i, false); dragAndDrop.addSource(new HotbarDragSource(slotTable, i, dragImage, this)); dragAndDrop.addTarget(new HotbarDragTarget(slotTable, i, this)); } m_tooltip = new Label(null, m_skin); stage.addActor(m_tooltip); }
private void initMilitaryTopPane() { Table contentTable = new Table(); int itemPerRow = (int) (militaryTablePos.width / (militaryTablePortraitSize.x + militaryTableCaptionSize.x)); int index = 0; for (Military m : parent.getCurrentArchitecture().getMilitariesWithLeader()) { Table item = new Table(); Person leader = m.getLeader(); ImageWidget<Military> portrait; if (leader != null) { portrait = new ImageWidget<>( parent.getScreen().getSmallPortrait(leader.getPortraitId()), militaryTablePortraitColor); } else { portrait = new ImageWidget<>(null, militaryTablePortraitColor); } portrait.setExtra(m); item.add(portrait).width(militaryTablePortraitSize.x).height(militaryTablePortraitSize.y); Table detail = new Table(); TextWidget<Military> caption = new TextWidget<>(militaryTableCaptionTemplate); caption.setExtra(m); caption.setText(m.getName()); detail .add(caption) .width(militaryTableCaptionSize.x) .height(militaryTableCaptionSize.y) .row(); TextWidget<Military> quantity = new TextWidget<>(militaryTableDetailTemplate); quantity.setExtra(m); quantity.setText( GlobalStrings.getString(GlobalStrings.Keys.MILITARY_QUANTITY_SHORT) + m.getQuantity()); detail.add(quantity).width(militaryTableDetailSize.x).height(militaryTableDetailSize.y).row(); TextWidget<Military> morale = new TextWidget<>(militaryTableDetailTemplate); morale.setExtra(m); morale.setText( GlobalStrings.getString(GlobalStrings.Keys.MILITARY_MORALE_SHORT) + m.getMorale()); detail.add(morale).width(militaryTableDetailSize.x).height(militaryTableDetailSize.y).row(); TextWidget<Military> combativity = new TextWidget<>(militaryTableDetailTemplate); combativity.setExtra(m); combativity.setText( GlobalStrings.getString(GlobalStrings.Keys.MILITARY_COMBATIVITY_SHORT) + m.getCombativity()); detail .add(combativity) .width(militaryTableDetailSize.x) .height(militaryTableDetailSize.y) .row(); detail.top(); item.add(detail); item.addListener( new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { currentMilitary = m; currentMilitaryPos = new Rectangle( item.getX() + militaryTablePos.getX(), item.getY() + militaryTablePos.getY(), item.getWidth(), item.getHeight()); if (m.isCampaignable()) { parent .getScreen() .getMapLayer() .startSelectingLocation( parent.getCurrentArchitecture().getCampaignablePositions(), p -> { m.startCampaign(p); invalidateListPanes(); }); } return true; } }); contentTable.add(item); index++; if (index % itemPerRow == 0) { contentTable.row(); } } contentTable.top().left(); ScrollPane data = new ScrollPane(contentTable); militaryTopPane = WidgetUtility.setupScrollpane( militaryTablePos.getX(), militaryTablePos.getY(), militaryTablePos.getWidth(), militaryTablePos.getHeight(), data, parent.getScrollbar()); parent.addActor(militaryTopPane); }
private void initMilitaryBottomPane() { Table contentTable = new Table(); for (Military m : parent.getCurrentArchitecture().getMilitariesWithoutLeader()) { List<TextWidget<Military>> rowWidgets = new ArrayList<>(); TextWidget<Military> name = new TextWidget<>(militaryListTextTemplate); name.setExtra(m); name.setText(m.getName()); contentTable.add(name).width(listNameWidth).height(listRowHeight); rowWidgets.add(name); TextWidget<Military> quantity = new TextWidget<>(militaryListTextTemplate); quantity.setExtra(m); quantity.setText(String.valueOf(m.getQuantity())); contentTable.add(quantity).width(listQuantityWidth).height(listRowHeight); rowWidgets.add(quantity); TextWidget<Military> recruit = new TextWidget<>(militaryListTextTemplate); recruit.setExtra(m); if (m.isFullyRecruited()) { recruit.setText(GlobalStrings.getString(GlobalStrings.Keys.TICK)); } else if (m.isBeingRecruited()) { recruit.setText(GlobalStrings.getString(GlobalStrings.Keys.UP_ARROW)); } else { recruit.setText(""); } contentTable.add(recruit).width(listRecruitWidth).height(listRowHeight).center(); rowWidgets.add(recruit); TextWidget<Military> train = new TextWidget<>(militaryListTextTemplate); train.setExtra(m); if (m.isFullyTrained()) { train.setText(GlobalStrings.getString(GlobalStrings.Keys.TICK)); } else if (m.isBeingTrained()) { train.setText(GlobalStrings.getString(GlobalStrings.Keys.UP_ARROW)); } else { train.setText(""); } contentTable.add(train).width(listTrainWidth).height(listRowHeight).center(); rowWidgets.add(train); rowWidgets.forEach( x -> x.addListener( new InputListener() { @Override public boolean touchDown( InputEvent event, float x, float y, int pointer, int button) { currentMilitary = m; currentMilitaryPos = new Rectangle( name.getX() + militaryListPos.getX(), name.getY() + militaryListPos.getY(), militaryListPos.getWidth(), name.getHeight()); return true; } })); showingTextWidgets.addAll(rowWidgets); contentTable.row().height(listRowHeight); } contentTable.top().left(); ScrollPane data = new ScrollPane(contentTable); militaryBottomPane = WidgetUtility.setupScrollpane( militaryListPos.getX(), militaryListPos.getY(), militaryListPos.getWidth(), militaryListPos.getHeight(), data, parent.getScrollbar()); parent.addActor(militaryBottomPane); }
@Override public void create() { skin = new Skin(Gdx.files.internal("data/uiskin.json")); texture1 = new Texture(Gdx.files.internal("data/badlogicsmall.jpg")); texture2 = new Texture(Gdx.files.internal("data/badlogic.jpg")); TextureRegion image = new TextureRegion(texture1); TextureRegion imageFlipped = new TextureRegion(image); imageFlipped.flip(true, true); TextureRegion image2 = new TextureRegion(texture2); // stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false, new // PolygonSpriteBatch()); stage = new Stage(); // stage.setViewport(new ExtendViewport(800, 480)); Gdx.input.setInputProcessor(stage); // Group.debug = true; ImageButtonStyle style = new ImageButtonStyle(skin.get(ButtonStyle.class)); style.imageUp = new TextureRegionDrawable(image); style.imageDown = new TextureRegionDrawable(imageFlipped); ImageButton iconButton = new ImageButton(style); Button buttonMulti = new TextButton("Multi\nLine\nToggle", skin, "toggle"); Button imgButton = new Button(new Image(image), skin); Button imgToggleButton = new Button(new Image(image), skin, "toggle"); Label myLabel = new Label("this is some text.", skin); myLabel.setWrap(true); Table t = new Table(); t.row(); t.add(myLabel); t.layout(); CheckBox checkBox = new CheckBox("Check me", skin); final Slider slider = new Slider(0, 10, 1, false, skin); TextField textfield = new TextField("", skin); textfield.setMessageText("Click here!"); SelectBox dropdown = new SelectBox(skin); dropdown.setItems( "Android1", "Windows1", "Linux1", "OSX1", "Android2", "Windows2", "Linux2", "OSX2", "Android3", "Windows3", "Linux3", "OSX3", "Android4", "Windows4", "Linux4", "OSX4", "Android5", "Windows5", "Linux5", "OSX5", "Android6", "Windows6", "Linux6", "OSX6", "Android7", "Windows7", "Linux7", "OSX7"); dropdown.setSelected("Linux6"); Image imageActor = new Image(image2); ScrollPane scrollPane = new ScrollPane(imageActor); List list = new List(skin); list.setItems(listEntries); list.getSelection().setMultiple(true); list.getSelection().setRequired(false); // list.getSelection().setToggle(true); ScrollPane scrollPane2 = new ScrollPane(list, skin); scrollPane2.setFlickScroll(false); SplitPane splitPane = new SplitPane(scrollPane, scrollPane2, false, skin, "default-horizontal"); fpsLabel = new Label("fps:", skin); // configures an example of a TextField in password mode. final Label passwordLabel = new Label("Textfield in password mode: ", skin); final TextField passwordTextField = new TextField("", skin); passwordTextField.setMessageText("password"); passwordTextField.setPasswordCharacter('*'); passwordTextField.setPasswordMode(true); // window.debug(); Window window = new Window("Dialog", skin); window.getButtonTable().add(new TextButton("X", skin)).height(window.getPadTop()); window.setPosition(0, 0); window.defaults().spaceBottom(10); window.row().fill().expandX(); window.add(iconButton); window.add(buttonMulti); window.add(imgButton); window.add(imgToggleButton); window.row(); window.add(checkBox); window.add(slider).minWidth(100).fillX().colspan(3); window.row(); window.add(dropdown); window.add(textfield).minWidth(100).expandX().fillX().colspan(3); window.row(); window.add(splitPane).fill().expand().colspan(4).maxHeight(200); window.row(); window.add(passwordLabel).colspan(2); window.add(passwordTextField).minWidth(100).expandX().fillX().colspan(2); window.row(); window.add(fpsLabel).colspan(4); window.pack(); // stage.addActor(new Button("Behind Window", skin)); stage.addActor(window); textfield.setTextFieldListener( new TextFieldListener() { public void keyTyped(TextField textField, char key) { if (key == '\n') textField.getOnscreenKeyboard().show(false); } }); slider.addListener( new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { Gdx.app.log("UITest", "slider: " + slider.getValue()); } }); iconButton.addListener( new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { new Dialog("Some Dialog", skin, "dialog") { protected void result(Object object) { System.out.println("Chosen: " + object); } }.text("Are you enjoying this demo?") .button("Yes", true) .button("No", false) .key(Keys.ENTER, true) .key(Keys.ESCAPE, false) .show(stage); } }); }
private void fillTable() { StyleHelper helper = StyleHelper.getInstance(); Table leftTable = new Table(); ImageButton menu = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-menu")); ImageButton hint = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-hint")); zoomIn = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-plus")); zoomOut = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-minus")); Button goal = new ImageButton( helper.getImageButtonStyleRound("widgets/icon-goal")); ImageButton startSimulation = new ImageButton(StyleHelper.getInstance() .getImageButtonStyleRound("widgets/icon-next")); startSimulation.addListener(new StartSimulationListener()); // add listeners menu.addListener(new MenuClickListener()); hint.addListener(new HintClickListener()); leftTable.pad(30); leftTable.defaults().space(30); leftTable.add(menu).size(100).top().left(); leftTable.row(); // TODO only activated after some time leftTable.add(hint).expand().size(100).top().left(); leftTable.row(); leftTable.add(goal).expand().size(100).top().left(); leftTable.row(); leftTable.add(zoomIn).size(70).left(); leftTable.row(); leftTable.add(zoomOut).size(70).left(); final ColorController colorController = gameController .getColorController(); final ActorLayoutConfiguration config = new ActorLayoutConfiguration(); config.setColorController(colorController); boardActor = new BoardActor(gameController.getShownBoard(), config); boardActor.setColorBlindEnabled(game.getSettingController() .getCurrentSetting().isColorblindEnabled()); game.getSettingController().addSettingChangeListener(boardActor); // used to make resetting the board via game controller possible gameController.registerPlacementBoardEventListener(boardActor .getBoardEventListener()); final Table boardTable = new Table(); boardTable.add(boardActor).fill().expand(); final Table controlTable = new Table(); controlTable.add(leftTable).expand().fill(); if (gameController.getLevel().getShowObjectBar()) { boardActor.enableLayoutEditing( gameController.getPlacmentBoardEventListener(), true); ObjectBar objectBar = boardActor.getObjectBar(); objectBar.add(startSimulation).size(200); controlTable.add(objectBar).padLeft(30); } else { boardActor.enableLayoutEditing( gameController.getPlacmentBoardEventListener(), false); controlTable.add(startSimulation).bottom().right().size(200) .pad(30); } table.stack(boardTable, controlTable).fill().expand(); onSettingChange(game.getSettingController().getCurrentSetting()); BoardActor goalBoard = new BoardActor(gameController.getLevel() .getGoalBoard(), config); goalBoard.setZoomAndPanEnabled(false); goalBoard.setColorBlindEnabled(game.getSettingController() .getCurrentSetting().isColorblindEnabled()); game.getSettingController().addSettingChangeListener(goalBoard); Table goalTable = new Table(); goalTable.add(goalBoard).size(getViewportHeight()); goal.addListener(new GoalClickListener()); goalDialog.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { goalDialog.hide(); } }); goalDialog.add(goalTable).width(getViewportWidth() - 250) .height(getViewportHeight()); }