Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Table#setBackground()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Table#setBackground() . 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: 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 2
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 3
Source File: SignInWindow.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
@Override protected void doShow(String signInReasonKey) {
    Table content = new Table(Config.skin);
    content.setBackground("ui-store-window-background");
    content.defaults().pad(4);

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

    Button button = new Button(Config.skin);
    button.defaults().pad(2);
    button.add(new LocLabel("ui-sign-in")).padTop(1).padLeft(4).expand().right();
    button.add(new Tile("ui/button/services-icon")).padTop(4).padBottom(2).padRight(4).expand().left();
    button.addListener(new ChangeListener() {
        @Override public void changed(ChangeEvent event, Actor actor) {
            signIn = true;
            hide();
        }
    });

    content.add(label).width(130).row();
    content.add(button).width(70).padBottom(8);

    table.add(content);
}
 
Example 4
Source File: DialogLoading.java    From skin-composer with MIT License 5 votes vote down vote up
public void populate() {
    Table t = getContentTable();
    Label label = new Label("Loading...", main.getSkin(), "title");
    label.setAlignment(Align.center);
    t.add(label);
    t.row();
    Table table = new Table(main.getSkin());
    table.setBackground(main.getLoadingAnimation());
    t.add(table);
}
 
Example 5
Source File: CreatureQueueWindow.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override protected void initialize() {
    creaturesList.defaults().pad(2);
    creaturesList.padTop(12);

    Image left = new Image(Config.skin, "ui-creature-queue-gradient-left");
    left.setScaling(Scaling.stretchY);
    left.setAlign(Align.left);
    left.setTouchable(Touchable.disabled);

    Image right = new Image(Config.skin, "ui-creature-queue-gradient-right");
    right.setScaling(Scaling.stretchY);
    right.setAlign(Align.right);
    right.setTouchable(Touchable.disabled);

    Stack stack = new Stack();
    stack.add(new ScrollPane(creaturesList, new ScrollPane.ScrollPaneStyle()));
    stack.add(left);
    stack.add(right);

    Table content = new Table(Config.skin);
    content.setTouchable(Touchable.enabled);
    content.setBackground("ui-inventory-ability-window-background");
    content.defaults().pad(2);
    content.add(new LocLabel("ui-turns-order")).row();
    content.add(new Image(Config.skin, "ui-creature-info-line")).width(100).row();
    content.add(stack).maxWidth(table.getStage().getWidth() - 45).padRight(4).padLeft(4).row();

    table.add(content);
}
 
Example 6
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 7
Source File: Hint.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public Hint(String locKey, ObjectMap<String, String> params) {
    label = new LocLabel(locKey, params, TEXT_COLOR);
    label.setWrap(true);
    label.setAlignment(Align.center);
    table = new Table(Config.skin);
    table.setBackground("ui/hint-background");
    labelCell = table.add(label).expand().fill().minWidth(60);
}
 
Example 8
Source File: InvitesWindow.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override protected void initialize() {
    Table content = new Table(Config.skin);
    content.setTouchable(Touchable.enabled);
    content.setBackground("ui-store-window-background");
    content.add(new ScrollPane(list)).size(100, 100);

    table.add(content);
}
 
Example 9
Source File: CCPanel.java    From cocos-ui-libgdx with Apache License 2.0 5 votes vote down vote up
@Override
public Actor parse(CocoStudioUIEditor editor, ObjectData widget) {
    Table table = new Table();

    Size size = widget.getSize();
    if (widget.getComboBoxIndex() == 0) { // 无颜色

    } else if (widget.getComboBoxIndex() == 1 && widget.getBackColorAlpha() != 0) {// 单色
        Pixmap pixmap = new Pixmap((int) size.getX(), (int) size.getY(),
            Format.RGBA8888);

        pixmap.setColor(editor.getColor(widget.getSingleColor(),
            widget.getBackColorAlpha()));

        pixmap.fill();

        Drawable d = new TextureRegionDrawable(new TextureRegion(
            new Texture(pixmap)));
        table.setBackground(d);
        pixmap.dispose();
    }

    if (widget.getFileData() != null) {// Panel的图片并不是拉伸平铺的!!.但是这里修改为填充
        Drawable tr = editor.findDrawable(widget, widget.getFileData());
        if (tr != null) {
            Image bg = new Image(tr);
            bg.setPosition((size.getX() - bg.getWidth()) / 2,
                (size.getY() - bg.getHeight()) / 2);
            // bg.setFillParent(true);
            bg.setTouchable(Touchable.disabled);

            table.addActor(bg);
        }
    }

    table.setClip(widget.isClipAble());

    return table;
}
 
Example 10
Source File: MonsterLabelManager.java    From riiablo with Apache License 2.0 5 votes vote down vote up
MonsterLabel() {
  label = new Table();
  label.setBackground(new PaletteIndexedColorDrawable(Riiablo.colors.darkRed) {{
    setTopHeight(VERTICAL_PADDING);
    setBottomHeight(VERTICAL_PADDING);
    setLeftWidth(HORIZONTAL_PADDING);
    setRightWidth(HORIZONTAL_PADDING);
  }});
  label.add(name = new com.riiablo.widget.Label(Riiablo.fonts.font16));
  label.pack();

  add(label).space(4).center().row();
  add(type = new Label(Riiablo.fonts.ReallyTheLastSucker)).row();
  pack();
}
 
Example 11
Source File: TabbedPane.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
private void initialize () {

		setTouchable(Touchable.enabled);
		tabTitleTable = new Table();
		tabBodyStack = new Stack();
		selectedIndex = -1;

		// Create 1st row
		Cell<?> leftCell = add(new Image(style.titleBegin));
		Cell<?> midCell = add(tabTitleTable);
		Cell<?> rightCell = add(new Image(style.titleEnd));
		switch (tabTitleAlign) {
		case Align.left:
			leftCell.width(((Image)leftCell.getActor()).getWidth()).bottom();
			midCell.left();
			rightCell.expandX().fillX().bottom();
			break;
		case Align.right:
			leftCell.expandX().fillX().bottom();
			midCell.right();
			rightCell.width(((Image)rightCell.getActor()).getWidth()).bottom();
			break;
		case Align.center:
			leftCell.expandX().fillX().bottom();
			midCell.center();
			rightCell.expandX().fillX().bottom();
			break;
		default:
			throw new IllegalArgumentException("TabbedPane align must be one of left, center, right");
		}

		// Create 2nd row
		row();
		Table t = new Table();
		t.setBackground(style.bodyBackground);
		t.add(tabBodyStack);
		add(t).colspan(3).expand().fill();
	}
 
Example 12
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 13
Source File: ConflictWindow.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.setTouchable(Touchable.enabled);
    content.setBackground("ui-store-window-background");

    LocLabel desc = new LocLabel("ui-conflict-description");
    desc.setWrap(true);
    desc.setAlignment(Align.center);

    Table diff = new Table(Config.skin);
    diff.defaults().uniform().pad(1);
    UserData local = params.localData;
    UserData server = params.serverData;


    diff.add(String.valueOf(local.numPassedLevels()), "default", AboutWindow.INACTIVE).expandX();
    final Tile levels = new Tile("ui/conflict-window/levels");
    Hint.make(levels, "ui-conflict-window-levels");
    diff.add(levels);
    diff.add(String.valueOf(server.numPassedLevels()), "default", AboutWindow.INACTIVE).expandX();
    diff.row();

    diff.add(String.valueOf(local.diceCount()), "default", AboutWindow.INACTIVE);
    final Tile dice = new Tile("ui/conflict-window/dice");
    Hint.make(dice, "ui-conflict-window-dice");
    diff.add(dice);
    diff.add(String.valueOf(server.diceCount()), "default", AboutWindow.INACTIVE);
    diff.row();

    Item coin = Config.items.get("coin");
    diff.add(String.valueOf(local.getItemCount(coin)), "default", AboutWindow.INACTIVE);
    final Tile coins = new Tile("ui/conflict-window/coins");
    Hint.make(coins, "ui-conflict-window-coins");
    diff.add(coins);
    diff.add(String.valueOf(server.getItemCount(coin)), "default", AboutWindow.INACTIVE);
    diff.row();

    diff.add(String.valueOf(local.potionsCount()), "default", AboutWindow.INACTIVE);
    final Tile potions = new Tile("ui/conflict-window/potions");
    Hint.make(potions, "ui-conflict-window-potions");
    diff.add(potions);
    diff.add(String.valueOf(server.potionsCount()), "default", AboutWindow.INACTIVE);
    diff.row();

    diff.add(String.valueOf(local.itemsCount(Item.Type.ingredient)), "default", AboutWindow.INACTIVE);
    final Tile ingredients = new Tile("ui/conflict-window/ingredients");
    Hint.make(ingredients, "ui-conflict-window-ingredients");
    diff.add(ingredients);
    diff.add(String.valueOf(server.itemsCount(Item.Type.ingredient)), "default", AboutWindow.INACTIVE);

    LocTextButton useLocal = new LocTextButton("ui-use-local");
    useLocal.addListener(listener(GameMapState.ConflictResolution.useLocal));
    LocTextButton useServer = new LocTextButton("ui-use-server");
    useServer.addListener(listener(GameMapState.ConflictResolution.useServer));

    Table buttons = new Table();
    buttons.defaults().uniformX();
    buttons.add(useLocal).expandX().fillX().padRight(3);
    buttons.add(useServer).expandX().fillX();

    content.add(new LocLabel("ui-conflict-header")).padBottom(0).row();
    content.add(desc).width(130).padTop(0).row();
    content.add(new Tile("ui-creature-info-line")).width(80).pad(4).row();
    content.add(diff).width(110).padBottom(3).row();
    content.add(buttons).expandX().fillX();

    table.add(content);
}
 
Example 14
Source File: CCScrollView.java    From cocos-ui-libgdx with Apache License 2.0 4 votes vote down vote up
@Override
public Actor parse(CocoStudioUIEditor editor, ObjectData widget) {
    ScrollPaneStyle style = new ScrollPaneStyle();

    if (widget.getFileData() != null) {

        style.background = editor
            .findDrawable(widget, widget.getFileData());
    }

    ScrollPane scrollPane = new ScrollPane(null, style);

    if ("Vertical_Horizontal".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(true, true);
    } else if ("Horizontal".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(true, false);
    } else if ("Vertical".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(false, true);
    }

    scrollPane.setClamp(widget.isClipAble());
    scrollPane.setFlickScroll(widget.isIsBounceEnabled());

    Table table = new Table();
    table.setSize(widget.getInnerNodeSize().getWidth(), widget
        .getInnerNodeSize().getHeight());

    if (widget.getComboBoxIndex() == 0) {// 无颜色

    } else if (widget.getComboBoxIndex() == 1) {// 单色

        Pixmap pixmap = new Pixmap((int) table.getWidth(),
            (int) table.getHeight(), Format.RGBA8888);
        Color color = editor.getColor(widget.getSingleColor(),
            widget.getBackColorAlpha());

        pixmap.setColor(color);

        pixmap.fill();

        Drawable drawable = new TextureRegionDrawable(new TextureRegion(
            new Texture(pixmap)));

        table.setBackground(drawable);
        pixmap.dispose();

    }
    scrollPane.setWidget(table);
    return scrollPane;
}
 
Example 15
Source File: TableTiledBackgroundLmlAttribute.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
@Override
public void process(final LmlParser parser, final LmlTag tag, final Table actor, final String rawAttributeData) {
    Skin skin = parser.getData().getDefaultSkin();
    TiledDrawable drawable = skin.getTiledDrawable(parser.parseString(rawAttributeData, actor));
    actor.setBackground(drawable);
}
 
Example 16
Source File: Editor.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void create() {

	if (EditorLogger.debugMode()) {
		EngineLogger.setDebug();
	}

	Gdx.graphics.setWindowedMode(Math.max((int) (Gdx.graphics.getDisplayMode().width * 0.9), 1920 / 2),
			Math.max((int) (Gdx.graphics.getDisplayMode().height * 0.9), 1080 / 2));

	skin = new BladeSkin(Gdx.files.internal(SKIN));
	VisUI.load();
	FileChooser.setDefaultPrefsName("com.bladecoder.engineeditor.filechooser");

	/*** STAGE SETUP ***/
	stage = new Stage(new ScreenViewport());
	Gdx.input.setInputProcessor(stage);

	setCtx();

	Message.init(skin);

	scnEditor = new ScnEditor(skin);
	scnEditor.setBackground("background");
	skin.getFont("default-font").getData().markupEnabled = true;

	// RIGHT PANEL
	ScenePanel scenePanel = new ScenePanel(skin);
	ActorPanel actorPanel = new ActorPanel(skin);

	Table rightPanel = new Table(skin);
	rightPanel.top().left();
	rightPanel.add(actorPanel).expand().fill().left();
	rightPanel.setBackground("background");

	SplitPane splitPaneRight = new SplitPane(scnEditor, rightPanel, false, skin);

	splitPaneRight.setSplitAmount(0.75f);

	// LEFT PANEL
	ProjectPanel projectPanel = new ProjectPanel(skin);
	Image img = new Image(Ctx.assetManager.getIcon("title"));
	img.setScaling(Scaling.none);
	img.setAlign(Align.left);

	Table leftPanel = new Table(skin);
	leftPanel.top().left().padLeft(10);
	leftPanel.add(img).expand().fill().padBottom(20).padTop(20).padLeft(0).left();
	leftPanel.row();
	leftPanel.add(new ProjectToolbar(skin)).expandX().fill().left();
	leftPanel.row();
	leftPanel.add(projectPanel).expand().fill().left();
	leftPanel.row();
	leftPanel.add(scenePanel).expand().fill().left();
	leftPanel.setBackground("background");

	SplitPane splitPaneLeft = new SplitPane(leftPanel, splitPaneRight, false, skin);
	splitPaneLeft.setFillParent(true);
	splitPaneLeft.setSplitAmount(0.25f);
	stage.addActor(splitPaneLeft);

	// LOAD LAST OPEN PROJECT
	String lastProject = Ctx.project.getEditorConfig().getProperty(Project.LAST_PROJECT_PROP, "");
	final File lastProjectFile = new File(lastProject);

	if (!lastProject.isEmpty() && lastProjectFile.exists()) {
		EditorLogger.debug("Loading previous project: " + lastProject);

		try {
			EditorUtils.checkVersionAndLoadProject(lastProjectFile, stage, skin);
		} catch (Exception e) {
			EditorLogger.error("Error loading previous project.", e);
			Ctx.project.closeProject();
		}
	}

	stage.setScrollFocus(scnEditor.getScnWidget());
	stage.setKeyboardFocus(scnEditor.getScnWidget());

	// TooltipManager.getInstance().instant();
	TooltipManager.getInstance().initialTime = 0.2f;
	TooltipManager.getInstance().hideAll();
	TooltipManager.getInstance().subsequentTime = 0.2f;
}