Prevent rendering of hidden windows.

This commit is contained in:
Charles Cook 2016-07-05 12:54:28 -04:00
parent f3786b3130
commit 19d873fedf
2 changed files with 32 additions and 2 deletions

View File

@ -146,7 +146,7 @@ void window_dispatch_update_all()
void window_update_all_viewports()
{
for (rct_window *w = g_window_list; w < RCT2_NEW_WINDOW; w++)
if (w->viewport != NULL)
if (w->viewport != NULL && window_is_visible(w))
viewport_update_position(w);
}
@ -1476,10 +1476,12 @@ void window_draw(rct_drawpixelinfo *dpi, rct_window *w, int left, int top, int r
if (left >= right) return;
if (top >= bottom) return;
if (!window_is_visible(w)) return;
// Draw the window in this region
for (rct_window *v = w; v < RCT2_NEW_WINDOW; v++) {
// Don't draw overlapping opaque windows, they won't have changed
if (w == v || (v->flags & WF_TRANSPARENT)) {
if ((w == v || (v->flags & WF_TRANSPARENT)) && window_is_visible(v)) {
window_draw_single(dpi, v, left, top, right, bottom);
}
}
@ -2477,3 +2479,29 @@ void window_update_textbox()
window_event_textinput_call(w, gCurrentTextBox.widget_index, gTextBoxInput);
}
}
bool window_is_visible(rct_window* w)
{
// only consider viewports, consider the main window always visible
if (w == NULL || w->viewport == NULL || w->classification == WC_MAIN_WINDOW)
{
// default to previous behavior
return true;
}
// start from the window above the current
for (rct_window *w_other = (w+1); w_other < RCT2_NEW_WINDOW; w_other++)
{
// if covered by a higher window, no rendering needed
if (w_other->x <= w->x
&& w_other->y <= w->y
&& w_other->x + w_other->width >= w->x + w->width
&& w_other->y + w_other->height >= w->y + w->height)
{
return false;
}
}
// default to previous behavior
return true;
}

View File

@ -729,6 +729,8 @@ void window_cancel_textbox();
void window_update_textbox_caret();
void window_update_textbox();
bool window_is_visible(rct_window* w);
bool land_tool_is_active();
//Cheat: in-game land ownership editor