The name of image files and variables of the attack indicator were very bad.

(misleading use of attack from/to and inverse use of direction)

Now use a simpler source/destination + direction of the attack and
rename the image files

Also make some simplification and comments about it.
This commit is contained in:
Ali El Gariani 2007-08-08 17:57:55 +00:00
parent 3076e23c9a
commit e4a8008707
14 changed files with 23 additions and 21 deletions

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 901 B

After

Width:  |  Height:  |  Size: 901 B

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 924 B

After

Width:  |  Height:  |  Size: 924 B

View file

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -292,7 +292,7 @@ void game_display::draw(bool update,bool force)
//we higlight hex under the mouse, origin of
//attack or under a selected unit
if (on_map && (*it == mouseoverHex_ || *it == attack_indicator_from_)) {
if (on_map && (*it == mouseoverHex_ || *it == attack_indicator_src_)) {
image_type = image::BRIGHTENED;
} else if (on_map && *it == selectedHex_) {
unit_map::iterator un = find_visible_unit(units_, *it, map_,
@ -348,9 +348,11 @@ void game_display::draw(bool update,bool force)
}
// draw reach_map information
// we remove the reachability mask of the unit
// that we want to attack
if (!reach_map_.empty() && !is_shrouded) {
reach_map::iterator reach = reach_map_.find(*it);
if (reach == reach_map_.end() && *it != attack_indicator_to_) {
if (reach == reach_map_.end() && *it != attack_indicator_dst_) {
tile_stack_append(image::get_image(game_config::unreachable_image,image::UNMASKED));
} else if (reach->second > 1) {
//FIXME: this is a temporary hack to render/flush
@ -383,14 +385,10 @@ void game_display::draw(bool update,bool force)
tile_stack_append(mouseover_hex_overlay_);
// draw the attack direction indicator
if(attack_indicator_to_.valid() && *it == attack_indicator_to_) {
const std::string dir = gamemap::location::write_direction(
attack_indicator_to_.get_relative_dir(attack_indicator_from_));
tile_stack_append(image::get_image("misc/attack-from-" + dir + ".png", image::UNMASKED));
} else if (attack_indicator_from_.valid() && *it == attack_indicator_from_) {
const std::string dir = gamemap::location::write_direction(
attack_indicator_from_.get_relative_dir(attack_indicator_to_));
tile_stack_append(image::get_image("misc/attack-to-" + dir + ".png", image::UNMASKED));
if(on_map && *it == attack_indicator_src_) {
tile_stack_append(image::get_image("misc/attack-indicator-src-" + attack_indicator_direction() + ".png", image::UNMASKED));
} else if (on_map && *it == attack_indicator_dst_) {
tile_stack_append(image::get_image("misc/attack-indicator-dst-" + attack_indicator_direction() + ".png", image::UNMASKED));
}
// apply shroud anf fog
@ -1102,17 +1100,17 @@ void game_display::remove_temporary_unit()
temp_unit_ = NULL;
}
void game_display::set_attack_indicator(const gamemap::location& from, const gamemap::location& to)
void game_display::set_attack_indicator(const gamemap::location& src, const gamemap::location& dst)
{
if (attack_indicator_from_ != from || attack_indicator_to_ != to) {
invalidate(attack_indicator_from_);
invalidate(attack_indicator_to_);
if (attack_indicator_src_ != src || attack_indicator_dst_ != dst) {
invalidate(attack_indicator_src_);
invalidate(attack_indicator_dst_);
attack_indicator_from_ = from;
attack_indicator_to_ = to;
attack_indicator_src_ = src;
attack_indicator_dst_ = dst;
invalidate(attack_indicator_from_);
invalidate(attack_indicator_to_);
invalidate(attack_indicator_src_);
invalidate(attack_indicator_dst_);
}
}

View file

@ -122,8 +122,12 @@ public:
void remove_temporary_unit();
// set the attack direction indicator
void set_attack_indicator(const gamemap::location& from, const gamemap::location& to);
void set_attack_indicator(const gamemap::location& src, const gamemap::location& dst);
void clear_attack_indicator();
//function to get attack direction suffix
const std::string attack_indicator_direction() const
{ return gamemap::location::write_direction(
attack_indicator_src_.get_relative_dir(attack_indicator_dst_)); }
//functions to add and remove overlays from locations. An overlay is an
//image that is displayed on top of the tile. One tile may have multiple
@ -194,8 +198,8 @@ private:
gamemap::location temp_unit_loc_;
//locations of the attack direction indicator's parts
gamemap::location attack_indicator_to_;
gamemap::location attack_indicator_from_;
gamemap::location attack_indicator_src_;
gamemap::location attack_indicator_dst_;
//function which finds the start and end rows on the energy bar image
//where white pixels are substituted for the colour of the energy