 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.model.mapmanager;
23 import java.io.IOException;
24 import java.util.Collection;
25 import java.util.Collections;
26 import java.util.Iterator;
27 import java.util.List;
28 import java.util.concurrent.CopyOnWriteArrayList;
41 import org.jetbrains.annotations.NotNull;
42 import org.jetbrains.annotations.Nullable;
82 private final List<MapControl<G, A, R>>
mapControls =
new CopyOnWriteArrayList<>();
87 private final Collection<MapManagerListener<G, A, R>>
listenerList =
new CopyOnWriteArrayList<>();
112 faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener);
126 listener.mapCreated(mapControl, interactive);
157 listener.mapClosing(mapControl);
159 assert mapControl.getUseCounter() <= 0;
165 listener.mapClosed(mapControl);
167 mapControl.getMapModel().mapClosed();
176 final MapFile tmpMapFile = mapControl.getMapModel().getMapFile();
177 if (tmpMapFile !=
null && tmpMapFile.
equals(mapFile)) {
178 mapControl.acquire();
208 }
catch (
final OutOfMemoryError ex) {
209 throw new IOException(
"out of memory", ex);
212 int outOfMapBoundsDeleted = 0;
213 final StringBuilder outOfMapBoundsObjects =
new StringBuilder();
217 while (
it.hasNext()) {
220 final int minX = gameObject.
getHead().getMapX() + gameObject.
getMinX();
221 final int minY = gameObject.
getHead().getMapY() + gameObject.
getMinY();
222 final int maxX = gameObject.
getHead().getMapX() + gameObject.
getMaxX();
223 final int maxY = gameObject.
getHead().getMapY() + gameObject.
getMaxY();
224 if (minX < 0 || minY < 0 || maxX >= mapWidth || maxY >= mapHeight) {
226 if (gameObject.
isHead()) {
227 outOfMapBoundsDeleted++;
229 outOfMapBoundsObjects.append(
'\n');
230 outOfMapBoundsObjects.append(gameObject.
getBestName());
231 outOfMapBoundsObjects.append(
" at ");
232 outOfMapBoundsObjects.append(minX).append(
'/').append(minY);
233 if (minX != maxX || minY != maxY) {
234 outOfMapBoundsObjects.append(
"..");
235 outOfMapBoundsObjects.append(maxX).append(
'/').append(maxY);
238 outOfMapBoundsObjects.append(
"\n...");
244 if (interactive && outOfMapBoundsDeleted > 0) {
293 final MapFile mapFile = mapControl.getMapModel().getMapFile();
294 if (mapFile ==
null) {
304 mapArchObject.beginTransaction();
308 mapArchObject.endTransaction();
321 if (mapControl ==
null) {
326 if (mapFile ==
null) {
330 return mapFile.
getFile().getParentFile();
335 mapControl.release();
336 if (mapControl.getUseCounter() <= 0) {
A MapModel reflects the data of a map.
Interface for classes that read map files.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
A MapManager manages all opened maps.
MapControl< G, A, R > currentMapControl
The current top map we are working with.
void resetModified()
Resets the modified flag to false.
void reportOutOfMapBoundsDeleted(@NotNull File file, int outOfMapBoundsDeleted, @NotNull StringBuilder outOfMapBoundsObjects)
Base package of all Gridarta classes.
void endTransaction()
End a transaction.
Abstract base class for MapManager implementations.
void setFileControl(@NotNull final FileControl< G, A, R > fileControl)
A factory for creating MapReader instances.
boolean isInContainer()
Check whether this GameObject is in a Container (in Gridarta sense, which means being in a MapSquare ...
int getMinY()
Determines the minimum y-coordinate of any part relative to the head part.
void beginTransaction(@NotNull String name)
Starts a new transaction.
int getMinX()
Determines the minimum x-coordinate of any part relative to the head part.
This class contains methods for converting relative map paths to absolute map paths and vice versa.
boolean equals(@Nullable final Object obj)
List< G > getGameObjects()
Return the decoded game objects.
Provider for faces of GameObjects and Archetypes.
Reflects a game object (object on a map).
String getBestName()
Returns the name which is best appropriate to describe this GameObject.
MapReader< G, A > newMapReader(@NotNull File file)
Creates a new MapReader instance.
final Collection< MapManagerListener< G, A, R > > listenerList
The MapManagerListeners to inform of changes.
boolean isHead()
Returns whether this object is a single-part object or the head of the multi-part object.
FileControl< G, A, R > fileControl
The main control.
void addMapManagerListener(@NotNull final MapManagerListener< G, A, R > listener)
MapControl< G, A, R > getCurrentMap()
Returns the current top map we are working with.
GameObjects are the objects based on Archetypes found on maps.
MapControl< G, A, R > openMapFile(@NotNull final File file, final boolean interactive)
int getMaxX()
Determines the maximum x-coordinate of any part relative to the head part.
AbstractMapManager(@NotNull final MapReaderFactory< G, A > mapReaderFactory, @NotNull final ProjectSettings projectSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager)
Creates a instance.
Interface for MapArchObjects.
abstract MapControl< G, A, R > createMapControl(@Nullable List< G > objects, @NotNull A mapArchObject, @Nullable MapFile mapFile)
Creates a new MapControl instance.
MapFile getMapFile(@NotNull final AbsoluteMapPath mapPath)
Returns a MapFile instance from an AbsoluteMapPath.
MapControl< G, A, R > openMapFile(@NotNull final MapFile mapFile, final boolean interactive)
File getFile()
Returns a File for this map file.
MapControl< G, A, R > getOpenMap()
The location of a map file with a map directory.
Reading and writing of maps, handling of paths.
Settings that apply to a project.
MapControl< G, A, R > newMap(@Nullable final List< G > objects, @NotNull final A mapArchObject, @Nullable final MapFile mapFile, final boolean interactive)
final MapReaderFactory< G, A > mapReaderFactory
The gridarta objects factory instance.
final List< MapControl< G, A, R > > mapControls
All open maps.
T getHead()
Return the head part of a multi-part object.
void closeMap(@NotNull final MapControl< G, A, R > mapControl)
void release(@NotNull final MapControl< G, A, R > mapControl)
Interface for listeners interested in FaceObjectProviders related events.
The face is the appearance of an object.
int getMaxY()
Determines the maximum y-coordinate of any part relative to the head part.
void clearMap()
Clears this map completely.
Currently nothing more than a marker interface for unification.
MapModel< G, A, R > getMapModel()
Returns the map model.
A getMapArchObject()
Returns the MapArchObject read from this MapFileDecode.
final PathManager pathManager
The PathManager for converting File instances.
void removeMapManagerListener(@NotNull final MapManagerListener< G, A, R > listener)
File getMapsDirectory()
Returns the default maps directory.
MapReader< G, A > decodeMapFile(@NotNull final File file, final boolean interactive)
Loads a map file.
MapFile getMapFile()
Returns the map file.
void setCurrentMap(@Nullable final MapControl< G, A, R > mapControl)
final ProjectSettings projectSettings
The project settings instance.
void addObjectListToMap(@NotNull Iterable< G > objects)
Adds a list of GameObjects to this map.
void facesReloaded()
Called whenever the faces have been reloaded.
void revert(@NotNull final MapControl< G, A, R > mapControl)
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from please keep code indentation accurate This is not just good it helps to keep code readable and in that way dramatically decreases the chance for overlooked bugs Everyone is welcomed to correct indentation errors wherever they are spotted Before you start to do this please double check that your editor is really configured to insert spaces Line feeds may be checked in either in windows or in unix linux style All reasonable text and java editors can deal with both linefeed formats Converting line feeds is but in this case please make sure that only linefeed characters are changed and nothing else is affected Due to the platform independent nature of the editor has the potential to run on almost any given operating system the build process differs greatly between systems as well as java environments In the several people have attempted to add build scripts along with structural changes to optimize the setup on one particular system environment which has led to conflict Please do *not *attempt to change the structure or any directories for the mere purpose of improving a build process or performance in a java environment Build scripts may be placed in the root it would be especially fine if it is just one or two files but the latter is not required Please excuse me for placing such restriction I and many users of the editor greatly appreciate build scripts We just had some real troubles over this issue in the past and I don t want to have them repeated the editor has relatively high performance requirements I ve spent a lot of extra work to keep everything as fast and memory efficient as possible when you add new data fields or calculations in the archetype please make sure they are as efficient as possible and worth both the time and space they consume Now don t be afraid too much No development would be possible without adding calculations and data at all Just bear in mind unlike for many other open source performance does make a difference for the CrossfireEditor The for as many systems as possible In case you are unexperienced with java and note that the graphics look different on every and with every font They also have different sizes proportions and behave different A seemingly trivial and effectless change can wreck havoc for the same GUI run on another system please don t be totally afraid of it
static final int DELETED_OBJECTS_TO_REPORT
The maximum number of deleted game objects to report.
List< MapControl< G, A, R > > getOpenedMaps()