author | darkvater |
Mon, 03 Jan 2005 22:04:34 +0000 | |
changeset 876 | d275d6d2aa65 |
parent 867 | 581154a08a78 |
child 883 | 0c54c6fc1790 |
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 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
72 |
w->flags4 &= ~WF_SCROLL2; |
842 | 73 |
w->flags4 |= WF_HSCROLL; |
74 |
mi = wi->left; |
|
75 |
ma = wi->right; |
|
76 |
pos = x; |
|
77 |
sb = &w->hscroll; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
78 |
break; |
842 | 79 |
} |
845
0c66e26fecb2
(svn r1326) fixed compiler warnings in vehicle_gui.c and widget.c
bjarni
parents:
842
diff
changeset
|
80 |
default: return; //this should never happen |
0 | 81 |
} |
82 |
if (pos <= mi+9) { |
|
83 |
// Pressing the upper button? |
|
84 |
if (!_demo_mode) { |
|
85 |
w->flags4 |= WF_SCROLL_UP; |
|
86 |
if (_scroller_click_timeout == 0) { |
|
87 |
_scroller_click_timeout = 6; |
|
88 |
if (sb->pos != 0) sb->pos--; |
|
89 |
} |
|
90 |
_left_button_clicked = false; |
|
91 |
} |
|
92 |
} else if (pos >= ma-10) { |
|
93 |
// Pressing the lower button? |
|
94 |
if (!_demo_mode) { |
|
95 |
w->flags4 |= WF_SCROLL_DOWN; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
96 |
|
0 | 97 |
if (_scroller_click_timeout == 0) { |
98 |
_scroller_click_timeout = 6; |
|
99 |
if ((byte)(sb->pos + sb->cap) < sb->count) |
|
100 |
sb->pos++; |
|
101 |
} |
|
102 |
_left_button_clicked = false; |
|
103 |
} |
|
104 |
} else { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
105 |
// |
0 | 106 |
Point pt = HandleScrollbarHittest(sb, mi, ma); |
107 |
||
108 |
if (pos < pt.x) { |
|
109 |
sb->pos = max(sb->pos - sb->cap, 0); |
|
110 |
} else if (pos > pt.y) { |
|
111 |
sb->pos = min( |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
112 |
sb->pos + sb->cap, |
0 | 113 |
max(sb->count - sb->cap, 0) |
114 |
); |
|
115 |
} else { |
|
116 |
_scrollbar_start_pos = pt.x - mi - 9; |
|
117 |
_scrollbar_size = ma - mi - 23; |
|
118 |
w->flags4 |= WF_SCROLL_MIDDLE; |
|
119 |
_scrolling_scrollbar = true; |
|
120 |
_cursorpos_drag_start = _cursor.pos; |
|
121 |
} |
|
122 |
} |
|
123 |
||
124 |
SetWindowDirty(w); |
|
125 |
} |
|
126 |
||
127 |
/***************************************************** |
|
128 |
* Returns the index for the widget located at the given |
|
129 |
* position relative to the window. |
|
130 |
* Parameters: |
|
131 |
* w - Window |
|
132 |
* x/y - Window client coordinates |
|
133 |
* Returns: |
|
134 |
* A widget index, or -1 if no widget was found. |
|
135 |
*/ |
|
136 |
int GetWidgetFromPos(Window *w, int x, int y) |
|
137 |
{ |
|
138 |
const Widget *wi; |
|
139 |
int index, found_index = -1; |
|
140 |
||
141 |
// Go through the widgets and check if we find the widget that the coordinate is |
|
142 |
// inside. |
|
143 |
for(index=0,wi=w->widget; wi->type != WWT_LAST; index++, wi++) { |
|
144 |
if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) |
|
145 |
continue; |
|
146 |
||
147 |
if (x >= wi->left && |
|
148 |
x < wi->right && |
|
149 |
y >= wi->top && |
|
150 |
y < wi->bottom && !HASBIT(w->hidden_state,index)) { |
|
151 |
found_index = index; |
|
152 |
} |
|
153 |
} |
|
154 |
||
155 |
// Return the index |
|
156 |
return found_index; |
|
157 |
} |
|
158 |
||
159 |
||
160 |
void DrawWindowWidgets(Window *w) |
|
161 |
{ |
|
162 |
const Widget *wi; |
|
163 |
DrawPixelInfo *dpi = _cur_dpi; |
|
164 |
Rect r; |
|
674
63eb544b0689
(svn r1112) -Fix: _decode_parameters was increased to [20], but not all temp-dparams were
truelight
parents:
507
diff
changeset
|
165 |
uint32 dparam_backup[20]; |
0 | 166 |
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
|
167 |
|
0 | 168 |
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
|
169 |
|
0 | 170 |
wi = w->widget; |
171 |
||
172 |
cur_click = w->click_state; |
|
173 |
cur_disabled = w->disabled_state; |
|
174 |
cur_hidden = w->hidden_state; |
|
175 |
||
176 |
do { |
|
177 |
if (dpi->left > (r.right=/*w->left + */wi->right) || |
|
178 |
dpi->left + dpi->width <= (r.left=wi->left/* + w->left*/) || |
|
179 |
dpi->top > (r.bottom=/*w->top +*/ wi->bottom) || |
|
180 |
dpi->top + dpi->height <= (r.top = /*w->top +*/ wi->top) || |
|
181 |
(cur_hidden&1)) |
|
182 |
continue; |
|
183 |
||
184 |
switch(wi->type&WWT_MASK) { |
|
185 |
case WWT_PANEL: |
|
186 |
case WWT_PANEL_2: { |
|
187 |
int img; |
|
188 |
||
189 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, |
|
190 |
(cur_click & 1) ? 0x20 : 0); |
|
191 |
||
192 |
if ((img=wi->unkA) != 0) { |
|
193 |
if ((wi->type&WWT_MASK) == WWT_PANEL_2 && (cur_click&1)) img++; |
|
194 |
DrawSprite(img, r.left+1, r.top+1); |
|
195 |
} |
|
196 |
goto draw_default; |
|
197 |
} |
|
198 |
||
199 |
case WWT_CLOSEBOX: |
|
200 |
case WWT_4: { |
|
201 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, |
|
202 |
(cur_click & 1) ? 0x20 : 0); |
|
203 |
} |
|
204 |
/* fall through */ |
|
205 |
||
206 |
case WWT_5: { |
|
207 |
StringID str = wi->unkA; |
|
208 |
||
209 |
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
|
210 |
|
0 | 211 |
DrawStringCentered((r.left + r.right+1)>>1, ((r.top+r.bottom + 1)>>1) - 5, str, 0); |
212 |
goto restore_dparam; |
|
213 |
} |
|
214 |
||
215 |
case WWT_6: { |
|
216 |
StringID str; |
|
217 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0x60); |
|
218 |
||
219 |
if ((str = wi->unkA) != 0) { |
|
220 |
DrawString(r.left+2, r.top+1, str, 0); |
|
221 |
goto restore_dparam; |
|
222 |
} |
|
223 |
goto draw_default; |
|
224 |
} |
|
225 |
||
226 |
case WWT_MATRIX: { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
227 |
int c, d, ctr; |
0 | 228 |
int x, amt1, amt2; |
229 |
int color; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
230 |
|
0 | 231 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, |
232 |
(cur_click & 1) ? 0x20 : 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
233 |
|
0 | 234 |
c = (wi->unkA&0xFF); |
235 |
amt1 = (wi->right - wi->left + 1) / c; |
|
236 |
||
237 |
d = (wi->unkA >> 8); |
|
238 |
amt2 = (wi->bottom - wi->top + 1) / d; |
|
239 |
||
240 |
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
|
241 |
|
0 | 242 |
x = r.left; |
243 |
for(ctr=c; --ctr; ) { |
|
244 |
x += amt1; |
|
245 |
GfxFillRect(x, r.top+1, x, r.bottom-1, color); |
|
246 |
} |
|
247 |
||
248 |
x = r.top; |
|
249 |
for(ctr=d; --ctr; ) { |
|
250 |
x += amt2; |
|
251 |
GfxFillRect(r.left+1, x, r.right-1, x, color); |
|
252 |
} |
|
253 |
||
254 |
color = _color_list[wi->color&0xF].window_color_1b; |
|
255 |
||
256 |
x = r.left-1; |
|
257 |
for(ctr=c; --ctr; ) { |
|
258 |
x += amt1; |
|
259 |
GfxFillRect(x, r.top+1, x, r.bottom-1, color); |
|
260 |
} |
|
261 |
||
262 |
x = r.top-1; |
|
263 |
for(ctr=d; --ctr; ) { |
|
264 |
x += amt2; |
|
265 |
GfxFillRect(r.left+1, x, r.right-1, x, color); |
|
266 |
} |
|
267 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
268 |
goto draw_default; |
0 | 269 |
} |
270 |
||
271 |
// vertical scrollbar |
|
272 |
case WWT_SCROLLBAR: { |
|
273 |
Point pt; |
|
274 |
int c1,c2; |
|
275 |
||
276 |
// draw up/down buttons |
|
842 | 277 |
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); |
278 |
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 | 279 |
|
280 |
// draw icons in up/down buttons |
|
281 |
DoDrawString("\xA0", r.left+2, r.top, 0x10); |
|
282 |
DoDrawString("\xAA", r.left+2, r.bottom-9, 0x10); |
|
283 |
||
284 |
c1 = _color_list[wi->color&0xF].window_color_1a; |
|
285 |
c2 = _color_list[wi->color&0xF].window_color_2; |
|
286 |
||
287 |
// draw "shaded" background |
|
288 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2); |
|
289 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | 0x8000); |
|
290 |
||
291 |
// draw shaded lines |
|
292 |
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1); |
|
293 |
GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
|
294 |
GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
|
295 |
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
|
296 |
|
0 | 297 |
pt = HandleScrollbarHittest(&w->vscroll, r.top, r.bottom); |
842 | 298 |
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); |
299 |
break; |
|
300 |
} |
|
301 |
case WWT_SCROLL2BAR: { |
|
302 |
Point pt; |
|
303 |
int c1,c2; |
|
304 |
||
305 |
// draw up/down buttons |
|
306 |
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); |
|
307 |
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); |
|
308 |
||
309 |
// draw icons in up/down buttons |
|
310 |
DoDrawString("\xA0", r.left+2, r.top, 0x10); |
|
311 |
DoDrawString("\xAA", r.left+2, r.bottom-9, 0x10); |
|
312 |
||
313 |
c1 = _color_list[wi->color&0xF].window_color_1a; |
|
314 |
c2 = _color_list[wi->color&0xF].window_color_2; |
|
315 |
||
316 |
// draw "shaded" background |
|
317 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2); |
|
318 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | 0x8000); |
|
319 |
||
320 |
// draw shaded lines |
|
321 |
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1); |
|
322 |
GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
|
323 |
GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
|
324 |
GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); |
|
325 |
||
326 |
pt = HandleScrollbarHittest(&w->vscroll2, r.top, r.bottom); |
|
327 |
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 | 328 |
break; |
329 |
} |
|
330 |
||
331 |
// horizontal scrollbar |
|
332 |
case WWT_HSCROLLBAR: { |
|
333 |
Point pt; |
|
334 |
int c1,c2; |
|
335 |
||
336 |
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); |
|
337 |
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); |
|
338 |
||
339 |
// draw icons in up/down buttons |
|
340 |
DoDrawString("\xA0", r.left+1, r.top+1, 0x10); |
|
341 |
DoDrawString("\xAA", r.right-8, r.top+1, 0x10); |
|
342 |
||
343 |
c1 = _color_list[wi->color&0xF].window_color_1a; |
|
344 |
c2 = _color_list[wi->color&0xF].window_color_2; |
|
345 |
||
346 |
// draw "shaded" background |
|
347 |
GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c2); |
|
348 |
GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c1 | 0x8000); |
|
349 |
||
350 |
// draw shaded lines |
|
351 |
GfxFillRect(r.left+10, r.top+2, r.right-10, r.top+2, c1); |
|
352 |
GfxFillRect(r.left+10, r.top+3, r.right-10, r.top+3, c2); |
|
353 |
GfxFillRect(r.left+10, r.top+7, r.right-10, r.top+7, c1); |
|
354 |
GfxFillRect(r.left+10, r.top+8, r.right-10, r.top+8, c2); |
|
355 |
||
356 |
// draw actual scrollbar |
|
357 |
pt = HandleScrollbarHittest(&w->hscroll, r.left, r.right); |
|
358 |
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); |
|
359 |
||
360 |
break; |
|
361 |
} |
|
362 |
||
363 |
case WWT_FRAME: { |
|
364 |
int c1,c2; |
|
860
d756b3e0e171
(svn r1341) -Fix: fix WWT_FRAME drawing when there is no text there (STR_NULL)
darkvater
parents:
845
diff
changeset
|
365 |
int x2 = r.left; // by default the left side is the left side of the widget |
0 | 366 |
|
367 |
if (wi->unkA != 0) { |
|
368 |
x2 = DrawString(r.left+6, r.top, wi->unkA, 0); |
|
369 |
} |
|
370 |
||
371 |
c1 = _color_list[wi->color].window_color_1a; |
|
372 |
c2 = _color_list[wi->color].window_color_2; |
|
373 |
||
374 |
//Line from upper left corner to start of text |
|
375 |
GfxFillRect(r.left, r.top+4, r.left+4,r.top+4, c1); |
|
376 |
GfxFillRect(r.left+1, r.top+5, r.left+4,r.top+5, c2); |
|
377 |
||
378 |
// Line from end of text to upper right corner |
|
379 |
GfxFillRect(x2, r.top+4, r.right-1,r.top+4,c1); |
|
380 |
GfxFillRect(x2, r.top+5, r.right-2,r.top+5,c2); |
|
381 |
||
382 |
// Line from upper left corner to bottom left corner |
|
383 |
GfxFillRect(r.left, r.top+5, r.left, r.bottom-1, c1); |
|
384 |
GfxFillRect(r.left+1, r.top+6, r.left+1, r.bottom-2, c2); |
|
385 |
||
386 |
//Line from upper right corner to bottom right corner |
|
387 |
GfxFillRect(r.right-1, r.top+5, r.right-1, r.bottom-2, c1); |
|
388 |
GfxFillRect(r.right, r.top+4, r.right, r.bottom-1, c2); |
|
389 |
||
390 |
GfxFillRect(r.left+1, r.bottom-1, r.right-1, r.bottom-1, c1); |
|
391 |
GfxFillRect(r.left, r.bottom, r.right, r.bottom, c2); |
|
392 |
||
393 |
goto restore_dparam; |
|
394 |
} |
|
395 |
||
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
|
396 |
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
|
397 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (cur_click & 1) ? 0x20 : 0); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
398 |
DrawSprite((cur_click & 1) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2, r.top + 3); |
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
|
399 |
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
|
400 |
} |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
401 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
402 |
case WWT_RESIZEBOX: { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
403 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0); |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
404 |
DrawSprite(SPR_WINDOW_RESIZE, r.left + 2, r.top + 3); |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
405 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
406 |
} |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
407 |
|
0 | 408 |
case WWT_CAPTION: { |
409 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, 0x10); |
|
410 |
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
|
411 |
|
0 | 412 |
if (w->caption_color != 0xFF) { |
413 |
GfxFillRect(r.left+2, r.top+2, r.right-2, r.bottom-2, _color_list[_player_colors[w->caption_color]].window_color_1b); |
|
414 |
} |
|
415 |
||
416 |
DrawStringCentered( (r.left+r.right+1)>>1, r.top+2, wi->unkA, 0x84); |
|
417 |
restore_dparam:; |
|
418 |
if (w->desc_flags & WDF_RESTORE_DPARAM) COPY_IN_DPARAM(0, dparam_backup, lengthof(dparam_backup)); |
|
419 |
draw_default:; |
|
420 |
if (cur_disabled & 1) { |
|
421 |
GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _color_list[wi->color&0xF].unk2 | 0x8000); |
|
422 |
} |
|
423 |
} |
|
424 |
} |
|
425 |
} 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
|
426 |
|
0 | 427 |
|
428 |
if (w->flags4 & WF_WHITE_BORDER_MASK) { |
|
429 |
//DrawFrameRect(w->left, w->top, w->left + w->width-1, w->top+w->height-1, 0xF, 0x10); |
|
430 |
DrawFrameRect(0, 0, w->width-1, w->height-1, 0xF, 0x10); |
|
431 |
} |
|
432 |
||
433 |
} |
|
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
|
434 |
|
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 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
|
436 |
static uint32 _dropdown_disabled; |
842 | 437 |
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
|
438 |
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
|
439 |
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
|
440 |
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
|
441 |
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
|
442 |
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
|
443 |
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
|
444 |
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
|
445 |
|
876
d275d6d2aa65
(svn r1357) -Fix: Disabled dropdown menu options are gray again (instead of blue)
darkvater
parents:
867
diff
changeset
|
446 |
static Widget _dropdown_menu_widgets[] = { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
447 |
{ WWT_IMGBTN, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
164
diff
changeset
|
448 |
{ 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
|
449 |
}; |
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
|
450 |
|
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 |
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
|
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 |
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
|
454 |
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
|
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 |
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
|
457 |
return -1; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
458 |
|
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
|
459 |
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
|
460 |
|
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 |
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
|
462 |
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
|
463 |
|
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 |
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
|
465 |
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
|
466 |
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
|
467 |
|
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
|
468 |
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
|
469 |
} |
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
|
470 |
|
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
|
471 |
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
|
472 |
{ |
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
|
473 |
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
|
474 |
|
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
|
475 |
switch(e->event) { |
842 | 476 |
case WE_PAINT: { |
477 |
int x,y,i,sel; |
|
478 |
uint32 dis; |
|
479 |
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
|
480 |
|
842 | 481 |
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
|
482 |
|
842 | 483 |
x = 1; |
484 |
y = 2; |
|
485 |
sel = _dropdown_selindex; |
|
486 |
dis = _dropdown_disabled; |
|
487 |
hidden = _dropdown_hide_disabled; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
488 |
|
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 |
for(i=0; _dropdown_items[i] != INVALID_STRING_ID; i++) { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
491 |
if (!(hidden && (dis & 1))) { |
842 | 492 |
if (_dropdown_items[i] != 0) { |
493 |
if (sel == 0) { |
|
494 |
GfxFillRect(x+1, y, x+w->width-4, y + 9, 0); |
|
495 |
} |
|
496 |
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
|
497 |
|
842 | 498 |
if (dis & 1) { |
499 |
GfxFillRect(x, y, x+w->width-3, y + 9, 0x8000 + |
|
500 |
_color_list[_dropdown_menu_widgets[0].color].window_color_bga); |
|
501 |
} |
|
502 |
} else { |
|
503 |
int color_1 = _color_list[_dropdown_menu_widgets[0].color].window_color_1a; |
|
504 |
int color_2 = _color_list[_dropdown_menu_widgets[0].color].window_color_2; |
|
505 |
GfxFillRect(x+1, y+3, x+w->width-5, y+3, color_1); |
|
506 |
GfxFillRect(x+1, y+4, x+w->width-5, y+4, color_2); |
|
507 |
} |
|
508 |
y += 10; |
|
509 |
sel--; |
|
510 |
} |
|
511 |
dis>>=1; |
|
512 |
} |
|
513 |
} break; |
|
514 |
||
515 |
case WE_CLICK: { |
|
516 |
item = GetDropdownItem(w); |
|
517 |
if (item >= 0) { |
|
518 |
_dropdown_var1 = 4; |
|
519 |
_dropdown_selindex = item; |
|
520 |
SetWindowDirty(w); |
|
521 |
} |
|
522 |
} break; |
|
523 |
||
524 |
case WE_MOUSELOOP: { |
|
525 |
Window *w2 = FindWindowById(_dropdown_windowclass, _dropdown_windownum); |
|
526 |
if (w2 == NULL) { |
|
527 |
DeleteWindow(w); |
|
528 |
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
|
529 |
} |
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
|
530 |
|
842 | 531 |
if (_dropdown_var1 != 0 && --_dropdown_var1 == 0) { |
532 |
WindowEvent e; |
|
533 |
e.event = WE_DROPDOWN_SELECT; |
|
534 |
e.dropdown.button = _dropdown_button; |
|
535 |
e.dropdown.index = _dropdown_selindex; |
|
536 |
w2->wndproc(w2, &e); |
|
537 |
DeleteWindow(w); |
|
538 |
return; |
|
539 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
540 |
|
842 | 541 |
if (_dropdown_var2 != 0) { |
542 |
item = GetDropdownItem(w); |
|
543 |
||
544 |
if (!_left_button_clicked) { |
|
545 |
_dropdown_var2 = 0; |
|
546 |
if (item < 0) |
|
547 |
return; |
|
548 |
_dropdown_var1 = 2; |
|
549 |
} else { |
|
550 |
if (item < 0) |
|
551 |
return; |
|
552 |
} |
|
553 |
||
554 |
_dropdown_selindex = item; |
|
555 |
SetWindowDirty(w); |
|
556 |
} |
|
557 |
} break; |
|
558 |
||
559 |
case WE_DESTROY: { |
|
560 |
Window *w2 = FindWindowById(_dropdown_windowclass, _dropdown_windownum); |
|
561 |
if (w2 != NULL) { |
|
562 |
CLRBIT(w2->click_state, _dropdown_button); |
|
563 |
InvalidateWidget(w2, _dropdown_button); |
|
564 |
} |
|
565 |
} 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
|
566 |
} |
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 |
} |
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 |
|
842 | 569 |
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
|
570 |
{ |
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
|
571 |
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
|
572 |
WindowClass cls; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
573 |
int i; |
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
|
574 |
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
|
575 |
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
|
576 |
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
|
577 |
|
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
|
578 |
_dropdown_disabled = disabled_mask; |
842 | 579 |
_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
|
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 |
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
|
582 |
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
|
583 |
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
|
584 |
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
|
585 |
|
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 (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
|
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 |
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
|
590 |
|
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 |
InvalidateWidget(w, button); |
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 |
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
|
594 |
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
|
595 |
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
|
596 |
|
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_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
|
598 |
_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
|
599 |
_dropdown_selindex = selected; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
600 |
|
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
|
601 |
_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
|
602 |
_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
|
603 |
_dropdown_button = button; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
604 |
|
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
|
605 |
_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
|
606 |
_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
|
607 |
|
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
|
608 |
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
|
609 |
|
842 | 610 |
if ( remove_filtered_strings ) { |
611 |
int j; |
|
612 |
for(j=0; _dropdown_items[j] != INVALID_STRING_ID; j++) { |
|
613 |
if ( disabled_mask & ( 1 << j )) { |
|
614 |
_dropdown_item_count--; |
|
615 |
i--; |
|
616 |
} |
|
617 |
} |
|
618 |
} |
|
619 |
||
876
d275d6d2aa65
(svn r1357) -Fix: Disabled dropdown menu options are gray again (instead of blue)
darkvater
parents:
867
diff
changeset
|
620 |
_dropdown_menu_widgets[0].color = wi->color; |
d275d6d2aa65
(svn r1357) -Fix: Disabled dropdown menu options are gray again (instead of blue)
darkvater
parents:
867
diff
changeset
|
621 |
|
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
|
622 |
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
|
623 |
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
|
624 |
w->top + wi->bottom + 2, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
625 |
wi->right - wi[-1].left + 1, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
626 |
i * 10 + 4, |
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
|
627 |
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
|
628 |
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
|
629 |
_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
|
630 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
631 |
w2->widget[0].color = wi->color; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
632 |
w2->widget[0].right = wi->right - wi[-1].left; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
633 |
w2->widget[0].bottom = i * 10 + 3; |
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
|
634 |
|
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
|
635 |
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
|
636 |
} |