Search in sources :

Example 11 with ValueContainer

use of eidolons.libgdx.gui.generic.ValueContainer in project Eidolons by IDemiurge.

the class UnitDataSource method getWeaponValueContainer.

private ValueContainer getWeaponValueContainer(DC_WeaponObj weapon) {
    TextureRegion image;
    if (weapon != null) {
        image = getOrCreateR(weapon.getImagePath());
    } else {
        image = getOrCreateR(CELL_TYPE.WEAPON_MAIN.getSlotImagePath());
    }
    ValueContainer valueContainer = new ValueContainer(image);
    if (weapon != null) {
        List<ValueContainer> list = new ArrayList<>();
        for (int i = 0; i < WEAPON_DC_INFO_PARAMS.length; i++) {
            PARAMS p = WEAPON_DC_INFO_PARAMS[i];
            String value = String.valueOf(weapon.getIntParam(p));
            String name = p.getName();
            final ValueContainer tooltipContainer = new ValueContainer(name, value);
            tooltipContainer.pad(10);
            list.add(tooltipContainer);
        }
        Tooltip tooltip = new WeaponTooltip();
        tooltip.setUserObject(new WeaponToolTipDataSource() {

            @Override
            public List<ValueContainer> getMainParams() {
                return list;
            }

            @Override
            public List<ValueContainer> getBuffs() {
                return weapon.getBuffs().stream().filter(obj -> StringUtils.isNoneEmpty(obj.getType().getProperty(G_PROPS.IMAGE))).map(AttackTooltipFactory.getObjValueContainerMapper()).collect(Collectors.toList());
            }
        });
        valueContainer.addListener(tooltip.getController());
    }
    return valueContainer;
}
Also used : DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) WeaponTooltip(eidolons.libgdx.gui.panels.dc.unitinfo.tooltips.WeaponTooltip) UNIT_INFO_PARAMS(eidolons.content.UNIT_INFO_PARAMS) Arrays(java.util.Arrays) AttackTooltipFactory(eidolons.libgdx.gui.panels.dc.unitinfo.tooltips.AttackTooltipFactory) UiMaster(eidolons.libgdx.gui.UiMaster) PARAMS(eidolons.content.PARAMS) VerticalValueContainer(eidolons.libgdx.gui.generic.VerticalValueContainer) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) WeaponToolTipDataSource(eidolons.libgdx.gui.panels.dc.unitinfo.tooltips.WeaponToolTipDataSource) TextureCache.getOrCreateR(eidolons.libgdx.texture.TextureCache.getOrCreateR) Pair(org.apache.commons.lang3.tuple.Pair) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Tooltip(eidolons.libgdx.gui.tooltips.Tooltip) G_PROPS(main.content.values.properties.G_PROPS) DC_UnitAction(eidolons.entity.active.DC_UnitAction) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) CELL_TYPE(eidolons.libgdx.gui.panels.dc.inventory.InventoryClickHandler.CELL_TYPE) AttackTooltip(eidolons.libgdx.gui.panels.dc.unitinfo.tooltips.AttackTooltip) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) PARAMETER(main.content.values.parameters.PARAMETER) ImageManager(main.system.images.ImageManager) List(java.util.List) TextureCache(eidolons.libgdx.texture.TextureCache) ValuePages(eidolons.content.ValuePages) ValueTooltip(eidolons.libgdx.gui.tooltips.ValueTooltip) DC_ArmorObj(eidolons.entity.item.DC_ArmorObj) Unit(eidolons.entity.obj.unit.Unit) WeaponTooltip(eidolons.libgdx.gui.panels.dc.unitinfo.tooltips.WeaponTooltip) Tooltip(eidolons.libgdx.gui.tooltips.Tooltip) AttackTooltip(eidolons.libgdx.gui.panels.dc.unitinfo.tooltips.AttackTooltip) ValueTooltip(eidolons.libgdx.gui.tooltips.ValueTooltip) ArrayList(java.util.ArrayList) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ArrayList(java.util.ArrayList) List(java.util.List) VerticalValueContainer(eidolons.libgdx.gui.generic.VerticalValueContainer) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) UNIT_INFO_PARAMS(eidolons.content.UNIT_INFO_PARAMS) PARAMS(eidolons.content.PARAMS) WeaponTooltip(eidolons.libgdx.gui.panels.dc.unitinfo.tooltips.WeaponTooltip) WeaponToolTipDataSource(eidolons.libgdx.gui.panels.dc.unitinfo.tooltips.WeaponToolTipDataSource)

Example 12 with ValueContainer

use of eidolons.libgdx.gui.generic.ValueContainer in project Eidolons by IDemiurge.

the class AttackTooltipFactory method createAttackTooltip.

public static AttackTooltip createAttackTooltip(DC_UnitAction el, boolean precalc, boolean costs, boolean additionalInfo, boolean combatMode, DC_Obj target) {
    Pair<PARAMS, PARAMS> pair = ACTION_TOOLTIPS_PARAMS_MAP.get(ACTION_TOOLTIP_HEADER_KEY);
    String name = ActionTooltipMaster.getStringForTableValue(ACTION_TOOLTIP_HEADER_KEY, el);
    final String leftImage = ActionTooltipMaster.getIconPathForTableRow(pair.getLeft());
    final String rightImage = ActionTooltipMaster.getIconPathForTableRow(pair.getRight());
    MultiValueContainer head = new MultiValueContainer(name, leftImage, rightImage);
    VALUE[] baseKeys = ACTION_TOOLTIP_BASE_KEYS;
    final List<MultiValueContainer> base = extractActionValues(el, baseKeys);
    baseKeys = ACTION_TOOLTIP_RANGE_KEYS;
    final List<MultiValueContainer> range = extractActionValues(el, baseKeys);
    List /*<List<MultiValueContainer>>*/
    textsList = new ArrayList<>();
    for (PARAMS[] params : ACTION_TOOLTIP_PARAMS_TEXT) {
        textsList.add(Arrays.stream(params).map(p -> {
            String textForTableValue = ActionTooltipMaster.getTextForTableValue(p, el);
            textForTableValue = TextWrapper.wrapWithNewLine(textForTableValue, 50);
            if (StringUtils.isEmpty(textForTableValue)) {
                return null;
            } else {
                return new MultiValueContainer(textForTableValue, "");
            }
        }).filter(Objects::nonNull).collect(Collectors.toList()));
    }
    AttackTooltip toolTip = new AttackTooltip(el);
    ValueContainer precalcRow = createPrecalcRow(precalc, el, target);
    toolTip.setUserObject(new ActionTooltipSource() {

        @Override
        public MultiValueContainer getHead() {
            return head;
        }

        @Override
        public List<MultiValueContainer> getBase() {
            return base;
        }

        @Override
        public List<MultiValueContainer> getRange() {
            return range;
        }

        @Override
        public List<List<ValueContainer>> getText() {
            return textsList;
        }

        @Override
        public CostTableSource getCostsSource() {
            return () -> ActionCostSourceImpl.getActionCostList(el);
        }

        @Override
        public ValueContainer getPrecalcRow() {
            return precalcRow;
        }
    });
    return toolTip;
}
Also used : UNIT_INFO_PARAMS(eidolons.content.UNIT_INFO_PARAMS) Arrays(java.util.Arrays) PARAMS(eidolons.content.PARAMS) TextWrapper(main.system.text.TextWrapper) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) StringUtils(org.apache.commons.lang3.StringUtils) Function(java.util.function.Function) ActionCostSourceImpl(eidolons.libgdx.gui.panels.dc.actionpanel.datasource.ActionCostSourceImpl) ArrayList(java.util.ArrayList) Pair(org.apache.commons.lang3.tuple.Pair) FutureBuilder(eidolons.game.battlecraft.ai.tools.future.FutureBuilder) Tooltip(eidolons.libgdx.gui.tooltips.Tooltip) G_PROPS(main.content.values.properties.G_PROPS) DC_Obj(eidolons.entity.obj.DC_Obj) DC_UnitAction(eidolons.entity.active.DC_UnitAction) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) Obj(main.entity.obj.Obj) Collectors(java.util.stream.Collectors) ImageManager(main.system.images.ImageManager) Objects(java.util.Objects) List(java.util.List) TextureCache(eidolons.libgdx.texture.TextureCache) ValueTooltip(eidolons.libgdx.gui.tooltips.ValueTooltip) DAMAGE_TYPE(main.content.enums.GenericEnums.DAMAGE_TYPE) VALUE(main.content.VALUE) ArrayList(java.util.ArrayList) VALUE(main.content.VALUE) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) Objects(java.util.Objects) ArrayList(java.util.ArrayList) List(java.util.List) UNIT_INFO_PARAMS(eidolons.content.UNIT_INFO_PARAMS) PARAMS(eidolons.content.PARAMS) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer)

Example 13 with ValueContainer

use of eidolons.libgdx.gui.generic.ValueContainer in project Eidolons by IDemiurge.

the class WeaponTooltip method initTableValues.

private TablePanel initTableValues(List<ValueContainer> valueContainers) {
    TablePanel table = new TablePanel();
    final int size = valueContainers.size();
    int halfSize = size / 2;
    if (size % 2 != 0) {
        halfSize++;
    }
    for (int i = 0; i < halfSize; i++) {
        ValueContainer valueContainer = valueContainers.get(i);
        valueContainer.cropName();
        valueContainer.setNameAlignment(Align.left);
        valueContainer.setBorder(getOrCreateR("UI/components/infopanel/simple_value_border.png"));
        table.addElement(valueContainer);
        final int i1 = i + halfSize;
        if (i1 < valueContainers.size()) {
            valueContainer = valueContainers.get(i1);
            valueContainer.cropName();
            valueContainer.setNameAlignment(Align.left);
            valueContainer.setBorder(getOrCreateR("UI/components/infopanel/simple_value_border.png"));
            table.addElement(valueContainer);
        }
        table.row();
    }
    return table;
}
Also used : ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) TablePanel(eidolons.libgdx.gui.panels.TablePanel)

Example 14 with ValueContainer

use of eidolons.libgdx.gui.generic.ValueContainer 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 15 with ValueContainer

use of eidolons.libgdx.gui.generic.ValueContainer in project Eidolons by IDemiurge.

the class RingSlotsPanel method afterUpdateAct.

// @Override
// public void clear() {
// 
// }
@Override
public void afterUpdateAct(float delta) {
    if (getUserObject() == null)
        return;
    clear();
    super.afterUpdateAct(delta);
    final List<InventoryValueContainer> rings = ((EquipDataSource) getUserObject()).rings();
    int a = 0;
    for (int i = 0; i < 8; i++) {
        if (i % 2 == (left ? 1 : 0)) {
            continue;
        }
        a++;
        ValueContainer valueContainer = rings.get(i);
        if (valueContainer == null) {
            valueContainer = new ValueContainer(getOrCreateR(CELL_TYPE.RING.getSlotImagePath()));
        }
        add(valueContainer).expand(0, 0);
        if ((a) % 2 == 0) {
            row();
        }
    }
}
Also used : EquipDataSource(eidolons.libgdx.gui.panels.dc.inventory.datasource.EquipDataSource) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer)

Aggregations

ValueContainer (eidolons.libgdx.gui.generic.ValueContainer)38 ValueTooltip (eidolons.libgdx.gui.tooltips.ValueTooltip)12 ArrayList (java.util.ArrayList)12 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)10 VerticalValueContainer (eidolons.libgdx.gui.generic.VerticalValueContainer)8 List (java.util.List)8 PARAMS (eidolons.content.PARAMS)7 DC_UnitAction (eidolons.entity.active.DC_UnitAction)5 TextureCache (eidolons.libgdx.texture.TextureCache)5 Arrays (java.util.Arrays)5 PARAMETER (main.content.values.parameters.PARAMETER)5 G_PROPS (main.content.values.properties.G_PROPS)5 Pair (org.apache.commons.lang3.tuple.Pair)5 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)4 UNIT_INFO_PARAMS (eidolons.content.UNIT_INFO_PARAMS)4 DC_ArmorObj (eidolons.entity.item.DC_ArmorObj)4 Unit (eidolons.entity.obj.unit.Unit)4 TablePanel (eidolons.libgdx.gui.panels.TablePanel)4 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)4 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)3