@@ -28,49 +28,49 @@ StringID DropDownListStringItem::String(
StringID DropDownListParamStringItem::String() const
{
for (uint i = 0; i < lengthof(this->decode_params); i++) SetDParam(i, this->decode_params[i]);
return this->string;
}
/**
* Delete all items of a drop down list and the list itself
* @param list List to delete.
*/
static void DeleteDropDownList(DropDownList *list)
for (DropDownList::iterator it = list->begin(); it != list->end(); ++it) {
DropDownListItem *item = *it;
delete item;
delete list;
struct dropdown_d {
WindowClass parent_wnd_class;
WindowNumber parent_wnd_num;
byte parent_button;
DropDownList *list;
byte selected_index;
int selected_index;
byte click_delay;
bool drag_mode;
int scrolling;
};
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d));
static const Widget _dropdown_menu_widgets[] = {
{ WWT_PANEL, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL},
{ WWT_SCROLLBAR, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WIDGETS_END},
static int GetDropDownItem(const Window *w)
if (GetWidgetFromPos(w, _cursor.pos.x - w->left, _cursor.pos.y - w->top) < 0) return -1;
int y = _cursor.pos.y - w->top - 2 + w->vscroll.pos * 10;
if (y < 0) return -1;
uint selected_row = y / 10;
const DropDownList *list = WP(w, dropdown_d).list;
if (selected_row >= list->size()) return -1;
Status change: