author | bjarni |
Sun, 02 Jan 2005 17:23:04 +0000 | |
changeset 842 | ebfd36603ab9 |
parent 682 | 7f5de4abac85 |
child 845 | 0c66e26fecb2 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
193
diff
changeset
|
3 |
#include "table/strings.h" |
0 | 4 |
#include "window.h" |
5 |
#include "gfx.h" |
|
6 |
#include "viewport.h" |
|
7 |
||
8 |
static Point HandleScrollbarHittest(Scrollbar *sb, int top, int bottom) |
|
9 |
{ |
|
10 |
Point pt; |
|
11 |
int height, count, pos, cap; |
|
12 |
||
13 |
top += 10; |
|
14 |
bottom -= 9; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
15 |
|
0 | 16 |
height = (bottom - top); |
17 |
||
18 |
pos = sb->pos; |
|
19 |
count = sb->count; |
|
20 |
cap = sb->cap; |
|
21 |
||
22 |
if (count != 0) top += height * pos / count; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
23 |
|
0 | 24 |
if (cap > count) cap = count; |
25 |
if (count != 0) |
|
26 |
bottom -= (count - pos - cap) * height / count; |
|
27 |
||
28 |
pt.x = top; |
|
29 |
pt.y = bottom - 1; |
|
30 |
return pt; |
|
31 |
} |
|
32 |
||
33 |
/***************************************************** |
|
34 |
* Special handling for the scrollbar widget type. |
|
35 |
* Handles the special scrolling buttons and other |
|
36 |
* scrolling. |
|
37 |
* Parameters: |
|
38 |
* w - Window. |
|
39 |
* wi - Pointer to the scrollbar widget. |
|
40 |
* x - The X coordinate of the mouse click. |
|
41 |
* y - The Y coordinate of the mouse click. |
|
42 |
*/ |
|
43 |
||
44 |
void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y) |
|
45 |
{ |
|
46 |
int mi, ma, pos; |
|
47 |
Scrollbar *sb; |
|
48 |
||
842 | 49 |
switch (wi->type) { |
50 |
case WWT_SCROLLBAR: { |
|
51 |
// vertical scroller |
|
52 |
w->flags4 &= ~WF_HSCROLL; |
|
53 |
w->flags4 &= ~WF_SCROLL2; |
|
54 |
mi = wi->top; |
|
55 |
ma = wi->bottom; |
|
56 |
pos = y; |
|
57 |
sb = &w->vscroll; |
|
58 |
break; |
|
59 |
} |
|
60 |
case WWT_SCROLL2BAR: { |
|
61 |
// 2nd vertical scroller |
|
62 |
w->flags4 &= ~WF_HSCROLL; |
|
63 |
w->flags4 |= WF_SCROLL2; |
|
64 |
mi = wi->top; |
|
65 |
ma = wi->bottom; |
|
66 |
pos = y; |
|
67 |
sb = &w->vscroll2; |
|
68 |
break; |
|
69 |
} |
|
70 |
case WWT_HSCROLLBAR: { |
|
71 |
// horizontal scroller |
|
72 |
assert(wi->type == WWT_HSCROLLBAR); |
|
73 |
w->flags4 |= WF_HSCROLL; |
|
74 |
mi = wi->left; |
|
75 |
ma = wi->right; |
|
76 |
pos = x; |
|
77 |
sb = &w->hscroll; |
|
78 |
} |
|
0 | 79 |
} |
80 |
if (pos <= mi+9) { |
|
81 |
// Pressing the upper button? |
|
82 |
if (!_demo_mode) { |
|
83 |
w->flags4 |= WF_SCROLL_UP; |
|
84 |
if (_scroller_click_timeout == 0) { |
|
85 |
_scroller_click_timeout = 6; |
|
86 |
if (sb->pos != 0) sb->pos--; |
|
87 |
} |
|
88 |
_left_button_clicked = false; |
|
89 |
} |
|
90 |
} else if (pos >= ma-10) { |
|
91 |
// Pressing the lower button? |
|
92 |
if (!_demo_mode) { |
|
93 |
w->flags4 |= WF_SCROLL_DOWN; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
94 |
|
0 | 95 |
if (_scroller_click_timeout == 0) { |
96 |
_scroller_click_timeout = 6; |
|
97 |
if ((byte)(sb->pos + sb->cap) < sb->count) |
|
98 |
sb->pos++; |
|
99 |
} |
|
100 |
_left_button_clicked = false; |
|
101 |
} |
|
102 |
} else { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
103 |
// |
0 | 104 |
Point pt = HandleScrollbarHittest(sb, mi, ma); |
105 |
||
106 |
if (pos < pt.x) { |
|
107 |
sb->pos = max(sb->pos - sb->cap, 0); |
|
108 |
} else if (pos > pt.y) { |
|
109 |
sb->pos = min( |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
110 |
sb->pos + sb->cap, |
0 | 111 |
max(sb->count - sb->cap, 0) |
112 |
); |
|
113 |
} else { |
|
114 |
_scrollbar_start_pos = pt.x - mi - 9; |
|
115 |
_scrollbar_size = ma - mi - 23; |
|
116 |
w->flags4 |= WF_SCROLL_MIDDLE; |
|
117 |
_scrolling_scrollbar = true; |
|
118 |
_cursorpos_drag_start = _cursor.pos; |
|
119 |
} |
|
120 |
} |
|
121 |
||
122 |
SetWindowDirty(w); |
|
123 |
} |
|
124 |
||
125 |
/***************************************************** |
|
126 |
* Returns the index for the widget located at the given |
|
127 |
* position relative to the window. |
|
128 |
* Parameters: |
|
129 |
* w - Window |
|
130 |
* x/y - Window client coordinates |
|
131 |
* Returns: |
|
132 |
* A widget index, or -1 if no widget was found. |
|
133 |
*/ |
|
134 |
int GetWidgetFromPos(Window *w, int x, int y) |
|
135 |
{ |
|
136 |
const Widget *wi; |
|
137 |
int index, found_index = -1; |
|
138 |
||
139 |
// Go through the widgets and check if we find the widget that the coordinate is |
|
140 |
// inside. |
|
141 |
for(index=0,wi=w->widget; wi->type != WWT_LAST; index++, wi++) { |
|
142 |
if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) |
|
143 |
continue; |
|
144 |
||
145 |
if (x >= wi->left && |
|
146 |
x < wi->right && |
|
147 |
y >= wi->top && |
|
148 |
y < wi->bottom && !HASBIT(w->hidden_state,index)) { |
|
149 |
found_index = index; |
|
150 |
} |
|
151 |
} |
|
152 |
||
153 |
// Return the index |
|
154 |
return found_index; |
|
155 |
} |
|
156 |
||
157 |
||
158 |
void DrawWindowWidgets(Window *w) |
|
159 |
{ |
|
160 |
const Widget *wi; |
|
161 |
DrawPixelInfo *dpi = _cur_dpi; |
|
162 |
Rect r; |
|
674
63eb544b0689
(svn r1112) -Fix: _decode_parameters was increased to [20], but not all temp-dparams were
truelight
parents:
507
diff
changeset
|
163 |
uint32 dparam_backup[20]; |
0 | 164 |
uint32 cur_click, cur_disabled, cur_hidden; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
165 |
|
0 | 166 |
if (w->desc_flags & WDF_RESTORE_DPARAM) COPY_OUT_DPARAM(dparam_backup, 0, lengthof(dparam_backup)); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
167 |
|
0 | 168 |
wi = w->widget; |
169 |
||
170 |
cur_click = w->click_state; |
|
171 |
cur_disabled = w->disabled_state; |
|
172 |
cur_hidden = w->hidden_state; |
|
173 |
||
174 |
do { |
|
175 |
if (dpi->left > (r.right=/*w->left + */wi->right) || |
|
176 |
dpi->left + dpi->width <= (r.left=wi->left/* + w->left*/) || |
|
177 |
dpi->top > (r.bottom=/*w->top +*/ wi->bottom) || |
|
178 |
dpi->top + dpi->height <= (r.top = /*w->top +*/ wi->top) || |
|
179 |
(cur_hidden&1)) |
|
180 |
continue; |
|
181 |
||
182 |
switch(wi->type&WWT_MASK) { |
|
183 |
case WWT_PANEL: |
|
184 |
case WWT_PANEL_2: { |
|
185 |
int img; |
|
186 |
||
187 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, |
|
188 |
(cur_click & 1) ? 0x20 : 0); |
|
189 |
||
190 |
if ((img=wi->unkA) != 0) { |
|
191 |
if ((wi->type&WWT_MASK) == WWT_PANEL_2 && (cur_click&1)) img++; |
|
192 |
DrawSprite(img, r.left+1, r.top+1); |
|
193 |
} |
|
194 |
goto draw_default; |
|
195 |
} |
|
196 |
||
197 |
case WWT_CLOSEBOX: |
|
198 |
case WWT_4: { |
|
199 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, |
|
200 |
(cur_click & 1) ? 0x20 : 0); |
|
201 |
} |
|
202 |
/* fall through */ |
|
203 |
||
204 |
case WWT_5: { |
|
205 |
StringID str = wi->unkA; |
|
206 |
||
207 |
if ((wi->type&WWT_MASK) == WWT_4 && (cur_click&1)) str++; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
208 |
|
0 | 209 |
DrawStringCentered((r.left + r.right+1)>>1, ((r.top+r.bottom + 1)>>1) - 5, str, 0); |
210 |
goto restore_dparam; |
|
211 |
} |
|
212 |
||
213 |
case WWT_6: { |
|
214 |
StringID str; |
|
215 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0x60); |
|
216 |
||
217 |
if ((str = wi->unkA) != 0) { |
|
218 |
DrawString(r.left+2, r.top+1, str, 0); |
|
219 |
goto restore_dparam; |
|
220 |
} |
|
221 |
goto draw_default; |
|
222 |
} |
|
223 |
||
224 |
case WWT_MATRIX: { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
225 |
int c, d, ctr; |
0 | 226 |
int x, amt1, amt2; |
227 |
int color; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
228 |
|
0 | 229 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, |
230 |
(cur_click & 1) ? 0x20 : 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
231 |
|
0 | 232 |
c = (wi->unkA&0xFF); |
233 |
amt1 = (wi->right - wi->left + 1) / c; |
|
234 |
||
235 |
d = (wi->unkA >> 8); |
|
236 |
amt2 = (wi->bottom - wi->top + 1) / d; |
|
237 |
||
238 |
color = _color_list[wi->color&0xF].window_color_bgb; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
239 |
|
0 | 240 |
x = r.left; |
241 |
for(ctr=c; --ctr; ) { |
|
242 |
x += amt1; |
|
243 |
GfxFillRect(x, r.top+1, x, r.bottom-1, color); |
|
244 |
} |
|
245 |
||
246 |
x = r.top; |
|
247 |
for(ctr=d; --ctr; ) { |
|
248 |
x += amt2; |
|
249 |
GfxFillRect(r.left+1, x, r.right-1, x, color); |
|
250 |
} |
|
251 |
||
252 |
color = _color_list[wi->color&0xF].window_color_1b; |
|
253 |
||
254 |
x = r.left-1; |
|
255 |
for(ctr=c; --ctr; ) { |
|
256 |
x += amt1; |
|
257 |
GfxFillRect(x, r.top+1, x, r.bottom-1, color); |
|
258 |
} |
|
259 |
||
260 |
x = r.top-1; |
|
261 |
for(ctr=d; --ctr; ) { |
|
262 |
x += amt2; |
|
263 |
GfxFillRect(r.left+1, x, r.right-1, x, color); |
|
264 |
} |
|
265 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
266 |
goto draw_default; |
0 | 267 |
} |
268 |
||
269 |
// vertical scrollbar |
|
270 |
case WWT_SCROLLBAR: { |
|
271 |
Point pt; |
|
272 |
int c1,c2; |
|
273 |
||
274 |
// draw up/down buttons |
|
842 | 275 |
DrawFrameRect(r.left, r.top, r.right, r.top+9, wi->color, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP ? 0x20 : 0); |
276 |
DrawFrameRect(r.left, r.bottom-9, r.right, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN ? 0x20 : 0); |
|
0 | 277 |
|
278 |
// draw icons in up/down buttons |
|
279 |
DoDrawString("\xA0", r.left+2, r.top, 0x10); |
|
280 |
DoDrawString("\xAA", r.left+2, r.bottom-9, 0x10); |
|
281 |
||
282 |
c1 = _color_list[wi->color&0xF].window_color_1a; |
|
283 |
c2 = _color_list[wi->color&0xF].window_color_2; |
|
284 |
||
285 |
// draw "shaded" background |
|
286 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2); |
|
287 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | 0x8000); |
|
288 |
||
289 |
// draw shaded lines |
|
290 |
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1); |
|
291 |
GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
|
292 |
GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
|
293 |
GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
294 |
|
0 | 295 |
pt = HandleScrollbarHittest(&w->vscroll, r.top, r.bottom); |
842 | 296 |
DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? 0x20 : 0); |
297 |
break; |
|
298 |
} |
|
299 |
case WWT_SCROLL2BAR: { |
|
300 |
Point pt; |
|
301 |
int c1,c2; |
|
302 |
||
303 |
// draw up/down buttons |
|
304 |
DrawFrameRect(r.left, r.top, r.right, r.top+9, wi->color, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2) ? 0x20 : 0); |
|
305 |
DrawFrameRect(r.left, r.bottom-9, r.right, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2) ? 0x20 : 0); |
|
306 |
||
307 |
// draw icons in up/down buttons |
|
308 |
DoDrawString("\xA0", r.left+2, r.top, 0x10); |
|
309 |
DoDrawString("\xAA", r.left+2, r.bottom-9, 0x10); |
|
310 |
||
311 |
c1 = _color_list[wi->color&0xF].window_color_1a; |
|
312 |
c2 = _color_list[wi->color&0xF].window_color_2; |
|
313 |
||
314 |
// draw "shaded" background |
|
315 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2); |
|
316 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | 0x8000); |
|
317 |
||
318 |
// draw shaded lines |
|
319 |
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1); |
|
320 |
GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
|
321 |
GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
|
322 |
GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); |
|
323 |
||
324 |
pt = HandleScrollbarHittest(&w->vscroll2, r.top, r.bottom); |
|
325 |
DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_MIDDLE | WF_SCROLL2) ? 0x20 : 0); |
|
0 | 326 |
break; |
327 |
} |
|
328 |
||
329 |
// horizontal scrollbar |
|
330 |
case WWT_HSCROLLBAR: { |
|
331 |
Point pt; |
|
332 |
int c1,c2; |
|
333 |
||
334 |
DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL) ? 0x20 : 0); |
|
335 |
DrawFrameRect(r.right-9, r.top, r.right, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL) ? 0x20 : 0); |
|
336 |
||
337 |
// draw icons in up/down buttons |
|
338 |
DoDrawString("\xA0", r.left+1, r.top+1, 0x10); |
|
339 |
DoDrawString("\xAA", r.right-8, r.top+1, 0x10); |
|
340 |
||
341 |
c1 = _color_list[wi->color&0xF].window_color_1a; |
|
342 |
c2 = _color_list[wi->color&0xF].window_color_2; |
|
343 |
||
344 |
// draw "shaded" background |
|
345 |
GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c2); |
|
346 |
GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c1 | 0x8000); |
|
347 |
||
348 |
// draw shaded lines |
|
349 |
GfxFillRect(r.left+10, r.top+2, r.right-10, r.top+2, c1); |
|
350 |
GfxFillRect(r.left+10, r.top+3, r.right-10, r.top+3, c2); |
|
351 |
GfxFillRect(r.left+10, r.top+7, r.right-10, r.top+7, c1); |
|
352 |
GfxFillRect(r.left+10, r.top+8, r.right-10, r.top+8, c2); |
|
353 |
||
354 |
// draw actual scrollbar |
|
355 |
pt = HandleScrollbarHittest(&w->hscroll, r.left, r.right); |
|
356 |
DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? 0x20 : 0); |
|
357 |
||
358 |
break; |
|
359 |
} |
|
360 |
||
361 |
case WWT_FRAME: { |
|
362 |
int c1,c2; |
|
363 |
int x2 = 0; |
|
364 |
||
365 |
if (wi->unkA != 0) { |
|
366 |
x2 = DrawString(r.left+6, r.top, wi->unkA, 0); |
|
367 |
} |
|
368 |
||
369 |
c1 = _color_list[wi->color].window_color_1a; |
|
370 |
c2 = _color_list[wi->color].window_color_2; |
|
371 |
||
372 |
//Line from upper left corner to start of text |
|
373 |
GfxFillRect(r.left, r.top+4, r.left+4,r.top+4, c1); |
|
374 |
GfxFillRect(r.left+1, r.top+5, r.left+4,r.top+5, c2); |
|
375 |
||
376 |
// Line from end of text to upper right corner |
|
377 |
GfxFillRect(x2, r.top+4, r.right-1,r.top+4,c1); |
|
378 |
GfxFillRect(x2, r.top+5, r.right-2,r.top+5,c2); |
|
379 |
||
380 |
// Line from upper left corner to bottom left corner |
|
381 |
GfxFillRect(r.left, r.top+5, r.left, r.bottom-1, c1); |
|
382 |
GfxFillRect(r.left+1, r.top+6, r.left+1, r.bottom-2, c2); |
|
383 |
||
384 |
//Line from upper right corner to bottom right corner |
|
385 |
GfxFillRect(r.right-1, r.top+5, r.right-1, r.bottom-2, c1); |
|
386 |
GfxFillRect(r.right, r.top+4, r.right, r.bottom-1, c2); |
|
387 |
||
388 |
GfxFillRect(r.left+1, r.bottom-1, r.right-1, r.bottom-1, c1); |
|
389 |
GfxFillRect(r.left, r.bottom, r.right, r.bottom, c2); |
|
390 |
||
391 |
goto restore_dparam; |
|
392 |
} |
|
393 |
||
682
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
674
diff
changeset
|
394 |
case WWT_STICKYBOX: { |
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
674
diff
changeset
|
395 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (cur_click & 1) ? 0x20 : 0); |
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
674
diff
changeset
|
396 |
DrawSprite((cur_click & 1) ? SPR_PIN_UP :SPR_PIN_DOWN, r.left + 2, r.top + 3); |
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
674
diff
changeset
|
397 |
break; |
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
674
diff
changeset
|
398 |
} |
7f5de4abac85
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
674
diff
changeset
|
399 |
|
0 | 400 |
case WWT_CAPTION: { |
401 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0x10); |
|
402 |
DrawFrameRect(r.left+1, r.top+1, r.right-1, r.bottom-1, wi->color, (w->caption_color == 0xFF) ? 0x60 : 0x70); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
403 |
|
0 | 404 |
if (w->caption_color != 0xFF) { |
405 |
GfxFillRect(r.left+2, r.top+2, r.right-2, r.bottom-2, _color_list[_player_colors[w->caption_color]].window_color_1b); |
|
406 |
} |
|
407 |
||
408 |
DrawStringCentered( (r.left+r.right+1)>>1, r.top+2, wi->unkA, 0x84); |
|
409 |
restore_dparam:; |
|
410 |
if (w->desc_flags & WDF_RESTORE_DPARAM) COPY_IN_DPARAM(0, dparam_backup, lengthof(dparam_backup)); |
|
411 |
draw_default:; |
|
412 |
if (cur_disabled & 1) { |
|
413 |
GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _color_list[wi->color&0xF].unk2 | 0x8000); |
|
414 |
} |
|
415 |
} |
|
416 |
} |
|
417 |
} while (cur_click>>=1, cur_disabled>>=1, cur_hidden >>= 1, (++wi)->type != WWT_LAST); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
418 |
|
0 | 419 |
|
420 |
if (w->flags4 & WF_WHITE_BORDER_MASK) { |
|
421 |
//DrawFrameRect(w->left, w->top, w->left + w->width-1, w->top+w->height-1, 0xF, 0x10); |
|
422 |
DrawFrameRect(0, 0, w->width-1, w->height-1, 0xF, 0x10); |
|
423 |
} |
|
424 |
||
425 |
} |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
426 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
427 |
static uint _dropdown_item_count; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
428 |
static uint32 _dropdown_disabled; |
842 | 429 |
static bool _dropdown_hide_disabled; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
430 |
static const StringID *_dropdown_items; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
431 |
static int _dropdown_selindex; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
432 |
static byte _dropdown_button; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
433 |
static WindowClass _dropdown_windowclass; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
434 |
static WindowNumber _dropdown_windownum; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
435 |
static byte _dropdown_var1; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
436 |
static byte _dropdown_var2; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
437 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
438 |
static Widget _dropdown_menu_widgets[] = { |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
439 |
{ WWT_IMGBTN, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
440 |
{ WIDGETS_END}, |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
441 |
}; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
442 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
443 |
static int GetDropdownItem(Window *w) |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
444 |
{ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
445 |
uint item; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
446 |
int y; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
447 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
448 |
if (GetWidgetFromPos(w, _cursor.pos.x - w->left, _cursor.pos.y - w->top) < 0) |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
449 |
return -1; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
450 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
451 |
y = _cursor.pos.y - w->top - 2; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
452 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
453 |
if (y < 0) |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
454 |
return - 1; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
455 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
456 |
item = y / 10; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
457 |
if (item >= _dropdown_item_count || HASBIT(_dropdown_disabled,item) || _dropdown_items[item] == 0) |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
458 |
return - 1; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
459 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
460 |
return item; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
461 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
462 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
463 |
void DropdownMenuWndProc(Window *w, WindowEvent *e) |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
464 |
{ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
465 |
int item; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
466 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
467 |
switch(e->event) { |
842 | 468 |
case WE_PAINT: { |
469 |
int x,y,i,sel; |
|
470 |
uint32 dis; |
|
471 |
bool hidden; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
472 |
|
842 | 473 |
DrawWindowWidgets(w); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
474 |
|
842 | 475 |
x = 1; |
476 |
y = 2; |
|
477 |
sel = _dropdown_selindex; |
|
478 |
dis = _dropdown_disabled; |
|
479 |
hidden = _dropdown_hide_disabled; |
|
480 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
481 |
|
842 | 482 |
for(i=0; _dropdown_items[i] != INVALID_STRING_ID; i++) { |
483 |
if (!(hidden) | !(dis & 1)) { |
|
484 |
if (_dropdown_items[i] != 0) { |
|
485 |
if (sel == 0) { |
|
486 |
GfxFillRect(x+1, y, x+w->width-4, y + 9, 0); |
|
487 |
} |
|
488 |
DrawString(x+2, y, _dropdown_items[i], sel==0 ? 12 : 16); |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
489 |
|
842 | 490 |
if (dis & 1) { |
491 |
GfxFillRect(x, y, x+w->width-3, y + 9, 0x8000 + |
|
492 |
_color_list[_dropdown_menu_widgets[0].color].window_color_bga); |
|
493 |
} |
|
494 |
} else { |
|
495 |
int color_1 = _color_list[_dropdown_menu_widgets[0].color].window_color_1a; |
|
496 |
int color_2 = _color_list[_dropdown_menu_widgets[0].color].window_color_2; |
|
497 |
GfxFillRect(x+1, y+3, x+w->width-5, y+3, color_1); |
|
498 |
GfxFillRect(x+1, y+4, x+w->width-5, y+4, color_2); |
|
499 |
} |
|
500 |
y += 10; |
|
501 |
sel--; |
|
502 |
} |
|
503 |
dis>>=1; |
|
504 |
} |
|
505 |
} break; |
|
506 |
||
507 |
case WE_CLICK: { |
|
508 |
item = GetDropdownItem(w); |
|
509 |
if (item >= 0) { |
|
510 |
_dropdown_var1 = 4; |
|
511 |
_dropdown_selindex = item; |
|
512 |
SetWindowDirty(w); |
|
513 |
} |
|
514 |
} break; |
|
515 |
||
516 |
case WE_MOUSELOOP: { |
|
517 |
Window *w2 = FindWindowById(_dropdown_windowclass, _dropdown_windownum); |
|
518 |
if (w2 == NULL) { |
|
519 |
DeleteWindow(w); |
|
520 |
return; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
521 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
522 |
|
842 | 523 |
if (_dropdown_var1 != 0 && --_dropdown_var1 == 0) { |
524 |
WindowEvent e; |
|
525 |
e.event = WE_DROPDOWN_SELECT; |
|
526 |
e.dropdown.button = _dropdown_button; |
|
527 |
e.dropdown.index = _dropdown_selindex; |
|
528 |
w2->wndproc(w2, &e); |
|
529 |
DeleteWindow(w); |
|
530 |
return; |
|
531 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
532 |
|
842 | 533 |
if (_dropdown_var2 != 0) { |
534 |
item = GetDropdownItem(w); |
|
535 |
||
536 |
if (!_left_button_clicked) { |
|
537 |
_dropdown_var2 = 0; |
|
538 |
if (item < 0) |
|
539 |
return; |
|
540 |
_dropdown_var1 = 2; |
|
541 |
} else { |
|
542 |
if (item < 0) |
|
543 |
return; |
|
544 |
} |
|
545 |
||
546 |
_dropdown_selindex = item; |
|
547 |
SetWindowDirty(w); |
|
548 |
} |
|
549 |
} break; |
|
550 |
||
551 |
case WE_DESTROY: { |
|
552 |
Window *w2 = FindWindowById(_dropdown_windowclass, _dropdown_windownum); |
|
553 |
if (w2 != NULL) { |
|
554 |
CLRBIT(w2->click_state, _dropdown_button); |
|
555 |
InvalidateWidget(w2, _dropdown_button); |
|
556 |
} |
|
557 |
} break; |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
558 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
559 |
} |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
560 |
|
842 | 561 |
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, bool remove_filtered_strings) |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
562 |
{ |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
563 |
WindowNumber num; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
564 |
WindowClass cls; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
565 |
int i,t1,t2; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
566 |
const Widget *wi; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
567 |
Window *w2; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
568 |
uint32 old_click_state = w->click_state; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
569 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
570 |
_dropdown_disabled = disabled_mask; |
842 | 571 |
_dropdown_hide_disabled = remove_filtered_strings; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
572 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
573 |
cls = w->window_class; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
574 |
num = w->window_number; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
575 |
DeleteWindowById(WC_DROPDOWN_MENU, 0); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
576 |
w = FindWindowById(cls, num); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
577 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
578 |
if (HASBIT(old_click_state, button)) |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
579 |
return; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
580 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
581 |
SETBIT(w->click_state, button); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
582 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
583 |
InvalidateWidget(w, button); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
584 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
585 |
for(i=0;strings[i] != INVALID_STRING_ID;i++); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
586 |
if (i == 0) |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
587 |
return; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
588 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
589 |
_dropdown_items = strings; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
590 |
_dropdown_item_count = i; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
591 |
_dropdown_selindex = selected; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
592 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
593 |
_dropdown_windowclass = w->window_class; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
594 |
_dropdown_windownum = w->window_number; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
595 |
_dropdown_button = button; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
596 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
597 |
_dropdown_var1 = 0; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
598 |
_dropdown_var2 = 1; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
599 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
600 |
wi = &w->widget[button]; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
601 |
|
842 | 602 |
if ( remove_filtered_strings ) { |
603 |
int j; |
|
604 |
for(j=0; _dropdown_items[j] != INVALID_STRING_ID; j++) { |
|
605 |
if ( disabled_mask & ( 1 << j )) { |
|
606 |
_dropdown_item_count--; |
|
607 |
i--; |
|
608 |
} |
|
609 |
} |
|
610 |
} |
|
611 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
612 |
_dropdown_menu_widgets[0].color = wi->color; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
613 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
614 |
w2 = AllocateWindow( |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
615 |
w->left + wi[-1].left + 1, |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
616 |
w->top + wi->bottom + 2, |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
617 |
(_dropdown_menu_widgets[0].right=t1=wi->right - wi[-1].left, t1 + 1), |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
618 |
(_dropdown_menu_widgets[0].bottom=t2=i*10+3, t2+1), |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
619 |
DropdownMenuWndProc, |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
620 |
0x3F, |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
621 |
_dropdown_menu_widgets); |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
622 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
623 |
|
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
624 |
w2->flags4 &= ~WF_WHITE_BORDER_MASK; |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
0
diff
changeset
|
625 |
} |