public interface MapModel<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends java.lang.Iterable<MapSquare<G,A,R>>, java.io.Serializable
| Modifier and Type | Method and Description |
|---|---|
void |
addActiveEditType(int editType)
Add edit type to the bitmask of active types.
|
void |
addGameObjectToMap(G gameObject,
java.awt.Point pos,
InsertionMode<G,A,R> insertionMode)
Add a gameObject to the map.
|
void |
addMapModelListener(MapModelListener<G,A,R> listener)
Register a map listener.
|
void |
addMapTransactionListener(MapTransactionListener<G,A,R> listener)
Registers a map transaction listener.
|
void |
addObjectListToMap(java.lang.Iterable<G> objects)
Adds a list of
GameObjects to this map. |
void |
beginGameObjectChange(G gameObject)
Method to notify the model that a game object is about to change.
|
void |
beginSquareChange(MapSquare<G,A,R> mapSquare)
Method to notify the model that a map square is about to change.
|
void |
beginTransaction(java.lang.String name)
Starts a new transaction.
|
void |
clearMap()
Clears this map completely.
|
void |
endAllTransactions()
Ends all transaction.
|
void |
endGameObjectChange(G gameObject)
Method to notify the model that a game object was changed.
|
void |
endSquareChange(MapSquare<G,A,R> mapSquare)
Method to notify the model that a map square was changed.
|
void |
endTransaction()
End a transaction.
|
void |
endTransaction(boolean fireEvent)
End a transaction.
|
void |
facesReloaded()
Will be called whenever the archetype faces have been reloaded.
|
java.util.List<G> |
getAllGameObjects()
Returns all game objects.
|
ErrorCollector<G,A,R> |
getErrors()
Gets the errors in this map.
|
A |
getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
|
MapFile |
getMapFile()
Returns the map file.
|
MapFile |
getMapFile(MapPath mapPath)
Returns the map file for a map that can be reached by following a
MapPath from this map. |
MapSquare<G,A,R> |
getMapSquare(java.awt.Point pos)
Get the square at a specified location.
|
int |
getTransactionDepth()
Get the transaction depth, which is the number of
beginTransaction(String) invocations without matching endTransaction() invocations. |
G |
insertArchToMap(BaseObject<G,A,R,?> templateBaseObject,
G nextGameObject,
java.awt.Point pos,
boolean join)
Insert a game object to the map at a specified position.
|
G |
insertBaseObject(BaseObject<G,A,R,?> baseObject,
java.awt.Point pos,
boolean allowMany,
boolean join,
InsertionMode<G,A,R> insertionMode)
Inserts a
BaseObject to a map. |
boolean |
isAnyTransactionActive()
Returns whether a transaction is currently active.
|
boolean |
isAreaEmpty(int left,
int top,
int width,
int height)
Checks whether an area of a map is completely empty.
|
boolean |
isEmpty()
Returns whether the map is empty.
|
boolean |
isModified()
Return whether the map has been modified from the on-disk state.
|
boolean |
isMultiArchFittingToMap(Archetype<G,A,R> archetype,
java.awt.Point pos,
boolean allowDouble)
Checks whether an GameObject (multi-arch) would still fit on this map.
|
void |
mapClosed()
This function must be called if this instance is freed.
|
void |
moveEnv(G gameObject,
java.awt.Point pos,
G nextGameObject)
Moves a
GameObject to its environment. |
void |
moveInv(G gameObject,
GameObject<G,A,R> prevGameObject)
Moves a
GameObject to the inventory of another game object. |
void |
nextPoint(java.awt.Point point,
int direction)
Moves the given point forward or backward one map square.
|
void |
removeGameObject(G gameObject,
boolean join)
Delete an existing
GameObject from the map. |
void |
removeMapModelListener(MapModelListener<G,A,R> listener)
Unregister a map listener.
|
void |
removeMapTransactionListener(MapTransactionListener<G,A,R> listener)
Unregisters a map transaction listener.
|
void |
resetModified()
Resets the modified flag to false.
|
void |
setErrors(ErrorCollector<G,A,R> errors)
Sets the errors in this map.
|
void |
setMapFile(MapFile mapFile)
Sets the map file.
|
void |
transientGameObjectChange(G gameObject)
Method to notify the model that a game object was changed but need not be
restored by undo/redo.
|
void mapClosed()
void clearMap()
boolean isEmpty()
true if the map is empty, or false if the map is
not empty@NotNull A getMapArchObject()
void addMapModelListener(@NotNull
MapModelListener<G,A,R> listener)
listener - the listener to registervoid removeMapModelListener(@NotNull
MapModelListener<G,A,R> listener)
listener - the listener to unregistervoid addMapTransactionListener(@NotNull
MapTransactionListener<G,A,R> listener)
listener - the the listener to registervoid removeMapTransactionListener(@NotNull
MapTransactionListener<G,A,R> listener)
listener - the listener to unregistervoid beginSquareChange(@NotNull
MapSquare<G,A,R> mapSquare)
mapSquare - the map square that is about to changevoid endSquareChange(@NotNull
MapSquare<G,A,R> mapSquare)
getTransactionDepth() returns 0, otherwise
it is transactional. The model then notifies the registered listeners of
the changes.mapSquare - the map square that has changedvoid beginGameObjectChange(@NotNull
G gameObject)
gameObject - the game object that is about to changevoid endGameObjectChange(@NotNull
G gameObject)
getTransactionDepth() returns 0,
otherwise it is transactional. The model then notifies the registered
listeners of the changes.gameObject - the game object that has changedvoid transientGameObjectChange(@NotNull
G gameObject)
getTransactionDepth() returns 0, otherwise it is transactional. The
model then notifies the registered listeners of the changes.gameObject - the game object that has changedvoid beginTransaction(@NotNull
java.lang.String name)
endTransaction().
A transaction has a name. The name of the outermost transaction is used
as a String presented to the user for undoing the operation enclosed by
that transaction.
Beginning a nested transaction is a cheap operation.name - the name of the transactionendTransaction(),
endTransaction(boolean),
endAllTransactions(),
getTransactionDepth(),
isAnyTransactionActive()void endTransaction()
endTransaction(false).void endTransaction(boolean fireEvent)
fireEvent to true is useful even
though the outermost transaction is not ended is when during painting the
UI should be updated though painting is not finished.fireEvent - true if an event should be fired even in case
this doesn't end the outermost transaction.beginTransaction(String),
endTransaction(),
endAllTransactions(),
getTransactionDepth(),
isAnyTransactionActive()fireEvent is ignored
and the event is always fired., An event is never fired when there were no changes, no matter
whether the outermost transaction is ended or fireEvent is set to
true., If the event is fired, the internal change list is not cleared.void endAllTransactions()
int getTransactionDepth()
beginTransaction(String) invocations without matching endTransaction() invocations. A transaction depth of 0 means there is
no ongoing transaction.beginTransaction(String),
endTransaction(),
endTransaction(boolean),
endAllTransactions(),
isAnyTransactionActive()boolean isAnyTransactionActive()
true if and only if getTransactionDepth() returns
a value greater than zero.true if there's a transaction going on, otherwise false.beginTransaction(String),
endTransaction(),
endTransaction(boolean),
endAllTransactions(),
getTransactionDepth()@NotNull MapSquare<G,A,R> getMapSquare(@NotNull java.awt.Point pos)
pos - location to get square atpjava.lang.IndexOutOfBoundsException - in case p specifies a location that's
not valid within this map modelvoid addObjectListToMap(@NotNull
java.lang.Iterable<G> objects)
GameObjects to this map.objects - the game objects to addvoid addGameObjectToMap(@NotNull
G gameObject,
@NotNull
java.awt.Point pos,
@NotNull
InsertionMode<G,A,R> insertionMode)
gameObject is a new and unlinked object.gameObject - The new GameObject with set destination coordinates to
be linked onto the map.pos - the insert locationinsertionMode - the insertion mode to usevoid moveEnv(@NotNull
G gameObject,
@NotNull
java.awt.Point pos,
@NotNull
G nextGameObject)
GameObject to its environment.gameObject - the game object to movepos - the insertion positionnextGameObject - the next game objectvoid moveInv(@NotNull
G gameObject,
@NotNull
GameObject<G,A,R> prevGameObject)
GameObject to the inventory of another game object.gameObject - the game object to moveprevGameObject - the previous game object@Nullable G insertBaseObject(@NotNull BaseObject<G,A,R,?> baseObject, @NotNull java.awt.Point pos, boolean allowMany, boolean join, @NotNull InsertionMode<G,A,R> insertionMode)
BaseObject to a map. Archetypes are instantiated, game
objects are cloned. The direction of the inserted game object is set to
the direction of the archetype chooser. This function allows multi-square
game objects.baseObject - the base objectpos - the insert-location on this mapallowMany - whether duplicates are allowedjoin - whether to auto-join the inserted game objectinsertionMode - the insertion mode to usenull if nothing was inserted@Nullable G insertArchToMap(@NotNull BaseObject<G,A,R,?> templateBaseObject, @Nullable G nextGameObject, @NotNull java.awt.Point pos, boolean join)
templateBaseObject - a clone copy of this game object gets inserted
to the map; it can be an archetype of a game objectnextGameObject - the new game object gets inserted before this; if
null, the game object gets inserted at bottompos - the map position to insert the new game objectjoin - if set, auto-joining is supportednull if an error occurredvoid removeGameObject(@NotNull
G gameObject,
boolean join)
GameObject from the map.gameObject - the game object to removejoin - if set, auto-joining is supportedboolean isMultiArchFittingToMap(@NotNull
Archetype<G,A,R> archetype,
@NotNull
java.awt.Point pos,
boolean allowDouble)
archetype - the archetype to checkpos - position of multi-square headallowDouble - whether overlapping multi-square arches should be
allowed (check is done using the archetype name)true if the multi-square archetype would still fit on
this map, false otherwisevoid setErrors(@NotNull
ErrorCollector<G,A,R> errors)
errors - the errors@NotNull ErrorCollector<G,A,R> getErrors()
boolean isAreaEmpty(int left,
int top,
int width,
int height)
left - the left border of the areatop - the top border of the areawidth - the with of the areaheight - the height of the areavoid addActiveEditType(int editType)
editType - new edit typevoid setMapFile(@Nullable
MapFile mapFile)
mapFile - the map file or null if the map has not yet been
saved@Nullable MapFile getMapFile()
null if the map has not yet been saved@NotNull MapFile getMapFile(@NotNull MapPath mapPath) throws SameMapException, UnsavedMapException
MapPath from this map.mapPath - the map path to followSameMapException - of the destination map file is the same as this
map fileUnsavedMapException - if this map is not saved and therefore its
map file is unknown@NotNull java.util.List<G> getAllGameObjects()
boolean isModified()
true if the map has been modified from the on-disk statevoid resetModified()
void facesReloaded()
void nextPoint(java.awt.Point point,
int direction)
point - the point to start with and modifydirection - the direction (-1 or +1)