Search in sources :

Example 1 with QueueView

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

the class InitiativePanel method registerCallback.

private void registerCallback() {
    GuiEventManager.bind(GuiEventType.ADD_OR_UPDATE_INITIATIVE, obj -> {
        if (!isRealTime()) {
            QueueView p = (QueueView) obj.get();
            addOrUpdate(p);
            if (isCleanUpOn())
                cleanUp();
            resetZIndices();
        }
    });
    GuiEventManager.bind(GuiEventType.ACTIVE_UNIT_SELECTED, obj -> {
        if (!isRealTime())
            checkPositions();
    });
    GuiEventManager.bind(GuiEventType.UPDATE_GUI, obj -> {
        if (!isRealTime()) {
            // cleanUp();
            resetZIndices();
        }
        checkPositionsRequired = true;
    });
    GuiEventManager.bind(GuiEventType.GRID_OBJ_HOVER_ON, obj -> {
        if (!isRealTime()) {
            if (!(obj.get() instanceof QueueView))
                return;
            QueueView p = (QueueView) obj.get();
            QueueViewContainer view = getIfExists(p.getCurId());
            if (view != null)
                view.setZIndex(Integer.MAX_VALUE - 1);
        }
        DungeonScreen.getInstance().getGridPanel().resetZIndices();
    });
    GuiEventManager.bind(GuiEventType.GRID_OBJ_HOVER_OFF, obj -> {
        if (!isRealTime()) {
            resetZIndices();
        }
        DungeonScreen.getInstance().getGridPanel().resetZIndices();
    });
    GuiEventManager.bind(GuiEventType.REMOVE_FROM_INITIATIVE_PANEL, obj -> {
        // if (!isRealTime()) {
        QueueView p = (QueueView) obj.get();
        removeView(p);
        resetZIndices();
    // checkPositionsRequired=true;
    // }
    });
    if (DC_Engine.isAtbMode()) {
        GuiEventManager.bind(GuiEventType.PREVIEW_ATB_READINESS, obj -> {
            List<Integer> list = (List<Integer>) obj.get();
            previewAtbReadiness(list);
        });
        GuiEventManager.bind(GuiEventType.ATB_POS_PREVIEW, obj -> {
            if (obj.get() == null) {
                removePreviewAtbPos();
                previewAtbReadiness(null);
            } else {
                previewAtbPos((int) obj.get());
            }
        });
    }
}
Also used : QueueView(eidolons.libgdx.bf.grid.QueueView) List(java.util.List)

Example 2 with QueueView

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

the class InitiativePanel method previewAtbReadiness.

private void previewAtbReadiness(List<Integer> list) {
    int i = 0;
    for (int j = queue.length - 1; j > 0; j--) {
        QueueViewContainer sub = queue[j];
        if (sub == null)
            break;
        QueueView actor = (QueueView) sub.getActor();
        String text = (list == null ? sub.initiative : list.get(i++)) + "";
        actor.setInitiativeLabelText(text);
    }
}
Also used : QueueView(eidolons.libgdx.bf.grid.QueueView)

Example 3 with QueueView

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

the class InitiativePanel method cleanUp.

private void cleanUp() {
    Map<Integer, QueueView> views = new XLinkedMap<>();
    DC_Game.game.getTurnManager().getDisplayedUnitQueue().stream().forEach(unit -> {
        Object o = DungeonScreen.getInstance().getGridPanel().getViewMap().get(unit);
        if (o instanceof GridUnitView) {
            GridUnitView view = ((GridUnitView) o);
            views.put(view.getCurId(), view.getInitiativeQueueUnitView());
        }
    });
    /*
        if unit is unknown/unseen?
        >>
        if unit is unable to act?

        proper cleanup is not done on death(), right?
         */
    for (QueueViewContainer sub : queue) {
        if (sub == null)
            continue;
        if (!views.containsKey(sub.id)) {
            QueueViewContainer view = getIfExists(sub.id);
            if (view == null)
                continue;
            if (view.getActor() == null)
                continue;
            removeView((sub.id));
        }
    }
    // to ensure proper values are displayed
    previewAtbReadiness(null);
}
Also used : QueueView(eidolons.libgdx.bf.grid.QueueView) XLinkedMap(main.data.XLinkedMap) GridUnitView(eidolons.libgdx.bf.grid.GridUnitView)

Aggregations

QueueView (eidolons.libgdx.bf.grid.QueueView)3 GridUnitView (eidolons.libgdx.bf.grid.GridUnitView)1 List (java.util.List)1 XLinkedMap (main.data.XLinkedMap)1