class hegame.HEGame(HLGame)

HEGame is a subclass of HLGame for use by games having a level editor. It provides facilities for loading and saving level files, creating level sets and running levels in test mode. It is designed to be used in conjunction with an HEShell.

To use HEGame you need to provide a create_level() method that creates and returns a new level object. If your level object is directly pickleable, that's all you need to do in order to support loading and saving levels. Otherwise you will also have to provide pickle_level() and unpickle_level() methods.

Class Attributes

level_file_version = 1
level_min_version = 1
level_app_version = (1, 0, 0)
level_version_ranges = {}
level_file_magic = "LEVL"
These attributes provide the same information about level files as the corresponding attributes for saved-game files in HLGame.

Attributes

editing_level_dir
Directory to which the level being edited belongs. Initially empty, set when the level is saved.
level_needs_saving
True when the level has been modified in the level editor and needs to be saved.

Abstract Methods

create_level()
Should create and return a new level object.
pickle_level(pickler, level)
Should preserve the given level object by pickling objects to the given pickler. The default implementation pickles the level object directly.
unpickle_level(unpickler)
Should reconstitute a level by unpickling objects from the given unpickler and return a level object. The default implementation unpickles the level object directly.

Methods

level_changed()
This method should be called by your level editor code whenever the level is modified in such a way as to require saving.
You probably won't have to call the following methods yourself, as they are called when appropriate from HEShell. They are documented here in case you want to know about them for customization purposes.
get_level_save_dir()
Returns the directory in which the level being edited should be saved by default. If the level has been saved before, returns the directory in which it was last saved. Otherwise, returns the directory from which it was loaded, unless it was loaded from the standard levels directory. If it is a new level or was loaded from the standard levels directory, the default custom levels directory is returned.
read_level(path)
Reads a level from the specified file and returns a level object.
write_level(path)
Writes the current level to the specified file.