Search in sources :

Example 21 with ValueContainer

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

the class ActionCostSourceImpl method getActionCostList.

public static List<ValueContainer> getActionCostList(DC_ActiveObj el) {
    List<ValueContainer> costsList = new ArrayList<>();
    for (int i = 0, costsLength = RESOURCE_COSTS.length; i < costsLength; i++) {
        PARAMETER cost = RESOURCE_COSTS[i];
        final double param = el.getParamDouble(cost);
        String text = String.format(Locale.US, "%.1f", param);
        if (cost == PARAMS.AP_COST) {
            if (DC_Engine.isAtbMode()) {
                text = MathMaster.round((float) (param * AtbController.ATB_MOD)) + "%";
            }
        }
        if (param > 0) {
            final String iconPath = ImageManager.getValueIconPath(COSTS_ICON_PARAMS[i]);
            costsList.add(new ValueContainer(getOrCreateR(iconPath), text));
        }
    }
    final double reqRes = el.getParamDouble(MIN_REQ_RES_FOR_USE.getLeft());
    if (reqRes > 0) {
        final String iconPath = ImageManager.getValueIconPath(MIN_REQ_RES_FOR_USE.getRight());
        costsList.add(new ValueContainer(getOrCreateR(iconPath), String.format(Locale.US, "> %.1f", reqRes)));
    }
    return costsList;
}
Also used : ArrayList(java.util.ArrayList) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) PARAMETER(main.content.values.parameters.PARAMETER)

Example 22 with ValueContainer

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

the class EditorPalette method init.

public void init() {
    clearChildren();
    clearListeners();
    addListener(new ClickListener() {

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            // updateRequired=true;
            return super.touchDown(event, x, y, pointer, button);
        }
    });
    setSize(GdxMaster.getWidth() / 3 * 2, 256);
    int columns = (int) (getWidth() / 64);
    for (EDITOR_PALETTE sub : EDITOR_PALETTE.values()) {
        OBJ_TYPE TYPE = ContentManager.getOBJ_TYPE(sub.name());
        if (TYPE == null) {
            addCustomTab(sub);
            continue;
        }
        TabbedPanel tabbedPanel = new TabbedPanel();
        TablePanel<Actor> table;
        if (TYPE == null)
            continue;
        List<String> list = DataManager.getTabsGroup(TYPE);
        if (list.isEmpty())
            list.add("");
        for (String group : list) {
            table = new TablePanel<>();
            table.defaults().width(64).height(64);
            table.top().left().padLeft(64).padTop(64);
            table.setFillParent(true);
            ArrayList<ObjType> types = new ArrayList<>(DataManager.getTypesGroup(TYPE, group));
            int i = 0;
            int rows = 0;
            for (ObjType type : types) {
                TextureRegion texture = TextureCache.getOrCreateR(type.getImagePath());
                ValueContainer item = new ValueContainer(texture);
                item.setBackground(new NinePatchDrawable(NinePatchFactory.getTooltip()));
                item.overrideImageSize(64, 64);
                item.addListener(new ValueTooltip(type.getName()).getController());
                item.addListener(getItemListener(item));
                table.add(item).left();
                item.setUserObject(type);
                i++;
                if (i >= columns) {
                    i = 0;
                    table.row();
                    rows++;
                }
            }
            table.pack();
            if (rows > 3) {
                ScrollPanel scrollPanel = new ScrollPanel();
                scrollPanel.addElement(table);
                tabbedPanel.addTab(scrollPanel, group);
            } else {
                tabbedPanel.addTab(table, group);
            }
        }
        addTab(tabbedPanel, sub.name());
    }
// scrollable?
}
Also used : ValueTooltip(eidolons.libgdx.gui.tooltips.ValueTooltip) OBJ_TYPE(main.content.OBJ_TYPE) ArrayList(java.util.ArrayList) TabbedPanel(eidolons.libgdx.gui.panels.TabbedPanel) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ObjType(main.entity.type.ObjType) Actor(com.badlogic.gdx.scenes.scene2d.Actor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) ScrollPanel(eidolons.libgdx.gui.panels.ScrollPanel) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) NinePatchDrawable(com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable)

Example 23 with ValueContainer

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

the class InventoryQuickSlotPanel method afterUpdateAct.

@Override
public void afterUpdateAct(float delta) {
    if (getUserObject() == null)
        return;
    clear();
    super.afterUpdateAct(delta);
    final List<InventoryValueContainer> quickSlots = ((QuickSlotDataSource) getUserObject()).getQuickSlots();
    int maxLength = Math.min(8, quickSlots.size());
    for (int i = 0; i < maxLength; i++) {
        ValueContainer valueContainer = quickSlots.get(i);
        if (valueContainer == null) {
            valueContainer = new ValueContainer(TextureCache.getOrCreateR("UI/empty_pack.jpg"));
        }
        addElement(valueContainer).fill(0, 1).expand(0, 1).center();
    }
}
Also used : QuickSlotDataSource(eidolons.libgdx.gui.panels.dc.inventory.datasource.QuickSlotDataSource) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer)

Example 24 with ValueContainer

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

the class InventorySlotsPanel method afterUpdateAct.

@Override
public void afterUpdateAct(float delta) {
    if (getUserObject() == null)
        return;
    clear();
    super.afterUpdateAct(delta);
    final List<InventoryValueContainer> inventorySlots = ((InventoryTableDataSource) getUserObject()).getInventorySlots();
    for (int i = 0; i < SIZE; i++) {
        ValueContainer valueContainer = inventorySlots.get(i);
        if (valueContainer == null) {
            valueContainer = new ValueContainer(getOrCreateR("UI/empty_pack.jpg"));
        }
        add(valueContainer).expand(0, 0);
        if ((i + 1) % COLUMNS == 0) {
            row();
        }
    }
}
Also used : ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) InventoryTableDataSource(eidolons.libgdx.gui.panels.dc.inventory.datasource.InventoryTableDataSource)

Example 25 with ValueContainer

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

the class TooltipFactory method addKeyAndValue.

protected void addKeyAndValue(String key, String value, List<ValueContainer> values) {
    final ValueContainer valueContainer = new ValueContainer(key, value);
    valueContainer.setNameAlignment(Align.left);
    valueContainer.setValueAlignment(Align.right);
    values.add(valueContainer);
}
Also used : 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