[[Castle and village graphics fixes]]

* Fixed (reverted?) castle tiles not being expanded to the border.
* Added support for animated flags on villages.
This commit is contained in:
Philippe Plantier 2004-07-25 21:26:28 +00:00
parent 0b2a519e47
commit eb70a354a3
5 changed files with 33 additions and 3 deletions

View file

@ -81,6 +81,21 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
unitDescriptionRect_.w = 0;
unitProfileRect_.w = 0;
//inits the flag list
flags_.reserve(teams_.size());
for(size_t i = 0; i != teams_.size(); ++i) {
std::string flag = game_config::flag_image;
std::string::size_type pos;
while((pos = flag.find("%d")) != std::string::npos) {
std::ostringstream s;
s << int(i+1);
flag.replace(pos, 2, s.str());
}
std::cerr << "Adding flag from " << flag << "\n";
flags_.push_back(animated<image::locator>(flag));
flags_.back().start_animation(0, animated<image::locator>::INFINITE_CYCLES);
}
//clear the screen contents
surface const disp(screen_.getSurface());
SDL_Rect area = screen_area();
@ -1720,9 +1735,12 @@ surface display::get_flag(gamemap::TERRAIN terrain, int x, int y)
for(size_t i = 0; i != teams_.size(); ++i) {
if(teams_[i].owns_village(loc) && (!fogged(x,y) || !shrouded(x,y) && !teams_[currentTeam_].is_enemy(i+1))) {
#if 0
char buf[50];
sprintf(buf,"terrain/flag-team%d.png",team::get_side_colour_index(int(i+1)));
return image::get_image(buf);
#endif
return image::get_image(flags_[i].get_current_frame());
}
}
@ -1916,14 +1934,21 @@ void display::invalidate_unit()
void display::invalidate_animations()
{
bool animate_flags = false;
gamemap::location topleft;
gamemap::location bottomright;
get_visible_hex_bounds(topleft, bottomright);
for(int i = 0; i < flags_.size(); ++i) {
flags_[i].update_current_frame();
if(flags_[i].frame_changed())
animate_flags = true;
}
for(int x = topleft.x; x <= bottomright.x; ++x) {
for(int y = topleft.y; y <= bottomright.y; ++y) {
gamemap::location loc(x,y);
if(builder_.update_animation(loc))
if(builder_.update_animation(loc) || (map_.is_village(loc) && animate_flags))
invalidated_.insert(loc);
}
}

View file

@ -495,6 +495,9 @@ private:
//variables for help strings
int help_string_;
//animated flags for each team
std::vector<animated<image::locator> > flags_;
};
//an object which will lock the display for the duration of its lifetime.

View file

@ -47,6 +47,7 @@ namespace game_config
std::string partmoved_energy_image = "partmoved-energy.png";
std::string enemy_energy_image = "enemy-energy.png";
std::string ally_energy_image = "ally-energy.png";
std::string flag_image = "terrain/flag-team%d.png";
std::string dot_image = "misc/dot.png";
std::string cross_image = "misc/cross.png";
@ -114,6 +115,7 @@ namespace game_config
partmoved_energy_image = v["partmoved_energy_image"];
enemy_energy_image = v["enemy_energy_image"];
ally_energy_image = v["ally_energy_image"];
flag_image = v["flag_image"];
cross_image = v["cross_image"];
dot_image = v["dot_image"];

View file

@ -38,7 +38,7 @@ namespace game_config
extern std::string game_icon, game_title, game_logo, title_music, map_image, rightside_image, rightside_image_bot,
moved_energy_image, unmoved_energy_image, partmoved_energy_image,
enemy_energy_image,ally_energy_image,
enemy_energy_image,ally_energy_image,flag_image,
dot_image,cross_image,
foot_left_nw,foot_left_n,foot_right_nw,foot_right_n,
missile_n_image,missile_ne_image,terrain_mask_image,observer_image,

View file

@ -306,7 +306,7 @@ gamemap::TERRAIN gamemap::get_terrain(const gamemap::location& loc) const
TERRAIN used_terrain = 0;
int terrain_count = 0;
for(int i = 0; i != nitems; ++i) {
if(items[i] != used_terrain && !is_village(items[i]) && !is_keep(items[i]) && !is_castle(items[i])) {
if(items[i] != used_terrain && !is_village(items[i]) && !is_keep(items[i])) {
const int c = std::count(items+i+1,items+nitems,items[i]) + 1;
if(c > terrain_count) {
used_terrain = items[i];