Search in sources :

Example 1 with InventoryDataSource

use of eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource in project Eidolons by IDemiurge.

the class InventoryWithAction method updateAct.

@Override
public void updateAct(float delta) {
    if (getUserObject() == null)
        return;
    super.updateAct(delta);
    final InventoryDataSource source = (InventoryDataSource) getUserObject();
    if (ExplorationMaster.isExplorationOn()) {
        actionPointsText.setActor(new ValueContainer("Free Mode", ""));
    } else {
        actionPointsText.setActor(new ValueContainer("Actions available:", source.getOperationsString()));
    }
    initButtonListeners();
}
Also used : InventoryDataSource(eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer)

Example 2 with InventoryDataSource

use of eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource in project Eidolons by IDemiurge.

the class ContainerClickHandler method cellClicked.

@Override
public boolean cellClicked(CELL_TYPE cell_type, int clickCount, boolean rightClick, boolean altClick, Entity cellContents) {
    boolean result = false;
    // }
    if (cellContents == null) {
        GuiEventManager.trigger(GuiEventType.SHOW_LOOT_PANEL, null);
        return false;
    }
    if (unit.isInventoryFull()) {
        FloatingTextMaster.getInstance().createFloatingText(TEXT_CASES.DEFAULT, "Inventory is full!", unit);
        return false;
    }
    DC_HeroItemObj item = (DC_HeroItemObj) cellContents;
    container.getItems().remove(item);
    unit.addItemToInventory(item);
    result = true;
    if (result) {
        Pair<InventoryDataSource, ContainerDataSource> param = new ImmutablePair<>(new InventoryDataSource(unit), new ContainerDataSource(container, unit));
        GuiEventManager.trigger(GuiEventType.SHOW_LOOT_PANEL, param);
        GuiEventManager.trigger(GuiEventType.SHOW_LOOT_PANEL, param);
    }
    return result;
}
Also used : InventoryDataSource(eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) DC_HeroItemObj(eidolons.entity.item.DC_HeroItemObj)

Example 3 with InventoryDataSource

use of eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource 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 4 with InventoryDataSource

use of eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource in project Eidolons by IDemiurge.

the class InventoryDialogEffect method applyThis.

@Override
public boolean applyThis() {
    Integer operations = numberOfOperations.getInt(ref);
    getGame().getInventoryManager().setHero(getSource());
    getGame().getInventoryManager().setOperationsPool(operations);
    CharacterCreator.getHeroManager().addHero(getSource());
    GuiEventManager.trigger(GuiEventType.SHOW_INVENTORY, new InventoryDataSource((Unit) ref.getSourceObj()));
    return (boolean) WaitMaster.waitForInput(InventoryTransactionManager.OPERATION);
}
Also used : InventoryDataSource(eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource) Unit(eidolons.entity.obj.unit.Unit)

Example 5 with InventoryDataSource

use of eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource in project Eidolons by IDemiurge.

the class InventoryClickHandlerImpl method cellClicked.

@Override
public boolean cellClicked(CELL_TYPE cell_type, int clickCount, boolean rightClick, boolean altClick, Entity cellContents) {
    boolean result = false;
    OPERATIONS operation = getOperation(cell_type, clickCount, rightClick, altClick, cellContents);
    if (operation == null) {
        result = false;
    } else {
        // if (arg == null) return false;
        if (Eidolons.game.getInventoryManager().tryExecuteOperation(operation, cellContents)) {
            dirty = true;
            result = true;
        }
    }
    if (result) {
        GuiEventManager.trigger(GuiEventType.SHOW_INVENTORY, new InventoryDataSource(unit));
    }
    return result;
}
Also used : InventoryDataSource(eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource) OPERATIONS(eidolons.client.cc.gui.lists.dc.DC_InventoryManager.OPERATIONS)

Aggregations

InventoryDataSource (eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryDataSource)8 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)1 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)1 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)1 OPERATIONS (eidolons.client.cc.gui.lists.dc.DC_InventoryManager.OPERATIONS)1 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)1 Unit (eidolons.entity.obj.unit.Unit)1 ValueContainer (eidolons.libgdx.gui.generic.ValueContainer)1 ButtonStyled (eidolons.libgdx.gui.generic.btn.ButtonStyled)1 TablePanel (eidolons.libgdx.gui.panels.TablePanel)1 InventorySlotsPanel (eidolons.libgdx.gui.panels.dc.inventory.InventorySlotsPanel)1 ContainerDataSource (eidolons.libgdx.gui.panels.dc.inventory.container.ContainerDataSource)1 Pair (org.apache.commons.lang3.tuple.Pair)1