mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Update window's widget lookup map when switching displayed plane.
parent
3d591c2094
commit
8c22690ce1
|
@ -1268,8 +1268,13 @@ void NWidgetStacked::AssignSizePosition(SizingType sizing, int x, int y, uint gi
|
||||||
|
|
||||||
void NWidgetStacked::FillWidgetLookup(WidgetLookup &widget_lookup)
|
void NWidgetStacked::FillWidgetLookup(WidgetLookup &widget_lookup)
|
||||||
{
|
{
|
||||||
|
/* We need to update widget_lookup later. */
|
||||||
|
this->widget_lookup = &widget_lookup;
|
||||||
|
|
||||||
if (this->index >= 0) widget_lookup[this->index] = this;
|
if (this->index >= 0) widget_lookup[this->index] = this;
|
||||||
NWidgetContainer::FillWidgetLookup(widget_lookup);
|
NWidgetContainer::FillWidgetLookup(widget_lookup);
|
||||||
|
/* In case widget IDs are repeated, make sure Window::GetWidget works on displayed widgets. */
|
||||||
|
if (static_cast<size_t>(this->shown_plane) < this->children.size()) this->children[shown_plane]->FillWidgetLookup(widget_lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NWidgetStacked::Draw(const Window *w)
|
void NWidgetStacked::Draw(const Window *w)
|
||||||
|
@ -1300,6 +1305,8 @@ bool NWidgetStacked::SetDisplayedPlane(int plane)
|
||||||
{
|
{
|
||||||
if (this->shown_plane == plane) return false;
|
if (this->shown_plane == plane) return false;
|
||||||
this->shown_plane = plane;
|
this->shown_plane = plane;
|
||||||
|
/* In case widget IDs are repeated, make sure Window::GetWidget works on displayed widgets. */
|
||||||
|
if (static_cast<size_t>(this->shown_plane) < this->children.size()) this->children[shown_plane]->FillWidgetLookup(*this->widget_lookup);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -497,6 +497,8 @@ public:
|
||||||
|
|
||||||
int shown_plane; ///< Plane being displayed (for #NWID_SELECTION only).
|
int shown_plane; ///< Plane being displayed (for #NWID_SELECTION only).
|
||||||
const WidgetID index; ///< If non-negative, index in the #Window::widget_lookup.
|
const WidgetID index; ///< If non-negative, index in the #Window::widget_lookup.
|
||||||
|
private:
|
||||||
|
WidgetLookup *widget_lookup; ///< Window's widget lookup, updated in SetDisplayedPlane().
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Nested widget container flags, */
|
/** Nested widget container flags, */
|
||||||
|
|
Loading…
Reference in New Issue