| 2083 | } |
| 2084 | |
| 2085 | void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override |
| 2086 | { |
| 2087 | switch (widget) { |
| 2088 | case WID_SVP_PRESET_LIST: { |
| 2089 | auto it = this->vscroll->GetScrolledItemFromWidget(this->presets, pt.y, this, WID_SVP_PRESET_LIST); |
| 2090 | if (it != this->presets.end()) { |
| 2091 | this->selected = it - this->presets.begin(); |
| 2092 | this->presetname_editbox.text.Assign(*it); |
| 2093 | this->SetWidgetDirty(WID_SVP_PRESET_LIST); |
| 2094 | this->SetWidgetDirty(WID_SVP_EDITBOX); |
| 2095 | } |
| 2096 | break; |
| 2097 | } |
| 2098 | |
| 2099 | case WID_SVP_SAVE: { |
| 2100 | Window *w = FindWindowById(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE); |
| 2101 | if (w != nullptr) { |
| 2102 | auto text = this->presetname_editbox.text.GetText(); |
| 2103 | if (!text.empty()) w->OnQueryTextFinished(std::string{text}); |
| 2104 | } |
| 2105 | this->Close(); |
| 2106 | break; |
| 2107 | } |
| 2108 | } |
| 2109 | } |
| 2110 | |
| 2111 | void OnResize() override |
| 2112 | { |
nothing calls this directly
no test coverage detected