use of pcgen.facade.core.CampaignFacade in project pcgen by PCGen.
the class Gui2CampaignInfoFactory method setSourcesForPrereqTesting.
private List<URI> setSourcesForPrereqTesting(List<CampaignFacade> testList, PersistenceManager pman) {
List<URI> oldList = pman.getChosenCampaignSourcefiles();
List<URI> uris = new ArrayList<>();
for (CampaignFacade campaignFacade : testList) {
uris.add(((Campaign) campaignFacade).getSourceURI());
}
pman.setChosenCampaignSourcefiles(uris);
return oldList;
}
use of pcgen.facade.core.CampaignFacade in project pcgen by PCGen.
the class CharacterFacadeImpl method save.
/**
* Save the character to disc using its filename. Note this method is not
* part of the CharacterFacade and should only be used by the
* ChracterManager class.
*
* @throws NullPointerException
* @throws IOException If the write fails
*/
public void save() throws NullPointerException, IOException {
GameMode mode = (GameMode) dataSet.getGameMode();
List<CampaignFacade> campaigns = ListFacades.wrap(dataSet.getCampaigns());
(new PCGIOHandler()).write(theCharacter, mode, campaigns, file.get());
theCharacter.setDirty(false);
}
use of pcgen.facade.core.CampaignFacade 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));
}
}
}
use of pcgen.facade.core.CampaignFacade in project pcgen by PCGen.
the class FacadeFactory method initCustomSourceSelections.
private static void initCustomSourceSelections() {
String[] keys = sourcesContext.getStringArray("selectionNames");
if (keys == null) {
return;
}
for (String name : keys) {
PropertyContext context = sourcesContext.createChildContext(name);
String modeName = context.getProperty("gamemode");
GameMode mode = SystemCollections.getGameModeNamed(modeName);
if (mode == null) {
Logging.errorPrint("Unable to load quick source '" + name + "'. Game mode '" + modeName + "' is missing");
continue;
}
String[] selectionArray = context.getStringArray("campaigns");
List<CampaignFacade> sources = new ArrayList<>();
boolean error = false;
for (String campaign : selectionArray) {
CampaignFacade c = campaignMap.get(campaign);
if (c != null) {
sources.add(c);
} else {
error = true;
Logging.log(Logging.WARNING, '\'' + campaign + '\'' + " campaign not found, custom quick source '" + name + "' might not work correctly.");
}
}
if (sources.isEmpty()) {
Logging.errorPrint("Unable to load quick source '" + name + "'. All of its sources are missing");
continue;
}
CustomSourceSelectionFacade selection = new CustomSourceSelectionFacade(name);
selection.setGameMode(mode);
selection.setCampaigns(sources);
if (error) {
selection.setLoadingState(LoadingState.LOADED_WITH_ERRORS);
selection.setErrorMessage("Some campaigns are missing");
}
customSources.addElement(selection);
quickSources.addElement(selection);
}
}
use of pcgen.facade.core.CampaignFacade in project pcgen by PCGen.
the class PCGVer2Creator method appendCampaignLine.
private void appendCampaignLine(StringBuilder buffer) {
if (campaigns != null) {
String del = Constants.EMPTY_STRING;
for (CampaignFacade campaign : campaigns) {
buffer.append(del);
buffer.append(IOConstants.TAG_CAMPAIGN).append(':');
buffer.append(campaign.getKeyName());
//$NON-NLS-1$
del = "|";
}
buffer.append(IOConstants.LINE_SEP);
}
}
Aggregations