 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.actions;
22 import java.awt.Point;
23 import java.io.IOException;
39 import org.jetbrains.annotations.NotNull;
40 import org.jetbrains.annotations.Nullable;
94 public ExitConnectorActions(@NotNull
final ExitConnectorModel exitConnectorModel, @NotNull
final ExitMatcher<G, A, R> exitMatcher, @NotNull
final ArchetypeSet<G, A, R> archetypeSet, @NotNull
final MapManager<G, A, R> mapManager, @NotNull
final FileControl<G, A, R> fileControl, @NotNull
final InsertionModeSet<G, A, R> insertionModeSet) {
113 if (mapFile ==
null) {
135 if (sourceExitLocation ==
null) {
146 if (cursorExit !=
null) {
147 targetExit = cursorExit;
156 if (targetExit ==
null) {
167 if (!
pasteExit(targetLocation, targetMapModel, targetArchetype, sourceExitLocation, targetMapFile)) {
175 pasteExit(targetExit, targetMapModel, sourceExitLocation, targetMapFile);
191 if (sourceExitLocation ==
null) {
197 if (targetMapFile ==
null) {
210 if (cursorExit !=
null) {
211 targetExit = cursorExit;
212 targetArchetype =
null;
227 }
catch (
final IOException ex) {
232 return doExitConnect(performAction, targetExit, targetArchetype, targetMapModel, targetLocation, targetMapFile, sourceMapControl.
getMapModel(), sourceExitLocation);
238 sourceMapControl.
save();
239 }
catch (
final IOException ex) {
263 private boolean doExitConnect(
final boolean performAction, @Nullable
final BaseObject<?, ?, ?, ?> targetExit, @Nullable
final BaseObject<G, A, R, ?> targetArchetype, @NotNull
final MapModel<G, A, R> targetMapModel, @NotNull
final Point targetLocation, @NotNull
final MapFile targetMapFile, @NotNull
final MapModel<G, A, R> sourceMapModel, @NotNull
final ExitLocation sourceExitLocation) {
264 final MapFile sourceMapFile = sourceMapModel.getMapFile();
265 if (sourceMapFile ==
null) {
270 final Point sourceLocation = sourceExitLocation.getMapCoordinate();
277 sourceArchetype =
null;
290 final ExitLocation targetExitLocation =
new ExitLocation(targetMapFile, targetLocation, targetMapModel.getMapArchObject().getMapName());
291 if (sourceExit ==
null) {
292 if (!
pasteExit(sourceLocation, sourceMapModel, sourceArchetype, targetExitLocation, sourceMapFile)) {
296 pasteExit(sourceExit, sourceMapModel, targetExitLocation, sourceMapFile);
299 if (targetExit ==
null) {
300 assert targetArchetype !=
null;
301 if (!
pasteExit(targetLocation, targetMapModel, targetArchetype, sourceExitLocation, targetMapFile)) {
305 pasteExit(targetExit, targetMapModel, sourceExitLocation, targetMapFile);
321 mapModel.beginTransaction(
"paste exit");
325 mapModel.endTransaction();
340 mapModel.beginTransaction(
"paste exit");
343 if (newExit ==
null) {
349 mapModel.endTransaction();
InsertionMode getTopmostInsertionMode()
Returns the "topmost" insertion mode.
A MapModel reflects the data of a map.
R getArchetype(@NotNull String archetypeName)
Returns an Archetype by its name.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
A MapManager manages all opened maps.
ExitConnectorActions(@NotNull final ExitConnectorModel exitConnectorModel, @NotNull final ExitMatcher< G, A, R > exitMatcher, @NotNull final ArchetypeSet< G, A, R > archetypeSet, @NotNull final MapManager< G, A, R > mapManager, @NotNull final FileControl< G, A, R > fileControl, @NotNull final InsertionModeSet< G, A, R > insertionModeSet)
Creates a new instance.
Stores information about a remembered exit location.
Base package of all Gridarta classes.
final FileControl< G, A, R > fileControl
The FileControl to use.
Exception thrown if an Archetype does not exist.
final MapManager< G, A, R > mapManager
The MapManager for loading maps.
void setExitLocation(@Nullable ExitLocation exitLocation)
Sets the remembered exit location.
G getExit(@NotNull final MapModel< G, A, R > mapModel, @Nullable final Point point)
Returns an exit game object on a given map square.
void reportLoadError(@Nullable File file, @NotNull String message)
Reflects a game object (object on a map).
Selects valid exit game objects from maps.
boolean isModified()
Return whether the map has been modified from the on-disk state.
boolean doExitCopy(final boolean performAction, @NotNull final MapControl< G, A, R > mapControl, @NotNull final Point location)
Executes the "exit copy" action.
GameObjects are the objects based on Archetypes found on maps.
MapFile getMapFile()
Returns the file of the map that contains the remembered exit.
boolean doExitConnect(final boolean performAction, @Nullable final BaseObject<?, ?, ?, ?> targetExit, @Nullable final BaseObject< G, A, R, ?> targetArchetype, @NotNull final MapModel< G, A, R > targetMapModel, @NotNull final Point targetLocation, @NotNull final MapFile targetMapFile, @NotNull final MapModel< G, A, R > sourceMapModel, @NotNull final ExitLocation sourceExitLocation)
Executes part of the "exit connect" action.
Interface for MapArchObjects.
File getFile()
Returns a File for this map file.
MapControl< G, A, R > openMapFile(@NotNull MapFile mapFile, boolean interactive)
Loads a map file.
void reportSaveError(@NotNull MapControl< G, A, R > mapControl, @NotNull String message)
Reports an error while saving a map file to the user.
Interface that captures similarities between different ArchetypeSet implementations.
void save()
Saves the map to a file.
The location of a map file with a map directory.
String getExitArchetypeName()
Returns the archetype name when creating exit game objects.
void release(@NotNull MapControl< G, A, R > mapControl)
Releases a MapControl instance.
Utility class implementing actions that operate on ExitConnectorModels.
final ExitConnectorModel exitConnectorModel
The ExitConnectorModel to use.
final ArchetypeSet< G, A, R > archetypeSet
The ArchetypeSet to use.
boolean isAutoCreateExit()
Returns whether exit game objects should be auto-created when needed.
final InsertionModeSet< G, A, R > insertionModeSet
The InsertionModeSet to use.
int getUseCounter()
Returns the use counter.
ExitLocation getExitLocation()
Returns the remembered exit location.
Currently nothing more than a marker interface for unification.
MapModel< G, A, R > getMapModel()
Returns the map model.
boolean pasteExit(@NotNull final Point location, @NotNull final MapModel< G, A, R > mapModel, @NotNull final BaseObject< G, A, R, ?> archetype, @NotNull final ExitLocation exitLocation, @Nullable final MapFile mapFile)
Creates a new exit game object.
MapFile getMapFile()
Returns the map file.
Stores information needed by the exit connector.
final ExitMatcher< G, A, R > exitMatcher
The ExitMatcher to use.
void pasteExit(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final MapModel< G, A, R > mapModel, @NotNull final ExitLocation exitLocation, @Nullable final MapFile gameObjectMapFile)
Pastes exit information into an exit game object.
boolean isPasteExitName()
Returns whether the exit name should be updated.
boolean doExitConnect(final boolean performAction, @NotNull final MapControl< G, A, R > mapControl, @NotNull final Point targetLocation)
Executes the "exit connect" action.
boolean doExitPaste(final boolean performAction, @NotNull final MapControl< G, A, R > mapControl, @NotNull final Point targetLocation)
Executes the "exit paste" action.