use of eidolons.libgdx.gui.panels.dc.inventory.InventorySlotsPanel 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;
}
});
}
Aggregations