Continue putting display::get_location_rect to good use
This commit is contained in:
parent
3e464cb856
commit
a832ed8b2e
3 changed files with 14 additions and 23 deletions
|
@ -2632,9 +2632,7 @@ void display::draw_invalidated()
|
|||
}
|
||||
|
||||
for(const map_location& loc : invalidated_) {
|
||||
const auto [xpos, ypos] = get_location(loc);
|
||||
|
||||
rect hex_rect(xpos, ypos, zoom_, zoom_);
|
||||
rect hex_rect = get_location_rect(loc);
|
||||
if(!hex_rect.overlaps(clip_rect)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -500,21 +500,16 @@ void terrain_label::calculate_shroud()
|
|||
|
||||
SDL_Rect terrain_label::get_rect() const
|
||||
{
|
||||
SDL_Rect rect {0, 0, 0, 0};
|
||||
|
||||
display* disp = display::get_singleton();
|
||||
if(!disp) {
|
||||
return rect;
|
||||
return sdl::empty_rect;
|
||||
}
|
||||
|
||||
int hex_size = disp->hex_size();
|
||||
SDL_Rect res = disp->get_location_rect(loc_);
|
||||
res.x += disp->hex_size() / 4;
|
||||
res.w -= disp->hex_size() / 2;
|
||||
|
||||
rect.x = disp->get_location_x(loc_) + hex_size / 4;
|
||||
rect.y = disp->get_location_y(loc_);
|
||||
rect.h = disp->hex_size();
|
||||
rect.w = disp->hex_size() - hex_size / 2;
|
||||
|
||||
return rect;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int scale_to_map_zoom(int val)
|
||||
|
|
|
@ -266,19 +266,17 @@ void unit_drawer::redraw_unit(const unit& u) const
|
|||
const auto [xsrc, ysrc] = disp.get_location(loc);
|
||||
const auto [xdst, ydst] = disp.get_location(dst);
|
||||
|
||||
// FIXME: double check whether the shift amount accounts for zoom level
|
||||
rect unit_rect = disp.get_location_rect(loc).shifted_by(0, adjusted_params.y);
|
||||
|
||||
// We draw bars only if wanted, visible on the map view
|
||||
bool draw_bars = ac.draw_bars_ ;
|
||||
if (draw_bars) {
|
||||
rect unit_rect {xsrc, ysrc +adjusted_params.y, hex_size, hex_size};
|
||||
draw_bars = unit_rect.overlaps(disp.map_outside_area());
|
||||
}
|
||||
if(ac.draw_bars_ && unit_rect.overlaps(disp.map_outside_area())) {
|
||||
|
||||
// Always show the ellipse for selected units
|
||||
if(draw_bars && (prefs::get().show_side_colors() || is_selected_hex)) {
|
||||
draw_ellipses(u, adjusted_params);
|
||||
}
|
||||
// Always show the ellipse for selected units
|
||||
if(prefs::get().show_side_colors() || is_selected_hex) {
|
||||
draw_ellipses(u, adjusted_params);
|
||||
}
|
||||
|
||||
if(draw_bars) {
|
||||
const auto& type_cfg = u.type().get_cfg();
|
||||
const auto& cfg_offset_x = type_cfg["bar_offset_x"];
|
||||
const auto& cfg_offset_y = type_cfg["bar_offset_y"];
|
||||
|
|
Loading…
Add table
Reference in a new issue