Codechange: Add and use GetScrolledItemFromWidget to get a list item.
This function returns an iterator, either to the selected item or the container's end. This makes handling the result more robust as indices are not used.
This commit is contained in:
@@ -235,10 +235,10 @@ struct SignListWindow : Window, SignList {
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SIL_LIST: {
|
||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.top);
|
||||
if (id_v == INT_MAX) return;
|
||||
auto it = this->vscroll->GetScrolledItemFromWidget(this->signs, pt.y, this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.top);
|
||||
if (it == this->signs.end()) return;
|
||||
|
||||
const Sign *si = this->signs[id_v];
|
||||
const Sign *si = *it;
|
||||
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user