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

Method prevAvailableWidgetInRange

src/OpenLoco/src/Ui/Window.cpp:1323–1354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1321 }
1322
1323 WidgetIndex_t Window::prevAvailableWidgetInRange(WidgetIndex_t minIndex, WidgetIndex_t maxIndex)
1324 {
1325 WidgetIndex_t activeIndex = firstActivatedWidgetInRange(minIndex, maxIndex);
1326 if (activeIndex == -1)
1327 {
1328 return activeIndex;
1329 }
1330
1331 // Offset, wrapping around if needed.
1332 activeIndex -= 1;
1333 if (activeIndex < minIndex)
1334 {
1335 activeIndex = maxIndex;
1336 }
1337
1338 for (WidgetIndex_t i = activeIndex; i >= minIndex; i--)
1339 {
1340 if (this->isDisabled(i) || this->widgets[i].type == WidgetType::empty || this->widgets[i].hidden)
1341 {
1342 // Wrap around (while compensating for next iteration)
1343 if (i == minIndex)
1344 {
1345 i = maxIndex + 1;
1346 }
1347 continue;
1348 }
1349
1350 return i;
1351 }
1352
1353 return -1;
1354 }
1355
1356 WidgetIndex_t Window::nextAvailableWidgetInRange(WidgetIndex_t minIndex, WidgetIndex_t maxIndex)
1357 {

Callers 3

previousTrackPieceFunction · 0.80
previousSlopeFunction · 0.80
previousTabFunction · 0.80

Calls 1

isDisabledMethod · 0.95

Tested by

no test coverage detected