74 typedef std::vector<animated<image::locator>>
imagelist;
170 const std::chrono::milliseconds&
random_start = std::chrono::milliseconds{-1});
175 const std::string& tod,
177 const std::chrono::milliseconds&
random_start = std::chrono::milliseconds{-1});
207 std::vector<animated<image::locator>>
images;
287 typedef std::pair<const rule_image_rand*, const rule_image_variant*>
log_details;
288 typedef std::vector<log_details>
logs;
453 void reload(
int x,
int y);
567 void replace_rotate_tokens(building_rule& rule,
int angle,
const std::vector<std::string>& replacement);
605 void rotate_rule(building_rule& rule,
int angle,
const std::vector<std::string>& angle_name);
638 const config& global_images);
A config object defines a single node in a WML file, with access to child nodes.
A class grating read only view to a vector of config objects, viewed as one config with all children ...
Encapsulates the map of the game.
The map of "tile" structures corresponding to the level map.
tile & operator[](const map_location &loc)
Returns a reference to the tile which is at the position pointed by loc.
bool on_map(const map_location &loc) const
Tests if a location is on the map.
void reset()
Resets the whole tile map.
int x_
The x dimension of the map.
tilemap(int x, int y)
Constructs a tilemap of dimensions x * y.
void reload(int x, int y)
Rebuilds the map to a new set of dimensions.
std::vector< tile > tiles_
The map.
int y_
The y dimension of the map.
The class terrain_builder is constructed from a config object, and a gamemap object.
void parse_mapstring(const std::string &mapstring, struct building_rule &br, anchormap &anchors, const config &global_images)
Parses a map string (the map= element of a [terrain_graphics] rule, and adds constraints from this ma...
std::vector< animated< image::locator > > imagelist
A shorthand typedef for a list of animated image locators, the base data type returned by the get_ter...
std::map< t_translation::terrain_code, std::vector< map_location > > terrain_by_type_map
Shorthand typedef for a map associating a list of locations to a terrain type.
bool terrain_matches(const t_translation::terrain_code &tcode, const t_translation::ter_match &terrain) const
Checks whether a terrain code matches a given list of terrain tcodes.
std::multiset< building_rule > building_ruleset
A set of building rules.
void parse_config(const config &cfg, bool local=true)
Parses a configuration object containing [terrain_graphics] rules, and fills the building_rules_ memb...
tile * get_tile(const map_location &loc)
void add_rule(building_ruleset &rules, building_rule &rule)
Adds a rule to a ruleset.
terrain_constraint & add_constraints(constraint_set &constraints, const map_location &loc, const t_translation::ter_match &type, const config &global_images)
Creates a rule constraint object which matches a given list of terrains, and adds it to the list of c...
void rotate_rule(building_rule &rule, int angle, const std::vector< std::string > &angle_name)
Rotates a template rule to a given angle.
bool draw_border_
Whether the map border should be drawn.
void add_off_map_rule(const std::string &image)
Adds a builder rule for the _off^_usr tile, this tile only has 1 image.
void build_terrains()
Calculates the list of terrains, and fills the tile_map_ member, from the gamemap and the building_ru...
void add_images_from_config(rule_imagelist &images, const config &cfg, bool global, int dx=0, int dy=0)
Parses a "config" object, which should contains [image] children, and adds the corresponding parsed r...
void rebuild_terrain(const map_location &loc)
Performs a "quick-rebuild" of the terrain in a given location.
bool update_animation(const map_location &loc)
Updates the animation at a given tile.
static building_ruleset building_rules_
Parsed terrain rules.
const gamemap & map() const
static const unsigned int DUMMY_HASH
bool rule_matches(const building_rule &rule, const map_location &loc, const terrain_constraint *type_checked) const
Checks whether a rule matches a given location in the map.
void change_map(const gamemap *m)
static void set_terrain_rules_cfg(const game_config_view &cfg)
Set the config where we will parse the global terrain rules.
std::vector< terrain_constraint > constraint_set
The list of constraints attached to a terrain_graphics WML rule.
const int tilewidth_
The tile width used when using basex and basey.
const gamemap * map_
A pointer to the gamemap class used in the current level.
bool terrain_matches(const t_translation::terrain_code &tcode, const t_translation::ter_list &terrains) const
Checks whether a terrain code matches a given list of terrain codes.
bool start_animation(building_rule &rule)
Starts the animation on a rule.
const imagelist * get_terrain_at(const map_location &loc, const std::string &tod, TERRAIN_TYPE const terrain_type)
Returns a vector of strings representing the images to load & blit together to get the built content ...
static const int UNITPOS
The position of unit graphics in a tile.
bool load_images(building_rule &rule)
Load images and tests for validity of a rule.
tilemap tile_map_
The tile_map_ for the current level, which is filled by the build_terrains_ method to contain "tiles"...
void apply_rule(const building_rule &rule, const map_location &loc)
Applies a rule at a given location: applies the result of a matching rule at a given location: attach...
void set_draw_border(bool do_draw)
void rotate(terrain_constraint &constraint, int angle)
"Rotates" a constraint from a rule.
void rebuild_all()
Performs a complete rebuild of the list of terrain graphics attached to a map.
std::multimap< int, map_location > anchormap
void add_rotated_rules(building_ruleset &rules, building_rule &tpl, const std::string &rotations)
Adds a set of rules to a ruleset, from a template rule which spans 6 rotations (or less if some of th...
void replace_rotate_tokens(rule_image_variant &variant, int angle, const std::vector< std::string > &replacement)
Replaces, in a given rule_variant_image, rotation tokens with their values.
TERRAIN_TYPE
Used as a parameter for the get_terrain_at function.
@ BACKGROUND
Represents terrains which are to be drawn behind unit sprites.
@ FOREGROUND
Represents terrains which are to be drawn in front of them.
std::vector< rule_image > rule_imagelist
A shorthand notation for a vector of rule_images.
terrain_by_type_map terrain_by_type_
A map representing all locations whose terrain is of a given type.
static const game_config_view * rules_cfg_
Config used to parse global terrain rules.
void parse_global_config(const game_config_view &cfg)
void reload_map()
Updates internals that cache map size.
void replace_rotate_tokens(std::string &s, int angle, const std::vector< std::string > &replacement)
Replaces, in a given string, rotation tokens with their values.
terrain_builder(const config &level, const gamemap *map, const std::string &offmap_image, bool draw_border)
Constructor for the terrain_builder class.
Functions to load and save images from/to disk.
static const std::string br
bool terrain_matches(const terrain_code &src, const terrain_code &dest)
Tests whether a specific terrain matches an expression, for matching rules see above.
std::vector< terrain_code > ter_list
Encapsulates the map of the game.
This structure can be used for matching terrain strings.
A terrain string which is converted to a terrain is a string with 1 or 2 layers the layers are separa...
The in-memory representation of a [terrain_graphics] WML rule.
int precedence
Ordering relation between the rules.
map_location modulo_constraints
Used to constrain locations to ones with coordinates that are multiples of the "mod_x" and "mod_y" pa...
map_location location_constraints
The location on which this map may match.
int probability
The probability of this rule to match, when all conditions are met.
unsigned int get_hash() const
bool operator<(const building_rule &that) const
constraint_set constraints
The set of [tile] constraints of this rule.
std::vector< std::string > has_flag
rule_image_variant(const std::string &image_string, const std::string &variations, const std::chrono::milliseconds &random_start=std::chrono::milliseconds{-1})
Constructor for the normal default case.
std::chrono::milliseconds random_start
Specify the allowed amount of random shift (in milliseconds) applied to the animation start time,...
std::vector< animated< image::locator > > images
An animated image locator built according to the image string.
std::set< std::string > tods
The Time of Day associated to this variant (if any)
std::string image_string
A string representing either the filename for an image, or a list of images, with an optional timing ...
std::string variations
A semi-solon separated list of string used to replace.
Each terrain_graphics rule is associated a set of images, which are applied on the terrain if the rul...
int basex
The position of the image base (that is, the point where the image reaches the floor) for vertical la...
bool is_background() const
bool global_image
Set to true if the image was defined as a child of the [terrain_graphics] tag, set to false if it was...
int layer
The layer of the image for horizontal layering.
std::vector< rule_image_variant > variants
A list of variants for this image.
int center_x
The position where the center of the image base should be.
The in-memory representation of a [tile] WML rule inside of a [terrain_graphics] WML rule.
t_translation::ter_match terrain_types_match
std::vector< std::string > set_flag
std::vector< std::string > has_flag
bool no_draw
Whether to actually draw the images onto this hex or not.
std::vector< std::string > no_flag
Represent a rule_image applied with a random seed.
bool operator<(const rule_image_rand &o) const
sort by layer first then by basey
const rule_image * operator->() const
Represents a tile of the game map, with all associated builder-specific parameters: flags,...
std::string last_tod
The time-of-day to which the image caches correspond.
std::vector< rule_image_rand > images
The list of rule_images and random seeds associated to this tile.
std::vector< log_details > logs
void clear()
Clears all data in this tile, and resets the cache.
void rebuild_cache(const std::string &tod, logs *log=nullptr)
Rebuilds the whole image cache, for a given time-of-day.
imagelist images_background
The list of images which are behind the unit sprites, attached to this tile.
imagelist images_foreground
The list of images which are in front of the unit sprites, attached to this tile.
bool sorted_images
Indicates if 'images' is sorted.
std::set< std::string > flags
The list of flags present in this tile.
std::pair< const rule_image_rand *, const rule_image_variant * > log_details
static map_location::direction s