Search in sources :

Example 1 with XLine

use of main.swing.XLine in project Eidolons by IDemiurge.

the class DrawMaster method draw.

public void draw(CellComp cellComp, Graphics compGraphics, int zoom, boolean editorMode) {
    this.cellComp = cellComp;
    this.zoom = zoom;
    initSizes();
    Map<Rectangle, Object> mouseMap = new XLinkedMap<>();
    cellComp.setMouseMap(mouseMap);
    Unit topObj = cellComp.getTopObj();
    if (isSingleObj()) {
        Image image = cellComp.getGame().getVisionMaster().getVisibilityMaster().getDisplayImageForUnit(topObj);
        if (image != null) {
            compGraphics.drawImage(image, 0, 0, null);
            if (topObj.isWall()) {
                drawWallOverlays(topObj, compGraphics, cellComp.getCoordinates());
            }
            if (GRAPHICS_TEST_MODE) {
                DC_Obj obj = cellComp.getTopObjOrCell();
                drawCI(obj, compGraphics);
                if (FULL_GRAPHICS_TEST_MODE) {
                    compGraphics.drawString("" + obj.getOutlineType(), 0, GuiManager.getCellHeight() - 40);
                    String tooltip = cellComp.getGame().getVisionMaster().getHintMaster().getTooltip(obj);
                    if (tooltip != null) {
                        compGraphics.drawString("" + tooltip, 0, GuiManager.getCellHeight() - 20);
                    }
                    drawSightBlockInfo(cellComp, compGraphics, zoom);
                }
            }
            drawSpecialOverlays(cellComp, compGraphics, zoom);
            return;
        }
    }
    // no overlays at all? Animations at least?
    if (isFramePaintZoom()) {
        if (!isMultiObj()) {
            try {
                drawCellFrame(compGraphics);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        }
    }
    if (!cellComp.isTerrain()) {
        try {
            drawObjComps(compGraphics);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    } else {
        try {
            drawTerrainObj(compGraphics);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    if (!cellComp.isTerrain()) {
        if (topObj.isInfoSelected() || topObj.isActiveSelected()) {
            BufferedImage compOverlayImage = ImageManager.getNewBufferedImage(getCompWidth(), getCompHeight());
            drawComponentOverlays(compOverlayImage.getGraphics());
            BfGridComp.getOverlayMap().put(new XLine(new Point(topObj.getX(), topObj.getY()), new Point(5 - getObjCount() * 2, 0)), compOverlayImage);
        } else {
            drawComponentOverlays(compGraphics);
        }
    }
    drawOverlayingObjects(compGraphics, cellComp);
    // perhaps should work with Obj instead?
    if (isAnimationPaintZoom()) {
        if (cellComp.isAnimated()) {
            try {
                drawAnimations(cellComp, compGraphics);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        }
    }
    if (GRAPHICS_TEST_MODE) {
        drawCI(topObj, compGraphics);
    }
    if (GRAPHICS_TEST_MODE || isEditorMode() || DC_Game.game.isDebugMode()) {
        Coordinates coordinates = cellComp.getCoordinates();
        BfGridComp grid = cellComp.getGrid();
        if (grid == null) {
            grid = cellComp.getGame().getBattleField().getGrid().getGridComp();
        }
        if (coordinates.x - grid.getOffsetX() == 0) {
            drawCoordinateMarkings(coordinates.y, compGraphics, false);
        }
        if (coordinates.y - grid.getOffsetY() == 0) {
            drawCoordinateMarkings(coordinates.x, compGraphics, true);
        }
        if (cellComp.isInfoSelected()) {
            drawCoordinateMarkings(coordinates.x, compGraphics, true);
            drawCoordinateMarkings(coordinates.y, compGraphics, false);
        }
    }
    if (isSightVisualsOn()) {
    // Unit obj = cellComp.getGame().getManager().getActiveObj();
    // // if (!obj.isMine()) return ;
    // boolean extended = !obj.getSightSpectrumCoordinates(false).contains(
    // cellComp.getCoordinates());
    // if (!extended) {
    // extended = obj.getSightSpectrumCoordinates(true)
    // .contains(cellComp.getCoordinates());
    // if (!extended) {
    // return;
    // }
    // }
    // 
    // drawSightVisualsOnCell((Graphics2D) compGraphics, extended, cellComp.getObjects().size() > 0);
    // drawSightBlockInfo(cellComp, compGraphics, zoom);
    }
    drawSpecialOverlays(cellComp, compGraphics, zoom);
}
Also used : BfGridComp(eidolons.swing.components.obj.BfGridComp) XLinkedMap(main.data.XLinkedMap) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage) XLine(main.swing.XLine) DC_Obj(eidolons.entity.obj.DC_Obj)

Example 2 with XLine

use of main.swing.XLine in project Eidolons by IDemiurge.

the class DrawMaster method drawSpecialIcons.

private void drawSpecialIcons(Unit obj) {
    // obj.getEngagementTarget();
    /*
         * when drawing stacked objects, draw a red arrow/sword towards the ET
		 */
    Unit engageShowUnit = obj.getGame().getManager().getInfoUnit();
    if (engageShowUnit == null) {
        engageShowUnit = obj.getGame().getManager().getActiveObj();
    } else if (engageShowUnit.isBfObj()) {
        engageShowUnit = obj.getGame().getManager().getActiveObj();
    }
    Image overlay = null;
    if (engageShowUnit.getEngagementTarget() == obj) {
        overlay = STD_IMAGES.ENGAGEMENT_TARGET.getImage();
    }
    if (obj.getGame().getRules().getEngagedRule().getEngagers(engageShowUnit).contains(obj)) {
        {
            overlay = STD_IMAGES.ENGAGER.getImage();
        }
    }
    if (overlay != null) {
        BufferedImage image = ImageManager.getNewBufferedImage(getObjCompWidth(), getObjCompHeight());
        Graphics g = image.getGraphics();
        drawImage(g, overlay, 24, 24);
        BfGridComp.getOverlayMap().put(new XLine(obj.getCoordinates(), new Coordinates(getOffsetX(obj), getOffsetY(obj))), image);
    }
    if (obj.isUnconscious()) {
    // drawImage(g,
    // ImageManager.getRandomBloodOverlay(GuiManager.getObjSize()), 0,
    // 0);
    // darkening/bloody overlay! perhaps on the cell frame as well,
    // blood stains/dripping
    // drawImage(g, image, x, y);
    // black'n'white?
    }
}
Also used : XLine(main.swing.XLine) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) BufferedImage(java.awt.image.BufferedImage) BufferedImage(java.awt.image.BufferedImage)

Example 3 with XLine

use of main.swing.XLine in project Eidolons by IDemiurge.

the class BfGridComp method drawMap.

private void drawMap(Graphics g, boolean drawOverlays) {
    for (XLine c : getMap(drawOverlays).keySet()) {
        int x = getCellWidth() * (c.getP1().x - getOffsetX()) - offsetX;
        int y = getCellHeight() * (c.getP1().y - getOffsetY()) - offsetY;
        int xOffset = c.getP2().x;
        int yOffset = c.getP2().y;
        g.drawImage(getMap(drawOverlays).get(c), x + xOffset, y + yOffset, null);
    }
}
Also used : XLine(main.swing.XLine)

Example 4 with XLine

use of main.swing.XLine in project Eidolons by IDemiurge.

the class HC_Tree method updateLinks.

private void updateLinks() {
    if (HC_Master.getPreviousSelectedTreeNode() == HC_Master.getSelectedTreeNode()) {
        return;
    }
    HT_Node node = HC_Master.getSelectedTreeNode();
    linksToHighlight = new ArrayList<>();
    selectionPathNodes.clear();
    if (node != null) {
        ObjType type = node.getType();
        // could cache per type too
        while (true) {
            node = map.getNodeForType(node.getParentType());
            if (node == null) {
                break;
            }
            selectionPathNodes.add(node);
            StaticTreeLink link = map.getLinkForChildType(node.getType());
            if (link == null) {
            }
            if (link == null) {
                continue;
            }
            linksToHighlight.add(link);
        }
        linksToHighlight.add(map.getLinkForChildType(type));
    }
    dynamicLinks = new ArrayList<>();
    // add req links
    for (ObjType t : HC_Master.getRequiredSkills(getSelectedType(), false)) {
        XLine line = getLine(getSelectedType(), t);
        TreeLink link = new TreeLink(LINK_TYPE.REQUIRED, line);
        dynamicLinks.add(link);
    }
    // add node from another
    // special requirements (e.g. Mastery, deity, class...)
    DataManager.getChildren(getSelectedType(), getTypes());
}
Also used : XLine(main.swing.XLine) StaticTreeLink(eidolons.client.cc.gui.neo.tree.logic.StaticTreeLink) ObjType(main.entity.type.ObjType) TreeLink(eidolons.client.cc.gui.neo.tree.logic.TreeLink) StaticTreeLink(eidolons.client.cc.gui.neo.tree.logic.StaticTreeLink)

Example 5 with XLine

use of main.swing.XLine in project Eidolons by IDemiurge.

the class DrawMaster method drawObjComps.

private void drawObjComps(Graphics g) {
    if (isSingleObj() || !isStackedPaintZoom() || isStackedIconMode()) {
        Image image = getObjDrawImage(cellComp.getObjects().get(0), false);
        image = ImageManager.getSizedVersion(image, new Dimension(objSize, objSize));
        g.drawImage(image, offsetX, offsetY, null);
        if (!isSingleObj()) {
            drawStackedIcon(g);
        }
    } else {
        // offset !
        if (cellComp.getGame().getAnimationManager().isStackAnimOverride(cellComp.getCoordinates())) {
            return;
        }
        List<Unit> objects = new ArrayList<>(cellComp.getObjects());
        int stackOffsetX = 0;
        int stackOffsetY = 0;
        if (!(cellComp.isWall() || cellComp.isLandscape())) {
            drawCellImage(g);
        } else {
            Unit obj = cellComp.getWallObj();
            if (obj == null) {
                obj = cellComp.getLandscapeObj();
            }
            objects.remove(obj);
            // if (objects.size() == 1) {
            // stackOffsetX = getStackOffsetX();
            // //getXOffsetPerObj(getObjCount());
            // stackOffsetY = getStackOffsetY();
            // // getYOffsetPerObj(getObjCount());
            // }
            Image image = getObjDrawImage(obj, false);
            drawImage(g, image, 0, 0);
            Rectangle rect = new Rectangle(0, 0, getCompWidth(), getCompHeight());
            cellComp.getMouseMap().put(rect, obj);
        }
        // sort cellComp.getObjects() by Z-Order
        for (Unit obj : objects) {
            // TODO selective! Not
            Image image = getObjDrawImage(obj, true);
            // all of them...
            image = ImageManager.getSizedVersion(image, new Dimension(objSize, objSize));
            int x = stackOffsetX + getStackOffsetX();
            int y = stackOffsetY + getStackOffsetY();
            if (obj.isInfoSelected() || obj.isActiveSelected()) {
                BfGridComp.setSelectedObjSize(obj.isInfoSelected(), objSize - getObjCount());
                Coordinates c = new Coordinates(true, x, y + getObjCount() * 3);
                XLine xLine = new XLine(new Point(obj.getX(), obj.getY()), new Point(x, y));
                if (obj.isActiveSelected()) {
                    BfGridComp.setStackedActiveHighlightRelativeCoordinates(c);
                }
                if (obj.isInfoSelected()) {
                    BfGridComp.setStackedInfoHighlightRelativeCoordinates(c);
                }
                // BfGridComp.getMap(obj.isInfoSelected()).put(xLine,
                // image);
                BfGridComp.getUnderlayMap().put(xLine, image);
                BfGridComp.getOverlayMap().put(xLine, infoObjImage);
            } else {
                drawImage(g, image, x, y);
            }
            getOffsetMap().put(obj, new Point(x, y));
            if (obj == cellComp.getTopObj()) {
                topObjX = x;
                topObjY = y;
            }
            Rectangle rect = new Rectangle(x, y, objSize, objSize);
            cellComp.getMouseMap().put(rect, obj);
            if (getStackOffsetX() > getXOffsetPerObj(getObjCount())) {
                stackOffsetX -= 3 * getXOffsetPerObj(getObjCount()) / 2;
            } else {
                stackOffsetX += 3 * getXOffsetPerObj(getObjCount()) / 2;
            }
            if (// TODO should be double or 'triple'
            getStackOffsetY() != 0) // if I want the top obj to end up
            // with the right gap!
            // lower objects can be above, below, ... what's the
            // difference for us?
            // currently if we go with 0, images will overlap!
            {
                stackOffsetY -= getYOffsetPerObj(getObjCount());
            } else {
                stackOffsetY += getYOffsetPerObj(getObjCount());
            }
        // spread evenly instead based on size...
        }
    }
    Unit obj = cellComp.getWallObj();
    if (obj == null) {
        obj = cellComp.getLandscapeObj();
    }
    if (obj != null) {
        if (cellComp.isWall()) {
            drawWallOverlays(obj, g, cellComp.getCoordinates());
        }
    }
}
Also used : XLine(main.swing.XLine) Coordinates(main.game.bf.Coordinates) BufferedImage(java.awt.image.BufferedImage) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

XLine (main.swing.XLine)7 Coordinates (main.game.bf.Coordinates)4 Unit (eidolons.entity.obj.unit.Unit)3 BufferedImage (java.awt.image.BufferedImage)3 StaticTreeLink (eidolons.client.cc.gui.neo.tree.logic.StaticTreeLink)1 TreeLink (eidolons.client.cc.gui.neo.tree.logic.TreeLink)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 BfGridComp (eidolons.swing.components.obj.BfGridComp)1 XLinkedMap (main.data.XLinkedMap)1 ObjType (main.entity.type.ObjType)1 DIRECTION (main.game.bf.Coordinates.DIRECTION)1