Search in sources :

Example 1 with GridCellContainer

use of eidolons.libgdx.bf.grid.GridCellContainer in project Eidolons by IDemiurge.

the class GlobalController method tab.

private void tab() {
    GridUnitView hovered = DungeonScreen.getInstance().getGridPanel().getHoverObj();
    GridCellContainer cell = (GridCellContainer) hovered.getParent();
    List<GenericGridView> list = new ArrayList<>(cell.getUnitViewsVisible());
    if (list.size() == 1)
        // or do something else
        return;
    SortMaster.sortByExpression(list, view -> view.hashCode());
    int index = list.indexOf(hovered);
    index++;
    if (list.size() <= index)
        index = 0;
    GuiEventManager.trigger(GuiEventType.GRID_OBJ_HOVER_OFF, hovered);
    GenericGridView newFocus = list.get(index);
    cell.popupUnitView(newFocus);
    GuiEventManager.trigger(GuiEventType.GRID_OBJ_HOVER_ON, newFocus);
    GuiEventManager.trigger(GuiEventType.SHOW_TOOLTIP, newFocus.getTooltip());
}
Also used : GridCellContainer(eidolons.libgdx.bf.grid.GridCellContainer) ArrayList(java.util.ArrayList) GenericGridView(eidolons.libgdx.bf.grid.GenericGridView) GridUnitView(eidolons.libgdx.bf.grid.GridUnitView)

Example 2 with GridCellContainer

use of eidolons.libgdx.bf.grid.GridCellContainer in project Eidolons by IDemiurge.

the class ShadeLightCell method adjustPosition.

public void adjustPosition(int x, int y) {
    float offsetX = 0;
    float offsetY = 0;
    setScale(1f, 1f);
    setVisible(true);
    for (Obj sub : DC_Game.game.getRules().getIlluminationRule().getEffectCache().keySet()) {
        if (sub instanceof Unit)
            // TODO illuminate some other way for units...
            continue;
        if (sub instanceof Structure) {
            if (sub.getCoordinates().x == x)
                if (sub.getCoordinates().y == y)
                    if (((Structure) sub).isOverlaying()) {
                        DIRECTION d = ((Structure) sub).getDirection();
                        if (d == null) {
                            setScale(0.7f, 0.7f);
                            continue;
                        }
                        setScale(d.growX == null ? 1 : 0.8f, d.growY == null ? 1 : 0.8f);
                        Dimension dim = GridMaster.getOffsetsForOverlaying(d, (int) getWidth() - 64, (int) getHeight() - 64);
                        offsetX += dim.width;
                        offsetY += dim.height;
                    // so if 2+ overlays, will be centered between them...
                    } else {
                        BaseView view = DungeonScreen.getInstance().getGridPanel().getViewMap().get(sub);
                        offsetX += view.getX() * 3;
                        offsetY += view.getY() * 3;
                        if (view.getParent() instanceof GridCellContainer) {
                            if ((((GridCellContainer) view.getParent()).getUnitViews(true).size() > 1)) {
                                if (!view.isHovered())
                                    setVisible(false);
                            }
                        }
                    }
        }
    }
    setPosition(originalX + offsetX / 3, originalY + offsetY / 3);
}
Also used : Obj(main.entity.obj.Obj) DIRECTION(main.game.bf.Coordinates.DIRECTION) GridCellContainer(eidolons.libgdx.bf.grid.GridCellContainer) BaseView(eidolons.libgdx.bf.grid.BaseView) Unit(eidolons.entity.obj.unit.Unit) Structure(eidolons.entity.obj.Structure)

Aggregations

GridCellContainer (eidolons.libgdx.bf.grid.GridCellContainer)2 Structure (eidolons.entity.obj.Structure)1 Unit (eidolons.entity.obj.unit.Unit)1 BaseView (eidolons.libgdx.bf.grid.BaseView)1 GenericGridView (eidolons.libgdx.bf.grid.GenericGridView)1 GridUnitView (eidolons.libgdx.bf.grid.GridUnitView)1 ArrayList (java.util.ArrayList)1 Obj (main.entity.obj.Obj)1 DIRECTION (main.game.bf.Coordinates.DIRECTION)1