Search in sources :

Example 21 with CharacterFacade

use of pcgen.facade.core.CharacterFacade in project pcgen by PCGen.

the class GMGenMessageHandler method handleFetchOpenPCGRequestMessage.

private void handleFetchOpenPCGRequestMessage() {
    for (int i = 0; i < CharacterManager.getCharacters().getSize(); i++) {
        CharacterFacade facade = CharacterManager.getCharacters().getElementAt(i);
        if (facade instanceof CharacterFacadeImpl) {
            CharacterFacadeImpl cfi = (CharacterFacadeImpl) facade;
            messageHandler.handleMessage(new PlayerCharacterWasLoadedMessage(this, cfi.getTheCharacter()));
        }
    }
}
Also used : PlayerCharacterWasLoadedMessage(pcgen.pluginmgr.messages.PlayerCharacterWasLoadedMessage) CharacterFacade(pcgen.facade.core.CharacterFacade)

Example 22 with CharacterFacade

use of pcgen.facade.core.CharacterFacade in project pcgen by PCGen.

the class GMGenMessageHandler method handleSavePcgMessage.

private void handleSavePcgMessage(PCGenMessage message) {
    RequestToSavePlayerCharacterMessage smessage = (RequestToSavePlayerCharacterMessage) message;
    PlayerCharacter pc = smessage.getPc();
    for (Iterator<CharacterFacade> iterator = CharacterManager.getCharacters().iterator(); iterator.hasNext(); ) {
        CharacterFacade facade = iterator.next();
        if (facade.matchesCharacter(pc)) {
            CharacterManager.saveCharacter(facade);
            break;
        }
    }
}
Also used : RequestToSavePlayerCharacterMessage(pcgen.pluginmgr.messages.RequestToSavePlayerCharacterMessage) PlayerCharacter(pcgen.core.PlayerCharacter) CharacterFacade(pcgen.facade.core.CharacterFacade)

Example 23 with CharacterFacade

use of pcgen.facade.core.CharacterFacade in project pcgen by PCGen.

the class BatchExporter method exportParty.

/**
	 * Write a party sheet for the characters in the party to the outputStream. The party sheet will
	 * be selected based on the selected game mode and pcgen preferences.
	 *
	 * @param party the party to be output
	 * @param outputStream the stream to output the party sheet to.
	 * @throws IOException
	 * @throws ExportException
	 */
private static void exportParty(PartyFacade party, OutputStream outputStream) throws IOException, ExportException {
    try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"))) {
        for (final CharacterFacade character : party) {
            File templateFile = getXMLTemplate(character);
            character.export(new ExportHandler(templateFile), bw);
        }
    }
}
Also used : ExportHandler(pcgen.io.ExportHandler) OutputStreamWriter(java.io.OutputStreamWriter) CharacterFacade(pcgen.facade.core.CharacterFacade) PCGFile(pcgen.io.PCGFile) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 24 with CharacterFacade

use of pcgen.facade.core.CharacterFacade in project pcgen by PCGen.

the class CharacterManager method createNewCharacter.

/**
	 * Create a new character using the supplied data sets.
	 * @param delegate the UIDelegate that this character will use.
	 * @param dataset the dataset that this will be loaded with.
	 * @return The character that was created.
	 */
public static CharacterFacade createNewCharacter(UIDelegate delegate, DataSetFacade dataset) {
    @SuppressWarnings("rawtypes") List campaigns = ListFacades.wrap(dataset.getCampaigns());
    try {
        @SuppressWarnings("unchecked") PlayerCharacter pc = new PlayerCharacter(campaigns);
        Globals.getPCList().add(pc);
        CharacterFacade character = new CharacterFacadeImpl(pc, delegate, dataset);
        String name = createNewCharacterName();
        character.setName(name);
        characters.addElement(character);
        //$NON-NLS-1$ //$NON-NLS-2$
        Logging.log(Logging.INFO, "Created new character " + name + '.');
        messageHandler.handleMessage(new PlayerCharacterWasLoadedMessage(delegate, pc));
        return character;
    } catch (final Exception e) {
        Logging.errorPrint(//$NON-NLS-1$
        "Unable to create character with data " + dataset, e);
        delegate.showErrorMessage(//$NON-NLS-1$
        LanguageBundle.getString("in_cmCreateErrorTitle"), //$NON-NLS-1$
        LanguageBundle.getFormattedString(//$NON-NLS-1$
        "in_cmCreateErrorMessage", e.getMessage()));
        return null;
    }
}
Also used : PlayerCharacterWasLoadedMessage(pcgen.pluginmgr.messages.PlayerCharacterWasLoadedMessage) PlayerCharacter(pcgen.core.PlayerCharacter) ArrayList(java.util.ArrayList) List(java.util.List) CharacterFacade(pcgen.facade.core.CharacterFacade) IOException(java.io.IOException) CharacterFacadeImpl(pcgen.gui2.facade.CharacterFacadeImpl)

Example 25 with CharacterFacade

use of pcgen.facade.core.CharacterFacade in project pcgen by PCGen.

the class CharacterManager method removeAllCharacters.

public static void removeAllCharacters() {
    for (final CharacterFacade characterFacade : characters) {
        recentCharacters.addRecentFile(characterFacade.getFileRef().get());
        // This advises the message handler also.
        characterFacade.closeCharacter();
    }
    characters.clearContents();
    recentParties.addRecentFile(characters.getFileRef().get());
    characters.setFile(null);
    //$NON-NLS-1$
    Logging.log(Logging.INFO, "Closed all characters");
}
Also used : CharacterFacade(pcgen.facade.core.CharacterFacade)

Aggregations

CharacterFacade (pcgen.facade.core.CharacterFacade)31 File (java.io.File)11 JPanel (javax.swing.JPanel)9 JScrollPane (javax.swing.JScrollPane)9 FilterBar (pcgen.gui2.filter.FilterBar)9 SearchFilterPanel (pcgen.gui2.filter.SearchFilterPanel)9 FlippingSplitPane (pcgen.gui2.tools.FlippingSplitPane)9 Box (javax.swing.Box)8 BorderLayout (java.awt.BorderLayout)6 ArrayList (java.util.ArrayList)5 PCGFile (pcgen.io.PCGFile)5 EmptyBorder (javax.swing.border.EmptyBorder)4 JCheckBox (javax.swing.JCheckBox)3 JLabel (javax.swing.JLabel)3 PlayerCharacter (pcgen.core.PlayerCharacter)3 SuperNode (pcgen.facade.core.SpellSupportFacade.SuperNode)3 SortableTableModel (pcgen.gui2.util.table.SortableTableModel)3 SortableTableRowSorter (pcgen.gui2.util.table.SortableTableRowSorter)3 IOException (java.io.IOException)2 URI (java.net.URI)2