66 } |
66 } |
67 |
67 |
68 static void SignListWndProc(Window *w, WindowEvent *e) |
68 static void SignListWndProc(Window *w, WindowEvent *e) |
69 { |
69 { |
70 switch (e->event) { |
70 switch (e->event) { |
71 case WE_PAINT: { |
71 case WE_PAINT: { |
72 int y = 16; // offset from top of widget |
72 if (_sign_sort_dirty) GlobalSortSignList(); |
73 |
73 |
74 if (_sign_sort_dirty) |
74 SetVScrollCount(w, _num_sign_sort); |
75 GlobalSortSignList(); |
75 |
76 |
76 SetDParam(0, w->vscroll.count); |
77 SetVScrollCount(w, _num_sign_sort); |
77 DrawWindowWidgets(w); |
78 |
78 |
79 SetDParam(0, w->vscroll.count); |
79 /* No signs? */ |
80 DrawWindowWidgets(w); |
80 int y = 16; // offset from top of widget |
81 |
81 if (w->vscroll.count == 0) { |
82 /* No signs? */ |
82 DrawString(2, y, STR_304A_NONE, TC_FROMSTRING); |
83 if (w->vscroll.count == 0) { |
83 return; |
84 DrawString(2, y, STR_304A_NONE, TC_FROMSTRING); |
84 } |
85 return; |
|
86 } |
|
87 |
|
88 { |
|
89 uint16 i; |
|
90 |
85 |
91 /* Start drawing the signs */ |
86 /* Start drawing the signs */ |
92 for (i = w->vscroll.pos; i < w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) { |
87 for (uint16 i = w->vscroll.pos; i < w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) { |
93 const Sign *si = _sign_sort[i]; |
88 const Sign *si = _sign_sort[i]; |
94 |
89 |
95 if (si->owner != OWNER_NONE) |
90 if (si->owner != OWNER_NONE) DrawPlayerIcon(si->owner, 4, y + 1); |
96 DrawPlayerIcon(si->owner, 4, y + 1); |
|
97 |
91 |
98 SetDParam(0, si->index); |
92 SetDParam(0, si->index); |
99 DrawString(22, y, STR_SIGN_NAME, TC_YELLOW); |
93 DrawString(22, y, STR_SIGN_NAME, TC_YELLOW); |
100 y += 10; |
94 y += 10; |
101 } |
95 } |
102 } |
|
103 } break; |
|
104 |
|
105 case WE_CLICK: { |
|
106 switch (e->we.click.widget) { |
|
107 case 3: { |
|
108 uint32 id_v = (e->we.click.pt.y - 15) / 10; |
|
109 const Sign *si; |
|
110 |
|
111 if (id_v >= w->vscroll.cap) |
|
112 return; |
|
113 |
|
114 id_v += w->vscroll.pos; |
|
115 |
|
116 if (id_v >= w->vscroll.count) |
|
117 return; |
|
118 |
|
119 si = _sign_sort[id_v]; |
|
120 ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); |
|
121 } break; |
96 } break; |
122 } |
97 |
123 } break; |
98 case WE_CLICK: |
124 |
99 if (e->we.click.widget == 3) { |
125 case WE_RESIZE: |
100 uint32 id_v = (e->we.click.pt.y - 15) / 10; |
126 w->vscroll.cap += e->we.sizing.diff.y / 10; |
101 |
127 break; |
102 if (id_v >= w->vscroll.cap) return; |
|
103 id_v += w->vscroll.pos; |
|
104 if (id_v >= w->vscroll.count) return; |
|
105 |
|
106 const Sign *si = _sign_sort[id_v]; |
|
107 ScrollMainWindowToTile(TileVirtXY(si->x, si->y)); |
|
108 } |
|
109 break; |
|
110 |
|
111 case WE_RESIZE: |
|
112 w->vscroll.cap += e->we.sizing.diff.y / 10; |
|
113 break; |
128 } |
114 } |
129 } |
115 } |
130 |
116 |
131 static const Widget _sign_list_widget[] = { |
117 static const Widget _sign_list_widget[] = { |
132 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
118 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
312 QuerySignEditWndProc |
295 QuerySignEditWndProc |
313 }; |
296 }; |
314 |
297 |
315 void ShowRenameSignWindow(const Sign *si) |
298 void ShowRenameSignWindow(const Sign *si) |
316 { |
299 { |
317 Window *w; |
|
318 |
|
319 /* Delete all other edit windows and the save window */ |
300 /* Delete all other edit windows and the save window */ |
320 DeleteWindowById(WC_QUERY_STRING, 0); |
301 DeleteWindowById(WC_QUERY_STRING, 0); |
321 DeleteWindowById(WC_SAVELOAD, 0); |
302 DeleteWindowById(WC_SAVELOAD, 0); |
322 |
303 |
323 w = AllocateWindowDesc(&_query_sign_edit_desc); |
304 Window *w = AllocateWindowDesc(&_query_sign_edit_desc); |
324 |
305 |
325 WP(w, editsign_d).caption = STR_280B_EDIT_SIGN_TEXT; |
306 WP(w, editsign_d).caption = STR_280B_EDIT_SIGN_TEXT; |
326 WP(w, editsign_d).afilter = CS_ALPHANUMERAL; |
307 WP(w, editsign_d).afilter = CS_ALPHANUMERAL; |
327 w->LowerWidget(QUERY_EDIT_SIGN_WIDGET_TEXT); |
308 w->LowerWidget(QUERY_EDIT_SIGN_WIDGET_TEXT); |
328 |
309 |
329 UpdateSignEditWindow(w, si); |
310 UpdateSignEditWindow(w, si); |
330 } |
311 } |
331 |
|
332 |
|
333 |
|