Search in sources :

Example 1 with SourceSelectionFacade

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);
    }
}
Also used : SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade) CampaignFacade(pcgen.facade.core.CampaignFacade)

Example 2 with SourceSelectionFacade

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);
    }
}
Also used : SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade) SourceFileLoader(pcgen.persistence.SourceFileLoader) PCGFile(pcgen.io.PCGFile) File(java.io.File) CharacterFacade(pcgen.facade.core.CharacterFacade)

Example 3 with SourceSelectionFacade

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;
}
Also used : ConsoleUIDelegate(pcgen.system.ConsoleUIDelegate) SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade) SourceFileLoader(pcgen.persistence.SourceFileLoader) PCGFile(pcgen.io.PCGFile) File(java.io.File) CharacterFacade(pcgen.facade.core.CharacterFacade) ConsoleUIDelegate(pcgen.system.ConsoleUIDelegate) UIDelegate(pcgen.facade.core.UIDelegate)

Example 4 with SourceSelectionFacade

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;
}
Also used : SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade) ArrayList(java.util.ArrayList) Parameters(org.junit.runners.Parameterized.Parameters)

Example 5 with SourceSelectionFacade

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;
}
Also used : GameMode(pcgen.core.GameMode) SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade) Campaign(pcgen.core.Campaign) ArrayList(java.util.ArrayList) CampaignFacade(pcgen.facade.core.CampaignFacade)

Aggregations

SourceSelectionFacade (pcgen.facade.core.SourceSelectionFacade)14 File (java.io.File)4 ArrayList (java.util.ArrayList)4 CampaignFacade (pcgen.facade.core.CampaignFacade)4 PCGFile (pcgen.io.PCGFile)4 SourceFileLoader (pcgen.persistence.SourceFileLoader)3 CharacterFacade (pcgen.facade.core.CharacterFacade)2 GameModeFacade (pcgen.facade.core.GameModeFacade)2 PCGIOHandler (pcgen.io.PCGIOHandler)2 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 HashSet (java.util.HashSet)1 BoxLayout (javax.swing.BoxLayout)1 JList (javax.swing.JList)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1 JTextField (javax.swing.JTextField)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1