use of main.elements.conditions.Requirements 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;
}
Aggregations