Skip to content

Commit f095ee4

Browse files
authored
support for INFO token export (#7311)
1 parent ca4a62b commit f095ee4

3 files changed

Lines changed: 37 additions & 6 deletions

File tree

code/src/java/pcgen/core/GameMode.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,11 +1966,14 @@ static <T extends Loadable> void resolveReferenceManufacturer(AbstractReferenceC
19661966
Class<T> cl = rm.getReferenceClass();
19671967
mfg = rc.getManufacturer(cl);
19681968
}
1969-
for (CDOMReference<T> ref : rm.getAllReferences())
1970-
{
1971-
((TransparentReference<T>) ref).resolve(mfg);
1969+
if (mfg!=null) {
1970+
for (CDOMReference<T> ref : rm.getAllReferences()) {
1971+
((TransparentReference<T>) ref).resolve(mfg);
1972+
}
1973+
rm.injectConstructed(mfg);
19721974
}
1973-
rm.injectConstructed(mfg);
1975+
else
1976+
System.out.println("idname="+identityName+" had a null mfg - skipping");
19741977
}
19751978

19761979
public LoadContext getContext()

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,10 @@ else if (tokenString.startsWith("CSHEETTAG2."))
16191619
else if (TOKEN_MAP.get(firstToken) != null)
16201620
{
16211621
Token token = TOKEN_MAP.get(firstToken);
1622-
if (token.isEncoded())
1622+
if (tokenString.indexOf(".INFO.")>-1) {
1623+
FileAccess.encodeWrite(output, token.getInfoToken(tokenString, aPC.getDisplay().getRace()));
1624+
}
1625+
else if (token.isEncoded())
16231626
{
16241627
FileAccess.encodeWrite(output, token.getToken(tokenString, aPC, this));
16251628
}

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
*/
2121
package pcgen.io.exporttoken;
2222

23-
import java.util.StringTokenizer;
23+
import java.text.MessageFormat;
24+
import java.util.*;
2425

26+
import pcgen.cdom.enumeration.MapKey;
27+
import pcgen.core.PObject;
2528
import pcgen.core.PlayerCharacter;
2629
import pcgen.io.ExportHandler;
2730

@@ -99,4 +102,26 @@ protected static int getIntToken(String token, int defaultVal)
99102
}
100103
return retInt;
101104
}
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>0)
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+
}
102127
}

0 commit comments

Comments
 (0)