33 #include "table/strings.h"
44 static const Sign *last_sign;
61 DEBUG(misc, 3,
"Building sign list");
66 FOR_ALL_SIGNS(si) *this->signs.
Append() = si;
77 static char buf_cache[64];
81 GetString(buf, STR_SIGN_NAME,
lastof(buf));
83 if (*b != last_sign) {
86 GetString(buf_cache, STR_SIGN_NAME,
lastof(buf_cache));
91 return r != 0 ? r : ((*a)->index - (*b)->index);
99 this->last_sign = NULL;
108 GetString(buf1, STR_SIGN_NAME,
lastof(buf1));
141 const Sign *SignList::last_sign = NULL;
171 this->BuildSortSignList();
191 if (this->signs.
NeedRebuild()) this->BuildSortSignList();
201 if (this->vscroll->
GetCount() == 0) {
208 uint icon_left = 4 + (rtl ? r.right - this->
text_offset : r.left);
214 const Sign *si = this->signs[i];
219 DrawString(text_left, text_right, y, STR_SIGN_NAME, TC_YELLOW);
237 if (id_v == INT_MAX)
return;
239 const Sign *si = this->signs[id_v];
245 if (this->signs.
Length() >= 1) {
246 const Sign *si = this->signs[0];
279 size->height += padding.height;
280 size->width += padding.width;
305 void BuildSortSignList()
308 this->BuildSignsList();
312 this->SortSignsList();
317 this->BuildSortSignList();
355 static Hotkey signlist_hotkeys[] = {
361 static const NWidgetPart _nested_sign_list_widgets[] = {
375 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_SIL_FILTER_TEXT),
SetMinimalSize(80, 12),
SetResize(1, 0),
SetFill(1, 0),
SetPadding(2, 2, 2, 2),
376 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
394 _nested_sign_list_widgets,
lengthof(_nested_sign_list_widgets),
395 &SignListWindow::hotkeys
405 return AllocateWindowDescFront<SignListWindow>(&_sign_list_desc, 0);
428 this->name_editbox.caption = STR_EDIT_SIGN_CAPTION;
434 UpdateSignEditWindow(si);
438 void UpdateSignEditWindow(
const Sign *si)
441 if (si->name != NULL) {
443 this->name_editbox.text.
Assign(STR_SIGN_NAME);
448 this->cur_sign = si->
index;
464 this->BuildSignsList();
465 this->SortSignsList();
470 uint end = this->signs.
Length() - (next ? 1 : 0);
471 for (uint i = next ? 0 : 1; i < end; i++) {
472 if (this->cur_sign == this->signs[i]->index) {
474 return this->signs[i + (next ? 1 : -1)];
478 return this->signs[next ? 0 : this->signs.
Length() - 1];
485 SetDParam(0, this->name_editbox.caption);
500 this->BuildSignsList();
501 this->SortSignsList();
505 UpdateSignEditWindow(si);
516 if (
RenameSign(this->cur_sign, this->name_editbox.text.
buf))
break;
526 static const NWidgetPart _nested_query_sign_edit_widgets[] = {
532 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_QES_TEXT),
SetMinimalSize(256, 12),
SetDataTip(STR_EDIT_SIGN_SIGN_OSKTITLE, STR_NULL),
SetPadding(2, 2, 2, 2),
548 _nested_query_sign_edit_widgets,
lengthof(_nested_query_sign_edit_widgets)
584 if (w != NULL && w->cur_sign == sign)
delete w;