Search in sources :

Example 21 with ClickListener

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

the class NewGamePanel method updateAct.

@Override
public void updateAct(float delta) {
    final List<ScreenData> dataList = (List<ScreenData>) getUserObject();
    dataList.forEach(data -> {
        TextButton button = getMainMenuButton(data.getName());
        button.addListener(new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                if (choiceCallback != null) {
                    choiceCallback.accept(data);
                }
            }
        });
        add(button);
        row();
    });
    addEmptyRow(0, 30);
    back = getMainMenuButton("back");
    if (backListener != null) {
        back.addListener(backListener);
    }
    add(back);
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) List(java.util.List) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) SimpleClickListener(eidolons.libgdx.gui.SimpleClickListener) ScreenData(eidolons.libgdx.screens.ScreenData)

Example 22 with ClickListener

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

the class UnitViewFactory method create.

public static GridUnitView create(BattleFieldObject bfObj) {
    UnitViewOptions options = new UnitViewOptions(bfObj);
    GridUnitView view = new GridUnitView(options);
    if (VisionMaster.isLastSeenOn()) {
        LastSeenView lsv = new LastSeenView(options, view);
        view.setLastSeenView(lsv);
        new LastSeenTooltipFactory().add(lsv, bfObj);
    }
    view.setOutlinePathSupplier(() -> {
        OUTLINE_TYPE type = null;
        // if (bfObj instanceof Unit) {
        // if (!VisionManager.checkVisible(bfObj)) {
        // type = OUTLINE_TYPE.DARK_OUTLINE;
        // }
        // }
        // if (type == null)
        type = bfObj.getOutlineTypeForPlayer();
        if (type == null)
            return null;
        String path = Eidolons.game.getVisionMaster().getVisibilityMaster().getImagePath(type, bfObj);
        return (path);
    });
    view.createHpBar((new ResourceSourceImpl(bfObj)));
    if (bfObj instanceof Unit) {
        view.getInitiativeQueueUnitView().getHpBar().setTeamColor(options.getTeamColor());
    }
    view.getHpBar().setTeamColor(options.getTeamColor());
    final UnitViewTooltip tooltip = new UnitViewTooltip(view);
    tooltip.setUserObject(UnitViewTooltipFactory.create(bfObj));
    view.setToolTip(tooltip);
    ClickListener listener = createListener(bfObj);
    view.addListener(listener);
    view.getInitiativeQueueUnitView().addListener(listener);
    return view;
}
Also used : OUTLINE_TYPE(main.content.enums.rules.VisionEnums.OUTLINE_TYPE) ResourceSourceImpl(eidolons.libgdx.gui.panels.dc.unitinfo.datasource.ResourceSourceImpl) LastSeenTooltipFactory(eidolons.libgdx.gui.tooltips.LastSeenTooltipFactory) Unit(eidolons.entity.obj.unit.Unit) UnitViewTooltip(eidolons.libgdx.gui.tooltips.UnitViewTooltip) BattleClickListener(eidolons.libgdx.bf.mouse.BattleClickListener) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 23 with ClickListener

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

the class RadialManager method addSimpleTooltip.

public static void addSimpleTooltip(RadialValueContainer el, String name) {
    ValueTooltip tooltip = new ValueTooltip();
    tooltip.setUserObject(Arrays.asList(new ValueContainer(name, "")));
    for (com.badlogic.gdx.scenes.scene2d.EventListener sub : el.getListeners()) {
        if (!(sub instanceof ClickListener))
            el.removeListener(sub);
    }
    el.addListener(tooltip.getController());
}
Also used : ValueTooltip(eidolons.libgdx.gui.tooltips.ValueTooltip) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 24 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener 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 25 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener 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)

Aggregations

ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)74 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)72 Stage (com.badlogic.gdx.scenes.scene2d.Stage)39 Texture (com.badlogic.gdx.graphics.Texture)26 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)26 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)24 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)23 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)23 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)23 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)22 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)21 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)18 Actor (com.badlogic.gdx.scenes.scene2d.Actor)17 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)12 Button (com.badlogic.gdx.scenes.scene2d.ui.Button)7 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)7 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)6 Touchpad (com.badlogic.gdx.scenes.scene2d.ui.Touchpad)6 Texto (mx.itesm.another_monkey_paradox.Utils.Texto)6 Random (java.util.Random)5