Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Label#setWrap()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Label#setWrap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VectorFieldModuleWrapper.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
protected void configureSlots () {
    addInputSlot("field position", VectorFieldModule.POSITION);
    addInputSlot("field size", VectorFieldModule.SIZE_SCALE);
    addInputSlot("field force", VectorFieldModule.FORCE_SCALE);

    addOutputSlot("velocity", VectorFieldModule.VELOCITY);
    addOutputSlot("angle", VectorFieldModule.ANGLE);

    leftWrapper.add().expandY().row();
    rightWrapper.add().expandY().row();

    vectorFieldLabel = new Label("drop .fga file here", getSkin());
    vectorFieldLabel.setAlignment(Align.center);
    vectorFieldLabel.setWrap(true);
    contentWrapper.add(vectorFieldLabel).padTop(60f).padBottom(10f).size(180, 50).center().expand();
}
 
Example 2
Source File: ArrowMessageNet.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
@Override protected Table getMessageTable() {

        LocLabel label = new LocLabel(locKey);
        label.setWrap(true);
        label.setAlignment(Align.center);

        Label tapToContinue = new LocLabel("tap-to-continue", ShowTutorialMessage.Message.TAP_TO_CONTINUE);
        tapToContinue.setWrap(true);
        tapToContinue.setAlignment(Align.center);

        Table result = new Table();
        result.align(Align.top);
        result.add(label).width(stage.getWidth() / 1.5f).row();
        result.add(new Image(Config.skin, "ui-creature-info-line")).width(120).padTop(4).row();
        result.add(tapToContinue);
        return result;
    }
 
Example 3
Source File: TutorialMessageWindow.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
@Override protected void initialize() {
    Table table = new Table(Config.skin);
    table.setBackground(Config.skin.getDrawable("ui-tutorial-window-background"));

    label = new LocLabel("", DieMessageWindow.ACTIVE);
    label.setWrap(true);
    label.setAlignment(Align.center);

    table.setTouchable(Touchable.disabled);

    Label tapToContinue = new LocLabel("tap-to-continue", DieMessageWindow.INACTIVE);
    tapToContinue.setWrap(true);
    tapToContinue.setAlignment(Align.center);

    if (image != null) {
        image.setTouchable(Touchable.disabled);
        table.add(image).padTop(-15 - dy).row();
    }
    final Cell<LocLabel> cell = table.add(label).width(100);
    if (forceLabelHeight) cell.height(labelHeight);
    cell.row();
    table.add(new Image(Config.skin, "ui-tutorial-window-line")).padTop(4).row();
    table.add(tapToContinue).width(80).row();

    this.table.add(table);
}
 
Example 4
Source File: DieMessageWindow.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
@Override protected void initialize() {
    Table table = new Table(Config.skin);
    table.setBackground(Config.skin.getDrawable("ui-tutorial-window-background"));
    label = new LocLabel("", ACTIVE);
    label.setWrap(true);
    label.setAlignment(Align.center);

    table.setTouchable(Touchable.disabled);

    Label tapToContinue = new LocLabel("tap-to-continue", INACTIVE);
    tapToContinue.setWrap(true);
    tapToContinue.setAlignment(Align.center);

    table.add(imageTable).padTop(6).row();
    table.add(label).width(100).row();
    table.add(new Image(Config.skin, "ui-tutorial-window-line")).padTop(4).row();
    table.add(tapToContinue).width(80).row();

    this.table.add(table);
}
 
Example 5
Source File: Message.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public static void init(Skin skin) {
	msg = new Label("", skin, "message") {

		@Override
		public Actor hit(float x, float y, boolean touchable) {
			if (isModal)
				return this;

			return null;
		}
	};

	Message.skin = skin;
	msg.setWrap(true);
	msg.setAlignment(Align.center, Align.center);
}
 
Example 6
Source File: ArrowForceClickInventory.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override protected Table getMessageTable() {
    Table table = new Table(Config.skin);
    table.align(Align.top);
    Label label = new LocLabel("tutorial-open-dice-window");
    label.setWrap(true);
    label.setAlignment(Align.center);
    table.add(label);
    return table;
}
 
Example 7
Source File: ProfessionAbilityDescriptionWindow.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override protected void doShow(Params params) {

        Table content = new Table(Config.skin);
        content.defaults().pad(2);
        content.setBackground("ui-creature-info-background");
        content.setTouchable(Touchable.enabled);
        table.add(content);

        Image image = new Image(Config.skin, "ability/" + params.ability.name + "-icon");
        Image line = new Image(Config.skin, "ui-creature-info-line");

        Thesaurus.Params dp = Thesaurus.params();
        params.ability.fillDescriptionParams(dp, params.creature);
        Label desc = new LocLabel(params.ability.locDescKey(), dp);
        desc.setWrap(true);
        desc.setAlignment(Align.center);

        content.add(image).size(image.getWidth() * 2, image.getHeight() * 2).padBottom(-6).padTop(0).row();
        content.add(new LocLabel(params.ability.locNameKey())).padBottom(3).row();
        content.add(line).width(50).row();
        content.add(desc).width(120).row();

        if (!params.ability.requirement.isSatisfied(params.creature.description)) {
            Label label = new LocLabel(params.ability.requirement.describe(params.creature.description), StoreWindow.INACTIVE);
            label.setWrap(true);
            label.setAlignment(Align.center);
            content.add(label).padLeft(4).padRight(4).padBottom(3).width(120).row();
        }
    }
 
Example 8
Source File: EditDialog.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
public EditDialog(String title, Skin skin) {
		super(title, skin);

		this.skin = skin;

		setResizable(false);
		setKeepWithinStage(false);

		infoLbl = new Label("", skin);
		infoLbl.setWrap(true);
		centerPanel = new Table(skin);
		infoCell = getContentTable().add((Widget) infoLbl).prefWidth(200).height(Gdx.graphics.getHeight() * 0.5f);
		getContentTable().add(new ScrollPane(centerPanel, skin)).maxHeight(Gdx.graphics.getHeight() * 0.8f)
				.maxWidth(Gdx.graphics.getWidth() * 0.7f).minHeight(Gdx.graphics.getHeight() * 0.5f)
				.minWidth(Gdx.graphics.getWidth() * 0.5f);

		getContentTable().setHeight(Gdx.graphics.getHeight() * 0.7f);

		centerPanel.addListener(new InputListener() {
			@Override
			public void enter(InputEvent event, float x, float y, int pointer,
					com.badlogic.gdx.scenes.scene2d.Actor fromActor) {
//				EditorLogger.debug("ENTER - X: " + x + " Y: " + y);
				getStage().setScrollFocus(centerPanel);
			}
		});

		button("OK", true);
		button("Cancel", false);
		// DISABLE the enter key because conflicts when newline in TextFields
//		key(Keys.ENTER, true);
		key(Keys.ESCAPE, false);

		padBottom(10);
		padLeft(10);
		padRight(10);
	}
 
Example 9
Source File: LogMenu.java    From Cubes with MIT 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 10
Source File: UIUtils.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
public static Label newLabel (String text, boolean wrap) {
	Label l = new Label(text, Art.scrSkin);
	l.setWrap(wrap);
	return l;
}
 
Example 11
Source File: BattleEventHandler.java    From Unlucky with MIT License 4 votes vote down vote up
public BattleEventHandler(GameScreen gameScreen, TileMap tileMap, Player player, Battle battle,
                          BattleUIHandler uiHandler, Stage stage, final ResourceManager rm) {
    super(gameScreen, tileMap, player, battle, uiHandler, rm);

    this.stage = stage;

    // create main UI
    ui = new Image(rm.dialogBox400x80);
    ui.setSize(200, 40);
    ui.setPosition(0, 0);
    ui.setTouchable(Touchable.disabled);

    stage.addActor(ui);

    // create Labels
    BitmapFont bitmapFont = rm.pixel10;
    Label.LabelStyle font = new Label.LabelStyle(bitmapFont, new Color(0, 0, 0, 255));

    textLabel = new Label("", font);
    textLabel.setWrap(true);
    textLabel.setTouchable(Touchable.disabled);
    textLabel.setFontScale(1.7f / 2);
    textLabel.setPosition(8, 6);
    textLabel.setSize(175, 26);
    textLabel.setAlignment(Align.topLeft);
    stage.addActor(textLabel);

    clickLabel = new Label("", font);
    clickLabel.setSize(200, 120);
    clickLabel.setPosition(0, 0);

    final Player p = player;
    clickLabel.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (dialogIndex + 1 == currentDialog.length && endCycle) {
                if (!p.settings.muteSfx) rm.textprogression.play(p.settings.sfxVolume);
                // the text animation has run through every element of the text array
                endDialog();
                handleBattleEvent(nextEvent);
            }
            // after a cycle of text animation ends, clicking the UI goes to the next cycle
            else if (endCycle && dialogIndex < currentDialog.length) {
                if (!p.settings.muteSfx) rm.textprogression.play(p.settings.sfxVolume);
                dialogIndex++;
                reset();
                currentText = currentDialog[dialogIndex];
                anim = currentText.split("");
                beginCycle = true;
            }
            // clicking on the box during a text animation completes it early
            else if (beginCycle && !endCycle) {
                resultingText = currentText;
                textLabel.setText(resultingText);
                beginCycle = false;
                endCycle = true;
            }
        }
    });
    stage.addActor(clickLabel);
}
 
Example 12
Source File: DialogScreen.java    From Unlucky with MIT License 4 votes vote down vote up
public DialogScreen(GameScreen gameScreen, TileMap tileMap, Player player, final ResourceManager rm) {
    super(gameScreen, tileMap, player, rm);

    // create main UI
    ui = new Image(rm.dialogBox400x80);
    ui.setSize(200, 40);
    ui.setPosition(0, 0);
    ui.setTouchable(Touchable.disabled);

    stage.addActor(ui);

    // create Labels
    BitmapFont bitmapFont = rm.pixel10;
    Label.LabelStyle font = new Label.LabelStyle(bitmapFont, new Color(0, 0, 0, 255));

    textLabel = new Label("", font);
    textLabel.setWrap(true);
    textLabel.setTouchable(Touchable.disabled);
    textLabel.setFontScale(1.7f / 2);
    textLabel.setPosition(8, 6);
    textLabel.setSize(350 / 2, 52 / 2);
    textLabel.setAlignment(Align.topLeft);
    stage.addActor(textLabel);

    clickLabel = new Label("", font);
    clickLabel.setSize(200, 120);
    clickLabel.setPosition(0, 0);

    final Player p = player;
    clickLabel.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (dialogIndex + 1 == currentDialog.length && endCycle) {
                if (!p.settings.muteSfx) rm.textprogression.play(p.settings.sfxVolume);
                // the text animation has run through every element of the text array
                endDialog();
                handleEvent(nextEvent);
            }
            // after a cycle of text animation ends, clicking the UI goes to the next cycle
            else if (endCycle && dialogIndex < currentDialog.length) {
                if (!p.settings.muteSfx) rm.textprogression.play(p.settings.sfxVolume);
                dialogIndex++;
                reset();
                currentText = currentDialog[dialogIndex];
                anim = currentText.split("");
                beginCycle = true;
            }
            // clicking on the box during a text animation completes it early
            else if (beginCycle && !endCycle) {
                resultingText = currentText;
                textLabel.setText(resultingText);
                beginCycle = false;
                endCycle = true;
            }
        }
    });
    stage.addActor(clickLabel);
}
 
Example 13
Source File: ProfessionAbilityPlayWindow.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
@Override protected void doShow(Params params) {
    callback = params.callback;
    Table content = new Table(Config.skin);
    content.defaults().pad(2);
    content.setBackground("ui-creature-info-background");
    content.setTouchable(Touchable.enabled);
    table.add(content);

    Image image = new Image(Config.skin, "ability/" + params.ability.name + "-icon");
    Image line = new Image(Config.skin, "ui-creature-info-line");
    TextButton use = new LocTextButton("ui-use-ability");

    Thesaurus.Params dp = Thesaurus.params();
    params.ability.fillDescriptionParams(dp, params.creature);
    Label desc = new LocLabel(params.ability.locDescKey(), dp);
    desc.setWrap(true);
    desc.setAlignment(Align.center);

    content.add(image).size(image.getWidth() * 2, image.getHeight() * 2).padBottom(-6).padTop(0).row();
    content.add(new LocLabel(params.ability.locNameKey())).padBottom(3).row();
    content.add(line).width(50).row();
    content.add(desc).width(120).row();
    content.add(use).padBottom(6).padTop(6).width(90).row();

    Thesaurus.LocalizationData reason = new Thesaurus.LocalizationData();
    if (!params.ability.action.canBeApplied(params.creature, reason)) {
        use.setDisabled(true);
        CooldownEffect cooldown = params.creature.get(Attribute.cooldownFor(params.ability.name));
        LocLabel label;
        if (cooldown == null) {
            label = new LocLabel(reason.key, reason.params, StoreWindow.INACTIVE);
        } else {
            Thesaurus.Params p = Thesaurus.params()
                .with("desc", cooldown.locDescKey())
                .with("turn-count", String.valueOf(cooldown.getTurnCount()))
                .with("die", params.creature.description.nameLocKey());
            params.ability.fillDescriptionParams(p, params.creature);
            label = new LocLabel("ui-creature-info-window-effect-description", p, StoreWindow.INACTIVE);
        }
        label.setWrap(true);
        label.setAlignment(Align.center);
        content.add(label).padLeft(4).padRight(4).padBottom(3).width(120).row();
    } else {
        use.addListener(new ChangeListener() {
            @Override public void changed(ChangeEvent event, Actor actor) {
                doUse = true;
                hide();
            }
        });
    }


}
 
Example 14
Source File: LoadSaveScreen.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void clicked(InputEvent event, float x, float y) {
	final Actor listenerActor = event.getListenerActor();

	Dialog d = new Dialog("", ui.getSkin()) {
		@Override
		protected void result(Object object) {
			if (((Boolean) object).booleanValue()) {
				final World world = ui.getWorld();
				final String filename = listenerActor.getName() + WorldSerialization.GAMESTATE_EXT;

				try {
					world.removeGameState(filename);

					listenerActor.getParent().getParent().getParent()
							.removeActor(listenerActor.getParent().getParent());

				} catch (IOException e) {
					EngineLogger.error(e.getMessage());
				}
			}
		}
	};

	d.pad(DPIUtils.getMarginSize());
	d.getButtonTable().padTop(DPIUtils.getMarginSize());
	d.getButtonTable().defaults().padLeft(DPIUtils.getMarginSize()).padRight(DPIUtils.getMarginSize());

	Label l = new Label(ui.getWorld().getI18N().getString("ui.remove"), ui.getSkin(), "ui-dialog");
	l.setWrap(true);
	l.setAlignment(Align.center);

	d.getContentTable().add(l).prefWidth(Gdx.graphics.getWidth() * .7f);

	d.button(ui.getWorld().getI18N().getString("ui.yes"), true,
			ui.getSkin().get("ui-dialog", TextButtonStyle.class));
	d.button(ui.getWorld().getI18N().getString("ui.no"), false,
			ui.getSkin().get("ui-dialog", TextButtonStyle.class));
	d.key(Keys.ENTER, true).key(Keys.ESCAPE, false);

	d.show(stage);
}
 
Example 15
Source File: DefaultSceneScreen.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
void showUIText(Text t) {
	// Type UI texts will show at the same time that TextManagerUI texts.

	String style = t.style == null ? "ui-text" : t.style;
	Label msg = new Label(t.str, getUI().getSkin(), style);

	msg.setWrap(true);
	msg.setAlignment(Align.center, Align.center);

	if (t.color != null)
		msg.setColor(t.color);

	msg.setSize(msg.getWidth() + DPIUtils.getMarginSize() * 2, msg.getHeight() + DPIUtils.getMarginSize() * 2);

	stage.addActor(msg);
	unprojectTmp.set(t.x, t.y, 0);
	getWorld().getSceneCamera().scene2screen(getStage().getViewport(), unprojectTmp);

	float posx, posy;

	if (t.x == TextManager.POS_CENTER) {
		posx = (getStage().getViewport().getScreenWidth() - msg.getWidth()) / 2;
	} else if (t.x == TextManager.POS_SUBTITLE) {
		posx = DPIUtils.getMarginSize();
	} else {
		posx = unprojectTmp.x;
	}

	if (t.y == TextManager.POS_CENTER) {
		posy = (getStage().getViewport().getScreenHeight() - msg.getHeight()) / 2;
	} else if (t.y == TextManager.POS_SUBTITLE) {
		posy = getStage().getViewport().getScreenHeight() - msg.getHeight() - DPIUtils.getMarginSize() * 3;
	} else {
		posy = unprojectTmp.y;
	}

	msg.setPosition(posx, posy);
	msg.getColor().a = 0;
	msg.addAction(sequence(Actions.fadeIn(0.4f, Interpolation.fade),
			Actions.delay(t.time, sequence(fadeOut(0.4f, Interpolation.fade), Actions.removeActor()))));
}