Search in sources :

Example 91 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent in project Eidolons by IDemiurge.

the class BaseView method init.

public void init(TextureRegion portraitTexture, String path) {
    portrait = initPortrait(portraitTexture, path);
    addActor(portrait);
    addListener(new BattleClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (button == Input.Buttons.LEFT) {
                event.handle();
                if (isAlt())
                    try {
                        if (DefaultActionHandler.leftClickActor(event, getX(), getY()))
                            return;
                    } catch (Exception e) {
                        main.system.ExceptionMaster.printStackTrace(e);
                    }
                GuiEventManager.trigger(CALL_BLUE_BORDER_ACTION, BaseView.this);
            }
        }
    });
}
Also used : InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) BattleClickListener(eidolons.libgdx.bf.mouse.BattleClickListener)

Example 92 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent in project Eidolons by IDemiurge.

the class ContainerPanel method initListeners.

private void initListeners() {
    clear();
    TextureRegion textureRegion = new TextureRegion(getOrCreateR("UI/components/inventory_background.png"));
    TextureRegionDrawable drawable = new TextureRegionDrawable(textureRegion);
    setBackground(drawable);
    inventorySlotsPanel = new InventorySlotsPanel();
    containerSlotsPanel = new InventorySlotsPanel();
    portrait = new Image();
    portrait.setSize(GridMaster.CELL_W, GridMaster.CELL_H);
    addElement(portrait).top().height(GridMaster.CELL_H).width(GridMaster.CELL_W);
    row();
    addElement(inventorySlotsPanel).height(340).pad(20, 20, 0, 20).top().expand(1, 0);
    row();
    addElement(containerSlotsPanel).height(340).pad(20, 30, 0, 20).top().expand(1, 0);
    // initListeners();
    final TablePanel<Actor> lower = new TablePanel<>();
    addElement(lower).pad(0, 30, 20, 20);
    takeAllButton = lower.addElement(new TextButton("Take All", StyleHolder.getDefaultTextButtonStyle())).fill(false).expand(0, 0).right().pad(20, 10, 20, 10).size(50, 50);
    GuiEventManager.bind(SHOW_LOOT_PANEL, (obj) -> {
        final Pair<InventoryDataSource, ContainerDataSource> param = (Pair<InventoryDataSource, ContainerDataSource>) obj.get();
        if (param == null) {
            close();
        } else {
            open();
            inventorySlotsPanel.setUserObject(param.getKey());
            containerSlotsPanel.setUserObject(param.getValue());
            if (containerSlotsPanel.getListeners().size > 0)
                inventorySlotsPanel.addListener(containerSlotsPanel.getListeners().first());
            TextButton button = (TextButton) takeAllButton.getActor();
            button.getListeners().clear();
            final ContainerDataSource source = param.getValue();
            button.addListener(new ClickListener() {

                @Override
                public void clicked(InputEvent event, float x, float y) {
                    source.getHandler().takeAllClicked();
                }
            });
            portrait.setDrawable(TextureCache.getOrCreateTextureRegionDrawable(StringMaster.getAppendedImageFile(source.getHandler().getContainer().getImagePath(), ContainerMaster.OPEN)));
        }
    });
    addListener(new InputListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.stop();
            return true;
        }

        @Override
        public boolean mouseMoved(InputEvent event, float x, float y) {
            event.stop();
            return true;
        }
    });
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) InventoryDataSource(eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource) InventorySlotsPanel(eidolons.libgdx.gui.panels.dc.inventory.InventorySlotsPanel) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) TablePanel(eidolons.libgdx.gui.panels.TablePanel) Pair(org.apache.commons.lang3.tuple.Pair)

Example 93 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent in project Eidolons by IDemiurge.

the class OverlayTextPanel method initScrollPanel.

@Override
protected void initScrollPanel() {
    super.initScrollPanel();
    scrollPanel.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return super.touchDown(event, x, y, pointer, button);
        }
    });
}
Also used : InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 94 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent in project Eidolons by IDemiurge.

the class OutcomePanel method handle.

@Override
public boolean handle(Event e) {
    if (!(e instanceof InputEvent))
        return true;
    InputEvent event = ((InputEvent) e);
    if (event.getType() != Type.touchDown)
        return true;
    if (getActions().size > 0)
        return true;
    Actor actor = event.getTarget();
    if (actor instanceof Label) {
        if (actor.getParent() instanceof TextButton) {
            ActorMaster.addMoveToAction(this, getX(), GdxMaster.getHeight(), 1.5f);
            // ActorMaster.addRemoveAfter(this);
            final Boolean exit_continue_next = doneButton.getActor().getLabel() == actor ? null : exitButton.getActor().getLabel() == actor;
            // public boolean act(float delta) {
            if (exit_continue_next == null) {
                if (!ExplorationMaster.isExplorationOn())
                    Eidolons.getGame().getMaster().nextLevel();
                if (!BooleanMaster.isTrue(outcome))
                    Eidolons.getGame().getMetaMaster().getBattleMaster().getOutcomeManager().restart();
                else
                    Eidolons.getGame().getMetaMaster().getBattleMaster().getOutcomeManager().next();
            } else if (exit_continue_next) {
                // if (DialogMaster.confirm("Must you really go?.."))
                if (CoreEngine.isMacro()) {
                    GuiEventManager.trigger(GuiEventType.BATTLE_FINISHED);
                } else {
                    Gdx.app.exit();
                }
            // else DialogMaster.inform("Glad you're still with us! :)");
            } else {
                WaitMaster.receiveInput(WAIT_OPERATIONS.GAME_FINISHED, false);
            // DialogMaster.inform("Feel free to roam around, until next round...))");
            }
            remove();
            return true;
        // }
        // });
        }
    }
    return false;
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 95 with InputEvent

use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.

the class DialogDrawables method refreshDrawableDisplay.

private void refreshDrawableDisplay() {
    contentGroup.clear();
    if (drawables.size == 0) {
        Label label = new Label("No drawables have been added!", getSkin());
        contentGroup.addActor(label);
    }
    for (DrawableData drawable : drawables) {
        Button drawableButton;
        if (property != null || customProperty != null) {
            drawableButton = new Button(getSkin(), "color-base");
            drawableButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    result(drawable);
                    hide();
                }
            });
            drawableButton.addListener(main.getHandListener());
        } else {
            drawableButton = new Button(getSkin(), "color-base-static");
        }
        contentGroup.addActor(drawableButton);
        Table table = new Table();
        drawableButton.add(table).width(sizes[MathUtils.floor(zoomSlider.getValue())]).height(sizes[MathUtils.floor(zoomSlider.getValue())]);
        ClickListener fixDuplicateTouchListener = new ClickListener() {

            @Override
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                event.setBubbles(false);
                return super.touchDown(event, x, y, pointer, button);
            }
        };
        // color wheel
        if (!drawable.customized && !drawable.tiled) {
            Button button = new Button(getSkin(), "colorwheel");
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    newTintedDrawable(drawable);
                    event.setBubbles(false);
                }
            });
            button.addListener(fixDuplicateTouchListener);
            if (property == null && customProperty == null) {
                button.addListener(main.getHandListener());
            }
            table.add(button);
            TextTooltip toolTip = new TextTooltip("New Tinted Drawable", main.getTooltipManager(), getSkin());
            button.addListener(toolTip);
        } else {
            table.add();
        }
        // swatches
        if (!drawable.customized && !drawable.tiled) {
            Button button = new Button(getSkin(), "swatches");
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    colorSwatchesDialog(drawable);
                    event.setBubbles(false);
                }
            });
            button.addListener(fixDuplicateTouchListener);
            if (property == null && customProperty == null) {
                button.addListener(main.getHandListener());
            }
            table.add(button);
            TextTooltip toolTip = new TextTooltip("Tinted Drawable from Colors", main.getTooltipManager(), getSkin());
            button.addListener(toolTip);
        } else {
            table.add();
        }
        // tiles button (NOT FOR TINTS OR CUSTOM DRAWABLES)
        if (!drawable.customized && drawable.tint == null && drawable.tintName == null) {
            ;
            Button button = new Button(getSkin(), "tiles");
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    tiledDrawableDialog(drawable);
                    event.setBubbles(false);
                }
            });
            button.addListener(fixDuplicateTouchListener);
            if (property == null && customProperty == null) {
                button.addListener(main.getHandListener());
            }
            table.add(button);
            TextTooltip toolTip = new TextTooltip("Tiled Drawable", main.getTooltipManager(), getSkin());
            button.addListener(toolTip);
        } else {
            table.add();
        }
        // tiled settings
        if (drawable.tiled) {
            Button button = new Button(getSkin(), "settings-small");
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    tiledDrawableSettingsDialog(drawable);
                    event.setBubbles(false);
                }
            });
            button.addListener(fixDuplicateTouchListener);
            if (property == null && customProperty == null) {
                button.addListener(main.getHandListener());
            }
            table.add(button);
            TextTooltip toolTip = new TextTooltip("Tiled Drawable Settings", main.getTooltipManager(), getSkin());
            button.addListener(toolTip);
        } else // rename (ONLY FOR TINTS)
        if (drawable.tint != null || drawable.tintName != null) {
            Button button = new Button(getSkin(), "settings-small");
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    renameDrawableDialog(drawable);
                    event.setBubbles(false);
                }
            });
            button.addListener(fixDuplicateTouchListener);
            if (property == null && customProperty == null) {
                button.addListener(main.getHandListener());
            }
            table.add(button);
            TextTooltip toolTip = new TextTooltip("Rename Tinted Drawable", main.getTooltipManager(), getSkin());
            button.addListener(toolTip);
        } else // settings for custom drawables
        if (drawable.customized) {
            Button button = new Button(getSkin(), "settings-small");
            button.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                    renameCustomDrawableDialog(drawable);
                    event.setBubbles(false);
                }
            });
            button.addListener(fixDuplicateTouchListener);
            if (property == null && customProperty == null) {
                button.addListener(main.getHandListener());
            }
            table.add(button);
            TextTooltip toolTip = new TextTooltip("Rename Custom Drawable", main.getTooltipManager(), getSkin());
            button.addListener(toolTip);
        } else {
            table.add();
        }
        // delete
        Button button = new Button(getSkin(), "delete-small");
        button.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeListener.ChangeEvent event, Actor actor) {
                deleteDrawable(drawable);
                event.setBubbles(false);
            }
        });
        button.addListener(fixDuplicateTouchListener);
        if (property == null && customProperty == null) {
            button.addListener(main.getHandListener());
        }
        table.add(button).expandX().right();
        TextTooltip toolTip = new TextTooltip("Delete Drawable", main.getTooltipManager(), getSkin());
        button.addListener(toolTip);
        // preview
        table.row();
        Container bg = new Container();
        bg.setClip(true);
        bg.setBackground(getSkin().getDrawable("white"));
        bg.setColor(drawable.bgColor);
        Image image = new Image(drawablePairs.get(drawable));
        if (MathUtils.isZero(zoomSlider.getValue())) {
            image.setScaling(Scaling.fit);
            bg.fill(false);
        } else {
            image.setScaling(Scaling.stretch);
            bg.fill();
        }
        bg.setActor(image);
        table.add(bg).colspan(5).grow();
        // name
        table.row();
        Label label = new Label(drawable.name, getSkin());
        label.setEllipsis("...");
        label.setEllipsis(true);
        label.setAlignment(Align.center);
        table.add(label).colspan(5).growX().width(sizes[MathUtils.floor(zoomSlider.getValue())]);
        // Tooltip
        toolTip = new TextTooltip(drawable.name, main.getTooltipManager(), getSkin());
        label.addListener(toolTip);
    }
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) DrawableData(com.ray3k.skincomposer.data.DrawableData) Container(com.badlogic.gdx.scenes.scene2d.ui.Container) TextTooltip(com.badlogic.gdx.scenes.scene2d.ui.TextTooltip) Button(com.badlogic.gdx.scenes.scene2d.ui.Button) TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)358 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)183 Actor (com.badlogic.gdx.scenes.scene2d.Actor)174 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)144 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)110 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)109 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)86 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)53 Stage (com.badlogic.gdx.scenes.scene2d.Stage)49 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)47 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)45 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)35 Texture (com.badlogic.gdx.graphics.Texture)34 Spinner (com.ray3k.stripe.Spinner)32 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)31 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)29 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)26 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)25 StyleSelectorPopTable (com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable)25 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)22