public class DefaultFileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends java.lang.Object implements FileControl<G,A,R>
FileControl
implementation. Asks the user for directions.Constructor and Description |
---|
DefaultFileControl(ProjectSettings projectSettings,
VolatileSettings volatileSettings,
MapImageCache<G,A,R> mapImageCache,
MapManager<G,A,R> mapManager,
MapViewsManager<G,A,R> mapViewsManager,
java.awt.Component parent,
javax.swing.filechooser.FileFilter mapFileFilter,
javax.swing.filechooser.FileFilter scriptFileFilter,
NewMapDialogFactory<G,A,R> newMapDialogFactory,
java.lang.String scriptExtension,
ScriptEditControl scriptEditControl,
PathManager pathManager)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
closeAllMaps()
Invoked when the user wants to close all maps.
|
boolean |
confirmSaveChanges(MapControl<G,A,R> mapControl)
Asks the user whether to save changes of a map.
|
void |
openFile(boolean mapFile)
The user wants to edit a file.
|
void |
reportLoadError(java.io.File file,
java.lang.String message) |
void |
reportOutOfMapBoundsDeleted(java.io.File file,
int outOfMapBoundsDeleted,
java.lang.StringBuilder outOfMapBoundsObjects) |
void |
reportOutOfMemory(java.io.File file) |
void |
reportSaveError(java.io.File mapFile,
java.lang.String message)
Reports an error while saving a map file to the user.
|
void |
reportSaveError(MapControl<G,A,R> mapControl,
java.lang.String message)
Reports an error while saving a map file to the user.
|
void |
reportTeleportCharacterError(java.lang.String mapPath,
java.lang.String message)
Reports an error while teleporting a character to the current map.
|
boolean |
save(MapControl<G,A,R> mapControl)
Save one map.
|
void |
saveAllMaps()
Saves all maps.
|
boolean |
saveAs(MapControl<G,A,R> mapControl)
Asks the user for a filename, then saves the map.
|
public DefaultFileControl(@NotNull ProjectSettings projectSettings, @NotNull VolatileSettings volatileSettings, @NotNull MapImageCache<G,A,R> mapImageCache, @NotNull MapManager<G,A,R> mapManager, @NotNull MapViewsManager<G,A,R> mapViewsManager, @NotNull java.awt.Component parent, @NotNull javax.swing.filechooser.FileFilter mapFileFilter, @NotNull javax.swing.filechooser.FileFilter scriptFileFilter, @NotNull NewMapDialogFactory<G,A,R> newMapDialogFactory, @NotNull java.lang.String scriptExtension, @NotNull ScriptEditControl scriptEditControl, @NotNull PathManager pathManager)
projectSettings
- the project settings instancevolatileSettings
- the volatile settings instancemapImageCache
- the map image cachemapManager
- the map managermapViewsManager
- the map views managerparent
- the parent component for showing dialog boxesmapFileFilter
- the file filter for selecting map filesscriptFileFilter
- the file filter for selecting script filesnewMapDialogFactory
- the new map dialog factoryscriptExtension
- the file extension for script filesscriptEditControl
- the script edit control to forward topathManager
- the path manager for creating map file instancespublic void openFile(boolean mapFile)
openFile
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapFile
- true
for map files, false
for script
filespublic boolean save(@NotNull MapControl<G,A,R> mapControl)
save
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapControl
- the mapfalse
if saving failed, true
otherwisepublic void saveAllMaps()
saveAllMaps
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public boolean closeAllMaps()
closeAllMaps
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
true
if all maps closed, false
if user cancelled.public boolean saveAs(@NotNull MapControl<G,A,R> mapControl)
saveAs
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapControl
- the mapfalse
if the user cancelled the save or if saving failed,
true
otherwisepublic boolean confirmSaveChanges(@NotNull MapControl<G,A,R> mapControl)
true
(and
does not ask the user) if the map is unmodified.confirmSaveChanges
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapControl
- the mappublic void reportSaveError(@NotNull MapControl<G,A,R> mapControl, @NotNull java.lang.String message)
reportSaveError
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapControl
- the map control that failed savingmessage
- the error messagepublic void reportSaveError(@NotNull java.io.File mapFile, @NotNull java.lang.String message)
reportSaveError
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapFile
- the map file that failed savingmessage
- the error messagepublic void reportLoadError(@Nullable java.io.File file, @NotNull java.lang.String message)
reportLoadError
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void reportOutOfMapBoundsDeleted(@NotNull java.io.File file, int outOfMapBoundsDeleted, @NotNull java.lang.StringBuilder outOfMapBoundsObjects)
reportOutOfMapBoundsDeleted
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void reportOutOfMemory(@NotNull java.io.File file)
reportOutOfMemory
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void reportTeleportCharacterError(@NotNull java.lang.String mapPath, @NotNull java.lang.String message)
reportTeleportCharacterError
in interface FileControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
mapPath
- the map path to teleport tomessage
- the error message