|
From: <boo...@us...> - 2006-10-09 04:02:19
|
Revision: 1459
http://svn.sourceforge.net/pcgen/?rev=1459&view=rev
Author: boomer70
Date: 2006-10-08 21:02:08 -0700 (Sun, 08 Oct 2006)
Log Message:
-----------
Ability object fixes.
Modified Paths:
--------------
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/chooser/AbstractComplexChoiceManager.java
Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties
Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbility.java
Modified: Trunk/pcgen/code/src/java/pcgen/core/Globals.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-10-09 02:54:13 UTC (rev 1458)
+++ Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2006-10-09 04:02:08 UTC (rev 1459)
@@ -2792,7 +2792,11 @@
if (stringsInList)
{
Collections.sort(availableList);
- Collections.sort(selectedList);
+ // NOCHOICE feats add nulls to the selectedList
+ if ( selectedList.get(0) != null )
+ {
+ Collections.sort(selectedList);
+ }
}
else
{
Modified: Trunk/pcgen/code/src/java/pcgen/core/PObject.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-10-09 02:54:13 UTC (rev 1458)
+++ Trunk/pcgen/code/src/java/pcgen/core/PObject.java 2006-10-09 04:02:08 UTC (rev 1459)
@@ -39,6 +39,8 @@
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import pcgen.core.bonus.Bonus;
import pcgen.core.bonus.BonusObj;
@@ -154,6 +156,8 @@
private Map<AbilityCategory, List<Ability>> theVirtualAbilities = null;
+ private List<Description> theDescriptions = null;
+
/* ************
* Methods
* ************/
@@ -186,17 +190,18 @@
*/
public final String getAssociated(int idx, final boolean expand)
{
- if (associatedList == null) {
+ if (associatedList == null)
+ {
return Constants.EMPTY_STRING;
}
if (expand)
{
int currentCount = 0;
- for ( AssociatedChoice<String> choice : associatedList )
+ for ( final AssociatedChoice<String> choice : associatedList )
{
final int choiceInd = choice.size() - 1;
- if ( currentCount + choiceInd <= idx )
+ if ( idx <= (currentCount + choiceInd) )
{
if ( choiceInd == 0 )
{
@@ -375,25 +380,100 @@
return descIsPI;
}
+// /**
+// * Set the description of this object
+// * @param a
+// */
+// public final void setDescription(final String a)
+// {
+// stringChar.put(StringKey.DESCRIPTION, a);
+// }
+
/**
- * Set the description of this object
- * @param a
+ * Adds a description for this object. Multiple descriptions are allowed
+ * and will be concatonated on output.
+ *
+ * <p>The format of the description tag
+ * @param aDesc
*/
- public final void setDescription(final String a)
+ public void addDescription( final Description aDesc )
{
- stringChar.put(StringKey.DESCRIPTION, a);
+ if ( theDescriptions == null )
+ {
+ theDescriptions = new ArrayList<Description>();
+ }
+ theDescriptions.add( aDesc );
}
+
+ /**
+ * Clears all current descriptions for the object.
+ */
+ public void removeAllDescriptions()
+ {
+ theDescriptions = null;
+ }
+
+ /**
+ * Removes <tt>Description</tt>s who's PCC Text matches the pattern
+ * specified.
+ *
+ * @param aDescPattern The regular expression to search for.
+ */
+ public void removeDescription( final String aDescPattern )
+ {
+ if ( theDescriptions == null )
+ {
+ return;
+ }
+ final Pattern pattern = Pattern.compile(aDescPattern);
+ for ( final Iterator<Description> i = theDescriptions.iterator(); i.hasNext(); )
+ {
+ final String descText = i.next().getPCCText();
+ final Matcher matcher = pattern.matcher(descText);
+ if ( matcher.find() )
+// if ( descText.matches(aDescPattern) )
+ {
+ i.remove();
+ }
+ }
+ }
+
/**
* Get the description of this object
+ *
+ * @param aPC The PlayerCharacter this object is associated to.
* @return the description of this object
*/
- public final String getDescription()
+ public String getDescription(final PlayerCharacter aPC)
{
- String characteristic = stringChar.get(StringKey.DESCRIPTION);
- return characteristic == null ? Constants.EMPTY_STRING : characteristic;
+ if ( theDescriptions == null )
+ {
+ return Constants.EMPTY_STRING;
+ }
+ final StringBuffer buf = new StringBuffer();
+ boolean firstTime = true;
+ for ( final Description desc : theDescriptions )
+ {
+ if ( !firstTime )
+ {
+ buf.append(Constants.COMMA);
+ }
+ buf.append(desc.getDescription(aPC));
+ firstTime = false;
+ }
+ return buf.toString();
}
+ public List<Description> getDescriptionList()
+ {
+ if ( theDescriptions == null )
+ {
+ return Collections.emptyList();
+ }
+ return Collections.unmodifiableList(theDescriptions);
+ }
+
/**
* Get the plugin data for this object
* @param key
@@ -853,7 +933,15 @@
{
for ( AssociatedChoice<String> choice : associatedList )
{
- choices.add( choice.getDefaultChoice() );
+ final String choiceStr = choice.getDefaultChoice();
+ if ( choiceStr.equals(Constants.EMPTY_STRING) )
+ {
+ choices.add(null);
+ }
+ else
+ {
+ choices.add( choice.getDefaultChoice() );
+ }
}
}
}
@@ -2589,9 +2677,9 @@
* Get the Product Identity description String
* @return the Product Identity description String
*/
- public String piDescString()
+ public String piDescString(final PlayerCharacter aPC)
{
- return piDescString(true);
+ return piDescString(aPC, true);
}
/**
@@ -2599,9 +2687,9 @@
* pre-existing <html> tag
* @return PI description
*/
- public String piDescSubString()
+ public String piDescSubString(final PlayerCharacter aPC)
{
- return piDescString(false);
+ return piDescString(aPC, false);
}
/**
@@ -2742,12 +2830,10 @@
txt.append("\tOUTPUTNAME:").append(outputName);
}
- aString = getDescription();
-
- if (aString.length() != 0)
+ for ( final Description desc : getDescriptionList() )
{
- txt.append("\tDESC:").append(pcgen.io.EntityEncoder.encode(aString));
-
+ txt.append("\tDESC:").append(pcgen.io.EntityEncoder.encode(desc.getPCCText()));
+
if (getDescIsPI())
{
txt.append("\tDESCISPI:Yes");
@@ -3596,25 +3682,20 @@
listChar.removeListFor(ListKey.SELECTED_WEAPON_PROF_BONUS);
}
- private String piDescString(final boolean useHeader)
+ private String piDescString(final PlayerCharacter aPC, final boolean useHeader)
{
- String aString = stringChar.get(StringKey.DESCRIPTION);
+ final String desc = getDescription(aPC);
- if (this instanceof Ability)
- {
- aString = ((Ability) this).getBenefitDescription();
- }
-
if (descIsPI)
{
- final StringBuffer sb = new StringBuffer(aString.length() + 30);
+ final StringBuffer sb = new StringBuffer(desc.length() + 30);
if (useHeader)
{
sb.append("<html>");
}
- sb.append("<b><i>").append(aString).append("</i></b>");
+ sb.append("<b><i>").append(desc).append("</i></b>");
if (useHeader)
{
@@ -3624,7 +3705,7 @@
return sb.toString();
}
- return aString;
+ return desc;
}
/**
Modified: Trunk/pcgen/code/src/java/pcgen/core/chooser/AbstractComplexChoiceManager.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/core/chooser/AbstractComplexChoiceManager.java 2006-10-09 02:54:13 UTC (rev 1458)
+++ Trunk/pcgen/code/src/java/pcgen/core/chooser/AbstractComplexChoiceManager.java 2006-10-09 04:02:08 UTC (rev 1459)
@@ -339,6 +339,10 @@
}
associateChoice(aPC, strChoice, objPrefix);
}
+ else
+ {
+ pobject.addAssociated(Constants.EMPTY_STRING);
+ }
}
adjustFeats(aPC, selected);
Modified: Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-10-09 02:54:13 UTC (rev 1458)
+++ Trunk/pcgen/code/src/java/pcgen/gui/prop/LanguageBundle.properties 2006-10-09 04:02:08 UTC (rev 1459)
@@ -3224,22 +3224,22 @@
# 0 - File name
# 1 - Error msg
-Errors.LstFileLoader.LoadError=Unable to load the file '{0}': {1}
+Errors.LstFileLoader.LoadError=Unable to load the file {0}: {1}
# 0 - File name
# 1 - Line number
# 2 - Error msg
-Errors.LstFileLoader.ParseError=Error parsing file '{0}' line '{1}': {2}
+Errors.LstFileLoader.ParseError=Error parsing file {0} line {1}: {2}
Errors.LstFileLoader.Ignoring=Ignoring error:
# 0 - PObject key
-Errors.LstFileLoader.CopyObjectNotFound=PObject '{0}' not found; .COPY skipped.
+Errors.LstFileLoader.CopyObjectNotFound=PObject {0} not found; .COPY skipped.
# 0 - Class of object
# 1 - Key of original object
# 2 - Key of new object
-Errors.LstFileLoader.CopyNotSupported={0} clone error; .COPY of '{1}' to '{2}' skipped.
+Errors.LstFileLoader.CopyNotSupported={0} clone error; .COPY of {1} to {2} skipped.
# 0 - File name
# 1 - Line number
@@ -3317,3 +3317,6 @@
SpellModel.SR=SR
SpellModel.PPCost=PP Cost
SpellModel.24=level
+
+Errors.Description.InvalidVariableReplacement=Description contains an invalid variable placeholder: {0}
+
Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbility.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbility.java 2006-10-09 02:54:13 UTC (rev 1458)
+++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/InfoAbility.java 2006-10-09 04:02:08 UTC (rev 1459)
@@ -306,9 +306,18 @@
PCGen_Frame1.setMessageAreaTextWithoutSaving(PropertyFactory.getString(
"InfoAbility.StatusLine.Info")); //$NON-NLS-1$
- theAvailablePane.setPC(getPc());
- theSelectedPane.setPC(getPc());
- theInfoPanel.setPC(getPc());
+ if ( theAvailablePane != null )
+ {
+ theAvailablePane.setPC(getPc());
+ }
+ if ( theSelectedPane != null )
+ {
+ theSelectedPane.setPC(getPc());
+ }
+ if ( theInfoPanel != null )
+ {
+ theInfoPanel.setPC(getPc());
+ }
if ( thePoolPanel != null )
{
thePoolPanel.setPC(getPc());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|