public abstract class AbstractMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends java.lang.Object implements MapManager<G,A,R>
MapManager
implementations.Modifier | Constructor and Description |
---|---|
protected |
AbstractMapManager(MapReaderFactory<G,A> mapReaderFactory,
ProjectSettings projectSettings,
FaceObjectProviders faceObjectProviders,
PathManager pathManager)
Create a new map manager.
|
Modifier and Type | Method and Description |
---|---|
void |
addMapManagerListener(MapManagerListener<G,A,R> listener)
Adds a
MapManagerListener to be notified. |
void |
closeMap(MapControl<G,A,R> mapControl)
Closes the given map, ignoring modified status.
|
protected abstract MapControl<G,A,R> |
createMapControl(java.util.List<G> objects,
A mapArchObject,
MapFile mapFile)
Creates a new
MapControl instance. |
MapControl<G,A,R> |
getCurrentMap()
Returns the current top map we are working with.
|
java.io.File |
getLocalMapDir()
Returns a guess for a script directory to use.
|
java.util.List<MapControl<G,A,R>> |
getOpenedMaps()
Returns all opened maps.
|
MapControl<G,A,R> |
getOpenMap()
Returns one open map.
|
MapControl<G,A,R> |
newMap(java.util.List<G> objects,
A mapArchObject,
MapFile mapFile,
boolean interactive)
Creates a new map control without view.
|
MapControl<G,A,R> |
openMapFile(java.io.File file,
boolean interactive)
Loads a map file.
|
MapControl<G,A,R> |
openMapFile(MapFile mapFile,
boolean interactive)
Loads a map file.
|
void |
release(MapControl<G,A,R> mapControl)
Releases a
MapControl instance. |
void |
removeMapManagerListener(MapManagerListener<G,A,R> listener)
Removes a
MapManagerListener to be notified. |
void |
revert(MapControl<G,A,R> mapControl)
Reverts one map.
|
void |
setCurrentMap(MapControl<G,A,R> mapControl)
Sets the given map as the current one.
|
void |
setFileControl(FileControl<G,A,R> fileControl)
Deprecated.
|
protected AbstractMapManager(@NotNull MapReaderFactory<G,A> mapReaderFactory, @NotNull ProjectSettings projectSettings, @NotNull FaceObjectProviders faceObjectProviders, @NotNull PathManager pathManager)
mapReaderFactory
- the map reader factory instanceprojectSettings
- the project settings instancefaceObjectProviders
- the face object providerspathManager
- the path manager for converting file instances@Deprecated public void setFileControl(@NotNull FileControl<G,A,R> fileControl)
@NotNull public MapControl<G,A,R> newMap(@Nullable java.util.List<G> objects, @NotNull A mapArchObject, @Nullable MapFile mapFile, boolean interactive)
MapManager.release(MapControl)
when not needed anymore.newMap
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
objects
- the game objects to insert; may be null
mapArchObject
- the map arch object for the new mapmapFile
- the map file, or null
if the map was not yet
savedinteractive
- if set, the new map becomes the current map@NotNull protected abstract MapControl<G,A,R> createMapControl(@Nullable java.util.List<G> objects, @NotNull A mapArchObject, @Nullable MapFile mapFile)
MapControl
instance.objects
- the objects to insert into the new mapmapArchObject
- the map arch object to use for the new mapmapFile
- the associated map file@Nullable public MapControl<G,A,R> getOpenMap()
getOpenMap
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
null
if no open maps existpublic void closeMap(@NotNull MapControl<G,A,R> mapControl)
closeMap
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapControl
- the map to close@NotNull public MapControl<G,A,R> openMapFile(@NotNull MapFile mapFile, boolean interactive) throws java.io.IOException
MapManager.release(MapControl)
when not needed anymore.openMapFile
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapFile
- the map file to loadinteractive
- if set, may ask to delete undefined archetypes; if
unset, keep undefined archetypesjava.io.IOException
- if an I/O error occurs@NotNull public MapControl<G,A,R> openMapFile(@NotNull java.io.File file, boolean interactive) throws java.io.IOException
MapManager.release(MapControl)
when not needed anymore.openMapFile
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
file
- the map file to loadinteractive
- if set, may ask to delete undefined archetypes; if
unset, keep undefined archetypesjava.io.IOException
- if an I/O error occurspublic void setCurrentMap(@Nullable MapControl<G,A,R> mapControl)
setCurrentMap
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapControl
- the MapControl
of the new current map@NotNull public java.util.List<MapControl<G,A,R>> getOpenedMaps()
getOpenedMaps
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
@Nullable public MapControl<G,A,R> getCurrentMap()
getCurrentMap
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
null
if no
map is openpublic void addMapManagerListener(@NotNull MapManagerListener<G,A,R> listener)
MapManagerListener
to be notified.addMapManagerListener
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
listener
- the listener to addpublic void removeMapManagerListener(@NotNull MapManagerListener<G,A,R> listener)
MapManagerListener
to be notified.removeMapManagerListener
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
listener
- the listener to removepublic void revert(@NotNull MapControl<G,A,R> mapControl) throws java.io.IOException
revert
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapControl
- the map to revertjava.io.IOException
- if an I/O error occurspublic java.io.File getLocalMapDir()
getLocalMapDir
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void release(@NotNull MapControl<G,A,R> mapControl)
MapControl
instance.release
in interface MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapControl
- the map control instance