use of pcgen.facade.core.SourceSelectionFacade in project pcgen by PCGen.
the class SourceSelectionDialog method fireSourceLoad.
private void fireSourceLoad() {
SourceSelectionFacade selection;
if (tabs.getSelectedComponent() == basicPanel) {
selection = basicPanel.getSourceSelection();
} else {
selection = FacadeFactory.createSourceSelection(advancedPanel.getSelectedGameMode(), advancedPanel.getSelectedCampaigns());
}
if (selection == null) {
return;
}
List<CampaignFacade> campaigns = ListFacades.wrap(selection.getCampaigns());
if (FacadeFactory.passesPrereqs(campaigns)) {
setVisible(false);
frame.loadSourceSelection(selection);
} else {
JOptionPane.showMessageDialog(this, "Some sources have unfulfilled prereqs", "Cannot Load Selected Sources", JOptionPane.INFORMATION_MESSAGE);
}
}
use of pcgen.facade.core.SourceSelectionFacade in project pcgen by PCGen.
the class BatchExporter method exportCharacter.
/**
* Export a character sheet for the character to the output file using the
* pre-registered template. If the output file is null then a default file
* will be used based on the character file name and the type of export
* template in use. If the output file exists it will be overwritten.
* <p>
* This method will load the required data for the character, load the
* character and then export the character sheet.
*
* @param characterFilename The path to the character PCG file.
* @param outputFile The path to the output file to be created. May be null.
* @return true if the export was successful, false if it failed in some way.
*/
boolean exportCharacter(String characterFilename, String outputFile) {
File file = new File(characterFilename);
if (!PCGFile.isPCGenCharacterFile(file)) {
Logging.errorPrint("Invalid character file specified: " + file.getAbsolutePath());
return false;
}
String outFilename = outputFile;
if (outFilename == null) {
outFilename = generateOutputFilename(characterFilename);
}
Logging.log(Logging.INFO, "Started export of " + file.getAbsolutePath() + " using " + exportTemplateFilename + " to " + outFilename);
// Load data
SourceSelectionFacade sourcesForCharacter = CharacterManager.getRequiredSourcesForCharacter(file, uiDelegate);
Logging.log(Logging.INFO, "Loading sources " + sourcesForCharacter.getCampaigns() + " using game mode " + sourcesForCharacter.getGameMode());
SourceFileLoader loader = new SourceFileLoader(sourcesForCharacter, uiDelegate);
loader.execute();
// Load character
CharacterFacade character = CharacterManager.openCharacter(file, uiDelegate, loader.getDataSetFacade());
if (character == null) {
return false;
}
// Export character
File templateFile = new File(exportTemplateFilename);
File outFile = new File(outFilename);
if (isPdf) {
return exportCharacterToPDF(character, outFile, templateFile);
} else {
return exportCharacterToNonPDF(character, outFile, templateFile);
}
}
use of pcgen.facade.core.SourceSelectionFacade in project pcgen by PCGen.
the class FtlMigrationTest method loadCharacter.
/**
* @param characterFile
* @return
*/
private CharacterFacade loadCharacter(String characterFilename) {
File file = new File(characterFilename);
if (!PCGFile.isPCGenCharacterFile(file)) {
Logging.errorPrint("Invalid character file specified: " + file.getAbsolutePath());
return null;
}
// Load data
UIDelegate uiDelegate = new ConsoleUIDelegate();
SourceSelectionFacade sourcesForCharacter = CharacterManager.getRequiredSourcesForCharacter(file, uiDelegate);
Logging.log(Logging.INFO, "Loading sources " + sourcesForCharacter.getCampaigns() + " using game mode " + sourcesForCharacter.getGameMode());
SourceFileLoader loader = new SourceFileLoader(sourcesForCharacter, uiDelegate);
loader.execute();
// Load character
CharacterFacade character = CharacterManager.openCharacter(file, uiDelegate, loader.getDataSetFacade());
return character;
}
use of pcgen.facade.core.SourceSelectionFacade in project pcgen by PCGen.
the class DataLoadTest method data.
/**
* Build the list of sources to be checked. Also initialises the plugins and
* loads the game mode and campaign files.
*/
@Parameters(name = "{1}")
public static Collection<Object[]> data() {
// Set things up
loadGameModes();
SettingsHandler.setOutputDeprecationMessages(false);
SettingsHandler.setInputUnconstructedMessages(false);
PCGenSettings.OPTIONS_CONTEXT.setBoolean(PCGenSettings.OPTION_ALLOW_OVERRIDE_DUPLICATES, true);
List<String> exclusions = Arrays.asList(excludedSources);
List<SourceSelectionFacade> basicSources = getBasicSources();
assertFalse("No sources found", basicSources.isEmpty());
List<Object[]> params = new ArrayList<>();
for (SourceSelectionFacade ssf : basicSources) {
String testName = ssf.toString().replaceAll("[\\(\\)]", "_");
if (!exclusions.contains(testName)) {
params.add(new Object[] { ssf, testName });
}
}
return params;
}
use of pcgen.facade.core.SourceSelectionFacade in project pcgen by PCGen.
the class DataLoadTest method getBasicSources.
private static List<SourceSelectionFacade> getBasicSources() {
List<SourceSelectionFacade> basicSources = new ArrayList<>();
for (Campaign campaign : Globals.getCampaignList()) {
if (campaign.showInMenu()) {
SourceSelectionFacade sourceSelection = FacadeFactory.createSourceSelection(campaign.getGameModes().getElementAt(0), Collections.singletonList(campaign), campaign.getName());
basicSources.add(sourceSelection);
}
}
for (GameMode mode : SystemCollections.getUnmodifiableGameModeList()) {
String title = mode.getDefaultSourceTitle();
if (title == null && !mode.getDefaultDataSetList().isEmpty()) {
title = mode.getName();
}
if (!mode.getDefaultDataSetList().isEmpty()) {
List<CampaignFacade> qcamps = new ArrayList<>();
List<String> sources = mode.getDefaultDataSetList();
for (String string : sources) {
Campaign camp = Globals.getCampaignKeyed(string);
assertNotNull("Cannot find source " + string + " for game mode " + mode, camp);
qcamps.add(camp);
}
basicSources.add(FacadeFactory.createSourceSelection(mode, qcamps, mode.getDefaultSourceTitle()));
}
}
return basicSources;
}
Aggregations