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

Method ShowDateDropDown

src/date_gui.cpp:69–100  ·  view source on GitHub ↗

* Helper function to construct the dropdown. * @param widget the dropdown widget to create the dropdown for */

Source from the content-addressed store, hash-verified

67 * @param widget the dropdown widget to create the dropdown for
68 */
69 void ShowDateDropDown(WidgetID widget)
70 {
71 int selected;
72 DropDownList list;
73
74 switch (widget) {
75 default: NOT_REACHED();
76
77 case WID_SD_DAY:
78 for (uint i = 0; i < 31; i++) {
79 list.push_back(MakeDropDownListStringItem(STR_DAY_NUMBER_1ST + i, i + 1));
80 }
81 selected = this->date.day;
82 break;
83
84 case WID_SD_MONTH:
85 for (uint i = 0; i < 12; i++) {
86 list.push_back(MakeDropDownListStringItem(STR_MONTH_JAN + i, i));
87 }
88 selected = this->date.month;
89 break;
90
91 case WID_SD_YEAR:
92 for (TimerGameEconomy::Year i = this->min_year; i <= this->max_year; i++) {
93 list.push_back(MakeDropDownListStringItem(GetString(STR_JUST_INT, i), i.base()));
94 }
95 selected = this->date.year.base();
96 break;
97 }
98
99 ShowDropDownList(this, std::move(list), selected, widget);
100 }
101
102 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
103 {

Callers

nothing calls this directly

Calls 6

NOT_REACHEDFunction · 0.85
ShowDropDownListFunction · 0.85
push_backMethod · 0.80
GetStringFunction · 0.70
baseMethod · 0.45

Tested by

no test coverage detected