Search in sources :

Example 66 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class AbstractPCClassLevelTokenTestCase method classSetUp.

@BeforeClass
public static final void classSetUp() throws URISyntaxException {
    testCampaign = new CampaignSourceEntry(new Campaign(), new URI("file:/Test%20Case"));
    classSetUpFired = true;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) URI(java.net.URI) BeforeClass(org.junit.BeforeClass)

Example 67 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class Campaign method getSubCampaigns.

/**
	 * Returns a list of the Campaign objects that were loaded by this Campaign.
	 * 
	 * @return A list of <tt>Campaign</tt>s loaded by this Campaign.
	 */
public List<Campaign> getSubCampaigns() {
    final List<CampaignSourceEntry> pccFiles = getSafeListFor(ListKey.FILE_PCC);
    final List<Campaign> ret = new ArrayList<>(pccFiles.size());
    for (final CampaignSourceEntry fileName : pccFiles) {
        final Campaign campaign = Globals.getCampaignByURI(fileName.getURI(), true);
        if (campaign != null) {
            ret.add(campaign);
        }
    }
    return ret;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) ArrayList(java.util.ArrayList)

Example 68 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class Gui2CampaignInfoFactory method appendCampaignInfo.

private void appendCampaignInfo(Campaign aCamp, final HtmlInfoBuilder infoText) {
    infoText.appendLineBreak();
    if (aCamp.getSizeOfListFor(ListKey.FILE_COVER) > 0) {
        CampaignSourceEntry image = aCamp.getSafeListFor(ListKey.FILE_COVER).get(0);
        infoText.appendIconElement(image.getURI().toString());
    }
    if (aCamp.getSizeOfListFor(ListKey.FILE_LOGO) > 0) {
        CampaignSourceEntry image = aCamp.getSafeListFor(ListKey.FILE_LOGO).get(0);
        infoText.appendIconElement(image.getURI().toString());
    }
    if (aCamp.getSizeOfListFor(ListKey.FILE_COVER) > 0 || aCamp.getSizeOfListFor(ListKey.FILE_LOGO) > 0) {
        infoText.appendLineBreak();
    }
    String bString = SourceFormat.getFormattedString(aCamp, SourceFormat.MEDIUM, true);
    if (StringUtils.isEmpty(bString)) {
        bString = SourceFormat.getFormattedString(aCamp, SourceFormat.LONG, true);
    }
    //$NON-NLS-1$
    infoText.appendI18nElement("in_sumSource", bString);
    //$NON-NLS-1$
    infoText.appendI18nFormattedElement(//$NON-NLS-1$
    "in_infByPub", aCamp.getSafe(StringKey.PUB_NAME_LONG));
    infoText.appendLineBreak();
    // Add the data set release status
    Status status = aCamp.getSafe(ObjectKey.STATUS);
    //$NON-NLS-1$
    infoText.appendI18nElement(//$NON-NLS-1$
    "in_infStatus", //$NON-NLS-1$ //$NON-NLS-2$
    "<font color=\"#" + Integer.toHexString(status.getColor()) + "\">" + status + //$NON-NLS-1$
    "</font>");
    infoText.appendLineBreak();
    String descr = aCamp.get(StringKey.DESCRIPTION);
    if (descr != null) {
        //$NON-NLS-1$
        infoText.appendI18nElement("in_infDesc", descr);
        infoText.appendLineBreak();
    }
    // Add the website URLs
    List<CampaignURL> webURLs = getUrlListForKind(aCamp, URLKind.WEBSITE);
    if (!webURLs.isEmpty()) {
        //$NON-NLS-1$
        infoText.appendI18nElement("in_infWebsite", buildURLListString(webURLs));
        infoText.appendLineBreak();
    }
    if (!aCamp.getType().isEmpty()) {
        //$NON-NLS-1$
        infoText.appendI18nElement("in_infType", aCamp.getType());
        infoText.appendSpacer();
    }
    infoText.appendI18nElement("in_infRank", String.valueOf(//$NON-NLS-1$
    aCamp.getSafe(IntegerKey.CAMPAIGN_RANK)));
    if (!StringUtil.join(aCamp.getSafeListFor(ListKey.GAME_MODE), ", ").isEmpty()) {
        infoText.appendSpacer();
        //$NON-NLS-1$
        infoText.appendI18nElement(//$NON-NLS-1$
        "in_infGame", StringUtil.join(aCamp.getSafeListFor(ListKey.GAME_MODE), ", "));
    }
    infoText.appendLineBreak();
    // Add the purchase URLs
    List<CampaignURL> purchaseURLs = getUrlListForKind(aCamp, URLKind.PURCHASE);
    if (!purchaseURLs.isEmpty()) {
        //$NON-NLS-1$
        infoText.appendI18nElement("in_infPurchase", buildURLListString(purchaseURLs));
        infoText.appendLineBreak();
    }
    // Add the survey URLs
    List<CampaignURL> surveyURLs = getUrlListForKind(aCamp, URLKind.SURVEY);
    if (!surveyURLs.isEmpty()) {
        //$NON-NLS-1$
        infoText.appendI18nElement("in_infSurvey", buildURLListString(surveyURLs));
        infoText.appendLineBreak();
    }
    String preString = PrerequisiteUtilities.preReqHTMLStringsForList(null, null, aCamp.getPrerequisiteList(), false);
    if (!preString.isEmpty()) {
        //$NON-NLS-1$
        infoText.appendI18nFormattedElement("in_InfoRequirements", preString);
    }
    boolean infoDisplayed = false;
    List<String> info = aCamp.getListFor(ListKey.INFO_TEXT);
    if (info != null) {
        if (!infoDisplayed) {
            infoText.appendLineBreak();
        }
        //$NON-NLS-1$
        infoText.appendSmallTitleElement(LanguageBundle.getString("in_infInf"));
        infoText.appendLineBreak();
        for (String infotext : info) {
            infoText.append(infotext);
            infoText.appendLineBreak();
        }
        infoDisplayed = true;
    }
    List<String> copyright = aCamp.getListFor(ListKey.SECTION_15);
    if (copyright != null) {
        if (!infoDisplayed) {
            infoText.appendLineBreak();
        }
        //$NON-NLS-1$
        infoText.appendSmallTitleElement(LanguageBundle.getString("in_infCopyright"));
        infoText.appendLineBreak();
        for (String license : copyright) {
            infoText.append(license);
            infoText.appendLineBreak();
        }
    }
    List<Campaign> subCampaigns = aCamp.getSubCampaigns();
    List<CampaignSourceEntry> notFoundSubCampaigns = aCamp.getNotFoundSubCampaigns();
    if (subCampaigns != null && notFoundSubCampaigns != null && (!subCampaigns.isEmpty() || !notFoundSubCampaigns.isEmpty())) {
        infoText.appendLineBreak();
        infoText.appendSmallTitleElement(LanguageBundle.getString(//$NON-NLS-1$
        "in_infIncludedCampaigns"));
        infoText.appendLineBreak();
        for (Campaign subCamp : subCampaigns) {
            infoText.append(subCamp.getDisplayName());
            infoText.appendLineBreak();
        }
        for (CampaignSourceEntry subCse : notFoundSubCampaigns) {
            infoText.append(LanguageBundle.getFormattedString("in_infMissingCampaign", subCse.getURI()));
            infoText.appendLineBreak();
        }
    }
    infoText.appendLineBreak();
    infoText.appendI18nElement("in_infPccPath", aCamp.getSourceURI().getPath());
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Status(pcgen.cdom.enumeration.Status) CampaignURL(pcgen.cdom.content.CampaignURL) Campaign(pcgen.core.Campaign)

Example 69 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class AbstractBasicCampaignToken method unparse.

public String[] unparse(LoadContext context, Campaign campaign) {
    Changes<CampaignSourceEntry> cseChanges = context.getObjectContext().getListChanges(campaign, getListKey());
    Collection<CampaignSourceEntry> added = cseChanges.getAdded();
    if (added == null) {
        //empty indicates no token
        return null;
    }
    Set<String> set = new TreeSet<>();
    for (CampaignSourceEntry cse : added) {
        set.add(cse.getLSTformat());
    }
    return set.toArray(new String[set.size()]);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) TreeSet(java.util.TreeSet)

Example 70 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class AbstractBasicCampaignToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Campaign campaign, String value) {
    CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, value);
    if (cse == null) {
        return ParseResult.INTERNAL_ERROR;
    }
    context.getObjectContext().addToList(campaign, getListKey(), cse);
    return ParseResult.SUCCESS;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry)

Aggregations

CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)95 URI (java.net.URI)54 Campaign (pcgen.core.Campaign)44 URISyntaxException (java.net.URISyntaxException)27 LoadContext (pcgen.rules.context.LoadContext)25 UnreachableError (pcgen.base.lang.UnreachableError)19 BeforeClass (org.junit.BeforeClass)16 PCClassLoader (pcgen.persistence.lst.PCClassLoader)15 TreeSet (java.util.TreeSet)12 PlayerCharacter (pcgen.core.PlayerCharacter)11 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)11 ArrayList (java.util.ArrayList)9 PCClass (pcgen.core.PCClass)9 File (java.io.File)8 GenericLoader (pcgen.persistence.lst.GenericLoader)8 CDOMReference (pcgen.cdom.base.CDOMReference)7 SourceEntry (pcgen.persistence.lst.SourceEntry)7 Ability (pcgen.core.Ability)6 FeatLoader (pcgen.persistence.lst.FeatLoader)6 AbilityList (pcgen.cdom.list.AbilityList)5