| 510 | } |
| 511 | |
| 512 | void ScriptList::Sort(SorterType sorter, bool ascending) |
| 513 | { |
| 514 | this->modifications++; |
| 515 | |
| 516 | if (sorter != SORT_BY_VALUE && sorter != SORT_BY_ITEM) return; |
| 517 | if (sorter == this->sorter_type && ascending == this->sort_ascending) return; |
| 518 | |
| 519 | switch (sorter) { |
| 520 | case SORT_BY_ITEM: |
| 521 | if (ascending) { |
| 522 | this->sorter = std::make_unique<ScriptListSorterItemAscending>(this); |
| 523 | } else { |
| 524 | this->sorter = std::make_unique<ScriptListSorterItemDescending>(this); |
| 525 | } |
| 526 | break; |
| 527 | |
| 528 | case SORT_BY_VALUE: |
| 529 | if (ascending) { |
| 530 | this->sorter = std::make_unique<ScriptListSorterValueAscending>(this); |
| 531 | } else { |
| 532 | this->sorter = std::make_unique<ScriptListSorterValueDescending>(this); |
| 533 | } |
| 534 | break; |
| 535 | |
| 536 | default: NOT_REACHED(); |
| 537 | } |
| 538 | this->sorter_type = sorter; |
| 539 | this->sort_ascending = ascending; |
| 540 | this->initialized = false; |
| 541 | } |
| 542 | |
| 543 | void ScriptList::AddList(ScriptList *list) |
| 544 | { |
no test coverage detected