20 package net.sf.gridarta.project;
23 import java.io.FileNotFoundException;
24 import java.io.IOException;
25 import java.net.URISyntaxException;
27 import java.util.Collections;
108 import net.
sf.japi.swing.action.ActionBuilder;
109 import net.
sf.japi.swing.action.ActionBuilderFactory;
110 import nu.xom.Document;
111 import nu.xom.ParsingException;
112 import nu.xom.xinclude.XIncludeException;
113 import org.apache.log4j.Category;
114 import org.apache.log4j.Logger;
115 import org.jetbrains.annotations.NotNull;
116 import org.jetbrains.annotations.Nullable;
117 import org.xml.sax.SAXException;
205 final int doubleFaceOffset = projectFactory.getDoubleFaceOffset();
252 return archetypeTypeSetParser.
loadTypesFromXML(typesErrorViewCollector, document);
253 }
catch (
final IOException | ParsingException | SAXException | URISyntaxException | XIncludeException ex) {
259 private static <G extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>>
void loadArchetypes(@NotNull
final ErrorView errorView, @NotNull
final ProjectSettings projectSettings, @NotNull
final ArchetypeSet<G, A, R> archetypeSet, @NotNull
final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull
final AbstractResources<G, A, R> resources, @NotNull
final ConfigSource configSource) {
260 final long timeStart = System.currentTimeMillis();
261 if (
LOG.isInfoEnabled()) {
262 LOG.info(
"Start to load archetypes...");
266 if (
LOG.isInfoEnabled()) {
267 LOG.info(
"Archetype loading took " + (System.currentTimeMillis() - timeStart) / 1000.0 +
" seconds.");
271 private static <G extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>>
void addArchetypes(@NotNull
final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull
final ArchetypeSet<G, A, R> archetypeSet) {
276 if (tmp.length == 2) {
277 final String panelName = tmp[0];
278 final String folderName = tmp[1];
291 }
catch (
final IOException ex) {
299 }
catch (
final IOException | ParsingException | SAXException | URISyntaxException | XIncludeException ex) {
318 private static <G extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>>
DelegatingMapValidator<G, A, R> loadValidators(@NotNull
final ErrorView errorView, @NotNull
final ProjectFactory<G, A, R> projectFactory, @NotNull
final ProjectSettings projectSettings, @NotNull
final GameObjectMatchers gameObjectMatchers, @NotNull
final ArchetypeTypeSet archetypeTypeSet, @NotNull
final ValidatorPreferences validatorPreferences, @NotNull
final MapWriter<G, A, R> mapWriter, @NotNull
final MapManager<G, A, R> mapManager) {
322 loadValidators(
validators, validatorFactory, errorView);
328 if (shopSquareMatcher !=
null) {
330 if (noSpellsMatcher !=
null) {
336 if (paidItemMatcher !=
null) {
337 validators.
addValidator(
new PaidItemShopSquareChecker<>(validatorPreferences, shopSquareMatcher, paidItemMatcher));
350 private static <G extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends Archetype<G, A, R>>
void loadValidators(@NotNull
final DelegatingMapValidator<G, A, R>
validators, @NotNull
final ValidatorFactory<G, A, R> validatorFactory, @NotNull
final ErrorView errorView) {
351 final ActionBuilder actionBuilder = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
354 final String spec = actionBuilder.getString(
"validator." +
id);
360 }
catch (
final NoSuchValidatorException ex) {
361 errorView.addWarning(ErrorViewCategory.MAP_VALIDATOR_ENTRY_INVALID,
id, ex.getMessage());
365 if (
LOG.isInfoEnabled()) {
366 LOG.info(
"Loaded " +
id +
" map validators.");
371 private static <G extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends Archetype<G, A, R>> Spells<GameObjectSpell<G, A, R>> loadArchetypeSpells(
final int spellType, @NotNull
final GameObjectFactory<G, A, R>
gameObjectFactory, @NotNull
final ArchetypeSet<G, A, R>
archetypeSet) {
373 if (spellType != 0) {
383 if (spellFile ==
null) {
392 }
catch (
final IOException | ParsingException | SAXException | URISyntaxException | XIncludeException ex) {
401 Map<String, TreasureTreeNode> specialTreasureLists;
408 }
catch (
final IOException | ParsingException | SAXException | URISyntaxException | XIncludeException ex) {
410 specialTreasureLists = Collections.emptyMap();
412 }
catch (
final FileNotFoundException ex) {
414 specialTreasureLists = Collections.emptyMap();
416 return specialTreasureLists;
555 return pluginParameters;