* Returns a pointer to the (alphabetically) previous or next sign of the current sign. * @param next false if the previous sign is wanted, true if the next sign is wanted * @return pointer to the previous/next sign */
| 437 | * @return pointer to the previous/next sign |
| 438 | */ |
| 439 | const Sign *PrevNextSign(bool next) |
| 440 | { |
| 441 | /* Rebuild the sign list */ |
| 442 | this->signs.ForceRebuild(); |
| 443 | this->signs.NeedResort(); |
| 444 | this->BuildSignsList(); |
| 445 | this->SortSignsList(); |
| 446 | |
| 447 | /* Search through the list for the current sign, excluding |
| 448 | * - the first sign if we want the previous sign or |
| 449 | * - the last sign if we want the next sign */ |
| 450 | size_t end = this->signs.size() - (next ? 1 : 0); |
| 451 | for (uint i = next ? 0 : 1; i < end; i++) { |
| 452 | if (this->cur_sign == this->signs[i]->index) { |
| 453 | /* We've found the current sign, so return the sign before/after it */ |
| 454 | return this->signs[i + (next ? 1 : -1)]; |
| 455 | } |
| 456 | } |
| 457 | /* If we haven't found the current sign by now, return the last/first sign */ |
| 458 | return next ? this->signs.front() : this->signs.back(); |
| 459 | } |
| 460 | |
| 461 | std::string GetWidgetString(WidgetID widget, StringID stringid) const override |
| 462 | { |
no test coverage detected