Theme: added [main_map_border] show_border= key to control whether map borders draw
Fixes #2272.
This commit is contained in:
parent
ca17047d07
commit
9f22a56370
7 changed files with 24 additions and 6 deletions
|
@ -64,6 +64,8 @@ Version 1.13.11:
|
|||
* Fixed crash when modifying an existing friend entry in Preferences.
|
||||
* Fixed players being unable to start campaigns in MP mode.
|
||||
* Added confirmation prompt when clearing map labels.
|
||||
* Added show_border= key to the [main_map_border] to control whether map
|
||||
borders draw. Right now this is utilized in the cutscene themes.
|
||||
* WFL Engine:
|
||||
* A new string insert() function has been added, similar to replace()
|
||||
* WML Engine:
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
[/main_map_border]
|
||||
#enddef
|
||||
|
||||
# TODO: cutscene themes aren't meant to have a border
|
||||
#define CUTSCENE_THEME_BACKGROUND
|
||||
[main_map_border]
|
||||
border_size = 0.5
|
||||
background_image = "terrain/off-map/background.png~CS(-255,-255,-255)"
|
||||
tile_image = "alphamask.png"
|
||||
show_border = no
|
||||
[/main_map_border]
|
||||
#enddef
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ display::display(const display_context * dc, std::weak_ptr<wb::manager> wb, repo
|
|||
theme_(theme_cfg, screen_.screen_area()),
|
||||
zoom_index_(0),
|
||||
fake_unit_man_(new fake_unit_manager(*this)),
|
||||
builder_(new terrain_builder(level, (dc_ ? &dc_->map() : nullptr), theme_.border().tile_image)),
|
||||
builder_(new terrain_builder(level, (dc_ ? &dc_->map() : nullptr), theme_.border().tile_image, theme_.border().show_border)),
|
||||
minimap_(nullptr),
|
||||
minimap_location_(sdl::empty_rect),
|
||||
redrawMinimap_(false),
|
||||
|
@ -277,6 +277,7 @@ display::~display()
|
|||
|
||||
void display::set_theme(config theme_cfg) {
|
||||
theme_ = theme(theme_cfg, screen_.screen_area());
|
||||
builder_->set_draw_border(theme_.border().show_border);
|
||||
menu_buttons_.clear();
|
||||
action_buttons_.clear();
|
||||
create_buttons();
|
||||
|
|
|
@ -241,11 +241,12 @@ const terrain_builder::tile& terrain_builder::tilemap::operator[](const map_loca
|
|||
return tiles_[(loc.x + 2) + (loc.y + 2) * (x_ + 4)];
|
||||
}
|
||||
|
||||
terrain_builder::terrain_builder(const config& level, const gamemap* m, const std::string& offmap_image)
|
||||
terrain_builder::terrain_builder(const config& level, const gamemap* m, const std::string& offmap_image, bool draw_border)
|
||||
: tilewidth_(game_config::tile_size)
|
||||
, map_(m)
|
||||
, tile_map_(m ? map().w() : 0, m ? map().h() : 0)
|
||||
, terrain_by_type_()
|
||||
, draw_border_(draw_border)
|
||||
{
|
||||
image::precache_file_existence("terrain/");
|
||||
|
||||
|
@ -1142,7 +1143,7 @@ void terrain_builder::build_terrains()
|
|||
|
||||
// Flag all hexes according to whether they're on the border or not,
|
||||
// to make it easier for WML to draw the borders
|
||||
if(!map().on_board(loc)) {
|
||||
if(draw_border_&& !map().on_board(loc)) {
|
||||
tile_map_[loc].flags.insert("_border");
|
||||
} else {
|
||||
tile_map_[loc].flags.insert("_board");
|
||||
|
|
|
@ -81,13 +81,15 @@ public:
|
|||
* off map image (see add_off_map_rule()).
|
||||
* This image automatically gets the 'terrain/' prefix
|
||||
* and '.png' suffix
|
||||
* @para draw_border Whether the map border flag should be set to allow
|
||||
* its drawing.
|
||||
*/
|
||||
terrain_builder(const config& level, const gamemap* map, const std::string& offmap_image);
|
||||
terrain_builder(const config& level, const gamemap* map, const std::string& offmap_image, bool draw_border);
|
||||
|
||||
/** Set the config where we will parse the global terrain rules.
|
||||
* This also flushes the terrain rules cache.
|
||||
*
|
||||
* @param cfg The main grame configuration object, where the
|
||||
* @param cfg The main game configuration object, where the
|
||||
* [terrain_graphics] rule reside.
|
||||
*/
|
||||
static void set_terrain_rules_cfg(const config& cfg);
|
||||
|
@ -148,6 +150,11 @@ public:
|
|||
|
||||
void rebuild_cache_all();
|
||||
|
||||
void set_draw_border(bool do_draw)
|
||||
{
|
||||
draw_border_ = do_draw;
|
||||
}
|
||||
|
||||
/**
|
||||
* An image variant. The in-memory representation of the [variant]
|
||||
* WML tag of the [image] WML tag. When an image only has one variant,
|
||||
|
@ -844,6 +851,9 @@ private:
|
|||
*/
|
||||
terrain_by_type_map terrain_by_type_;
|
||||
|
||||
/** Whether the map border should be drawn. */
|
||||
bool draw_border_;
|
||||
|
||||
/** Parsed terrain rules. Cached between instances */
|
||||
static building_ruleset building_rules_;
|
||||
|
||||
|
|
|
@ -297,6 +297,7 @@ theme::border_t::border_t()
|
|||
: size(0.0)
|
||||
, background_image()
|
||||
, tile_image()
|
||||
, show_border(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -304,6 +305,7 @@ theme::border_t::border_t(const config& cfg)
|
|||
: size(cfg["border_size"].to_double())
|
||||
, background_image(cfg["background_image"])
|
||||
, tile_image(cfg["tile_image"])
|
||||
, show_border(cfg["show_border"].to_bool(true))
|
||||
{
|
||||
VALIDATE(size >= 0.0 && size <= 0.5, _("border_size should be between 0.0 and 0.5."));
|
||||
}
|
||||
|
|
|
@ -85,6 +85,8 @@ class theme
|
|||
|
||||
std::string background_image;
|
||||
std::string tile_image;
|
||||
|
||||
bool show_border;
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
Loading…
Add table
Reference in a new issue