#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "mape/material.h"
#include "mape/texture.h"
Go to the source code of this file.
Typedefs | |
typedef G_BEGIN_DECLS enum _MapeMapgenError | MapeMapgenError |
typedef enum _MapeMapgenType | MapeMapgenType |
Enumerations | |
enum | _MapeMapgenError { MAPE_MAPGEN_ERROR_COMPILE , MAPE_MAPGEN_ERROR_MEMORY } |
enum | _MapeMapgenType { MAPE_MAPGEN_NONE , MAPE_MAPGEN_LANDSCAPE_TXT , MAPE_MAPGEN_MAP_C } |
Functions | |
gboolean | mape_mapgen_init (GError **error) |
void | mape_mapgen_deinit () |
void | mape_mapgen_set_root_group (MapeGroup *group) |
GdkPixbuf * | mape_mapgen_render (const gchar *filename, const gchar *source, MapeMapgenType type, const gchar *script_path, MapeMaterialMap *material_map, MapeTextureMap *texture_map, guint width, guint height, GError **error) |
typedef G_BEGIN_DECLS enum _MapeMapgenError MapeMapgenError |
MapeMapgenError: @MAPE_MAPGEN_ERROR_COMPILE: An error occured while compiling the Landscape.txt source code. @MAPE_GROUP_ERROR_MEMORY: Insufficient memory was available to render the map.
These errors are from the MAPE_MAPGEN_ERROR error domain. They can occur when rendering a map from a Landscape.txt file.
typedef enum _MapeMapgenType MapeMapgenType |
MapeMapgenType: @MAPE_MAPGEN_NONE: Does not represent a map description. @MAPE_MAPGEN_LANDSCAPE_TXT: Represents a Landscape.txt script. @MAPE_MAPGEN_MAP_C: Represents a Map.c script.
Specifies the different types of maps that can be rendered.
enum _MapeMapgenError |
MapeMapgenError: @MAPE_MAPGEN_ERROR_COMPILE: An error occured while compiling the Landscape.txt source code. @MAPE_GROUP_ERROR_MEMORY: Insufficient memory was available to render the map.
These errors are from the MAPE_MAPGEN_ERROR error domain. They can occur when rendering a map from a Landscape.txt file.
Enumerator | |
---|---|
MAPE_MAPGEN_ERROR_COMPILE | |
MAPE_MAPGEN_ERROR_MEMORY |
Definition at line 37 of file mapgen.h.
enum _MapeMapgenType |
MapeMapgenType: @MAPE_MAPGEN_NONE: Does not represent a map description. @MAPE_MAPGEN_LANDSCAPE_TXT: Represents a Landscape.txt script. @MAPE_MAPGEN_MAP_C: Represents a Map.c script.
Specifies the different types of maps that can be rendered.
Enumerator | |
---|---|
MAPE_MAPGEN_NONE | |
MAPE_MAPGEN_LANDSCAPE_TXT | |
MAPE_MAPGEN_MAP_C |
Definition at line 50 of file mapgen.h.
void mape_mapgen_deinit | ( | ) |
Deinitializes the map generator.
Definition at line 156 of file mapgen.c.
References c4_mapgen_handle_deinit_script_engine().
gboolean mape_mapgen_init | ( | GError ** | error | ) |
mape_mapgen_init: @error: Location to store error information, if any.
Initializes the map generator.
Returns: TRUE on success or FALSE on error.
Definition at line 144 of file mapgen.c.
References c4_mapgen_handle_init_script_engine().
GdkPixbuf* mape_mapgen_render | ( | const gchar * | filename, |
const gchar * | source, | ||
MapeMapgenType | type, | ||
const gchar * | script_path, | ||
MapeMaterialMap * | material_map, | ||
MapeTextureMap * | texture_map, | ||
guint | width, | ||
guint | height, | ||
GError ** | error | ||
) |
mape_mapgen_render:
@filename: The filename of the file that is being parsed. This is only used for display purposes. @source: The map generator source code for the map to generate. @type: Specifies how the text in @source should be interpreted. Must not be MAPE_MAPGEN_NONE. @script_path: Path to the script source for algo=script overlays, or NULL. @material_map: The material map containing the materials to be used during map generation. @texture_map: The texture map containing the textures to be used during map generation. @width: The width of the map to generate. @height: The height of the map to generate. @error: Location to store error information, if any, or NULL.
Renders the map described by @source with the C4MapCreatorS2 into a pixbuf. The pixel color depends on the texture at the corresponding position and is determined by the average color of that texture.
If the source contains one or more algo=script overlays and @script_path is NULL, an error is generated. Otherwise, the file at @script_path is opened and used to look up the relevant script functions.
In case an error occurs, for example when the map generator source code is not valid, @error is set and the function returns NULL.
Return Value: A #GdkPixbuf with the generated map, or NULL. Free with g_object_unref().
Definition at line 227 of file mapgen.c.
References _mape_material_map_get_handle(), _mape_texture_map_get_handle(), c4_mapgen_handle_get_error(), c4_mapgen_handle_new(), c4_mapgen_handle_new_script(), MAPE_MAPGEN_LANDSCAPE_TXT, and MAPE_MAPGEN_MAP_C.
void mape_mapgen_set_root_group | ( | MapeGroup * | group | ) |
mape_mapgen_set_root_group: @group: The root group.
Sets the root group for the map generator. This group is used to lookup the Library_Map definition.
Definition at line 169 of file mapgen.c.
References _mape_group_get_handle(), c4_mapgen_handle_set_map_library(), and mape_group_open_child().