Search in sources :

Example 1 with BattleClickListener

use of eidolons.libgdx.bf.mouse.BattleClickListener in project Eidolons by IDemiurge.

the class GridPanel method init.

public GridPanel init(DequeImpl<BattleFieldObject> units) {
    this.viewMap = new HashMap<>();
    emptyImage = TextureCache.getOrCreateR(getCellImagePath());
    cornerRegion = TextureCache.getOrCreateR(gridCornerElementPath);
    cells = new GridCellContainer[cols][rows];
    int rows1 = rows - 1;
    for (int x = 0; x < cols; x++) {
        for (int y = 0; y < rows; y++) {
            cells[x][y] = new GridCellContainer(emptyImage, x, rows1 - y);
            cells[x][y].setX(x * GridMaster.CELL_W);
            cells[x][y].setY(y * GridMaster.CELL_H);
            addActor(cells[x][y].init());
            checkAddBorder(x, y);
        }
    }
    if (OptionsMaster.getGraphicsOptions().getBooleanValue(GRAPHIC_OPTION.SPRITE_CACHE_ON))
        TextureManager.addCellsToCache(cols, rows);
    addActor(new CellBorderManager());
    bindEvents();
    createUnitsViews(units);
    setHeight(cells[0][0].getHeight() * rows);
    setWidth(cells[0][0].getWidth() * cols);
    addListener(new BattleClickListener() {

        @Override
        public boolean mouseMoved(InputEvent event, float x, float y) {
            GridPanel.this.getStage().setScrollFocus(GridPanel.this);
            return false;
        }

        @Override
        public boolean touchDown(InputEvent e, float x, float y, int pointer, int button) {
            // return PhaseAnimator.getInstance().checkAnimClicked(x, y, pointer, button);
            return false;
        }
    });
    addActor(overlayManager = new OverlaysManager(this));
    addActor(animMaster = AnimMaster.getInstance());
    animMaster.bindEvents();
    if (AnimationConstructor.isPreconstructAllOnGameInit())
        units.forEach(unit -> {
            if (unit instanceof Unit)
                animMaster.getConstructor().preconstructAll((Unit) unit);
        });
    if (fpsDebug) {
        fpsLabel = new Label("0", StyleHolder.getDefaultLabelStyle());
        addActor(fpsLabel);
        fpsLabel.setAlignment(Align.topLeft);
    }
    return this;
}
Also used : StrPathBuilder(main.system.auxiliary.StrPathBuilder) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) LastSeenMaster(eidolons.game.battlecraft.logic.battlefield.vision.LastSeenMaster) GuiEventType(main.system.GuiEventType) MapMaster(main.system.auxiliary.data.MapMaster) Entrance(eidolons.game.module.dungeoncrawl.dungeon.Entrance) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) DungeonScreen(eidolons.libgdx.screens.DungeonScreen) Ref(main.entity.Ref) Pair(org.apache.commons.lang3.tuple.Pair) Vector2(com.badlogic.gdx.math.Vector2) GdxMaster(eidolons.libgdx.GdxMaster) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) OptionsMaster(eidolons.system.options.OptionsMaster) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) HpBar(eidolons.libgdx.bf.overlays.HpBar) OUTLINE_TYPE(main.content.enums.rules.VisionEnums.OUTLINE_TYPE) MoveAnimation(eidolons.libgdx.anims.std.MoveAnimation) TextureManager(eidolons.libgdx.texture.TextureManager) DC_Obj(eidolons.entity.obj.DC_Obj) ActorMaster(eidolons.libgdx.anims.ActorMaster) Event(main.game.logic.event.Event) FadeOutAction(eidolons.libgdx.anims.actions.FadeOutAction) Align(com.badlogic.gdx.utils.Align) DC_Game(eidolons.game.core.game.DC_Game) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ShadowMap(eidolons.libgdx.bf.light.ShadowMap) HelpMaster(eidolons.system.text.HelpMaster) List(java.util.List) OutlineMaster(eidolons.game.battlecraft.logic.battlefield.vision.OutlineMaster) Keys(com.badlogic.gdx.Input.Keys) Coordinates(main.game.bf.Coordinates) WallMap(eidolons.libgdx.bf.overlays.WallMap) STANDARD_EVENT_TYPE(main.game.logic.event.Event.STANDARD_EVENT_TYPE) java.util(java.util) DequeImpl(main.system.datatypes.DequeImpl) DeathAnim(eidolons.libgdx.anims.std.DeathAnim) BattleClickListener(eidolons.libgdx.bf.mouse.BattleClickListener) AnimMaster(eidolons.libgdx.anims.AnimMaster) EVENT_TYPE(main.game.logic.event.Event.EVENT_TYPE) Gdx(com.badlogic.gdx.Gdx) Batch(com.badlogic.gdx.graphics.g2d.Batch) WaitMaster(main.system.threading.WaitMaster) GuiEventManager(main.system.GuiEventManager) StringMaster(main.system.auxiliary.StringMaster) DC_Engine(eidolons.game.battlecraft.DC_Engine) OverlaysManager(eidolons.libgdx.bf.overlays.OverlaysManager) PanelActionsDataSource(eidolons.libgdx.gui.panels.dc.actionpanel.datasource.PanelActionsDataSource) GRAPHIC_OPTION(eidolons.system.options.GraphicsOptions.GRAPHIC_OPTION) VisionManager(eidolons.game.battlecraft.logic.battlefield.vision.VisionManager) LogMaster(main.system.auxiliary.log.LogMaster) EventCallback(main.system.EventCallback) KEYS(main.entity.Ref.KEYS) AnimationConstructor(eidolons.libgdx.anims.AnimationConstructor) FloatingTextMaster(eidolons.libgdx.anims.text.FloatingTextMaster) ResourceSourceImpl(eidolons.libgdx.gui.panels.dc.unitinfo.datasource.ResourceSourceImpl) Group(com.badlogic.gdx.scenes.scene2d.Group) StyleHolder(eidolons.libgdx.StyleHolder) TEXT_CASES(eidolons.libgdx.anims.text.FloatingTextMaster.TEXT_CASES) eidolons.libgdx.bf(eidolons.libgdx.bf) WAIT_OPERATIONS(main.system.threading.WaitMaster.WAIT_OPERATIONS) java.awt(java.awt) TextureCache(eidolons.libgdx.texture.TextureCache) Eidolons(eidolons.game.core.Eidolons) Unit(eidolons.entity.obj.unit.Unit) DC_SoundMaster(eidolons.system.audio.DC_SoundMaster) SHADE_LIGHT(eidolons.libgdx.bf.light.ShadowMap.SHADE_LIGHT) OverlaysManager(eidolons.libgdx.bf.overlays.OverlaysManager) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) BattleClickListener(eidolons.libgdx.bf.mouse.BattleClickListener) Unit(eidolons.entity.obj.unit.Unit)

Example 2 with BattleClickListener

use of eidolons.libgdx.bf.mouse.BattleClickListener in project Eidolons by IDemiurge.

the class UnitViewFactory method createListener.

public static ClickListener createListener(BattleFieldObject bfObj) {
    return new BattleClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            // event.getButton() == Input.Buttons.RIGHT;
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (IntroTestLauncher.running) {
                ScenarioMetaMaster m = new ScenarioMetaMaster("Pride and Treachery");
                // new LinearDialogue();
                GameDialogue dialogue = null;
                dialogue = bfObj.getGame().getMetaMaster().getDialogueFactory().getDialogue("Interrogation");
                List<DialogScenario> list = SceneFactory.getScenes(dialogue);
                GuiEventManager.trigger(GuiEventType.DIALOG_SHOW, list);
            }
            if (event.getButton() == Input.Buttons.RIGHT) {
                GuiEventManager.trigger(CREATE_RADIAL_MENU, bfObj);
                event.handle();
                event.stop();
            } else {
                if (event.getButton() == Buttons.LEFT)
                    if (isAlt() || isShift() || isControl())
                        try {
                            DefaultActionHandler.leftClickUnit(isShift(), isControl(), bfObj);
                        } catch (Exception e) {
                            main.system.ExceptionMaster.printStackTrace(e);
                        }
                GuiEventManager.trigger(RADIAL_MENU_CLOSE);
            }
        }
    };
}
Also used : ScenarioMetaMaster(eidolons.game.battlecraft.logic.meta.scenario.ScenarioMetaMaster) GameDialogue(eidolons.game.battlecraft.logic.meta.scenario.dialogue.GameDialogue) DialogScenario(eidolons.libgdx.DialogScenario) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) BattleClickListener(eidolons.libgdx.bf.mouse.BattleClickListener)

Example 3 with BattleClickListener

use of eidolons.libgdx.bf.mouse.BattleClickListener 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 4 with BattleClickListener

use of eidolons.libgdx.bf.mouse.BattleClickListener in project Eidolons by IDemiurge.

the class GridCell method init.

public GridCell init() {
    backImage = new Image(backTexture);
    backImage.setFillParent(true);
    addActor(backImage);
    setSize(GridMaster.CELL_W, GridMaster.CELL_H);
    cordsText = new Label(getGridX() + ":" + getGridY(), StyleHolder.getAVQLabelStyle());
    cordsText.setPosition(getWidth() / 2 - cordsText.getWidth() / 2, getHeight() / 2 - cordsText.getHeight() / 2);
    cordsText.setVisible(false);
    addActor(cordsText);
    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) {
            DC_Obj dc_cell = Eidolons.gameMaster.getCellByCoordinate(new Coordinates(getGridX(), getGridY()));
            if (button == Input.Buttons.RIGHT && !event.isHandled()) {
                event.handle();
                GuiEventManager.trigger(CREATE_RADIAL_MENU, dc_cell);
            }
            if (button == Input.Buttons.LEFT) {
                event.handle();
                if (isEmpty())
                    if (isAlt() || isShift() || isControl())
                        try {
                            if (DefaultActionHandler.leftClickCell(isShift(), isControl(), getGridX(), getGridY()))
                                return;
                        } catch (Exception e) {
                            main.system.ExceptionMaster.printStackTrace(e);
                        }
                GuiEventManager.trigger(CALL_BLUE_BORDER_ACTION, GridCell.this);
                GuiEventManager.trigger(RADIAL_MENU_CLOSE);
            }
        }
    });
    return this;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Coordinates(main.game.bf.Coordinates) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) BattleClickListener(eidolons.libgdx.bf.mouse.BattleClickListener)

Aggregations

InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)4 BattleClickListener (eidolons.libgdx.bf.mouse.BattleClickListener)4 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)2 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)2 DC_Obj (eidolons.entity.obj.DC_Obj)2 Gdx (com.badlogic.gdx.Gdx)1 Keys (com.badlogic.gdx.Input.Keys)1 Batch (com.badlogic.gdx.graphics.g2d.Batch)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Vector2 (com.badlogic.gdx.math.Vector2)1 Group (com.badlogic.gdx.scenes.scene2d.Group)1 Align (com.badlogic.gdx.utils.Align)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 Unit (eidolons.entity.obj.unit.Unit)1 DC_Engine (eidolons.game.battlecraft.DC_Engine)1 LastSeenMaster (eidolons.game.battlecraft.logic.battlefield.vision.LastSeenMaster)1 OutlineMaster (eidolons.game.battlecraft.logic.battlefield.vision.OutlineMaster)1 VisionManager (eidolons.game.battlecraft.logic.battlefield.vision.VisionManager)1 ScenarioMetaMaster (eidolons.game.battlecraft.logic.meta.scenario.ScenarioMetaMaster)1 GameDialogue (eidolons.game.battlecraft.logic.meta.scenario.dialogue.GameDialogue)1