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

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Table. These examples are extracted from open source projects. 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 Project: gdx-ai   Source File: ResumeVsJoinTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Actor createActor (final Skin skin) {
	Table table = new Table();

	LabelStyle labelStyle = new LabelStyle(skin.get(LabelStyle.class));
	labelStyle.background = skin.newDrawable("white", .6f, .6f, .6f, 1);
	String branchChildren = "\n    spinAround\n    selectTarget\n    pursue";
	table.add(new Label("parallel policy:\"sequence\" orchestrator:\"resume\"" + branchChildren, labelStyle)).pad(5);
	table.add(new Label("vs", skin)).padLeft(10).padRight(10);
	table.add(new Label("parallel policy:\"sequence\" orchestrator:\"join\"" + branchChildren, labelStyle)).pad(5);

	table.row().padTop(15);

	TextButton startButton = new TextButton("Start", skin);
	startButton.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			oldScreen = container.getScreen();
			container.setScreen(new TestScreen(ResumeVsJoinTest.this, skin));
		}
	});
	table.add();
	table.add(startButton);
	table.add();
	return table;
}
 
Example 2
Source Project: gdx-ai   Source File: Scene2dSteeringTest.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void create () {
	lastUpdateTime = 0;
	testStack = new Stack();
	container.stage.getRoot().addActorAt(0, testStack);
	testStack.setSize(container.stageWidth, container.stageHeight);
	testStack.add(testTable = new Table() {
		@Override
		public void act (float delta) {
			float time = GdxAI.getTimepiece().getTime();
			if (lastUpdateTime != time) {
				lastUpdateTime = time;
				super.act(GdxAI.getTimepiece().getDeltaTime());
			}
		}
	});
	testStack.layout();
}
 
Example 3
Source Project: talos   Source File: GlobalScopeModuleWrapper.java    License: Apache License 2.0 6 votes vote down vote up
protected VisSelectBox addSelectBox(Array<String> values) {
    Table slotRow = new Table();
    final VisSelectBox selectBox = new VisSelectBox();

    selectBox.setItems(values);

    selectBox.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            updateFromSelectBox();
        }
    });

    slotRow.add(selectBox).width(50).left().padBottom(4).padLeft(5).padRight(10);

    leftWrapper.add(slotRow).left().expandX();
    leftWrapper.row();

    return selectBox;
}
 
Example 4
Source Project: gdx-ai   Source File: SteeringTestBase.java    License: Apache License 2.0 6 votes vote down vote up
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);
	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);
}
 
Example 5
public Message(boolean addTapToContinueText) {
            super(Config.skin);
            setFillParent(true);
            align(Align.bottom);

            child = new Table();
            label = new LocLabel("");
            label.setWrap(true);
            label.setAlignment(Align.center);
            child.add(label).expandX().fillX().row();
            if (addTapToContinueText) {
//                child.add(new Image(Config.skin, "ui-creature-info-line")).width(Value.percentWidth(0.7f)).padTop(4).row();
                child.add(new LocLabel("tap-to-continue", TAP_TO_CONTINUE)).row();
            }

            add(child).expandX().fillX();
        }
 
Example 6
Source Project: dice-heroes   Source File: ArrowMessageNet.java    License: 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 7
@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 8
Source Project: bladecoder-adventure-engine   Source File: PropertyTable.java    License: Apache License 2.0 6 votes vote down vote up
public PropertyTable(Skin skin) {
	// super(skin);
	table = new Table(skin);
	this.skin = skin;
	top().left();
	table.top().left();

	table.add(new Label("Name", skin));
	table.add(new Label("Value", skin));
	table.setFillParent(true);

	fill();
	prefHeight(1000);

	setActor(table);
}
 
Example 9
Source Project: ingress-apk-mod   Source File: PortalUpgradeMod.java    License: Apache License 2.0 6 votes vote down vote up
public static void onStatsTableCreated(PortalUpgradeUi ui, Table t) {
    init(ui);

    Label.LabelStyle style = Mod.skin.get("portal-stats", Label.LabelStyle.class);
    final float den = Mod.displayMetrics.density;

    List<Cell> cells = new ArrayList<Cell>(t.getCells());
    t.clear();
    t.left();
    t.defaults().left();
    t.add((Actor) cells.get(1).getWidget()).padLeft(20 * den);
    t.add((Actor) cells.get(2).getWidget()).padLeft(8 * den);
    t.add((Actor) cells.get(3).getWidget()).padLeft(16 * den);
    t.add((Actor) cells.get(4).getWidget()).padLeft(8 * den);
    t.row();
    t.add((Actor) cells.get(7).getWidget()).padLeft(20 * den);
    t.add((Actor) cells.get(8).getWidget()).padLeft(8 * den);
    t.add(new Label("Dist.:", style)).padLeft(16 * den);
    t.add(distLabel = new Label("", style)).padLeft(8 * den);

    updateDistLabel(Mod.world.getPlayerModel().getPlayerLocation());
}
 
Example 10
Source Project: gdx-ai   Source File: SteeringTestBase.java    License: Apache License 2.0 6 votes vote down vote up
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);
	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);
}
 
Example 11
Source Project: gdx-soundboard   Source File: AddStateDialog.java    License: MIT License 6 votes vote down vote up
public AddStateDialog(final Stage stage, final Skin skin, final MusicEventManager eventManager) {

        super("Add State", skin);
        this.stage = stage;
        this.skin = skin;
        this.eventManager = eventManager;


        Table content = this.getContentTable();
        Label label = new Label("State name", skin);
        label.setAlignment(Align.left);
        content.add(label).left().fillX().expandX().row();

        eventName = new TextField("", skin);
        content.add(eventName).right().fillX().expandX().row();

        Table buttons = this.getButtonTable();
        buttons.defaults().fillX().expandX();
        
        this.button("Ok", true);
        this.button("Cancel", false);
        

        key(Keys.ENTER, true);
        key(Keys.ESCAPE, false);
    }
 
Example 12
Source Project: vis-ui   Source File: Toast.java    License: Apache License 2.0 5 votes vote down vote up
/** @param content table content, preferably instance of {@link ToastTable} */
public Toast (ToastStyle style, Table content) {
	this.style = style;
	this.contentTable = content;
	if (content instanceof ToastTable) {
		((ToastTable) content).setToast(this);
	}
	createMainTable();
}
 
Example 13
Source Project: gdx-smart-font   Source File: ExampleMain.java    License: MIT License 5 votes vote down vote up
@Override
public void create() {
	Gdx.app.setLogLevel(Application.LOG_DEBUG);
	SmartFontGenerator fontGen = new SmartFontGenerator();
	FileHandle exoFile = Gdx.files.local("LiberationMono-Regular.ttf");
	BitmapFont fontSmall = fontGen.createFont(exoFile, "exo-small", 24);
	BitmapFont fontMedium = fontGen.createFont(exoFile, "exo-medium", 48);
	BitmapFont fontLarge = fontGen.createFont(exoFile, "exo-large", 64);

	stage = new Stage();

	Label.LabelStyle smallStyle = new Label.LabelStyle();
	smallStyle.font = fontSmall;
	Label.LabelStyle mediumStyle = new Label.LabelStyle();
	mediumStyle.font = fontMedium;
	Label.LabelStyle largeStyle = new Label.LabelStyle();
	largeStyle.font = fontLarge;

	Label small = new Label("Small Font", smallStyle);
	Label medium = new Label("Medium Font", mediumStyle);
	Label large = new Label("Large Font", largeStyle);

	Table table = new Table();
	table.setFillParent(true);
	table.align(Align.center);
	stage.addActor(table);

	table.defaults().size(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 6);

	table.add(small).row();
	table.add(medium).row();
	table.add(large).row();
}
 
Example 14
Source Project: talos   Source File: CustomList.java    License: Apache License 2.0 5 votes vote down vote up
public void rebuild() {
    clearChildren();
    containers.clear();
    for(T item: items) {
        Table container = new Table();
        container.add(item).growX().pad(2f).padLeft(4f).padRight(4f);
        add(container).growX().row();
        containers.put(item, container);
    }

    add().expandY();
}
 
Example 15
Source Project: Entitas-Java   Source File: MenuState.java    License: MIT License 5 votes vote down vote up
@Override
public void loadResources() {
    assetsManager = engine.getManager(BaseAssetsManager.class);
    this.stage = new Stage();
    mainTable = new Table();
    mainTable.setFillParent(true);
    stage.clear();
    stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
    this.stage.addActor(mainTable);
    Gdx.input.setInputProcessor(stage);
    Gdx.app.log("Menu", "LoadResources");
}
 
Example 16
Source Project: talos   Source File: PropertyPanelContainer.java    License: Apache License 2.0 5 votes vote down vote up
public PropertyPanelContainer(Skin skin) {
    setSkin(skin);
    container = new Table();
    fakeContainer = new Table();
    scrollPane = new ScrollPane(fakeContainer);
    add(scrollPane).grow();

    fakeContainer.add(container).growX().row();
    fakeContainer.add().expandY();
}
 
Example 17
Source Project: xibalba   Source File: HudRenderer.java    License: MIT License 5 votes vote down vote up
private void showDeathDialog() {
  Table table = deathDialog.getContentTable();
  table.pad(0);
  table.add(new Label("YOU HAVE FAILED", Main.skin)).center().row();

  String depth = "[LIGHT_GRAY]You made it to depth[] " + playerDetails.lowestDepth;
  table.add(new Label(depth, Main.skin)).left().row();

  String hits = "[LIGHT_GRAY]You hit enemies[] " + playerDetails.totalHits
      + "[LIGHT_GRAY] times and missed[] " + playerDetails.totalMisses;
  table.add(new Label(hits, Main.skin)).left().row();

  String damage = "[LIGHT_GRAY]You did[] " + playerDetails.totalDamageDone
      + "[LIGHT_GRAY] damage, took[] " + playerDetails.totalDamageReceived
      + "[LIGHT_GRAY], and healed[] " + playerDetails.totalDamageHealed;
  table.add(new Label(damage, Main.skin)).left().row();

  String kills = "[LIGHT_GRAY]You killed[] "
      + playerDetails.totalKills + "[LIGHT_GRAY] enemies";
  table.add(new Label(kills, Main.skin)).left().row();

  deathDialog.getButtonTable().pad(5, 0, 0, 0);
  deathDialogShowing = true;
  deathDialog.show(stage);

  deathDialog.setPosition(
      deathDialog.getX(), deathDialog.getY() + (deathDialog.getY() / 2)
  );
}
 
Example 18
Source Project: xibalba   Source File: LoadingScreen.java    License: MIT License 5 votes vote down vote up
/**
 * Loading screen.
 *
 * @param main Instance of Main
 */
public LoadingScreen(Main main) {
  this.main = main;

  stage = new Stage(new FitViewport(960, 540));

  Table table = new Table();
  table.setFillParent(true);
  stage.addActor(table);

  label = new Label("", Main.skin);
  table.add(label);

  new Thread(() -> Gdx.app.postRunnable(this::loadAssets)).start();
}
 
Example 19
Source Project: gdx-ai   Source File: BulletSeekTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void create () {
	super.create();

	BulletEntity ground = world.add("ground", 0f, 0f, 0f);
	ground.setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(),
		0.25f + 0.5f * (float)Math.random(), 1f);
	ground.body.userData = "ground";

	BulletEntity characterBase = world.add("capsule", new Matrix4());

	character = new SteeringBulletEntity(characterBase);
	character.setMaxLinearSpeed(50);
	character.setMaxLinearAcceleration(200);

	BulletEntity targetBase = world.add("staticbox", new Matrix4().setToTranslation(new Vector3(5f, 1.5f, 5f)));
	targetBase.body.setCollisionFlags(targetBase.body.getCollisionFlags()
		| btCollisionObject.CollisionFlags.CF_NO_CONTACT_RESPONSE);
	target = new SteeringBulletEntity(targetBase);

	setNewTargetInputProcessor(target, new Vector3(0, 1.5f, 0));

	final Seek<Vector3> seekSB = new Seek<Vector3>(character, target);
	character.setSteeringBehavior(seekSB);

	Table detailTable = new Table(container.skin);

	detailTable.row();
	addMaxLinearAccelerationController(detailTable, character, 0, 2000, 100);

	detailTable.row();
	addSeparator(detailTable);

	detailTable.row();
	addMaxLinearSpeedController(detailTable, character, 0, 200, 1);

	detailWindow = createDetailWindow(detailTable);
}
 
Example 20
Source Project: RuinsOfRevenge   Source File: ScreenPause.java    License: MIT License 5 votes vote down vote up
public ScreenPause(final ResourceLoader resources, final RuinsOfRevenge game) {
	super(new Stage(), game);
	this.resources = resources;
	this.game = game;

	skin = resources.getSkin("uiskin");

	TextButton play = new TextButton("Continue Playing", skin);
	TextButton settings = new TextButton("Settings", skin);
	TextButton backToMM = new TextButton("Back to Main Menu", skin);

	play.addListener(continueListener);
	settings.addListener(settingsListener);
	backToMM.addListener(backToMMListener);

	table = new Table(skin);
	table.add(play).size(320, 64).space(8);
	table.row();
	table.add(settings).size(320, 64).space(8);
	table.row();
	table.add(backToMM).size(320, 64).space(8);
	table.setPosition(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
	stage.addActor(table);
	stage.addListener(new KeyUpListener() {
		@Override
		public boolean keyUp(InputEvent event, int keycode) {
			if (keycode == Config.get().key("escape"))
				game.popScreen();
			return false;
		}
	});
}
 
Example 21
Source Project: gdx-gltf   Source File: CollapsableUI.java    License: Apache License 2.0 5 votes vote down vote up
public CollapsableUI(Skin skin, String name, boolean visible) {
	toggle = new TextButton(name, skin, "toggle");
	toggle.setChecked(visible);
	add(toggle).row();
	optTable = new Table(skin);
	optCell = add();
	row();
	show(visible);
	toggle.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			show(toggle.isChecked());
		}
	});
}
 
Example 22
Source Project: uracer-kotd   Source File: UIUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static Table newTable () {
	Table t = new Table();
	if (debug) {
		t.debug();
	}
	return t;
}
 
Example 23
Source Project: Norii   Source File: PauseMenuUI.java    License: Apache License 2.0 5 votes vote down vote up
private void initVariables(Camera camera) {
	stage = new Stage(new ScreenViewport(camera));
	menuTable = new Table();
	menuTable.setDebug(false);
	menuTable.setFillParent(true);
	this.setVisible(false);
}
 
Example 24
Source Project: gdx-soundboard   Source File: Scene2dUtils.java    License: MIT License 5 votes vote down vote up
public static TextField addTextField(String labelText, Table parent, Skin skin){
    Label label = new Label(labelText, skin);
    label.setAlignment(Align.left);
    parent.add(label).left();

    TextField info = new TextField("", skin);
    parent.add(info).right().fillX().expandX().row();

    return info;
}
 
Example 25
Source Project: skin-composer   Source File: Core.java    License: MIT License 5 votes vote down vote up
public static void transition(Table table1, final Table table2, float transitionTime1, final float transitionTime2) {
    table1.addAction(Actions.sequence(Actions.fadeOut(transitionTime1), new Action() {
        @Override
        public boolean act(float delta) {
            table2.setColor(1, 1, 1, 0);
            table2.setTouchable(Touchable.disabled);
            
            root.clear();
            root.add(table2).grow();
            table2.addAction(Actions.sequence(Actions.fadeIn(transitionTime2), Actions.touchable(Touchable.childrenOnly)));
            return true;
        }
    }));
}
 
Example 26
Source Project: skin-composer   Source File: DialogLoading.java    License: 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 27
@Override protected Table getMessageTable() {
    Table result = new Table();
    result.align(Align.top);
    LocLabel label = new LocLabel(locKey);
    label.setWrap(true);
    label.setAlignment(Align.center);
    result.add(label).width(stage.getWidth() / 1.5f);
    return result;
}
 
Example 28
@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 29
@Override protected Table getMessageTable() {
    Table result = new Table();
    result.align(Align.bottom);
    LocLabel label = new LocLabel(locKey);
    label.setWrap(true);
    label.setAlignment(Align.center);
    result.add(label).width(stage.getWidth() / 1.5f);
    return result;
}
 
Example 30
Source Project: gdx-soundboard   Source File: FileChooser.java    License: MIT License 5 votes vote down vote up
@Override
public Dialog show(Stage stage, Action action) {
    final Table content = getContentTable();
    content.add(fileListLabel).top().left().expandX().fillX().row();
    content.add(new ScrollPane(fileList, skin)).size(300, 150).fill().expand().row();

    if (fileNameEnabled) {
        content.add(fileNameLabel).fillX().expandX().row();
        content.add(fileNameInput).fillX().expandX().row();
        stage.setKeyboardFocus(fileNameInput);
    }

    if (newFolderEnabled) {
        content.add(newFolderButton).fillX().expandX().row();
    }
    
    if(directoryBrowsingEnabled){
        fileList.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                final FileListItem selected = fileList.getSelected();
                if (selected.file.isDirectory()) {
                    changeDirectory(selected.file);
                }
            }
        });
    }

    this.stage = stage;
    changeDirectory(baseDir);
    return super.show(stage, action);
}