author | miham |
Wed, 17 Aug 2005 12:30:07 +0000 | |
changeset 2349 | df02d0ffb588 |
parent 2218 | abd47ef7d902 |
child 2406 | be5cfb8cd20d |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1657
diff
changeset
|
4 |
#include "openttd.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2154
diff
changeset
|
5 |
#include "functions.h" |
2154
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2064
diff
changeset
|
6 |
#include "player.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1177
diff
changeset
|
7 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
193
diff
changeset
|
8 |
#include "table/strings.h" |
0 | 9 |
#include "window.h" |
10 |
#include "gfx.h" |
|
11 |
#include "viewport.h" |
|
12 |
||
13 |
static Point HandleScrollbarHittest(Scrollbar *sb, int top, int bottom) |
|
14 |
{ |
|
15 |
Point pt; |
|
16 |
int height, count, pos, cap; |
|
17 |
||
18 |
top += 10; |
|
19 |
bottom -= 9; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
20 |
|
0 | 21 |
height = (bottom - top); |
22 |
||
23 |
pos = sb->pos; |
|
24 |
count = sb->count; |
|
25 |
cap = sb->cap; |
|
26 |
||
2026 | 27 |
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
|
28 |
|
0 | 29 |
if (cap > count) cap = count; |
30 |
if (count != 0) |
|
31 |
bottom -= (count - pos - cap) * height / count; |
|
32 |
||
33 |
pt.x = top; |
|
34 |
pt.y = bottom - 1; |
|
35 |
return pt; |
|
36 |
} |
|
37 |
||
38 |
/***************************************************** |
|
39 |
* Special handling for the scrollbar widget type. |
|
40 |
* Handles the special scrolling buttons and other |
|
41 |
* scrolling. |
|
42 |
* Parameters: |
|
43 |
* w - Window. |
|
44 |
* wi - Pointer to the scrollbar widget. |
|
45 |
* x - The X coordinate of the mouse click. |
|
46 |
* y - The Y coordinate of the mouse click. |
|
47 |
*/ |
|
48 |
||
49 |
void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y) |
|
50 |
{ |
|
51 |
int mi, ma, pos; |
|
52 |
Scrollbar *sb; |
|
53 |
||
842 | 54 |
switch (wi->type) { |
55 |
case WWT_SCROLLBAR: { |
|
56 |
// vertical scroller |
|
57 |
w->flags4 &= ~WF_HSCROLL; |
|
58 |
w->flags4 &= ~WF_SCROLL2; |
|
59 |
mi = wi->top; |
|
60 |
ma = wi->bottom; |
|
61 |
pos = y; |
|
62 |
sb = &w->vscroll; |
|
63 |
break; |
|
64 |
} |
|
65 |
case WWT_SCROLL2BAR: { |
|
66 |
// 2nd vertical scroller |
|
67 |
w->flags4 &= ~WF_HSCROLL; |
|
68 |
w->flags4 |= WF_SCROLL2; |
|
69 |
mi = wi->top; |
|
70 |
ma = wi->bottom; |
|
71 |
pos = y; |
|
72 |
sb = &w->vscroll2; |
|
73 |
break; |
|
74 |
} |
|
75 |
case WWT_HSCROLLBAR: { |
|
76 |
// horizontal scroller |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
77 |
w->flags4 &= ~WF_SCROLL2; |
842 | 78 |
w->flags4 |= WF_HSCROLL; |
79 |
mi = wi->left; |
|
80 |
ma = wi->right; |
|
81 |
pos = x; |
|
82 |
sb = &w->hscroll; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
83 |
break; |
842 | 84 |
} |
845
0c66e26fecb2
(svn r1326) fixed compiler warnings in vehicle_gui.c and widget.c
bjarni
parents:
842
diff
changeset
|
85 |
default: return; //this should never happen |
0 | 86 |
} |
87 |
if (pos <= mi+9) { |
|
88 |
// Pressing the upper button? |
|
89 |
if (!_demo_mode) { |
|
90 |
w->flags4 |= WF_SCROLL_UP; |
|
91 |
if (_scroller_click_timeout == 0) { |
|
92 |
_scroller_click_timeout = 6; |
|
93 |
if (sb->pos != 0) sb->pos--; |
|
94 |
} |
|
95 |
_left_button_clicked = false; |
|
96 |
} |
|
97 |
} else if (pos >= ma-10) { |
|
98 |
// Pressing the lower button? |
|
99 |
if (!_demo_mode) { |
|
100 |
w->flags4 |= WF_SCROLL_DOWN; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
101 |
|
0 | 102 |
if (_scroller_click_timeout == 0) { |
103 |
_scroller_click_timeout = 6; |
|
104 |
if ((byte)(sb->pos + sb->cap) < sb->count) |
|
105 |
sb->pos++; |
|
106 |
} |
|
107 |
_left_button_clicked = false; |
|
108 |
} |
|
109 |
} else { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
110 |
// |
0 | 111 |
Point pt = HandleScrollbarHittest(sb, mi, ma); |
112 |
||
113 |
if (pos < pt.x) { |
|
114 |
sb->pos = max(sb->pos - sb->cap, 0); |
|
115 |
} else if (pos > pt.y) { |
|
116 |
sb->pos = min( |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
117 |
sb->pos + sb->cap, |
0 | 118 |
max(sb->count - sb->cap, 0) |
119 |
); |
|
120 |
} else { |
|
121 |
_scrollbar_start_pos = pt.x - mi - 9; |
|
122 |
_scrollbar_size = ma - mi - 23; |
|
123 |
w->flags4 |= WF_SCROLL_MIDDLE; |
|
124 |
_scrolling_scrollbar = true; |
|
125 |
_cursorpos_drag_start = _cursor.pos; |
|
126 |
} |
|
127 |
} |
|
128 |
||
129 |
SetWindowDirty(w); |
|
130 |
} |
|
131 |
||
2021
3be628c59488
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
132 |
/** Returns the index for the widget located at the given position |
3be628c59488
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
133 |
* relative to the window. It includes all widget-corner pixels as well. |
3be628c59488
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
134 |
* @param *w Window to look inside |
3be628c59488
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
135 |
* @param x,y Window client coordinates |
3be628c59488
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
136 |
* @return A widget index, or -1 if no widget was found. |
0 | 137 |
*/ |
138 |
int GetWidgetFromPos(Window *w, int x, int y) |
|
139 |
{ |
|
140 |
const Widget *wi; |
|
141 |
int index, found_index = -1; |
|
142 |
||
143 |
// Go through the widgets and check if we find the widget that the coordinate is |
|
144 |
// inside. |
|
2021
3be628c59488
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
145 |
for (index = 0,wi = w->widget; wi->type != WWT_LAST; index++, wi++) { |
0 | 146 |
if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) |
147 |
continue; |
|
148 |
||
2021
3be628c59488
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
149 |
if (x >= wi->left && x <= wi->right && y >= wi->top && y <= wi->bottom && |
3be628c59488
(svn r2530) - Fix: [ 1219829 ] Mouse-wheel crashes OTTD. Widget detection failed to detect the most-right and most-bottom pixels of a widget. If scrollwheel is used on a not-found widget (such as the background of the toolbar), it will now fail correctly (glx)
Darkvater
parents:
1938
diff
changeset
|
150 |
!HASBIT(w->hidden_state,index)) { |
0 | 151 |
found_index = index; |
152 |
} |
|
153 |
} |
|
154 |
||
155 |
return found_index; |
|
156 |
} |
|
157 |
||
158 |
||
159 |
void DrawWindowWidgets(Window *w) |
|
160 |
{ |
|
161 |
const Widget *wi; |
|
162 |
DrawPixelInfo *dpi = _cur_dpi; |
|
163 |
Rect r; |
|
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 |
wi = w->widget; |
167 |
||
168 |
cur_click = w->click_state; |
|
169 |
cur_disabled = w->disabled_state; |
|
170 |
cur_hidden = w->hidden_state; |
|
171 |
||
172 |
do { |
|
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
173 |
bool clicked = (cur_click & 1); |
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
174 |
|
0 | 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 |
||
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
182 |
switch (wi->type & WWT_MASK) { |
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
183 |
case WWT_PANEL: /* WWT_IMGBTN */ |
0 | 184 |
case WWT_PANEL_2: { |
185 |
int img; |
|
186 |
||
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
187 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
0 | 188 |
|
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
189 |
if ((img = wi->unkA) != 0) { // has an image |
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
190 |
if ((wi->type & WWT_MASK) == WWT_PANEL_2 && clicked) img++; // show diff image when clicked |
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
191 |
|
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
192 |
DrawSprite(img, r.left + 1 + clicked, r.top + 1 + clicked); |
0 | 193 |
} |
194 |
goto draw_default; |
|
195 |
} |
|
196 |
||
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
197 |
case WWT_CLOSEBOX: /* WWT_TEXTBTN */ |
0 | 198 |
case WWT_4: { |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
199 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
0 | 200 |
} |
201 |
/* fall through */ |
|
202 |
||
203 |
case WWT_5: { |
|
204 |
StringID str = wi->unkA; |
|
205 |
||
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
206 |
if ((wi->type&WWT_MASK) == WWT_4 && clicked) str++; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
207 |
|
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
208 |
DrawStringCentered(((r.left + r.right + 1) >> 1) + clicked, ((r.top + r.bottom + 1) >> 1) - 5 + clicked, str, 0); |
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
209 |
//DrawStringCentered((r.left + r.right+1)>>1, ((r.top+r.bottom + 1)>>1) - 5, str, 0); |
2064
c889fcc76398
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2026
diff
changeset
|
210 |
goto draw_default; |
0 | 211 |
} |
212 |
||
213 |
case WWT_6: { |
|
214 |
StringID str; |
|
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
215 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_LOWERED | FR_DARKENED); |
0 | 216 |
|
217 |
if ((str = wi->unkA) != 0) { |
|
218 |
DrawString(r.left+2, r.top+1, str, 0); |
|
219 |
} |
|
220 |
goto draw_default; |
|
221 |
} |
|
222 |
||
223 |
case WWT_MATRIX: { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
224 |
int c, d, ctr; |
0 | 225 |
int x, amt1, amt2; |
226 |
int color; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
227 |
|
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
228 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
229 |
|
0 | 230 |
c = (wi->unkA&0xFF); |
231 |
amt1 = (wi->right - wi->left + 1) / c; |
|
232 |
||
233 |
d = (wi->unkA >> 8); |
|
234 |
amt2 = (wi->bottom - wi->top + 1) / d; |
|
235 |
||
236 |
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
|
237 |
|
0 | 238 |
x = r.left; |
239 |
for(ctr=c; --ctr; ) { |
|
240 |
x += amt1; |
|
241 |
GfxFillRect(x, r.top+1, x, r.bottom-1, color); |
|
242 |
} |
|
243 |
||
244 |
x = r.top; |
|
245 |
for(ctr=d; --ctr; ) { |
|
246 |
x += amt2; |
|
247 |
GfxFillRect(r.left+1, x, r.right-1, x, color); |
|
248 |
} |
|
249 |
||
250 |
color = _color_list[wi->color&0xF].window_color_1b; |
|
251 |
||
252 |
x = r.left-1; |
|
253 |
for(ctr=c; --ctr; ) { |
|
254 |
x += amt1; |
|
255 |
GfxFillRect(x, r.top+1, x, r.bottom-1, color); |
|
256 |
} |
|
257 |
||
258 |
x = r.top-1; |
|
259 |
for(ctr=d; --ctr; ) { |
|
260 |
x += amt2; |
|
261 |
GfxFillRect(r.left+1, x, r.right-1, x, color); |
|
262 |
} |
|
263 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
264 |
goto draw_default; |
0 | 265 |
} |
266 |
||
267 |
// vertical scrollbar |
|
268 |
case WWT_SCROLLBAR: { |
|
269 |
Point pt; |
|
270 |
int c1,c2; |
|
271 |
||
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
272 |
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
273 |
|
0 | 274 |
// draw up/down buttons |
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
275 |
clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP); |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
276 |
DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
277 |
DoDrawString("\xA0", r.left + 2 + clicked, r.top + clicked, 0x10); |
0 | 278 |
|
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
279 |
clicked = !!(((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_DOWN)); |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
280 |
DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
281 |
DoDrawString("\xAA", r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); |
0 | 282 |
|
283 |
c1 = _color_list[wi->color&0xF].window_color_1a; |
|
284 |
c2 = _color_list[wi->color&0xF].window_color_2; |
|
285 |
||
286 |
// draw "shaded" background |
|
287 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2); |
|
2218
abd47ef7d902
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
celestar
parents:
2186
diff
changeset
|
288 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | PALETTE_MODIFIER_GREYOUT); |
0 | 289 |
|
290 |
// draw shaded lines |
|
291 |
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1); |
|
292 |
GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
|
293 |
GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
|
294 |
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
|
295 |
|
0 | 296 |
pt = HandleScrollbarHittest(&w->vscroll, r.top, r.bottom); |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
297 |
DrawFrameRect(r.left, pt.x, r.right, pt.y, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_MIDDLE ? FR_LOWERED : 0); |
842 | 298 |
break; |
299 |
} |
|
300 |
case WWT_SCROLL2BAR: { |
|
301 |
Point pt; |
|
302 |
int c1,c2; |
|
303 |
||
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
304 |
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
305 |
|
842 | 306 |
// draw up/down buttons |
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
307 |
clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2)); |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
308 |
DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
309 |
DoDrawString("\xA0", r.left + 2 + clicked, r.top + clicked, 0x10); |
842 | 310 |
|
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
311 |
clicked = !!((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_DOWN | WF_SCROLL2)); |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
312 |
DrawFrameRect(r.left, r.bottom - 9, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
313 |
DoDrawString("\xAA", r.left + 2 + clicked, r.bottom - 9 + clicked, 0x10); |
842 | 314 |
|
315 |
c1 = _color_list[wi->color&0xF].window_color_1a; |
|
316 |
c2 = _color_list[wi->color&0xF].window_color_2; |
|
317 |
||
318 |
// draw "shaded" background |
|
319 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2); |
|
2218
abd47ef7d902
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
celestar
parents:
2186
diff
changeset
|
320 |
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | PALETTE_MODIFIER_GREYOUT); |
842 | 321 |
|
322 |
// draw shaded lines |
|
323 |
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1); |
|
324 |
GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2); |
|
325 |
GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1); |
|
326 |
GfxFillRect(r.left+8, r.top+10, r.left+8, r.bottom-10, c2); |
|
327 |
||
328 |
pt = HandleScrollbarHittest(&w->vscroll2, r.top, r.bottom); |
|
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
329 |
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) ? FR_LOWERED : 0); |
0 | 330 |
break; |
331 |
} |
|
332 |
||
333 |
// horizontal scrollbar |
|
334 |
case WWT_HSCROLLBAR: { |
|
335 |
Point pt; |
|
336 |
int c1,c2; |
|
337 |
||
894
ab8a5f7ea3db
(svn r1380) -Fix: missed widget fixes; thanks Jango and TestMan57
darkvater
parents:
893
diff
changeset
|
338 |
assert(r.bottom - r.top == 11); // XXX - to ensure the same sizes are used everywhere! |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
339 |
|
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
340 |
clicked = !!((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL)) == (WF_SCROLL_UP | WF_HSCROLL)); |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
341 |
DrawFrameRect(r.left, r.top, r.left + 9, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
342 |
DrawSprite(SPR_ARROW_LEFT, r.left + 1 + clicked, r.top + 1 + clicked); |
0 | 343 |
|
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
344 |
clicked = !!((w->flags4 & (WF_SCROLL_DOWN | WF_HSCROLL)) == (WF_SCROLL_DOWN | WF_HSCROLL)); |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
345 |
DrawFrameRect(r.right-9, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
346 |
DrawSprite(SPR_ARROW_RIGHT, r.right - 8 + clicked, r.top + 1 + clicked); |
0 | 347 |
|
348 |
c1 = _color_list[wi->color&0xF].window_color_1a; |
|
349 |
c2 = _color_list[wi->color&0xF].window_color_2; |
|
350 |
||
351 |
// draw "shaded" background |
|
352 |
GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c2); |
|
2218
abd47ef7d902
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
celestar
parents:
2186
diff
changeset
|
353 |
GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c1 | PALETTE_MODIFIER_GREYOUT); |
0 | 354 |
|
355 |
// draw shaded lines |
|
356 |
GfxFillRect(r.left+10, r.top+2, r.right-10, r.top+2, c1); |
|
357 |
GfxFillRect(r.left+10, r.top+3, r.right-10, r.top+3, c2); |
|
358 |
GfxFillRect(r.left+10, r.top+7, r.right-10, r.top+7, c1); |
|
359 |
GfxFillRect(r.left+10, r.top+8, r.right-10, r.top+8, c2); |
|
360 |
||
361 |
// draw actual scrollbar |
|
362 |
pt = HandleScrollbarHittest(&w->hscroll, r.left, r.right); |
|
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
363 |
DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? FR_LOWERED : 0); |
0 | 364 |
|
365 |
break; |
|
366 |
} |
|
367 |
||
368 |
case WWT_FRAME: { |
|
369 |
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
|
370 |
int x2 = r.left; // by default the left side is the left side of the widget |
0 | 371 |
|
372 |
if (wi->unkA != 0) { |
|
373 |
x2 = DrawString(r.left+6, r.top, wi->unkA, 0); |
|
374 |
} |
|
375 |
||
376 |
c1 = _color_list[wi->color].window_color_1a; |
|
377 |
c2 = _color_list[wi->color].window_color_2; |
|
378 |
||
379 |
//Line from upper left corner to start of text |
|
380 |
GfxFillRect(r.left, r.top+4, r.left+4,r.top+4, c1); |
|
381 |
GfxFillRect(r.left+1, r.top+5, r.left+4,r.top+5, c2); |
|
382 |
||
383 |
// Line from end of text to upper right corner |
|
384 |
GfxFillRect(x2, r.top+4, r.right-1,r.top+4,c1); |
|
385 |
GfxFillRect(x2, r.top+5, r.right-2,r.top+5,c2); |
|
386 |
||
387 |
// Line from upper left corner to bottom left corner |
|
388 |
GfxFillRect(r.left, r.top+5, r.left, r.bottom-1, c1); |
|
389 |
GfxFillRect(r.left+1, r.top+6, r.left+1, r.bottom-2, c2); |
|
390 |
||
391 |
//Line from upper right corner to bottom right corner |
|
392 |
GfxFillRect(r.right-1, r.top+5, r.right-1, r.bottom-2, c1); |
|
393 |
GfxFillRect(r.right, r.top+4, r.right, r.bottom-1, c2); |
|
394 |
||
395 |
GfxFillRect(r.left+1, r.bottom-1, r.right-1, r.bottom-1, c1); |
|
396 |
GfxFillRect(r.left, r.bottom, r.right, r.bottom, c2); |
|
397 |
||
2064
c889fcc76398
(svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents:
2026
diff
changeset
|
398 |
goto draw_default; |
0 | 399 |
} |
400 |
||
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
|
401 |
case WWT_STICKYBOX: { |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
402 |
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
403 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
404 |
DrawSprite((clicked) ? SPR_PIN_UP : SPR_PIN_DOWN, r.left + 2 + clicked, r.top + 3 + clicked); |
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
|
405 |
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
|
406 |
} |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
407 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
408 |
case WWT_RESIZEBOX: { |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
409 |
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere! |
915 | 410 |
|
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
411 |
clicked = !!(w->flags4 & WF_SIZING); |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
412 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, (clicked) ? FR_LOWERED : 0); |
1657
eb57fee328fb
(svn r2161) - Fix: When resizing a window, the button is also visibly depressed
Darkvater
parents:
1363
diff
changeset
|
413 |
DrawSprite(SPR_WINDOW_RESIZE, r.left + 3 + clicked, r.top + 3 + clicked); |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
414 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
415 |
} |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
416 |
|
0 | 417 |
case WWT_CAPTION: { |
893
d9e69e5060ba
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
884
diff
changeset
|
418 |
assert(r.bottom - r.top == 13); // XXX - to ensure the same sizes are used everywhere! |
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
419 |
DrawFrameRect(r.left, r.top, r.right, r.bottom, wi->color, FR_BORDERONLY); |
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
420 |
DrawFrameRect(r.left+1, r.top+1, r.right-1, r.bottom-1, wi->color, (w->caption_color == 0xFF) ? FR_LOWERED | FR_DARKENED : FR_LOWERED | FR_DARKENED | FR_BORDERONLY); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
421 |
|
0 | 422 |
if (w->caption_color != 0xFF) { |
423 |
GfxFillRect(r.left+2, r.top+2, r.right-2, r.bottom-2, _color_list[_player_colors[w->caption_color]].window_color_1b); |
|
424 |
} |
|
425 |
||
426 |
DrawStringCentered( (r.left+r.right+1)>>1, r.top+2, wi->unkA, 0x84); |
|
427 |
draw_default:; |
|
428 |
if (cur_disabled & 1) { |
|
2218
abd47ef7d902
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
celestar
parents:
2186
diff
changeset
|
429 |
GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _color_list[wi->color&0xF].unk2 | PALETTE_MODIFIER_GREYOUT); |
0 | 430 |
} |
431 |
} |
|
432 |
} |
|
433 |
} 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
|
434 |
|
0 | 435 |
|
436 |
if (w->flags4 & WF_WHITE_BORDER_MASK) { |
|
437 |
//DrawFrameRect(w->left, w->top, w->left + w->width-1, w->top+w->height-1, 0xF, 0x10); |
|
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
438 |
DrawFrameRect(0, 0, w->width-1, w->height-1, 0xF, FR_BORDERONLY); |
0 | 439 |
} |
440 |
||
441 |
} |
|
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
|
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 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
|
444 |
static uint32 _dropdown_disabled; |
842 | 445 |
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
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
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
|
452 |
static byte _dropdown_var2; |
1177
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
453 |
static uint32 _dropdown_disabled_items; |
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
|
454 |
|
883
0c54c6fc1790
(svn r1368) -Fix: Disabled dropdown menu options are gray again (instead of blue)
truelight
parents:
876
diff
changeset
|
455 |
static const 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
|
456 |
{ 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
|
457 |
{ 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
|
458 |
}; |
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 |
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
|
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 |
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
|
463 |
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
|
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 |
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
|
466 |
return -1; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
467 |
|
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
|
468 |
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
|
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 |
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
|
471 |
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
|
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 |
item = y / 10; |
1177
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
474 |
if (item >= _dropdown_item_count || (HASBIT(_dropdown_disabled,item) && !_dropdown_disabled_items) || _dropdown_items[item] == 0) |
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
|
475 |
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
|
476 |
|
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
|
477 |
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
|
478 |
} |
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
|
479 |
|
1095 | 480 |
static void DropdownMenuWndProc(Window *w, WindowEvent *e) |
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 |
{ |
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 |
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
|
483 |
|
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
|
484 |
switch(e->event) { |
842 | 485 |
case WE_PAINT: { |
486 |
int x,y,i,sel; |
|
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
|
487 |
|
842 | 488 |
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
|
489 |
|
842 | 490 |
x = 1; |
491 |
y = 2; |
|
492 |
sel = _dropdown_selindex; |
|
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
|
493 |
|
842 | 494 |
for(i=0; _dropdown_items[i] != INVALID_STRING_ID; i++) { |
1177
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
495 |
if (HASBIT(_dropdown_disabled_items, i)) { |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
496 |
sel--; |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
497 |
continue; |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
498 |
} |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
499 |
if (_dropdown_items[i] != 0) { |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
500 |
if (sel == 0) { |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
501 |
GfxFillRect(x+1, y, x+w->width-4, y + 9, 0); |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
502 |
} |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
503 |
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
|
504 |
|
1177
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
505 |
if (HASBIT(_dropdown_disabled, i) && !_dropdown_disabled_items) { |
2218
abd47ef7d902
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
celestar
parents:
2186
diff
changeset
|
506 |
GfxFillRect(x, y, x+w->width-3, y + 9, PALETTE_MODIFIER_GREYOUT | |
1177
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
507 |
_color_list[_dropdown_menu_widgets[0].color].window_color_bga); |
842 | 508 |
} |
1177
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
509 |
} else { |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
510 |
int color_1 = _color_list[_dropdown_menu_widgets[0].color].window_color_1a; |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
511 |
int color_2 = _color_list[_dropdown_menu_widgets[0].color].window_color_2; |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
512 |
GfxFillRect(x+1, y+3, x+w->width-5, y+3, color_1); |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
513 |
GfxFillRect(x+1, y+4, x+w->width-5, y+4, color_2); |
842 | 514 |
} |
1177
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
515 |
y += 10; |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
516 |
sel--; |
842 | 517 |
} |
518 |
} break; |
|
519 |
||
520 |
case WE_CLICK: { |
|
521 |
item = GetDropdownItem(w); |
|
522 |
if (item >= 0) { |
|
1177
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
523 |
// make sure that item match the index of the string, that was clicked |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
524 |
// basically we just add one for each hidden item before the clicked one |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
525 |
byte counter; |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
526 |
for (counter = 0 ; item >= counter; ++counter) { |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
527 |
if (HASBIT(_dropdown_disabled_items, counter)) item++; |
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
528 |
} |
842 | 529 |
_dropdown_var1 = 4; |
530 |
_dropdown_selindex = item; |
|
531 |
SetWindowDirty(w); |
|
532 |
} |
|
533 |
} break; |
|
534 |
||
535 |
case WE_MOUSELOOP: { |
|
536 |
Window *w2 = FindWindowById(_dropdown_windowclass, _dropdown_windownum); |
|
537 |
if (w2 == NULL) { |
|
538 |
DeleteWindow(w); |
|
539 |
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
|
540 |
} |
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
|
541 |
|
842 | 542 |
if (_dropdown_var1 != 0 && --_dropdown_var1 == 0) { |
543 |
WindowEvent e; |
|
544 |
e.event = WE_DROPDOWN_SELECT; |
|
545 |
e.dropdown.button = _dropdown_button; |
|
546 |
e.dropdown.index = _dropdown_selindex; |
|
547 |
w2->wndproc(w2, &e); |
|
548 |
DeleteWindow(w); |
|
549 |
return; |
|
550 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
551 |
|
842 | 552 |
if (_dropdown_var2 != 0) { |
553 |
item = GetDropdownItem(w); |
|
554 |
||
555 |
if (!_left_button_clicked) { |
|
556 |
_dropdown_var2 = 0; |
|
557 |
if (item < 0) |
|
558 |
return; |
|
559 |
_dropdown_var1 = 2; |
|
560 |
} else { |
|
561 |
if (item < 0) |
|
562 |
return; |
|
563 |
} |
|
564 |
||
565 |
_dropdown_selindex = item; |
|
566 |
SetWindowDirty(w); |
|
567 |
} |
|
568 |
} break; |
|
569 |
||
570 |
case WE_DESTROY: { |
|
571 |
Window *w2 = FindWindowById(_dropdown_windowclass, _dropdown_windownum); |
|
572 |
if (w2 != NULL) { |
|
573 |
CLRBIT(w2->click_state, _dropdown_button); |
|
574 |
InvalidateWidget(w2, _dropdown_button); |
|
575 |
} |
|
576 |
} 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
|
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 |
} |
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 |
|
842 | 580 |
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
|
581 |
{ |
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 |
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
|
583 |
WindowClass cls; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
584 |
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
|
585 |
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
|
586 |
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
|
587 |
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
|
588 |
|
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
|
589 |
_dropdown_disabled = disabled_mask; |
842 | 590 |
_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
|
591 |
|
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
|
592 |
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
|
593 |
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
|
594 |
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
|
595 |
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
|
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 |
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
|
598 |
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
|
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 |
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
|
601 |
|
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 |
InvalidateWidget(w, button); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
603 |
|
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
|
604 |
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
|
605 |
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
|
606 |
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
|
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 |
_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
|
609 |
_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
|
610 |
_dropdown_selindex = selected; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
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_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
|
613 |
_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
|
614 |
_dropdown_button = button; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
615 |
|
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
|
616 |
_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
|
617 |
_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
|
618 |
|
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 |
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
|
620 |
|
842 | 621 |
if ( remove_filtered_strings ) { |
622 |
int j; |
|
623 |
for(j=0; _dropdown_items[j] != INVALID_STRING_ID; j++) { |
|
624 |
if ( disabled_mask & ( 1 << j )) { |
|
625 |
_dropdown_item_count--; |
|
626 |
i--; |
|
627 |
} |
|
628 |
} |
|
629 |
} |
|
630 |
||
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
|
631 |
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
|
632 |
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
|
633 |
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
|
634 |
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
|
635 |
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
|
636 |
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
|
637 |
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
|
638 |
_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
|
639 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
860
diff
changeset
|
640 |
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
|
641 |
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
|
642 |
w2->widget[0].bottom = i * 10 + 3; |
1177
6adbf59f59a3
(svn r1679) Fix: dropdown menus now returns the index of the string that was clicked even if a previous item is hidden
bjarni
parents:
1095
diff
changeset
|
643 |
_dropdown_disabled_items = remove_filtered_strings ? disabled_mask : 0; |
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
|
644 |
|
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
|
645 |
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
|
646 |
} |