Search in sources :

Example 76 with ClickListener

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

the class MapGuiStage method setMainPartyMarker.

public void setMainPartyMarker(PartyActor mainPartyMarker) {
    this.mainPartyMarker = mainPartyMarker;
    mainPartyMarker.setMarker(true);
    addActor(mainPartyMarker);
    mainPartyMarker.clearListeners();
    mainPartyMarker.hover();
    mainPartyMarker.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            MapScreen.getInstance().centerCamera();
            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 77 with ClickListener

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

the class MapTimePanel method init.

public void init() {
    setSize((355), (203));
    speedUpBtn = new TextButtonX("", STD_BUTTON.SPEED_UP, () -> {
        MacroGame.getGame().getLoop().getTimeMaster().speedUp();
    });
    speedDownBtn = new TextButtonX("", STD_BUTTON.SPEED_DOWN, () -> {
        MacroGame.getGame().getLoop().getTimeMaster().speedDown();
    });
    pauseButton = new TextButtonX("", STD_BUTTON.PAUSE, () -> {
        MacroGame.getGame().getLoop().togglePaused();
        MacroGame.getGame().getLoop().getTimeMaster().resetSpeed();
    });
    float moonSize = GdxMaster.adjustSize(SIZE);
    addListener(new DynamicTooltip(() -> getDateString()).getController());
    // display DatePanel?
    for (MOON moon : MOON.values()) {
        MoonActor container = new MoonActor(moon);
        moonMap.put(moon, container);
    }
    float sunSize = moonSize * 2f;
    sun = new SunActor(false);
    sun.setSize(sunSize, sunSize);
    sun.setVisible(false);
    undersun = new SunActor(true);
    undersun.setSize(sunSize, sunSize);
    undersun.setVisible(false);
    timeLabel = new Label("", StyleHolder.getSizedLabelStyle(FONT.NYALA, 18));
    addActor(weave);
    addActor(mainCircle);
    addActor(sun);
    addActor(undersun);
    addActor(labelBg = new Image(TextureCache.getOrCreateR(getPath() + "label bg.png")));
    addActor(pauseButton);
    addActor(speedUpBtn);
    addActor(speedDownBtn);
    addActor(timeLabel);
    initPositions();
    GuiEventManager.bind(MapEvent.TIME_CHANGED, p -> {
        update((DAY_TIME) p.get());
    });
    sun.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            MacroGame.getGame().getLoop().getTimeMaster().newMonth();
            return super.touchDown(event, x, y, pointer, button);
        }
    });
    undersun.addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            MacroGame.getGame().getLoop().getTimeMaster().newMonth();
            return super.touchDown(event, x, y, pointer, button);
        }
    });
// adjustSizes();
}
Also used : TextButtonX(eidolons.libgdx.gui.generic.btn.TextButtonX) MOON(eidolons.libgdx.screens.map.ui.time.MapTimePanel.MOON) DynamicTooltip(eidolons.libgdx.gui.tooltips.DynamicTooltip) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 78 with ClickListener

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

the class InventoryValueContainer method init.

@Override
protected void init(TextureRegion texture, String name, String value) {
    super.init(texture, "", "");
    addListener(new ValueTooltip(name).getController());
    addListener(new ClickListener(-1) {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            final int tapCount = this.getTapCount();
            final boolean isRightClicked = event.getButton() == Input.Buttons.RIGHT;
            final boolean isAltPressed = Gdx.input.isKeyPressed(Input.Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Input.Keys.ALT_RIGHT);
            handler.cellClicked(cellType, tapCount, isRightClicked, isAltPressed, entity);
            event.stop();
        }
    });
}
Also used : ValueTooltip(eidolons.libgdx.gui.tooltips.ValueTooltip) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 79 with ClickListener

use of com.badlogic.gdx.scenes.scene2d.utils.ClickListener in project commons-gdx by gemserk.

the class Actors method twoOptionsDialog.

public static Actor twoOptionsDialog(String[] texts, final DialogListener dialogListener, String titleText, String firstOption, String secondOption, Skin skin) {
    Window window = new Window(titleText, skin);
    window.setMovable(false);
    TextButton firstOptionButton = new TextButton(firstOption, skin);
    TextButton secondOptionButton = new TextButton(secondOption, skin);
    firstOptionButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            dialogListener.optionSelected(0);
        }
    });
    secondOptionButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            dialogListener.optionSelected(1);
        }
    });
    window.defaults().spaceBottom(10);
    window.row().fill().expandX();
    for (int i = 0; i < texts.length; i++) {
        window.row().padLeft(20);
        Label label = new Label(texts[i], skin);
        label.setWrap(true);
        window.add(label).align(Align.left).colspan(2).fillX();
    }
    window.row().fill().expandX();
    window.add(firstOptionButton).align(Align.center).padLeft(20).padRight(20).expandX();
    window.add(secondOptionButton).align(Align.center).padLeft(20).padRight(20).expandX();
    ScrollPane scrollPane = new ScrollPane(window);
    scrollPane.setWidth(Gdx.graphics.getWidth() * 0.95f);
    scrollPane.setHeight(Gdx.graphics.getHeight() * 0.95f);
    scrollPane.setX(Gdx.graphics.getWidth() * 0.5f - scrollPane.getWidth() * 0.5f);
    scrollPane.setY(Gdx.graphics.getHeight() * 0.5f - scrollPane.getHeight() * 0.5f);
    return scrollPane;
}
Also used : Window(com.badlogic.gdx.scenes.scene2d.ui.Window) TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 80 with ClickListener

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

the class DialogTenPatchAnimation method refreshFrames.

public void refreshFrames(Array<Integer> selectedIndexes) {
    Table table = findActor("scroll-table");
    table.clear();
    buttonGroup.clear();
    var i = 0;
    for (var region : drawableDatas) {
        var 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);
            }
        };
        var button = new Button(skin, "toggle");
        button.setName("button");
        button.setUserObject(region);
        button.setProgrammaticChangeEvents(false);
        table.add(button).size(150, 200).space(5);
        buttonGroup.add(button);
        button.addListener(handListener);
        final var check = new Button(skin, "check");
        check.setName("check");
        check.setProgrammaticChangeEvents(false);
        button.add(check).uniform();
        check.setTouchable(Touchable.disabled);
        button.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                var buttons = buttonGroup.getButtons();
                if (Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Input.Keys.SHIFT_RIGHT)) {
                    var allChecked = buttonGroup.getAllChecked();
                    allChecked.removeValue(button, false);
                    if (allChecked.size > 0) {
                        int index = buttons.indexOf(button, false);
                        int high = buttons.indexOf(allChecked.peek(), false);
                        int low = buttons.indexOf(allChecked.first(), false);
                        for (var button : buttons) {
                            button.setChecked(false);
                            Button check = button.findActor("check");
                            check.setChecked(false);
                        }
                        for (int i = Math.min(index, lastClicked); i <= Math.max(index, lastClicked); i++) {
                            var button = buttons.get(i);
                            button.setChecked(true);
                            Button check = button.findActor("check");
                            check.setChecked(true);
                        }
                    }
                } else if (!Gdx.input.isKeyPressed(Input.Keys.CONTROL_LEFT) && !Gdx.input.isKeyPressed(Input.Keys.CONTROL_RIGHT)) {
                    for (var button : buttons) {
                        Button check = button.findActor("check");
                        check.setChecked(false);
                        button.setChecked(false);
                    }
                    button.setChecked(true);
                }
                check.setChecked(button.isChecked());
                lastClicked = buttons.indexOf(button, false);
            }
        });
        var label = new Label(Integer.toString(i++), skin, "white");
        button.add(label).expandX();
        button.add().uniform();
        button.row();
        Image image = new Image(atlasData.getDrawablePairs().get(region));
        image.setScaling(Scaling.fit);
        button.add(image).colspan(3).expand();
        button.row();
        label = new Label(region.name, skin, "white");
        label.setAlignment(Align.center);
        label.setEllipsis("...");
        button.add(label).colspan(3).width(125f);
        var textTooltip = new TextTooltip(region.name, tooltipManager, skin);
        label.addListener(textTooltip);
    }
    Button firstButton = null;
    Button lastButton = null;
    for (var index : selectedIndexes) {
        var button = buttonGroup.getButtons().get(index);
        Button check = button.findActor("check");
        check.setChecked(true);
        button.setChecked(true);
        if (firstButton == null)
            firstButton = button;
        lastButton = button;
    }
    ScrollPane scrollPane = findActor("scroll-pane");
    scrollPane.layout();
    table.layout();
    if (firstButton != null) {
        scrollPane.scrollTo(firstButton.getX(), firstButton.getY(), lastButton.getX() - firstButton.getX() + lastButton.getWidth(), firstButton.getHeight());
    }
}
Also used : ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

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