Search in sources :

Example 16 with CampaignFacade

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

Example 17 with CampaignFacade

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

Example 18 with CampaignFacade

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

Example 19 with CampaignFacade

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

Example 20 with CampaignFacade

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

Aggregations

CampaignFacade (pcgen.facade.core.CampaignFacade)20 ArrayList (java.util.ArrayList)6 Campaign (pcgen.core.Campaign)5 GameMode (pcgen.core.GameMode)4 GameModeFacade (pcgen.facade.core.GameModeFacade)4 SourceSelectionFacade (pcgen.facade.core.SourceSelectionFacade)4 DefaultListFacade (pcgen.facade.util.DefaultListFacade)4 URI (java.net.URI)3 BorderLayout (java.awt.BorderLayout)2 Dimension (java.awt.Dimension)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 DataSet (pcgen.core.DataSet)2 GameModeDisplayFacade (pcgen.facade.core.GameModeDisplayFacade)2 HtmlInfoBuilder (pcgen.gui2.util.HtmlInfoBuilder)2 PCGIOHandler (pcgen.io.PCGIOHandler)2 Point (java.awt.Point)1 File (java.io.File)1 HashSet (java.util.HashSet)1 Box (javax.swing.Box)1