Made the offmap tiles themable in the map, the minimap stays as is.

This commit is contained in:
Mark de Wever 2007-08-12 14:22:41 +00:00
parent b4c9f875fe
commit 60bb1b1b71
10 changed files with 77 additions and 13 deletions

View file

@ -15,6 +15,9 @@
# the proper way to calculate the propabilities is described here
# http://www.wesnoth.org/wiki/Terrain_Graphics_Probability
# NOTE the terrain _off^_usr gets its definition from the code since it's
# themable
#-----------------------------------------------------------------
# forest/pine<->Castle|Encampment special cases, also used by some other
# terrain
@ -862,6 +865,4 @@
{TERRAIN_ADJACENT -560 Chw (!,Chw,Chr) water/coast}
{TERRAIN_ADJACENT -570 (!,Chr,Chw) Chr flat/grass}
{TERRAIN_BASE _off^* off-map/alpha}
{TERRAIN_BASE_DEFAULT void}

View file

@ -57,6 +57,11 @@
border_size = 0.5
background_image = "terrain/off-map/background.png"
# this image is processed by the terrain matching code so should be
# in the terrains directory and should ommit the 'terrain/' prefix
# and the '.png' suffix
tile_image = "off-map/alpha"
corner_image_top_left = "terrain/off-map/fade_corner_top_left.png"
corner_image_bottom_left = "terrain/off-map/fade_corner_bottom_left.png"

View file

@ -93,6 +93,11 @@
border_size = 0.5
background_image = "terrain/off-map/background.png"
# this image is processed by the terrain matching code so should be
# in the terrains directory and should ommit the 'terrain/' prefix
# and the '.png' suffix
tile_image = "off-map/alpha"
corner_image_top_left = "terrain/off-map/fade_corner_top_left.png"
corner_image_bottom_left = "terrain/off-map/fade_corner_bottom_left.png"

View file

@ -492,6 +492,11 @@
border_size = 0.5
background_image = "terrain/off-map/background.png"
# this image is processed by the terrain matching code so should be
# in the terrains directory and should ommit the 'terrain/' prefix
# and the '.png' suffix
tile_image = "off-map/alpha"
corner_image_top_left = "terrain/off-map/fade_corner_top_left.png"
corner_image_bottom_left = "terrain/off-map/fade_corner_bottom_left.png"

View file

@ -48,6 +48,11 @@
border_size = 0.5
background_image = "terrain/off-map/background.png"
# this image is processed by the terrain matching code so should be
# in the terrains directory and should ommit the 'terrain/' prefix
# and the '.png' suffix
tile_image = "off-map/alpha"
corner_image_top_left = "terrain/off-map/fade_corner_top_left.png"
corner_image_bottom_left = "terrain/off-map/fade_corner_bottom_left.png"

View file

@ -127,8 +127,9 @@ const terrain_builder::tile& terrain_builder::tilemap::operator[] (const gamemap
return map_[(loc.x+1) + (loc.y+1)*(x_+2)];
}
terrain_builder::terrain_builder(const config& cfg, const config& level, const gamemap& gmap) :
map_(gmap), tile_map_(gmap.w(), gmap.h())
terrain_builder::terrain_builder(const config& cfg, const config& level,
const gamemap& map, const std::string& offmap_image) :
map_(map), tile_map_(map.w(), map.h())
{
// make sure there's nothing left in the cache since it might
// give problems
@ -136,8 +137,9 @@ terrain_builder::terrain_builder(const config& cfg, const config& level, const g
parse_config(cfg);
parse_config(level);
add_off_map_rule(offmap_image);
build_terrains();
//rebuild_terrain(gamemap::location(0,0));
}
const terrain_builder::imagelist *terrain_builder::get_terrain_at(const gamemap::location &loc,
@ -759,6 +761,33 @@ void terrain_builder::parse_config(const config &cfg)
}
void terrain_builder::add_off_map_rule(const std::string& image)
{
// build a config object
config cfg;
cfg.add_child("terrain_graphics");
config *item = cfg.child("terrain_graphics");
(*item).add_child("tile");
config *tile = (*item).child("tile");
(*tile)["x"] = "0";
(*tile)["y"] = "0";
(*tile)["type"] = t_translation::write_letter(t_translation::OFF_MAP_USER);
(*tile).add_child("image");
config *tile_image = (*tile).child("image");
(*tile_image)["layer"] = "-1000";
(*tile_image)["name"] = image;
(*item)["probability"] = "100";
(*item)["no_flag"] = "base";
(*item)["set_flag"] = "base";
// parse the object
parse_config(cfg);
}
bool terrain_builder::rule_matches(const terrain_builder::building_rule &rule,
const gamemap::location &loc, const int rule_index, const bool check_loc) const
{

View file

@ -50,14 +50,19 @@ public:
/** Constructor for the terrain_builder class.
*
* @param cfg The main grame configuration object, where the
* [terrain_graphics] rule reside.
* @param level A level (scenario)-specific configuration file,
* containing scenario-specific [terrain_graphics] rules.
* @param gmap A properly-initialized gamemap object representing the
* current terrain map.
* @param cfg The main grame configuration object, where the
* [terrain_graphics] rule reside.
* @param level A level (scenario)-specific configuration file,
* containing scenario-specific [terrain_graphics] rules.
* @param map A properly-initialized gamemap object representing the
* current terrain map.
* @param offmap_image The filename of the image which will be used as
* off map image (see add_off_map_rule()). This image
* automatically gets the 'terrain/' prefix and '.png'
* suffix
*/
terrain_builder(const config& cfg, const config &level, const gamemap& gmap);
terrain_builder(const config& cfg, const config &level,
const gamemap& map, const std::string& offmap_image);
/** Returns a vector of strings representing the images to load & blit
* together to get the built content for this tile.
@ -580,6 +585,13 @@ private:
*/
void parse_config(const config &cfg);
/**
* adds a builder rule for the _off^_usr tile, this tile only has 1 image
*
* @param image The filename of the image
*/
void add_off_map_rule(const std::string& image);
/**
* Checks whether a terrain letter matches a given list of terrain letters
*

View file

@ -62,7 +62,7 @@ namespace {
display::display(CVideo& video, const gamemap& map, const config& theme_cfg, const config& cfg, const config& level) :
screen_(video), map_(map), viewpoint_(NULL), xpos_(0), ypos_(0),
theme_(theme_cfg,screen_area()), zoom_(DefaultZoom),
builder_(cfg, level, map),
builder_(cfg, level, map, theme_.border().tile_image),
minimap_(NULL), redrawMinimap_(false), redraw_background_(true),
invalidateAll_(true), grid_(false),
diagnostic_label_(0), panelsDrawn_(false),

View file

@ -280,6 +280,7 @@ theme::tborder::tborder(const config& cfg) :
size(lexical_cast_default<double>(cfg["border_size"], 0.0)),
background_image(cfg["background_image"]),
tile_image(cfg["tile_image"]),
corner_image_top_left(cfg["corner_image_top_left"]),
corner_image_bottom_left(cfg["corner_image_bottom_left"]),

View file

@ -72,6 +72,7 @@ class theme
double size;
std::string background_image;
std::string tile_image;
std::string corner_image_top_left;
std::string corner_image_bottom_left;