mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-30 01:47:13 +00:00
Fixed units not being animated when partly out of the screen.
This commit is contained in:
parent
dac3983838
commit
fe2ae37e9e
@ -1532,6 +1532,16 @@ bool display::tile_on_screen(const map_location& loc)
|
||||
return !outside_area(map_area(), x, y);
|
||||
}
|
||||
|
||||
bool display::tile_nearly_on_screen(const map_location& loc)
|
||||
{
|
||||
int x = get_location_x(loc);
|
||||
int y = get_location_y(loc);
|
||||
const SDL_Rect &area = map_area();
|
||||
int hw = hex_width(), hs = hex_size();
|
||||
return !(x + hs >= area.x - hw && x < area.x + area.w - hw &&
|
||||
y + hs >= area.y - hs && y < area.y - area.h - hs);
|
||||
}
|
||||
|
||||
void display::scroll_to_xy(int screenxpos, int screenypos, SCROLL_TYPE scroll_type, bool force)
|
||||
{
|
||||
if(!force && !preferences::scroll_to_action()) return;
|
||||
|
@ -434,6 +434,9 @@ public:
|
||||
/** Check if a tile is fully on screen. */
|
||||
bool tile_on_screen(const map_location& loc);
|
||||
|
||||
/** Checks if location @a loc or one of the adjacent tiles is visible on screen. */
|
||||
bool tile_nearly_on_screen(const map_location &loc);
|
||||
|
||||
/**
|
||||
* Draws invalidated items.
|
||||
* If update is true, will also copy the display to the frame buffer.
|
||||
|
@ -890,10 +890,10 @@ void game_display::invalidate_animations()
|
||||
for (unit_map::iterator u = units_.begin(),
|
||||
u_end = units_.end(); u != u_end; ++u)
|
||||
{
|
||||
if (!tile_on_screen(u->first)) continue;
|
||||
if (!tile_nearly_on_screen(u->first)) continue;
|
||||
u->second.refresh(*this, u->first);
|
||||
}
|
||||
if (temp_unit_ && tile_on_screen(temp_unit_loc_))
|
||||
if (temp_unit_ && tile_nearly_on_screen(temp_unit_loc_))
|
||||
temp_unit_->refresh(*this, temp_unit_loc_);
|
||||
bool new_inval = true;
|
||||
while(new_inval) {
|
||||
@ -901,10 +901,10 @@ void game_display::invalidate_animations()
|
||||
for (unit_map::iterator u = units_.begin(),
|
||||
u_end = units_.end(); u != u_end; ++u)
|
||||
{
|
||||
if (!tile_on_screen(u->first)) continue;
|
||||
if (!tile_nearly_on_screen(u->first)) continue;
|
||||
new_inval |= u->second.invalidate(u->first);
|
||||
}
|
||||
if (temp_unit_ && tile_on_screen(temp_unit_loc_)) {
|
||||
if (temp_unit_ && tile_nearly_on_screen(temp_unit_loc_)) {
|
||||
//new_inval |=invalidate(temp_unit_loc_);
|
||||
new_inval |=temp_unit_->invalidate(temp_unit_loc_);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user