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);
}
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.");
}
}
Aggregations