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

Method BuildDropDownList

src/story_gui.cpp:246–262  ·  view source on GitHub ↗

* Builds the page selector drop down list. */

Source from the content-addressed store, hash-verified

244 * Builds the page selector drop down list.
245 */
246 DropDownList BuildDropDownList() const
247 {
248 DropDownList list;
249 uint16_t page_num = 1;
250 for (const StoryPage *p : this->story_pages) {
251 bool current_page = p->index == this->selected_page_id;
252 if (!p->title.empty()) {
253 list.push_back(MakeDropDownListStringItem(p->title.GetDecodedString(), p->index.base(), current_page));
254 } else {
255 /* No custom title => use a generic page title with page number. */
256 list.push_back(MakeDropDownListStringItem(GetString(STR_STORY_BOOK_GENERIC_PAGE_ITEM, page_num), p->index.base(), current_page));
257 }
258 page_num++;
259 }
260
261 return list;
262 }
263
264 /**
265 * Get the width available for displaying content on the page panel.

Callers 1

OnClickMethod · 0.95

Calls 6

push_backMethod · 0.80
GetDecodedStringMethod · 0.80
GetStringFunction · 0.70
emptyMethod · 0.45
baseMethod · 0.45

Tested by

no test coverage detected