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.DeityFacade)
*/
@Override
public String getHTMLInfo(DeityFacade deityFacade) {
if (!(deityFacade instanceof Deity)) {
return EMPTY_STRING;
}
Deity aDeity = (Deity) deityFacade;
final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
if (aDeity != null) {
infoText.appendTitleElement(OutputNameFormatting.piString(aDeity, false));
infoText.appendLineBreak();
infoText.appendI18nFormattedElement("in_InfoDescription", //$NON-NLS-1$
DescriptionFormatting.piWrapDesc(aDeity, pc.getDescription(aDeity), false));
appendFacts(infoText, aDeity);
String aString = getPantheons(aDeity);
if (aString != null) {
infoText.appendSpacer();
infoText.appendI18nElement("in_pantheon", //$NON-NLS-1$
aString);
}
infoText.appendSpacer();
infoText.appendI18nElement("in_domains", //$NON-NLS-1$
getDomains(aDeity));
List<CDOMReference<WeaponProf>> dwp = aDeity.getListFor(ListKey.DEITYWEAPON);
if (dwp != null) {
infoText.appendSpacer();
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_deityFavWeap", ReferenceUtilities.joinLstFormat(dwp, "|"));
}
aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, aDeity.getPrerequisiteList(), false);
if (!aString.isEmpty()) {
infoText.appendSpacer();
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoRequirements", aString);
}
aString = aDeity.getSource();
if (!aString.isEmpty()) {
infoText.appendSpacer();
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoSource", aString);
}
}
return infoText.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.DomainFacade)
*/
@Override
public String getHTMLInfo(DomainFacade domainFacade) {
if (!(domainFacade instanceof DomainFacadeImpl)) {
return EMPTY_STRING;
}
DomainFacadeImpl domainFI = (DomainFacadeImpl) domainFacade;
Domain aDomain = domainFI.getRawObject();
final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
if (aDomain != null) {
infoText.appendTitleElement(OutputNameFormatting.piString(aDomain, false));
appendFacts(infoText, aDomain);
String aString = pc.getDescription(aDomain);
if (!aString.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_domainGrant", aString);
}
aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, aDomain.getPrerequisiteList(), false);
if (!aString.isEmpty()) {
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoRequirements", aString);
}
aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, aDomain, domainFI.getPrerequisiteList(), false);
if (!aString.isEmpty()) {
infoText.appendLineBreak();
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_domainRequirements", aString);
}
aString = SourceFormat.getFormattedString(aDomain, Globals.getSourceDisplay(), true);
if (!aString.isEmpty()) {
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoSource", aString);
}
}
return infoText.toString();
}
use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.
the class Gui2InfoFactory method produceSpellListInfo.
/**
* Produce the HTML info label for a prepared spell list.
* @param book The spell list being output.
* @return The HTML info for the list.
*/
private String produceSpellListInfo(SpellBook spelllist) {
final HtmlInfoBuilder b = new HtmlInfoBuilder(spelllist.getName());
//$NON-NLS-1$
b.append(" (");
b.append(spelllist.getTypeName());
//$NON-NLS-1$
b.append(")");
b.appendLineBreak();
if (spelllist.getDescription() != null) {
//$NON-NLS-1$
b.appendI18nElement("in_descrip", spelllist.getDescription());
b.appendLineBreak();
}
// Look at each spell on each spellcasting class
for (PCClass pcClass : charDisplay.getClassSet()) {
Map<Integer, Integer> spellCountMap = new TreeMap<>();
int highestSpellLevel = -1;
Collection<? extends CharacterSpell> sp = charDisplay.getCharacterSpells(pcClass);
List<CharacterSpell> classSpells = new ArrayList<>(sp);
// Add in the spells granted by objects
pc.addBonusKnownSpellsToList(pcClass, classSpells);
for (CharacterSpell charSpell : classSpells) {
for (SpellInfo spellInfo : charSpell.getInfoList()) {
if (!spelllist.getName().equals(spellInfo.getBook())) {
continue;
}
int level = spellInfo.getActualLevel();
int count = spellCountMap.containsKey(level) ? spellCountMap.get(level) : 0;
count += spellInfo.getTimes();
spellCountMap.put(level, count);
if (level > highestSpellLevel) {
highestSpellLevel = level;
}
}
}
if (!spellCountMap.isEmpty()) {
//$NON-NLS-1$
b.append("<table border=1><tr><td><font size=-1><b>");
b.append(OutputNameFormatting.piString(pcClass, false));
//$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>Prepared</b></font></td>");
for (int i = 0; i <= highestSpellLevel; ++i) {
//$NON-NLS-1$
b.append("<td><font size=-1><center>");
b.append(String.valueOf(spellCountMap.get(i) == null ? 0 : spellCountMap.get(i)));
//$NON-NLS-1$
b.append("</center></font></td>");
}
//$NON-NLS-1$
b.append("</tr></table>");
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.ClassFacade, pcgen.core.facade.ClassFacade)
*/
@Override
public String getHTMLInfo(ClassFacade classFacade, ClassFacade parentClassFacade) {
if (!(classFacade instanceof PCClass)) {
return EMPTY_STRING;
}
PCClass aClass = (PCClass) classFacade;
PCClass parentClass = aClass;
String aString;
boolean isSubClass = aClass instanceof SubClass;
if (isSubClass && parentClassFacade != null) {
parentClass = (PCClass) parentClassFacade;
}
final HtmlInfoBuilder b = new HtmlInfoBuilder(OutputNameFormatting.piString(aClass, false));
b.appendLineBreak();
// Subclass cost - at the top to make choices easier
if (isSubClass && aClass.getSafe(IntegerKey.COST) != 0) {
//$NON-NLS-1$
b.appendI18nElement("in_clInfoCost", String.valueOf(aClass.getSafe(IntegerKey.COST)));
b.appendLineBreak();
}
// Type
aString = aClass.getType();
if (isSubClass && (aString.isEmpty())) {
aString = parentClass.getType();
}
//$NON-NLS-1$
b.appendI18nElement("in_clInfoType", aString);
// Hit Die
HitDie hitDie = aClass.getSafe(ObjectKey.LEVEL_HITDIE);
if (isSubClass && HitDie.ZERO.equals(hitDie)) {
hitDie = parentClass.getSafe(ObjectKey.LEVEL_HITDIE);
}
if (!HitDie.ZERO.equals(hitDie)) {
b.appendSpacer();
//$NON-NLS-1$ //$NON-NLS-2$
b.appendI18nElement("in_clInfoHD", "d" + hitDie.getDie());
}
appendFacts(b, aClass);
if (SettingsHandler.getGame().getTabShown(Tab.SPELLS)) {
FactKey<String> fk = FactKey.valueOf("SpellType");
aString = aClass.getResolved(fk);
if (isSubClass && aString == null) {
aString = parentClass.getSpellType();
}
b.appendSpacer();
//$NON-NLS-1$
b.appendI18nElement("in_clInfoSpellType", aString);
aString = aClass.getSpellBaseStat();
/*
* CONSIDER This test here is the ONLY place where the "magical"
* value of null is tested for in getSpellBaseStat(). This is
* currently set by SubClass and SubstititionClass, so it IS
* used, but the question is: Is there a better method for
* identifying this special deferral to the "parentClass" other
* than null SpellBaseStat? - thpr 11/9/06
*/
if (isSubClass && ((aString == null) || (aString.isEmpty()))) {
aString = parentClass.getSpellBaseStat();
}
b.appendSpacer();
//$NON-NLS-1$
b.appendI18nElement("in_clInfoBaseStat", aString);
}
// Prereqs
aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, aClass.getPrerequisiteList(), false);
if (isSubClass && (aString.isEmpty())) {
aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, parentClass.getPrerequisiteList(), false);
}
if (!aString.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_requirements", aString);
}
//Description
String desc = pc.getDescription(aClass);
if (!desc.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoDescription", DescriptionFormatting.piWrapDesc(aClass, desc, false));
}
// Sub class extra info
if (isSubClass) {
int specialtySpells = aClass.getSafe(IntegerKey.KNOWN_SPELLS_FROM_SPECIALTY);
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_clSpecialtySpells", Delta.toString(specialtySpells));
b.appendSpacer();
//$NON-NLS-1$
b.appendI18nElement("in_clSpecialty", ((SubClass) aClass).getChoice());
}
// Source
aString = aClass.getSource();
if (isSubClass && (aString.isEmpty())) {
aString = parentClass.getSource();
}
if (!aString.isEmpty()) {
b.appendLineBreak();
//$NON-NLS-1$
b.appendI18nElement("in_source", aString);
}
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.SkillFacade)
*/
@Override
public String getHTMLInfo(SkillFacade skillFacade) {
if (!(skillFacade instanceof Skill)) {
return EMPTY_STRING;
}
Skill skill = (Skill) skillFacade;
final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
infoText.appendTitleElement(OutputNameFormatting.piString(skill, false));
infoText.appendLineBreak();
String typeString = StringUtil.join(skill.getTrueTypeList(true), ". ");
if (StringUtils.isNotBlank(typeString)) {
//$NON-NLS-1$
infoText.appendI18nElement(//$NON-NLS-1$
"in_igInfoLabelTextType", typeString);
infoText.appendLineBreak();
}
appendFacts(infoText, skill);
String aString = SkillInfoUtilities.getKeyStatFromStats(pc, skill);
if (!aString.isEmpty()) {
//$NON-NLS-1$
infoText.appendI18nElement("in_iskKEY_STAT", aString);
}
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nElement(//$NON-NLS-1$
"in_iskUntrained", skill.getSafe(ObjectKey.USE_UNTRAINED) ? LanguageBundle.getString("in_yes") : LanguageBundle.getString("in_no"));
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nElement(//$NON-NLS-1$
"in_iskEXCLUSIVE", skill.getSafe(ObjectKey.EXCLUSIVE) ? LanguageBundle.getString("in_yes") : LanguageBundle.getString("in_no"));
String bString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, skill.getPrerequisiteList(), false);
if (!bString.isEmpty()) {
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoRequirements", bString);
}
//Description
String desc = pc.getDescription(skill);
if (!desc.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_InfoDescription", DescriptionFormatting.piWrapDesc(skill, desc, false));
}
bString = skill.getSource();
if (!bString.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nElement("in_iskSource", bString);
}
if (PCGenSettings.OPTIONS_CONTEXT.getBoolean(PCGenSettings.OPTION_SHOW_SKILL_MOD_BREAKDOWN, false)) {
bString = SkillCostDisplay.getModifierExplanation(skill, pc, false);
if (!bString.isEmpty()) {
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_iskHtml_PcMod", bString);
}
}
if (PCGenSettings.OPTIONS_CONTEXT.getBoolean(PCGenSettings.OPTION_SHOW_SKILL_RANK_BREAKDOWN, false)) {
bString = SkillCostDisplay.getRanksExplanation(pc, skill);
if (bString.isEmpty()) {
//$NON-NLS-1$
bString = LanguageBundle.getString("in_none");
}
infoText.appendLineBreak();
//$NON-NLS-1$
infoText.appendI18nFormattedElement(//$NON-NLS-1$
"in_iskHtml_Ranks", bString);
}
return infoText.toString();
}
Aggregations