Skip to content

Commit 9d0493c

Browse files
authored
Info export (#7319)
* support for INFO token export * Support CASTERLEVEL for PC * simplify code * Better support for .INFO. export * allow tag to start with .INFO. * SPELLMEM...DESC will now return the INFO.DESC value if it exists. The GUI for all objects will return the INFO.DESC value if it exists, otherwise the normal DESC value. * getInfoToken now on PlayerCharacter
1 parent 744ae72 commit 9d0493c

4 files changed

Lines changed: 32 additions & 25 deletions

File tree

code/src/java/pcgen/core/PlayerCharacter.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.awt.Rectangle;
1919
import java.math.BigDecimal;
20+
import java.text.MessageFormat;
2021
import java.util.ArrayList;
2122
import java.util.Arrays;
2223
import java.util.Collection;
@@ -8179,6 +8180,9 @@ public String getDescription(List<? extends Object> objList)
81798180
if (b instanceof PObject)
81808181
{
81818182
cdo = (PObject) b;
8183+
String dString = getInfoToken(".INFO.DESC", cdo);
8184+
if (!dString.equals(".INFO.DESC"))
8185+
return dString;
81828186
}
81838187
else if (b instanceof CNAbility)
81848188
{
@@ -8213,6 +8217,29 @@ else if (b instanceof CNAbility)
82138217
return sb.toString();
82148218
}
82158219

8220+
public String getInfoToken(String token, PObject po) {
8221+
// looking for a token in the form of RACE.INFO.TAG where
8222+
// RACE indicate which token map to check for a INFO label of TAG to return
8223+
int i = token.indexOf(".INFO.");
8224+
String ts = token;
8225+
if (i>-1)
8226+
ts = token.substring(i+6).toUpperCase();
8227+
else
8228+
return token;
8229+
Set<MapKey<?, ?>> keys = po.getMapKeys();
8230+
for (MapKey<?, ?> key : keys) {
8231+
Map<?, ?> key2 = po.getMapFor(key);
8232+
for(Object k : key2.keySet()) {
8233+
if (k.toString().equals(ts)) {
8234+
MessageFormat m = (MessageFormat) key2.get(k);
8235+
return m.toPattern();
8236+
}
8237+
}
8238+
}
8239+
return token;
8240+
}
8241+
8242+
82168243
/**
82178244
* This method gets the information about the levels at which classes and
82188245
* domains may cast the spell.

code/src/java/pcgen/io/ExportHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ else if (tokenString.indexOf(".INFO.")>-1) {
16161616
for (CDOMObject cd : plist) {
16171617
if (cd instanceof PObject) {
16181618
PObject po = (PObject) cd;
1619-
v = token.getInfoToken(tokenString, po);
1619+
v = aPC.getInfoToken(tokenString, po);
16201620
if (!v.equals(tokenString)) {
16211621
FileAccess.encodeWrite(output, v);
16221622
break;
@@ -1632,7 +1632,7 @@ else if (TOKEN_MAP.get(firstToken) != null)
16321632
{
16331633
Token token = TOKEN_MAP.get(firstToken);
16341634
if (tokenString.indexOf(".INFO.")>-1) {
1635-
FileAccess.encodeWrite(output, token.getInfoToken(tokenString, aPC.getDisplay().getRace()));
1635+
FileAccess.encodeWrite(output, aPC.getInfoToken(tokenString, aPC.getDisplay().getRace()));
16361636
}
16371637
else if (token.isEncoded())
16381638
{

code/src/java/pcgen/io/exporttoken/Token.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,26 +102,4 @@ protected static int getIntToken(String token, int defaultVal)
102102
}
103103
return retInt;
104104
}
105-
106-
public String getInfoToken(String token, PObject po) {
107-
// looking for a token in the form of RACE.INFO.TAG where
108-
// RACE indicate which token map to check for a INFO label of TAG to return
109-
int i = token.indexOf(".INFO.");
110-
String ts = token;
111-
if (i>-1)
112-
ts = token.substring(i+6).toUpperCase();
113-
else
114-
return token;
115-
Set<MapKey<?, ?>> keys = po.getMapKeys();
116-
for (MapKey<?, ?> key : keys) {
117-
Map<?, ?> key2 = po.getMapFor(key);
118-
for(Object k : key2.keySet()) {
119-
if (k.toString().equals(ts)) {
120-
MessageFormat m = (MessageFormat) key2.get(k);
121-
return m.toPattern();
122-
}
123-
}
124-
}
125-
return token;
126-
}
127105
}

code/src/java/plugin/exporttokens/SpellMemToken.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ else if ("DURATION".equals(aLabel))
258258
}
259259
else if ("DESC".equals(aLabel) || "EFFECT".equals(aLabel))
260260
{
261-
String mString = aPC.parseSpellString(selectedCSpell, aPC.getDescription(aSpell));
261+
String mString = aPC.getInfoToken(".INFO.DESC", aSpell);
262+
if (mString.equals(".INFO.DESC"))
263+
mString = aPC.parseSpellString(selectedCSpell, aPC.getDescription(aSpell));
262264
retValue.append(mString);
263265
}
264266
else if ("TARGET".equals(aLabel) || "EFFECTYPE".equals(aLabel))

0 commit comments

Comments
 (0)