Search in sources :

Example 1 with ImageButton

use of main.swing.components.ImageButton 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)

Aggregations

CustomButton (eidolons.swing.components.buttons.CustomButton)1 PhaseAnimation (eidolons.system.graphics.PhaseAnimation)1 Coordinates (main.game.bf.Coordinates)1 ImageButton (main.swing.components.ImageButton)1 ANIM (main.system.graphics.ANIM)1 LogEntryNode (main.system.text.LogEntryNode)1