mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-28 15:50:26 +00:00
Display: make fog/shroud drawing buffer registration more readable
This commit is contained in:
parent
c21b049d52
commit
ae119c1d8a
@ -421,12 +421,6 @@ void display::fill_images_list(const std::string& prefix, std::vector<std::strin
|
|||||||
images.emplace_back();
|
images.emplace_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& display::get_variant(const std::vector<std::string>& variants, const map_location &loc)
|
|
||||||
{
|
|
||||||
//TODO use better noise function
|
|
||||||
return variants[std::abs(loc.x + loc.y) % variants.size()];
|
|
||||||
}
|
|
||||||
|
|
||||||
void display::rebuild_all()
|
void display::rebuild_all()
|
||||||
{
|
{
|
||||||
builder_->rebuild_all();
|
builder_->rebuild_all();
|
||||||
@ -2717,17 +2711,15 @@ void display::draw_hex(const map_location& loc)
|
|||||||
|
|
||||||
// Apply shroud, fog and linger overlay
|
// Apply shroud, fog and linger overlay
|
||||||
|
|
||||||
if(is_shrouded) {
|
if(is_shrouded || fogged(loc)) {
|
||||||
// We apply void also on off-map tiles to shroud the half-hexes too
|
// TODO: better noise function
|
||||||
|
const auto get_variant = [&loc](const std::vector<std::string>& variants) -> const auto& {
|
||||||
|
return variants[std::abs(loc.x + loc.y) % variants.size()];
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::string& img = get_variant(is_shrouded ? shroud_images_ : fog_images_);
|
||||||
drawing_buffer_add(drawing_layer::fog_shroud, loc,
|
drawing_buffer_add(drawing_layer::fog_shroud, loc,
|
||||||
[tex = image::get_texture(get_variant(shroud_images_, loc), image::TOD_COLORED)](const rect& dest) {
|
[tex = image::get_texture(img, image::TOD_COLORED)](const rect& dest) { draw::blit(tex, dest); });
|
||||||
draw::blit(tex, dest);
|
|
||||||
});
|
|
||||||
} else if(fogged(loc)) {
|
|
||||||
drawing_buffer_add(drawing_layer::fog_shroud, loc,
|
|
||||||
[tex = image::get_texture(get_variant(fog_images_, loc), image::TOD_COLORED)](const rect& dest) {
|
|
||||||
draw::blit(tex, dest);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_shrouded) {
|
if(!is_shrouded) {
|
||||||
|
@ -732,8 +732,6 @@ protected:
|
|||||||
|
|
||||||
static void fill_images_list(const std::string& prefix, std::vector<std::string>& images);
|
static void fill_images_list(const std::string& prefix, std::vector<std::string>& images);
|
||||||
|
|
||||||
static const std::string& get_variant(const std::vector<std::string>& variants, const map_location &loc);
|
|
||||||
|
|
||||||
std::size_t currentTeam_;
|
std::size_t currentTeam_;
|
||||||
bool dont_show_all_; //const team *viewpoint_;
|
bool dont_show_all_; //const team *viewpoint_;
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user