Search in sources :

Example 1 with LogEntryNode

use of main.system.text.LogEntryNode in project Eidolons by IDemiurge.

the class DC_PagedLogPanel method addComponents.

protected void addComponents() {
    String pos = "pos 0 0";
    add(getCurrentComponent(), pos);
    addControls();
    returnButton = new CustomButton(VISUALS.ADD) {

        public void handleClick() {
            back();
        }

        protected void playClickSound() {
            DC_SoundMaster.playStandardSound(STD_SOUNDS.SLING);
        }

        public VISUALS getVisuals() {
            if (!isEnabled()) {
                return VISUALS.ADD_BLOCKED;
            }
            return super.getVisuals();
        }

        public boolean isEnabled() {
            // nodeViewMode
            return true;
        }
    };
    // toggleButton = new CustomButton(BUTTON_VISUALS) {
    // public void handleClick() {
    // toggleMode();
    // }
    // 
    // protected void playSound() {
    // DC_SoundMaster.playStandardSound(STD_SOUNDS.CLOCK);
    // }
    // 
    // };
    // 
    // pos = "pos " + (getPanelWidth() - BUTTON_VISUALS.getWidth()) + " "
    // + (getPanelHeight() - BUTTON_VISUALS.getHeight()) + "";
    // add(toggleButton, pos);
    pos = "pos 0 0";
    add(returnButton, pos);
    int i = 0;
    if (entryNodes != null) {
        for (final LogEntryNode node : entryNodes) {
            int lineIndex = (node.getLineIndex()) % getRowCount();
            if (lineIndex == 0) {
                lineIndex = getRowCount();
            }
            Integer y = Math.min(getPanelHeight() - EntryNodeMaster.getRowHeight(isTopPage()), EntryNodeMaster.getRowHeight(isTopPage()) * (lineIndex));
            // TODO
            // top
            // vs
            // generic
            // separate!
            ImageButton entryNodeButton = new ImageButton((node.getButtonImagePath())) {

                @Override
                public void handleClick() {
                    if (entryNode == null) {
                        setCachedTopPageIndex(getCurrentIndex());
                    }
                    if (node.getLinkedAnimation() != null) {
                        for (ANIM anim : node.getLinkedAnimations()) {
                            PhaseAnimation animation = (PhaseAnimation) anim;
                            // DC_Game.game.getAnimationManager()
                            // .getAnimation(key);
                            animation.setPhaseFilter(node.getAnimPhasesToPlay());
                            if (animation != null) {
                                animation.setReplay(true);
                                animation.start();
                                animation.setAutoFinish(false);
                            }
                        }
                        Coordinates bufferedOffset = game.getAnimationManager().updatePoints();
                        game.getManager().refreshGUI();
                        game.getBattleField().getGrid().setNextOffsetCoordinate(bufferedOffset);
                    }
                    setNodeView(node);
                }

                @Override
                protected void playClickSound() {
                    DC_SoundMaster.playStandardSound(STD_SOUNDS.DIS__OPEN_MENU);
                }
            };
            pos = "pos " + 0 + " " + (y);
            add(entryNodeButton, pos);
            entryNodeButton.activateMouseListener();
            setComponentZOrder(entryNodeButton, i);
            i++;
        }
    }
    setComponentZOrder(returnButton, i);
    i++;
    // setComponentZOrder(toggleButton, i);
    // i++;
    setComponentZOrder(forwardButton, i);
    i++;
    setComponentZOrder(backButton, i);
    i++;
    setComponentZOrder(getCurrentComponent(), i);
}
Also used : ImageButton(main.swing.components.ImageButton) PhaseAnimation(eidolons.system.graphics.PhaseAnimation) CustomButton(eidolons.swing.components.buttons.CustomButton) Coordinates(main.game.bf.Coordinates) LogEntryNode(main.system.text.LogEntryNode) ANIM(main.system.graphics.ANIM)

Example 2 with LogEntryNode

use of main.system.text.LogEntryNode in project Eidolons by IDemiurge.

the class DeathMaster method unitDies.

public void unitDies(DC_ActiveObj activeObj, Obj _killed, Obj _killer, boolean leaveCorpse, boolean quietly) {
    if (_killed.isDead())
        return;
    String message = null;
    if (_killed == _killer) {
        // + _killed.getInfoString();
        message = _killed + " dies ";
    } else
        message = _killed + " killed by " + _killer + " with " + activeObj;
    SpecialLogger.getInstance().appendSpecialLog(SPECIAL_LOG.MAIN, message);
    _killed.setDead(true);
    BattleFieldObject killed = (BattleFieldObject) _killed;
    BattleFieldObject killer = (BattleFieldObject) _killer;
    Ref ref = Ref.getCopy(killed.getRef());
    ref.setSource(killer.getId());
    ref.setTarget(killed.getId());
    for (AbilityObj abil : killed.getPassives()) {
        abil.kill();
    }
    if (killed.getBuffs() != null) {
        for (Attachment attach : killed.getBuffs()) {
            if (!attach.isRetainAfterDeath()) {
                getState().getAttachmentsMap().get(killed).remove(attach);
                attach.remove();
            }
        }
    }
    if (!leaveCorpse) {
    // leave a *ghost*?
    // destroy items?
    } else {
        if (killed instanceof Unit) {
            try {
                getGame().getDroppedItemManager().dropDead((Unit) killed);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        }
        try {
            getGame().getGraveyardManager().unitDies(killed);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    // getGame().getBattleField().remove(killed); // TODO GRAVEYARD
    if (!quietly) {
        Ref REF = Ref.getCopy(killer.getRef());
        REF.setTarget(killed.getId());
        REF.setSource(killer.getId());
        if (activeObj != null)
            REF.setObj(KEYS.ACTIVE, activeObj);
        if (killed instanceof Unit) {
            getGame().getRules().getMoraleKillingRule().unitDied((Unit) killed, killer.getRef().getAnimationActive());
        }
        LogEntryNode node = game.getLogManager().newLogEntryNode(ENTRY_TYPE.DEATH, killed);
        if (killer.getRef().getAnimationActive() != null) {
            ANIM animation = killer.getRef().getAnimationActive().getAnimation();
            if (animation != null) {
                animation.addPhase(new AnimPhase(PHASE_TYPE.DEATH, killer, killed));
                node.setLinkedAnimation(animation);
            }
        }
        DC_SoundMaster.playEffectSound(SOUNDS.DEATH, killed);
        game.getLogManager().logDeath(killed, killer);
        getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_KILLED, REF));
        game.getLogManager().doneLogEntryNode();
    } else {
        GuiEventManager.trigger(GuiEventType.DESTROY_UNIT_MODEL, killed);
    }
// refreshAll();
}
Also used : AbilityObj(main.ability.AbilityObj) Ref(main.entity.Ref) AnimPhase(main.system.graphics.AnimPhase) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Event(main.game.logic.event.Event) Attachment(main.entity.obj.Attachment) Unit(eidolons.entity.obj.unit.Unit) LogEntryNode(main.system.text.LogEntryNode) ANIM(main.system.graphics.ANIM)

Example 3 with LogEntryNode

use of main.system.text.LogEntryNode in project Eidolons by IDemiurge.

the class DC_PagedLogPanel method refresh.

@Override
public void refresh() {
    setFont(EntryNodeMaster.getFont(isTopPage()));
    if (nodeViewMode && entryNode != null) {
        entryNodes = entryNode.getChildren();
        // only for this page TODO
        setFont(EntryNodeMaster.getSubNodeFont());
    } else {
        // TODO will the index be
        setFont(EntryNodeMaster.getTopFont());
        // correct??
        entryNodes = game.getLogManager().getTopEntryNodesMap().get(getCurrentIndex());
        if (entryNodes == null) {
            entryNodes = new ArrayList<>();
            for (LogEntryNode node : game.getLogManager().getTopNodes()) {
                if (node.getLineIndex() > getRowCount() * getCurrentIndex() && node.getLineIndex() <= (getCurrentIndex() + 1) * getRowCount()) // if (node.getPageIndex() == getCurrentIndex())
                // line index range for the page
                {
                    entryNodes.add(node);
                }
            }
            // cache into a map if page is complete
            if (getPageData().size() - 1 > getCurrentIndex()) {
                game.getLogManager().getTopEntryNodesMap().put(getCurrentIndex(), entryNodes);
            }
        }
    }
    setDirty(true);
    super.refresh();
}
Also used : LogEntryNode(main.system.text.LogEntryNode)

Example 4 with LogEntryNode

use of main.system.text.LogEntryNode in project Eidolons by IDemiurge.

the class RollMaster method rollLogged.

/**
 * @param logString  to be appended to the logged string; for success by default,
 *                   for failure if contains @
 * @param rollSource special descriptor for logging, e.g. if rolling vs Ensnare
 * @returns false if target has resisted ('wins roll')
 */
public static boolean rollLogged(ROLL_TYPES roll_type, String success, String fail, Ref ref, String logString, String rollSource) {
    boolean result = roll(roll_type, success, fail, ref, logString, rollSource, false);
    if (!checkRollLogged(roll_type, result)) {
        return result;
    }
    Object[] args = { roll_type.getName(), ref.getSourceObj().getName(), ref.getTargetObj().getName() };
    if (roll_type.isLogToTop()) {
        args = new Object[] { main.system.text.LogManager.WRITE_TO_TOP, roll_type.getName(), ref.getSourceObj().getName(), ref.getTargetObj().getName() };
    }
    LogEntryNode entry = ref.getGame().getLogManager().newLogEntryNode(result ? ENTRY_TYPE.ROLL_LOST : ENTRY_TYPE.ROLL_WON, args);
    ref.getGame().getLogManager().log(RollMaster.logString);
    ref.getGame().getLogManager().doneLogEntryNode();
    if (CoreEngine.isPhaseAnimsOn())
        if (ref.getActive() != null) {
            ANIM anim = new EffectAnimation((DC_ActiveObj) ref.getActive());
            anim.addPhase(new AnimPhase(PHASE_TYPE.ROLL, roll));
            entry.setLinkedAnimation(anim);
        }
    // PHASE_TYPE.ROLL));
    if (ref.getGame().isDummyMode()) {
        return true;
    }
    return result;
}
Also used : EffectAnimation(eidolons.system.graphics.EffectAnimation) AnimPhase(main.system.graphics.AnimPhase) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) LogEntryNode(main.system.text.LogEntryNode) ANIM(main.system.graphics.ANIM)

Aggregations

LogEntryNode (main.system.text.LogEntryNode)4 ANIM (main.system.graphics.ANIM)3 AnimPhase (main.system.graphics.AnimPhase)2 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 Unit (eidolons.entity.obj.unit.Unit)1 CustomButton (eidolons.swing.components.buttons.CustomButton)1 EffectAnimation (eidolons.system.graphics.EffectAnimation)1 PhaseAnimation (eidolons.system.graphics.PhaseAnimation)1 AbilityObj (main.ability.AbilityObj)1 Ref (main.entity.Ref)1 Attachment (main.entity.obj.Attachment)1 Coordinates (main.game.bf.Coordinates)1 Event (main.game.logic.event.Event)1 ImageButton (main.swing.components.ImageButton)1