Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Label

The following are top voted examples for showing how to use com.badlogic.gdx.scenes.scene2d.ui.Label. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ProjektGG   File: LobbyScreen.java   Source Code and License 6 votes vote down vote up
private Table updatePlayerSlot(Table t, Player p) {
	t.clear();
	if (p == null) {
		t.add().width(25);
		t.add(new Label(" -- Frei -- ", skin)).width(350);
		t.add().width(50);
	} else {
		t.add().width(25); // Icon
		t.add(new Label(p.getName() + " " + p.getSurname() + " ", skin))
				.width(350);
		t.add().width(25); // Bereit
		t.add().width(25); // Kicken
	}

	return t;
}
 
Example 2
Project: Catan   File: ChooseDiceResultWindow.java   Source Code and License 6 votes vote down vote up
private Table setupRedDiceOption(int diceNumber) {
    Table redDiceOption = new Table();
    redDiceOption.setBackground(redBackground);
    
    redDiceOption.add(new Label("" + diceNumber, CatanGame.skin));
    
    redDiceOption.setTouchable(Touchable.enabled); 
    redDiceOption.addListener(new ClickListener(){
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (chosenRedDice == diceNumber) {
                System.out.println("discard choice of " + diceNumber);
                chosenRedDice = 0;
                enableAllTouchablesRed();
            } else {
                System.out.println("choose " + diceNumber);
                chosenRedDice = diceNumber;
                disableAllTouchablesRed();
                redDiceOption.setTouchable(Touchable.enabled);
                redDiceOption.setBackground(redBackground);
            }
        }
    });
    
    return redDiceOption;
}
 
Example 3
Project: Catan   File: ChooseDiceResultWindow.java   Source Code and License 6 votes vote down vote up
private Table setupYellowDiceOption(int diceNumber) {
    Table yellowDiceOption = new Table();
    yellowDiceOption.setBackground(yellowBackground);
    
    yellowDiceOption.add(new Label("" + diceNumber, CatanGame.skin));
    
    yellowDiceOption.setTouchable(Touchable.enabled); 
    yellowDiceOption.addListener(new ClickListener(){
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (chosenYellowDice == diceNumber) {
                System.out.println("discard choice of " + diceNumber);
                chosenYellowDice = 0;
                enableAllTouchablesYellow();
            } else {
                System.out.println("choose " + diceNumber);
                chosenYellowDice = diceNumber;
                disableAllTouchablesYellow();
                yellowDiceOption.setTouchable(Touchable.enabled);
                yellowDiceOption.setBackground(yellowBackground);
            }
        }
    });
    
    return yellowDiceOption;
}
 
Example 4
Project: ExamensArbeteTD   File: WinStage.java   Source Code and License 6 votes vote down vote up
private void initWinStage() {
	setViewport(new ScreenViewport(getCamera()));
	getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	getViewport().apply(true);
	
	Label youWinLabel = new Label("You Won!" , Assets._skin , "fontVeraBd24" , "white");
	playAgainBtn = new TextButton("Play Again", Assets._skin , "menu");
	mainMenuBtn = new TextButton("Main Menu", Assets._skin , "menu");
	Table container = new Table(Assets._skin);
	youWinLabel.setColor(Color.GREEN);
	container.add(youWinLabel).spaceBottom(100).row();
	container.add(playAgainBtn).align(Align.left).spaceBottom(20).row();
	container.add(mainMenuBtn).align(Align.left);
	container.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	container.setFillParent(true);
	addActor(container);
}
 
Example 5
Project: feup-lpoo-armadillo   File: CustomizeMenuScreen.java   Source Code and License 6 votes vote down vote up
/**
 * Function used to create the Skins' Buttons and Labels and associate them to a given table, organized.
 * It also adds Listeners to the Skins' Buttons.
 *
 * @param table Table where the Skins' Labels and Buttons will be organized.
 */
private void createSkins(Table table) {
    for (int i = 0; i < game.getNumSkins(); ++i) {

        //Adding Buttons and Labels to the Arrays
        skinButtons.add(new Button(new TextureRegionDrawable(new TextureRegion(game.getAssetManager().get("big_skins/skin" + (i < 10 ? "0" : "") + i + ".png", Texture.class)))));
        skinLabels.add(new Label("Current", skin1));

        final int j = i; //Needed for Listener initialization
        skinButtons.get(i).addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                setCurrentLabel(j);
            }
        });

        table.add(skinButtons.get(i)).size(BUTTON_SIZE, BUTTON_SIZE).pad(IMAGE_EDGE);
    }
    table.row();

    for (int i = 0; i < game.getNumSkins(); ++i)
        table.add(skinLabels.get(i));

    initializeCurrentSkin();
}
 
Example 6
Project: feup-lpoo-armadillo   File: HudMenu.java   Source Code and License 6 votes vote down vote up
/**
 * Function used to initialize all the elements of the HUD and add the respective Listeners.
 */
private void initHUD() {
    Table hudTable = new Table();
    hudTable.setFillParent(true);

    Button pauseButton = new Button(new TextureRegionDrawable(
            new TextureRegion(game.getAssetManager().get("pause.png", Texture.class))));

    scoreText = new Label("0:00", skin);
    scoreText.setFontScale(FONT_SCALE, FONT_SCALE);

    pauseButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            model.togglePause();
        }
    });

    hudTable.top();
    hudTable.add(scoreText).size(HUD_ELEMENTS_SIZE, HUD_ELEMENTS_SIZE).expandX()
            .left().fill().padLeft(HORIZONTAL_PAD).padTop(VERTICAL_PAD);
    hudTable.add(pauseButton).size(HUD_ELEMENTS_SIZE, HUD_ELEMENTS_SIZE).fill()
            .padRight(HORIZONTAL_PAD).padTop(VERTICAL_PAD);

    this.addActor(hudTable);
}
 
Example 7
Project: Caramelos   File: CaramelosScreen.java   Source Code and License 6 votes vote down vote up
public void UpdateInvisibleCells()
{
    for(int i =0; i< labelArrayList.size();i++){
        Label label = labelArrayList.get(i);
        if(!label.isVisible()){
            Random random = new Random();
            int rand = random.nextInt(5);
            CalculateColorText calculateColorText = new CalculateColorText(rand).invoke();
            Color color = calculateColorText.getColor();
            String text = calculateColorText.getText();
            Label.LabelStyle labelStyle = new Label.LabelStyle();
            labelStyle.font = font50;
            labelStyle.background = uiSkin.newDrawable("white", color);
            label.setText(text);
            label.setStyle(labelStyle);
            label.setVisible(true);
        }
    }
}
 
Example 8
Project: drc-sim-client   File: StageLoad.java   Source Code and License 6 votes vote down vote up
/**
 * Loading stage
 * @param doLoad should resources be loaded? It acts as a splash screen otherwise.
 */
public StageLoad(boolean doLoad) {
	this.doLoad = doLoad;
	// Create icon
	icon = new Image(new Texture("image/icon-512.png"));
	int size = Gdx.graphics.getHeight();
	if (Gdx.graphics.getHeight() > Gdx.graphics.getWidth())
		size = Gdx.graphics.getWidth();
	icon.setSize(size, size);
	icon.setPosition(Gdx.graphics.getWidth() / 2 - size / 2,
			Gdx.graphics.getHeight() / 2 - icon.getHeight() / 2);
	addActor(icon);
	// Loading Text
	Label.LabelStyle loadingStyle = new Label.LabelStyle();
	loadingStyle.font = new BitmapFont(Gdx.files.internal("font/collvetica.fnt"));
	loadingStyle.font.getData().setScale(Gdx.graphics.getHeight() * 2 / 720);
	loading = new Label("DRC Sim", loadingStyle);
	loading.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() * .2f);
	loading.setAlignment(Align.center);
	addActor(loading);
}
 
Example 9
Project: GDX-Engine   File: GameDialog.java   Source Code and License 6 votes vote down vote up
public GameDialog(Skin skin) {
super("", skin);

waveLevel = new Label("", skin);
monsHP = new Label("", skin);
monsBonus = new Label("", skin);
monsSpeed = new Label("", skin);
monsNumber = new Label("", skin);
btnOK = new TextButton("Okay, Let them come!", skin);
btnOK.addListener(new ChangeListener() {

    @Override
    public void changed(ChangeEvent event, Actor actor) {
	// TODO Auto-generated method stub
	setVisible(false);

    }
});
setTitle(" There are more monsters are coming to you... ");
   }
 
Example 10
Project: projecttd   File: HudScene.java   Source Code and License 6 votes vote down vote up
public HudScene(SpriteBatch batch, ShapeRenderer shapeRenderer, ArcRenderer arcRenderer) {
    this.batch = batch;
    stage = new Stage();

    VisUI.load();

    Table table = new Table();
    table.top();
    table.setFillParent(true);

    scoreLabel = new Label("", new Label.LabelStyle(new BitmapFont(), Color.VIOLET));
    setScore(score);
    balanceLabel = new Label("", new Label.LabelStyle(new BitmapFont(), Color.VIOLET));
    setBalance(balance);

    table.add(scoreLabel).align(Align.left).expandX();
    table.add(balanceLabel).align(Align.right).expandX();

    stage.addActor(table);


    ringButton = new RingButton(shapeRenderer, arcRenderer);
    ringButton.setBounds(10, 10, 100, 100);
    stage.addActor(ringButton);
}
 
Example 11
Project: Cubes_2   File: ScrollInventoryActor.java   Source Code and License 6 votes vote down vote up
public ScrollInventoryActor(Inventory inventory, int slots) {
	defaults().space(4f);

	add(new Label(inventory.getDisplayName(), new LabelStyle(Fonts.hud, Color.WHITE)));
	row();

	inner = new Table();
	inner.defaults().space(4f);
	for (int i = 0; i < inventory.itemStacks.length; i++) {
		SlotActor slotActor = new SlotActor(inventory, i);
		inner.add(slotActor);

		if ((i + 1) % inventory.width == 0) {
			inner.row();
		}
	}
	inner.pack();

	scrollPane = new ScrollPane(inner);
	scrollPane.setScrollingDisabled(true, false);
	add(scrollPane).height(slots * CALIBRATION_PER_ROW).fill();
	row();
	pack();
}
 
Example 12
Project: Cubes_2   File: InventoryActor.java   Source Code and License 6 votes vote down vote up
public InventoryActor(Inventory inventory) {
	defaults().space(4f);

	add(new Label(inventory.getDisplayName(), new LabelStyle(Fonts.hud, Color.WHITE))).colspan(inventory.width);
	row();

	SlotActor slotActor;
	for (int i = 0; i < inventory.itemStacks.length; i++) {
		slotActor = new SlotActor(inventory, i);
		add(slotActor);

		if ((i + 1) % inventory.width == 0) {
			row();
		}
	}

	pack();
}
 
Example 13
Project: Cubes_2   File: SingleplayerSaveDeleteMenu.java   Source Code and License 6 votes vote down vote up
public SingleplayerSaveDeleteMenu(final Save save) {
	title = new Label(Localization.get("menu.singleplayer.delete.title"),
			skin.get("title", Label.LabelStyle.class));
	text = new Label(Localization.get("menu.singleplayer.delete.text", save.name), skin);
	delete = new TextButton(Localization.get("menu.singleplayer.delete.delete", save.name), skin);
	back = MenuTools.getBackButton(this);

	text.setAlignment(Align.center);

	delete.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			ClientSaveManager.deleteSave(save);
			Menu prev = MenuManager.getPrevious(SingleplayerSaveDeleteMenu.this);
			if (!(prev instanceof SingleplayerSavesMenu))
				return;
			((SingleplayerSavesMenu) prev).updateSavesList();
			Adapter.setMenu(prev);
		}
	});

	stage.addActor(title);
	stage.addActor(text);
	stage.addActor(delete);
	stage.addActor(back);
}
 
Example 14
Project: Cubes_2   File: MultiplayerConnectMenu.java   Source Code and License 6 votes vote down vote up
public MultiplayerConnectMenu() {
  super();
  title = new Label(Localization.get("menu.multiplayer.title"), skin.get("title", Label.LabelStyle.class));
  address = new TextField("", skin);
  address.setMessageText(Localization.get("menu.multiplayer.address"));
  port = new TextField("", skin);
  port.setMessageText(Localization.get("menu.multiplayer.port", 24842)); //Not "Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)" because the port is set on the server
  port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
  connect = new TextButton(Localization.get("menu.multiplayer.connect"), skin);
  back = MenuTools.getBackButton(this);

  connect.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      Adapter.setMenu(new MultiplayerLoadingMenu(address.getText().isEmpty() ? "localhost" : address.getText(), port.getText().isEmpty() ? 24842 : Integer.parseInt(port.getText())));
    }
  });

  stage.addActor(title);
  stage.addActor(address);
  stage.addActor(port);
  stage.addActor(connect);
  stage.addActor(back);
}
 
Example 15
Project: enklave   File: ScreenSetting.java   Source Code and License 6 votes vote down vote up
private void addChangeFaction(){
    groupChangeFaction = new Group();
    Image background = new Image(new TextureRegion(manager.getAssetsSettings().getTexture(NameFiles.extensionImgBackground)));
    background.setSize(Width - Width * 0.03f, Height * 0.1f);
    background.setPosition(Width / 2 - background.getWidth() / 2, Height * 0.3f);
    groupChangeFaction.addActor(background);
    Label labelFac = new Label("Change Faction",new Label.LabelStyle(Font.getFont((int)(Height*0.025f)),Color.WHITE));
    labelFac.setPosition(background.getX()+background.getWidth()*0.05f,background.getY()+background.getHeight()/2-labelFac.getHeight()/2);
    labelFac.addListener(new ClickListener(){
        @Override
        public void clicked(InputEvent event, float x, float y) {
            manager.loadAssetsChoiceFaction();
            gameManager.setScreen(new ScreenCircleLoading(gameManager,new ScreenChoiceFaction(gameManager),manager.getAssetsChoiceFaction()));
        }
    });
    groupChangeFaction.addActor(labelFac);
}
 
Example 16
Project: enklave   File: ScreenSetting.java   Source Code and License 6 votes vote down vote up
private void addTestCombat(){
    groupTestCombat = new Group();
    Image background = new Image(new TextureRegion(manager.getAssetsSettings().getTexture(NameFiles.extensionImgBackground)));
    background.setSize(Width - Width * 0.03f, Height * 0.1f);
    background.setPosition(Width / 2 - background.getWidth() / 2, Height * 0.15f);
    groupChangeFaction.addActor(background);
    Label labelFac = new Label("Combat Training",new Label.LabelStyle(Font.getFont((int)(Height*0.025f)),Color.WHITE));
    labelFac.setPosition(background.getX()+background.getWidth()*0.05f,background.getY()+background.getHeight()/2-labelFac.getHeight()/2);
    labelFac.addListener(new ClickListener(){
        @Override
        public void clicked(InputEvent event, float x, float y) {
            manager.loadAssetsEnklaveScreen();
            new GetEnklaveDetails().makeRequest(16066, manager);
            gameManager.screenEnklave.setEnklave3D(new Vector2(0,0));
            gameManager.setScreen(new ScreenCircleLoading(gameManager,gameManager.screenEnklave,manager.getAssertEnklaveScreen()));;
        }
    });
    groupChangeFaction.addActor(labelFac);
}
 
Example 17
Project: enklave   File: ScreenCombat.java   Source Code and License 6 votes vote down vote up
public void screenExit(String message){
        messageShow = message;
        showtextexit = true;
        circleShow = false;
        InformationProfile.getInstance().getDateUserGame().setEnklaveCombatId(-1);
        Label labelmess = new Label("You already joined this combat once!",new Label.LabelStyle(bitmapFont,Color.WHITE));
        labelmess.setPosition(WIDTH /2 - labelmess.getWidth() /2,labelmess.getHeight()*2);
        stage.addActor(labelmess);
        combatFight.deselect();
        attachers.deselect();
        defenders.deselect();
        if(!message.contentEquals("You lose!")){
            new Timer().scheduleTask(new Timer.Task() {
                @Override
                public void run() {
                    managerAssets.getAssertEnklaveScreen().setIsupdate(false);
                    new GetEnklaveDetails().makeRequest(InformationEnklave.getInstance().getId(), managerAssets);
//                    gameManager.setScreen(gameManager.screenEnklave);
                }
            },1);
        }
    }
 
Example 18
Project: enklave   File: ScreenCrafting.java   Source Code and License 6 votes vote down vote up
private void makeRequest() {
    countBricks = Integer.parseInt(((Label)(((Group)(gr.findActor(MaterialsCraft.BRICKS.name()))).findActor(MaterialsCraft.BRICKS.name()))).getText().toString());
    countcell = Integer.parseInt(((Label)(((Group)(gr.findActor("CELLS"))).findActor("CELLS"))).getText().toString());
    if (countBricks > 0 || countcell > 0) {
        if(!queue.deployOn) {
            setisOn();
            createAddQueue();
        }else{
            queueDisplay.createexitdialog(this);
        }
    }
    ((Label) (((Group) (gr.findActor("BRICKS"))).findActor("BRICKS"))).setText("0");
    ((Label) (((Group) (gr.findActor("CELLS"))).findActor("CELLS"))).setText("0");
    updateDisplay();
    progressbar.update();
    queue.showqueue();
}
 
Example 19
Project: FlappySpinner   File: GameScreen.java   Source Code and License 6 votes vote down vote up
public void setUpMoneyLabel() {
    moneyImage = new Image(AssetsManager.getTextureRegion(Constants.COIN_NAME));
    moneyImage.setSize(2.5f, 2.5f);
    moneyImage.setPosition(Constants.WIDTH * 2 / 3 + 0.5f, onFinish.getY() + onFinish.getHeight() * 1.3f + moneyImage.getHeight() / 5.5f);
    moneyImage.setOrigin(moneyImage.getWidth() / 2, moneyImage.getHeight() / 2);
    moneyImage.setVisible(false);
    stage.addActor(moneyImage);

    Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = AssetsManager.getMediumFont();
    moneyLabel = new Label(" " + 0, labelStyle);
    moneyLabel.setFontScale(0.065f);
    moneyLabel.setSize(moneyLabel.getWidth() * moneyLabel.getFontScaleX(), moneyLabel.getHeight() * moneyLabel.getFontScaleY());
    moneyLabel.setPosition(moneyImage.getX() - moneyLabel.getWidth(), moneyImage.getY());
    moneyLabel.setVisible(false);
    stage.addActor(moneyLabel);
}
 
Example 20
Project: Klooni1010   File: ShopCard.java   Source Code and License 6 votes vote down vote up
ShopCard(final Klooni game, final GameLayout layout,
         final String itemName, final Color backgroundColor) {
    this.game = game;
    Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = game.skin.getFont("font_small");

    priceLabel = new Label("", labelStyle);
    nameLabel = new Label(itemName, labelStyle);

    Color labelColor = Theme.shouldUseWhite(backgroundColor) ? Color.WHITE : Color.BLACK;
    priceLabel.setColor(labelColor);
    nameLabel.setColor(labelColor);

    priceBounds = new Rectangle();
    nameBounds = new Rectangle();

    layout.update(this);
}
 
Example 21
Project: Klooni1010   File: Band.java   Source Code and License 6 votes vote down vote up
public Band(final Klooni game, final GameLayout layout, final BaseScorer scorer) {
    this.scorer = scorer;
    bandTexture = Theme.getBlankTexture();

    Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = game.skin.getFont("font");

    scoreLabel = new Label("", labelStyle);
    scoreLabel.setAlignment(Align.center);
    infoLabel = new Label("pause menu", labelStyle);
    infoLabel.setAlignment(Align.center);

    scoreBounds = new Rectangle();
    infoBounds = new Rectangle();
    layout.update(this);
}
 
Example 22
Project: Klooni1010   File: ShareScoreScreen.java   Source Code and License 6 votes vote down vote up
ShareScoreScreen(final Klooni game, final Screen lastScreen,
                 final int score, final boolean timeMode) {
    this.game = game;
    this.lastScreen = lastScreen;

    this.score = score;
    this.timeMode = timeMode;

    final Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.font = game.skin.getFont("font_small");

    infoLabel = new Label("Generating image...", labelStyle);
    infoLabel.setColor(Klooni.theme.textColor);
    infoLabel.setAlignment(Align.center);
    infoLabel.layout();
    infoLabel.setPosition(
            (Gdx.graphics.getWidth() - infoLabel.getWidth()) * 0.5f,
            (Gdx.graphics.getHeight() - infoLabel.getHeight()) * 0.5f);

    spriteBatch = new SpriteBatch();
}
 
Example 23
Project: MMORPG_Prototype   File: NpcConversationDialog.java   Source Code and License 6 votes vote down vote up
public void update(String speech, String[] possibleAnwsers)
{
	getContentTable().clear();
	LineBreaker lineBreaker = new LineBreaker(speech, 30);
	getContentTable().add(lineBreaker);
	getContentTable().row();
	for (String anwser : possibleAnwsers)
	{
		Runnable onClickAction = () -> packetsSender
				.send(PacketsMaker.makeNpcConversationAnwserChoosenPacket(npc.getId(), anwser));
		Label label = new ClickableLabel(anwser, onClickAction);
		getContentTable().add(label);
		getContentTable().row();
	}
	this.pack();
}
 
Example 24
Project: DarkDay   File: Hud.java   Source Code and License 6 votes vote down vote up
public Hud(SpriteBatch sb) {
    countKill = 0;
    viewport = new FitViewport(ScreenConf.V_WIDTH, ScreenConf.V_HEIGHT, new OrthographicCamera());

    stage = new Stage(viewport, sb);

    Table table = new Table();
    table.setFillParent(true);
    table.top();

    countKillLabel = new Label(String.format("%03d", countKill), new Label.LabelStyle(new BitmapFont(), Color.WHITE));

    table.add(countKillLabel).expandX().padTop(10);
    table.add().expandX();
    table.add().expandX();
    table.add().expandX();
    stage.addActor(table);

}
 
Example 25
Project: MMORPG_Prototype   File: LineBreaker.java   Source Code and License 6 votes vote down vote up
public LineBreaker(String text, int wrapLength)
{
    String wrappedText = WordUtils.wrap(text, wrapLength);
    String[] lines = wrappedText.split(System.lineSeparator());
    for(String line : lines)
    {
        Label lineLabel = new Label(line, Settings.DEFAULT_SKIN);
        this.add(lineLabel);
        this.row();
    }
    this.pack();
}
 
Example 26
Project: Hexpert   File: ActionDialog.java   Source Code and License 6 votes vote down vote up
public ActionDialog(Label text, Action action, I18NBundle bundle, Skin skin, Hexpert hexpert) {
    super(hexpert, skin);
    this.action = action;

    getBackground().setMinWidth(1000);
    getBackground().setMinHeight(400);
    text.setWrap(true);
    text.setAlignment(Align.center);

    getContentTable().add(text).width(getBackground().getMinWidth()).expandX();

    getButtonTable().defaults().width(200).height(120).pad(15);

    TextButton textButtonYes = new TextButton(bundle.get("yes"), skin);
    getButtonTable().add(textButtonYes);
    setObject(textButtonYes, 1);
    TextButton textButtonNo = new TextButton(bundle.get("no"), skin);
    getButtonTable().add(textButtonNo);
    setObject(textButtonNo, null);
}
 
Example 27
Project: cocos2d-java   File: GdxUIConsole.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitUI() {
	Skin skin = GdxUISkin.instance().getDeafult();
	input = new TextField("", skin);
	
	ClickListener mClickListener = new ClickListener() {
		public boolean keyDown (InputEvent event, int keycode) {
			if(keycode == Keys.ENTER && !isHide()) {
				if(!handleCmdString(input.getText())) {
					//clear input 
					input.setText(null);
				}
			}
			return true;
		}
	};
	input.addCaptureListener(mClickListener);
	
	input.setTextFieldFilter(new TextFieldFilter() {
		@Override
		public boolean acceptChar(TextField textField, char c) {
			if(c == '`' || c == '~') {
				hide();
				return false;
			}
			return true;
		}
	});
	label = new Label("", skin);
	
	maxTmp = GdxUIConfig.instance().consoleMaxOutputLine;
	
	input.setSize(getUIWidth()/2, 32);
	input.setPosition(20, getUIHeight() * 0.25f);
	addUI(input);
	addUI(label);
	
	skin = null;
}
 
Example 28
Project: libgdx_ui_editor   File: XmlUtils.java   Source Code and License 5 votes vote down vote up
public static void parseUqAttr(Actor actor, XmlReader.Element element){
    Class cls  = EditorManager.getInstance().getActorType(actor);
    if (cls.equals(Label.class)){
        parseLabel((Label) actor,element);
    }else if (cls.equals(Image.class)){
        parseImage((Image) actor,element);
    }else if (cls.equals(Button.class)){
        parseButton((VisImageButton) actor,element);
    }else if (cls.equals(TextField.class)){
        parseTextField((TextField) actor,element);
    }
}
 
Example 29
Project: Cubes   File: SplashMenu.java   Source Code and License 5 votes vote down vote up
public SplashMenu() {
  logo = new Image(new TextureRegionDrawable(Assets.getTextureRegion("core:logo.png")), Scaling.fillY, Align.center);
  text = new Label("Loading " + Branding.DEBUG, new Label.LabelStyle(Fonts.smallHUD, Color.WHITE));

  stage.addActor(logo);
  stage.addActor(text);
}
 
Example 30
Project: fluffybalance   File: LeaderBoardGuiEntity.java   Source Code and License 5 votes vote down vote up
private void addLeadBoardRow(String rank, String name, String score) {
    Label indexLabel = new Label(rank, mSkin);
    indexLabel.setFontScale(0.7f);
    indexLabel.setStyle(new Label.LabelStyle(mFont, COLOR_FONT));
    mScrollPaneTable.add(indexLabel)
            .expand(true, false)
            .center()
            .padTop(mDefaultMargin * 0.5f)
            .padBottom(mDefaultMargin * 0.5f)
            .padRight(mDefaultMargin * 0.5f);

    Label scoreNameLabel = new Label(name, mSkin);
    scoreNameLabel.setFontScale(0.7f);
    scoreNameLabel.setStyle(new Label.LabelStyle(mFont, COLOR_FONT));
    mScrollPaneTable.add(scoreNameLabel)
            .expand(true, false)
            .center()
            .padTop(mDefaultMargin * 0.5f)
            .padBottom(mDefaultMargin * 0.5f)
            .padRight(mDefaultMargin * 0.5f);

    Label scoreLabel = new Label(score, mSkin);
    scoreLabel.setFontScale(0.7f);
    scoreLabel.setStyle(new Label.LabelStyle(mFont, COLOR_FONT));
    mScrollPaneTable.add(scoreLabel)
            .expand(true, false)
            .center()
            .padTop(mDefaultMargin * 0.5f)
            .padBottom(mDefaultMargin * 0.5f);

    mScrollPaneTable.row();
}
 
Example 31
Project: NoRiskNoFun   File: AssetLabelImpl.java   Source Code and License 5 votes vote down vote up
private Label.LabelStyle createDefaultLabelStyle() {

        currentBackground = cache.getPixMapTexture(DEFAULT_BACKGROUND_COLOR);
        Label.LabelStyle labelStyle = new Label.LabelStyle(font, font.getColor());
        labelStyle.background = new Image(currentBackground).getDrawable();

        return labelStyle;
    }
 
Example 32
Project: NoRiskNoFun   File: AssetLabelImpl.java   Source Code and License 5 votes vote down vote up
@Override
public void setBackgroundColor(Color color) {

    // prepare new style
    Texture newTexture = cache.getPixMapTexture(color);
    Label.LabelStyle newStyle = new Label.LabelStyle(label.getStyle());
    newStyle.background = new Image(newTexture).getDrawable();
    label.setStyle(newStyle);

    // release old texture & set new one
    cache.releasePixMapTexture(currentBackground);
    currentBackground = newTexture;
}
 
Example 33
Project: Hexpert   File: LockedTutDialog.java   Source Code and License 5 votes vote down vote up
public LockedTutDialog(Hexpert hexpert, Skin skin) {
    super(hexpert, skin, false);
    I18NBundle i18n = hexpert.i18NBundle;
    Label lblContent = new Label(i18n.get("lck_diag"), skin);
    lblContent.setAlignment(Align.center);
    lblContent.setWrap(true);
    getContentTable().defaults().pad(25);
    getContentTable().add(lblContent).width(800);
}
 
Example 34
Project: Cubes   File: LogMenu.java   Source Code and License 5 votes vote down vote up
public LogMenu() {
  label = new Label("", new LabelStyle(Fonts.smallHUD, Color.BLACK));
  label.setWrap(true);
  Drawable background = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/LogBackground.png"));
  scrollPane = new ScrollPane(label, new ScrollPaneStyle(background, null, null, null, null));
  scrollPane.setScrollingDisabled(true, false);
  back = MenuTools.getBackButton(this);
  
  stage.addActor(scrollPane);
  stage.addActor(back);
  
  refresh();
}
 
Example 35
Project: Hexpert   File: PlayScreen.java   Source Code and License 5 votes vote down vote up
public void updateTableButton(Objective nextObjective)
{
    tableBtn.clearChildren();
    tableBtn.add(btnMore);
    tableBtn.add(btnRemove);
    tableBtn.add(btnHelp);
    tableBtn.row();
    lblNextObjective = new Label("", hexpert.getSkin());
    lblNextObjective.setWrap(true);
    lblNextObjective.setText(nextObjective.toString(hexpert.i18NBundle));
    nextObjectiveImage = new Image(getNextObjectiveTexture(mapResult.getObjectivePassedCount(), map.getObjectives()));
    tableBtn.add(nextObjectiveImage).width(96).height(96);
    tableBtn.add(lblNextObjective).width(lblNextObjective.getPrefWidth()).left();
}
 
Example 36
Project: Cubes_2   File: ServerSetupMenu.java   Source Code and License 5 votes vote down vote up
public ServerSetupMenu(final Save save) {
	super();
	title = new Label(Localization.get("menu.server.title"), skin.get("title", Label.LabelStyle.class));
	saveLabel = new Label(Localization.get("menu.server.save", save.name), skin);
	saveLabel.setAlignment(Align.center);
	port = new TextField("", skin);
	port.setMessageText(
			Localization.get("menu.server.port", Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)));
	port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
	start = new TextButton(Localization.get("menu.server.start"), skin);
	back = MenuTools.getBackButton(this);

	start.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			int p = port.getText().isEmpty() ? Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)
					: Integer.parseInt(port.getText());
			Adapter.setMenu(new ServerRunningMenu(save, p));
		}
	});

	stage.addActor(title);
	stage.addActor(saveLabel);
	stage.addActor(port);
	stage.addActor(start);
	stage.addActor(back);
}
 
Example 37
Project: Cubes_2   File: SplashMenu.java   Source Code and License 5 votes vote down vote up
public SplashMenu() {
  logo = new Image(new TextureRegionDrawable(Assets.getTextureRegion("core:logo.png")), Scaling.fillY, Align.center);
  text = new Label("Loading " + Branding.DEBUG, new Label.LabelStyle(Fonts.smallHUD, Color.WHITE));

  stage.addActor(logo);
  stage.addActor(text);
}
 
Example 38
Project: Cubes_2   File: InfoMenu.java   Source Code and License 5 votes vote down vote up
public InfoMenu(String labelText, String buttonText) {
	super();
	text = new Label(labelText, new LabelStyle(Fonts.hud, Color.WHITE));
	text.setAlignment(Align.center, Align.center);
	button = new TextButton(buttonText, skin);

	stage.addActor(text);
	stage.addActor(button);
}
 
Example 39
Project: Cubes_2   File: InfoMenu.java   Source Code and License 5 votes vote down vote up
public InfoMenu(String labelText, boolean back) {
	super();
	text = new Label(labelText, new LabelStyle(Fonts.hud, Color.WHITE));
	text.setAlignment(Align.center, Align.center);
	stage.addActor(text);

	if (back) {
		button = MenuTools.getBackButton(this);
		stage.addActor(button);
	}
}
 
Example 40
Project: summer17-android   File: PlayScreen.java   Source Code and License 5 votes vote down vote up
public PlayScreen(NoObjectionGame game) {
    atlas = new TextureAtlas("dudestuff3.pack");

    this.game = game;
    bg = new Texture("main_background.png");
    gameCam = new OrthographicCamera();
    gamePort = new FitViewport(NoObjectionGame.V_WIDTH / NoObjectionGame.PPM, NoObjectionGame.V_HEIGHT / NoObjectionGame.PPM, gameCam);
    hud = new Hud(game.batch);

    maploader = new TmxMapLoader();
    map = maploader.load("map1.tmx");
    renderer = new OrthoCachedTiledMapRenderer(map, 1 / NoObjectionGame.PPM);
    gameCam.position.set(gamePort.getWorldWidth() / 2, gamePort.getWorldHeight() / 2, 0);

    world = new World(new Vector2(0, -10), true);
    b2dr = new Box2DDebugRenderer();

    new B2WorldCreator(world, map);
    hero = new Hero(world, this);
    controller = new Controller();
    worldContactListener = new WorldContactListener();
    world.setContactListener(worldContactListener);

    //timer
    sb = new SpriteBatch();
    viewport = new FitViewport(NoObjectionGame.V_WIDTH, NoObjectionGame.V_HEIGHT, new OrthographicCamera());
    stage = new Stage(viewport, sb);
    table = new Table();
    table.top();
    table.setFillParent(true);
    countDownLabel = new Label(Float.toString(playTime), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    table.add(countDownLabel).expandX();
    stage.addActor(table);


}