List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Label setText
public void setText(CharSequence newText)
From source file:at.hid.tabletopsimulator.screens.About.java
License:Apache License
@Override public void show() { TableTopSimulator.debug(this.getClass().toString(), "creating About screen"); stage = new Stage(new ExtendViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight())); Gdx.input.setInputProcessor(stage);/*from ww w. j av a 2 s .co m*/ // creating skin TableTopSimulator.debug(this.getClass().toString(), "creating skin"); skin = TableTopSimulator.assets.get("ui/gui.json", Skin.class); table = new Table(skin); // table.setFillParent(true); // table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // creating heading TableTopSimulator.debug(this.getClass().toString(), "creating heading"); Label lblHeading = new Label(TableTopSimulator.getLangBundle().format("About.lblHeading.text"), skin); final Label lblContent = new Label("http://libgdx.badlogicgames.com/\r\n" + "\r\n" + "libGDX is licensed under the Apache 2 License,\r\n" + "meaning you can use it free of charge, without strings attached in commercial and non-commercial projects.\r\n" + "We love to get (non-mandatory) credit in case you release a game or app using libgdx!", skin, "content"); // creating list final List<String> listAbout = new List<String>(skin, "content"); ArrayList<String> newItems = new ArrayList<String>(); newItems.add("libgdx"); newItems.add("libgdx-utils"); newItems.add("flare gameart"); String[] data = new String[newItems.size()]; listAbout.setItems(newItems.toArray(data)); listAbout.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (listAbout.getSelected().equals("libgdx")) { lblContent.clear(); lblContent.setText("http://libgdx.badlogicgames.com/\r\n" + "\r\n" + "libGDX is licensed under the Apache 2 License,\r\n" + "meaning you can use it free of charge, without strings attached in commercial and non-commercial projects.\r\n" + "We love to get (non-mandatory) credit in case you release a game or app using libgdx!"); } else if (listAbout.getSelected().equals("libgdx-utils")) { lblContent.clear(); lblContent.setText("https://bitbucket.org/dermetfan/libgdx-utils/wiki/Home\r\n" + "\r\n" + "/* Copyright (c) 2014 PixelScientists\r\n" + "*\r\n" + "* The MIT License (MIT)\r\n" + "*\r\n" + "* Permission is hereby granted, free of charge, to any person obtaining a copy of\r\n" + "* this software and associated documentation files (the \"Software\"), to deal in\r\n" + "* the Software without restriction, including without limitation the rights to\r\n" + "* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r\n" + "* the Software, and to permit persons to whom the Software is furnished to do so,\r\n" + "* subject to the following conditions:\r\n" + "*\r\n" + "* The above copyright notice and this permission notice shall be included in all\r\n" + "* copies or substantial portions of the Software.\r\n" + "*\r\n" + "* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n" + "* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r\n" + "* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r\n" + "* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r\n" + "* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r\n" + "* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n" + "*/"); } else if (listAbout.getSelected().equals("flare gameart")) { lblContent.clear(); lblContent.setText("https://github.com/clintbellanger/flare-game\r\n" + "\r\n" + "Flare (the game) is Copyright 2010-2013 Clint Bellanger. Contributors retain copyrights to their original contributions.\r\n" + "\r\n" + "The Flare Engine is released under GPL version 3 or later.\r\n" + "\r\n" + "All of Flare's art and data files are released under CC-BY-SA 3.0. Later versions are permitted.\r\n" + "\r\n" + "The Liberation Sans fonts version 2 are released under the SIL Open Font License, Version 1.1.\r\n" + "\r\n" + "The GNU Unifont font is released under GPL v2, with the exception that embedding the font in a document does not in itself bind that document to the terms of the GPL."); } } }); // creating buttons TableTopSimulator.debug(this.getClass().toString(), "creating buttons"); TextButton btnBack = new TextButton(TableTopSimulator.getLangBundle().format("About.btnBack.text"), skin); btnBack.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { TableTopSimulator.debug(this.getClass().toString(), "switching to Options screen"); ((Game) Gdx.app.getApplicationListener()).setScreen(new Options()); dispose(); } }); btnBack.pad(10); ScrollPane spAboutList = new ScrollPane(null, skin); ScrollPane spAboutContent = new ScrollPane(null, skin); SplitPane splitAbout = new SplitPane(spAboutList, spAboutContent, false, skin); splitAbout.setSplitAmount(0.2f); spAboutList.setWidget(listAbout); spAboutContent.setWidget(lblContent); // building ui TableTopSimulator.debug(this.getClass().toString(), "building ui"); table.add(lblHeading).spaceBottom(100).row(); table.add(splitAbout).spaceBottom(15).width(1200).row(); table.add(btnBack).spaceBottom(15).row(); if (TableTopSimulator.DEBUG) { table.debug(); // draw debug lines splitAbout.debug(); // draw debug lines } stage.addActor(table); }
From source file:ca.hiphiparray.amazingmaze.HighScoresScreen.java
License:Open Source License
@Override public void show() { Gdx.input.setInputProcessor(stage);/*from w w w . j a v a 2 s .c o m*/ game.music.setSong(Song.MENU); stage.clear(); table = new Table(); table.setFillParent(true); table.top(); stage.addActor(table); Label header = new Label("High Scores", game.assets.skin, Assets.SANS_HEADER_STYLE); table.add(header).pad(Gdx.graphics.getHeight() / 20).colspan(3); table.row(); HighScore[] scores = game.save.getHighScores(); for (int i = 0; i < scores.length; i++) { Label position = new Label(Integer.toString(i + 1) + ". ", game.assets.skin); Label name = new Label(scores[i].getName(), game.assets.skin); Label score = new Label(Integer.toString(scores[i].getScore()), game.assets.skin); if (scores[i].getScore() < 0) { score.setText(""); } table.add(position).padBottom(Gdx.graphics.getHeight() / 50); table.add(name).left().padBottom(Gdx.graphics.getHeight() / 50).padRight(Gdx.graphics.getWidth() / 32); table.add(score).padBottom(Gdx.graphics.getHeight() / 50).right(); table.row(); } final TextButton resetButton = new TextButton("Reset High Scores", game.assets.skin); resetButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (resetButton.isPressed()) { game.save.resetScores(); game.setScreen(game.highScoresScreen); } } }); table.add(resetButton).colspan(3); table.row(); final TextButton menuButton = new TextButton("Main Menu", game.assets.skin); menuButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (menuButton.isPressed()) { game.setScreen(game.menuScreen); } } }); table.add(menuButton).colspan(3).pad(10); }
From source file:com.agateau.pixelwheels.racescreen.FinishedOverlay.java
License:Open Source License
private Actor createRecordBreakerContent() { Racer racer = mRecordBreakers.pop(); GameInfo.Player player = (GameInfo.Player) racer.getEntrant(); Racer.RecordRanks ranks = racer.getRecordRanks(); UiBuilder builder = new UiBuilder(mGame.getAssets().atlas, mGame.getAssets().ui.skin); Actor content = builder.build(FileUtils.assets("screens/recordbreaker.gdxui")); Label titleLabel = builder.getActor("titleLabel"); String title = String.format(Locale.US, "Congratulations player %d!", player.getIndex() + 1); if (ranks.lapRecordRank >= 0) { fillBestRow(builder, 1, ranks.lapRecordRank, "Best lap"); }//from w ww.j a v a 2s. c o m if (ranks.totalRecordRank >= 0) { int row = ranks.lapRecordRank >= 0 ? 2 : 1; fillBestRow(builder, row, ranks.totalRecordRank, "Best total time"); } titleLabel.setText(title); titleLabel.pack(); Menu menu = builder.getActor("menu"); menu.addButton("OK").addListener(new MenuItemListener() { @Override public void triggered() { onRecordBreakerOK(); } }); return content; }
From source file:com.agateau.pixelwheels.racescreen.FinishedOverlay.java
License:Open Source License
private void fillBestRow(UiBuilder builder, int row, int rank, String text) { Image image = builder.getActor("bestImage" + String.valueOf(row)); Label label = builder.getActor("bestLabel" + String.valueOf(row)); TextureRegion region = mGame.getAssets().ui.atlas.findRegion("best-" + String.valueOf(rank + 1)); image.setDrawable(new TextureRegionDrawable(region)); image.pack();/*from w w w .j a va2 s.com*/ label.setText(text); label.pack(); }
From source file:com.agateau.pixelwheels.racescreen.HudContent.java
License:Open Source License
private void updateLabels() { int idx = 0;//from ww w .ja va 2s. co m boolean singlePlayer = mGameWorld.getPlayerRacers().size == 1; for (Racer racer : mGameWorld.getPlayerRacers()) { Label lapLabel = mLapLabels.get(idx); Label rankLabel = mRankLabels.get(idx); int lapCount = Math.max(racer.getLapPositionComponent().getLapCount(), 1); int totalLapCount = mGameWorld.getTrack().getTotalLapCount(); int rank = mGameWorld.getRacerRank(racer); mStringBuilder.setLength(0); if (!singlePlayer) { mStringBuilder.append("P").append(idx + 1).append(": "); } mStringBuilder.append(rank).append(StringUtils.getRankSuffix(rank)); rankLabel.setText(mStringBuilder); rankLabel.pack(); mStringBuilder.setLength(0); mStringBuilder.append("Lap ").append(lapCount).append('/').append(totalLapCount); lapLabel.setText(mStringBuilder); lapLabel.pack(); ++idx; } }
From source file:com.badlogic.gdx.ai.tests.steer.SteeringTestBase.java
License:Apache License
protected void addMaxLinearAccelerationController(Table table, final Limiter limiter, float minValue, float maxValue, float step) { final Label labelMaxLinAcc = new Label("Max.Linear Acc.[" + limiter.getMaxLinearAcceleration() + "]", container.skin);/*from w ww . j ava2 s . com*/ table.add(labelMaxLinAcc); table.row(); Slider maxLinAcc = new Slider(minValue, maxValue, step, false, container.skin); maxLinAcc.setValue(limiter.getMaxLinearAcceleration()); maxLinAcc.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Slider slider = (Slider) actor; limiter.setMaxLinearAcceleration(slider.getValue()); labelMaxLinAcc.setText("Max.Linear Acc.[" + limiter.getMaxLinearAcceleration() + "]"); } }); table.add(maxLinAcc); }
From source file:com.badlogic.gdx.ai.tests.steer.SteeringTestBase.java
License:Apache License
protected void addMaxLinearSpeedController(Table table, final Limiter limiter, float minValue, float maxValue, float step) { final Label labelMaxSpeed = new Label("Max.Lin.Speed [" + limiter.getMaxLinearSpeed() + "]", container.skin);/*w w w .j a v a2 s . co m*/ table.add(labelMaxSpeed); table.row(); Slider maxSpeed = new Slider(minValue, maxValue, step, false, container.skin); maxSpeed.setValue(limiter.getMaxLinearSpeed()); maxSpeed.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Slider slider = (Slider) actor; limiter.setMaxLinearSpeed(slider.getValue()); labelMaxSpeed.setText("Max.Lin.Speed [" + limiter.getMaxLinearSpeed() + "]"); } }); table.add(maxSpeed); }
From source file:com.badlogic.gdx.ai.tests.steer.SteeringTestBase.java
License:Apache License
protected void addMaxAngularAccelerationController(Table table, final Limiter limiter, float minValue, float maxValue, float step) { final Label labelMaxAngAcc = new Label("Max.Ang.Acc.[" + limiter.getMaxAngularAcceleration() + "]", container.skin);/*from ww w . ja va 2 s.co m*/ table.add(labelMaxAngAcc); table.row(); Slider maxAngAcc = new Slider(minValue, maxValue, step, false, container.skin); maxAngAcc.setValue(limiter.getMaxAngularAcceleration()); maxAngAcc.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Slider slider = (Slider) actor; limiter.setMaxAngularAcceleration(slider.getValue()); labelMaxAngAcc.setText("Max.Ang.Acc.[" + limiter.getMaxAngularAcceleration() + "]"); } }); table.add(maxAngAcc); }
From source file:com.badlogic.gdx.ai.tests.steer.SteeringTestBase.java
License:Apache License
protected void addMaxAngularSpeedController(Table table, final Limiter limiter, float minValue, float maxValue, float step) { final Label labelMaxAngSpeed = new Label("Max.Ang.Speed [" + limiter.getMaxAngularSpeed() + "]", container.skin);// ww w.j a va 2s .c om table.add(labelMaxAngSpeed); table.row(); Slider maxAngSpeed = new Slider(minValue, maxValue, step, false, container.skin); maxAngSpeed.setValue(limiter.getMaxAngularSpeed()); maxAngSpeed.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Slider slider = (Slider) actor; limiter.setMaxAngularSpeed(slider.getValue()); labelMaxAngSpeed.setText("Max.Ang.Speed [" + limiter.getMaxAngularSpeed() + "]"); } }); table.add(maxAngSpeed); }
From source file:com.bladecoder.engineeditor.ui.DialogOptionTree.java
License:Apache License
private void updateNode(Node node) { Element e = (Element) node.getObject(); VerticalGroup vg = (VerticalGroup) node.getActor(); Label textLbl = (Label) vg.getChildren().get(0); Label infoLbl = (Label) vg.getChildren().get(1); String text = e.getAttribute("text"); textLbl.setText(Ctx.project.getSelectedChapter().getTranslation(text)); StringBuilder sb = new StringBuilder(); // if(!actor.isEmpty()) // sb.append(" actor '").append(actor).append("'"); NamedNodeMap attr = e.getAttributes(); String response = e.getAttribute("response_text"); if (!response.isEmpty()) sb.append("R: ").append(Ctx.project.getSelectedChapter().getTranslation(response)).append(' '); for (int i = 0; i < attr.getLength(); i++) { org.w3c.dom.Node n = attr.item(i); String name = n.getNodeName(); if (name.equals("text") || name.equals("response_text")) continue; String v = n.getNodeValue(); sb.append(name).append(':').append(Ctx.project.getSelectedChapter().getTranslation(v)).append(' '); }//from w ww. j a v a 2 s. c o m infoLbl.setText(sb.toString()); // NodeList childs = e.getChildNodes(); // int n = childs.getLength(); // // for (int i = 0; i < n; i++) { // if (childs.item(i) instanceof Element) { // node.add(createNode((Element) childs.item(i))); // } // } }