Search in sources :

Example 1 with MultiValueContainer

use of eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer 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 2 with MultiValueContainer

use of eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer in project Eidolons by IDemiurge.

the class AttackTooltipFactory method extractActionValues.

private static List<MultiValueContainer> extractActionValues(DC_UnitAction el, VALUE[] baseKeys) {
    List<MultiValueContainer> list = new ArrayList<>();
    Pair<PARAMS, PARAMS> pair;
    for (VALUE key : baseKeys) {
        pair = ACTION_TOOLTIPS_PARAMS_MAP.get(key);
        String name = ActionTooltipMaster.getStringForTableValue(key, el);
        String imagePath = ActionTooltipMaster.getIconPathForTableRow(key);
        final String leftVal = ActionTooltipMaster.getValueForTableParam(pair.getLeft(), el);
        final String rightVal = ActionTooltipMaster.getValueForTableParam(pair.getRight(), el);
        MultiValueContainer mvc;
        if (!ImageManager.isImage(imagePath)) {
            mvc = new MultiValueContainer(name, leftVal, rightVal);
        } else {
            mvc = new MultiValueContainer(TextureCache.getOrCreateR(imagePath), name, leftVal, rightVal);
        }
        list.add(mvc);
    }
    return list;
}
Also used : MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) ArrayList(java.util.ArrayList) UNIT_INFO_PARAMS(eidolons.content.UNIT_INFO_PARAMS) PARAMS(eidolons.content.PARAMS) VALUE(main.content.VALUE)

Example 3 with MultiValueContainer

use of eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer in project Eidolons by IDemiurge.

the class AttackTooltip method updateAct.

@Override
public void updateAct(float delta) {
    clear();
    TablePanel left = new TablePanel();
    final ActionTooltipSource source = (ActionTooltipSource) getUserObject();
    final MultiValueContainer valueContainer = source.getHead();
    final List<Container<Label>> values = valueContainer.getValues();
    final TextureRegion leftImage = getOrCreateR(values.get(0).getActor().getText().toString());
    final TextureRegion rightImage = getOrCreateR(values.get(1).getActor().getText().toString());
    baseTable = new TablePanel();
    baseTable.addElement(null).expand(0, 0).fill(false);
    baseTable.addElement(new ValueContainer(valueContainer.getName(), ""));
    baseTable.addElement(new ValueContainer(leftImage));
    baseTable.addElement(new ValueContainer(rightImage));
    baseTable.row();
    ValueContainer precalcRow = source.getPrecalcRow();
    if (precalcRow != null) {
        Label label = new Label("Est.", StyleHolder.getDefaultLabelStyle());
        baseTable.addElement(label);
        baseTable.addElement(precalcRow);
        baseTable.row();
    }
    List<MultiValueContainer> list = source.getBase();
    for (Object o : list) {
        MultiValueContainer container = (MultiValueContainer) o;
        final List<ValueContainer> separated = container.separate();
        separated.forEach(el -> {
            baseTable.addElement(el);
        });
        baseTable.row();
    }
    rangeTable = new TablePanel();
    list = source.getRange();
    for (Object o : list) {
        MultiValueContainer container = (MultiValueContainer) o;
        final List<ValueContainer> separated = container.separate();
        separated.forEach(el -> {
            rangeTable.addElement(el);
        });
        rangeTable.row();
    }
    List<List<ValueContainer>> listText = source.getText();
    for (List<ValueContainer> valueContainers : listText) {
        TablePanel panel = new TablePanel();
        textTables.add(panel);
        for (ValueContainer container : valueContainers) {
            // container.wrapNames();
            panel.addElement(container);
            panel.row();
        }
    }
    left.addElement(baseTable).width(282).pad(0, 0, 3, 0);
    left.row();
    left.addElement(rangeTable).width(282).pad(0, 0, 3, 0);
    left.row();
    textTables.forEach(el -> {
        left.addElement(el).width(282).pad(0, 0, 3, 0);
        left.row();
    });
    addElement(left);
    CostsPanel costsPanel = new CostsPanel();
    costsPanel.setUserObject(source.getCostsSource());
    addElement(costsPanel);
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) Container(com.badlogic.gdx.scenes.scene2d.ui.Container) ArrayList(java.util.ArrayList) List(java.util.List) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) TablePanel(eidolons.libgdx.gui.panels.TablePanel)

Aggregations

MultiValueContainer (eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer)3 ArrayList (java.util.ArrayList)3 PARAMS (eidolons.content.PARAMS)2 UNIT_INFO_PARAMS (eidolons.content.UNIT_INFO_PARAMS)2 ValueContainer (eidolons.libgdx.gui.generic.ValueContainer)2 List (java.util.List)2 VALUE (main.content.VALUE)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Container (com.badlogic.gdx.scenes.scene2d.ui.Container)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 DC_UnitAction (eidolons.entity.active.DC_UnitAction)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 FutureBuilder (eidolons.game.battlecraft.ai.tools.future.FutureBuilder)1 TablePanel (eidolons.libgdx.gui.panels.TablePanel)1 ActionCostSourceImpl (eidolons.libgdx.gui.panels.dc.actionpanel.datasource.ActionCostSourceImpl)1 Tooltip (eidolons.libgdx.gui.tooltips.Tooltip)1 ValueTooltip (eidolons.libgdx.gui.tooltips.ValueTooltip)1 TextureCache (eidolons.libgdx.texture.TextureCache)1 Arrays (java.util.Arrays)1 Objects (java.util.Objects)1