Gridarta Editor
ProjectModel.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.project;
21 
22 import java.io.File;
23 import java.io.FileNotFoundException;
24 import java.io.IOException;
25 import java.net.URISyntaxException;
26 import java.net.URL;
27 import java.util.Collections;
28 import java.util.Map;
104 import net.sf.gridarta.utils.IOUtils;
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;
118 
122 public class ProjectModel<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> {
123 
127  @NotNull
128  private static final Category LOG = Logger.getLogger(ProjectModel.class);
129 
130  @NotNull
132 
133  @NotNull
135 
136  @NotNull
138 
139  @NotNull
141 
142  @NotNull
144 
145  @NotNull
147 
148  @NotNull
150 
151  @NotNull
152  private final SmoothFaces smoothFaces;
153 
154  @NotNull
156 
157  @NotNull
158  private final File scriptsFile;
159 
160  @NotNull
162 
163  @NotNull
165 
166  @NotNull
168 
169  @NotNull
171 
172  @NotNull
174 
175  @NotNull
177 
178  @NotNull
179  private final FaceObjects faceObjects;
180 
181  @NotNull
183 
184  @NotNull
186 
187  @NotNull
189 
190  @NotNull
192 
193  @NotNull
195 
196  @NotNull
197  private final TreasureTree treasureTree;
198 
199  @NotNull
200  private final PathManager pathManager;
201 
202  @NotNull
204 
205  public ProjectModel(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ProjectFactory<G, A, R> projectFactory, @NotNull final ResourceIcons resourceIcons, @NotNull final ConfigSource configSource) {
206  this.projectSettings = projectSettings;
207  archetypeTypeSet = loadArchetypeTypeSet(errorView, projectSettings);
208  final int doubleFaceOffset = projectFactory.getDoubleFaceOffset();
209  faceObjects = new DefaultFaceObjects(projectFactory.getIncludeFaceNumbers());
210  smoothFaces = new SmoothFaces(faceObjects);
211  faceObjectProviders = new FaceObjectProviders(doubleFaceOffset, faceObjects, resourceIcons);
212  animationObjects = new DefaultAnimationObjects();
213  final ArchetypeFactory<G, A, R> archetypeFactory = projectFactory.newArchetypeFactory(faceObjectProviders, animationObjects);
214  gameObjectFactory = projectFactory.newGameObjectFactory(faceObjectProviders, animationObjects, archetypeTypeSet);
215  archetypeSet = projectFactory.newArchetypeSet(projectSettings, archetypeFactory);
216  final GameObjectParserFactory<G, A, R> gameObjectParserFactory = projectFactory.newGameObjectParserFactory(gameObjectFactory, archetypeSet, archetypeTypeSet);
217  gameObjectParser = gameObjectParserFactory.newGameObjectParser();
218  final AbstractArchetypeParser<G, A, R, ?> archetypeParser = projectFactory.newArchetypeParser(errorView, gameObjectParser, animationObjects, archetypeSet, gameObjectFactory, projectSettings, smoothFaces);
219  final ArchFaceProvider archFaceProvider = new ArchFaceProvider();
220  resources = projectFactory.newResources(gameObjectParser, archetypeSet, archetypeParser, faceObjects, animationObjects, archFaceProvider, faceObjectProviders, smoothFaces);
221  loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource);
222  faceObjectProviders.addFaceObjectProvidersListener(archetypeSet::connectFaces);
223  final MapArchObjectParserFactory<A> mapArchObjectParserFactory = projectFactory.newMapArchObjectParserFactory();
224  mapArchObjectFactory = projectFactory.newMapArchObjectFactory(projectSettings);
225  mapReaderFactory = new DefaultMapReaderFactory<>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory);
226  final MapWriter<G, A, R> mapWriter = new DefaultMapWriter<>(mapArchObjectParserFactory, gameObjectParser);
227  final ValidatorPreferences validatorPreferences = new DefaultValidatorPreferences();
228  gameObjectMatchers = loadGameObjectMatchers(errorView, projectSettings);
229  validators = loadValidators(errorView, projectFactory, projectSettings, gameObjectMatchers, archetypeTypeSet, validatorPreferences, mapWriter);
230  final AutojoinLists<G, A, R> autojoinLists = AutojoinListsParser.loadList(errorView, archetypeSet, projectSettings.getConfigurationDirectory());
232  final MapControlFactory<G, A, R> mapControlFactory = projectFactory.newMapControlFactory(mapWriter, projectSettings, mapModelFactory);
233  pathManager = new PathManager(projectSettings);
235  pickmapManager = new DefaultPickmapManager<>(mapReaderFactory, mapControlFactory, projectSettings, faceObjectProviders, pathManager);
236  gameObjectSpells = loadArchetypeSpells(projectFactory.getSpellType(), gameObjectFactory, archetypeSet);
237  numberSpells = loadSpellFile(projectFactory.getSpellFile(), errorView, projectSettings);
238  scriptsFile = new File(projectSettings.getMapsDirectory(), projectFactory.getScriptsDir());
239  final Map<String, TreasureTreeNode> specialTreasureLists = loadSpecialTreasureLists(errorView, projectSettings);
240  treasureTree = TreasureLoader.parseTreasures(errorView, specialTreasureLists, configSource, projectSettings);
242  final PluginModelParser<G, A, R> pluginModelParser = new PluginModelParser<>(pluginParameterFactory);
243  pluginModel = PluginModelLoader.loadPlugins(pluginParameterFactory, pluginModelParser, errorView, scriptsFile);
244  }
245 
246  @NotNull
247  private static ArchetypeTypeSet loadArchetypeTypeSet(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings) {
248  final ArchetypeAttributeFactory archetypeAttributeFactory = new DefaultArchetypeAttributeFactory();
249  final ArchetypeAttributeParser archetypeAttributeParser = new ArchetypeAttributeParser(archetypeAttributeFactory);
250  final ArchetypeTypeParser archetypeTypeParser = new ArchetypeTypeParser(archetypeAttributeParser);
251  try {
252  final URL url = IOUtils.getResource(projectSettings.getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE);
253  final ErrorViewCollector typesErrorViewCollector = new ErrorViewCollector(errorView, url);
254  final Document document = ParseUtils.readXmlUrl(url, "types", "types.dtd", "/system/dtd/types.dtd", new ErrorViewCollectorErrorHandler(typesErrorViewCollector, ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID));
255  final ArchetypeTypeSetParser archetypeTypeSetParser = new ArchetypeTypeSetParser(archetypeTypeParser);
256  return archetypeTypeSetParser.loadTypesFromXML(typesErrorViewCollector, document);
257  } catch (final IOException ex) {
258  errorView.addWarning(ErrorViewCategory.TYPES_FILE_INVALID, CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage());
259  } catch (final ParsingException ex) {
260  errorView.addWarning(ErrorViewCategory.TYPES_FILE_INVALID, CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage());
261  } catch (final SAXException ex) {
262  errorView.addWarning(ErrorViewCategory.TYPES_FILE_INVALID, CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage());
263  } catch (final URISyntaxException ex) {
264  errorView.addWarning(ErrorViewCategory.TYPES_FILE_INVALID, CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage());
265  } catch (final XIncludeException ex) {
266  errorView.addWarning(ErrorViewCategory.TYPES_FILE_INVALID, CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage());
267  }
268  return new ArchetypeTypeSet();
269  }
270 
271  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) {
272  final long timeStart = System.currentTimeMillis();
273  if (LOG.isInfoEnabled()) {
274  LOG.info("Start to load archetypes...");
275  }
276  configSource.read(projectSettings, resources, errorView);
277  addArchetypes(archetypeChooserModel, archetypeSet);
278  if (LOG.isInfoEnabled()) {
279  LOG.info("Archetype loading took " + (double) (System.currentTimeMillis() - timeStart) / 1000.0 + " seconds.");
280  }
281  }
282 
283  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) {
284  for (final R archetype : archetypeSet.getArchetypes()) {
285  final CharSequence editorFolder = archetype.getEditorFolder();
286  if (editorFolder != null && !editorFolder.equals(GameObject.EDITOR_FOLDER_INTERN)) {
287  final String[] tmp = StringUtils.PATTERN_SLASH.split(editorFolder, 2);
288  if (tmp.length == 2) {
289  final String panelName = tmp[0];
290  final String folderName = tmp[1];
291  archetypeChooserModel.addArchetype(panelName, folderName, archetype);
292  }
293  }
294  }
295  }
296 
297  @NotNull
298  public static GameObjectMatchers loadGameObjectMatchers(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings) {
299  final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers();
300  final URL url;
301  try {
302  url = IOUtils.getResource(projectSettings.getConfigurationDirectory(), "GameObjectMatchers.xml");
303  } catch (final IOException ex) {
304  errorView.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, "GameObjectMatchers.xml: " + ex.getMessage());
305  return gameObjectMatchers;
306  }
307  final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, url);
308  try {
309  final Document document = ParseUtils.readXmlUrl(url, "GameObjectMatchers", "GameObjectMatchers.dtd", "/system/dtd/GameObjectMatchers.dtd", new ErrorViewCollectorErrorHandler(gameObjectMatchersErrorViewCollector, ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID));
310  GameObjectMatchersParser.readGameObjectMatchers(document, gameObjectMatchers, gameObjectMatchersErrorViewCollector);
311  } catch (final IOException ex) {
312  gameObjectMatchersErrorViewCollector.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, ex.getMessage());
313  } catch (final ParsingException ex) {
314  gameObjectMatchersErrorViewCollector.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, ex.getMessage());
315  } catch (final SAXException ex) {
316  gameObjectMatchersErrorViewCollector.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, ex.getMessage());
317  } catch (final URISyntaxException ex) {
318  gameObjectMatchersErrorViewCollector.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, ex.getMessage());
319  } catch (final XIncludeException ex) {
320  gameObjectMatchersErrorViewCollector.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, ex.getMessage());
321  }
322  return gameObjectMatchers;
323  }
324 
336  @NotNull
337  public 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) {
338  final DelegatingMapValidator<G, A, R> validators = new DelegatingMapValidator<>(validatorPreferences);
339  final EnvironmentChecker<G, A, R> environmentChecker = new EnvironmentChecker<>(validatorPreferences);
340  final ValidatorFactory<G, A, R> validatorFactory = new ValidatorFactory<>(validatorPreferences, gameObjectMatchers, projectSettings, mapWriter);
341  loadValidators(validators, validatorFactory, errorView);
342  final AttributeRangeChecker<G, A, R> attributeRangeChecker = projectFactory.loadAttributeRangeChecker(new ErrorViewCollector(errorView, new File("GameObjectMatchers.xml")), gameObjectMatchers, validatorPreferences);
343  validators.addValidator(attributeRangeChecker);
344  validators.addValidator(environmentChecker);
345  ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker);
346  final GameObjectMatcher shopSquareMatcher = gameObjectMatchers.getMatcher("system_shop_square", "shop_square");
347  if (shopSquareMatcher != null) {
348  final GameObjectMatcher noSpellsMatcher = gameObjectMatchers.getMatcher("system_no_spells", "no_spells");
349  if (noSpellsMatcher != null) {
350  final GameObjectMatcher blockedMatcher = gameObjectMatchers.getMatcher("system_blocked", "blocked");
351  validators.addValidator(new ShopSquareChecker<>(validatorPreferences, shopSquareMatcher, noSpellsMatcher, blockedMatcher));
352  }
353 
354  final GameObjectMatcher paidItemMatcher = gameObjectMatchers.getMatcher("system_paid_item");
355  if (paidItemMatcher != null) {
356  validators.addValidator(new PaidItemShopSquareChecker<>(validatorPreferences, shopSquareMatcher, paidItemMatcher));
357  }
358  }
359  return validators;
360  }
361 
369  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) {
370  final ActionBuilder actionBuilder = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta");
371  int id = 0;
372  while (true) {
373  final String spec = actionBuilder.getString("validator." + id);
374  if (spec == null) {
375  break;
376  }
377  try {
378  validators.addValidator(validatorFactory.newValidator(spec));
379  } catch (final NoSuchValidatorException ex) {
380  errorView.addWarning(ErrorViewCategory.MAP_VALIDATOR_ENTRY_INVALID, id, ex.getMessage());
381  }
382  id++;
383  }
384  if (LOG.isInfoEnabled()) {
385  LOG.info("Loaded " + id + " map validators.");
386  }
387  }
388 
389  @NotNull
390  public 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) {
391  final Spells<GameObjectSpell<G, A, R>> gameObjectSpells = new Spells<>();
392  if (spellType != 0) {
393  new ArchetypeSetSpellLoader<>(gameObjectFactory).load(archetypeSet, spellType, gameObjectSpells);
394  gameObjectSpells.sort();
395  }
396  return gameObjectSpells;
397  }
398 
399  @NotNull
400  public static Spells<NumberSpell> loadSpellFile(@Nullable final String spellFile, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings) {
401  @NotNull final Spells<NumberSpell> numberSpells = new Spells<>();
402  if (spellFile == null) {
403  return numberSpells;
404  }
405 
406  try {
407  final URL url = IOUtils.getResource(projectSettings.getConfigurationDirectory(), spellFile);
408  final ErrorViewCollector errorViewCollector = new ErrorViewCollector(errorView, url);
409  final Document document = ParseUtils.readXmlUrl(url, "spells", "spells.dtd", "/system/dtd/spells.dtd", new ErrorViewCollectorErrorHandler(errorViewCollector, ErrorViewCategory.SPELLS_FILE_INVALID));
410  XMLSpellLoader.load(errorViewCollector, document, numberSpells);
411  } catch (final IOException ex) {
412  errorView.addWarning(ErrorViewCategory.SPELLS_FILE_INVALID, spellFile + ": " + ex.getMessage());
413  } catch (final ParsingException ex) {
414  errorView.addWarning(ErrorViewCategory.SPELLS_FILE_INVALID, spellFile + ": " + ex.getMessage());
415  } catch (final SAXException ex) {
416  errorView.addWarning(ErrorViewCategory.SPELLS_FILE_INVALID, spellFile + ": " + ex.getMessage());
417  } catch (final URISyntaxException ex) {
418  errorView.addWarning(ErrorViewCategory.SPELLS_FILE_INVALID, spellFile + ": " + ex.getMessage());
419  } catch (final XIncludeException ex) {
420  errorView.addWarning(ErrorViewCategory.SPELLS_FILE_INVALID, spellFile + ": " + ex.getMessage());
421  }
422  numberSpells.sort();
423  return numberSpells;
424  }
425 
426  @NotNull
427  public static Map<String, TreasureTreeNode> loadSpecialTreasureLists(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings) {
428  Map<String, TreasureTreeNode> specialTreasureLists;
429  try {
430  final URL url = IOUtils.getResource(projectSettings.getConfigurationDirectory(), "TreasureLists.xml");
431  final ErrorViewCollector treasureListsErrorViewCollector = new ErrorViewCollector(errorView, url);
432  try {
433  final Document specialTreasureListsDocument = ParseUtils.readXmlUrl(url, "lists", "TreasureLists.dtd", "/system/dtd/TreasureLists.dtd", new ErrorViewCollectorErrorHandler(treasureListsErrorViewCollector, ErrorViewCategory.TREASURES_FILE_INVALID));
434  specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument);
435  } catch (final IOException ex) {
436  treasureListsErrorViewCollector.addWarning(ErrorViewCategory.TREASURES_FILE_INVALID, ex.getMessage());
437  specialTreasureLists = Collections.emptyMap();
438  } catch (final ParsingException ex) {
439  treasureListsErrorViewCollector.addWarning(ErrorViewCategory.TREASURES_FILE_INVALID, ex.getMessage());
440  specialTreasureLists = Collections.emptyMap();
441  } catch (final SAXException ex) {
442  treasureListsErrorViewCollector.addWarning(ErrorViewCategory.TREASURES_FILE_INVALID, ex.getMessage());
443  specialTreasureLists = Collections.emptyMap();
444  } catch (final URISyntaxException ex) {
445  treasureListsErrorViewCollector.addWarning(ErrorViewCategory.TREASURES_FILE_INVALID, ex.getMessage());
446  specialTreasureLists = Collections.emptyMap();
447  } catch (final XIncludeException ex) {
448  treasureListsErrorViewCollector.addWarning(ErrorViewCategory.TREASURES_FILE_INVALID, ex.getMessage());
449  specialTreasureLists = Collections.emptyMap();
450  }
451  } catch (final FileNotFoundException ex) {
452  errorView.addWarning(ErrorViewCategory.TREASURES_FILE_INVALID, "TreasureLists.xml: " + ex.getMessage());
453  specialTreasureLists = Collections.emptyMap();
454  }
455  return specialTreasureLists;
456  }
457 
458  @NotNull
460  return projectSettings;
461  }
462 
463  @NotNull
465  return archetypeTypeSet;
466  }
467 
468  @NotNull
470  return gameObjectFactory;
471  }
472 
473  @NotNull
475  return archetypeSet;
476  }
477 
478  @NotNull
480  return mapManager;
481  }
482 
483  @NotNull
485  return gameObjectMatchers;
486  }
487 
488  @NotNull
490  return gameObjectParser;
491  }
492 
493  @NotNull
495  return faceObjectProviders;
496  }
497 
498  @NotNull
500  return smoothFaces;
501  }
502 
503  @NotNull
504  public File getScriptsFile() {
505  return scriptsFile;
506  }
507 
508  @NotNull
510  return validators;
511  }
512 
513  @NotNull
515  return animationObjects;
516  }
517 
518  @NotNull
520  return resources;
521  }
522 
523  @NotNull
525  return pickmapManager;
526  }
527 
528  @NotNull
530  return mapArchObjectFactory;
531  }
532 
533  @NotNull
535  return mapModelFactory;
536  }
537 
538  @NotNull
540  return faceObjects;
541  }
542 
543  @NotNull
545  return mapReaderFactory;
546  }
547 
548  @NotNull
550  return gameObjectSpells;
551  }
552 
553  @NotNull
555  return numberSpells;
556  }
557 
558  @NotNull
560  return topmostInsertionMode;
561  }
562 
563  @NotNull
565  return archetypeChooserModel;
566  }
567 
568  @NotNull
570  return treasureTree;
571  }
572 
573  @NotNull
575  return pathManager;
576  }
577 
578  @NotNull
580  return pluginModel;
581  }
582 
588  @NotNull
589  public PluginParameters newPluginParameters(@NotNull final Object rendererFactory) {
590  final PluginParameters pluginParameters = new PluginParameters();
591  pluginParameters.addPluginParameter("archetypeSet", archetypeSet);
592  pluginParameters.addPluginParameter("projectSettings", projectSettings);
593  pluginParameters.addPluginParameter("globalSettings", projectSettings); // XXX: for compatibility with existing scripts; should be replaced with "projectSettings"
594  pluginParameters.addPluginParameter("mapManager", mapManager);
595  pluginParameters.addPluginParameter("validators", validators);
596  pluginParameters.addPluginParameter("gameObjectMatchers", gameObjectMatchers);
597  pluginParameters.addPluginParameter("rendererFactory", rendererFactory);
598  return pluginParameters;
599  }
600 
601 }
A factory for creating MapModel instances.
A validator that checks for suspicious attribute values.
Default implementation of MapWriter.
static GameObjectMatchers loadGameObjectMatchers(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings)
static Map< String, TreasureTreeNode > loadSpecialTreasureLists(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings)
Utility class for string manipulation.
final PluginModel< G, A, R > pluginModel
MapModelFactory< G, A, R > getMapModelFactory()
MapReaderFactory< G, A > getMapReaderFactory()
This class contains methods for converting relative map paths to absolute map paths and vice versa...
Convenience class for adding messages to a ErrorView instance using a fixed category name...
A MapManager manages all opened maps.
Definition: MapManager.java:37
final MapArchObjectFactory< A > mapArchObjectFactory
Loader for AutojoinLists instances from files.
Reading and writing of maps, handling of paths.
Interface for classes that match GameObjects.
Spells< GameObjectSpell< G, A, R > > getGameObjectSpells()
This package contains classes related to matching GameObjects, so called GameObjectMatchers.
Interface for classes implementing ArchetypeAttribute factories.
Settings that apply to a project.
final ArchetypeSet< G, A, R > archetypeSet
Manages ArchetypeType instances, list, and bitmask definitions.
Interface for classes that write map files.
Definition: MapWriter.java:34
This package contains the framework for validating maps.
Utility class for parsing XML files.
Definition: ParseUtils.java:43
A net.sf.gridarta.model.validation.MapValidator to detect shop squares which allow magic or prayers...
void addWarning(@NotNull final ErrorViewCategory category)
Adds a warning message.
final DefaultMapReaderFactory< G, A, R > mapReaderFactory
final MapManager< G, A, R > pickmapManager
A factory for creating MapReader instances.
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
final ArchetypeChooserModel< G, A, R > archetypeChooserModel
Extract spell definitions from an archetype set.
Parser for the GameObjectMatchers.xml file.
Utility class for loading plugins.
final MapModelFactory< G, A, R > mapModelFactory
GameObjectFactory< G, A, R > getGameObjectFactory()
GameObjectParser< G, A, R > getGameObjectParser()
Utility class for parsing ArchetypeType instances.
Factory for creating MapArchObject instances.
static Spells< NumberSpell > loadSpellFile(@Nullable final String spellFile, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings)
Interface for classes that read or write GameObject instances.
final GameObjectFactory< G, A, R > gameObjectFactory
final FaceObjectProviders faceObjectProviders
GameObjectMatchers getGameObjectMatchers()
ArchetypeTypeSet loadTypesFromXML(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final Document document)
Loads a types.xml file.
Describes a numbered in-game spell.
Class with constants used in Gridarta and derivates.
void addPluginParameter(@NotNull final String name, @Nullable final Object value)
Defines a variable to be passed to plugins.
A factory for creating GameObjectParser instances.
AbstractMapManager< G, A, R > getMapManager()
final Spells< GameObjectSpell< G, A, R > > gameObjectSpells
Factory for creating MapArchObjectParser instances.
Defines possible error categories for ErrorView instances.
An ErrorHandler that adds all reported problems to an ErrorViewCollector instance.
void addFaceObjectProvidersListener(@NotNull final FaceObjectProvidersListener listener)
Adds a FaceObjectProvidersListener to be notified about changes.
Default implementation of MapReaderFactory.
Abstract base class for MapManager implementations.
Interface for classes displaying error messages.
Definition: ErrorView.java:28
A factory for creating Archetype instances.
A GameObjectValidator that checks for valid environment.
Base package of all Gridarta classes.
ProjectModel(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ProjectFactory< G, A, R > projectFactory, @NotNull final ResourceIcons resourceIcons, @NotNull final ConfigSource configSource)
Common base class for spells and spell lists.
Definition: Spells.java:33
Reflects a game object (object on a map).
Definition: GameObject.java:36
PluginParameters newPluginParameters(@NotNull final Object rendererFactory)
Creates a new PluginParameters instance for this project model.
Abstract factory for creating GameObject instances.
static Document readXmlUrl(@NotNull final URL url, @NotNull final String rootElement, @NotNull final String systemId, @NotNull final String resourceName, @Nullable final ErrorHandler errorHandler)
Reads an XML file from an URL.
Definition: ParseUtils.java:68
static ArchetypeTypeSet loadArchetypeTypeSet(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings)
Utility-class for Gridarta&#39;s I/O.
Definition: IOUtils.java:40
Converter for Plugin instances to or from XML representation.
final AbstractResources< G, A, R > resources
Possible source locations for configuration files.
Collection of all smoothing information.
Load spell definitions from an XML file.
Exception thrown if a map validator cannot be created.
final GameObjectParser< G, A, R > gameObjectParser
Spells< NumberSpell > getNumberSpells()
MapArchObjectFactory< A > getMapArchObjectFactory()
AnimationObjects is a container for AnimationObjects.
GameObjects are the objects based on Archetypes found on maps.
void sort()
Sort the added spells after loading is finished.
Definition: Spells.java:56
static void load(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final Document document, @NotNull final Spells< NumberSpell > spells)
Load an XML spell definitions file.
Maintains GameObjectMatcher instances.
static URL getResource(@Nullable final File dir, @NotNull final String fileName)
Get the URL of a resource.
Definition: IOUtils.java:68
InsertionMode< G, A, R > getTopmostInsertionMode()
PluginModel< G, A, R > getPluginModel()
Utility class for loadings the TreasureLists.xml file.
MapManager< G, A, R > getPickmapManager()
final InsertionMode< G, A, R > topmostInsertionMode
Describes a numbered in-game spell.
final ProjectSettings projectSettings
FaceObjects is a container for FaceObjects.
final Spells< NumberSpell > numberSpells
Makes basic Gridarta classes available to scripts.
ArchetypeSet< G, A, R > getArchetypeSet()
Parser for ArchetypeTypeSets ("types.xml" files).
A Map Validator that delegates to other MapValidators.
A factory for creating Validator instances from string representation.
Stores all defined treasure lists.
Provider for faces of GameObjects and Archetypes.
A net.sf.gridarta.model.validation.MapValidator to detect shop squares that contain paid items...
The face is the appearance of an object.
GameObjectParser< G, A, R > newGameObjectParser()
Creates a new GameObjectParser instance.
Manages a mapping between archetypes to AutojoinLists.
static void readGameObjectMatchers(@NotNull final Document document, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ErrorViewCollector errorViewCollector)
Parses a .xml file defining game object matchers.
final GameObjectMatchers gameObjectMatchers
ArchetypeChooserModel< G, A, R > getArchetypeChooserModel()
Abstract base implementation of AnimationObjects.
final DelegatingMapValidator< G, A, R > validators
Creates ImageIcon instances from resources.
static Map< String, TreasureTreeNode > parseTreasureLists(@NotNull final Document specialTreasureListsDocument)
This method fills the &#39;specialTreasureLists&#39; hash table with the names of all treasurelists which are...
final AbstractMapManager< G, A, R > mapManager
Subclass: Nodes in the CFTreasureListTree.
Abstract base implementation of FaceObjects.
This package contains the checks for validating maps.
Interface that captures similarities between different ArchetypeSet implementations.
Implementation of FaceProvider which reads images from the arch directory.
Abstract base implementation of ArchetypeParser.
final AnimationObjects animationObjects
Defines types of GameObjects with corresponding attributes.
AbstractResources< G, A, R > getResources()
String EDITOR_FOLDER_INTERN
The editor folder name for server-internal archetypes.
Definition: GameObject.java:42
DelegatingMapValidator< G, A, R > getValidators()
static TreasureTree parseTreasures(@NotNull final ErrorView errorView, @NotNull final Map< String, TreasureTreeNode > specialTreasureLists, @NotNull final ConfigSource configSource, @NotNull final ProjectSettings projectSettings)
Parses a treasure file into a TreasureTree instance.
static final Category LOG
The Logger for printing log messages.
Factory for creating MapControl instances.
void addValidator(@NotNull final Validator< G, A, R > validator)
Add a Validator that might to be queried.
static final String TYPEDEF_FILE
Name of the file that contains the type definitions.
FaceObjectProviders getFaceObjectProviders()
final ArchetypeTypeSet archetypeTypeSet
static final Pattern PATTERN_SLASH
The pattern that matches a single slash ("/").