Search in sources :

Example 1 with ValueContainer

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

the class PlaceTooltip method updateAct.

@Override
public void updateAct(float delta) {
    clearChildren();
    TextureRegion r = TextureCache.getOrCreateR(place.getImagePath());
    ValueContainer container = new ValueContainer(r, place.getName());
    float size = GdxMaster.adjustSize(128);
    if (size < r.getRegionHeight() && size < r.getRegionWidth())
        container.overrideImageSize(size, size);
    add(container);
    setBackground(new NinePatchDrawable(NinePatchFactory.getTooltip()));
    // return ;
    if (place.getRoutes().isEmpty()) {
        return;
    }
    row();
    TablePanel<ValueContainer> routesInfo = new TablePanel<>();
    routesInfo.defaults().space(5);
    add(routesInfo);
    routesInfo.addListener(new ClickListener() {

        @Override
        public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
            if (toActor == routesInfo)
                return;
            if (toActor == null) {
                if (getWidth() >= x)
                    return;
                if (getWidth() >= y)
                    return;
            }
            if (GdxMaster.getAncestors(toActor).contains(routesInfo))
                return;
            if (!checkActorExitRemoves(toActor))
                return;
            super.exit(event, x, y, pointer, toActor);
            GuiEventManager.trigger(MapEvent.ROUTES_PANEL_HOVER_OFF);
        }
    });
    int i = 0;
    for (Route sub : place.getRoutes()) {
        // reverse pic pos
        TextureRegion tex = TextureCache.getOrCreateR(sub.getImagePath());
        ValueContainer routeInfo = new ValueContainer(tex, sub.getName(), sub.getLength() + " leagues");
        routeInfo.setBackground(new NinePatchDrawable(NinePatchFactory.getTooltip()));
        routesInfo.add(routeInfo).left().padLeft(5).uniform(true, false);
        routeInfo.setUserObject(sub);
        routeInfo.addListener(new ClickListener() {

            @Override
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                // getTapCount()
                GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, sub);
                return super.touchDown(event, x, y, pointer, button);
            }

            @Override
            public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
                super.exit(event, x, y, pointer, toActor);
                GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, null);
            }

            @Override
            public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
                super.enter(event, x, y, pointer, fromActor);
                GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, sub);
            }
        });
        if (i % 2 == 1)
            routesInfo.row();
        i++;
    }
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) PlaceActor(eidolons.libgdx.screens.map.obj.PlaceActor) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) Route(eidolons.game.module.adventure.map.Route) NinePatchDrawable(com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable) TablePanel(eidolons.libgdx.gui.panels.TablePanel)

Example 2 with ValueContainer

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

the class EmitterPalette method init.

public void init() {
    clear();
    setSize(GdxMaster.getWidth() - 300, 256);
    // int columns = (int) (getWidth() / 64);
    defaults().padLeft(200).top().right().width(GdxMaster.getWidth() - 300);
    Map<String, List<File>> presets = new LinkedHashMap<>();
    List<File> subfolders = FileManager.getFilesFromDirectory(PathFinder.getSfxPath(), true);
    subfolders.forEach(file -> {
        if (!file.isDirectory()) {
            MapMaster.addToListMap(presets, "main", file);
        } else
            presets.put(file.getName(), FileManager.getFilesFromDirectory(file.getPath(), false));
    });
    LabelStyle style = StyleHolder.getSizedLabelStyle(FONT.MAIN, 15);
    for (String sub : presets.keySet()) {
        HorizontalFlowGroup table = new HorizontalFlowGroup(0);
        table.setWidth(getWidth() - 100);
        boolean bg = presets.get(sub).size() < 55;
        for (File preset : presets.get(sub)) {
            // textButton?
            ValueContainer label = new ValueContainer(new Label(preset.getName(), style));
            NinePatch patch = NinePatchFactory.getTooltip();
            patch.scale(0.7f, 0.7f);
            if (bg)
                label.setBackground(new NinePatchDrawable(patch));
            label.addListener(new ClickListener() {

                @Override
                public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                    if (Gdx.input.isKeyPressed(Keys.SHIFT_LEFT)) {
                    // EmitterMaster.
                    }
                    EditorManager.setMode(MAP_EDITOR_MOUSE_MODE.EMITTER);
                    if (selectedLabel != null)
                        selectedLabel.setColor(1, 1, 1, 1);
                    if (sub.equals("main"))
                        selected = preset.getName();
                    else
                        selected = StrPathBuilder.build(sub, preset.getName());
                    selectedLabel = label;
                    label.setColor(1, 0.3f, 0.8f, 1);
                    return super.touchDown(event, x, y, pointer, button);
                }
            });
            table.addActor(label);
        }
        addTab(table, sub);
    }
}
Also used : NinePatch(com.badlogic.gdx.graphics.g2d.NinePatch) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle) HorizontalFlowGroup(com.kotcrab.vis.ui.layout.HorizontalFlowGroup) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) File(java.io.File) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) NinePatchDrawable(com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable)

Example 3 with ValueContainer

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

the class TooltipFactory method addPropStringToValues.

protected void addPropStringToValues(BattleFieldObject hero, List<ValueContainer> values, PROPERTY v) {
    String value = hero.getValue(v);
    value = StringMaster.getWellFormattedString(value);
    value = value.replace(";", ", ");
    final ValueContainer valueContainer = new ValueContainer(v.getDisplayedName(), value);
    valueContainer.setNameAlignment(Align.left);
    valueContainer.setValueAlignment(Align.right);
    values.add(valueContainer);
}
Also used : ValueContainer(eidolons.libgdx.gui.generic.ValueContainer)

Example 4 with ValueContainer

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

the class RadialManager method addSimpleTooltip.

public static void addSimpleTooltip(RadialValueContainer el, String name) {
    ValueTooltip tooltip = new ValueTooltip();
    tooltip.setUserObject(Arrays.asList(new ValueContainer(name, "")));
    for (com.badlogic.gdx.scenes.scene2d.EventListener sub : el.getListeners()) {
        if (!(sub instanceof ClickListener))
            el.removeListener(sub);
    }
    el.addListener(tooltip.getController());
}
Also used : ValueTooltip(eidolons.libgdx.gui.tooltips.ValueTooltip) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 5 with ValueContainer

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

the class UnitDataSource method getWeaponDetail.

private List<ValueContainer> getWeaponDetail(DC_WeaponObj weapon) {
    List<ValueContainer> result = new ArrayList<>();
    if (weapon != null) {
        for (DC_UnitAction el : weapon.getOrCreateAttackActions()) {
            final ValueContainer valueContainer = new ValueContainer(getOrCreateR(el.getImagePath()));
            AttackTooltip toolTip = AttackTooltipFactory.createAttackTooltip(el);
            valueContainer.addListener(toolTip.getController());
            result.add(valueContainer);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) AttackTooltip(eidolons.libgdx.gui.panels.dc.unitinfo.tooltips.AttackTooltip) VerticalValueContainer(eidolons.libgdx.gui.generic.VerticalValueContainer) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) DC_UnitAction(eidolons.entity.active.DC_UnitAction)

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