Search in sources :

Example 6 with VisTextButton

use of com.kotcrab.vis.ui.widget.VisTextButton in project HyperLap2D by rednblackgames.

the class ArrayActionBoxProducer method addPart.

private void addPart(Skin skin, GraphBoxImpl<ActionFieldType> graphBox) {
    Map<String, GraphNodeInput<ActionFieldType>> inputs = graphBox.getConfiguration().getNodeInputs();
    VisTextButton addButton = StandardWidgetsFactory.createTextButton("+ Add Pin");
    VisTextButton removeButton = StandardWidgetsFactory.createTextButton("- Remove Pin");
    removeButton.setDisabled(inputs.size() <= 2);
    addButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            addPin(skin, graphBox);
            addButton.fire(new GraphChangedEvent(true, false));
            if (inputs.size() > 2) {
                removeButton.setDisabled(false);
            }
        }
    });
    addButton.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.cancel();
            return true;
        }
    });
    GraphBoxPartImpl<ActionFieldType> addPart = new GraphBoxPartImpl<>(addButton, null);
    graphBox.addHeaderGraphBoxPart(addPart);
    removeButton.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.cancel();
            return true;
        }
    });
    removeButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            Map<String, GraphNodeInput<ActionFieldType>> inputs = graphBox.getConfiguration().getNodeInputs();
            GraphNodeInput<ActionFieldType> n = inputs.get("action" + (inputs.size() - 1));
            inputs.remove(n.getFieldId());
            graphBox.removeGraphBoxPart(inputs.size());
            graphBox.invalidate();
            addButton.fire(new GraphChangedEvent(true, false));
            if (inputs.size() == 2) {
                removeButton.setDisabled(true);
            }
        }
    });
    GraphBoxPartImpl<ActionFieldType> removePart = new GraphBoxPartImpl<>(removeButton, null);
    graphBox.addFooterGraphBoxPart(removePart);
    graphBox.setSerializeCallback(object -> {
        object.put("pins", String.valueOf(inputs.size()));
    });
}
Also used : VisTextButton(com.kotcrab.vis.ui.widget.VisTextButton) GraphChangedEvent(games.rednblack.editor.graph.GraphChangedEvent) GraphBoxPartImpl(games.rednblack.editor.graph.GraphBoxPartImpl) ActionFieldType(games.rednblack.editor.graph.actions.ActionFieldType) GraphNodeInput(games.rednblack.editor.graph.data.GraphNodeInput) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) HashMap(java.util.HashMap) Map(java.util.Map) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 7 with VisTextButton

use of com.kotcrab.vis.ui.widget.VisTextButton in project vis-ui by kotcrab.

the class ColorPicker method createButtons.

private VisTable createButtons() {
    ButtonBar buttonBar = new ButtonBar();
    buttonBar.setIgnoreSpacing(true);
    buttonBar.setButton(ButtonType.LEFT, restoreButton = new VisTextButton(RESTORE.get()));
    buttonBar.setButton(ButtonType.OK, okButton = new VisTextButton(OK.get()));
    buttonBar.setButton(ButtonType.CANCEL, cancelButton = new VisTextButton(CANCEL.get()));
    return buttonBar.createTable();
}
Also used : VisTextButton(com.kotcrab.vis.ui.widget.VisTextButton) ButtonBar(com.kotcrab.vis.ui.widget.ButtonBar)

Example 8 with VisTextButton

use of com.kotcrab.vis.ui.widget.VisTextButton in project talos by rockbite.

the class ParticleControlTest method create.

@Override
public void create() {
    orthographicCamera = new OrthographicCamera();
    float width = 2000f;
    float aspect = (float) Gdx.graphics.getWidth() / (float) Gdx.graphics.getHeight();
    orthographicCamera.setToOrtho(false, width, width / aspect);
    shapeRenderer = new ShapeRenderer();
    batch = new SpriteBatch();
    particleRenderer = new SpriteBatchParticleRenderer(batch);
    cameraController = new CameraController(orthographicCamera);
    ParticleEffectDescriptor descriptor = new ParticleEffectDescriptor();
    TextureAtlas atlas = new TextureAtlas();
    atlas.addRegion("fire", new TextureRegion(new TextureRegion(new Texture(Gdx.files.internal("fire.png")))));
    descriptor.setAssetProvider(new TestAssetProvider(atlas));
    descriptor.load(Gdx.files.internal("test.p"));
    particleEffectInstance = descriptor.createEffectInstance();
    particleEffectInstance.loopable = true;
    stage = new Stage();
    VisUI.load();
    VisTextButton start = new VisTextButton("Start/Resume");
    VisTextButton pause = new VisTextButton("Pause");
    VisTextButton restart = new VisTextButton("Restart");
    VisTextButton allowCompletion = new VisTextButton("Allow Completion");
    start.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            particleEffectInstance.resume();
        }
    });
    pause.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            particleEffectInstance.pause();
        }
    });
    restart.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            particleEffectInstance.restart();
        }
    });
    allowCompletion.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            particleEffectInstance.allowCompletion();
        }
    });
    Table table = new Table();
    table.setFillParent(true);
    table.defaults().pad(10).top().left();
    table.top().left();
    table.add(start);
    table.row();
    table.add(pause);
    table.row();
    table.add(restart);
    table.row();
    table.add(allowCompletion);
    stage.addActor(table);
    Gdx.input.setInputProcessor(new InputMultiplexer(stage, cameraController));
}
Also used : VisTextButton(com.kotcrab.vis.ui.widget.VisTextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) CameraController(com.talosvfx.talos.runtime.test.utils.CameraController) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) TestAssetProvider(com.talosvfx.talos.runtime.test.utils.TestAssetProvider) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) ParticleEffectDescriptor(com.talosvfx.talos.runtime.ParticleEffectDescriptor) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) Stage(com.badlogic.gdx.scenes.scene2d.Stage) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) SpriteBatchParticleRenderer(com.talosvfx.talos.runtime.render.SpriteBatchParticleRenderer)

Example 9 with VisTextButton

use of com.kotcrab.vis.ui.widget.VisTextButton in project HyperLap2D by rednblackgames.

the class UIPolygonComponentProperties method initView.

public void initView() {
    mainTable.clear();
    verticesCountLbl = new VisLabel("", Align.left);
    copyBtn = new VisTextButton("Copy");
    pasteBtn = new VisTextButton("Paste");
    openEndedCheckbox = StandardWidgetsFactory.createCheckBox("Open Ended");
    mainTable.add(new VisLabel("Vertices: ", Align.left)).left().padRight(3);
    mainTable.add(verticesCountLbl).left().width(67);
    mainTable.add(copyBtn).right().padRight(4);
    mainTable.add(pasteBtn).right().padRight(4);
    mainTable.row();
    mainTable.add(openEndedCheckbox).left().colspan(4).padTop(5).row();
    initListeners();
}
Also used : VisTextButton(com.kotcrab.vis.ui.widget.VisTextButton) VisLabel(com.kotcrab.vis.ui.widget.VisLabel)

Example 10 with VisTextButton

use of com.kotcrab.vis.ui.widget.VisTextButton in project HyperLap2D by rednblackgames.

the class MainPanel method initPreView.

private void initPreView() {
    previewTable.clear();
    previewWidget = new PreviewWidget();
    previewWidget.setHeight(205);
    previewTable.add(previewWidget).width(200).height(205).top();
    previewTable.row();
    previewWidget.update((TextureAtlas.AtlasRegion) texture, ((TextureAtlas.AtlasRegion) texture).findValue("split"));
    VisLabel label = new VisLabel("Note: after saving, your \n scene will reload to \n apply changes.");
    label.setAlignment(Align.center);
    previewTable.add(label).pad(10).fillY().expandY();
    previewTable.row();
    VisTextButton saveBtn = new VisTextButton("apply and save");
    previewTable.add(saveBtn).pad(5);
    previewTable.row();
    saveBtn.addListener(new ClickListener() {

        public void clicked(InputEvent event, float x, float y) {
            facade.sendNotification(SAVE_CLICKED);
        }
    });
}
Also used : VisTextButton(com.kotcrab.vis.ui.widget.VisTextButton) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) VisLabel(com.kotcrab.vis.ui.widget.VisLabel) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

VisTextButton (com.kotcrab.vis.ui.widget.VisTextButton)12 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)8 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)8 VisLabel (com.kotcrab.vis.ui.widget.VisLabel)3 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)2 Actor (com.badlogic.gdx.scenes.scene2d.Actor)2 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)2 Array (com.badlogic.gdx.utils.Array)2 VisTable (com.kotcrab.vis.ui.widget.VisTable)2 AttributeVO (games.rednblack.editor.plugin.tiled.data.AttributeVO)2 CategoryVO (games.rednblack.editor.plugin.tiled.data.CategoryVO)2 Category (games.rednblack.editor.plugin.tiled.view.Category)2 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)1 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1 Texture (com.badlogic.gdx.graphics.Texture)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)1 Vector2 (com.badlogic.gdx.math.Vector2)1 Stage (com.badlogic.gdx.scenes.scene2d.Stage)1