| 665 | } |
| 666 | |
| 667 | void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override |
| 668 | { |
| 669 | switch (widget) { |
| 670 | case WID_SL_SORT_BYNAME: // Sort save names by name |
| 671 | _savegame_sort_order = (_savegame_sort_order == SORT_BY_NAME) ? |
| 672 | SORT_BY_NAME | SORT_DESCENDING : SORT_BY_NAME; |
| 673 | _savegame_sort_dirty = true; |
| 674 | this->SetDirty(); |
| 675 | break; |
| 676 | |
| 677 | case WID_SL_SORT_BYDATE: // Sort save names by date |
| 678 | _savegame_sort_order = (_savegame_sort_order == SORT_BY_DATE) ? |
| 679 | SORT_BY_DATE | SORT_DESCENDING : SORT_BY_DATE; |
| 680 | _savegame_sort_dirty = true; |
| 681 | this->SetDirty(); |
| 682 | break; |
| 683 | |
| 684 | case WID_SL_HOME_BUTTON: // OpenTTD 'button', jumps to OpenTTD directory |
| 685 | FiosBrowseTo(&o_dir); |
| 686 | this->InvalidateData(SLIWD_RESCAN_FILES); |
| 687 | break; |
| 688 | |
| 689 | case WID_SL_LOAD_BUTTON: { |
| 690 | if (this->selected == nullptr || _load_check_data.HasErrors()) break; |
| 691 | |
| 692 | _file_to_saveload.Set(*this->selected); |
| 693 | |
| 694 | if (this->abstract_filetype == FT_HEIGHTMAP) { |
| 695 | this->Close(); |
| 696 | ShowHeightmapLoad(); |
| 697 | } else if (this->abstract_filetype == FT_TOWN_DATA) { |
| 698 | this->Close(); |
| 699 | LoadTownData(); |
| 700 | } else if (!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) { |
| 701 | _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME; |
| 702 | ClearErrorMessages(); |
| 703 | this->Close(); |
| 704 | } |
| 705 | break; |
| 706 | } |
| 707 | |
| 708 | case WID_SL_NEWGRF_INFO: |
| 709 | if (_load_check_data.HasNewGrfs()) { |
| 710 | ShowNewGRFSettings(false, false, false, _load_check_data.grfconfig); |
| 711 | } |
| 712 | break; |
| 713 | |
| 714 | case WID_SL_MISSING_NEWGRFS: |
| 715 | if (!_network_available) { |
| 716 | ShowErrorMessage(GetEncodedString(STR_NETWORK_ERROR_NOTAVAILABLE), {}, WL_ERROR); |
| 717 | } else if (_load_check_data.HasNewGrfs()) { |
| 718 | ShowMissingContentWindow(_load_check_data.grfconfig); |
| 719 | } |
| 720 | break; |
| 721 | |
| 722 | case WID_SL_DRIVES_DIRECTORIES_LIST: { // Click the listbox |
| 723 | auto it = this->vscroll->GetScrolledItemFromWidget(this->display_list, pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WidgetDimensions::scaled.inset.top); |
| 724 | if (it == this->display_list.end()) return; |
nothing calls this directly
no test coverage detected