MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / nextAvailableWidgetInRange

Method nextAvailableWidgetInRange

src/OpenLoco/src/Ui/Window.cpp:1356–1387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1354 }
1355
1356 WidgetIndex_t Window::nextAvailableWidgetInRange(WidgetIndex_t minIndex, WidgetIndex_t maxIndex)
1357 {
1358 WidgetIndex_t activeIndex = firstActivatedWidgetInRange(minIndex, maxIndex);
1359 if (activeIndex == kWidgetIndexNull)
1360 {
1361 return activeIndex;
1362 }
1363
1364 // Offset, wrapping around if needed.
1365 activeIndex += 1;
1366 if (activeIndex > maxIndex)
1367 {
1368 activeIndex = minIndex;
1369 }
1370
1371 for (WidgetIndex_t i = activeIndex; i <= maxIndex; i++)
1372 {
1373 if (this->isDisabled(i) || this->widgets[i].type == WidgetType::empty || this->widgets[i].hidden)
1374 {
1375 // Wrap around (while compensating for next iteration)
1376 if (i == maxIndex)
1377 {
1378 i = minIndex - 1;
1379 }
1380 continue;
1381 }
1382
1383 return i;
1384 }
1385
1386 return -1;
1387 }
1388}

Callers 3

nextTrackPieceFunction · 0.80
nextSlopeFunction · 0.80
nextTabFunction · 0.80

Calls 1

isDisabledMethod · 0.95

Tested by

no test coverage detected