Search in sources :

Example 1 with BfGridComp

use of eidolons.swing.components.obj.BfGridComp 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 BfGridComp

use of eidolons.swing.components.obj.BfGridComp in project Eidolons by IDemiurge.

the class LE_MapViewComp method tabSelected.

@Override
public void tabSelected(int index) {
    if (mission == null) {
        currentLevel = levels.get(index);
    } else {
        currentLevel = mission.getLevels().get(index);
    }
    LevelEditor.getMainPanel().setCurrentLevel(currentLevel);
    LevelEditor.getMainPanel().activateLevel(currentLevel);
    tabs.getCurrentComp().requestFocusInWindow();
    if (isMinimapMode()) {
        map = maps.get(currentLevel);
        grid = null;
    } else {
        grid = grids.get(currentLevel);
        map = null;
    }
    if (map == null && grid == null) {
        if (isMinimapMode()) {
            map = currentLevel.getMinimap();
            map.setCustomMouseListener(LevelEditor.getMouseMaster());
            map.setMouseWheelListener(LevelEditor.getMouseMaster());
            map.init();
            maps.put(currentLevel, map);
        } else {
            grid = new BfGridComp(LevelEditor.getSimulation(), SIZE.width, SIZE.height, getZoom());
            grid.getPanel().addMouseListener(LevelEditor.getMouseMaster());
            grids.put(currentLevel, grid);
        }
        currentLevel.setInitialized(true);
    } else {
    // if (map != null) {
    // }
    // if (grid != null) {
    // }
    // if (!map.isInitialized()) {
    // map.init();
    // }
    }
    // grid.refresh();
    if (tabs.getCurrentComp().getComponentCount() > 0) {
        if (!isMinimapMode()) {
            grid.refresh();
        }
        return;
    }
    if (isMinimapMode()) {
        tabs.getCurrentComp().add(map.getComp(), "pos 0 0");
    } else {
        grid.refresh();
        tabs.getCurrentComp().add(grid.getPanel(), "pos 0 0");
    }
}
Also used : BfGridComp(eidolons.swing.components.obj.BfGridComp)

Aggregations

BfGridComp (eidolons.swing.components.obj.BfGridComp)2 DC_Obj (eidolons.entity.obj.DC_Obj)1 Unit (eidolons.entity.obj.unit.Unit)1 BufferedImage (java.awt.image.BufferedImage)1 XLinkedMap (main.data.XLinkedMap)1 Coordinates (main.game.bf.Coordinates)1 XLine (main.swing.XLine)1