|
From: <boo...@us...> - 2006-07-28 02:53:43
|
Revision: 1232 Author: boomer70 Date: 2006-07-27 19:52:48 -0700 (Thu, 27 Jul 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=1232&view=rev Log Message: ----------- Part 4 of FREQ [ 1484380 ] [SPEC] Companion Mod Enhancements implemented. 1. Global COMPANIONLIST tag implemented 2. FOLLOWERADJUSTMENT accounted for. 3. GUI changed to display and use the companion list for each type. This FREQ is basically complete now. Modified Paths: -------------- Trunk/pcgen/code/pluginbuild.xml Trunk/pcgen/code/src/java/pcgen/core/Constants.java Trunk/pcgen/code/src/java/pcgen/core/Equipment.java Trunk/pcgen/code/src/java/pcgen/core/Globals.java Trunk/pcgen/code/src/java/pcgen/core/PObject.java Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java Trunk/pcgen/code/src/java/pcgen/core/Race.java Trunk/pcgen/code/src/java/pcgen/core/character/Follower.java Trunk/pcgen/code/src/java/pcgen/core/chooser/MiscChoiceManager.java Trunk/pcgen/code/src/java/pcgen/gui/CharacterInfo.java Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/resources/AvailableFollowerModel.java Trunk/pcgen/code/src/java/pcgen/gui/utils/PObjectNode.java Trunk/pcgen/code/src/java/pcgen/gui/utils/SwingChooser.java Trunk/pcgen/code/src/java/pcgen/gui/utils/chooser/ChooserTableModel.java Trunk/pcgen/code/src/java/pcgen/io/IOConstants.java Trunk/pcgen/code/src/java/pcgen/io/PCGParser.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer0Parser.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Creator.java Trunk/pcgen/code/src/java/pcgen/io/PCGVer2Parser.java Trunk/pcgen/code/src/java/pcgen/io/exporttoken/Token.java Trunk/pcgen/code/src/java/pcgen/persistence/lst/LstUtils.java Trunk/pcgen/code/src/java/pcgen/util/Logging.java Trunk/pcgen/code/src/java/pcgen/util/PropertyFactory.java Trunk/pcgen/code/src/java/plugin/exporttokens/RaceToken.java Trunk/pcgen/code/src/java/plugin/lsttokens/FollowersLst.java Trunk/pcgen/code/src/java/plugin/lsttokens/race/RacenameToken.java Trunk/pcgen/data/d20ogl/srd35/basics/rsrd_classes_base.lst Trunk/pcgen/data/d20ogl/srd35/basics/rsrd_companionmods.lst Trunk/pcgen/data/d20ogl/srd35/basics/rsrd_feats.lst Trunk/pcgen/data/d20ogl/srd35/basics/rsrd_feats_hidden.lst Added Paths: ----------- Trunk/pcgen/code/src/java/pcgen/core/FollowerOption.java Trunk/pcgen/code/src/java/pcgen/gui/HTMLUtils.java Trunk/pcgen/code/src/java/plugin/lsttokens/CompanionListLst.java Property Changed: ---------------- Trunk/pcgen/ Property changes on: Trunk/pcgen ___________________________________________________________________ Name: svn:ignore - pcgen.jar *.ini pcgen-tests.jar pcgen.sh pcgen.bat pcgen_low_mem.bat target .pmd .settings bak + pcgen.jar *.ini pcgen-tests.jar pcgen.sh pcgen.bat pcgen_low_mem.bat target .pmd .settings bak .metadata Modified: Trunk/pcgen/code/pluginbuild.xml =================================================================== --- Trunk/pcgen/code/pluginbuild.xml 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/pluginbuild.xml 2006-07-28 02:52:48 UTC (rev 1232) @@ -1855,6 +1855,13 @@ </patternset> </fileset> </jar> + <jar jarfile="${lstplugins.dir}/LstToken-COMPANIONLIST.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> + <fileset dir="${build.classes.dir}"> + <patternset> + <include name="plugin/lsttokens/CompanionListLst.class" /> + </patternset> + </fileset> + </jar> <jar jarfile="${lstplugins.dir}/LstToken-DEFINE.jar" manifest="${src.java.dir}/plugin/lsttokens/manifest.mf"> <fileset dir="${build.classes.dir}"> <patternset> Modified: Trunk/pcgen/code/src/java/pcgen/core/Constants.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Constants.java 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/src/java/pcgen/core/Constants.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -376,4 +376,7 @@ /** For Tokens that need to know they're dealing with a .fo file */ String XSL_FO_EXTENSION = "fo"; + + /** An empty string. */ + String EMPTY_STRING = ""; //$NON-NLS-1$ } Modified: Trunk/pcgen/code/src/java/pcgen/core/Equipment.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/src/java/pcgen/core/Equipment.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -3340,7 +3340,7 @@ * @param endPart * @return String **/ - public String formatSaveLine(final String sep, final String endPart) + public String formatSaveLine(final char sep, final char endPart) { final StringBuffer sbuf = new StringBuffer(100); @@ -4266,7 +4266,7 @@ boolean save(final BufferedWriter output) { - FileAccess.write(output, "BASEITEM:" + formatSaveLine("\t", ":")); + FileAccess.write(output, "BASEITEM:" + formatSaveLine('\t', ':')); FileAccess.newLine(output); return true; Added: Trunk/pcgen/code/src/java/pcgen/core/FollowerOption.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/FollowerOption.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/core/FollowerOption.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -0,0 +1,219 @@ +/* + * FollowerOption.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.core; + +import java.text.Collator; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; + +/** + * This class represents a possible choice for a follower. This is basically + * a Race with a "FOLLOWERADJUSTMENT" that modifies the owner's effective + * level when selecting a follower of this type. Prereqs can also be specified + * + * @author boomer70 + */ +public class FollowerOption extends PrereqObject implements Comparable<FollowerOption> +{ + private String theRaceKey; + private Race theRace = null; + private int theAdjustment = 0; + private String theType = null; + + private static final String ANY_RACE = "ANY"; //$NON-NLS-1$ + private static final String RACETYPE = "RACETYPE"; //$NON-NLS-1$ + + /** + * Creates a FollowerOption of the specified race with no adjustment and + * an unknown type. + * @param aRace The race key of this companion + */ + public FollowerOption( final String aRace ) + { + theRaceKey = aRace; + theRace = Globals.getRaceKeyed( theRaceKey ); + } + + /** + * Creates a FollowerOption of the specified race with no adjustment and + * an unknown type. + * @param aRace The race of this companion + */ + public FollowerOption( final Race aRace ) + { + theRace = aRace; + theRaceKey = aRace.getKeyName(); + } + + /** + * Returns the race associated with this option. If this option represents + * a group of races this method will return null. + * @return The Race associated or null + */ + public Race getRace() + { + if ( theRace == null ) + { + if ( theRaceKey.startsWith( RACETYPE ) + || theRaceKey.equalsIgnoreCase(ANY_RACE) ) + { + return null; + } + theRace = Globals.getRaceKeyed( theRaceKey ); + } + return theRace; + } + + /** + * Separates into indivual FollowerOptions this option. If this option + * does not represent multiple races it will simply return itself. + * Otherwise the method returns a list of FollowerOptions with the same + * options one for each Race that qualifies. + * @return The expanded list of FollowerOptions + */ + public Collection<FollowerOption> getExpandedOptions() + { + final List<FollowerOption> options = new ArrayList<FollowerOption>(); + if ( theRace != null ) + { + options.add( this ); + return options; + } + Collection<Race> raceSet = null; + if ( theRaceKey.startsWith( RACETYPE ) ) + { + raceSet = new HashSet<Race>(); + final String raceType = theRaceKey.substring(10); + final Collection<Race> allRaces = Globals.getRaceMap().values(); + for ( final Race r : allRaces ) + { + if ( raceType.equalsIgnoreCase(r.getRaceType()) ) + { + raceSet.add( r ); + } + } + } + else if ( theRaceKey.equals( ANY_RACE ) ) + { + raceSet = new HashSet<Race>(); + raceSet.addAll( Globals.getRaceMap().values() ); + } + if ( raceSet != null ) + { + for ( final Race r : raceSet ) + { + final FollowerOption opt = new FollowerOption( r ); + opt.setAdjustment( getAdjustment() ); + opt.addPrerequisites( getPreReqList() ); + options.add( opt ); + } + } + return options; + } + + /** + * Sets the Follower type for this option. + * @param aType The follower type to set e.g. Familiar + */ + public void setType( final String aType ) + { + theType = aType; + } + + /** + * Gets the Follower type for this option. + * @return The Follower type e.g. Familiar + */ + public String getType() + { + return theType; + } + + /** + * Sets the variable adjustment for a master selecting this option. For + * example an adjustment of -3 would mean the master's level would be 3 + * lower for purposes of applying companion mods. + * @param anAdjustment Amount to modify the master's level by + */ + public void setAdjustment( final int anAdjustment ) + { + theAdjustment = anAdjustment; + } + + /** + * Returns the adjustment to the master's level for this option. + * @return The adjustment to the master's level + */ + public int getAdjustment() + { + return theAdjustment; + } + + /** + * This method is overridden to also check that a master has enough + * effective levels to have a positive level after applying any adjustment + * for this follower. For example, if a follower has an adjustment of -3 + * then the master must have at least 4 levels to qualify for this follower + * (4 - 3 > 0) + * @see pcgen.core.PrereqObject#qualifies(pcgen.core.PlayerCharacter) + */ + @Override + public boolean qualifies( final PlayerCharacter aPC ) + { + if ( theAdjustment != 0 ) + { + final int lvl = aPC.getEffectiveCompanionLevel( theType ); + if ( lvl + theAdjustment <= 0 ) + { + return false; + } + } + + return super.qualifies( aPC ); + } + + /** + * Compares this FollowerOption to another. This uses the race name of the + * option to do the comparison. + * @param anO The FollowerOption to compare to. + * @return The comparison between the objects + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + public int compareTo(FollowerOption anO) + { + final Collator col = Collator.getInstance(); + String s1 = theRaceKey; + String s2 = anO.theRaceKey; + if ( this.theRace != null ) + { + s1 = theRace.getDisplayName(); + } + if ( anO.theRace != null ) + { + s2 = anO.theRace.getDisplayName(); + } + return col.compare( s1, s2); + } +} Property changes on: Trunk/pcgen/code/src/java/pcgen/core/FollowerOption.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/pcgen/core/Globals.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -473,11 +473,12 @@ public static void addCompanionMod( final CompanionMod aMod ) { - List<CompanionMod> mods = companionModMap.get( aMod.getType() ); + final String type = aMod.getType().toUpperCase(); + List<CompanionMod> mods = companionModMap.get( type ); if ( mods == null ) { mods = new ArrayList<CompanionMod>(); - companionModMap.put( aMod.getType(), mods ); + companionModMap.put( type, mods ); } mods.add( aMod ); } @@ -500,20 +501,35 @@ } } + /** + * Returns all types of followers for which a <code>CompanionMod</code> + * has been defined. + * + * @return Collection of Follower types. + */ public static Collection<String> getFollowerTypes() { return Collections.unmodifiableSet( companionModMap.keySet() ); } + /** + * Gets all the <code>CompanionMod</code>s for the specified type of + * follower. + * + * @param aType The type of Follower to get mods for. + * @return Collection of COMPANIONMODs or an EMPTY_LIST + */ public static Collection<CompanionMod> getCompanionMods( final String aType ) { - final List<CompanionMod> cMods = companionModMap.get( aType ); + final String type = aType.toUpperCase(); + final List<CompanionMod> cMods = companionModMap.get( type ); if ( cMods == null ) { return Collections.emptyList(); } - return Collections.unmodifiableList( companionModMap.get( aType ) ); + return Collections.unmodifiableList( companionModMap.get( type ) ); } + /** * Get companion modifier * @param aString Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -89,8 +89,10 @@ protected Map<String, String> vision = null; private HashMap<String, String> pluginDataMap = new HashMap<String, String>(); - protected String keyName = ""; - protected String displayName = ""; + /** The Non-internationalized name to use to refer to this object. */ + protected String keyName = Constants.EMPTY_STRING; + /** The name to display to the user. This should be internationalized. */ + protected String displayName = Constants.EMPTY_STRING; /** Indicates if this object should be displayed to the user in the UI. */ protected boolean visible = true; @@ -122,10 +124,12 @@ private ArrayList<DamageReduction> drList = new ArrayList<DamageReduction>(); - private String chooseLanguageAutos = ""; + private String chooseLanguageAutos = Constants.EMPTY_STRING; /** Number of followers of each type allowed */ - private Map<String, List<String>> followerNumbers = new HashMap<String, List<String>>(); + private Map<String, List<String>> followerNumbers = null; + /** List of followers of a type allowed to be selected. */ + private Map<String, List<FollowerOption>> theAvailableFollowers = null; /* ************ * Methods @@ -160,7 +164,7 @@ public final String getAssociated(int idx, final boolean expand) { if (associatedList == null) { - return ""; + return Constants.EMPTY_STRING; } if (expand) @@ -175,11 +179,8 @@ { return choice.getDefaultChoice(); } - else - { - return choice.getChoice(String.valueOf(currentCount - + idx)); - } + return choice.getChoice(String.valueOf(currentCount + + idx)); } currentCount += choice.size(); } @@ -1618,7 +1619,14 @@ retVal.levelAbilityList.add(ab); } } - retVal.followerNumbers = new HashMap<String,List<String>>(followerNumbers); + if ( followerNumbers != null ) + { + retVal.followerNumbers = new HashMap<String,List<String>>(followerNumbers); + } + if ( theAvailableFollowers != null ) + { + retVal.theAvailableFollowers = new HashMap<String, List<FollowerOption>>( theAvailableFollowers ); + } return retVal; } @@ -1633,6 +1641,7 @@ return 1; } + @Override public boolean equals( final Object obj ) { if ( obj == null ) @@ -1784,6 +1793,15 @@ } /** + * This method sets only the name not the key. + * @param aName Name to use for display + */ + public void setDisplayName( final String aName ) + { + displayName = aName; + } + + /** * Get name * @return name */ @@ -4656,6 +4674,10 @@ */ public void setNumFollowers( final String aType, final String aFormula) { + if ( followerNumbers == null ) + { + followerNumbers = new HashMap<String, List<String>>(); + } List<String> numFollowers = followerNumbers.get( aType ); if ( numFollowers == null ) { @@ -4668,6 +4690,10 @@ public List<String> getNumFollowers( final String aType ) { + if ( followerNumbers == null ) + { + return null; + } final List<String> formulas = followerNumbers.get( aType.toUpperCase() ); if ( formulas == null ) { @@ -4676,6 +4702,58 @@ return Collections.unmodifiableList( formulas ); } + public void addToFollowerList( final String aType, final FollowerOption anOption ) + { + final String ucType = aType.toUpperCase(); + if ( theAvailableFollowers == null ) + { + theAvailableFollowers = new HashMap<String, List<FollowerOption>>(); + } + List<FollowerOption> followers = theAvailableFollowers.get( ucType ); + if ( followers == null ) + { + followers = new ArrayList<FollowerOption>(); + theAvailableFollowers.put( ucType, followers ); + } + followers.add( anOption ); + } + + /** + * Gets the list of potential followers of a given type. + * @param aType Type of follower to retrieve list for e.g. Familiar + * @return A List of FollowerOption objects representing the possible list + * of follower choices. + */ + public List<FollowerOption> getPotentialFollowers( final String aType ) + { + if ( theAvailableFollowers == null ) + { + return null; + } + final String ucType = aType.toUpperCase(); + List<FollowerOption> options = theAvailableFollowers.get( ucType ); + if ( options != null ) + { + for ( int i = options.size() - 1; i >= 0; i-- ) + { + FollowerOption opt = options.get(i); + if ( opt.getRace() == null ) + { + // This FollowerOption references more than one race. + // We need to get the expanded versions and throw this one + // away + final Collection<FollowerOption> newOpts = opt.getExpandedOptions(); + if ( newOpts != null ) + { + options.addAll( newOpts ); + } + options.remove(i); + } + } + } + return options; + } + // public void addSpellLikeAbilities( final int aLevel, final List<SpellLikeAbility> aList ) // { // Prerequisite minLevel = null; Modified: Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/src/java/pcgen/core/PlayerCharacter.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -69,6 +69,7 @@ import pcgen.util.BigDecimalHelper; import pcgen.util.Delta; import pcgen.util.Logging; +import pcgen.util.PropertyFactory; import pcgen.util.enumeration.Visibility; /** @@ -84,7 +85,7 @@ public static final int ATTACKBONUS = 0; /** MONKBONUS = 4 */ public static final int MONKBONUS = 4; - private static final BigDecimal BIG_ONE = new BigDecimal("1.00"); + private static final BigDecimal BIG_ONE = new BigDecimal(1); private static String lastVariable = null; // List of Armor Proficiencies @@ -115,7 +116,7 @@ // List of VARs private final ArrayList<String> variableList = new ArrayList<String>(); - private BigDecimal gold = new BigDecimal("0.00"); + private BigDecimal gold = new BigDecimal(0); private Deity deity = null; // source of granted domains @@ -172,10 +173,10 @@ private final SortedSet<Language> templateLanguages = new TreeSet<Language>(); private final TreeSet<Language> languages = new TreeSet<Language>(); private StringKeyMap stringChar = new StringKeyMap(); - private String calcEquipSetId = "0.1"; - private String descriptionLst = "EMPTY"; - private String tabName = ""; - private String gender = "Male"; + private String calcEquipSetId = "0.1"; //$NON-NLS-1$ + private String descriptionLst = "EMPTY"; //$NON-NLS-1$ + private String tabName = Constants.EMPTY_STRING; + private String gender = Globals.getAllGenders().get(0); private HashSet<String> variableSet = new HashSet<String>(); // Weapon, Armor and Shield proficiencies @@ -210,8 +211,8 @@ private final boolean useMonsterDefault = SettingsHandler.isMonsterDefault(); // output sheet locations - private String outputSheetHTML = ""; - private String outputSheetPDF = ""; + private String outputSheetHTML = Constants.EMPTY_STRING; + private String outputSheetPDF = Constants.EMPTY_STRING; private boolean[] ageSetKitSelections = new boolean[10]; private boolean dirtyFlag = false; private int serial = 0; @@ -280,19 +281,19 @@ } setRace(Globals.getRaceMap().get(Constants.s_NONESELECTED)); - setName(""); + setName(Constants.EMPTY_STRING); setFeats(0); rollStats(SettingsHandler.getGame().getRollMethod()); - miscList.add(""); - miscList.add(""); - miscList.add(""); + miscList.add(Constants.EMPTY_STRING); + miscList.add(Constants.EMPTY_STRING); + miscList.add(Constants.EMPTY_STRING); addSpellBook(new SpellBook(Globals.getDefaultSpellBook(), SpellBook.TYPE_KNOWN_SPELLS)); addSpellBook(new SpellBook(Globals.INNATE_SPELL_BOOK_NAME, SpellBook.TYPE_KNOWN_SPELLS)); populateSkills(SettingsHandler.getSkillsTab_IncludeSkills()); spellTracker = new PCSpellTracker(this); - setStringFor(StringKey.HANDED, "Right"); + setStringFor(StringKey.HANDED, PropertyFactory.getString("in_right")); //$NON-NLS-1$ } /** @@ -373,14 +374,13 @@ return skillList; } - for (Skill aSkill : Globals.getSkillList()) + for ( final Skill skill : Globals.getSkillList() ) { - if (!hasSkill(aSkill.getKeyName())) + if (!hasSkill(skill.getKeyName())) { -// if (!CoreUtility.doublesEqual(getTotalBonusTo("SKILLRANK", aSkill.getName()), 0.0)) - if (!CoreUtility.doublesEqual(aSkill.getSkillRankBonusTo(this), 0.0)) + if (!CoreUtility.doublesEqual(skill.getSkillRankBonusTo(this), 0.0)) { - addSkill(aSkill); + addSkill(skill); } } } @@ -1445,8 +1445,8 @@ } } - return match; - } + return match; + } /** * Set the characters eye colour @@ -1897,13 +1897,50 @@ } /** + * This method returns the effective level of this character for purposes + * of applying companion mods to a companion of the specified type. + * <p> + * <b>Note</b>: This whole structure is kind of messed up since nothing + * enforces that a companion mod of a given type always looks at the same + * variable (either Class or Variable). + * + * @param compType A type of companion to get level for + * @return The effective level for this companion type + */ + public int getEffectiveCompanionLevel( final String compType ) + { + final Collection<CompanionMod> mods = Globals.getCompanionMods( compType ); + for ( CompanionMod cMod : mods ) + { + for (Iterator<String> iType = cMod.getVarMap().keySet().iterator(); iType.hasNext();) + { + final String varName = iType.next(); + final int lvl = this.getVariableValue( varName, Constants.EMPTY_STRING ).intValue(); + if ( lvl > 0 ) + { + return lvl; + } + } + for ( final String classKey : cMod.getClassMap().keySet() ) + { + final int lvl = this.getClassKeyed( classKey ).getLevel(); + if ( lvl > 0 ) + { + return lvl; + } + } + } + return 0; + } + + /** * Set the master for this object * also set the level dependent stats based on the masters level * and info contained in the companionModList Array * such as HitDie, SR, BONUS, SA, etc * @param aM The master to be set. */ - public void setMaster(final Follower aM) + public void setMaster( final Follower aM ) { followerMaster = aM; @@ -1953,7 +1990,7 @@ // Check all the masters classes for (PCClass mClass : mPC.getClassList()) { - final int mLev = mClass.getLevel(); + final int mLev = mClass.getLevel() + aM.getAdjustment(); final int compLev = cMod.getLevel(mClass.getKeyName()); if (compLev < 0) @@ -1975,7 +2012,9 @@ } for (String varName : cMod.getVarMap().keySet()) { - if (mPC.getVariableValue(varName, "").intValue() >= cMod.getLevel(varName)) + final int mLev = mPC.getVariableValue( varName, Constants.EMPTY_STRING ).intValue() + aM.getAdjustment(); + + if ( mLev >= cMod.getLevel(varName) ) { if ( PrereqHandler.passesAll( cMod.getPreReqList(), this, cMod ) ) // if (!companionModList.contains(aComp)) @@ -2074,6 +2113,14 @@ setDirty(true); } + /** + * Returns the maximum number of followers of the specified type this + * character can have. This method does not adjust for any followers + * already selected by the character. + * + * @param aType The follower type to check e.g. Familiar + * @return The max number of followers -1 for any number + */ public int getMaxFollowers( final String aType ) { int ret = -1; @@ -2134,6 +2181,33 @@ } /** + * Gets the list of potential followers of a given type. + * @param aType Type of follower to retrieve list for e.g. Familiar + * @return A List of FollowerOption objects representing the possible list + * of follower choices. + */ + public List<FollowerOption> getAvailableFollowers( final String aType ) + { + final List<FollowerOption> ret = new ArrayList<FollowerOption>(); + + final List<? extends PObject> pobjList = getPObjectList(); + for ( PObject pobj : pobjList ) + { + if ( pobj == null ) + { + continue; + } + + final List<FollowerOption> followers = pobj.getPotentialFollowers(aType); + if ( followers != null ) + { + ret.addAll( followers ); + } + } + return ret; + } + + /** * Get the Follower object that is the "master" for this object * @return follower master */ @@ -2684,16 +2758,16 @@ for (SpecialAbility sa : getSpecialAbilityList()) { - if (!PrereqHandler.passesAll( sa.getPreReqList(), this, sa )) - { - continue; + if (!PrereqHandler.passesAll( sa.getPreReqList(), this, sa )) + { + continue; + } + final String saText = sa.getParsedText(this, this); + if (saText!=null && !saText.equals("")) + { + bList.add(saText); + } } - final String saText = sa.getParsedText(this, this); - if (saText!=null && !saText.equals("")) - { - bList.add(saText); - } - } return bList; } @@ -3624,8 +3698,8 @@ for (PCStat stat : statList) { activateAndAddBonusesFromPObject(stat); - } } + } public boolean checkQualifyList(final String qualifierItem) { @@ -10713,7 +10787,7 @@ { buf.append("/"); first = false; - } + } buf.append(c.getFullDisplayClassName()); } @@ -11501,13 +11575,13 @@ { for (Equipment weap : EquipmentList.getEquipmentOfType("WEAPON." + aString.substring(11), "")) { - final WeaponProf aProf = Globals.getWeaponProfKeyed(weap.profKey(this)); + final WeaponProf aProf = Globals.getWeaponProfKeyed(weap.profKey(this)); - if (aProf != null) - { - addWeaponProfToList(aFeatList, aProf.getKeyName(), isAuto); + if (aProf != null) + { + addWeaponProfToList(aFeatList, aProf.getKeyName(), isAuto); + } } - } return; } @@ -11942,15 +12016,15 @@ for (EquipmentModifier eqMod : eq.getEqModifierList(true)) { - results.add(eqMod); - } + results.add(eqMod); + } for (EquipmentModifier eqMod : eq.getEqModifierList(false)) { - results.add(eqMod); + results.add(eqMod); + } } } - } // Feat (virtual feats, auto feats) results.addAll(aggregateFeatList()); Modified: Trunk/pcgen/code/src/java/pcgen/core/Race.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/Race.java 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/src/java/pcgen/core/Race.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -55,7 +55,6 @@ private String hitDieLock = ""; private String ageString = ""; private String bonusSkillList = ""; - private String displayName = "None"; //private String face = "5 ft. by 5 ft."; private Point2D.Double face = new Point2D.Double(5, 0); @@ -146,16 +145,6 @@ return CR; } - public void setDisplayName(final String displayName) - { - this.displayName = displayName; - } - - public String getDisplayName() - { - return displayName; - } - public String getDisplayVision(final PlayerCharacter aPC) { if (vision == null) Modified: Trunk/pcgen/code/src/java/pcgen/core/character/Follower.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/character/Follower.java 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/src/java/pcgen/core/character/Follower.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -51,11 +51,12 @@ * String fileName = path and file name * */ - private String fileName = ""; - private String name = ""; - private String race = ""; - private String type = ""; + private String fileName = Constants.EMPTY_STRING; + private String name = Constants.EMPTY_STRING; + private String race = Constants.EMPTY_STRING; + private String type = Constants.EMPTY_STRING; private int usedHD; + private int theAdjustment = 0; /** * Constructor @@ -191,6 +192,16 @@ return usedHD; } + public void setAdjustment( final int anAdjustment ) + { + theAdjustment = anAdjustment; + } + + public int getAdjustment() + { + return theAdjustment; + } + public int compareTo(final Object obj) { final Follower aF = (Follower) obj; @@ -216,5 +227,5 @@ ShowMessageDelegate.showMessageDialog(exc.getMessage(), Constants.s_APPNAME, MessageType.ERROR); } return aClone; + } } -} Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/MiscChoiceManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/core/chooser/MiscChoiceManager.java 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/src/java/pcgen/core/chooser/MiscChoiceManager.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -26,14 +26,13 @@ import pcgen.core.PObject; import pcgen.core.PlayerCharacter; -import java.util.Iterator; import java.util.List; /** * This is the chooser that deals with choosing from among a set * of supplied strings. */ -public class MiscChoiceManager extends AbstractComplexChoiceManager { +public class MiscChoiceManager extends AbstractComplexChoiceManager<String> { /** * Make a new Miscellaneous chooser. This is the chooser that deals @@ -52,7 +51,7 @@ chooserHandled = "MISC"; if (choices != null && choices.size() > 0 && - ((String) choices.get(0)).equals(chooserHandled)) { + choices.get(0).equals(chooserHandled)) { choices = choices.subList(1, choices.size()); } } @@ -63,16 +62,14 @@ * @param availableList * @param selectedList */ + @Override public void getChoices( PlayerCharacter aPc, - List availableList, - List selectedList) + List<String> availableList, + List<String> selectedList) { - Iterator it = choices.iterator(); - while (it.hasNext()) + for ( String aString : choices ) { - final String aString = (String) it.next(); - if (dupsAllowed || !availableList.contains(aString)) { availableList.add(aString); Modified: Trunk/pcgen/code/src/java/pcgen/gui/CharacterInfo.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/CharacterInfo.java 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/src/java/pcgen/gui/CharacterInfo.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -75,12 +75,12 @@ /** * Constructor - * @param pc - * @param tempTabList + * @param aPC + * @param aTempTabList */ - public CharacterInfo(PlayerCharacter pc, List<Component> tempTabList) { - this.pc = pc; - this.tempTabList = tempTabList; + public CharacterInfo(PlayerCharacter aPC, List<Component> aTempTabList) { + this.pc = aPC; + this.tempTabList = aTempTabList; infoDesc = new InfoDescription(pc); infoInventory = new InfoInventory(pc); infoSummary = new InfoSummary(pc); @@ -91,7 +91,7 @@ infoFeats = new InfoFeats(pc); infoDomain = new InfoDomain(pc); infoSpells = new InfoSpells(pc); - setName(""); + setName(""); //$NON-NLS-1$ try { jbInit(); Added: Trunk/pcgen/code/src/java/pcgen/gui/HTMLUtils.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/HTMLUtils.java (rev 0) +++ Trunk/pcgen/code/src/java/pcgen/gui/HTMLUtils.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -0,0 +1,61 @@ +/* + * HTMLUtils.java + * Copyright 2006 (C) Aaron Divinsky <boo...@ya...> + * + * 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 + * + * Current Ver: $Revision$ + * Last Editor: $Author: $ + * Last Edited: $Date$ + */ +package pcgen.gui; + +/** + * A utility class to simplify dealing with HTML controls. + * + * @author boomer70 + */ +public final class HTMLUtils +{ + /** Constant for HTML start tag */ + public static final String HTML = "<html>"; //$NON-NLS-1$ + /** Constant for HTML end tag */ + public static final String END_HTML = "</html>"; //$NON-NLS-1$ + /** Constant for HTML font size +1 tag */ + public static final String FONT_PLUS_1 = "<font size=+1>"; //$NON-NLS-1$ + /** Constant for HTML font end tag */ + public static final String END_FONT = "</font>"; //$NON-NLS-1$ + /** Constant for HTML paragraph tag */ + public static final String PARA = "<p>"; //$NON-NLS-1$ + /** Constant for HTML bold start tag */ + public static final String BOLD = "<b>"; //$NON-NLS-1$ + /** Constant for HTML bold end tag */ + public static final String END_BOLD = "</b>"; //$NON-NLS-1$ + /** Constant for HTML line break tag */ + public static final String BR = "<br>"; //$NON-NLS-1$ + /** Constant for HTML italic start tag */ + public static final String ITALIC = "<i>"; //$NON-NLS-1$ + /** Constant for HTML italic end tag */ + public static final String END_ITALIC = "</i>"; //$NON-NLS-1$ + /** Constant for HTML unordered (bulleted) list start tag */ + public static final String UL = "<ul>"; //$NON-NLS-1$ + /** Constant for HTML unordered (bulleted) list end tag */ + public static final String END_UL = "</ul>"; //$NON-NLS-1$ + /** Constant for HTML list item start tag */ + public static final String LI = "<li>"; //$NON-NLS-1$ + /** Constant for HTML list item end tag */ + public static final String END_LI = "</li>"; //$NON-NLS-1$ + +} Property changes on: Trunk/pcgen/code/src/java/pcgen/gui/HTMLUtils.java ___________________________________________________________________ Name: svn:keywords + "Author Revision Date Id" Name: svn:eol-style + native Modified: Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-07-28 02:52:48 UTC (rev 1232) @@ -3006,9 +3006,162 @@ InfoResources.AddFromFile=Add from existing File InfoResources.AddExistingFile=Add from existing File InfoResources.NoMoreFollowers=You cannot add any more followers of the selected type. +ToDo.InfoResources.AddFollower=You can select {1} more {0} Errors.Save=Could not save {0} Errors.Load=Unable to load {0} +Errors.LstTokens.RaceNotFound={0}: Could not find Race keyed {1} +Errors.LstTokens.InvalidTokenFormat={0}: Invalid token format [{1}] +Errors.TreeTableModel.NoActiveNode=No active node when doing getValueAt in {0} +Errors.FollowerModel.UnknownColumn=The column {0} not handled in {1} +Warnings.LstTokens.Deprecated={0} deprecated. Tag was {1} in {2} of {3}. {4} + in_plusSign=+ in_caretSymbol=^ + +in_adjustment=Adjustment + +Exceptions.PCGenParser.WrongNumAttributes=Number of attributes for character is {0}. PCGen is currently using {1}. Cannot load character. +Exceptions.PCGenParser.NoCampaignInfo=Insufficient campaign information to load character file. + +# 0 - Race key +Exceptions.PCGenParser.RaceNotFound=Race not found: {0}.\nCheck loaded campaigns. +# 0 - class key +Exceptions.PCGenParser.ClassNotFound=Class not found: {0}.\nCheck loaded campaigns. + +# 0 - Character GameMode +# 1 - Current GameMode +Exceptions.PCGenParser.WrongGameMode=Unable to load the character as it uses game mode: '{0}'. PCGen is currently using gamemode '{1}'. Use the 'Settings->Game Mode / Campaign' menu to change the current game mode. + +# 0 - Line being parsed +# 1 - Type of object +# 2 - Object key +Errors.PCGenParser.ObjectNotFound=Error in line: {0}\n Could not find {1} {2} + +# 0 - Line being parsed +Errors.PCGenParser.UnknownObject=Error in line: {0}\n Unknown object. + +# 0 - domain key +Errors.PCGenParser.DuplicateDomain=Duplicate domain found: {0} + +Warnings.PCGenParser.IllegalAgeLine=Illegal Age line ignored: {0} +Warnigns.PCGenParser.IllegalAlignment=Invalid alignment specification: {0} +Warnings.PCGenParser.IllegalClassAbility=Illegal Class abilities line ignored: {0}\nError: {1} +Warnings.PCGenParser.InvalidClassLevel=Invalid class/level specification: {0} + +# 0 - tag name +# 1 - Tag text +Warnings.PCGenParser.InvalidHP=Invalid hitpoint specification: {0}:{1} + +# 0 - Class key +Warnings.PCGenParser.ClassNotFound=Could not find class: {0} + +# 0 - tag name +# 1 - Tag text +Warnings.PCGenParser.InvalidStatMod=Invalid stat modification: {0}:{1} + +# 0 - tag name +# 1 - Tag text +Warnings.PCGenParser.UnknownStat=Unknown stat: {0}:{1} + +# 0 - tag name +# 1 - Tag text +Warnings.PCGenParser.UnknownStat=Missing = in tag: {0}:{1} + +# 0 - tag name +# 1 - Tag text +Warnings.PCGenParser.UnknownTag=Unknown tag: {0}:{1} + +# 0 - Tag text +Warnings.PCGenParser.CouldntAddClass=Could not add class: {0} + +# 0 - Tag text +Warnings.PCGenParser.InvalidLevel=Invalid level specification: {0} + +# 0 - Tag text +Warnings.PCGenParser.InvalidSkillPool=Invalid skill pool specification: {0} + +# 0 - line being parsed +# 1 - exception message +Warnings.PCGenParser.IllegalDeity=Illegal Deity line ignored: {0}\nError: {1} + +# 0 - line being parsed +# 1 - exception message +Warnings.PCGenParser.IllegalDomain=Illegal Domain line ignored: {0}\nError: {1} + +# 0 - Deity key +Warnings.PCGenParser.DeityNotFound=Deity not found: {0}.\nCheck loaded campaigns. +# 0 - Domain key +Warnings.PCGenParser.DomainNotFound=Global domain not found: {0}.\nCheck loaded campaigns. + +# 0 - Equipment key +Warnings.PCGenParser.EquipmentNotFound=Could not add equipment: {0}.\nCheck loaded campaigns. + +# 0 - line being parsed +# 1 - exception message +Warnings.PCGenParser.IllegalEquipSetTempBonus=Illegal EquipSetTempBonus line ignored: {0}\nError: {1} + +# 0 - line being parsed +Warnings.PCGenParser.InvalidEquipSetTempBonus=Illegal EquipSet TempBonus line ignored: {0} + +# 0 - line being parsed +# 1 - exception message +Warnings.PCGenParser.IllegalFeat=Illegal Feat line ignored: {0}\nError: {1} + +# 0 - feat key +Warnings.PCGenParser.CouldntAddAbility=Could not add Ability: {0} + +# 0 - line being parsed +Warnings.PCGenParser.IllegalFeatPool=Illegal Feat Pool line ignored: {0} + +# 0 - line being parsed +Warnings.PCGenParser.IllegalFeatIgnored=Illegal Feat line ignored: {0} + +# 0 - line being parsed +# 1 - exception message +Warnings.PCGenParser.IllegalFollower=Illegal Follower line ignored: {0}\nError: {1} + +# 0 - Skill key +# 1 - ranks +Warnings.PCGenParser.SkillNotFound=Ranked skill not found: {0} ({1}).\nCheck loaded campaigns. + +# 0 - line being parsed +Warnings.PCGenParser.IllegalHeight=Illegal Height line ignored: {0} + +# 0 - Kit key +Warnings.PCGenParser.KitNotFound=Could not add Kit: {0}.\nCheck loaded campaigns. + + +# 0 - line being parsed +# 1 - exception message +Warnings.PCGenParser.IllegalLanguage=Illegal Language line ignored: {0}\nError: {1} + +# 0 - line being parsed +# 1 - exception message +Warnings.PCGenParser.IllegalMaster=Illegal Master line ignored: {0}\nError: {1} + +# 0 - line being parsed +# 1 - exception message +Warnings.PCGenParser.IllegalNotes=Illegal Notes line ignored: {0}\nError: {1} +# 0 - line being parsed +Warnings.PCGenParser.InvalidNotes=Illegal Notes line ignored: {0} + +# 0 - line being parsed +Warnings.PCGenParser.InvalidPoolPoints=Illegal Pool Points line ignored: {0} + +# 0 - Race key +Warnings.PCGenParser.RaceFewerHD=Saved race ({0}) now has fewer HITDICE. + +# 0 - Race key +Warnings.PCGenParser.RaceMoreHD=Saved race ({0}) now has more HITDICE. + +# 0 - Race key +Warnings.PCGenParser.RaceNoHD=Saved race ({0}) no longer has a HITDICE tag. + +# 0 - Race key +Warnings.PCGenParser.RaceNoHDDefMon=Saved race ({0}) no longer has a HITDICE tag or,\nwas saved with "Use Default Monsters" on. + +# 0 - Tag data +Warnings.PCGenParser.UnknownRaceInfo=Ignoring unknown race info: {0}. + Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java 2006-07-27 22:37:39 UTC (rev 1231) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoResources.java 2006-07-28 02:52:48 UTC (rev 1232) @@ -70,16 +70,19 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.TableColumn; +import javax.swing.text.Position.Bias; import javax.swing.tree.TreePath; import pcgen.core.Constants; import pcgen.core.Equipment; +import pcgen.core.FollowerOption; import pcgen.core.GameMode; import pcgen.core.Globals; import pcgen.core.PCStat; import pcgen.core.PlayerCharacter; import pcgen.core.Race; import pcgen.core.SettingsHandler; +import pcgen.core.SizeAdjustment; import pcgen.core.character.Follower; import pcgen.core.utils.MessageType; import pcgen.core.utils.ShowMessageDelegate; @@ -109,6 +112,8 @@ import pcgen.util.Logging; import pcgen.util.PropertyFactory; +import static pcgen.gui.HTMLUtils.*; + /** * <code>InfoResources</code> creates a new tabbed panel that is used to * allow creating/adding familiars, cohorts, companions, intelligent items @@ -136,8 +141,6 @@ private JButton loadButton = new JButton(); private JButton updateButton = new JButton(); private JCheckBox shouldLoadCompanion = new JCheckBox(PropertyFactory.getString("InfoResources.AutoLoadCompanions")); //$NON-NLS-1$ - private final JLabel modeLabel = new JLabel(PropertyFactory.getString("InfoResources.ModeLabel")); //$NON-NLS-1$ - private JComboBoxEx viewModeBox = new JComboBoxEx(); private final JLabel sortLabel = new JLabel(PropertyFactory.getString("InfoResources.SortLabel")); //$NON-NLS-1$ private JComboBoxEx viewSortBox = new JComboBoxEx(); private JLabelPane followerInfo = new JLabelPane(); @@ -145,7 +148,6 @@ private JPanel botPane = new JPanel(); private JPanel followerPane = new JPanel(); private JPanel masterPane = new JPanel(); - private JPanel modePane = new JPanel(); private JPanel topPane = new JPanel(); private JTreeTable availableTable; // available table private JTreeTable selectedTable; // selected table @@ -153,7 +155,6 @@ private JTreeTableSorter selectedSort = null; private TreePath selPath; private boolean hasBeenSized = false; - private int viewMode = 0; private int viewSortMode = 0; private final JLabel lblQFilter = new JLabel(PropertyFactory.getString("InfoResources.FilterLabel")); //$NON-NLS-1$ @@ -166,25 +167,7 @@ private boolean readyForRefresh = false; private static final String TAB_ORDER_KEY = ".Panel.Resources.Order"; //$NON-NLS-1$ - - - private static final String HTML = "<html>"; //$NON-NLS-1$ - private static final String END_HTML = "</html>"; //$NON-NLS-1$ - private static final String FONT_PLUS_1 = "<font size=+1>"; //$NON-NLS-1$ - private static final String END_FONT = "</font>"; //$NON-NLS-1$ - private static final String PARA = "<p>"; //$NON-NLS-1$ - private static final String BOLD = "<b>"; //$NON-NLS-1$ - private static final String END_BOLD = "</b>"; //$NON-NLS-1$ - private static final String BR = "<br>"; //$NON-NLS-1$ - private static final String ITALIC = "<i>"; //$NON-NLS-1$ - private static final String END_ITALIC = "</i>"; //$NON-NLS-1$ - private static final String UL = "<ul>"; //$NON-NLS-1$ - private static final String END_UL = "</ul>"; //$NON-NLS-1$ - private static final String LI = "<li>"; //$NON-NLS-1$ - private static final String END_LI = "</li>"; //$NON-NLS-1$ - - /** * Constructor for the InfoResources object * @param aPC @@ -275,6 +258,27 @@ public List<String> getToDos() { List<String> toDoList = new ArrayList<String>(); + for ( String compType : Globals.getFollowerTypes() ) + { + // Check if we have a number set for this type + int maxVal = pc.getMaxFollowers( compType ); + if ( maxVal > 0 ) + { + for (Follower aF : pc.getFollowerList()) + { + if ( compType.equalsIgnoreCase(aF.getType()) ) + { + maxVal--; + } + } + + if ( maxVal > 0 ) + { + toDoList.add( PropertyFactory.getFormattedString( + "ToDo.InfoResources.AddFollower", compType, maxVal) ); //$NON-NLS-1$ + } + } + } return toDoList; } @@ -511,15 +515,16 @@ } TreePath avaCPath = availableTable.getTree().getSelectionPath(); - TreePath selCPath = selectedTable.getTree().getSelectionPath(); -// String target; + PObjectNode node = (PObjectNode)avaCPath.getParentPath().getLastPathComponent(); + TreePath selCPath = selectedTable.getTree().getNextMatch( node.getDisplayName(), 0, Bias.Forward ); if (selCPath == null) { ShowMessageDelegate.showMessageDialog(PropertyFactory.getString("InfoResources.DestinationFirst"), Constants.s_APPNAME, MessageType.ERROR); //$NON-NLS-1$ return; } + selectedTable.getTree().setSelectionPath( selCPath ); SelectedFollowerModel.FollowerType target = (SelectedFollowerModel.FollowerType)((PObjectNode)selCPath.getPathComponent(1)).getItem(); if ( target.getNumRemaining() < 1 ) { @@ -530,142 +535,127 @@ Object endComp = avaCPath.getLastPathComponent(); PObjectNode fNode = (PObjectNode) endComp; - // Different operations depending on the type of the object - if ((fNode.getItem() instanceof Race)) + final FollowerOption opt = (FollowerOption)fNode.getItem(); + if ( !opt.qualifies( pc ) ) { - // we are adding a familiar, animal companion, etc - Race aRace = (Race) fNode.getItem(); + return; + } + final Race race = opt.getRace(); - if (aRace == null) - { - return; - } + if (race == null) + { + return; + } - String nName; - String aType; + String nName; + String aType; - Logging.debugPrint("addButton:race: " + aRace.getDisplayName() + " -> " + target); //$NON-NLS-1$ //$NON-NLS-2$ + Logging.debugPrint("addButton:race: " + race.getDisplayName() + " -> " + target); //$NON-NLS-1$ //$NON-NLS-2$ - // first ask for the name of the new object - Object nValue = JOptionPane.showInputDialog(null, PropertyFactory.getFormattedString("InfoResources.EnterName", target), //$NON-NLS-1$ - Constants.s_APPNAME, JOptionPane.QUESTION_MESSAGE); + // first ask for the name of the new object + Object nValue = JOptionPane.showInputDialog(null, PropertyFactory.getFormattedString("InfoResources.EnterName", target), //$NON-NLS-1$ + Constants.s_APPNAME, JOptionPane.QUESTION_MESSAGE); - if (nValue != null) - { - nName = ((String) nValue).trim(); - } - else - { - return; - } + if (nValue != null) + { + nName = ((String) nValue).trim(); + } + else + { + return; + } - JFileChooser fc = new JFileChooser(); - fc.setDialogTitle(PropertyFactory.getFormattedString("InfoResources.SaveCaption", target, nName)); //$NON-NLS-1$ - fc.setSelectedFile(new File(SettingsHandler.getPcgPath(), nName + Constants.s_PCGEN_CHARACTER_EXTENSION)); - fc.setCurrentDirectory(SettingsHandler.getPcgPath()); + JFileChooser fc = new JFileChooser(); + fc.setDialogTitle(PropertyFactory.getFormattedString("InfoResources.SaveCaption", target, nName)); //$NON-NLS-1$ + fc.setSelectedFile(new File(SettingsHandler.getPcgPath(), nName + Constants.s_PCGEN_CHARACTER_EXTENSION)); + fc.setCurrentDirectory(SettingsHandler.getPcgPath()); - if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) - { - return; - } + if (fc.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) + { + return; + } - File file = fc.getSelectedFile(); + File file = fc.getSelectedFile(); - if (!PCGFile.isPCGenCharacterFile(file)) - { - file = new File(file.getParent(), file.getName() + Constants.s_PCGEN_CHARACTER_EXTENSION); - } + if (!PCGFile.isPCGenCharacterFile(file)) + { + file = new File(file.getParent(), file.getName() + Constants.s_PCGEN_CHARACTER_EXTENSION); + } - if (file.exists()) - { - int iConfirm = JOptionPane.showConfirmDialog(null, - PropertyFactory.getFormattedString("InfoSpells.confirm.overwrite", file.getName()), //$NON-NLS-1$ - PropertyFactory.getString("in_confirmOverwriteCaption"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ + if (file.exists()) + { + int iConfirm = JOptionPane.showConfirmDialog(null, + PropertyFactory.getFormattedString("InfoSpells.confirm.overwrite", file.getName()), //$NON-NLS-1$ + PropertyFactory.getString("in_confirmOverwriteCaption"), JOptionPane.YES_NO_OPTION); //$NON-NLS-1$ - if (iConfirm != JOptionPane.YES_OPTION) - { - return; - } - } - - PlayerCharacter newPC = new PlayerCharacter(); - newPC.setName(nName); - newPC.setFileName(file.getAbsolutePath()); - - for (Iterator<PCStat> i = newPC.getStatList().iterator(); i.hasNext();) + if (iConfirm != JOptionPane.YES_OPTION) { - final PCStat aStat = i.next(); - aStat.setBaseScore(10); + return; } + } - newPC.setAlignment(pc.getAlignment(), true, true); - newPC.setRace(aRace); + PlayerCharacter newPC = new PlayerCharacter(); + newPC.setName(nName); + newPC.setFileName(file.getAbsolutePath()); - if (newPC.getRace().hitDice(pc) != 0) - { - newPC.getRace().rollHP(pc); - } + for (Iterator<PCStat> i = newPC.getStatList().iterator(); i.hasNext();) + { + final PCStat aStat = i.next(); + aStat.setBaseScore(10); + } - newPC.setDirty(true); + newPC.setAlignment(pc.getAlignment(), true, true); + newPC.setRace(race); - aType = target.getType(); + if (newPC.getRace().hitDice(pc) != 0) + { + newPC.getRace().rollHP(pc); + } - Follower newMaster = new Follower(pc.getFileName(), pc.getName(), aType); - newPC.setMaster(newMaster); + newPC.setDirty(true); - Follower newFollower = new Follower(file.getAbsolutePath(), nName, aType); - newFollower.setRace(newPC.getRace().getKeyName()); - pc.addFollower(newFollower); - pc.setDirty(true); - pc.setCalcFollowerBonus(pc); - pc.setAggregateFeatsStable(false); - pc.setVirtualFeatsStable(false); + aType = target.getType(); - ShowMessageDelegate.showMessageDialog(PropertyFactory.getFormattedString("InfoResources.SaveAndSwitch", nName), //$NON-NLS-1$ - Constants.s_APPNAME, MessageType.INFORMATION); + final Follower newMaster = new Follower(pc.getFileName(), pc.getName(), aType); + newMaster.setAdjustment( opt.getAdjustment() ); + newPC.setMaster( newMaster ); - // save the new Follower to a file + final Follower newFollower = new Follower(file.getAbsolutePath(), nName, aType); + newFollower.setRace(newPC.getRace().getKeyName()); + pc.addFollower(newFollower); + pc.setDirty(true); + pc.setCalcFollowerBonus(pc); + pc.setAggregateFeatsStable(false); + pc.setVirtualFeatsStable(false); - try - { - (new PCGIOHandler()).write(newPC, file.getAbsolutePath()); - } - catch (Exception ex) - { - ShowMessageDelegate.showMessageDialog(PropertyFactory.getFormattedString("Errors.Save", newPC.getDisplayName()), //$NON-NLS-1$ - Constants.s_APPNAME, MessageType.ERROR); - Logging.errorPrint(PropertyFactory.getFormattedString("Errors.Save", newPC.getDisplayName()), ex); //$NON-NLS-1$ - return; - } + ShowMessageDelegate.showMessageDialog(PropertyFactory.getFormattedString("InfoResources.SaveAndSwitch", nName), //$NON-NLS-1$ + Constants.s_APPNAME, MessageType.INFORMATION); - // must force an Update before switching tabs - setNeedsUpdate(true); - pc.calcActiveBonuses(); + // save the new Follower to a file - // now load the new Follower from the file - // and switch tabs - PlayerCharacter loadedChar = PCGen_Frame1.getInst().loadPCFromFile(file); - loadedChar.calcActiveBonuses(); - CharacterInfo pane = PCGen_Frame1.getCharacterPane(); - pane.setPaneForUpdate(pane.infoSummary()); - pane.refresh(); + try + { + (new PCGIOHandler()).write(newPC, file.getAbsolutePath()); } - else if ((fNode.getItem() instanceof Equipment)) + catch (Exception ex) { - Equipment eqI = (Equipment) fNode.getItem(); + ShowMessageDelegate.showMessageDialog(PropertyFactory.getFormattedString("Errors.Save", newPC.getDisplayName()), //$NON-NLS-1$ + Constants.s_APPNAME, MessageType.ERROR); + Logging.errorPrint(PropertyFactory.getFormattedString("Errors.Save", newPC.getDisplayName()), ex); //$NON-NLS-1$ + return; + } - if (eqI == null) - { - return; - } + // must force an Update before switching tabs + setNeedsUpdate(true); + pc.calcActiveBonuses(); - Logging.errorPrint("addButton:item: " + eqI.getName() + " -> " + target); //$NON-NLS-1$//$NON-NLS-2$ - - // reset EquipSet model to get the new equipment - // added into the selectedTable tree - pc.setDirty(true); - updateSelectedModel(); - } + // now load the new Follower from the file + // and switch tabs + PlayerCharacter loadedChar = PCGen_Frame1.getInst().loadPCFromFile(file); + loadedChar.calcActiveBonuses(); + CharacterInfo pane = PCGen_Frame1.getCharacterPane(); + pane.setPaneForUpdate(pane.infoSummary()); + pane.refresh(); } private void addFileButton() @@ -691,7 +681,7 @@ String aType; File file = null; - file = findPCGFile(file); + file = findPCGFile(); if ((file == null) || !file.exists()) { @@ -924,13 +914,6 @@ centerSplit.setOneTouchExpandable(true); centerSplit.setDividerSize(10); - // first add a combobox to select mode to view - modePane.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); - modePane.add(modeLabel, null); - modePane.add(viewModeBox, null); - - masterPane.add(modePane, BorderLayout.NORTH); - // Now add centerSplit (which has top and bottom splits) masterPane.add(centerSplit, BorderLayout.CENTER); @@ -1000,7 +983,7 @@ { babAbbrev = "BAB"; //$NON-NLS-1$ } - b.append(BOLD).append(babAbbrev).append(END_BOLD).append(": "); //$NON-NLS-1$ //$NON-NLS-2$ + b.append(BOLD).append(babAbbrev).append(END_BOLD).append(": "); //$NON-NLS-1$ b.append((bonus >= 0) ? PropertyFactory.getString("in_plusSign") : "").append(bonus); //$NON-NLS-1$ //$NON-NLS-2$ b.append(BR); b.append(" ").append(BOLD).append(Globals.getGameModeHPAbbrev()).append(END_BOLD).append(": ").append(newPC.hitPoints()); //$NON-NLS-1$//$NON-NLS-2$ @@ -1056,10 +1039,19 @@ return; } + Race aRace = null; + FollowerOption option = null; if (obj instanceof Race) { - Race aRace = (Race) obj; - + aRace = (Race) obj; + } + else if ( obj instanceof FollowerOption ) + { + option = (FollowerOption)obj; + aRace = option.getRace(); + } + if ( aRace != null ) + { if (aRace.getKeyName().startsWith(Constants.s_NONESELECTED)) { return; @@ -1070,9 +1062,32 @@ b.append(HTML).append(FONT_PLUS_1).append(BOLD); b.append(aRace.getDisplayName()); b.append(END_BOLD).append(END_FONT); - b.append(" ").append(BOLD).append(PropertyFactory.getString("InfoResources.TypeLabel")).append(END_BOLD); //$NON-NLS-1$ //$NON-NLS-2$ - b.append(aRace.getType()); + b.append(": "); //$NON-NLS-1$ + final SizeAdjustment sadj = SettingsHandler.getGame().getSizeAdjustmentNamed(aRace.getSize()); + if ( sadj != null ) + { + b.append( sadj.getDisplayName() ); + } + b.append( " " ).append( aRace.getRaceType() ); //$NON-NLS-1$ + b.append( "; " ); //$NON-NLS-1$ + b.append( BOLD ); + b.append( PropertyFactory.getString( "in_hdLabel" ) ); //$NON-NLS-1$ + b.append( END_BOLD ); + b.append( ": " ); //$NON-NLS-1$ + b.append( aRace.hitDice(null, false) ); + b.append( "d" ); //$NON-NLS-1$ + b.append( aRace.getHitDiceSize( null, false ) ); + + if ( option != null ) + { + if ( option.preReqHTMLStrings(pc).length() > 0 ) + { + b.append( " " ).append(BOLD).append(PropertyFactory.getString("in_requirements")).append(END_BOLD).append(":"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + b.append( " " + option.preReqHTMLStrings(pc) ); //$NON-NLS-1$ + } + } + if (aRace.getMovement() != null) { bString = aRace.getMovement().toString(); } @@ -1083,14 +1098,6 @@ b.append(bString); } - bString = aRace.getSize(); - - if (bString.length() > 0) - { - b.append(" ").append(BOLD).append(PropertyFactory.getString("in_sumSize")).append(END_BOLD).append(": "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - b.append(bString); - } - bString = aRace.getSource(); if (bString.length() > 0) @@ -1374,10 +1381,9 @@ /** * Prompt the user to find the Followers .pcg file - * @param file * @return PCG File **/ - private File findPCGFile(File file) + private File findPCGFile() { JFileChooser fc = new JFileChooser(); fc.setDialogTitle(PropertyFactory.getString("InfoResources.FindFile")); //$NON-NLS-1$ @@ -1388,7 +1394,7 @@ return null; } - file = fc.getSelectedFile(); + final File file = fc.getSelectedFile(); if (file.exists() && file.canWrite()) { @@ -1561,14 +1567,6 @@ } }); */ - viewModeBox.addActionListener(new ActionListener() - { - public void actionPerformed(@SuppressWarnings("unused") - ActionEvent evt) - { - viewModeBoxActionPerformed(); - } - }); viewSortBox.addActionListener(new ActionListener() { public void actionPerformed(@SuppressWarnings("unused") @@ -1617,7 +1615,6 @@ * This method is called from within the constructor to * initialize the form. **/ - @SuppressWarnings("nls") private void initComponents() { readyForRefresh = true; @@ -1628,12 +1625,9 @@ // create tables associated with the above trees createTreeTables(); - Utility.setDescription(viewModeBox, PropertyFactory.getString("InfoResources.ChooseViewMode")); - - viewSortBox.addItem(PropertyFactory.getString("in_typeName") + " "); //$NON-NLS-1$//$NON-NLS-2$ viewSortBox.addItem(PropertyFactory.getString("in_nameLabel") + " "); //$NON-NLS-1$ //$NON-NLS-2$ - viewSortBox.addItem(PropertyFactory.getString("in_racetypeName") + " "); - Utility.setDescription(viewSortBox, "Sort Sort"); + viewSortBox.addIt... [truncated message content] |