Search in sources :

Example 6 with DefaultListFacade

use of pcgen.facade.util.DefaultListFacade in project pcgen by PCGen.

the class CharacterFacadeImpl method getLanguageChoosers.

@Override
public ListFacade<LanguageChooserFacade> getLanguageChoosers() {
    CNAbility cna = theCharacter.getBonusLanguageAbility();
    DefaultListFacade<LanguageChooserFacade> chooserList = new DefaultListFacade<>();
    chooserList.addElement(new LanguageChooserFacadeImpl(this, LanguageBundle.getString("in_sumLangBonus"), //$NON-NLS-1$
    cna));
    SkillFacade speakLangSkill = dataSet.getSpeakLanguageSkill();
    if (speakLangSkill != null) {
        chooserList.addElement(new LanguageChooserFacadeImpl(this, //$NON-NLS-1$
        LanguageBundle.getString("in_sumLangSkill"), (Skill) speakLangSkill));
    }
    return chooserList;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) LanguageChooserFacade(pcgen.facade.core.LanguageChooserFacade) Skill(pcgen.core.Skill) SkillFacade(pcgen.facade.core.SkillFacade) DefaultListFacade(pcgen.facade.util.DefaultListFacade)

Example 7 with DefaultListFacade

use of pcgen.facade.util.DefaultListFacade in project pcgen by PCGen.

the class SourceFileLoader method loadCampaigns.

private void loadCampaigns() throws PersistenceLayerException {
    // Unload the existing campaigns and load our selected campaign
    Globals.emptyLists();
    PersistenceManager pManager = PersistenceManager.getInstance();
    List<URI> uris = new ArrayList<>();
    for (CampaignFacade campaignFacade : selectedCampaigns) {
        uris.add(((Campaign) campaignFacade).getSourceURI());
    }
    pManager.setChosenCampaignSourcefiles(uris);
    sourcesSet.clear();
    licenseFiles.clear();
    if (selectedCampaigns.isEmpty()) {
        throw new PersistenceLayerException("You must select at least one campaign to load.");
    }
    // -- sage_sam
    try {
        LoadContext context = Globals.getContext();
        loadCampaigns(selectedGame, selectedCampaigns, context);
        // Load custom items
        loadCustomItems(context);
        finishLoad(selectedCampaigns, context);
        // Check for valid race types
        //			checkRaceTypes();
        // Verify weapons are melee or ranged
        verifyWeaponsMeleeOrRanged(context);
        //  Auto-gen additional equipment
        if (PCGenSettings.OPTIONS_CONTEXT.initBoolean(PCGenSettings.OPTION_AUTOCREATE_MW_MAGIC_EQUIP, false)) {
            EquipmentList.autoGenerateEquipment();
        }
        for (Campaign campaign : selectedCampaigns) {
            sourcesSet.add(SourceFormat.getFormattedString(campaign, SourceFormat.MEDIUM, true));
        }
        context.setLoaded(selectedCampaigns);
        /*
			 * This needs to happen after auto equipment generation and after
			 * context.setLoaded, not in finishLoad
			 */
        context.loadCampaignFacets();
        dataset = new DataSet(context, selectedGame, new DefaultListFacade<>(selectedCampaigns));
    //			//  Show the licenses
    //			showLicensesIfNeeded();
    //			showSponsorsIfNeeded();
    } catch (Throwable thr) {
        Logging.errorPrint("Exception loading files.", thr);
        uiDelegate.showErrorMessage(Constants.APPLICATION_NAME, "Failed to load campaigns, see log for details.");
    }
}
Also used : Campaign(pcgen.core.Campaign) DataSet(pcgen.core.DataSet) ArrayList(java.util.ArrayList) LoadContext(pcgen.rules.context.LoadContext) URI(java.net.URI) CampaignFacade(pcgen.facade.core.CampaignFacade) DefaultListFacade(pcgen.facade.util.DefaultListFacade)

Example 8 with DefaultListFacade

use of pcgen.facade.util.DefaultListFacade in project pcgen by PCGen.

the class FacadeFactory method initGameModes.

private static void initGameModes(List<GameMode> modes) {
    for (GameMode mode : modes) {
        String title = mode.getDefaultSourceTitle();
        if (SettingsHandler.getGame().equals(mode) && title == null && !mode.getDefaultDataSetList().isEmpty()) {
            title = mode.getName();
        }
        if (title != null && !"".equals(title)) {
            DefaultListFacade<CampaignFacade> qcamps = new DefaultListFacade<>();
            List<String> sources = mode.getDefaultDataSetList();
            for (String string : sources) {
                Campaign camp = Globals.getCampaignKeyed(string);
                if (camp != null) {
                    qcamps.addElement(camp);
                } else {
                    Logging.log(Logging.WARNING, "Unable to find source " + string + " used in default source " + title + " for game mode " + mode + ". " + title + " might not work correctly.");
                }
            }
            if (qcamps.isEmpty()) {
                Logging.log(Logging.WARNING, "Unable to load default source '" + title + "'. All of its sources are missing.");
                continue;
            }
            quickSources.addElement(new BasicSourceSelectionFacade(mode.getDefaultSourceTitle(), qcamps, mode));
        }
    }
}
Also used : GameMode(pcgen.core.GameMode) Campaign(pcgen.core.Campaign) CampaignFacade(pcgen.facade.core.CampaignFacade) DefaultListFacade(pcgen.facade.util.DefaultListFacade)

Aggregations

DefaultListFacade (pcgen.facade.util.DefaultListFacade)8 CampaignFacade (pcgen.facade.core.CampaignFacade)4 ArrayList (java.util.ArrayList)2 CNAbility (pcgen.cdom.content.CNAbility)2 Campaign (pcgen.core.Campaign)2 DataSet (pcgen.core.DataSet)2 AbilityFacade (pcgen.facade.core.AbilityFacade)2 URI (java.net.URI)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Type (pcgen.cdom.enumeration.Type)1 CompanionList (pcgen.cdom.list.CompanionList)1 CDOMDirectSingleRef (pcgen.cdom.reference.CDOMDirectSingleRef)1 CDOMSimpleSingleRef (pcgen.cdom.reference.CDOMSimpleSingleRef)1 AbilityCategory (pcgen.core.AbilityCategory)1 Equipment (pcgen.core.Equipment)1 FollowerOption (pcgen.core.FollowerOption)1 GameMode (pcgen.core.GameMode)1 Race (pcgen.core.Race)1