From: <jde...@us...> - 2011-10-10 00:34:42
|
Revision: 15435 http://pcgen.svn.sourceforge.net/pcgen/?rev=15435&view=rev Author: jdempsey Date: 2011-10-10 00:34:34 +0000 (Mon, 10 Oct 2011) Log Message: ----------- Add storage for the campaign history. Still needs fields to be saved to the ChronicleEntries. Modified Paths: -------------- sandbox/uisync/code/src/java/applicationContext.xml sandbox/uisync/code/src/java/pcgen/core/PlayerCharacter.java sandbox/uisync/code/src/java/pcgen/core/facade/CharacterFacade.java sandbox/uisync/code/src/java/pcgen/gui2/facade/CharacterFacadeImpl.java sandbox/uisync/code/src/java/pcgen/gui2/tabs/bio/CampaignHistoryInfoPane.java sandbox/uisync/code/src/java/pcgen/io/EntityEncoder.java sandbox/uisync/code/src/java/pcgen/io/IOConstants.java sandbox/uisync/code/src/java/pcgen/io/PCGVer2Creator.java sandbox/uisync/code/src/java/pcgen/io/PCGVer2Parser.java Added Paths: ----------- sandbox/uisync/code/src/java/pcgen/cdom/facet/ChronicleEntryFacet.java sandbox/uisync/code/src/java/pcgen/core/ChronicleEntry.java sandbox/uisync/code/src/java/pcgen/core/facade/DescriptionFacade.java sandbox/uisync/code/src/java/pcgen/gui2/facade/DescriptionFacadeImpl.java Modified: sandbox/uisync/code/src/java/applicationContext.xml =================================================================== --- sandbox/uisync/code/src/java/applicationContext.xml 2011-10-07 20:42:07 UTC (rev 15434) +++ sandbox/uisync/code/src/java/applicationContext.xml 2011-10-10 00:34:34 UTC (rev 15435) @@ -26,5 +26,6 @@ <bean id="templateFacet" class="pcgen.cdom.facet.TemplateFacet"/> <bean id="raceFacet" class="pcgen.cdom.facet.RaceFacet" /> <bean id="formulaResolvingFacet" class="pcgen.cdom.facet.FormulaResolvingFacet" /> + <bean id="chronicleEntryFacet" class="pcgen.cdom.facet.ChronicleEntryFacet" /> </beans> Added: sandbox/uisync/code/src/java/pcgen/cdom/facet/ChronicleEntryFacet.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/cdom/facet/ChronicleEntryFacet.java (rev 0) +++ sandbox/uisync/code/src/java/pcgen/cdom/facet/ChronicleEntryFacet.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -0,0 +1,36 @@ +/* + * Copyright (c) James Dempsey, 2011. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ +package pcgen.cdom.facet; + +import pcgen.core.ChronicleEntry; + +/** + * ChronicleEntryFacet is a Facet that tracks the chronicle entries that have + * been entered for a Player Character. + * + * <br/> + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author James Dempsey <jde...@us...> + * @version $Revision$ + */ +public class ChronicleEntryFacet extends AbstractListFacet<ChronicleEntry> +{ + +} Property changes on: sandbox/uisync/code/src/java/pcgen/cdom/facet/ChronicleEntryFacet.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Id Added: svn:eol-style + native Added: sandbox/uisync/code/src/java/pcgen/core/ChronicleEntry.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/core/ChronicleEntry.java (rev 0) +++ sandbox/uisync/code/src/java/pcgen/core/ChronicleEntry.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -0,0 +1,162 @@ +/** + * ChronicleEntry.java + * Copyright James Dempsey, 2011 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on 30/09/2011 10:17:51 PM + * + * $Id$ + */ +package pcgen.core; + + +/** + * The Class <code>ChronicleEntry</code> contains a record of an + * event in the character's history. + * + * <br/> + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author James Dempsey <jde...@us...> + * @version $Revision$ + */ +public class ChronicleEntry +{ + private boolean outputEntry = false; + private String campaign = ""; + private String adventure = ""; + private String party = ""; + private String date = ""; + private int xpField = 0; + private String gmField = ""; + private String chronicle = ""; + + /** + * @return the outputEntry + */ + public boolean isOutputEntry() + { + return outputEntry; + } + /** + * @param outputEntry the outputEntry to set + */ + public void setOutputEntry(boolean outputEntry) + { + this.outputEntry = outputEntry; + } + /** + * @return the campaign + */ + public String getCampaign() + { + return campaign; + } + /** + * @param campaign the campaign to set + */ + public void setCampaign(String campaign) + { + this.campaign = campaign; + } + /** + * @return the adventure + */ + public String getAdventure() + { + return adventure; + } + /** + * @param adventure the adventure to set + */ + public void setAdventure(String adventure) + { + this.adventure = adventure; + } + /** + * @return the party + */ + public String getParty() + { + return party; + } + /** + * @param party the party to set + */ + public void setParty(String party) + { + this.party = party; + } + /** + * @return the date + */ + public String getDate() + { + return date; + } + /** + * @param date the date to set + */ + public void setDate(String date) + { + this.date = date; + } + /** + * @return the xpField + */ + public int getXpField() + { + return xpField; + } + /** + * @param xpField the xpField to set + */ + public void setXpField(int xpField) + { + this.xpField = xpField; + } + /** + * @return the gmField + */ + public String getGmField() + { + return gmField; + } + /** + * @param gmField the gmField to set + */ + public void setGmField(String gmField) + { + this.gmField = gmField; + } + /** + * @return the chronicle + */ + public String getChronicle() + { + return chronicle; + } + /** + * @param chronicle the chronicle to set + */ + public void setChronicle(String chronicle) + { + this.chronicle = chronicle; + } + + +} Property changes on: sandbox/uisync/code/src/java/pcgen/core/ChronicleEntry.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Id Added: svn:eol-style + native Modified: sandbox/uisync/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/core/PlayerCharacter.java 2011-10-07 20:42:07 UTC (rev 15434) +++ sandbox/uisync/code/src/java/pcgen/core/PlayerCharacter.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -268,6 +268,7 @@ private AgeSetFacet ageSetFacet = FacetLibrary.getFacet(AgeSetFacet.class); private MultiClassFacet multiClassFacet = FacetLibrary.getFacet(MultiClassFacet.class); private ArmorClassFacet armorClassFacet = FacetLibrary.getFacet(ArmorClassFacet.class); + private ChronicleEntryFacet chronicleEntryFacet = FacetLibrary.getFacet(ChronicleEntryFacet.class); private FormulaResolvingFacet resolveFacet = FacetLibrary.getFacet(FormulaResolvingFacet.class); private PrerequisiteFacet prereqFacet = FacetLibrary.getFacet(PrerequisiteFacet.class); @@ -12909,4 +12910,31 @@ } } } + + /** + * Add a chronicle entry. + * @param chronicleEntry The entry to be added. + */ + public void addChronicleEntry(ChronicleEntry chronicleEntry) + { + chronicleEntryFacet.add(id, chronicleEntry); + } + + /** + * Remove a chronicle entry. + * @param chronicleEntry The entry to be removed. + */ + public void removeChronicleEntry(ChronicleEntry chronicleEntry) + { + chronicleEntryFacet.remove(id, chronicleEntry); + } + + /** + * Retrieve the set of the character's chronicle entries. + * @return The character's chronicle entries. + */ + public Collection<ChronicleEntry> getChronicleEntries() + { + return chronicleEntryFacet.getSet(id); + } } Modified: sandbox/uisync/code/src/java/pcgen/core/facade/CharacterFacade.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/core/facade/CharacterFacade.java 2011-10-07 20:42:07 UTC (rev 15434) +++ sandbox/uisync/code/src/java/pcgen/core/facade/CharacterFacade.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -405,6 +405,11 @@ public CharacterLevelsFacade getCharacterLevelsFacade(); /** + * @return The facade for description for this character. + */ + public DescriptionFacade getDescriptionFacade(); + + /** * Set the character's current experience point value * @param xp The new XP value to be set */ Added: sandbox/uisync/code/src/java/pcgen/core/facade/DescriptionFacade.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/core/facade/DescriptionFacade.java (rev 0) +++ sandbox/uisync/code/src/java/pcgen/core/facade/DescriptionFacade.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -0,0 +1,60 @@ +/** + * DescriptionFacade.java + * Copyright James Dempsey, 2011 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on 06/10/2011 7:53:48 PM + * + * $Id$ + */ +package pcgen.core.facade; + +import pcgen.core.ChronicleEntry; +import pcgen.core.facade.util.ListFacade; + +/** + * The Class <code>DescriptionFacade</code> tracks descriptive entries about the character, + * interfacing between the user interface and the core. + * + * <br/> + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author James Dempsey <jde...@us...> + * @version $Revision$ + */ +public interface DescriptionFacade +{ + + /** + * Remove a chronicle entry. + * @param chronicleEntry The entry to be removed. + */ + public void removeChronicleEntry(ChronicleEntry chronicleEntry); + + /** + * Retrieve the set of the character's chronicle entries. + * @return The character's chronicle entries. + */ + public ListFacade<ChronicleEntry> getChronicleEntries(); + + /** + * Create a new Chronicle Entry and add it to the character's list. + * @return The new ChronicleEntry. + */ + public ChronicleEntry createChronicleEntry(); + +} Property changes on: sandbox/uisync/code/src/java/pcgen/core/facade/DescriptionFacade.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Id Added: svn:eol-style + native Modified: sandbox/uisync/code/src/java/pcgen/gui2/facade/CharacterFacadeImpl.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/gui2/facade/CharacterFacadeImpl.java 2011-10-07 20:42:07 UTC (rev 15434) +++ sandbox/uisync/code/src/java/pcgen/gui2/facade/CharacterFacadeImpl.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -91,6 +91,7 @@ import pcgen.core.facade.DataSetFacade; import pcgen.core.facade.DefaultReferenceFacade; import pcgen.core.facade.DeityFacade; +import pcgen.core.facade.DescriptionFacade; import pcgen.core.facade.DomainFacade; import pcgen.core.facade.EquipmentFacade; import pcgen.core.facade.EquipmentListFacade; @@ -202,6 +203,7 @@ private Gui2InfoFactory infoFactory; private CharacterAbilities characterAbilities; + private DescriptionFacade descriptionFacade; private TodoManager todoManager; /** @@ -243,6 +245,7 @@ infoFactory = new Gui2InfoFactory(pc); characterAbilities = new CharacterAbilities(pc, delegate, dataSet); + descriptionFacade = new DescriptionFacadeImpl(pc); //TODO: Init appliedTempBonuses appliedTempBonuses = new DefaultListFacade<TempBonusFacade>(); @@ -1995,6 +1998,11 @@ return charLevelsFacade; } + public DescriptionFacade getDescriptionFacade() + { + return descriptionFacade; + } + /* (non-Javadoc) * @see pcgen.core.facade.CharacterFacade#setXP(int) */ Added: sandbox/uisync/code/src/java/pcgen/gui2/facade/DescriptionFacadeImpl.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/gui2/facade/DescriptionFacadeImpl.java (rev 0) +++ sandbox/uisync/code/src/java/pcgen/gui2/facade/DescriptionFacadeImpl.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -0,0 +1,90 @@ +/** + * DescriptionFacadeImpl.java + * Copyright James Dempsey, 2011 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on 06/10/2011 7:59:35 PM + * + * $Id$ + */ +package pcgen.gui2.facade; + +import pcgen.core.ChronicleEntry; +import pcgen.core.PlayerCharacter; +import pcgen.core.facade.DescriptionFacade; +import pcgen.core.facade.util.DefaultListFacade; +import pcgen.core.facade.util.ListFacade; + +/** + * The Class <code>DescriptionFacadeImpl</code> is an implementation of + * the DescriptionFacade interface for the new user interface. It is + * intended to provide a full implementation of the new ui/core + * interaction layer. + * + * <br/> + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author James Dempsey <jde...@us...> + * @version $Revision$ + */ +public class DescriptionFacadeImpl implements DescriptionFacade +{ + private PlayerCharacter theCharacter; + private DefaultListFacade<ChronicleEntry> chronicleEntries; + + /** + * @param pc + */ + public DescriptionFacadeImpl(PlayerCharacter pc) + { + theCharacter = pc; + chronicleEntries = new DefaultListFacade<ChronicleEntry>(); + for (ChronicleEntry entry : theCharacter.getChronicleEntries()) + { + chronicleEntries.addElement(entry); + } + } + + /* (non-Javadoc) + * @see pcgen.core.facade.DescriptionFacade#createChronicleEntry() + */ + public ChronicleEntry createChronicleEntry() + { + ChronicleEntry chronicleEntry = new ChronicleEntry(); + theCharacter.addChronicleEntry(chronicleEntry); + chronicleEntries.addElement(chronicleEntry); + return chronicleEntry; + } + + /* (non-Javadoc) + * @see pcgen.core.facade.DescriptionFacade#removeChronicleEntry(pcgen.core.ChronicleEntry) + */ + public void removeChronicleEntry(ChronicleEntry chronicleEntry) + { + theCharacter.removeChronicleEntry(chronicleEntry); + chronicleEntries.removeElement(chronicleEntry); + } + + /* (non-Javadoc) + * @see pcgen.core.facade.DescriptionFacade#getChronicleEntries() + */ + public ListFacade<ChronicleEntry> getChronicleEntries() + { + return chronicleEntries; + } + +} Property changes on: sandbox/uisync/code/src/java/pcgen/gui2/facade/DescriptionFacadeImpl.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Id Added: svn:eol-style + native Modified: sandbox/uisync/code/src/java/pcgen/gui2/tabs/bio/CampaignHistoryInfoPane.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/gui2/tabs/bio/CampaignHistoryInfoPane.java 2011-10-07 20:42:07 UTC (rev 15434) +++ sandbox/uisync/code/src/java/pcgen/gui2/tabs/bio/CampaignHistoryInfoPane.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -45,7 +45,9 @@ import javax.swing.Scrollable; import org.apache.commons.lang.StringUtils; import pcgen.cdom.base.Constants; +import pcgen.core.ChronicleEntry; import pcgen.core.facade.CharacterFacade; +import pcgen.core.facade.DescriptionFacade; import pcgen.gui2.tabs.CharacterInfoTab; import pcgen.gui2.tabs.TabTitle; import pcgen.gui2.tools.Icons; @@ -114,7 +116,7 @@ public Hashtable<Object, Object> createModels(CharacterFacade character) { Hashtable<Object, Object> state = new Hashtable<Object, Object>(); - state.put(ChronicleHandler.class, new ChronicleHandler()); + state.put(ChronicleHandler.class, new ChronicleHandler(character)); return state; } @@ -136,14 +138,30 @@ { private List<ChroniclePane> chronicles; + private DescriptionFacade descFacade; - public ChronicleHandler() + public ChronicleHandler(CharacterFacade character) { super("Add Next Chronicle"); + descFacade = character.getDescriptionFacade(); chronicles = new ArrayList<ChroniclePane>(); - chronicles.add(new ChroniclePane(this)); + for (ChronicleEntry entry : descFacade.getChronicleEntries()) + { + chronicles.add(new ChroniclePane(this, entry)); + } } + /** + * Crete a new chronicle entry for the character. + */ + private ChroniclePane createNewChronicleEntry() + { + ChronicleEntry entry = descFacade.createChronicleEntry(); + ChroniclePane pane = new ChroniclePane(this, entry); + chroniclesPane.add(pane); + return pane; + } + public void install() { addButton.setAction(this); @@ -157,8 +175,7 @@ public void actionPerformed(ActionEvent e) { - ChroniclePane pane = new ChroniclePane(this); - chroniclesPane.add(pane); + ChroniclePane pane = createNewChronicleEntry(); chronicles.add(pane); chroniclesPane.revalidate(); } @@ -185,6 +202,7 @@ private JTextField gmField = new JTextField(); private JTextArea textArea = new JTextArea(); private ChronicleHandler handler; + private ChronicleEntry entry; public ChroniclePane() { @@ -192,10 +210,12 @@ initComponents(); } - public ChroniclePane(ChronicleHandler handler) + public ChroniclePane(ChronicleHandler handler, ChronicleEntry entry) { this(); this.handler = handler; + this.entry = entry; + populateComponents(); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); deleteButton.addActionListener(this); @@ -281,6 +301,21 @@ add(new JScrollPane(textArea), gbc); } + /** + * Place the values from the entry into the fields. + */ + private void populateComponents() + { + checkBox.setSelected(entry.isOutputEntry()); + campaignField.setText(entry.getCampaign()); + adventureField.setText(entry.getAdventure()); + partyField.setText(entry.getParty()); + dateField.setText(entry.getDate()); + xpField.setText(String.valueOf(entry.getXpField())); + gmField.setText(entry.getGmField()); + textArea.setText(entry.getChronicle()); + } + } private class ChroniclesPane extends JPanel implements Scrollable Modified: sandbox/uisync/code/src/java/pcgen/io/EntityEncoder.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/io/EntityEncoder.java 2011-10-07 20:42:07 UTC (rev 15434) +++ sandbox/uisync/code/src/java/pcgen/io/EntityEncoder.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -140,13 +140,15 @@ public static String encode(String s) { final StringBuffer buffer = new StringBuffer(); - final StringTokenizer tokens = new StringTokenizer(s, ENCODE, true); - - while (tokens.hasMoreTokens()) + if (s != null) { - buffer.append(ENTITIES.get(tokens.nextToken())); + final StringTokenizer tokens = new StringTokenizer(s, ENCODE, true); + + while (tokens.hasMoreTokens()) + { + buffer.append(ENTITIES.get(tokens.nextToken())); + } } - return buffer.toString(); } } Modified: sandbox/uisync/code/src/java/pcgen/io/IOConstants.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/io/IOConstants.java 2011-10-07 20:42:07 UTC (rev 15434) +++ sandbox/uisync/code/src/java/pcgen/io/IOConstants.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -53,6 +53,9 @@ /** Tag for Follower ADJUSTMENT */ String TAG_ADJUSTMENT = "ADJUSTMENT"; + /** Adventure */ + String TAG_ADVENTURE = "ADVENTURE"; + /** AGE tag - Used by PCGVer2Creator and Parser */ String TAG_AGE = "AGE"; @@ -152,6 +155,12 @@ /** CHOSENTEMPLATE */ String TAG_CHOSENTEMPLATE = "CHOSENTEMPLATE"; + + /** CHRONICLE */ + String TAG_CHRONICLE = "CHRONICLE"; + /** CHRONICLE_ENTRY */ + String TAG_CHRONICLE_ENTRY = "CHRONICLEENTRY"; + /** CITY */ String TAG_CITY = "CITY"; @@ -174,6 +183,8 @@ String TAG_CUSTOMIZATION = "CUSTOMIZATION"; /** DATA */ String TAG_DATA = "DATA"; + /** Date */ + String TAG_DATE = "DATE"; /** DEFINED */ String TAG_DEFINED = "DEFINED"; @@ -239,6 +250,8 @@ String TAG_GAMEMODE = "GAMEMODE"; /** GENDER */ String TAG_GENDER = "GENDER"; + /** Game master */ + String TAG_GM = "GM"; /** HAIRCOLOR */ String TAG_HAIRCOLOR = "HAIRCOLOR"; /** HAIRSTYLE */ @@ -293,6 +306,8 @@ String TAG_OUTPUTORDER = "OUTPUTORDER"; /** PARENTID */ String TAG_PARENTID = "PARENTID"; + /** Party */ + String TAG_PARTY = "PARTY"; /** PC */ String TAG_PC = "PC"; /** PCCLASS */ Modified: sandbox/uisync/code/src/java/pcgen/io/PCGVer2Creator.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/io/PCGVer2Creator.java 2011-10-07 20:42:07 UTC (rev 15434) +++ sandbox/uisync/code/src/java/pcgen/io/PCGVer2Creator.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -59,6 +59,7 @@ import pcgen.core.AbilityCategory; import pcgen.core.BonusManager; import pcgen.core.Campaign; +import pcgen.core.ChronicleEntry; import pcgen.core.Deity; import pcgen.core.Description; import pcgen.core.Domain; @@ -440,6 +441,13 @@ appendAgeSetLine(buffer); /* + * #Campaign History + */ + appendNewline(buffer); + appendComment("Campaign History", buffer); //$NON-NLS-1$ + appendCampaignHistoryLines(buffer); + + /* * Add one more newline at end of file */ appendNewline(buffer); @@ -598,6 +606,41 @@ buffer.append(LINE_SEP); } + /** + * @param buffer + */ + private void appendCampaignHistoryLines(StringBuffer buffer) + { + for (ChronicleEntry ce : thePC.getChronicleEntries()) + { + buffer.append(TAG_CHRONICLE_ENTRY).append(':'); + buffer.append(ce.isOutputEntry()?"Y":"N:"); + buffer.append('|'); + buffer.append(TAG_CAMPAIGN).append(':'); + buffer.append(EntityEncoder.encode(ce.getCampaign())); + buffer.append('|'); + buffer.append(TAG_ADVENTURE).append(':'); + buffer.append(EntityEncoder.encode(ce.getAdventure())); + buffer.append('|'); + buffer.append(TAG_PARTY).append(':'); + buffer.append(EntityEncoder.encode(ce.getParty())); + buffer.append('|'); + buffer.append(TAG_DATE).append(':'); + buffer.append(EntityEncoder.encode(ce.getDate())); + buffer.append('|'); + buffer.append(TAG_EXPERIENCE).append(':'); + buffer.append(ce.getXpField()); + buffer.append('|'); + buffer.append(TAG_GM).append(':'); + buffer.append(EntityEncoder.encode(ce.getGmField())); + buffer.append('|'); + buffer.append(TAG_CHRONICLE).append(':'); + buffer.append(EntityEncoder.encode(ce.getChronicle())); + buffer.append(LINE_SEP); + + } + } + private void appendCatchPhraseLine(StringBuffer buffer) { buffer.append(TAG_CATCHPHRASE).append(':'); Modified: sandbox/uisync/code/src/java/pcgen/io/PCGVer2Parser.java =================================================================== --- sandbox/uisync/code/src/java/pcgen/io/PCGVer2Parser.java 2011-10-07 20:42:07 UTC (rev 15434) +++ sandbox/uisync/code/src/java/pcgen/io/PCGVer2Parser.java 2011-10-10 00:34:34 UTC (rev 15435) @@ -72,6 +72,7 @@ import pcgen.core.AbilityUtilities; import pcgen.core.BonusManager; import pcgen.core.Campaign; +import pcgen.core.ChronicleEntry; import pcgen.core.Deity; import pcgen.core.Domain; import pcgen.core.Equipment; @@ -1457,6 +1458,14 @@ } } + if (cache.containsKey(TAG_CHRONICLE_ENTRY)) + { + for (final String line : cache.get(TAG_CHRONICLE_ENTRY)) + { + parseChronicleEntryLine(line); + } + } + } /* @@ -3421,6 +3430,88 @@ } } + /* + * ############################################################### + * Character Chronicle Entry methods + * ############################################################### + */ + private void parseChronicleEntryLine(final String line) + { + final PCGTokenizer tokens; + + try + { + tokens = new PCGTokenizer(line); + } + catch (PCGParseException pcgpex) + { + final String msg = + LanguageBundle.getFormattedString( + "Warnings.PCGenParser.IllegalChronicleEntry", //$NON-NLS-1$ + line, pcgpex.getMessage()); + warnings.add(msg); + + return; + } + + final ChronicleEntry ce = new ChronicleEntry(); + + for (PCGElement element : tokens.getElements()) + { + final String tag = element.getName(); + + if (TAG_CHRONICLE_ENTRY.equals(tag)) + { + ce.setOutputEntry("Y".equals(element.getText())); + } + else if (TAG_EXPERIENCE.equals(tag)) + { + try + { + ce.setXpField(Integer.parseInt(element.getText())); + } + catch (NumberFormatException nfe) + { + ce.setXpField(0); + + final String msg = + LanguageBundle.getFormattedString( + "Warnings.PCGenParser.InvalidChronicleEntry", //$NON-NLS-1$ + line); + warnings.add(msg); + + break; + } + } + else if (TAG_CAMPAIGN.equals(tag)) + { + ce.setCampaign(EntityEncoder.decode(element.getText())); + } + else if (TAG_ADVENTURE.equals(tag)) + { + ce.setAdventure(EntityEncoder.decode(element.getText())); + } + else if (TAG_PARTY.equals(tag)) + { + ce.setParty(EntityEncoder.decode(element.getText())); + } + else if (TAG_DATE.equals(tag)) + { + ce.setDate(EntityEncoder.decode(element.getText())); + } + else if (TAG_GM.equals(tag)) + { + ce.setGmField(EntityEncoder.decode(element.getText())); + } + else if (TAG_CHRONICLE.equals(tag)) + { + ce.setChronicle(EntityEncoder.decode(element.getText())); + } + } + + thePC.addChronicleEntry(ce); + } + /** * # PDF Output Sheet location * @param line This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |