Search in sources :

Example 1 with SmartText

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

the class DrawMaster method drawInfoIcons.

private void drawInfoIcons(Graphics g, Unit obj) {
    if (obj.isBfObj()) {
        return;
    }
    // DrawHelper.AP_ICON_SIZE * objSize
    int size = 28;
    Image image = ImageManager.getSizedVersion(STD_IMAGES.COUNTERS.getPath(), size).getImage();
    // if (isMultiObj())
    // size = size * getMultiObjSizeMod() / 100;
    // DrawHelper.AP_ICON_X *
    int x = getCompWidth() - size;
    // DrawHelper.AP_ICON_Y *
    int y = size;
    drawImage(g, image, x, y);
    VALUE_CASES CASE = SmartTextManager.getParamCase(PARAMS.C_N_OF_COUNTERS, obj);
    String string = obj.getParam(PARAMS.C_N_OF_COUNTERS);
    SmartText text = new SmartText(string, CASE.getColor());
    Point c = // getHeight());
    new Point(getCompWidth() - FontMaster.getStringWidth(text.getFont(), text.getText()), size + FontMaster.getFontHeight(text.getFont()));
    drawText(g, text, c);
}
Also used : VALUE_CASES(main.swing.renderers.SmartTextManager.VALUE_CASES) SmartText(main.system.text.SmartText) BufferedImage(java.awt.image.BufferedImage)

Example 2 with SmartText

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

the class PriorityListItem method resetSmartText.

private void resetSmartText() {
    String value;
    Color color;
    if (unit.getGame().getVisionMaster().getDetectionMaster().checkDetectedEnemy(unit)) {
        value = unit.getParam(PARAMS.C_N_OF_ACTIONS);
        color = SmartTextManager.getParamCase(PARAMS.C_N_OF_ACTIONS, unit).getColor();
    } else {
        value = "?";
        color = ColorManager.getAspectColor(unit.getType());
    }
    apText = new SmartText(value, color);
    if (unit.getGame().getVisionMaster().getDetectionMaster().checkDetectedEnemy(unit)) {
        value = unit.getParam(PARAMS.C_INITIATIVE);
        color = SmartTextManager.getParamCase(PARAMS.C_INITIATIVE, unit).getColor();
    } else {
        value = "?";
        color = ColorManager.getAspectColor(unit.getType());
    }
    initText = new SmartText(value, color);
}
Also used : SmartText(main.system.text.SmartText)

Example 3 with SmartText

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

the class HC_Tree method updateText.

private void updateText() {
    textMap.clear();
    textBgPoint1 = null;
    textBgPoint2 = null;
    if (isViewMode()) {
        return;
    }
    if (Launcher.DEV_MODE) {
        if (CoreEngine.isArcaneVault()) {
            return;
        }
    }
    // TODO draw black background for this!
    if (isDisplayRequirements()) {
        boolean rank = false;
        if (reqTextType == null) {
            reqTextType = getSelectedType();
        } else {
            rank = true;
        }
        if (types.contains(reqTextType)) {
            Integer x = null;
            Integer y = map.getPointForType(reqTextType).y + 58;
            boolean above = false;
            boolean centered = false;
            Integer originX = null;
            if (y >= HT_MapBuilder.defTreeHeight - 130) {
                y = map.getPointForType(reqTextType).y - 20;
                above = true;
            }
            int mode = 0;
            // display SD ?
            if (rank) {
                mode = RequirementsManager.RANK_MODE;
            }
            Requirements reqs = reqTextType.getGame().getRequirementsManager().getRequirements((rank ? hero.getFeat(isSkill(), reqTextType) : reqTextType), mode);
            Point point;
            Color color = ColorManager.CRIMSON;
            Font font = getDefaultFont();
            List<String> list;
            if (reasons != null) {
                list = reasons;
            } else {
                Ref ref = new Ref(hero);
                ref.setMatch((reqTextType).getId());
                reqs.preCheck(ref);
                list = reqs.getReasons();
                reasons = new ArrayList<>();
            }
            for (String text : list) {
                if (text.equals(InfoMaster.NOT_ENOUGH_MASTERY)) {
                    text = InfoMaster.NOT_ENOUGH_MASTERY_SLOTS + ((SkillPointCondition) reqs.getReqMap().get(text)).getPointsRequired();
                }
                text = TextParser.parse(text, new Ref(getHero()));
                text = text.replace(StringMaster.MASTERY + " ", "");
                text = text.replace(" needed", "");
                text = text.replace(" required", "");
                if (!text.contains(" or ")) {
                    if (text.contains(": ")) {
                        String varPart = text.split(": ")[1];
                        if (varPart.startsWith("(") || StringMaster.isInteger("" + varPart.charAt(0))) {
                            String parsedVarPart = "";
                            try {
                                parsedVarPart = "" + new Formula(varPart).getInt(new Ref(getHero()));
                            } catch (Exception e) {
                                main.system.ExceptionMaster.printStackTrace(e);
                            }
                            if (!parsedVarPart.isEmpty()) // TextParser.parse(varPart, new
                            // Ref(getHero()));
                            {
                                text = text.replace(varPart, parsedVarPart);
                            }
                        }
                    }
                }
                reasons.add(text);
            }
            Collections.sort(reasons, new Comparator<String>() {

                public int compare(String o1, String o2) {
                    if (o1.length() < o2.length()) {
                        return 1;
                    }
                    if (o1.length() > o2.length()) {
                        return -1;
                    }
                    return 0;
                }
            });
            int stringWidth;
            for (String text : reasons) {
                SmartText smartText = new SmartText(text, color);
                smartText.setFont(font);
                stringWidth = FontMaster.getStringWidth(font, text);
                if (x == null) {
                    x = map.getPointForType(reqTextType).x;
                    if (x + stringWidth >= getPanel().getWidth() - 10) {
                        x = getPanel().getWidth() - stringWidth - 10;
                        originX = x;
                        centered = true;
                    }
                } else if (centered) {
                    x = originX;
                // x = stringWidth - originX / 2 + getPanel().getWidth()
                // - stringWidth / 2;
                }
                if (x == map.getPointForType(reqTextType).x) {
                    x = map.getPointForType(reqTextType).x - stringWidth / 4;
                }
                if (x < 0) {
                    x = 0;
                }
                if (above) {
                    y -= 20;
                } else {
                    y += 20;
                }
                if (x == null) {
                    x = map.getPointForType(reqTextType).x;
                }
                point = new Point(x, y);
                textMap.put(point, smartText);
                // TODO if above... vice versa
                if (textBgPoint1 == null) {
                    textBgPoint1 = new Point(x + stringWidth, y - FontMaster.getFontHeight(font));
                }
            }
            textBgPoint2 = new Point(x, y);
            if (above) {
                Point buffer = textBgPoint1;
                textBgPoint1 = new Point(textBgPoint2.x, textBgPoint2.y - FontMaster.getFontHeight(font));
                textBgPoint2 = new Point(buffer.x, buffer.y + FontMaster.getFontHeight(font));
            }
        // mouse map on reqs -> goto req-skill or so
        }
    }
    reasons = null;
    reqTextType = null;
}
Also used : SmartText(main.system.text.SmartText) Requirements(main.elements.conditions.Requirements) Formula(main.system.math.Formula) Ref(main.entity.Ref) SkillPointCondition(eidolons.ability.conditions.req.SkillPointCondition)

Example 4 with SmartText

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

the class HC_Tree method updateReqText.

public void updateReqText(ObjType type, List<String> reasons) {
    textMap.clear();
    Point basePoint = map.getPointForType(type);
    Color color = ColorManager.CRIMSON;
    int y = basePoint.y;
    for (String r : reasons) {
        int x = basePoint.x;
        Font font = getDefaultFont();
        y += FontMaster.getFontHeight(font) + 4;
        Point point = new Point(x, y);
        SmartText smartText = new SmartText(r, color);
        smartText.setFont(font);
        textMap.put(point, smartText);
    }
// clear?
}
Also used : SmartText(main.system.text.SmartText)

Example 5 with SmartText

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

the class HC_Tree method drawText.

protected void drawText(Graphics g) {
    for (Point p : textMap.keySet()) {
        SmartText smartText = textMap.get(p);
        g.setFont(smartText.getFont());
        g.setColor(smartText.getColor());
        g.drawString(smartText.getText(), p.x, p.y);
    }
    if (isNodeNamesDrawn()) {
        Font defaultFont = getDefaultFont();
        for (Point p : map.getNodeMap().keySet()) {
            int wrapLength = 15;
            ObjType type = map.getNodeMap().get(p).getType();
            String text = type.getName();
            List<String> list = TextWrapper.wrap(text, wrapLength);
            int width = FontMaster.getStringLengthForWidth(defaultFont, Math.min(wrapLength, text.length()));
            int offsetX = (width - map.getNodeSize()) / 2;
            int x = Math.max(p.x - offsetX, 0);
            // boolean hasOverlap = false;
            int offsetY = 5;
            // lower if overlap
            int y = Math.max(p.y - offsetY, 0);
            int fontHeight = FontMaster.getFontHeight(defaultFont) + 3;
            int height = list.size() * fontHeight + 5;
            List<ObjType> overlapping = map.getTypesWithinRange(type, 0, 0, x, y, Math.max(20, (width - map.getNodeSize())), fontHeight * 3 / 2);
            if (y < 5) {
                y = 5;
            }
            if (x <= offsetX) {
                x = offsetX;
            }
            if (overlapping.size() > 0) {
                LogMaster.log(1, type + " has " + overlapping);
                y += map.getNodeSize() + offsetY * 2;
                while (overlapping.size() > 0) {
                    y += fontHeight;
                    if (y >= map.getDimension().height) {
                        y -= fontHeight;
                        break;
                    }
                    overlapping = map.getTypesWithinRange(type, 0, 0, x, y, Math.max(20, (width - map.getNodeSize())), fontHeight * 3 / 2);
                    LogMaster.log(1, type + " has " + overlapping);
                }
                while (overlapping.size() > 0) {
                    y -= fontHeight;
                    if (y <= offsetY) {
                        y = offsetY;
                        break;
                    }
                    overlapping = map.getTypesWithinRange(type, 0, 0, x, y, Math.max(20, (width - map.getNodeSize())), fontHeight * 3 / 2);
                    LogMaster.log(1, type + " has " + overlapping);
                }
            }
            // height += offsetY;
            g.setColor(ColorManager.getTranslucent(getTipBackgroundColor(), 90));
            g.fillRect(x - 12, y - 12, width, height);
            for (String str : list) {
                g.setColor(getTextColor());
                g.drawString(str, x, y);
                y += fontHeight;
            }
        }
    }
}
Also used : ObjType(main.entity.type.ObjType) SmartText(main.system.text.SmartText)

Aggregations

SmartText (main.system.text.SmartText)13 BufferedImage (java.awt.image.BufferedImage)3 VALUE_CASES (main.swing.renderers.SmartTextManager.VALUE_CASES)3 PARAMETER (main.content.values.parameters.PARAMETER)2 SkillPointCondition (eidolons.ability.conditions.req.SkillPointCondition)1 CellComp (eidolons.swing.components.obj.CellComp)1 Requirements (main.elements.conditions.Requirements)1 Ref (main.entity.Ref)1 ObjType (main.entity.type.ObjType)1 Formula (main.system.math.Formula)1