MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ConstructWindow

Method ConstructWindow

src/picker_gui.cpp:177–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177void PickerWindow::ConstructWindow()
178{
179 this->CreateNestedTree();
180
181 /* Test if pickers should be active.*/
182 bool is_active = this->callbacks.IsActive();
183
184 this->preview_height = std::max(this->callbacks.preview_height, PREVIEW_HEIGHT);
185
186 /* Functionality depends on widgets being present, not window class. */
187 this->has_class_picker = is_active && this->GetWidget<NWidgetBase>(WID_PW_CLASS_LIST) != nullptr && this->callbacks.HasClassChoice();
188 this->has_type_picker = is_active && this->GetWidget<NWidgetBase>(WID_PW_TYPE_MATRIX) != nullptr;
189
190 if (this->has_class_picker) {
191 this->GetWidget<NWidgetCore>(WID_PW_CLASS_LIST)->SetToolTip(this->callbacks.GetClassTooltip());
192
193 this->querystrings[WID_PW_CLASS_FILTER] = &this->class_editbox;
194 } else {
195 if (auto *nwid = this->GetWidget<NWidgetStacked>(WID_PW_CLASS_SEL); nwid != nullptr) {
196 /* Check the container orientation. MakeNWidgets adds an additional NWID_VERTICAL container so we check the grand-parent. */
197 bool is_vertical = (nwid->parent->parent->type == NWID_VERTICAL);
198 nwid->SetDisplayedPlane(is_vertical ? SZSP_HORIZONTAL : SZSP_VERTICAL);
199 }
200 }
201
202 this->class_editbox.cancel_button = QueryString::ACTION_CLEAR;
203 this->class_string_filter.SetFilterTerm(this->class_editbox.text.GetText());
204 this->class_string_filter.callbacks = &this->callbacks;
205
206 this->classes.SetListing(this->callbacks.class_last_sorting);
207 this->classes.SetFiltering(this->callbacks.class_last_filtering);
208 this->classes.SetSortFuncs(_class_sorter_funcs);
209 this->classes.SetFilterFuncs(_class_filter_funcs);
210
211 /* Update saved type information. */
212 this->callbacks.saved = this->callbacks.UpdateSavedItems(this->callbacks.saved);
213
214 /* Clear used type information. */
215 this->callbacks.used.clear();
216
217 if (this->has_type_picker) {
218 /* Populate used type information. */
219 this->callbacks.FillUsedItems(this->callbacks.used);
220
221 SetWidgetDisabledState(WID_PW_MODE_ALL, !this->callbacks.HasClassChoice());
222
223 this->GetWidget<NWidgetCore>(WID_PW_TYPE_ITEM)->SetToolTip(this->callbacks.GetTypeTooltip());
224
225 auto *matrix = this->GetWidget<NWidgetMatrix>(WID_PW_TYPE_MATRIX);
226 matrix->SetScrollbar(this->GetScrollbar(WID_PW_TYPE_SCROLL));
227
228 this->querystrings[WID_PW_TYPE_FILTER] = &this->type_editbox;
229 } else {
230 if (auto *nwid = this->GetWidget<NWidgetStacked>(WID_PW_TYPE_SEL); nwid != nullptr) {
231 /* Check the container orientation. MakeNWidgets adds an additional NWID_VERTICAL container so we check the grand-parent. */
232 bool is_vertical = (nwid->parent->parent->type == NWID_VERTICAL);
233 nwid->SetDisplayedPlane(is_vertical ? SZSP_HORIZONTAL : SZSP_VERTICAL);
234 }

Callers 12

NewGRFTextfileWindowMethod · 0.45
BuildHouseWindowMethod · 0.45
BuildObjectWindowMethod · 0.45
BaseSetTextfileWindowMethod · 0.45
ScriptTextfileWindowMethod · 0.45
ContentTextfileWindowMethod · 0.45

Calls 15

InvalidateDataMethod · 0.95
CreateNestedTreeMethod · 0.80
SetToolTipMethod · 0.80
SetDisplayedPlaneMethod · 0.80
SetFilterTermMethod · 0.80
SetListingMethod · 0.80
SetFilteringMethod · 0.80
SetSortFuncsMethod · 0.80
SetFilterFuncsMethod · 0.80
SetScrollbarMethod · 0.80
GetScrollbarMethod · 0.80

Tested by

no test coverage detected