Search in sources :

Example 1 with UnreachableError

use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.

the class GameModeFileLoader method loadGameModes.

private void loadGameModes(String[] gameFiles) {
    SystemCollections.clearGameModeList();
    File gameModeDir = new File(ConfigurationSettings.getSystemsDir(), "gameModes");
    int progress = 0;
    for (final String gameFile : gameFiles) {
        File specGameModeDir = new File(gameModeDir, gameFile);
        File miscInfoFile = new File(specGameModeDir, "miscinfo.lst");
        final GameMode gm = GameModeFileLoader.loadGameModeMiscInfo(gameFile, miscInfoFile.toURI());
        if (gm != null) {
            String gmName = gm.getName();
            //SettingsHandler.setGame(gmName);
            LoadContext context = gm.getModeContext();
            loadGameModeInfoFile(gm, new File(specGameModeDir, "level.lst").toURI(), "level");
            loadGameModeInfoFile(gm, new File(specGameModeDir, "rules.lst").toURI(), "rules");
            // Load equipmentslot.lst
            GameModeFileLoader.loadGameModeLstFile(context, eqSlotLoader, gmName, gameFile, "equipmentslots.lst");
            // Load paperInfo.lst
            GameModeFileLoader.loadGameModeLstFile(context, paperLoader, gmName, gameFile, "paperInfo.lst");
            // Load bio files
            GameModeFileLoader.loadGameModeLstFile(context, traitLoader, gmName, gameFile, "bio" + File.separator + "traits.lst");
            GameModeFileLoader.loadGameModeLstFile(context, locationLoader, gmName, gameFile, "bio" + File.separator + "locations.lst");
            // Load load.lst and check for completeness
            GameModeFileLoader.loadGameModeLstFile(context, loadInfoLoader, gmName, gameFile, "load.lst");
            // Load sizeAdjustment.lst
            GameModeFileLoader.loadGameModeLstFile(context, sizeLoader, gmName, gameFile, "sizeAdjustment.lst");
            // Load statsandchecks.lst
            GameModeFileLoader.loadGameModeLstFile(context, statCheckLoader, gmName, gameFile, "statsandchecks.lst");
            // Load equipIcons.lst
            GameModeFileLoader.loadGameModeLstFile(context, equipIconLoader, gmName, gameFile, "equipIcons.lst");
            GameModeFileLoader.loadGameModeLstFile(context, codeControlLoader, gmName, gameFile, "codeControl.lst");
            // Load pointbuymethods.lst
            loadPointBuyFile(context, gameFile, gmName);
            for (final PointBuyCost pbc : context.getReferenceContext().getConstructedCDOMObjects(PointBuyCost.class)) {
                gm.addPointBuyStatCost(pbc);
            }
            // Load migration.lst
            GameModeFileLoader.loadGameModeLstFile(context, migrationLoader, gmName, gameFile, "migration.lst");
            GameModeFileLoader.loadGameModeLstFile(context, bioLoader, gmName, gameFile, "bio" + File.separator + "biosettings.lst");
        }
        try {
            GameModeFileLoader.addDefaultWieldCategories(gm.getModeContext());
        } catch (final PersistenceLayerException ple) {
            Logging.errorPrint("Error Initializing PreParserFactory");
            Logging.errorPrint("  " + ple.getMessage(), ple);
            throw new UnreachableError();
        }
        progress++;
        setProgress(progress);
    }
    SystemCollections.sortGameModeList();
}
Also used : GameMode(pcgen.core.GameMode) LoadContext(pcgen.rules.context.LoadContext) PointBuyCost(pcgen.core.PointBuyCost) UnreachableError(pcgen.base.lang.UnreachableError) File(java.io.File)

Example 2 with UnreachableError

use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.

the class AssociationKey method buildMap.

private static void buildMap() {
    map = new CaseInsensitiveMap<>();
    Field[] fields = AssociationKey.class.getDeclaredFields();
    for (int i = 0; i < fields.length; i++) {
        int mod = fields[i].getModifiers();
        if (Modifier.isStatic(mod) && Modifier.isFinal(mod) && Modifier.isPublic(mod)) {
            try {
                Object obj = fields[i].get(null);
                if (obj instanceof AssociationKey) {
                    map.put(fields[i].getName(), (AssociationKey<?>) obj);
                }
            } catch (IllegalArgumentException | IllegalAccessException e) {
                throw new UnreachableError(e);
            }
        }
    }
}
Also used : Field(java.lang.reflect.Field) CDOMObject(pcgen.cdom.base.CDOMObject) UnreachableError(pcgen.base.lang.UnreachableError)

Example 3 with UnreachableError

use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.

the class ObjectKey method buildMap.

private static void buildMap() {
    map = new CaseInsensitiveMap<>();
    Field[] fields = ObjectKey.class.getDeclaredFields();
    for (int i = 0; i < fields.length; i++) {
        int mod = fields[i].getModifiers();
        if (java.lang.reflect.Modifier.isStatic(mod) && java.lang.reflect.Modifier.isFinal(mod) && java.lang.reflect.Modifier.isPublic(mod)) {
            try {
                Object obj = fields[i].get(null);
                if (obj instanceof ObjectKey) {
                    map.put(fields[i].getName(), (ObjectKey<?>) obj);
                }
            } catch (IllegalArgumentException | IllegalAccessException e) {
                throw new UnreachableError(e);
            }
        }
    }
}
Also used : Field(java.lang.reflect.Field) CDOMListObject(pcgen.cdom.base.CDOMListObject) QualifiedObject(pcgen.core.QualifiedObject) UnreachableError(pcgen.base.lang.UnreachableError)

Example 4 with UnreachableError

use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.

the class InfoPane method setText.

public void setText(String text) {
    //This is done so the vertical scroll bar goes back up to the top when the text is changed
    EditorKit kit = textPane.getEditorKit();
    Document newDoc = kit.createDefaultDocument();
    try {
        kit.read(new StringReader(text), newDoc, 0);
    } catch (IOException | BadLocationException ex) {
        throw new UnreachableError(ex);
    }
    textPane.setDocument(newDoc);
}
Also used : EditorKit(javax.swing.text.EditorKit) StringReader(java.io.StringReader) IOException(java.io.IOException) UnreachableError(pcgen.base.lang.UnreachableError) Document(javax.swing.text.Document) BadLocationException(javax.swing.text.BadLocationException)

Example 5 with UnreachableError

use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.

the class TokenFamily method buildMap.

/**
	 * Actually build the set of Constants, using any "public static final"
	 * constants within the child (extending) class as initial values in the
	 * Constant pool.
	 */
private static void buildMap() {
    typeMap = new TreeMap<>();
    Class<TokenFamily> cl = TokenFamily.class;
    Field[] fields = cl.getDeclaredFields();
    for (int i = 0; i < fields.length; i++) {
        int mod = fields[i].getModifiers();
        if (Modifier.isStatic(mod) && Modifier.isFinal(mod) && Modifier.isPublic(mod)) {
            try {
                Object o = fields[i].get(null);
                if (cl.equals(o.getClass())) {
                    TokenFamily tObj = cl.cast(o);
                    if (typeMap.containsKey(tObj.rev)) {
                        throw new UnreachableError("Attempt to redefine constant value " + tObj.rev + " to " + fields[i].getName() + ", value was " + typeMap.get(tObj.rev));
                    }
                    typeMap.put(tObj.rev, tObj);
                }
            } catch (IllegalArgumentException e) {
                throw new UnreachableError("Attempt to fetch field failed: " + e.getMessage());
            } catch (IllegalAccessException e) {
                throw new UnreachableError("Attempt to fetch field failed for access: " + e.getMessage());
            }
        }
    }
}
Also used : Field(java.lang.reflect.Field) UnreachableError(pcgen.base.lang.UnreachableError)

Aggregations

UnreachableError (pcgen.base.lang.UnreachableError)39 URI (java.net.URI)23 URISyntaxException (java.net.URISyntaxException)23 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)19 LoadContext (pcgen.rules.context.LoadContext)14 Field (java.lang.reflect.Field)9 Ability (pcgen.core.Ability)9 Campaign (pcgen.core.Campaign)9 CDOMReference (pcgen.cdom.base.CDOMReference)7 AbilityList (pcgen.cdom.list.AbilityList)6 CNAbility (pcgen.cdom.content.CNAbility)5 PlayerCharacter (pcgen.core.PlayerCharacter)4 FeatLoader (pcgen.persistence.lst.FeatLoader)4 ArrayList (java.util.ArrayList)3 PCClass (pcgen.core.PCClass)3 PCTemplate (pcgen.core.PCTemplate)3 QualifiedObject (pcgen.core.QualifiedObject)3 AbilityLoader (pcgen.persistence.lst.AbilityLoader)3 GenericLoader (pcgen.persistence.lst.GenericLoader)3 PCClassLoader (pcgen.persistence.lst.PCClassLoader)3