use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.
the class Gui2InfoFactory method getEquipmentHtmlInfo.
private HtmlInfoBuilder getEquipmentHtmlInfo(Equipment equip) {
final StringBuilder title = new StringBuilder(50);
title.append(OutputNameFormatting.piString(equip, false));
if (!equip.longName().equals(equip.getName())) {
title.append("(").append(equip.longName()).append(")");
}
final HtmlInfoBuilder b = new HtmlInfoBuilder(null, false);
File icon = equip.getIcon();
if (icon != null) {
b.appendIconElement(icon.toURI().toString());
}
b.appendTitleElement(title.toString());
b.appendLineBreak();
String baseName = equip.getBaseItemName();
if (StringUtils.isNotEmpty(baseName) && !baseName.equals(equip.getName())) {
//$NON-NLS-1$
b.appendI18nElement(//$NON-NLS-1$
"in_igInfoLabelTextBaseItem", baseName);
b.appendLineBreak();
}
//$NON-NLS-1$
b.appendI18nElement(//$NON-NLS-1$
"in_igInfoLabelTextType", StringUtil.join(equip.getTrueTypeList(true), ". "));
appendFacts(b, equip);
//
if (equip.isWeapon() || equip.get(ObjectKey.WIELD) != null) {
b.appendLineBreak();
final WieldCategory wCat = equip.getEffectiveWieldCategory(pc);
if (wCat != null) {
//$NON-NLS-1$
b.appendI18nElement(//$NON-NLS-1$
"in_igInfoLabelTextWield", wCat.getDisplayName());
}
}
//
if (equip.isWeapon() || equip.isArmor() || equip.isShield()) {
b.appendLineBreak();
final String value = (pc.isProficientWith(equip) && equip.meetsPreReqs(pc)) ? //$NON-NLS-1$
LanguageBundle.getString("in_igInfoLabelTextYes") : (SettingsHandler.getPrereqFailColorAsHtmlStart() + //$NON-NLS-1$
LanguageBundle.getString("in_igInfoLabelTextNo") + SettingsHandler.getPrereqFailColorAsHtmlEnd());
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextProficient", value);
}
final String cString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, equip.getPrerequisiteList(), false);
if (!cString.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextReq", cString);
}
BigDecimal cost = equip.getCost(pc);
if (cost != BigDecimal.ZERO) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_igEqModelColCost", COST_FMT.format(cost.doubleValue()));
b.append(" ");
b.append(SettingsHandler.getGame().getCurrencyDisplay());
}
String bString = Globals.getGameModeUnitSet().displayWeightInUnitSet(equip.getWeight(pc).doubleValue());
if (!bString.isEmpty()) {
b.appendLineBreak();
bString += Globals.getGameModeUnitSet().getWeightUnit();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextWeight", bString);
}
Integer a = EqToken.getMaxDexTokenInt(pc, equip);
if (a.intValue() != Constants.MAX_MAXDEX) {
b.appendSpacer();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextMaxDex", a.toString());
}
a = EqToken.getAcCheckTokenInt(pc, equip);
if (equip.isArmor() || equip.isShield() || (a.intValue() != 0)) {
b.appendSpacer();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextAcCheck", a.toString());
}
if (!SettingsHandler.getGame().getACText().isEmpty()) {
a = equip.getACMod(pc);
if (equip.isArmor() || equip.isShield() || (a.intValue() != 0)) {
b.appendSpacer();
b.appendElement(LanguageBundle.getFormattedString(//$NON-NLS-1$
"in_igInfoLabelTextAcBonus", SettingsHandler.getGame().getACText()), a.toString());
}
}
if (SettingsHandler.getGame().getTabShown(Tab.SPELLS)) {
a = EqToken.getSpellFailureTokenInt(pc, equip);
if (equip.isArmor() || equip.isShield() || (a.intValue() != 0)) {
b.appendSpacer();
b.appendI18nElement("in_igInfoLabelTextArcaneFailure", //$NON-NLS-1$
a.toString());
}
}
bString = SettingsHandler.getGame().getDamageResistanceText();
if (!bString.isEmpty()) {
a = EqToken.getEdrTokenInt(pc, equip);
if (equip.isArmor() || equip.isShield() || (a.intValue() != 0)) {
b.appendSpacer();
b.appendElement(bString, a.toString());
}
}
bString = equip.moveString();
if (!bString.isEmpty()) {
b.appendSpacer();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextMove", bString);
}
bString = equip.getSize();
if (!bString.isEmpty()) {
b.appendSpacer();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextSize", bString);
}
bString = equip.getDamage(pc);
if (!bString.isEmpty()) {
if (equip.isDouble()) {
//$NON-NLS-1$
bString += "/" + equip.getAltDamage(pc);
}
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextDamage", bString);
}
String critRangeVar = ControlUtilities.getControlToken(Globals.getContext(), CControl.CRITRANGE);
if (critRangeVar == null) {
int critrange = EqToken.getOldBonusedCritRange(pc, equip, true);
int altcritrange = EqToken.getOldBonusedCritRange(pc, equip, false);
bString = critrange == 0 ? EMPTY_STRING : Integer.toString(critrange);
if (equip.isDouble() && critrange != altcritrange) {
bString += //$NON-NLS-1$
"/" + (altcritrange == 0 ? EMPTY_STRING : Integer.toString(altcritrange));
}
} else {
bString = WeaponToken.getNewCritRangeString(pc, equip, critRangeVar);
}
if (!bString.isEmpty()) {
b.appendSpacer();
//$NON-NLS-1$
b.appendI18nElement("in_ieInfoLabelTextCritRange", bString);
}
String critMultVar = ControlUtilities.getControlToken(Globals.getContext(), CControl.CRITMULT);
if (critMultVar == null) {
bString = EqToken.multAsString(equip.getCritMultiplier());
if (equip.isDouble() && !(equip.getCritMultiplier() == equip.getAltCritMultiplier())) {
//$NON-NLS-1$
bString += "/" + EqToken.multAsString(equip.getAltCritMultiplier());
}
} else {
bString = WeaponToken.getNewCritMultString(pc, equip, critMultVar);
}
if (!bString.isEmpty()) {
b.appendSpacer();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextCritMult", bString);
}
if (equip.isWeapon()) {
bString = Globals.getGameModeUnitSet().displayDistanceInUnitSet(EqToken.getRange(pc, equip).intValue());
if (!bString.isEmpty()) {
b.appendSpacer();
b.appendI18nElement("in_igInfoLabelTextRange", //$NON-NLS-1$
bString + Globals.getGameModeUnitSet().getDistanceUnit());
}
}
bString = equip.getContainerCapacityString();
if (!bString.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextContainer", bString);
}
bString = equip.getContainerContentsString();
if (!bString.isEmpty()) {
b.appendSpacer();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextCurrentlyContains", bString);
}
final int charges = equip.getRemainingCharges();
if (charges >= 0) {
b.appendLineBreak();
b.appendI18nElement("in_igInfoLabelTextCharges", //$NON-NLS-1$
Integer.valueOf(charges).toString());
}
Map<String, String> qualityMap = equip.getMapFor(MapKey.QUALITY);
if (qualityMap != null && !qualityMap.isEmpty()) {
Set<String> qualities = new TreeSet<>();
for (Map.Entry<String, String> me : qualityMap.entrySet()) {
qualities.add(new StringBuilder(50).append(me.getKey()).append(": ").append(me.getValue()).toString());
}
b.appendLineBreak();
b.appendI18nElement("in_igInfoLabelTextQualities", //$NON-NLS-1$
StringUtil.join(qualities, //$NON-NLS-2$
", "));
}
//Description
String desc = pc.getDescription(equip);
if (!desc.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoDescription", DescriptionFormatting.piWrapDesc(equip, desc, false));
}
String IDS = equip.getInterestingDisplayString(pc);
if (!IDS.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextProp", IDS);
}
String note = equip.getNote();
if (!note.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextNote", note);
}
return b;
}
use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.
the class Gui2InfoFactory method getHTMLInfo.
/**
* @see pcgen.core.facade.InfoFactory#getHTMLInfo(pcgen.core.facade.RaceFacade)
*/
@Override
public String getHTMLInfo(RaceFacade raceFacade) {
if (!(raceFacade instanceof Race)) {
return EMPTY_STRING;
}
Race race = (Race) raceFacade;
final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
if (!race.getKeyName().startsWith("<none")) {
infoText.appendTitleElement(OutputNameFormatting.piString(race, false));
infoText.appendLineBreak();
RaceType rt = race.get(ObjectKey.RACETYPE);
if (rt != null) {
//$NON-NLS-1$
infoText.appendI18nElement("in_irInfoRaceType", rt.toString());
}
List<RaceSubType> rst = race.getListFor(ListKey.RACESUBTYPE);
if (rst != null) {
infoText.appendSpacer();
//$NON-NLS-1$
infoText.appendI18nElement("in_irInfoSubType", StringUtil.join(rst, ", "));
}
if (!race.getType().isEmpty()) {
infoText.appendSpacer();
//$NON-NLS-1$
infoText.appendI18nElement("in_irInfoType", race.getType());
}
appendFacts(infoText, race);
infoText.appendLineBreak();
String size = race.getSize();
if (StringUtils.isNotEmpty(size)) {
//$NON-NLS-1$
infoText.appendI18nElement("in_size", size);
}
String movement = getMovement(raceFacade);
if (!movement.isEmpty()) {
infoText.appendSpacer();
//$NON-NLS-1$
infoText.appendI18nElement("in_movement", movement);
}
String vision = getVision(raceFacade);
if (!vision.isEmpty()) {
infoText.appendSpacer();
//$NON-NLS-1$
infoText.appendI18nElement("in_vision", vision);
}
String bString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, race.getPrerequisiteList(), false);
if (!bString.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nElement("in_requirements", bString);
}
String desc = pc.getDescription(race);
if (!desc.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoDescription", DescriptionFormatting.piWrapDesc(race, desc, false));
}
String statAdjustments = getStatAdjustments(raceFacade);
if (StringUtils.isNotEmpty(statAdjustments)) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nElement("in_irTableStat", statAdjustments);
}
LevelCommandFactory levelCommandFactory = race.get(ObjectKey.MONSTER_CLASS);
if (levelCommandFactory != null) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_irInfoMonsterClass", String.valueOf(levelCommandFactory.getLevelCount()), OutputNameFormatting.piString(levelCommandFactory.getPCClass(), false));
}
String favoredClass = getFavoredClass(raceFacade);
if (StringUtils.isNotEmpty(favoredClass)) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nElement("in_favoredClass", favoredClass);
}
bString = race.getSource();
if (!bString.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nElement("in_sourceLabel", bString);
}
}
return infoText.toString();
}
use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.
the class Gui2InfoFactory method getHTMLInfo.
@Override
public String getHTMLInfo(EquipModFacade equipModFacade, EquipmentFacade equipFacade) {
if (equipModFacade == null || !(equipModFacade instanceof EquipmentModifier) || equipFacade == null || !(equipFacade instanceof Equipment)) {
return EMPTY_STRING;
}
EquipmentModifier equipMod = (EquipmentModifier) equipModFacade;
Equipment equip = (Equipment) equipFacade;
final StringBuilder title = new StringBuilder(50);
title.append(OutputNameFormatting.piString(equipMod, false));
final HtmlInfoBuilder b = new HtmlInfoBuilder(null, false);
b.appendTitleElement(title.toString());
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement(//$NON-NLS-1$
"in_igInfoLabelTextType", StringUtil.join(equipMod.getTrueTypeList(true), ". "));
// Various cost types
int iPlus = equipMod.getSafe(IntegerKey.PLUS);
if (iPlus != 0) {
b.appendLineBreak();
b.appendI18nElement("in_igInfoLabelTextPlus", String.valueOf(iPlus));
}
Formula baseCost = equipMod.getSafe(FormulaKey.BASECOST);
if (!"0".equals(baseCost.toString())) {
b.appendLineBreak();
b.appendI18nElement("in_igInfoLabelTextPrecost", String.valueOf(baseCost));
}
Formula cost = equipMod.getSafe(FormulaKey.COST);
if (!"0".equals(cost.toString())) {
b.appendLineBreak();
b.appendI18nElement("in_igEqModelColCost", String.valueOf(cost));
}
//Description
String desc = pc.getDescription(equipMod);
if (!desc.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoDescription", DescriptionFormatting.piWrapDesc(equipMod, desc, false));
}
// Special properties
StringBuilder sb = new StringBuilder(100);
boolean first = true;
for (SpecialProperty sp : equipMod.getSafeListFor(ListKey.SPECIAL_PROPERTIES)) {
if (!first) {
sb.append(", ");
}
first = false;
sb.append(sp.getDisplayName());
}
if (sb.length() > 0) {
b.appendLineBreak();
b.appendI18nElement("in_igInfoLabelTextSprop", sb.toString());
}
final String cString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, equip, equipMod.getPrerequisiteList(), false);
if (!cString.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextReq", cString);
}
String bString = equipMod.getSource();
if (!bString.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_igInfoLabelTextSource", bString);
}
b.appendLineBreak();
return b.toString();
}
use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.
the class Gui2InfoFactory method getHTMLInfo.
/**
* @see pcgen.core.facade.InfoFactory#getHTMLInfo(pcgen.core.facade.TemplateFacade)
*/
@Override
public String getHTMLInfo(TemplateFacade templateFacade) {
if (templateFacade == null) {
return EMPTY_STRING;
}
PCTemplate template = (PCTemplate) templateFacade;
final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
infoText.appendTitleElement(OutputNameFormatting.piString(template, false));
appendFacts(infoText, template);
RaceType rt = template.get(ObjectKey.RACETYPE);
if (rt != null) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nElement("in_irInfoRaceType", rt.toString());
}
if (!template.getType().isEmpty()) {
infoText.appendSpacer();
//$NON-NLS-1$
infoText.appendI18nElement("in_irInfoType", template.getType());
}
String aString = pc.getDescription(template);
if (!aString.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoDescription", aString);
}
aString = TemplateModifier.modifierString(template, pc);
if (!aString.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nElement("in_modifier", aString);
}
aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, template.getPrerequisiteList(), false);
if (!aString.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nElement("in_requirements", aString);
}
aString = template.getSource();
if (!aString.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nElement("in_sourceLabel", aString);
}
return infoText.toString();
}
use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.
the class SpellSupportFacadeImpl method getClassInfo.
/**
* @see pcgen.core.facade.SpellSupportFacade#getClassInfo(pcgen.core.facade.ClassFacade)
*/
@Override
public String getClassInfo(ClassFacade spellcaster) {
if (!(spellcaster instanceof PCClass)) {
return "";
}
PCClass aClass = (PCClass) spellcaster;
SpellSupportForPCClass spellSupport = pc.getSpellSupport(aClass);
int highestSpellLevel = spellSupport.getHighestLevelSpell(pc);
final HtmlInfoBuilder b = new HtmlInfoBuilder();
//$NON-NLS-1$
b.append("<table border=1><tr><td><font size=-2><b>");
//$NON-NLS-1$
b.append(OutputNameFormatting.piString(aClass, false)).append(" [");
b.append(String.valueOf(charDisplay.getLevel(aClass) + //$NON-NLS-1$
(int) pc.getTotalBonusTo("PCLEVEL", aClass.getKeyName())));
//$NON-NLS-1$
b.append("]</b></font></td>");
for (int i = 0; i <= highestSpellLevel; ++i) {
//$NON-NLS-1$
b.append("<td><font size=-2><b><center> ");
b.append(String.valueOf(i));
//$NON-NLS-1$
b.append(" </b></center></font></td>");
}
//$NON-NLS-1$
b.append("</tr>");
//$NON-NLS-1$
b.append("<tr><td><font size=-1><b>Cast</b></font></td>");
for (int i = 0; i <= highestSpellLevel; ++i) {
//$NON-NLS-1$
b.append("<td><font size=-1><center>");
b.append(getNumCast(aClass, i, pc));
//$NON-NLS-1$
b.append("</center></font></td>");
}
//$NON-NLS-1$
b.append("</tr>");
// Making sure KnownList can be handled safely and produces the correct behaviour
if (spellSupport.hasKnownList() || spellSupport.hasKnownSpells(pc)) {
//$NON-NLS-1$
b.append("<tr><td><font size=-1><b>Known</b></font></td>");
for (int i = 0; i <= highestSpellLevel; ++i) {
final int a = spellSupport.getKnownForLevel(i, pc);
final int bonus = spellSupport.getSpecialtyKnownForLevel(i, pc);
//$NON-NLS-1$
b.append("<td><font size=-1><center>");
b.append(String.valueOf(a));
if (bonus > 0) {
b.append('+').append(Integer.toString(bonus));
}
//$NON-NLS-1$
b.append("</center></font></td>");
}
//$NON-NLS-1$
b.append("</tr>");
}
//$NON-NLS-1$
b.append("<tr><td><font size=-1><b>DC</b></font></td>");
for (int i = 0; i <= highestSpellLevel; ++i) {
//$NON-NLS-1$
b.append("<td><font size=-1><center>");
b.append(String.valueOf(getDC(aClass, i, pc)));
//$NON-NLS-1$
b.append("</center></font></td>");
}
//$NON-NLS-1$
b.append("</tr></table>");
//$NON-NLS-1$
b.appendI18nElement("InfoSpells.caster.type", aClass.getSpellType());
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("InfoSpells.stat.bonus", aClass.getSpellBaseStat());
if (pc.hasAssocs(aClass, AssociationKey.SPECIALTY) || charDisplay.hasDomains()) {
boolean needComma = false;
StringBuilder schoolInfo = new StringBuilder();
String spec = pc.getAssoc(aClass, AssociationKey.SPECIALTY);
if (spec != null) {
schoolInfo.append(spec);
needComma = true;
}
for (Domain d : charDisplay.getSortedDomainSet()) {
if (needComma) {
schoolInfo.append(',');
}
needComma = true;
schoolInfo.append(d.getKeyName());
}
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("InfoSpells.school", schoolInfo.toString());
}
Set<String> set = new TreeSet<>();
for (SpellProhibitor sp : aClass.getSafeListFor(ListKey.PROHIBITED_SPELLS)) {
set.addAll(sp.getValueList());
}
Collection<? extends SpellProhibitor> prohibList = charDisplay.getProhibitedSchools(aClass);
if (prohibList != null) {
for (SpellProhibitor sp : prohibList) {
set.addAll(sp.getValueList());
}
}
if (!set.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement(//$NON-NLS-1$
"InfoSpells.prohibited.school", //$NON-NLS-1$
StringUtil.join(set, ","));
}
String bString = SourceFormat.getFormattedString(aClass, Globals.getSourceDisplay(), true);
if (bString.length() > 0) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_source", bString);
}
return b.toString();
}
Aggregations