fixed wrong positioning of script GUI windows with the GUI_Multiple flag on startup (#1477)

GUI_Multiple windows are supposed to be updated from the root window in a full refresh. However, they also had the "dirty" flag set (that is only used for non GUI_Multiple windows after the initial startup), but they did not unset it when updating.
So they were first updated with the correct parent width (full screen) and then, because of the dirty flag, were updated again like a non GUI_Multiple window with the parent's size. That was incorrect. Only another update would then fix it again (because the "dirty" flag would then have been unset).
shapetextures
David Dormagen 2015-12-27 15:47:46 +01:00
parent b2f299cc9d
commit 65dc58c77d
1 changed files with 7 additions and 3 deletions

View File

@ -1745,6 +1745,9 @@ bool C4ScriptGuiWindow::UpdateLayout(C4TargetFacet &cgo, float parentWidth, floa
// never show scrollbar on non-cropping windows
if ((style & C4ScriptGuiWindowStyleFlag::NoCrop) || !C4GUI::ScrollWindow::IsScrollingNecessary())
pScrollBar->SetVisibility(false);
// The "dirty" flag is unset here. Note that it's only used for non "multiple"-style windows after startup.
// The "multiple"-style windows are updated together when the root window does a full refresh.
mainWindowNeedsLayoutUpdate = false;
return true;
}
@ -1781,17 +1784,18 @@ bool C4ScriptGuiWindow::Draw(C4TargetFacet &cgo, int32_t player, C4Rect *current
return false;
}
const int32_t &style = props[C4ScriptGuiWindowPropertyName::style].GetInt();
if (mainWindowNeedsLayoutUpdate)
{
assert(GetParent() && (static_cast<C4ScriptGuiWindow*>(GetParent())->IsRoot()));
assert(isMainWindow);
assert(!(style & C4ScriptGuiWindowStyleFlag::Multiple) && "\"Multiple\"-style window not updated by a full refresh of the root window.");
C4ScriptGuiWindow * parent = static_cast<C4ScriptGuiWindow*>(GetParent());
UpdateLayout(cgo, parent->rcBounds.Wdt, parent->rcBounds.Hgt);
mainWindowNeedsLayoutUpdate = false;
assert(!mainWindowNeedsLayoutUpdate);
}
const int32_t &style = props[C4ScriptGuiWindowPropertyName::style].GetInt();
const int32_t outDrawX = cgo.X + cgo.TargetX + rcBounds.x;
const int32_t outDrawY = cgo.Y + cgo.TargetY + rcBounds.y;
const int32_t outDrawWdt = rcBounds.Wdt;