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()));
}
}
}
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;
}
}
}
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);
}
}
}
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;
}
}
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");
}
Aggregations