1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-27 16:39:09 +00:00

Codechange: Use unified NWidgetContainer methods instead of duplicating.

Most NWidgetContainer derivatives implemented Draw() and GetWidgetFromPos()
the same way. Move this these to NWidgetContainer itself to avoid repeating.
This commit is contained in:
2023-10-19 19:58:43 +01:00
committed by Peter Nelson
parent af41c5cb4e
commit 59a2abd298
5 changed files with 22 additions and 69 deletions

View File

@@ -161,24 +161,6 @@ public:
}
}
}
void Draw(const Window *w) override
{
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
child_wid->Draw(w);
}
}
NWidgetCore *GetWidgetFromPos(int x, int y) override
{
if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr;
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y);
if (nwid != nullptr) return nwid;
}
return nullptr;
}
};
class NetworkGameWindow : public Window {