Search in sources :

Example 1 with DataSet

use of pcgen.core.DataSet in project pcgen by PCGen.

the class CompanionSupportFacadeImplTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    uiDelegate = new MockUIDelegate();
    todoManager = new TodoManager();
    ListFacade<CampaignFacade> campaigns = new DefaultListFacade<>();
    dataSetFacade = new DataSet(Globals.getContext(), SettingsHandler.getGame(), campaigns);
    masterRace = TestHelper.makeRace("Wood Elf");
    companionRace = TestHelper.makeRace("Weasel");
    CDOMReference<Race> race = new CDOMDirectSingleRef<>(companionRace);
    CDOMSingleRef<CompanionList> ref = new CDOMSimpleSingleRef<>(CompanionList.class, companionList.getKeyName());
    FollowerOption option = new FollowerOption(race, ref);
    masterRace.addToListFor(ListKey.COMPANIONLIST, option);
}
Also used : CDOMDirectSingleRef(pcgen.cdom.reference.CDOMDirectSingleRef) DataSet(pcgen.core.DataSet) FollowerOption(pcgen.core.FollowerOption) CompanionList(pcgen.cdom.list.CompanionList) CDOMSimpleSingleRef(pcgen.cdom.reference.CDOMSimpleSingleRef) CampaignFacade(pcgen.facade.core.CampaignFacade) Race(pcgen.core.Race) DefaultListFacade(pcgen.facade.util.DefaultListFacade)

Example 2 with DataSet

use of pcgen.core.DataSet 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)

Aggregations

DataSet (pcgen.core.DataSet)2 CampaignFacade (pcgen.facade.core.CampaignFacade)2 DefaultListFacade (pcgen.facade.util.DefaultListFacade)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 CompanionList (pcgen.cdom.list.CompanionList)1 CDOMDirectSingleRef (pcgen.cdom.reference.CDOMDirectSingleRef)1 CDOMSimpleSingleRef (pcgen.cdom.reference.CDOMSimpleSingleRef)1 Campaign (pcgen.core.Campaign)1 FollowerOption (pcgen.core.FollowerOption)1 Race (pcgen.core.Race)1 LoadContext (pcgen.rules.context.LoadContext)1