Search in sources :

Example 1 with HtmlInfoBuilder

use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.

the class Gui2InfoFactory method getHTMLInfo.

@Override
public String getHTMLInfo(TempBonusFacade tempBonusFacade) {
    if (tempBonusFacade == null) {
        return EMPTY_STRING;
    }
    if (!(tempBonusFacade instanceof TempBonusFacadeImpl)) {
        final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
        infoText.appendTitleElement(tempBonusFacade.toString());
        return infoText.toString();
    }
    TempBonusFacadeImpl tempBonus = (TempBonusFacadeImpl) tempBonusFacade;
    CDOMObject originObj = tempBonus.getOriginObj();
    final HtmlInfoBuilder infoText;
    if (originObj instanceof Equipment) {
        infoText = getEquipmentHtmlInfo((Equipment) originObj);
    } else {
        infoText = new HtmlInfoBuilder();
        infoText.appendTitleElement(OutputNameFormatting.piString(originObj, false));
        //$NON-NLS-1$ //$NON-NLS-2$
        infoText.append(" (").append(tempBonus.getOriginType()).append(")");
    }
    if (tempBonus.getTarget() != null) {
        String targetName = charDisplay.getName();
        if (tempBonus.getTarget() instanceof CDOMObject) {
            targetName = ((CDOMObject) tempBonus.getTarget()).getKeyName();
        }
        infoText.appendLineBreak();
        //$NON-NLS-1$
        infoText.appendI18nElement("in_itmInfoLabelTextTarget", targetName);
        StringBuilder bonusValues = new StringBuilder(100);
        Map<BonusObj, TempBonusInfo> bonusMap = pc.getTempBonusMap(originObj.getKeyName(), targetName);
        boolean first = true;
        List<BonusObj> bonusList = new ArrayList<>(bonusMap.keySet());
        bonusList.sort(new BonusComparator());
        for (BonusObj bonusObj : bonusList) {
            if (!first) {
                //$NON-NLS-1$
                bonusValues.append(", ");
            }
            first = false;
            //$NON-NLS-1$
            String adj = ADJ_FMT.format(bonusObj.resolve(pc, ""));
            //$NON-NLS-1$
            bonusValues.append(adj + " " + bonusObj.getDescription());
        }
        if (bonusValues.length() > 0) {
            infoText.appendLineBreak();
            infoText.appendI18nElement(//$NON-NLS-1$
            "in_itmInfoLabelTextEffect", bonusValues.toString());
        }
    }
    if (originObj instanceof Spell) {
        Spell aSpell = (Spell) originObj;
        infoText.appendLineBreak();
        //$NON-NLS-1$
        infoText.appendI18nElement(//$NON-NLS-1$
        "in_spellDuration", aSpell.getListAsString(ListKey.DURATION));
        infoText.appendSpacer();
        //$NON-NLS-1$
        infoText.appendI18nElement(//$NON-NLS-1$
        "in_spellRange", aSpell.getListAsString(ListKey.RANGE));
        infoText.appendSpacer();
        //$NON-NLS-1$
        infoText.appendI18nElement(//$NON-NLS-1$
        "in_spellTarget", aSpell.getSafe(StringKey.TARGET_AREA));
    }
    String aString = originObj.getSafe(StringKey.TEMP_DESCRIPTION);
    if (StringUtils.isEmpty(aString) && originObj instanceof Spell) {
        Spell sp = (Spell) originObj;
        aString = DescriptionFormatting.piWrapDesc(sp, pc.getDescription(sp), false);
    } else if (StringUtils.isEmpty(aString) && originObj instanceof Ability) {
        Ability ab = (Ability) originObj;
        List<CNAbility> wrappedAbility = Collections.singletonList(CNAbilityFactory.getCNAbility(ab.getCDOMCategory(), Nature.NORMAL, ab));
        aString = DescriptionFormatting.piWrapDesc(ab, pc.getDescription(wrappedAbility), false);
    }
    if (!aString.isEmpty()) {
        infoText.appendLineBreak();
        //$NON-NLS-1$
        infoText.appendI18nElement("in_itmInfoLabelTextDesc", aString);
    }
    aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, originObj.getPrerequisiteList(), false);
    if (!aString.isEmpty()) {
        infoText.appendLineBreak();
        //$NON-NLS-1$
        infoText.appendI18nElement("in_requirements", aString);
    }
    infoText.appendLineBreak();
    infoText.appendI18nElement(//$NON-NLS-1$
    "in_itmInfoLabelTextSource", SourceFormat.getFormattedString(originObj, Globals.getSourceDisplay(), true));
    return infoText.toString();
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) BonusObj(pcgen.core.bonus.BonusObj) ArrayList(java.util.ArrayList) Spell(pcgen.core.spell.Spell) CharacterSpell(pcgen.core.character.CharacterSpell) TempBonusInfo(pcgen.core.BonusManager.TempBonusInfo) Equipment(pcgen.core.Equipment) CDOMObject(pcgen.cdom.base.CDOMObject) ArrayList(java.util.ArrayList) List(java.util.List) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder)

Example 2 with HtmlInfoBuilder

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.EquipmentFacade)
	 */
@Override
public String getHTMLInfo(EquipmentFacade equipFacade) {
    if (equipFacade == null || !(equipFacade instanceof Equipment)) {
        return EMPTY_STRING;
    }
    Equipment equip = (Equipment) equipFacade;
    final HtmlInfoBuilder b = getEquipmentHtmlInfo(equip);
    String bString = equip.getSource();
    if (!bString.isEmpty()) {
        b.appendLineBreak();
        //$NON-NLS-1$
        b.appendI18nElement("in_igInfoLabelTextSource", bString);
    }
    b.appendLineBreak();
    return b.toString();
}
Also used : Equipment(pcgen.core.Equipment) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder)

Example 3 with HtmlInfoBuilder

use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.

the class Gui2InfoFactory method produceSpellBookInfo.

/**
	 * Produce the HTML info label for a spell book.
	 * @param book The spell book being output.
	 * @return The HTML info for the book.
	 */
private String produceSpellBookInfo(SpellBook book) {
    final HtmlInfoBuilder b = new HtmlInfoBuilder(book.getName());
    //$NON-NLS-1$
    b.append(" (");
    b.append(book.getTypeName());
    if (book.getName().equals(charDisplay.getSpellBookNameToAutoAddKnown())) {
        b.append(TWO_SPACES).append(BOLD);
        b.append(//$NON-NLS-1$
        LanguageBundle.getString("InfoSpellsSubTab.DefaultKnownBook")).append(END_BOLD);
    }
    //$NON-NLS-1$
    b.append(")");
    b.appendLineBreak();
    b.append(LanguageBundle.getFormattedString(//$NON-NLS-1$
    "InfoSpells.html.spellbook.details", new Object[] { book.getNumPages(), book.getNumPagesUsed(), book.getPageFormula(), book.getNumSpells() }));
    if (book.getDescription() != null) {
        b.appendLineBreak();
        //$NON-NLS-1$
        b.appendI18nElement("in_descrip", book.getDescription());
    }
    return b.toString();
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder)

Example 4 with HtmlInfoBuilder

use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.

the class Gui2InfoFactory method getHTMLInfo.

@Override
public String getHTMLInfo(KitFacade kitFacade) {
    if (kitFacade == null) {
        return EMPTY_STRING;
    }
    Kit kit = (Kit) kitFacade;
    final HtmlInfoBuilder infoText = new HtmlInfoBuilder();
    infoText.appendTitleElement(OutputNameFormatting.piString(kit, false));
    appendFacts(infoText, kit);
    String aString = PrerequisiteUtilities.preReqHTMLStringsForList(pc, null, kit.getPrerequisiteList(), false);
    if (!aString.isEmpty()) {
        infoText.appendLineBreak();
        //$NON-NLS-1$
        infoText.appendI18nElement("in_requirements", aString);
    }
    List<BaseKit> sortedObjects = new ArrayList<>();
    sortedObjects.addAll(kit.getSafeListFor(ListKey.KIT_TASKS));
    sortedObjects.sort(new ObjectTypeComparator());
    String lastObjectName = EMPTY_STRING;
    for (BaseKit bk : sortedObjects) {
        String objName = bk.getObjectName();
        if (!objName.equals(lastObjectName)) {
            if (!EMPTY_STRING.equals(lastObjectName)) {
                infoText.append("; ");
            } else {
                infoText.appendLineBreak();
            }
            infoText.append("  <b>" + objName + "</b>: ");
            lastObjectName = objName;
        } else {
            infoText.append(", ");
        }
        infoText.append(bk.toString());
    }
    BigDecimal totalCost = kit.getTotalCost(pc);
    if (totalCost != null) {
        infoText.appendLineBreak();
        //$NON-NLS-1$
        infoText.appendI18nFormattedElement(//$NON-NLS-1$
        "in_kitInfo_TotalCost", COST_FMT.format(totalCost), SettingsHandler.getGame().getCurrencyDisplay());
    }
    String desc = pc.getDescription(kit);
    if (!desc.isEmpty()) {
        infoText.appendLineBreak();
        //$NON-NLS-1$
        infoText.appendI18nFormattedElement(//$NON-NLS-1$
        "in_InfoDescription", DescriptionFormatting.piWrapDesc(kit, desc, false));
    }
    aString = kit.getSource();
    if (!aString.isEmpty()) {
        infoText.appendLineBreak();
        //$NON-NLS-1$
        infoText.appendI18nElement("in_sourceLabel", aString);
    }
    //TODO ListKey.KIT_TASKS
    return infoText.toString();
}
Also used : BaseKit(pcgen.core.kit.BaseKit) BaseKit(pcgen.core.kit.BaseKit) Kit(pcgen.core.Kit) ArrayList(java.util.ArrayList) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder) BigDecimal(java.math.BigDecimal)

Example 5 with HtmlInfoBuilder

use of pcgen.gui2.util.HtmlInfoBuilder in project pcgen by PCGen.

the class Gui2CampaignInfoFactory method getHTMLInfo.

public String getHTMLInfo(SourceSelectionFacade selection) {
    if (selection.getCampaigns().getSize() == 1) {
        return getHTMLInfo(selection.getCampaigns().getElementAt(0));
    }
    final HtmlInfoBuilder infoText = new HtmlInfoBuilder(selection.toString());
    for (CampaignFacade campaign : selection.getCampaigns()) {
        if (campaign == null || !(campaign instanceof Campaign)) {
            continue;
        }
        Campaign aCamp = (Campaign) campaign;
        infoText.appendLineBreak();
        infoText.appendLineBreak();
        infoText.appendTitleElement(aCamp.getDisplayName());
        appendCampaignInfo(aCamp, infoText);
    }
    return infoText.toString();
}
Also used : Campaign(pcgen.core.Campaign) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder) CampaignFacade(pcgen.facade.core.CampaignFacade)

Aggregations

HtmlInfoBuilder (pcgen.gui2.util.HtmlInfoBuilder)22 BigDecimal (java.math.BigDecimal)3 ArrayList (java.util.ArrayList)3 Equipment (pcgen.core.Equipment)3 PCClass (pcgen.core.PCClass)3 CharacterSpell (pcgen.core.character.CharacterSpell)3 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2 CDOMObject (pcgen.cdom.base.CDOMObject)2 CNAbility (pcgen.cdom.content.CNAbility)2 RaceType (pcgen.cdom.enumeration.RaceType)2 Ability (pcgen.core.Ability)2 Campaign (pcgen.core.Campaign)2 Domain (pcgen.core.Domain)2 SpellInfo (pcgen.core.character.SpellInfo)2 Spell (pcgen.core.spell.Spell)2 CampaignFacade (pcgen.facade.core.CampaignFacade)2 File (java.io.File)1 List (java.util.List)1 Map (java.util.Map)1