wyvern.lib
Interface GameMapLoader

All Known Implementing Classes:
MapLoader

public interface GameMapLoader

Interface for classes that can create or load game maps. Game maps are usually loaded on a background worker thread, and people waiting for the map to load are notified when the map is ready. The BackgroundMapLoader class that performs this can take an instance of a GameMapLoader to perform the map creation.

Version:
1.0, Mar 23, 2000
Author:
Steve Yegge

Method Summary
 boolean inMapEditor()
          Returns true if we've been told we're loading the map inside the Map Editor.
 GameMap loadMap(java.lang.String filename)
          Reads a map from a Wyvern XML map file.
 void setMapEditor(boolean editor)
          Sets whether the map is being loaded within the Map Editor
 void throwExceptions(boolean exceptions)
          Turns exception-throwing on or off.
 boolean throwingExceptions()
          Returns true if this GameMapLoader is configured to throw exceptions when it encounters errors loading a map.
 

Method Detail

loadMap

public GameMap loadMap(java.lang.String filename)
                throws java.lang.Exception
Reads a map from a Wyvern XML map file. Don't try to do this on a map with the same path (i.e. from the same file) that's currently available via World.getMap(), or it'll throw an exception.

Parameters:
filename - the full path to the file. If it ends with ".py", it'll be instantiated as a python map.
Returns:
the map
Throws:
various - exceptions if the map couldn't be loaded, and the the GameMapLoader is configured to throw exceptions when there are errors loading the map.
java.lang.Exception

throwExceptions

public void throwExceptions(boolean exceptions)
Turns exception-throwing on or off. By default, it's off, and the MapLoader simply returns null if it can't load a map. If you set this option, it will throw exceptions that you can use for debugging the problem with your map.

Note: if the map header in the .map file has an "errors-ok" boolean property, it will continue without throwing any exceptions if it fails to load a particular archetype in the map. "errors-ok" maps will only throw exceptions if the map was fundamentally not loadable, e.g. if the map class couldn't be loaded, or the map's XML is corrupted.


throwingExceptions

public boolean throwingExceptions()
Returns true if this GameMapLoader is configured to throw exceptions when it encounters errors loading a map.

Returns:
true if throwing exceptions

inMapEditor

public boolean inMapEditor()
Returns true if we've been told we're loading the map inside the Map Editor. Don't use this.

Returns:
true if someone called setMapEditor(true)

setMapEditor

public void setMapEditor(boolean editor)
Sets whether the map is being loaded within the Map Editor

Parameters:
editor - true if being loaded into Map Editor, false if being loaded into an actual game session. If true, sets the transient property "@mapedit" on the loaded maps.