 |
Gridarta Editor
|
Go to the documentation of this file.
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) {
273 final CharSequence editorFolder = archetype.getEditorFolder();
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) {
328 if (shopSquareMatcher !=
null) {
330 if (noSpellsMatcher !=
null) {
336 if (paidItemMatcher !=
null) {
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);
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;
Load spell definitions from an XML file.
static URL getResource(@NotNull final File dir, @NotNull final String fileName)
Get the URL of a resource.
GameObjectParser< G, A, R > getGameObjectParser()
ProjectSettings getProjectSettings()
Parser for the GameObjectMatchers.xml file.
Defines types of GameObjects with corresponding attributes.
void addWarning(@NotNull final ErrorViewCategory category)
Adds a warning message.
ArchetypeTypeSet loadTypesFromXML(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final Document document)
Loads a types.xml file.
Factory for creating MapControl instances.
Abstract factory for creating GameObject instances.
GameObjectParser< G, A, R > newGameObjectParser()
Creates a new GameObjectParser instance.
A MapManager manages all opened maps.
An ErrorHandler that adds all reported problems to an {} instance.
Subclass: Nodes in the CFTreasureListTree.
static final Pattern PATTERN_SLASH
The pattern that matches a single slash ("/").
Loader for AutojoinLists instances from files.
Parser for ArchetypeTypeSets ("types.xml" files).
The view of the archetype chooser.
static< G extends GameObject< G, A, R > A extends 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)
Loader for treasure list files.
Base package of all Gridarta classes.
void addPluginParameter(@NotNull final String name, @Nullable final Object value)
Defines a variable to be passed to plugins.
Abstract base implementation of ArchetypeParser.
final FaceObjects faceObjects
Abstract base class for MapManager implementations.
AnimationObjects is a container for AnimationObjects.
Implementation of FaceProvider which reads images from the arch directory.
MapReaderFactory< G, A > getMapReaderFactory()
final InsertionMode topmostInsertionMode
Utility class for parsing ArchetypeType instances.
Manages all opened pickmaps.
A factory for creating MapReader instances.
Utility class for loading plugins.
final ArchetypeSet< G, A, R > archetypeSet
final FaceObjectProviders faceObjectProviders
Default implementation of ArchetypeAttributeFactory.
Describes a numbered in-game spell.
static ArchetypeTypeSet loadArchetypeTypeSet(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings)
Converter for Plugin instances to or from XML representation.
This class contains methods for converting relative map paths to absolute map paths and vice versa.
Factory for creating MapArchObjectParser instances.
FaceObjectProviders getFaceObjectProviders()
Class with constants used in Gridarta and derivates.
Abstract base implementation of FaceObjects.
ArchetypeChooserModel< G, A, R > getArchetypeChooserModel()
Extract spell definitions from an archetype set.
ArchetypeTypeSet getArchetypeTypeSet()
MapModelFactory< G, A, R > getMapModelFactory()
Interface for classes displaying error messages.
static final String TYPEDEF_FILE
Name of the file that contains the type definitions.
Default ValidatorPreferences implementations.
PluginModel< G, A, R > getPluginModel()
SmoothFaces getSmoothFaces()
A factory for creating MapModel instances.
final MapArchObjectFactory< A > mapArchObjectFactory
Interface for classes that match GameObjects.
final AbstractMapManager< G, A, R > mapManager
A net.sf.gridarta.model.validation.MapValidator to detect shop squares that contain paid items.
final ArchetypeTypeSet archetypeTypeSet
final AnimationObjects animationObjects
Provider for faces of GameObjects and Archetypes.
Reflects a game object (object on a map).
final AbstractResources< G, A, R > resources
Makes basic Gridarta classes available to scripts.
GameObjectMatcher getMatcher(@NotNull final String... ids)
Returns a matcher by id; returns.
Manages ArchetypeType instances, list, and bitmask definitions.
static Map< String, TreasureTreeNode > parseTreasureLists(@NotNull final Document specialTreasureListsDocument)
This method fills the 'specialTreasureLists' hash table with the names of all treasurelists which are...
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.
void addFaceObjectProvidersListener(@NotNull final FaceObjectProvidersListener listener)
Adds a FaceObjectProvidersListener to be notified about changes.
final GameObjectMatchers gameObjectMatchers
Possible source locations for configuration files.
Configuration parameters for Validators.
static Map< String, TreasureTreeNode > loadSpecialTreasureLists(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings)
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.
GameObjects are the objects based on Archetypes found on maps.
GAMEOBJECTMATCHERS_FILE_INVALID
static final Category LOG
The Logger for printing log messages.
final SmoothFaces smoothFaces
Convenience class for adding messages to a ErrorView instance using a fixed category name.
Interface for classes that write map files.
Defines possible error categories for ErrorView instances.
ArchetypeSet< G, A, R > getArchetypeSet()
final PathManager pathManager
Exception thrown if a map validator cannot be created.
Classes related to matching {GameObjects}, so called { net.sf.gridarta.model.match....
Utility class for parsing XML files.
A factory for creating Archetype instances.
Stores all defined treasure lists.
static< G extends GameObject< G, A, R > A extends R extends Archetype< G, A, R > PluginModel< G, A, R > loadPlugins(@NotNull final PluginParameterFactory< G, A, R > pluginParameterFactory, @NotNull final PluginModelParser< G, A, R > pluginModelParser, @NotNull final ErrorView errorView, @NotNull final File pluginsDir)
final Spells< GameObjectSpell< G, A, R > > gameObjectSpells
Interface for MapArchObjects.
Maintains GameObjectMatcher instances.
Default implementation of MapWriter.
Describes a numbered in-game spell.
AbstractResources< G, A, R > getResources()
A net.sf.gridarta.model.validation.MapValidator to detect shop squares which allow magic or prayers.
void addArchetype(@NotNull final String panel, @NotNull final String folder, @NotNull final R archetype)
Adds an Archetype to this model.
final DefaultMapReaderFactory< G, A, R > mapReaderFactory
void load(@NotNull final ArchetypeSet< G, A, R > archetypeSet, final int typeNo, @NotNull final Spells< GameObjectSpell< G, A, R >> spells)
Find all game object that describe spells and add corresponding {} objects.
final MapManager< G, A, R > pickmapManager
FaceObjects is a container for FaceObjects.
ProjectModel(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ProjectFactory< G, A, R > projectFactory, @NotNull final ResourceIcons resourceIcons, @NotNull final ConfigSource configSource)
static< G extends GameObject< G, A, R > A extends 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)
final ProjectSettings projectSettings
Interface that captures similarities between different ArchetypeSet implementations.
DelegatingMapValidator< G, A, R > getValidators()
This package contains the framework for validating maps.
GameObjectFactory< G, A, R > getGameObjectFactory()
final DelegatingMapValidator< G, A, R > validators
static< G extends GameObject< G, A, R > A extends R extends Archetype< G, A, R > void addChecks(@NotNull final ArchetypeTypeSet archetypeTypeSet, @Nullable final AttributeRangeChecker< G, A, R > attributeRangeChecker, @NotNull final EnvironmentChecker< G, A, R > environmentChecker)
MapArchObjectFactory< A > getMapArchObjectFactory()
Utility class for string manipulation.
Manages a mapping between archetypes to AutojoinLists.
MapManager< G, A, R > getPickmapManager()
String EDITOR_FOLDER_INTERN
The editor folder name for server-internal archetypes.
Reading and writing of maps, handling of paths.
Settings that apply to a project.
MAP_VALIDATOR_ENTRY_INVALID
This package contains the checks for validating maps.
Interface for classes implementing ArchetypeAttribute factories.
GameObjectMatchers getGameObjectMatchers()
Collection< R > getArchetypes()
Returns a read-only collection of all Archetypes.
Utility class for loadings the TreasureLists.xml file.
A GameObjectValidator that checks for valid environment.
final TreasureTree treasureTree
static< G extends GameObject< G, A, R > A extends R extends Archetype< G, A, R > void addArchetypes(@NotNull final ArchetypeChooserModel< G, A, R > archetypeChooserModel, @NotNull final ArchetypeSet< G, A, R > archetypeSet)
PathManager getPathManager()
static< G extends GameObject< G, A, R > A extends R extends Archetype< G, A, R > AutojoinLists< G, A, R > loadList(@NotNull final ErrorView errorView, final ArchetypeSet< G, A, R > archetypeSet, @NotNull final File baseDir)
final Spells< NumberSpell > numberSpells
Spells< NumberSpell > getNumberSpells()
Collection of all smoothing information.
InsertionMode getTopmostInsertionMode()
File getConfigurationDirectory()
Returns the configuration directory which is used to load configuration information like types....
final PluginModel< G, A, R > pluginModel
void addValidator(@NotNull final Validator< G, A, R > validator)
Adds a Validator that might to be queried.
Creates checks from ArchetypeTypes.
static< G extends GameObject< G, A, R > A extends 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)
Utility class for parsing ArchetypeAttributes.
Utility-class for Gridarta's I/O.
The face is the appearance of an object.
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
static GameObjectMatchers loadGameObjectMatchers(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings)
final MapModelFactory< G, A, R > mapModelFactory
static Spells< NumberSpell > loadSpellFile(@Nullable final String spellFile, @NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings)
final ArchetypeChooserModel< G, A, R > archetypeChooserModel
static void readGameObjectMatchers(@NotNull final Document document, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ErrorViewCollector errorViewCollector)
Parses a .xml file defining game object matchers.
AbstractMapManager< G, A, R > getMapManager()
Factory for Plugin Parameters.
Creates ImageIcon instances from resources.
Default implementation of MapReaderFactory.
A Map Validator that delegates to other MapValidators.
A factory for creating Validator instances from string representation.
Abstract base implementation of AnimationObjects.
File getMapsDirectory()
Returns the default maps directory.
final GameObjectParser< G, A, R > gameObjectParser
Interface for classes that read or write GameObject instances.
Common base class for spells and spell lists.
static void load(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final Document document, @NotNull final Spells< NumberSpell > spells)
Load an XML spell definitions file.
PluginParameters newPluginParameters(@NotNull final Object rendererFactory)
Creates a new PluginParameters instance for this project model.
A validator that checks for suspicious attribute values.
FaceObjects getFaceObjects()
static< G extends GameObject< G, A, R > A extends 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)
final GameObjectFactory< G, A, R > gameObjectFactory
TreasureTree getTreasureTree()
A factory for creating GameObjectParser instances.
Factory for creating MapArchObject instances.
AnimationObjects getAnimationObjects()
Spells< GameObjectSpell< G, A, R > > getGameObjectSpells()