Make previous commit about fog/shroud variants less config heavy.
Simply scan which images exist as we already do for transitions.
This commit is contained in:
parent
a658bd23bb
commit
a5c24198b4
5 changed files with 31 additions and 11 deletions
|
@ -98,9 +98,7 @@
|
|||
unreachable_image="terrain/darken.png"
|
||||
|
||||
fog_prefix="terrain/fog"
|
||||
fog_variants="terrain/fog1.png,terrain/fog2.png,terrain/fog3.png"
|
||||
shroud_prefix="terrain/void"
|
||||
shroud_variants="terrain/void.png"
|
||||
|
||||
observer_image="misc/eye.png"
|
||||
tod_bright_image="misc/tod-bright.png"
|
||||
|
|
|
@ -107,6 +107,8 @@ display::display(CVideo& video, const gamemap* map, const config& theme_cfg, con
|
|||
mouseover_hex_overlay_(NULL),
|
||||
tod_hex_mask1(NULL),
|
||||
tod_hex_mask2(NULL),
|
||||
fog_images_(),
|
||||
shroud_images_(),
|
||||
selectedHex_(),
|
||||
mouseoverHex_(),
|
||||
keys_(),
|
||||
|
@ -129,6 +131,9 @@ display::display(CVideo& video, const gamemap* map, const config& theme_cfg, con
|
|||
screen_.lock_updates(true);
|
||||
}
|
||||
|
||||
fill_images_list(game_config::fog_prefix, fog_images_);
|
||||
fill_images_list(game_config::shroud_prefix, shroud_images_);
|
||||
|
||||
set_idle_anim_rate(preferences::idle_anim_rate());
|
||||
|
||||
std::fill(reportRects_,reportRects_+reports::NUM_REPORTS,empty_rect);
|
||||
|
@ -140,7 +145,25 @@ display::~display()
|
|||
{
|
||||
}
|
||||
|
||||
const std::string& display::get_variant(const std::vector<std::string>& variants, const map_location &loc)
|
||||
void display::fill_images_list(const std::string& prefix, std::vector<std::string>& images)
|
||||
{
|
||||
// search prefix.png, prefix1.png, prefix2.png ...
|
||||
for(int i=0; ; ++i){
|
||||
std::ostringstream s;
|
||||
s << prefix;
|
||||
if(i != 0)
|
||||
s << i;
|
||||
s << ".png";
|
||||
if(image::exists(s.str()))
|
||||
images.push_back(s.str());
|
||||
else if(i>0)
|
||||
break;
|
||||
}
|
||||
if (images.empty())
|
||||
images.push_back("");
|
||||
}
|
||||
|
||||
const std::string& display::get_variant(const std::vector<std::string>& variants, const map_location &loc) const
|
||||
{
|
||||
//TODO use better noise function
|
||||
return variants[abs(loc.x + loc.y) % variants.size()];
|
||||
|
@ -1967,11 +1990,11 @@ void display::draw_hex(const map_location& loc) {
|
|||
if(shrouded(loc)) {
|
||||
// We apply void also on off-map tiles
|
||||
// to shroud the half-hexes too
|
||||
const std::string& shroud_image = get_variant(game_config::shroud_variants, loc);
|
||||
const std::string& shroud_image = get_variant(shroud_images_, loc);
|
||||
drawing_buffer_add(LAYER_FOG_SHROUD, loc, tblit(xpos, ypos,
|
||||
image::get_image(shroud_image, image_type)));
|
||||
} else if(fogged(loc)) {
|
||||
const std::string& fog_image = get_variant(game_config::fog_variants, loc);
|
||||
const std::string& fog_image = get_variant(fog_images_, loc);
|
||||
drawing_buffer_add(LAYER_FOG_SHROUD, loc, tblit(xpos, ypos,
|
||||
image::get_image(fog_image, image_type)));
|
||||
}
|
||||
|
|
|
@ -546,7 +546,9 @@ protected:
|
|||
|
||||
void scroll_to_xy(int screenxpos, int screenypos, SCROLL_TYPE scroll_type,bool force = true);
|
||||
|
||||
const std::string& get_variant(const std::vector<std::string>& variants, const map_location &loc);
|
||||
void fill_images_list(const std::string& prefix, std::vector<std::string>& images);
|
||||
|
||||
const std::string& get_variant(const std::vector<std::string>& variants, const map_location &loc) const;
|
||||
|
||||
CVideo& screen_;
|
||||
const gamemap* map_;
|
||||
|
@ -590,6 +592,8 @@ protected:
|
|||
// If we're transitioning from one time of day to the next,
|
||||
// then we will use these two masks on top of all hexes when we blit.
|
||||
surface tod_hex_mask1, tod_hex_mask2;
|
||||
std::vector<std::string> fog_images_;
|
||||
std::vector<std::string> shroud_images_;
|
||||
|
||||
map_location selectedHex_;
|
||||
map_location mouseoverHex_;
|
||||
|
|
|
@ -66,8 +66,6 @@ namespace game_config
|
|||
|
||||
std::string shroud_prefix;
|
||||
std::string fog_prefix;
|
||||
std::vector<std::string> fog_variants;
|
||||
std::vector<std::string> shroud_variants;
|
||||
|
||||
std::string energy_image = "misc/bar-energy.png";
|
||||
std::string moved_ball_image = "misc/ball-moved.png";
|
||||
|
@ -205,8 +203,6 @@ namespace game_config
|
|||
|
||||
shroud_prefix = v["shroud_prefix"].str();
|
||||
fog_prefix = v["fog_prefix"].str();
|
||||
fog_variants = utils::split(v["fog_variants"].str());
|
||||
shroud_variants = utils::split(v["shroud_variants"].str());
|
||||
|
||||
observer_image = v["observer_image"].str();
|
||||
tod_bright_image = v["tod_bright_image"].str();
|
||||
|
|
|
@ -82,7 +82,6 @@ namespace game_config
|
|||
extern std::vector<Uint32> red_green_scale;
|
||||
extern std::vector<Uint32> red_green_scale_text;
|
||||
|
||||
extern std::vector<std::string> fog_variants, shroud_variants;
|
||||
extern std::vector<std::string> foot_speed_prefix;
|
||||
extern std::string foot_teleport_enter, foot_teleport_exit;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue