author | rubidium |
Mon, 19 Mar 2007 19:22:26 +0000 | |
branch | 0.5 |
changeset 5461 | 03285c9589f9 |
parent 5431 | bad513e2c7d8 |
child 5495 | ccc57a497257 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1688
diff
changeset
|
4 |
#include "openttd.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
5 |
#include "functions.h" |
1309
dab90d4cbf2d
(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
787400219027
(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
8aa8100b0b22
(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
b2cd7bc9f90f
(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
66647f97e7c0
(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
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2150
diff
changeset
|
16 |
#include "variables.h" |
4261
2ec8f5a9747b
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4171
diff
changeset
|
17 |
#include "date.h" |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
18 |
#include "string.h" |
0 | 19 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
20 |
/* News system |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
21 |
* News system is realized as a FIFO queue (in an array) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
22 |
* The positions in the queue can't be rearranged, we only access |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
23 |
* the array elements through pointers to the elements. Once the |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
24 |
* array is full, the oldest entry (_oldest_news) is being overwritten |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
25 |
* by the newest (_latest news). |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
26 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
27 |
* oldest current lastest |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
28 |
* | | | |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
29 |
* [O------------F-------------C---------L ] |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
30 |
* | |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
31 |
* forced |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
32 |
* |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
33 |
* Of course by using an array we can have situations like |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
34 |
* |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
35 |
* [----L O-----F---------C-----------------] |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
36 |
* This is where we have wrapped around the array and have |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
37 |
* (MAX_NEWS - O) + L news items |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
38 |
*/ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
39 |
|
427 | 40 |
#define MAX_NEWS 30 |
41 |
||
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
42 |
typedef byte NewsID; |
427 | 43 |
#define INVALID_NEWS 255 |
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 NewsItem _news_items[MAX_NEWS]; |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
46 |
static NewsID _current_news = INVALID_NEWS; // points to news item that should be shown next |
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
47 |
static NewsID _oldest_news = 0; // points to first item in fifo queue |
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
48 |
static NewsID _latest_news = INVALID_NEWS; // points to last item in fifo queue |
427 | 49 |
/* if the message being shown was forced by the user, its index is stored in |
50 |
* _forced_news. forced_news is INVALID_NEWS otherwise. |
|
51 |
* (Users can force messages through history or "last message") */ |
|
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
52 |
static NewsID _forced_news = INVALID_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
53 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
54 |
static byte _total_news = 0; // total news count |
0 | 55 |
|
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
56 |
void DrawNewsNewVehicleAvail(Window *w); |
0 | 57 |
void DrawNewsBankrupcy(Window *w); |
5253
a9775de4e6b6
(svn r7383) -Codechange: fix up typo in news-gui s/MoveToNexItem/MoveToNextItem/.
Darkvater
parents:
5246
diff
changeset
|
58 |
static void MoveToNextItem(void); |
0 | 59 |
|
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
60 |
StringID GetNewsStringNewVehicleAvail(const NewsItem *ni); |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
61 |
StringID GetNewsStringBankrupcy(const NewsItem *ni); |
0 | 62 |
|
63 |
static DrawNewsCallbackProc * const _draw_news_callback[] = { |
|
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
64 |
DrawNewsNewVehicleAvail, /* DNC_VEHICLEAVAIL */ |
427 | 65 |
DrawNewsBankrupcy, /* DNC_BANKRUPCY */ |
0 | 66 |
}; |
67 |
||
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
68 |
extern GetNewsStringCallbackProc * const _get_news_string_callback[]; |
0 | 69 |
GetNewsStringCallbackProc * const _get_news_string_callback[] = { |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
70 |
GetNewsStringNewVehicleAvail, /* DNC_VEHICLEAVAIL */ |
427 | 71 |
GetNewsStringBankrupcy, /* DNC_BANKRUPCY */ |
0 | 72 |
}; |
73 |
||
427 | 74 |
void InitNewsItemStructs(void) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
75 |
{ |
427 | 76 |
memset(_news_items, 0, sizeof(_news_items)); |
77 |
_current_news = INVALID_NEWS; |
|
89 | 78 |
_oldest_news = 0; |
427 | 79 |
_latest_news = INVALID_NEWS; |
80 |
_forced_news = INVALID_NEWS; |
|
89 | 81 |
_total_news = 0; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
82 |
} |
0 | 83 |
|
427 | 84 |
void DrawNewsBorder(const Window *w) |
0 | 85 |
{ |
86 |
int left = 0; |
|
87 |
int right = w->width - 1; |
|
88 |
int top = 0; |
|
89 |
int bottom = w->height - 1; |
|
90 |
||
91 |
GfxFillRect(left, top, right, bottom, 0xF); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
92 |
|
0 | 93 |
GfxFillRect(left, top, left, bottom, 0xD7); |
94 |
GfxFillRect(right, top, right, bottom, 0xD7); |
|
95 |
GfxFillRect(left, top, right, top, 0xD7); |
|
96 |
GfxFillRect(left, bottom, right, bottom, 0xD7); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
97 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
98 |
DrawString(left + 2, top + 1, STR_00C6, 0); |
0 | 99 |
} |
100 |
||
101 |
static void NewsWindowProc(Window *w, WindowEvent *e) |
|
102 |
{ |
|
427 | 103 |
switch (e->event) { |
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
104 |
case WE_CREATE: { /* If chatbar is open at creation time, we need to go above it */ |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
105 |
const Window *w1 = FindWindowById(WC_SEND_NETWORK_MSG, 0); |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
106 |
w->message.msg = (w1 != NULL) ? w1->height : 0; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
107 |
} break; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
108 |
|
0 | 109 |
case WE_PAINT: { |
427 | 110 |
const NewsItem *ni = WP(w, news_d).ni; |
0 | 111 |
ViewPort *vp; |
112 |
||
427 | 113 |
switch (ni->display_mode) { |
114 |
case NM_NORMAL: |
|
115 |
case NM_THIN: { |
|
116 |
DrawNewsBorder(w); |
|
0 | 117 |
|
427 | 118 |
DrawString(2, 1, STR_00C6, 0); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
119 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
120 |
SetDParam(0, ni->date); |
427 | 121 |
DrawStringRightAligned(428, 1, STR_01FF, 0); |
122 |
||
123 |
if (!(ni->flags & NF_VIEWPORT)) { |
|
124 |
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); |
|
125 |
DrawStringMultiCenter(215, ni->display_mode == NM_NORMAL ? 76 : 56, |
|
126 |
ni->string_id, 426); |
|
127 |
} else { |
|
128 |
byte bk = _display_opt; |
|
497
2d6d31173813
(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
|
129 |
_display_opt &= ~DO_TRANS_BUILDINGS; |
427 | 130 |
DrawWindowViewport(w); |
131 |
_display_opt = bk; |
|
132 |
||
133 |
/* Shade the viewport into gray, or color*/ |
|
134 |
vp = w->viewport; |
|
135 |
GfxFillRect(vp->left - w->left, vp->top - w->top, |
|
136 |
vp->left - w->left + vp->width - 1, vp->top - w->top + vp->height - 1, |
|
2227
24f19bde1400
(svn r2747) -Fix: r2736 broke the newpaper display. Sorry.
celestar
parents:
2186
diff
changeset
|
137 |
(ni->flags & NF_INCOLOR ? 0x322 : 0x323) | USE_COLORTABLE |
427 | 138 |
); |
139 |
||
140 |
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); |
|
141 |
DrawStringMultiCenter(w->width / 2, 20, ni->string_id, 428); |
|
142 |
} |
|
143 |
break; |
|
0 | 144 |
} |
427 | 145 |
|
146 |
case NM_CALLBACK: { |
|
147 |
_draw_news_callback[ni->callback](w); |
|
148 |
break; |
|
149 |
} |
|
150 |
||
151 |
default: { |
|
152 |
DrawWindowWidgets(w); |
|
153 |
if (!(ni->flags & NF_VIEWPORT)) { |
|
154 |
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); |
|
155 |
DrawStringMultiCenter(140, 38, ni->string_id, 276); |
|
156 |
} else { |
|
157 |
DrawWindowViewport(w); |
|
158 |
COPY_IN_DPARAM(0, ni->params, lengthof(ni->params)); |
|
159 |
DrawStringMultiCenter(w->width / 2, w->height - 16, ni->string_id, 276); |
|
160 |
} |
|
161 |
break; |
|
0 | 162 |
} |
163 |
} |
|
164 |
} break; |
|
165 |
||
166 |
case WE_CLICK: { |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
167 |
switch (e->we.click.widget) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
168 |
case 1: { |
427 | 169 |
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
|
170 |
DeleteWindow(w); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
171 |
ni->duration = 0; |
427 | 172 |
_forced_news = INVALID_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
173 |
} break; |
0 | 174 |
case 0: { |
427 | 175 |
NewsItem *ni = WP(w, news_d).ni; |
0 | 176 |
if (ni->flags & NF_VEHICLE) { |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
177 |
Vehicle *v = GetVehicle(ni->data_a); |
0 | 178 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
179 |
} else if (ni->flags & NF_TILE) { |
|
180 |
if (!ScrollMainWindowToTile(ni->data_a) && ni->data_b != 0) |
|
181 |
ScrollMainWindowToTile(ni->data_b); |
|
182 |
} |
|
183 |
} break; |
|
184 |
} |
|
185 |
} break; |
|
186 |
||
187 |
case WE_KEYPRESS: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
188 |
if (e->we.keypress.keycode == WKC_SPACE) { |
0 | 189 |
// Don't continue. |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
190 |
e->we.keypress.cont = false; |
0 | 191 |
DeleteWindow(w); |
192 |
} |
|
193 |
break; |
|
194 |
||
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
195 |
case WE_MESSAGE: /* The chatbar has notified us that is was either created or closed */ |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
196 |
switch (e->we.message.msg) { |
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
197 |
case WE_CREATE: w->message.msg = e->we.message.wparam; break; |
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
198 |
case WE_DESTROY: w->message.msg = 0; break; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
199 |
} |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
200 |
break; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
201 |
|
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
202 |
case WE_TICK: { /* Scroll up newsmessages from the bottom in steps of 4 pixels */ |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
203 |
int diff; |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
204 |
int y = max(w->top - 4, _screen.height - w->height - 12 - w->message.msg); |
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
205 |
if (y == w->top) return; |
0 | 206 |
|
207 |
if (w->viewport != NULL) |
|
208 |
w->viewport->top += y - w->top; |
|
209 |
||
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
210 |
diff = abs(w->top - y); |
0 | 211 |
w->top = y; |
212 |
||
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
213 |
SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height); |
0 | 214 |
} break; |
215 |
} |
|
216 |
} |
|
217 |
||
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
218 |
/** Return the correct index in the pseudo-fifo |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
219 |
* queue and deals with overflows when increasing the index */ |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
220 |
static inline NewsID increaseIndex(NewsID i) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
221 |
{ |
5258
eae66ac02803
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
222 |
assert(i != INVALID_NEWS); |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
223 |
return (i + 1) % MAX_NEWS; |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
224 |
} |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
225 |
|
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
226 |
/** Return the correct index in the pseudo-fifo |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
227 |
* queue and deals with overflows when decreasing the index */ |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
228 |
static inline NewsID decreaseIndex(NewsID i) |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
229 |
{ |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
230 |
assert(i != INVALID_NEWS); |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
231 |
return (i + MAX_NEWS - 1) % MAX_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
232 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
233 |
|
4873
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
234 |
/** Add a new newsitem to be shown. |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
235 |
* @param string String to display, can have special values based on parameter 'flags' |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
236 |
* @param flags various control bits that will show various news-types. See macro NEWS_FLAGS() |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
237 |
* @param data_a news-specific value based on news type |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
238 |
* @param data_b news-specific value based on news type |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
239 |
* @note flags exists of 4 byte-sized extra parameters.<br/> |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
240 |
* 1. 0 - 7 display_mode, any of the NewsMode enums (NM_)<br/> |
4874
b95cdd66085f
(svn r6804) -Codechange: Remove the unused NF_NOEXPIRE flag.
Darkvater
parents:
4873
diff
changeset
|
241 |
* 2. 8 - 15 news flags, any of the NewsFlags enums (NF_) NF_INCOLOR are set automatically if needed<br/> |
4873
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
242 |
* 3. 16 - 23 news category, any of the NewsType enums (NT_)<br/> |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
243 |
* 4. 24 - 31 news callback function, any of the NewsCallback enums (DNC_)<br/> |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
244 |
* If the display mode is NM_CALLBACK special news is shown and parameter |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
245 |
* stringid has a special meaning.<br/> |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
246 |
* DNC_TRAINAVAIL, DNC_ROADAVAIL, DNC_SHIPAVAIL, DNC_AIRCRAFTAVAIL: StringID is |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
247 |
* the index of the engine that is shown<br/> |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
248 |
* DNC_BANKRUPCY: bytes 0-3 of StringID contains the player that is in trouble, |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
249 |
* and 4-7 contains what kind of bankrupcy message is shown, NewsBankrupcy enum (NB_)<br/> |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
250 |
* @see NewsMode |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
251 |
* @see NewsFlags |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
252 |
* @see NewsType |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
253 |
* @see NewsCallback */ |
0 | 254 |
void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b) |
255 |
{ |
|
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
256 |
NewsID l_news; |
0 | 257 |
|
4000
bab1ebc37da0
(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
|
258 |
if (_game_mode == GM_MENU) return; |
0 | 259 |
|
102
1d277a07f1f1
(svn r103) Fix: rare newspaper crash with too many messages [ 1009976 ] (thx to blathij)s
dominik
parents:
94
diff
changeset
|
260 |
// check the rare case that the oldest (to be overwritten) news item is open |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
261 |
if (_total_news == MAX_NEWS && (_oldest_news == _current_news || _oldest_news == _forced_news)) |
5253
a9775de4e6b6
(svn r7383) -Codechange: fix up typo in news-gui s/MoveToNexItem/MoveToNextItem/.
Darkvater
parents:
5246
diff
changeset
|
262 |
MoveToNextItem(); |
102
1d277a07f1f1
(svn r103) Fix: rare newspaper crash with too many messages [ 1009976 ] (thx to blathij)s
dominik
parents:
94
diff
changeset
|
263 |
|
427 | 264 |
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
|
265 |
|
5258
eae66ac02803
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
266 |
/* Increase _latest_news. If we have no news yet, use _oldest news as an |
eae66ac02803
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
267 |
* index. We cannot use 0 as _oldest_news can jump around due to |
eae66ac02803
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
268 |
* DeleteVehicleNews */ |
5244
e110f52333e8
(svn r7368) -Fix: [FS#332] Vehicle Deletion Crash [News Window Related?] (r3757).
Darkvater
parents:
5108
diff
changeset
|
269 |
l_news = _latest_news; |
5258
eae66ac02803
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
270 |
_latest_news = (_latest_news == INVALID_NEWS) ? _oldest_news : increaseIndex(_latest_news); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
271 |
|
5244
e110f52333e8
(svn r7368) -Fix: [FS#332] Vehicle Deletion Crash [News Window Related?] (r3757).
Darkvater
parents:
5108
diff
changeset
|
272 |
/* If the fifo-buffer is full, overwrite the oldest entry */ |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
273 |
if (l_news != INVALID_NEWS && _latest_news == _oldest_news) { |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
274 |
assert(_total_news == MAX_NEWS); |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
275 |
_oldest_news = increaseIndex(_oldest_news); |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
276 |
} |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
277 |
|
5395
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
278 |
/*DEBUG(misc, 0) ("+cur %3d, old %2d, lat %3d, for %3d, tot %2d", |
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
279 |
_current_news, _oldest_news, _latest_news, _forced_news, _total_news); */ |
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
280 |
|
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
281 |
{ /* Add news to _latest_news */ |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
282 |
Window *w; |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
283 |
NewsItem *ni = &_news_items[_latest_news]; |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
284 |
memset(ni, 0, sizeof(*ni)); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
285 |
|
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
286 |
ni->string_id = string; |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
287 |
ni->display_mode = (byte)flags; |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
288 |
ni->flags = (byte)(flags >> 8); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
289 |
|
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
290 |
// show this news message in color? |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
291 |
if (_cur_year >= _patches.colored_news_year) ni->flags |= NF_INCOLOR; |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
292 |
|
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
293 |
ni->type = (byte)(flags >> 16); |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
294 |
ni->callback = (byte)(flags >> 24); |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
295 |
ni->data_a = data_a; |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
296 |
ni->data_b = data_b; |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
297 |
ni->date = _date; |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
298 |
COPY_OUT_DPARAM(ni->params, 0, lengthof(ni->params)); |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
299 |
|
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
300 |
w = FindWindowById(WC_MESSAGE_HISTORY, 0); |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
301 |
if (w == NULL) return; |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
302 |
SetWindowDirty(w); |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
303 |
w->vscroll.count = _total_news; |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
304 |
} |
0 | 305 |
} |
306 |
||
715
83805642c830
(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
|
307 |
|
5395
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
308 |
/* Don't show item if it's older than x days, corresponds with NewsType in news.h */ |
0 | 309 |
static const byte _news_items_age[] = {60, 60, 90, 60, 90, 30, 150, 30, 90, 180}; |
310 |
||
311 |
static const Widget _news_type13_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
312 |
{ WWT_PANEL, RESIZE_NONE, 15, 0, 429, 0, 169, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
313 |
{ 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
|
314 |
{ WIDGETS_END}, |
0 | 315 |
}; |
316 |
||
317 |
static WindowDesc _news_type13_desc = { |
|
318 |
WDP_CENTER, 476, 430, 170, |
|
427 | 319 |
WC_NEWS_WINDOW, 0, |
0 | 320 |
WDF_DEF_WIDGET, |
321 |
_news_type13_widgets, |
|
322 |
NewsWindowProc |
|
323 |
}; |
|
324 |
||
325 |
static const Widget _news_type2_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
326 |
{ WWT_PANEL, RESIZE_NONE, 15, 0, 429, 0, 129, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
327 |
{ 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
|
328 |
{ WIDGETS_END}, |
0 | 329 |
}; |
330 |
||
331 |
static WindowDesc _news_type2_desc = { |
|
332 |
WDP_CENTER, 476, 430, 130, |
|
427 | 333 |
WC_NEWS_WINDOW, 0, |
0 | 334 |
WDF_DEF_WIDGET, |
335 |
_news_type2_widgets, |
|
336 |
NewsWindowProc |
|
337 |
}; |
|
338 |
||
339 |
static const Widget _news_type0_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
340 |
{ WWT_PANEL, RESIZE_NONE, 5, 0, 279, 14, 86, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
341 |
{ WWT_CLOSEBOX, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
342 |
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 279, 0, 13, STR_012C_MESSAGE, STR_NULL}, |
4939
ede0f6777b3c
(svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents:
4938
diff
changeset
|
343 |
{ WWT_INSET, 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
|
344 |
{ WIDGETS_END}, |
0 | 345 |
}; |
346 |
||
347 |
static WindowDesc _news_type0_desc = { |
|
348 |
WDP_CENTER, 476, 280, 87, |
|
427 | 349 |
WC_NEWS_WINDOW, 0, |
0 | 350 |
WDF_DEF_WIDGET, |
351 |
_news_type0_widgets, |
|
352 |
NewsWindowProc |
|
353 |
}; |
|
354 |
||
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
355 |
static const SoundFx _news_sounds[NT_END] = { |
427 | 356 |
SND_1D_APPLAUSE, |
357 |
SND_1D_APPLAUSE, |
|
358 |
0, |
|
359 |
0, |
|
360 |
0, |
|
361 |
0, |
|
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
362 |
0, |
427 | 363 |
SND_1E_OOOOH, |
364 |
0, |
|
365 |
0, |
|
366 |
0 |
|
367 |
}; |
|
0 | 368 |
|
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
369 |
const char *_news_display_name[NT_END] = { |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
370 |
"arrival_player", |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
371 |
"arrival_other", |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
372 |
"accident", |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
373 |
"company_info", |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
374 |
"openclose", |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
375 |
"economy", |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
376 |
"advice", |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
377 |
"new_vehicles", |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
378 |
"acceptance", |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
379 |
"subsidies", |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
380 |
"general", |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
381 |
}; |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
382 |
|
1688
787400219027
(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
|
383 |
/** Get the value of an item of the news-display settings. This is |
787400219027
(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
|
384 |
* a little tricky since on/off/summary must use 2 bits to store the value |
787400219027
(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
|
385 |
* @param item the item whose value is requested |
787400219027
(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
|
386 |
* @return return the found value which is between 0-2 |
787400219027
(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
|
387 |
*/ |
787400219027
(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
|
388 |
static inline byte GetNewsDisplayValue(byte item) |
787400219027
(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
|
389 |
{ |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
390 |
assert(item < NT_END && GB(_news_display_opt, item * 2, 2) <= 2); |
2549 | 391 |
return GB(_news_display_opt, item * 2, 2); |
1688
787400219027
(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
|
392 |
} |
787400219027
(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
|
393 |
|
787400219027
(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
|
394 |
/** Set the value of an item in the news-display settings. This is |
787400219027
(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
|
395 |
* a little tricky since on/off/summary must use 2 bits to store the value |
787400219027
(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
|
396 |
* @param item the item whose value is being set |
787400219027
(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
|
397 |
* @param val new value |
787400219027
(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
|
398 |
*/ |
787400219027
(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
|
399 |
static inline void SetNewsDisplayValue(byte item, byte val) |
787400219027
(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
|
400 |
{ |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
401 |
assert(item < NT_END && val <= 2); |
2549 | 402 |
SB(_news_display_opt, item * 2, 2, val); |
1688
787400219027
(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
|
403 |
} |
787400219027
(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
|
404 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
405 |
// 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
|
406 |
static void ShowNewspaper(NewsItem *ni) |
0 | 407 |
{ |
408 |
Window *w; |
|
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2227
diff
changeset
|
409 |
SoundFx sound; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
410 |
int top; |
4874
b95cdd66085f
(svn r6804) -Codechange: Remove the unused NF_NOEXPIRE flag.
Darkvater
parents:
4873
diff
changeset
|
411 |
ni->flags &= ~NF_FORCE_BIG; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
412 |
ni->duration = 555; |
0 | 413 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
414 |
sound = _news_sounds[ni->type]; |
2639 | 415 |
if (sound != 0) SndPlayFx(sound); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
416 |
|
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
417 |
top = _screen.height; |
427 | 418 |
switch (ni->display_mode) { |
419 |
case NM_NORMAL: |
|
420 |
case NM_CALLBACK: { |
|
421 |
_news_type13_desc.top = top; |
|
422 |
w = AllocateWindowDesc(&_news_type13_desc); |
|
423 |
if (ni->flags & NF_VIEWPORT) |
|
424 |
AssignWindowViewport(w, 2, 58, 0x1AA, 0x6E, |
|
425 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0); |
|
426 |
break; |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
427 |
} |
427 | 428 |
|
429 |
case NM_THIN: { |
|
430 |
_news_type2_desc.top = top; |
|
431 |
w = AllocateWindowDesc(&_news_type2_desc); |
|
432 |
if (ni->flags & NF_VIEWPORT) |
|
433 |
AssignWindowViewport(w, 2, 58, 0x1AA, 0x46, |
|
434 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0); |
|
435 |
break; |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
436 |
} |
427 | 437 |
|
438 |
default: { |
|
439 |
_news_type0_desc.top = top; |
|
440 |
w = AllocateWindowDesc(&_news_type0_desc); |
|
441 |
if (ni->flags & NF_VIEWPORT) |
|
442 |
AssignWindowViewport(w, 3, 17, 0x112, 0x2F, |
|
443 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), 0); |
|
444 |
break; |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
445 |
} |
0 | 446 |
} |
5395
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
447 |
|
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
448 |
/*DEBUG(misc, 0) (" cur %3d, old %2d, lat %3d, for %3d, tot %2d", |
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
449 |
_current_news, _oldest_news, _latest_news, _forced_news, _total_news); */ |
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
450 |
|
427 | 451 |
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
|
452 |
w->flags4 |= WF_DISABLE_VP_SCROLL; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
453 |
} |
0 | 454 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
455 |
// show news item in the ticker |
427 | 456 |
static void ShowTicker(const NewsItem *ni) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
457 |
{ |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
458 |
Window *w; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
459 |
|
1688
787400219027
(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
|
460 |
if (_news_ticker_sound) SndPlayFx(SND_16_MORSE); |
787400219027
(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
|
461 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
462 |
_statusbar_news_item = *ni; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
463 |
w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 464 |
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
|
465 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
466 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
467 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
468 |
// Are we ready to show another news item? |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
469 |
// Only if nothing is in the newsticker and no newspaper is displayed |
427 | 470 |
static bool ReadyForNextItem(void) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
471 |
{ |
427 | 472 |
const Window *w; |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
473 |
NewsID 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
|
474 |
NewsItem *ni; |
20b4c7536349
(svn r93) Fix: memory leak in news system (blathijs)
dominik
parents:
89
diff
changeset
|
475 |
|
427 | 476 |
if (item >= MAX_NEWS) return true; |
92
20b4c7536349
(svn r93) Fix: memory leak in news system (blathijs)
dominik
parents:
89
diff
changeset
|
477 |
ni = &_news_items[item]; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
478 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
479 |
// Ticker message |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
480 |
// 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
|
481 |
w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 482 |
if (w != NULL && WP(w, const def_d).data_1 > -1280) return false; |
0 | 483 |
|
5264
b2b3c60af210
(svn r7402) -Fix: [FS#255] Long Delay for Message Windows to Appear. Immediately show a new message
Darkvater
parents:
5258
diff
changeset
|
484 |
// Newspaper message, decrement duration counter |
b2b3c60af210
(svn r7402) -Fix: [FS#255] Long Delay for Message Windows to Appear. Immediately show a new message
Darkvater
parents:
5258
diff
changeset
|
485 |
if (ni->duration != 0) ni->duration--; |
0 | 486 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
487 |
// neither newsticker nor newspaper are running |
5264
b2b3c60af210
(svn r7402) -Fix: [FS#255] Long Delay for Message Windows to Appear. Immediately show a new message
Darkvater
parents:
5258
diff
changeset
|
488 |
return (ni->duration == 0 || FindWindowById(WC_NEWS_WINDOW, 0) == NULL); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
489 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
490 |
|
5253
a9775de4e6b6
(svn r7383) -Codechange: fix up typo in news-gui s/MoveToNexItem/MoveToNextItem/.
Darkvater
parents:
5246
diff
changeset
|
491 |
static void MoveToNextItem(void) |
79
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 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
427 | 494 |
_forced_news = INVALID_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
495 |
|
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
496 |
// if we're not at the last item, then move on |
427 | 497 |
if (_current_news != _latest_news) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
498 |
NewsItem *ni; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
499 |
|
5258
eae66ac02803
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
500 |
_current_news = (_current_news == INVALID_NEWS) ? _oldest_news : increaseIndex(_current_news); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
501 |
ni = &_news_items[_current_news]; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
502 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
503 |
// check the date, don't show too old items |
2639 | 504 |
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
|
505 |
|
2639 | 506 |
switch (GetNewsDisplayValue(ni->type)) { |
507 |
case 0: { /* Off - show nothing only a small reminder in the status bar */ |
|
4171 | 508 |
Window *w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 509 |
|
1688
787400219027
(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
|
510 |
if (w != NULL) { |
787400219027
(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
|
511 |
WP(w, def_d).data_2 = 91; |
787400219027
(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
|
512 |
SetWindowDirty(w); |
787400219027
(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
|
513 |
} |
2639 | 514 |
break; |
515 |
} |
|
516 |
||
517 |
case 1: /* Summary - show ticker, but if forced big, cascade to full */ |
|
518 |
if (!(ni->flags & NF_FORCE_BIG)) { |
|
519 |
ShowTicker(ni); |
|
520 |
break; |
|
521 |
} |
|
522 |
/* Fallthrough */ |
|
523 |
||
524 |
case 2: /* Full - show newspaper*/ |
|
525 |
ShowNewspaper(ni); |
|
526 |
break; |
|
527 |
} |
|
0 | 528 |
} |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
529 |
} |
0 | 530 |
|
427 | 531 |
void NewsLoop(void) |
0 | 532 |
{ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
533 |
// no news item yet |
427 | 534 |
if (_total_news == 0) return; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
535 |
|
5253
a9775de4e6b6
(svn r7383) -Codechange: fix up typo in news-gui s/MoveToNexItem/MoveToNextItem/.
Darkvater
parents:
5246
diff
changeset
|
536 |
if (ReadyForNextItem()) MoveToNextItem(); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
537 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
538 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
539 |
/* Do a forced show of a specific message */ |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
540 |
static void ShowNewsMessage(NewsID i) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
541 |
{ |
427 | 542 |
if (_total_news == 0) return; |
89 | 543 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
544 |
// Delete the news window |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
545 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
546 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
547 |
// setup forced news item |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
548 |
_forced_news = i; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
549 |
|
427 | 550 |
if (_forced_news != INVALID_NEWS) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
551 |
NewsItem *ni = &_news_items[_forced_news]; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
552 |
ni->duration = 555; |
4874
b95cdd66085f
(svn r6804) -Codechange: Remove the unused NF_NOEXPIRE flag.
Darkvater
parents:
4873
diff
changeset
|
553 |
ni->flags |= NF_FORCE_BIG; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
554 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
555 |
ShowNewspaper(ni); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
556 |
} |
0 | 557 |
} |
558 |
||
427 | 559 |
void ShowLastNewsMessage(void) |
0 | 560 |
{ |
5414
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
561 |
if (_forced_news == INVALID_NEWS) { |
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
562 |
/* Not forced any news yet, show the current one, unless a news window is |
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
563 |
* open (which can only be the current one), then show the previous item */ |
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
564 |
const Window *w = FindWindowById(WC_NEWS_WINDOW, 0); |
5431
bad513e2c7d8
(svn r8627) [0.5] -Backport from trunk (8409, 8420 + 8421, 8533, 8612):
rubidium
parents:
5414
diff
changeset
|
565 |
ShowNewsMessage((w == NULL || (_current_news == _oldest_news)) ? _current_news : decreaseIndex(_current_news)); |
5414
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
566 |
} else if (_forced_news == _oldest_news) { |
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
567 |
/* We have reached the oldest news, start anew with the latest */ |
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
568 |
ShowNewsMessage(_latest_news); |
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
569 |
} else { |
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
570 |
/* 'Scrolling' through news history show each one in turn */ |
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
571 |
ShowNewsMessage(decreaseIndex(_forced_news)); |
83
bd21afea96d8
(svn r84) Improved news system code a little to avoid potential memory leaks
dominik
parents:
80
diff
changeset
|
572 |
} |
0 | 573 |
} |
574 |
||
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
575 |
|
89 | 576 |
/* return news by number, with 0 being the most |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
577 |
* recent news. Returns INVALID_NEWS if end of queue reached. */ |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
578 |
static NewsID getNews(NewsID i) |
89 | 579 |
{ |
2639 | 580 |
if (i >= _total_news) return INVALID_NEWS; |
89 | 581 |
|
2639 | 582 |
if (_latest_news < i) { |
89 | 583 |
i = _latest_news + MAX_NEWS - i; |
2639 | 584 |
} else { |
89 | 585 |
i = _latest_news - i; |
2639 | 586 |
} |
89 | 587 |
|
427 | 588 |
i %= MAX_NEWS; |
89 | 589 |
return i; |
590 |
} |
|
591 |
||
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
592 |
/** Draw an unformatted news message truncated to a maximum length. If |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
593 |
* length exceeds maximum length it will be postfixed by '...' |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
594 |
* @param x,y position of the string |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
595 |
* @param color the color the string will be shown in |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
596 |
* @param *ni NewsItem being printed |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
597 |
* @param maxw maximum width of string in pixels |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
598 |
*/ |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
599 |
static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint maxw) |
89 | 600 |
{ |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
601 |
char buffer[512], buffer2[512]; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
602 |
const char *ptr; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
603 |
char *dest; |
89 | 604 |
StringID str; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
605 |
|
89 | 606 |
if (ni->display_mode == 3) { |
607 |
str = _get_news_string_callback[ni->callback](ni); |
|
608 |
} else { |
|
609 |
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
|
610 |
str = ni->string_id; |
89 | 611 |
} |
612 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4874
diff
changeset
|
613 |
GetString(buffer, str, lastof(buffer)); |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
614 |
/* Copy the just gotten string to another buffer to remove any formatting |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
615 |
* from it such as big fonts, etc. */ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
616 |
ptr = buffer; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
617 |
dest = buffer2; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
618 |
for (;;) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
619 |
WChar c = Utf8Consume(&ptr); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
620 |
if (c == 0) break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
621 |
if (c == '\r') { |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
622 |
dest[0] = dest[1] = dest[2] = dest[3] = ' '; |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
623 |
dest += 4; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
624 |
} else if (IsPrintable(c)) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
625 |
dest += Utf8Encode(dest, c); |
89 | 626 |
} |
627 |
} |
|
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
628 |
|
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
629 |
*dest = '\0'; |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
630 |
/* Truncate and show string; postfixed by '...' if neccessary */ |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
631 |
DoDrawStringTruncated(buffer2, x, y, color, maxw); |
89 | 632 |
} |
633 |
||
634 |
||
635 |
static void MessageHistoryWndProc(Window *w, WindowEvent *e) |
|
636 |
{ |
|
427 | 637 |
switch (e->event) { |
89 | 638 |
case WE_PAINT: { |
427 | 639 |
int y = 19; |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
640 |
NewsID p, show; |
89 | 641 |
|
3155
b2cd7bc9f90f
(svn r3778) - Fix crash when resizing news history window.
peter1138
parents:
3143
diff
changeset
|
642 |
SetVScrollCount(w, _total_news); |
89 | 643 |
DrawWindowWidgets(w); |
644 |
||
427 | 645 |
if (_total_news == 0) break; |
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
646 |
show = min(_total_news, w->vscroll.cap); |
89 | 647 |
|
427 | 648 |
for (p = w->vscroll.pos; p < w->vscroll.pos + show; p++) { |
89 | 649 |
// get news in correct order |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
650 |
const NewsItem *ni = &_news_items[getNews(p)]; |
89 | 651 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
652 |
SetDParam(0, ni->date); |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
653 |
DrawString(4, y, STR_SHORT_DATE, 12); |
89 | 654 |
|
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
655 |
DrawNewsString(82, y, 12, ni, w->width - 95); |
89 | 656 |
y += 12; |
657 |
} |
|
658 |
break; |
|
659 |
} |
|
660 |
||
661 |
case WE_CLICK: |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
662 |
switch (e->we.click.widget) { |
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
663 |
case 3: { |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
664 |
int y = (e->we.click.pt.y - 19) / 12; |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
665 |
NewsID p = getNews(y + w->vscroll.pos); |
89 | 666 |
|
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
667 |
if (p == INVALID_NEWS) break; |
89 | 668 |
|
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
669 |
ShowNewsMessage(p); |
89 | 670 |
break; |
671 |
} |
|
672 |
} |
|
673 |
break; |
|
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
674 |
|
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
675 |
case WE_RESIZE: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
676 |
w->vscroll.cap += e->we.sizing.diff.y / 12; |
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
677 |
break; |
89 | 678 |
} |
679 |
} |
|
680 |
||
681 |
static const Widget _message_history_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
682 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
683 |
{ WWT_CAPTION, RESIZE_RIGHT, 13, 11, 387, 0, 13, STR_MESSAGE_HISTORY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
684 |
{ WWT_STICKYBOX, RESIZE_LR, 13, 388, 399, 0, 13, 0x0, STR_STICKY_BUTTON}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
685 |
{ WWT_PANEL, RESIZE_RB, 13, 0, 387, 14, 139, 0x0, STR_MESSAGE_HISTORY_TIP}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
686 |
{ WWT_SCROLLBAR, RESIZE_LRB, 13, 388, 399, 14, 127, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
687 |
{ 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
|
688 |
{ WIDGETS_END}, |
89 | 689 |
}; |
690 |
||
691 |
static const WindowDesc _message_history_desc = { |
|
692 |
240, 22, 400, 140, |
|
427 | 693 |
WC_MESSAGE_HISTORY, 0, |
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
694 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
89 | 695 |
_message_history_widgets, |
696 |
MessageHistoryWndProc |
|
697 |
}; |
|
698 |
||
427 | 699 |
void ShowMessageHistory(void) |
89 | 700 |
{ |
701 |
Window *w; |
|
702 |
||
703 |
DeleteWindowById(WC_MESSAGE_HISTORY, 0); |
|
704 |
w = AllocateWindowDesc(&_message_history_desc); |
|
705 |
||
427 | 706 |
if (w != NULL) { |
89 | 707 |
w->vscroll.cap = 10; |
708 |
w->vscroll.count = _total_news; |
|
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
709 |
w->resize.step_height = 12; |
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
710 |
w->resize.height = w->height - 12 * 6; // minimum of 4 items in the list, each item 12 high |
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
711 |
w->resize.step_width = 1; |
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
712 |
w->resize.width = 200; // can't make window any smaller than 200 pixel |
89 | 713 |
SetWindowDirty(w); |
714 |
} |
|
715 |
} |
|
716 |
||
1688
787400219027
(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 |
/** Setup the disabled/enabled buttons in the message window |
787400219027
(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 |
* If the value is 'off' disable the [<] widget, and enable the [>] one |
787400219027
(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 |
* Same-wise for all the others. Starting value of 3 is the first widget |
787400219027
(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 |
* group. These are grouped as [<][>] .. [<][>], etc. |
787400219027
(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 |
*/ |
787400219027
(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 |
static void SetMessageButtonStates(Window *w, byte value, int element) |
787400219027
(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 |
{ |
787400219027
(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 |
element *= 2; |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
725 |
|
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
726 |
SetWindowWidgetDisabledState(w, element + 3, value == 0); |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
727 |
SetWindowWidgetDisabledState(w, element + 3 + 1, value == 2); |
1688
787400219027
(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 |
} |
0 | 729 |
|
730 |
static void MessageOptionsWndProc(Window *w, WindowEvent *e) |
|
731 |
{ |
|
1688
787400219027
(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
|
732 |
static const StringID message_opt[] = {STR_OFF, STR_SUMMARY, STR_FULL, INVALID_STRING_ID}; |
787400219027
(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
|
733 |
|
787400219027
(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
|
734 |
/* WP(w, def_d).data_1 are stores the clicked state of the fake widgets |
787400219027
(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 |
* WP(w, def_d).data_2 stores state of the ALL on/off/summary button */ |
427 | 736 |
switch (e->event) { |
1688
787400219027
(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 |
case WE_CREATE: { |
787400219027
(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 |
uint32 val = _news_display_opt; |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
739 |
uint32 all_val; |
1688
787400219027
(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
|
740 |
int i; |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
741 |
WP(w, def_d).data_1 = 0; |
1688
787400219027
(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 |
|
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
743 |
/* Set up the initial disabled buttons in the case of 'off' or 'full' */ |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
744 |
all_val = val & 0x3; |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
745 |
for (i = 0; i != 10; i++, val >>= 2) { |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
746 |
SetMessageButtonStates(w, val & 0x3, i); |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
747 |
/* If the value doesn't match the ALL-button value, set the ALL-button value to 'off' */ |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
748 |
if ((val & 0x3) != all_val) all_val = 0; |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
749 |
} |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
750 |
/* If all values are the same value, the ALL-button will take over this value */ |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
751 |
WP(w, def_d).data_2 = all_val; |
1688
787400219027
(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 |
} break; |
787400219027
(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 |
|
0 | 754 |
case WE_PAINT: { |
1688
787400219027
(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 |
uint32 val = _news_display_opt; |
787400219027
(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 |
int click_state = WP(w, def_d).data_1; |
0 | 757 |
int i, y; |
758 |
||
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
759 |
if (_news_ticker_sound) LowerWindowWidget(w, 27); |
0 | 760 |
DrawWindowWidgets(w); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
761 |
|
1688
787400219027
(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 |
/* XXX - Draw the fake widgets-buttons. Can't add these to the widget-desc since |
787400219027
(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 |
* openttd currently can only handle 32 widgets. So hack it *g* */ |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
764 |
for (i = 0, y = 26; i < NT_END; i++, y += 12, click_state >>= 1, val >>= 2) { |
1688
787400219027
(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 |
bool clicked = !!(click_state & 1); |
787400219027
(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 |
|
1938
21bd6ef5f85e
(svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents:
1891
diff
changeset
|
767 |
DrawFrameRect(13, y, 89, 11 + y, 3, (clicked) ? FR_LOWERED : 0); |
1688
787400219027
(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 |
DrawStringCentered(((13 + 89 + 1) >> 1) + clicked, ((y + 11 + y + 1) >> 1) - 5 + clicked, message_opt[val & 0x3], 0x10); |
787400219027
(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 |
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
|
770 |
} |
0 | 771 |
|
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
772 |
DrawStringCentered(((13 + 89 + 1) >> 1), y + 9, message_opt[WP(w, def_d).data_2], 0x10); |
1688
787400219027
(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 |
DrawString(103, y + 9, STR_MESSAGES_ALL, 0); |
787400219027
(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 |
DrawString(103, y + 9 + 12, STR_MESSAGE_SOUND, 0); |
0 | 775 |
|
776 |
} break; |
|
1688
787400219027
(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 |
|
787400219027
(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 |
case WE_CLICK: |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
779 |
switch (e->we.click.widget) { |
1688
787400219027
(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 |
case 2: /* Clicked on any of the fake widgets */ |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
781 |
if (e->we.click.pt.x > 13 && e->we.click.pt.x < 89 && e->we.click.pt.y > 26 && e->we.click.pt.y < NT_END * 12 + 26) { |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
782 |
int element = (e->we.click.pt.y - 26) / 12; |
1688
787400219027
(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 |
byte val = (GetNewsDisplayValue(element) + 1) % 3; |
787400219027
(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 |
|
787400219027
(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 |
SetMessageButtonStates(w, val, element); |
787400219027
(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 |
SetNewsDisplayValue(element, val); |
787400219027
(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 |
|
787400219027
(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_1 |= (1 << element); |
787400219027
(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 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; // XXX - setup unclick (fake widget) |
787400219027
(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 |
SetWindowDirty(w); |
787400219027
(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 |
} |
787400219027
(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; |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
793 |
case 25: case 26: /* Dropdown menu for all settings */ |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
794 |
ShowDropDownMenu(w, message_opt, WP(w, def_d).data_2, 26, 0, 0); |
1688
787400219027
(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 |
break; |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
796 |
case 27: /* Change ticker sound on/off */ |
1688
787400219027
(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 |
_news_ticker_sound ^= 1; |
4719
413b21513ef7
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
798 |
ToggleWidgetLoweredState(w, e->we.click.widget); |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
799 |
InvalidateWidget(w, e->we.click.widget); |
1688
787400219027
(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
|
800 |
break; |
787400219027
(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
|
801 |
default: { /* Clicked on the [<] .. [>] widgets */ |
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
802 |
int wid = e->we.click.widget; |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
803 |
if (wid > 2 && wid <= NT_END * 2 + 2) { |
1688
787400219027
(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 |
int element = (wid - 3) / 2; |
787400219027
(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 |
byte val = (GetNewsDisplayValue(element) + ((wid & 1) ? -1 : 1)) % 3; |
787400219027
(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
|
806 |
|
787400219027
(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 |
SetMessageButtonStates(w, val, element); |
787400219027
(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 |
SetNewsDisplayValue(element, val); |
787400219027
(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 |
SetWindowDirty(w); |
787400219027
(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 |
} |
787400219027
(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 |
} break; |
787400219027
(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 |
} break; |
787400219027
(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 |
|
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
814 |
case WE_DROPDOWN_SELECT: {/* Select all settings for newsmessages */ |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
815 |
int i; |
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
816 |
|
4634
897461a3e9ca
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
817 |
WP(w, def_d).data_2 = e->we.dropdown.index; |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
818 |
|
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
819 |
for (i = 0; i < NT_END; i++) { |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
820 |
SetMessageButtonStates(w, e->we.dropdown.index, i); |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
821 |
SetNewsDisplayValue(i, e->we.dropdown.index); |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
822 |
} |
1688
787400219027
(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 |
SetWindowDirty(w); |
787400219027
(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 |
break; |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
825 |
} |
1688
787400219027
(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 |
|
787400219027
(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 |
case WE_TIMEOUT: /* XXX - Hack to animate 'fake' buttons */ |
787400219027
(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 |
WP(w, def_d).data_1 = 0; |
787400219027
(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 |
SetWindowDirty(w); |
787400219027
(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 |
break; |
0 | 831 |
} |
832 |
} |
|
833 |
||
834 |
static const Widget _message_options_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
835 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1688
787400219027
(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 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 409, 0, 13, STR_0204_MESSAGE_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
837 |
{ WWT_PANEL, RESIZE_NONE, 13, 0, 409, 14, 196, 0x0, STR_NULL}, |
1688
787400219027
(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
|
838 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
839 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 26, 37, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
840 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 26, 37, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
1688
787400219027
(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
|
841 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
842 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 38, 49, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
843 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 38, 49, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
1688
787400219027
(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
|
844 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
845 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 50, 61, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
846 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 50, 61, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
1688
787400219027
(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
|
847 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
848 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 62, 73, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
849 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 62, 73, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
850 |
|
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
851 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 74, 85, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
852 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 74, 85, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
853 |
|
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
854 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 86, 97, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
855 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 86, 97, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
856 |
|
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
857 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 98, 109, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
858 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 98, 109, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
859 |
|
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
860 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 110, 121, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
861 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 110, 121, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
862 |
|
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
863 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 122, 133, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
864 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 122, 133, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
865 |
|
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
866 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 134, 145, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
867 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 134, 145, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
868 |
|
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
869 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 4, 12, 146, 157, SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
870 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, 3, 90, 98, 146, 157, SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
871 |
|
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
872 |
{ WWT_PANEL, RESIZE_NONE, 3, 4, 86, 166, 177, 0x0, STR_NULL}, |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
873 |
{ WWT_TEXTBTN, RESIZE_NONE, 3, 87, 98, 166, 177, STR_0225, STR_NULL}, |
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
874 |
{ WWT_TEXTBTN_2, RESIZE_NONE, 3, 4, 98, 178, 189, STR_02DB_OFF, STR_NULL}, |
0 | 875 |
|
4345
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
876 |
{ WWT_LABEL, RESIZE_NONE, 13, 0, 409, 13, 26, STR_0205_MESSAGE_TYPES, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
102
diff
changeset
|
877 |
{ WIDGETS_END}, |
0 | 878 |
}; |
879 |
||
880 |
static const WindowDesc _message_options_desc = { |
|
5461
03285c9589f9
(svn r9343) [0.5] -Backport from trunk (r9000, r9001, r9097, r9137):
rubidium
parents:
5431
diff
changeset
|
881 |
270, 22, 410, 197, |
427 | 882 |
WC_GAME_OPTIONS, 0, |
0 | 883 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
884 |
_message_options_widgets, |
|
885 |
MessageOptionsWndProc |
|
886 |
}; |
|
887 |
||
427 | 888 |
void ShowMessageOptions(void) |
0 | 889 |
{ |
890 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
891 |
AllocateWindowDesc(&_message_options_desc); |
|
892 |
} |
|
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
893 |
|
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
894 |
|
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
895 |
void DeleteVehicleNews(VehicleID vid, StringID news) |
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
896 |
{ |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
897 |
NewsID n; |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
898 |
|
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
899 |
for (n = _oldest_news; _latest_news != INVALID_NEWS; n = increaseIndex(n)) { |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
900 |
const NewsItem *ni = &_news_items[n]; |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
901 |
|
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
902 |
if (ni->flags & NF_VEHICLE && |
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
903 |
ni->data_a == vid && |
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
904 |
(news == INVALID_STRING_ID || ni->string_id == news)) { |
4171 | 905 |
Window *w; |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
906 |
|
5414
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
907 |
/* If we delete a forced news and it is just before the current news |
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
908 |
* then we need to advance to the next news (if any) */ |
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
909 |
if (_forced_news == n) MoveToNextItem(); |
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
910 |
if (_forced_news == INVALID_NEWS && _current_news == n) MoveToNextItem(); |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
911 |
_total_news--; |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
912 |
|
5395
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
913 |
/* If this is the last news item, invalidate _latest_news */ |
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
914 |
if (_total_news == 0) { |
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
915 |
assert(_latest_news == _oldest_news); |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
916 |
_latest_news = INVALID_NEWS; |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
917 |
} |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
918 |
|
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
919 |
/* Since we only imitate a FIFO removing an arbitrary element does need |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
920 |
* some magic. Remove the item by shifting head towards the tail. eg |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
921 |
* oldest remove last |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
922 |
* | | | |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
923 |
* [------O--------n-----L--] |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
924 |
* will become (change dramatized to make clear) |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
925 |
* [---------O-----------L--] |
5395
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
926 |
* We also need an update of the current, forced and visible (open window) |
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
927 |
* news's as this shifting could change the items they were pointing to */ |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
928 |
if (_total_news != 0) { |
5414
039b96c813b3
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
Darkvater
parents:
5395
diff
changeset
|
929 |
NewsID visible_news, i; |
5395
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
930 |
w = FindWindowById(WC_NEWS_WINDOW, 0); |
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
931 |
visible_news = (w != NULL) ? (NewsID)(WP(w, news_d).ni - _news_items) : INVALID_NEWS; |
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
932 |
|
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
933 |
for (i = n;; i = decreaseIndex(i)) { |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
934 |
_news_items[i] = _news_items[decreaseIndex(i)]; |
5395
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
935 |
|
5431
bad513e2c7d8
(svn r8627) [0.5] -Backport from trunk (8409, 8420 + 8421, 8533, 8612):
rubidium
parents:
5414
diff
changeset
|
936 |
if (i != _latest_news) { |
bad513e2c7d8
(svn r8627) [0.5] -Backport from trunk (8409, 8420 + 8421, 8533, 8612):
rubidium
parents:
5414
diff
changeset
|
937 |
if (i == _current_news) _current_news = increaseIndex(_current_news); |
bad513e2c7d8
(svn r8627) [0.5] -Backport from trunk (8409, 8420 + 8421, 8533, 8612):
rubidium
parents:
5414
diff
changeset
|
938 |
if (i == _forced_news) _forced_news = increaseIndex(_forced_news); |
bad513e2c7d8
(svn r8627) [0.5] -Backport from trunk (8409, 8420 + 8421, 8533, 8612):
rubidium
parents:
5414
diff
changeset
|
939 |
if (i == visible_news) WP(w, news_d).ni = &_news_items[increaseIndex(visible_news)]; |
bad513e2c7d8
(svn r8627) [0.5] -Backport from trunk (8409, 8420 + 8421, 8533, 8612):
rubidium
parents:
5414
diff
changeset
|
940 |
} |
5395
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
941 |
|
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
942 |
if (i == _oldest_news) break; |
5244
e110f52333e8
(svn r7368) -Fix: [FS#332] Vehicle Deletion Crash [News Window Related?] (r3757).
Darkvater
parents:
5108
diff
changeset
|
943 |
} |
e110f52333e8
(svn r7368) -Fix: [FS#332] Vehicle Deletion Crash [News Window Related?] (r3757).
Darkvater
parents:
5108
diff
changeset
|
944 |
_oldest_news = increaseIndex(_oldest_news); |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
945 |
} |
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
946 |
|
5395
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
947 |
/*DEBUG(misc, 0) ("-cur %3d, old %2d, lat %3d, for %3d, tot %2d", |
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
948 |
_current_news, _oldest_news, _latest_news, _forced_news, _total_news); */ |
9443baf4f597
(svn r7952) -Backport from trunk (r7823, r7861):
Darkvater
parents:
5264
diff
changeset
|
949 |
|
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
950 |
w = FindWindowById(WC_MESSAGE_HISTORY, 0); |
3143 | 951 |
if (w != NULL) { |
952 |
SetWindowDirty(w); |
|
953 |
w->vscroll.count = _total_news; |
|
954 |
} |
|
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
955 |
} |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
956 |
|
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
957 |
if (n == _latest_news) break; |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
958 |
} |
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
959 |
} |