avoid halos on items being shown when the shroud is active.

Note the fix is a bit of a kludge so if somebody has a cleaner
solution, please make it so.  Changelog entry will follow, this fixes
bug #8523
This commit is contained in:
Mark de Wever 2007-02-22 20:31:06 +00:00
parent 27a8b48159
commit 19be24b40d
5 changed files with 32 additions and 10 deletions

View file

@ -2177,7 +2177,9 @@ void display::remove_temporary_unit()
}
void display::add_overlay(const gamemap::location& loc, const std::string& img, const std::string& halo)
{
const int halo_handle = halo::add(get_location_x(loc)+hex_size()/2,get_location_y(loc)+hex_size()/2,halo);
const int halo_handle = halo::add(get_location_x(loc) + hex_size() / 2,
get_location_y(loc) + hex_size() / 2, halo, loc);
const overlay item(img,halo,halo_handle);
overlays_.insert(overlay_map::value_type(loc,item));
}

View file

@ -35,7 +35,8 @@ display* disp = NULL;
class effect
{
public:
effect(int xpos, int ypos, const animated<std::string>::anim_description& img, ORIENTATION orientation,bool infinite);
effect(int xpos, int ypos, const animated<std::string>::anim_description& img,
const gamemap::location& loc, ORIENTATION, bool infinite);
void set_location(int x, int y);
@ -58,6 +59,7 @@ private:
double origzoom_, zoom_;
surface surf_, buffer_;
SDL_Rect rect_;
gamemap::location loc_;
};
std::map<int,effect> haloes;
@ -66,9 +68,11 @@ int halo_id = 1;
bool hide_halo = false;
effect::effect(int xpos, int ypos, const animated<std::string>::anim_description& img, ORIENTATION orientation,bool infinite)
: images_(img), orientation_(orientation), origx_(xpos), origy_(ypos), x_(xpos), y_(ypos),
origzoom_(disp->zoom()), zoom_(disp->zoom()), surf_(NULL), buffer_(NULL), rect_(empty_rect)
effect::effect(int xpos, int ypos, const animated<std::string>::anim_description& img,
const gamemap::location& loc, ORIENTATION orientation, bool infinite) :
images_(img), orientation_(orientation), origx_(xpos), origy_(ypos),
x_(xpos), y_(ypos), origzoom_(disp->zoom()), zoom_(disp->zoom()),
surf_(NULL), buffer_(NULL), rect_(empty_rect), loc_(loc)
{
wassert(disp != NULL);
// std::cerr << "Constructing halo sequence from image " << img << "\n";
@ -130,6 +134,10 @@ void effect::render()
if(disp == NULL) {
return;
}
if(loc_.x != -1 && loc_.y != -1 && disp->shrouded(loc_.x, loc_.y)) {
return;
}
images_.update_last_draw_time();
const std::string& img = current_image();
@ -218,7 +226,8 @@ halo_hider::~halo_hider()
unrender();
}
int add(int x, int y, const std::string& image, ORIENTATION orientation, bool infinite)
int add(int x, int y, const std::string& image, const gamemap::location& loc,
ORIENTATION orientation, bool infinite)
{
const int id = halo_id++;
animated<std::string>::anim_description image_vector;
@ -239,7 +248,7 @@ int add(int x, int y, const std::string& image, ORIENTATION orientation, bool in
image_vector.push_back(animated<std::string>::frame_description(time,std::string(str)));
}
haloes.insert(std::pair<int,effect>(id,effect(x,y,image_vector,orientation,infinite)));
haloes.insert(std::pair<int,effect>(id,effect(x,y,image_vector,loc,orientation,infinite)));
return id;
}

View file

@ -16,6 +16,7 @@
class display;
#include "map.hpp"
#include <string>
namespace halo
@ -44,7 +45,12 @@ enum ORIENTATION { NORMAL, HREVERSE, VREVERSE, HVREVERSE };
///centered on (x,y)
///returns the handle to the halo object
///0 is the invalid handle
int add(int x, int y, const std::string& image, ORIENTATION orientation=NORMAL, bool infinite=true);
//
// if the halo is attached to an item it needs to be hidden if the shroud is
// active. (Note it will be shown with the fog active.) If it's not attached
// to an iten the location should be set to -1, -1
int add(int x, int y, const std::string& image, const gamemap::location& loc,
ORIENTATION orientation=NORMAL, bool infinite=true);
///function to set the position of an existing haloing
///effect, according to its handle

View file

@ -1748,12 +1748,14 @@ void unit::redraw_unit(display& disp,gamemap::location hex)
unit_anim_halo_ = halo::add(x+d-static_cast<int>(current_frame.halo_x(anim_->get_current_frame_time())*disp.zoom()),
y+d+static_cast<int>(current_frame.halo_y(anim_->get_current_frame_time())*disp.zoom()),
current_frame.halo(anim_->get_current_frame_time()),
gamemap::location(-1, -1),
halo::HREVERSE);
} else {
const int d = disp.hex_size() / 2;
unit_anim_halo_ = halo::add(x+d+static_cast<int>(current_frame.halo_x(anim_->get_current_frame_time())*disp.zoom()),
y+d+static_cast<int>(current_frame.halo_y(anim_->get_current_frame_time())*disp.zoom()),
current_frame.halo(anim_->get_current_frame_time()));
current_frame.halo(anim_->get_current_frame_time()),
gamemap::location(-1, -1));
}
}
image::locator loc;
@ -1844,7 +1846,7 @@ void unit::redraw_unit(display& disp,gamemap::location hex)
disp.draw_unit(tmp_x, tmp_y -height_adjust, image, false, highlight_ratio,
blend_with, blend_ratio, submerge,ellipse_back,ellipse_front);
if(!unit_halo_ && !image_halo().empty()) {
unit_halo_ = halo::add(0,0,image_halo());
unit_halo_ = halo::add(0, 0, image_halo(), gamemap::location(-1, -1));
}
if(unit_halo_) {
const int d = disp.hex_size() / 2;

View file

@ -336,17 +336,20 @@ void unit_attack_ranged(display& disp, unit_map& units,
missile_halo = halo::add(posx+d+missile_frame.halo_x(missile_animation.get_current_frame_time()),
posy+d+missile_frame.halo_y(missile_animation.get_current_frame_time()),
missile_frame.halo(missile_animation.get_current_frame_time()),
gamemap::location(-1, -1),
orientation);
} else {
missile_halo = halo::add(posx+d-missile_frame.halo_x(missile_animation.get_current_frame_time()),
posy+d+missile_frame.halo_y(missile_animation.get_current_frame_time()),
missile_frame.halo(missile_animation.get_current_frame_time()),
gamemap::location(-1, -1),
orientation);
}
}
missile_frame_halo = halo::add(posx+d,
posy+d,
missile_image.get_filename(),
gamemap::location(-1, -1),
orientation);
}