author | Darkvater |
Mon, 31 Jul 2006 22:40:55 +0000 | |
changeset 4204 | 3aa39be759f2 |
parent 4171 | 5c6e60c392c3 |
child 4261 | 28670f743746 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1688
diff
changeset
|
4 |
#include "openttd.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
5 |
#include "functions.h" |
1309
4403a69da4f8
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1097
diff
changeset
|
6 |
#include "strings.h" |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
7 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
8 |
#include "table/strings.h" |
0 | 9 |
#include "window.h" |
3155
c4673c936039
(svn r3778) - Fix crash when resizing news history window.
peter1138
parents:
3143
diff
changeset
|
10 |
#include "gui.h" |
0 | 11 |
#include "viewport.h" |
12 |
#include "gfx.h" |
|
13 |
#include "news.h" |
|
14 |
#include "vehicle.h" |
|
337
cbe0c766c947
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
15 |
#include "sound.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2150
diff
changeset
|
16 |
#include "variables.h" |
0 | 17 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
18 |
/* News system |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
19 |
News system is realized as a FIFO queue (in an array) |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
20 |
The positions in the queue can't be rearranged, we only access |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
21 |
the array elements through pointers to the elements. Once the |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
22 |
array is full, the oldest entry (_oldest_news) is being overwritten |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
23 |
by the newest (_latest news). |
0 | 24 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
25 |
oldest current lastest |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
26 |
| | | |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
27 |
[O------------F-------------C---------L ] |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
28 |
| |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
29 |
forced |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
30 |
*/ |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
31 |
|
427 | 32 |
#define MAX_NEWS 30 |
33 |
||
34 |
#define INVALID_NEWS 255 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
35 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
36 |
static NewsItem _news_items[MAX_NEWS]; |
427 | 37 |
static byte _current_news = INVALID_NEWS; // points to news item that should be shown next |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
38 |
static byte _oldest_news = 0; // points to first item in fifo queue |
427 | 39 |
static byte _latest_news = INVALID_NEWS; // points to last item in fifo queue |
40 |
/* if the message being shown was forced by the user, its index is stored in |
|
41 |
* _forced_news. forced_news is INVALID_NEWS otherwise. |
|
42 |
* (Users can force messages through history or "last message") */ |
|
43 |
static byte _forced_news = INVALID_NEWS; |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
44 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
45 |
static byte _total_news = 0; // total news count |
0 | 46 |
|
47 |
void DrawNewsNewTrainAvail(Window *w); |
|
48 |
void DrawNewsNewRoadVehAvail(Window *w); |
|
49 |
void DrawNewsNewShipAvail(Window *w); |
|
50 |
void DrawNewsNewAircraftAvail(Window *w); |
|
51 |
void DrawNewsBankrupcy(Window *w); |
|
427 | 52 |
static void MoveToNexItem(void); |
0 | 53 |
|
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
54 |
StringID GetNewsStringNewTrainAvail(const NewsItem *ni); |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
55 |
StringID GetNewsStringNewRoadVehAvail(const NewsItem *ni); |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
56 |
StringID GetNewsStringNewShipAvail(const NewsItem *ni); |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
57 |
StringID GetNewsStringNewAircraftAvail(const NewsItem *ni); |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
58 |
StringID GetNewsStringBankrupcy(const NewsItem *ni); |
0 | 59 |
|
60 |
static DrawNewsCallbackProc * const _draw_news_callback[] = { |
|
427 | 61 |
DrawNewsNewTrainAvail, /* DNC_TRAINAVAIL */ |
62 |
DrawNewsNewRoadVehAvail, /* DNC_ROADAVAIL */ |
|
63 |
DrawNewsNewShipAvail, /* DNC_SHIPAVAIL */ |
|
0 | 64 |
DrawNewsNewAircraftAvail, /* DNC_AIRCRAFTAVAIL */ |
427 | 65 |
DrawNewsBankrupcy, /* DNC_BANKRUPCY */ |
0 | 66 |
}; |
67 |
||
68 |
GetNewsStringCallbackProc * const _get_news_string_callback[] = { |
|
427 | 69 |
GetNewsStringNewTrainAvail, /* DNC_TRAINAVAIL */ |
70 |
GetNewsStringNewRoadVehAvail, /* DNC_ROADAVAIL */ |
|
71 |
GetNewsStringNewShipAvail, /* DNC_SHIPAVAIL */ |
|
0 | 72 |
GetNewsStringNewAircraftAvail, /* DNC_AIRCRAFTAVAIL */ |
427 | 73 |
GetNewsStringBankrupcy, /* DNC_BANKRUPCY */ |
0 | 74 |
}; |
75 |
||
427 | 76 |
void InitNewsItemStructs(void) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
77 |
{ |
427 | 78 |
memset(_news_items, 0, sizeof(_news_items)); |
79 |
_current_news = INVALID_NEWS; |
|
89 | 80 |
_oldest_news = 0; |
427 | 81 |
_latest_news = INVALID_NEWS; |
82 |
_forced_news = INVALID_NEWS; |
|
89 | 83 |
_total_news = 0; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
84 |
} |
0 | 85 |
|
427 | 86 |
void DrawNewsBorder(const Window *w) |
0 | 87 |
{ |
88 |
int left = 0; |
|
89 |
int right = w->width - 1; |
|
90 |
int top = 0; |
|
91 |
int bottom = w->height - 1; |
|
92 |
||
93 |
GfxFillRect(left, top, right, bottom, 0xF); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
94 |
|
0 | 95 |
GfxFillRect(left, top, left, bottom, 0xD7); |
96 |
GfxFillRect(right, top, right, bottom, 0xD7); |
|
97 |
GfxFillRect(left, top, right, top, 0xD7); |
|
98 |
GfxFillRect(left, bottom, right, bottom, 0xD7); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
99 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
100 |
DrawString(left + 2, top + 1, STR_00C6, 0); |
0 | 101 |
} |
102 |
||
103 |
static void NewsWindowProc(Window *w, WindowEvent *e) |
|
104 |
{ |
|
427 | 105 |
switch (e->event) { |
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
106 |
case WE_CREATE: { /* If chatbar is open at creation time, we need to go above it */ |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
107 |
const Window *w1 = FindWindowById(WC_SEND_NETWORK_MSG, 0); |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
108 |
w->message.msg = (w1 != NULL) ? w1->height : 0; |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
109 |
} break; |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
110 |
|
0 | 111 |
case WE_PAINT: { |
427 | 112 |
const NewsItem *ni = WP(w, news_d).ni; |
0 | 113 |
ViewPort *vp; |
114 |
||
427 | 115 |
switch (ni->display_mode) { |
116 |
case NM_NORMAL: |
|
117 |
case NM_THIN: { |
|
118 |
DrawNewsBorder(w); |
|
0 | 119 |
|
427 | 120 |
DrawString(2, 1, STR_00C6, 0); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
121 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
122 |
SetDParam(0, ni->date); |
427 | 123 |
DrawStringRightAligned(428, 1, STR_01FF, 0); |
124 |
||
125 |
if (!(ni->flags & NF_VIEWPORT)) { |
|
126 |
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); |
|
127 |
DrawStringMultiCenter(215, ni->display_mode == NM_NORMAL ? 76 : 56, |
|
128 |
ni->string_id, 426); |
|
129 |
} else { |
|
130 |
byte bk = _display_opt; |
|
497
4d1c889526ee
(svn r787) Invert the sense of the DO_TRANS_BUILDINGS flag to be consistent with its own name and all other DO_* flags.
tron
parents:
427
diff
changeset
|
131 |
_display_opt &= ~DO_TRANS_BUILDINGS; |
427 | 132 |
DrawWindowViewport(w); |
133 |
_display_opt = bk; |
|
134 |
||
135 |
/* Shade the viewport into gray, or color*/ |
|
136 |
vp = w->viewport; |
|
137 |
GfxFillRect(vp->left - w->left, vp->top - w->top, |
|
138 |
vp->left - w->left + vp->width - 1, vp->top - w->top + vp->height - 1, |
|
2227
4a6aba550173
(svn r2747) -Fix: r2736 broke the newpaper display. Sorry.
celestar
parents:
2186
diff
changeset
|
139 |
(ni->flags & NF_INCOLOR ? 0x322 : 0x323) | USE_COLORTABLE |
427 | 140 |
); |
141 |
||
142 |
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); |
|
143 |
DrawStringMultiCenter(w->width / 2, 20, ni->string_id, 428); |
|
144 |
} |
|
145 |
break; |
|
0 | 146 |
} |
427 | 147 |
|
148 |
case NM_CALLBACK: { |
|
149 |
_draw_news_callback[ni->callback](w); |
|
150 |
break; |
|
151 |
} |
|
152 |
||
153 |
default: { |
|
154 |
DrawWindowWidgets(w); |
|
155 |
if (!(ni->flags & NF_VIEWPORT)) { |
|
156 |
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); |
|
157 |
DrawStringMultiCenter(140, 38, ni->string_id, 276); |
|
158 |
} else { |
|
159 |
DrawWindowViewport(w); |
|
160 |
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); |
|
161 |
DrawStringMultiCenter(w->width / 2, w->height - 16, ni->string_id, 276); |
|
162 |
} |
|
163 |
break; |
|
0 | 164 |
} |
165 |
} |
|
166 |
} break; |
|
167 |
||
168 |
case WE_CLICK: { |
|
427 | 169 |
switch (e->click.widget) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
170 |
case 1: { |
427 | 171 |
NewsItem *ni = WP(w, news_d).ni; |
80
405a85ce732a
(svn r81) -Fix: news_gui.c contained a MSVC compile error
truelight
parents:
79
diff
changeset
|
172 |
DeleteWindow(w); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
173 |
ni->duration = 0; |
427 | 174 |
_forced_news = INVALID_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
175 |
} break; |
0 | 176 |
case 0: { |
427 | 177 |
NewsItem *ni = WP(w, news_d).ni; |
0 | 178 |
if (ni->flags & NF_VEHICLE) { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
179 |
Vehicle *v = GetVehicle(ni->data_a); |
0 | 180 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
181 |
} else if (ni->flags & NF_TILE) { |
|
182 |
if (!ScrollMainWindowToTile(ni->data_a) && ni->data_b != 0) |
|
183 |
ScrollMainWindowToTile(ni->data_b); |
|
184 |
} |
|
185 |
} break; |
|
186 |
} |
|
187 |
} break; |
|
188 |
||
189 |
case WE_KEYPRESS: |
|
190 |
if (e->keypress.keycode == WKC_SPACE) { |
|
191 |
// Don't continue. |
|
192 |
e->keypress.cont = false; |
|
193 |
DeleteWindow(w); |
|
194 |
} |
|
195 |
break; |
|
196 |
||
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
197 |
case WE_MESSAGE: /* The chatbar has notified us that is was either created or closed */ |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
198 |
switch (e->message.msg) { |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
199 |
case WE_CREATE: w->message.msg = e->message.wparam; break; |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
200 |
case WE_DESTROY: w->message.msg = 0; break; |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
201 |
} |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
202 |
break; |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
203 |
|
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
204 |
case WE_TICK: { /* Scroll up newsmessages from the bottom in steps of 4 pixels */ |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
205 |
int diff; |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
206 |
int y = max(w->top - 4, _screen.height - w->height - 12 - w->message.msg); |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
207 |
if (y == w->top) return; |
0 | 208 |
|
209 |
if (w->viewport != NULL) |
|
210 |
w->viewport->top += y - w->top; |
|
211 |
||
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
212 |
diff = abs(w->top - y); |
0 | 213 |
w->top = y; |
214 |
||
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
215 |
SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height); |
0 | 216 |
} break; |
217 |
} |
|
218 |
} |
|
219 |
||
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
220 |
// returns the correct index in the array |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
221 |
// (to deal with overflows) |
1095 | 222 |
static byte increaseIndex(byte i) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
223 |
{ |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3155
diff
changeset
|
224 |
if (i == INVALID_NEWS) return 0; |
83
bd21afea96d8
(svn r84) Improved news system code a little to avoid potential memory leaks
dominik
parents:
80
diff
changeset
|
225 |
i++; |
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3155
diff
changeset
|
226 |
if (i >= MAX_NEWS) i = i % MAX_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
227 |
return i; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
228 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
229 |
|
0 | 230 |
void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b) |
231 |
{ |
|
232 |
NewsItem *ni; |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
233 |
Window *w; |
0 | 234 |
|
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3155
diff
changeset
|
235 |
if (_game_mode == GM_MENU) return; |
0 | 236 |
|
102
1d277a07f1f1
(svn r103) Fix: rare newspaper crash with too many messages [ 1009976 ] (thx to blathij)s
dominik
parents:
94
diff
changeset
|
237 |
// check the rare case that the oldest (to be overwritten) news item is open |
935 | 238 |
if (_total_news==MAX_NEWS && (_oldest_news == _current_news || _oldest_news == _forced_news)) |
102
1d277a07f1f1
(svn r103) Fix: rare newspaper crash with too many messages [ 1009976 ] (thx to blathij)s
dominik
parents:
94
diff
changeset
|
239 |
MoveToNexItem(); |
1d277a07f1f1
(svn r103) Fix: rare newspaper crash with too many messages [ 1009976 ] (thx to blathij)s
dominik
parents:
94
diff
changeset
|
240 |
|
427 | 241 |
_forced_news = INVALID_NEWS; |
242 |
if (_total_news < MAX_NEWS) _total_news++; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
243 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
244 |
// make sure our pointer isn't overflowing |
83
bd21afea96d8
(svn r84) Improved news system code a little to avoid potential memory leaks
dominik
parents:
80
diff
changeset
|
245 |
_latest_news = increaseIndex(_latest_news); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
246 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
247 |
// overwrite oldest news entry |
427 | 248 |
if (_oldest_news == _latest_news && _news_items[_oldest_news].string_id != 0) |
83
bd21afea96d8
(svn r84) Improved news system code a little to avoid potential memory leaks
dominik
parents:
80
diff
changeset
|
249 |
_oldest_news = increaseIndex(_oldest_news); // but make sure we're not overflowing here |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
250 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
251 |
// add news to _latest_news |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
252 |
ni = &_news_items[_latest_news]; |
745
6073a73d0b13
(svn r1201) -Fix: I forgot to add a * in r1183 ;)
truelight
parents:
731
diff
changeset
|
253 |
memset(ni, 0, sizeof(*ni)); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
254 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
255 |
ni->string_id = string; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
256 |
ni->display_mode = (byte)flags; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
257 |
ni->flags = (byte)(flags >> 8) | NF_NOEXPIRE; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
258 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
259 |
// show this news message in color? |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
260 |
if (_date >= ConvertIntDate(_patches.colored_news_date)) |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
261 |
ni->flags |= NF_INCOLOR; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
262 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
263 |
ni->type = (byte)(flags >> 16); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
264 |
ni->callback = (byte)(flags >> 24); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
265 |
ni->data_a = data_a; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
266 |
ni->data_b = data_b; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
267 |
ni->date = _date; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
268 |
COPY_OUT_DPARAM(ni->params, 0, lengthof(ni->params)); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
269 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
270 |
w = FindWindowById(WC_MESSAGE_HISTORY, 0); |
427 | 271 |
if (w == NULL) return; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
272 |
SetWindowDirty(w); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
273 |
w->vscroll.count = _total_news; |
0 | 274 |
} |
275 |
||
715
28dd55cc55ae
(svn r1167) Feature: Added the possibility to add validation functions to NewsItems. This is now done for "Train in depot" messages. Before displaying such a message, it checks if the train really still is in the depot. Can be applied to other news items as well.
dominik
parents:
541
diff
changeset
|
276 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
277 |
// don't show item if it's older than x days |
0 | 278 |
static const byte _news_items_age[] = {60, 60, 90, 60, 90, 30, 150, 30, 90, 180}; |
279 |
||
280 |
static const Widget _news_type13_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
281 |
{ WWT_PANEL, RESIZE_NONE, 15, 0, 429, 0, 169, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
282 |
{ WWT_PANEL, RESIZE_NONE, 15, 0, 10, 0, 11, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
102
diff
changeset
|
283 |
{ WIDGETS_END}, |
0 | 284 |
}; |
285 |
||
286 |
static WindowDesc _news_type13_desc = { |
|
287 |
WDP_CENTER, 476, 430, 170, |
|
427 | 288 |
WC_NEWS_WINDOW, 0, |
0 | 289 |
WDF_DEF_WIDGET, |
290 |
_news_type13_widgets, |
|
291 |
NewsWindowProc |
|
292 |
}; |
|
293 |
||
294 |
static const Widget _news_type2_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
295 |
{ WWT_PANEL, RESIZE_NONE, 15, 0, 429, 0, 129, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
296 |
{ WWT_PANEL, RESIZE_NONE, 15, 0, 10, 0, 11, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
102
diff
changeset
|
297 |
{ WIDGETS_END}, |
0 | 298 |
}; |
299 |
||
300 |
static WindowDesc _news_type2_desc = { |
|
301 |
WDP_CENTER, 476, 430, 130, |
|
427 | 302 |
WC_NEWS_WINDOW, 0, |
0 | 303 |
WDF_DEF_WIDGET, |
304 |
_news_type2_widgets, |
|
305 |
NewsWindowProc |
|
306 |
}; |
|
307 |
||
308 |
static const Widget _news_type0_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
309 |
{ WWT_PANEL, RESIZE_NONE, 5, 0, 279, 14, 86, 0x0, STR_NULL}, |
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
310 |
{ WWT_CLOSEBOX, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
311 |
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 279, 0, 13, STR_012C_MESSAGE, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
312 |
{ WWT_6, RESIZE_NONE, 5, 2, 277, 16, 64, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
102
diff
changeset
|
313 |
{ WIDGETS_END}, |
0 | 314 |
}; |
315 |
||
316 |
static WindowDesc _news_type0_desc = { |
|
317 |
WDP_CENTER, 476, 280, 87, |
|
427 | 318 |
WC_NEWS_WINDOW, 0, |
0 | 319 |
WDF_DEF_WIDGET, |
320 |
_news_type0_widgets, |
|
321 |
NewsWindowProc |
|
322 |
}; |
|
323 |
||
427 | 324 |
static const SoundFx _news_sounds[] = { |
325 |
SND_1D_APPLAUSE, |
|
326 |
SND_1D_APPLAUSE, |
|
327 |
0, |
|
328 |
0, |
|
329 |
0, |
|
330 |
0, |
|
331 |
SND_1E_OOOOH, |
|
332 |
0, |
|
333 |
0, |
|
334 |
0 |
|
335 |
}; |
|
0 | 336 |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
337 |
/** Get the value of an item of the news-display settings. This is |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
338 |
* a little tricky since on/off/summary must use 2 bits to store the value |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
339 |
* @param item the item whose value is requested |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
340 |
* @return return the found value which is between 0-2 |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
341 |
*/ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
342 |
static inline byte GetNewsDisplayValue(byte item) |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
343 |
{ |
2549 | 344 |
assert(item < 10 && GB(_news_display_opt, item * 2, 2) <= 2); |
345 |
return GB(_news_display_opt, item * 2, 2); |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
346 |
} |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
347 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
348 |
/** Set the value of an item in the news-display settings. This is |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
349 |
* a little tricky since on/off/summary must use 2 bits to store the value |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
350 |
* @param item the item whose value is being set |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
351 |
* @param val new value |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
352 |
*/ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
353 |
static inline void SetNewsDisplayValue(byte item, byte val) |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
354 |
{ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
355 |
assert(item < 10 && val <= 2); |
2549 | 356 |
SB(_news_display_opt, item * 2, 2, val); |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
357 |
} |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
358 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
359 |
// open up an own newspaper window for the news item |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
360 |
static void ShowNewspaper(NewsItem *ni) |
0 | 361 |
{ |
362 |
Window *w; |
|
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2227
diff
changeset
|
363 |
SoundFx sound; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
364 |
int top; |
427 | 365 |
ni->flags &= ~(NF_NOEXPIRE | NF_FORCE_BIG); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
366 |
ni->duration = 555; |
0 | 367 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
368 |
sound = _news_sounds[ni->type]; |
2639 | 369 |
if (sound != 0) SndPlayFx(sound); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
370 |
|
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
371 |
top = _screen.height; |
427 | 372 |
switch (ni->display_mode) { |
373 |
case NM_NORMAL: |
|
374 |
case NM_CALLBACK: { |
|
375 |
_news_type13_desc.top = top; |
|
376 |
w = AllocateWindowDesc(&_news_type13_desc); |
|
377 |
if (ni->flags & NF_VIEWPORT) |
|
378 |
AssignWindowViewport(w, 2, 58, 0x1AA, 0x6E, |
|
379 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0); |
|
380 |
break; |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
381 |
} |
427 | 382 |
|
383 |
case NM_THIN: { |
|
384 |
_news_type2_desc.top = top; |
|
385 |
w = AllocateWindowDesc(&_news_type2_desc); |
|
386 |
if (ni->flags & NF_VIEWPORT) |
|
387 |
AssignWindowViewport(w, 2, 58, 0x1AA, 0x46, |
|
388 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0); |
|
389 |
break; |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
390 |
} |
427 | 391 |
|
392 |
default: { |
|
393 |
_news_type0_desc.top = top; |
|
394 |
w = AllocateWindowDesc(&_news_type0_desc); |
|
395 |
if (ni->flags & NF_VIEWPORT) |
|
396 |
AssignWindowViewport(w, 3, 17, 0x112, 0x2F, |
|
397 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0); |
|
398 |
break; |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
399 |
} |
0 | 400 |
} |
427 | 401 |
WP(w, news_d).ni = &_news_items[_forced_news == INVALID_NEWS ? _current_news : _forced_news]; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
402 |
w->flags4 |= WF_DISABLE_VP_SCROLL; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
403 |
} |
0 | 404 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
405 |
// show news item in the ticker |
427 | 406 |
static void ShowTicker(const NewsItem *ni) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
407 |
{ |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
408 |
Window *w; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
409 |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
410 |
if (_news_ticker_sound) SndPlayFx(SND_16_MORSE); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
411 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
412 |
_statusbar_news_item = *ni; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
413 |
w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 414 |
if (w != NULL) WP(w, def_d).data_1 = 360; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
415 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
416 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
417 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
418 |
// Are we ready to show another news item? |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
419 |
// Only if nothing is in the newsticker and no newspaper is displayed |
427 | 420 |
static bool ReadyForNextItem(void) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
421 |
{ |
427 | 422 |
const Window *w; |
423 |
byte item = _forced_news == INVALID_NEWS ? _current_news : _forced_news; |
|
92
20b4c7536349
(svn r93) Fix: memory leak in news system (blathijs)
dominik
parents:
89
diff
changeset
|
424 |
NewsItem *ni; |
20b4c7536349
(svn r93) Fix: memory leak in news system (blathijs)
dominik
parents:
89
diff
changeset
|
425 |
|
427 | 426 |
if (item >= MAX_NEWS) return true; |
92
20b4c7536349
(svn r93) Fix: memory leak in news system (blathijs)
dominik
parents:
89
diff
changeset
|
427 |
ni = &_news_items[item]; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
428 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
429 |
// Ticker message |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
430 |
// Check if the status bar message is still being displayed? |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
431 |
w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 432 |
if (w != NULL && WP(w, const def_d).data_1 > -1280) return false; |
0 | 433 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
434 |
// Newspaper message |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
435 |
// Wait until duration reaches 0 |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
436 |
if (ni->duration != 0) { |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
437 |
ni->duration--; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
438 |
return false; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
439 |
} |
0 | 440 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
441 |
// neither newsticker nor newspaper are running |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
442 |
return true; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
443 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
444 |
|
427 | 445 |
static void MoveToNexItem(void) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
446 |
{ |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
447 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
427 | 448 |
_forced_news = INVALID_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
449 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
450 |
// if we're not at the last item, than move on |
427 | 451 |
if (_current_news != _latest_news) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
452 |
NewsItem *ni; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
453 |
|
83
bd21afea96d8
(svn r84) Improved news system code a little to avoid potential memory leaks
dominik
parents:
80
diff
changeset
|
454 |
_current_news = increaseIndex(_current_news); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
455 |
ni = &_news_items[_current_news]; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
456 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
457 |
// check the date, don't show too old items |
2639 | 458 |
if (_date - _news_items_age[ni->type] > ni->date) return; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
459 |
|
2639 | 460 |
switch (GetNewsDisplayValue(ni->type)) { |
461 |
case 0: { /* Off - show nothing only a small reminder in the status bar */ |
|
4171 | 462 |
Window *w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 463 |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
464 |
if (w != NULL) { |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
465 |
WP(w, def_d).data_2 = 91; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
466 |
SetWindowDirty(w); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
467 |
} |
2639 | 468 |
break; |
469 |
} |
|
470 |
||
471 |
case 1: /* Summary - show ticker, but if forced big, cascade to full */ |
|
472 |
if (!(ni->flags & NF_FORCE_BIG)) { |
|
473 |
ShowTicker(ni); |
|
474 |
break; |
|
475 |
} |
|
476 |
/* Fallthrough */ |
|
477 |
||
478 |
case 2: /* Full - show newspaper*/ |
|
479 |
ShowNewspaper(ni); |
|
480 |
break; |
|
481 |
} |
|
0 | 482 |
} |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
483 |
} |
0 | 484 |
|
427 | 485 |
void NewsLoop(void) |
0 | 486 |
{ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
487 |
// no news item yet |
427 | 488 |
if (_total_news == 0) return; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
489 |
|
2639 | 490 |
if (ReadyForNextItem()) MoveToNexItem(); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
491 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
492 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
493 |
/* Do a forced show of a specific message */ |
1095 | 494 |
static void ShowNewsMessage(byte i) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
495 |
{ |
427 | 496 |
if (_total_news == 0) return; |
89 | 497 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
498 |
// Delete the news window |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
499 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
500 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
501 |
// setup forced news item |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
502 |
_forced_news = i; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
503 |
|
427 | 504 |
if (_forced_news != INVALID_NEWS) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
505 |
NewsItem *ni = &_news_items[_forced_news]; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
506 |
ni->duration = 555; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
507 |
ni->flags |= NF_NOEXPIRE | NF_FORCE_BIG; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
508 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
509 |
ShowNewspaper(ni); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
510 |
} |
0 | 511 |
} |
512 |
||
427 | 513 |
void ShowLastNewsMessage(void) |
0 | 514 |
{ |
2549 | 515 |
if (_forced_news == INVALID_NEWS) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
516 |
ShowNewsMessage(_current_news); |
2549 | 517 |
} else if (_forced_news != 0) { |
427 | 518 |
ShowNewsMessage(_forced_news - 1); |
2549 | 519 |
} else { |
520 |
ShowNewsMessage(_total_news != MAX_NEWS ? _latest_news : MAX_NEWS - 1); |
|
83
bd21afea96d8
(svn r84) Improved news system code a little to avoid potential memory leaks
dominik
parents:
80
diff
changeset
|
521 |
} |
0 | 522 |
} |
523 |
||
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
524 |
|
89 | 525 |
/* return news by number, with 0 being the most |
427 | 526 |
recent news. Returns INVALID_NEWS if end of queue reached. */ |
89 | 527 |
static byte getNews(byte i) |
528 |
{ |
|
2639 | 529 |
if (i >= _total_news) return INVALID_NEWS; |
89 | 530 |
|
2639 | 531 |
if (_latest_news < i) { |
89 | 532 |
i = _latest_news + MAX_NEWS - i; |
2639 | 533 |
} else { |
89 | 534 |
i = _latest_news - i; |
2639 | 535 |
} |
89 | 536 |
|
427 | 537 |
i %= MAX_NEWS; |
89 | 538 |
return i; |
539 |
} |
|
540 |
||
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
541 |
/** Draw an unformatted news message truncated to a maximum length. If |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
542 |
* length exceeds maximum length it will be postfixed by '...' |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
543 |
* @param x,y position of the string |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
544 |
* @param color the color the string will be shown in |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
545 |
* @param *ni NewsItem being printed |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
546 |
* @param maxw maximum width of string in pixels |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
547 |
*/ |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
548 |
static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint maxw) |
89 | 549 |
{ |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
550 |
char buffer[512], buffer2[512]; |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
551 |
char *ptr, *dest; |
89 | 552 |
StringID str; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
553 |
|
89 | 554 |
if (ni->display_mode == 3) { |
555 |
str = _get_news_string_callback[ni->callback](ni); |
|
556 |
} else { |
|
557 |
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
558 |
str = ni->string_id; |
89 | 559 |
} |
560 |
||
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
561 |
GetString(buffer, str); |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
562 |
/* Copy the just gotten string to another buffer to remove any formatting |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
563 |
* from it such as big fonts, etc. */ |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
564 |
for (ptr = buffer, dest = buffer2; *ptr != '\0'; ptr++) { |
2150
f710b959b1c4
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2101
diff
changeset
|
565 |
if (*ptr == '\r') { |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
566 |
dest[0] = dest[1] = dest[2] = dest[3] = ' '; |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
567 |
dest += 4; |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
568 |
} else if ((byte)*ptr >= ' ' && ((byte)*ptr < 0x88 || (byte)*ptr >= 0x99)) { |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
569 |
*dest++ = *ptr; |
89 | 570 |
} |
571 |
} |
|
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
572 |
|
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
573 |
*dest = '\0'; |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
574 |
/* Truncate and show string; postfixed by '...' if neccessary */ |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
575 |
DoDrawStringTruncated(buffer2, x, y, color, maxw); |
89 | 576 |
} |
577 |
||
578 |
||
579 |
static void MessageHistoryWndProc(Window *w, WindowEvent *e) |
|
580 |
{ |
|
427 | 581 |
switch (e->event) { |
89 | 582 |
case WE_PAINT: { |
427 | 583 |
int y = 19; |
89 | 584 |
byte p, show; |
585 |
||
3155
c4673c936039
(svn r3778) - Fix crash when resizing news history window.
peter1138
parents:
3143
diff
changeset
|
586 |
SetVScrollCount(w, _total_news); |
89 | 587 |
DrawWindowWidgets(w); |
588 |
||
427 | 589 |
if (_total_news == 0) break; |
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
590 |
show = min(_total_news, w->vscroll.cap); |
89 | 591 |
|
427 | 592 |
for (p = w->vscroll.pos; p < w->vscroll.pos + show; p++) { |
89 | 593 |
// get news in correct order |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
594 |
const NewsItem *ni = &_news_items[getNews(p)]; |
89 | 595 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
596 |
SetDParam(0, ni->date); |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
597 |
DrawString(4, y, STR_SHORT_DATE, 12); |
89 | 598 |
|
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
599 |
DrawNewsString(82, y, 12, ni, w->width - 95); |
89 | 600 |
y += 12; |
601 |
} |
|
602 |
break; |
|
603 |
} |
|
604 |
||
605 |
case WE_CLICK: |
|
427 | 606 |
switch (e->click.widget) { |
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
607 |
case 3: { |
89 | 608 |
int y = (e->click.pt.y - 19) / 12; |
609 |
byte p, q; |
|
610 |
||
427 | 611 |
#if 0 // === DEBUG code only |
2549 | 612 |
for (p = 0; p < _total_news; p++) { |
89 | 613 |
NewsItem *ni; |
614 |
byte buffer[256]; |
|
427 | 615 |
ni = &_news_items[p]; |
89 | 616 |
GetNewsString(ni, buffer); |
617 |
printf("%i\t%i\t%s\n", p, ni->date, buffer); |
|
618 |
} |
|
619 |
printf("=========================\n"); |
|
427 | 620 |
#endif |
89 | 621 |
|
622 |
p = y + w->vscroll.pos; |
|
427 | 623 |
if (p > _total_news - 1) break; |
89 | 624 |
|
2639 | 625 |
if (_latest_news >= p) { |
427 | 626 |
q = _latest_news - p; |
2639 | 627 |
} else { |
427 | 628 |
q = _latest_news + MAX_NEWS - p; |
2639 | 629 |
} |
89 | 630 |
ShowNewsMessage(q); |
631 |
||
632 |
break; |
|
633 |
} |
|
634 |
} |
|
635 |
break; |
|
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
636 |
|
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
637 |
case WE_RESIZE: |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
638 |
w->vscroll.cap += e->sizing.diff.y / 12; |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
639 |
break; |
89 | 640 |
} |
641 |
} |
|
642 |
||
643 |
static const Widget _message_history_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
644 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
645 |
{ WWT_CAPTION, RESIZE_RIGHT, 13, 11, 387, 0, 13, STR_MESSAGE_HISTORY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
646 |
{ WWT_STICKYBOX, RESIZE_LR, 13, 388, 399, 0, 13, 0x0, STR_STICKY_BUTTON}, |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
647 |
{ WWT_IMGBTN, RESIZE_RB, 13, 0, 387, 14, 139, 0x0, STR_MESSAGE_HISTORY_TIP}, |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
648 |
{ WWT_SCROLLBAR, RESIZE_LRB, 13, 388, 399, 14, 127, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
649 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 13, 388, 399, 128, 139, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
102
diff
changeset
|
650 |
{ WIDGETS_END}, |
89 | 651 |
}; |
652 |
||
653 |
static const WindowDesc _message_history_desc = { |
|
654 |
240, 22, 400, 140, |
|
427 | 655 |
WC_MESSAGE_HISTORY, 0, |
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
656 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
89 | 657 |
_message_history_widgets, |
658 |
MessageHistoryWndProc |
|
659 |
}; |
|
660 |
||
427 | 661 |
void ShowMessageHistory(void) |
89 | 662 |
{ |
663 |
Window *w; |
|
664 |
||
665 |
DeleteWindowById(WC_MESSAGE_HISTORY, 0); |
|
666 |
w = AllocateWindowDesc(&_message_history_desc); |
|
667 |
||
427 | 668 |
if (w != NULL) { |
89 | 669 |
w->vscroll.cap = 10; |
670 |
w->vscroll.count = _total_news; |
|
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
671 |
w->resize.step_height = 12; |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
672 |
w->resize.height = w->height - 12 * 6; // minimum of 4 items in the list, each item 12 high |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
673 |
w->resize.step_width = 1; |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
674 |
w->resize.width = 200; // can't make window any smaller than 200 pixel |
89 | 675 |
SetWindowDirty(w); |
676 |
} |
|
677 |
} |
|
678 |
||
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
679 |
/** Setup the disabled/enabled buttons in the message window |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
680 |
* If the value is 'off' disable the [<] widget, and enable the [>] one |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
681 |
* Same-wise for all the others. Starting value of 3 is the first widget |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
682 |
* group. These are grouped as [<][>] .. [<][>], etc. |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
683 |
*/ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
684 |
static void SetMessageButtonStates(Window *w, byte value, int element) |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
685 |
{ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
686 |
element *= 2; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
687 |
switch (value) { |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
688 |
case 0: /* Off */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
689 |
SETBIT(w->disabled_state, element + 3); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
690 |
CLRBIT(w->disabled_state, element + 3 + 1); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
691 |
break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
692 |
case 1: /* Summary */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
693 |
CLRBIT(w->disabled_state, element + 3); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
694 |
CLRBIT(w->disabled_state, element + 3 + 1); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
695 |
break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
696 |
case 2: /* Full */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
697 |
SETBIT(w->disabled_state, element + 3 + 1); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
698 |
CLRBIT(w->disabled_state, element + 3); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
699 |
break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
700 |
default: NOT_REACHED(); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
701 |
} |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
702 |
} |
0 | 703 |
|
704 |
static void MessageOptionsWndProc(Window *w, WindowEvent *e) |
|
705 |
{ |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
706 |
static const StringID message_opt[] = {STR_OFF, STR_SUMMARY, STR_FULL, INVALID_STRING_ID}; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
707 |
static const uint32 message_val[] = {0x0, 0x55555555, 0xAAAAAAAA}; // 0x555.. = 01010101010101010101 (all summary), 286.. 1010... (full) |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
708 |
static const uint32 message_dis[] = { |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
709 |
(1 << 3) | (1 << 5) | (1 << 7) | (1 << 9) | (1 << 11) | (1 << 13) | (1 << 15) | (1 << 17) | (1 << 19) | (1 << 21), |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
710 |
0, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
711 |
(1 << 4) | (1 << 6) | (1 << 8) | (1 << 10) | (1 << 12) | (1 << 14) | (1 << 16) | (1 << 18) | (1 << 20) | (1 << 22), |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
712 |
}; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
713 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
714 |
/* WP(w, def_d).data_1 are stores the clicked state of the fake widgets |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
715 |
* WP(w, def_d).data_2 stores state of the ALL on/off/summary button */ |
427 | 716 |
switch (e->event) { |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
717 |
case WE_CREATE: { |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
718 |
uint32 val = _news_display_opt; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
719 |
int i; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
720 |
WP(w, def_d).data_1 = WP(w, def_d).data_2 = 0; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
721 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
722 |
// Set up the initial disabled buttons in the case of 'off' or 'full' |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
723 |
for (i = 0; i != 10; i++, val >>= 2) SetMessageButtonStates(w, val & 0x3, i); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
724 |
} break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
725 |
|
0 | 726 |
case WE_PAINT: { |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
727 |
uint32 val = _news_display_opt; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
728 |
int click_state = WP(w, def_d).data_1; |
0 | 729 |
int i, y; |
730 |
||
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
731 |
if (_news_ticker_sound) SETBIT(w->click_state, 25); |
0 | 732 |
DrawWindowWidgets(w); |
733 |
DrawStringCentered(185, 15, STR_0205_MESSAGE_TYPES, 0); |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
734 |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
735 |
/* XXX - Draw the fake widgets-buttons. Can't add these to the widget-desc since |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
736 |
* openttd currently can only handle 32 widgets. So hack it *g* */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
737 |
for (i = 0, y = 26; i != 10; i++, y += 12, click_state >>= 1, val >>= 2) { |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
738 |
bool clicked = !!(click_state & 1); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
739 |
|
1938
70baf462aff1
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
740 |
DrawFrameRect(13, y, 89, 11 + y, 3, (clicked) ? FR_LOWERED : 0); |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
741 |
DrawStringCentered(((13 + 89 + 1) >> 1) + clicked, ((y + 11 + y + 1) >> 1) - 5 + clicked, message_opt[val & 0x3], 0x10); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
742 |
DrawString(103, y + 1, i + STR_0206_ARRIVAL_OF_FIRST_VEHICLE, 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
743 |
} |
0 | 744 |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
745 |
DrawString( 8, y + 9, message_opt[WP(w, def_d).data_2], 0x10); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
746 |
DrawString(103, y + 9, STR_MESSAGES_ALL, 0); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
747 |
DrawString(103, y + 9 + 12, STR_MESSAGE_SOUND, 0); |
0 | 748 |
|
749 |
} break; |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
750 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
751 |
case WE_CLICK: |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
752 |
switch (e->click.widget) { |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
753 |
case 2: /* Clicked on any of the fake widgets */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
754 |
if (e->click.pt.x > 13 && e->click.pt.x < 89 && e->click.pt.y > 26 && e->click.pt.y < 146) { |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
755 |
int element = (e->click.pt.y - 26) / 12; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
756 |
byte val = (GetNewsDisplayValue(element) + 1) % 3; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
757 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
758 |
SetMessageButtonStates(w, val, element); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
759 |
SetNewsDisplayValue(element, val); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
760 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
761 |
WP(w, def_d).data_1 |= (1 << element); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
762 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; // XXX - setup unclick (fake widget) |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
763 |
SetWindowDirty(w); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
764 |
} |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
765 |
break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
766 |
case 23: case 24: /* Dropdown menu for all settings */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
767 |
ShowDropDownMenu(w, message_opt, WP(w, def_d).data_2, 24, 0, 0); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
768 |
break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
769 |
case 25: /* Change ticker sound on/off */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
770 |
_news_ticker_sound ^= 1; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
771 |
TOGGLEBIT(w->click_state, e->click.widget); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
772 |
InvalidateWidget(w, e->click.widget); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
773 |
break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
774 |
default: { /* Clicked on the [<] .. [>] widgets */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
775 |
int wid = e->click.widget; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
776 |
if (wid > 2 && wid < 23) { |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
777 |
int element = (wid - 3) / 2; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
778 |
byte val = (GetNewsDisplayValue(element) + ((wid & 1) ? -1 : 1)) % 3; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
779 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
780 |
SetMessageButtonStates(w, val, element); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
781 |
SetNewsDisplayValue(element, val); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
782 |
SetWindowDirty(w); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
783 |
} |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
784 |
} break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
785 |
} break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
786 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
787 |
case WE_DROPDOWN_SELECT: /* Select all settings for newsmessages */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
788 |
WP(w, def_d).data_2 = e->dropdown.index; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
789 |
_news_display_opt = message_val[WP(w, def_d).data_2]; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
790 |
w->disabled_state = message_dis[WP(w, def_d).data_2]; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
791 |
SetWindowDirty(w); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
792 |
break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
793 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
794 |
case WE_TIMEOUT: /* XXX - Hack to animate 'fake' buttons */ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
795 |
WP(w, def_d).data_1 = 0; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
796 |
SetWindowDirty(w); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
797 |
break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
798 |
|
0 | 799 |
} |
800 |
} |
|
801 |
||
802 |
static const Widget _message_options_widgets[] = { |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
803 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
804 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 409, 0, 13, STR_0204_MESSAGE_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
805 |
{ WWT_PANEL, RESIZE_NONE, 13, 0, 409, 14, 184, STR_NULL, STR_NULL}, |
0 | 806 |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
807 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 26, 37, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
808 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 26, 37, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
809 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
810 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 38, 49, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
811 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 38, 49, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
812 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
813 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 50, 61, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
814 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 50, 61, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
815 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
816 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 62, 73, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
817 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 62, 73, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
818 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
819 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 74, 85, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
820 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 74, 85, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
821 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
822 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 86, 97, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
823 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 86, 97, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
824 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
825 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 98, 109, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
826 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 98, 109, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
827 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
828 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 110, 121, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
829 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 110, 121, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
830 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
831 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 122, 133, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
832 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 122, 133, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
833 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
834 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 134, 145, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
835 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 134, 145, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
836 |
|
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
837 |
{ WWT_PANEL, RESIZE_NONE, 3, 4, 86, 154, 165, STR_NULL, STR_NULL}, |
2725
775e3e14ca46
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2639
diff
changeset
|
838 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 87, 98, 154, 165, STR_0225, STR_NULL}, |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
839 |
{ WWT_4, RESIZE_NONE, 3, 4, 98, 166, 177, STR_02DB_OFF, STR_NULL}, |
0 | 840 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
102
diff
changeset
|
841 |
{ WIDGETS_END}, |
0 | 842 |
}; |
843 |
||
844 |
static const WindowDesc _message_options_desc = { |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
845 |
270, 22, 410, 185, |
427 | 846 |
WC_GAME_OPTIONS, 0, |
0 | 847 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
848 |
_message_options_widgets, |
|
849 |
MessageOptionsWndProc |
|
850 |
}; |
|
851 |
||
427 | 852 |
void ShowMessageOptions(void) |
0 | 853 |
{ |
854 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
855 |
AllocateWindowDesc(&_message_options_desc); |
|
856 |
} |
|
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
857 |
|
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
858 |
|
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
859 |
void DeleteVehicleNews(VehicleID vid, StringID news) |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
860 |
{ |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
861 |
byte n; |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
862 |
|
3143 | 863 |
for (n = _oldest_news; _latest_news != INVALID_NEWS && n != (_latest_news + 1) % MAX_NEWS; n = (n + 1) % MAX_NEWS) { |
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
864 |
const NewsItem* ni = &_news_items[n]; |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
865 |
|
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
866 |
if (ni->flags & NF_VEHICLE && |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
867 |
ni->data_a == vid && |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
868 |
(news == INVALID_STRING_ID || ni->string_id == news)) { |
4171 | 869 |
Window *w; |
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
870 |
byte i; |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
871 |
|
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
872 |
if (_forced_news == n) MoveToNexItem(); |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
873 |
if (_current_news == n) MoveToNexItem(); |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
874 |
|
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
875 |
// If this is the last news item, invalidate _latest_news |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
876 |
if (_latest_news == _oldest_news) _latest_news = INVALID_NEWS; |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
877 |
|
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
878 |
for (i = n; i != _oldest_news; i = (i + MAX_NEWS - 1) % MAX_NEWS) { |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
879 |
_news_items[i] = _news_items[(i + MAX_NEWS - 1) % MAX_NEWS]; |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
880 |
} |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
881 |
_oldest_news = (_oldest_news + 1) % MAX_NEWS; |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
882 |
_total_news--; |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
883 |
|
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
884 |
w = FindWindowById(WC_MESSAGE_HISTORY, 0); |
3143 | 885 |
if (w != NULL) { |
886 |
SetWindowDirty(w); |
|
887 |
w->vscroll.count = _total_news; |
|
888 |
} |
|
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
889 |
} |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
890 |
} |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
891 |
} |