author | rubidium |
Mon, 07 Jan 2008 14:23:25 +0000 | |
changeset 8214 | 971f861d5543 |
parent 8157 | 1505def01945 |
child 8224 | c5a64d87cc54 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
3 |
|
0 | 4 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1688
diff
changeset
|
5 |
#include "openttd.h" |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
6 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
7 |
#include "table/strings.h" |
3155
c4673c936039
(svn r3778) - Fix crash when resizing news history window.
peter1138
parents:
3143
diff
changeset
|
8 |
#include "gui.h" |
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
9 |
#include "window_gui.h" |
0 | 10 |
#include "viewport.h" |
11 |
#include "news.h" |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2150
diff
changeset
|
12 |
#include "variables.h" |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
7824
diff
changeset
|
13 |
#include "transparency.h" |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8107
diff
changeset
|
14 |
#include "strings_func.h" |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8121
diff
changeset
|
15 |
#include "window_func.h" |
8140
0d0d8c94f84b
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8131
diff
changeset
|
16 |
#include "date_func.h" |
8144
65cec0877b78
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8140
diff
changeset
|
17 |
#include "vehicle_base.h" |
8157
1505def01945
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8144
diff
changeset
|
18 |
#include "sound_func.h" |
8214
971f861d5543
(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents:
8157
diff
changeset
|
19 |
#include "string_func.h" |
0 | 20 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
21 |
/** @file news_gui.cpp |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
22 |
* |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
23 |
* News system is realized as a FIFO queue (in an array) |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
24 |
* The positions in the queue can't be rearranged, we only access |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
25 |
* the array elements through pointers to the elements. Once the |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
26 |
* array is full, the oldest entry (\a _oldest_news) is being overwritten |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
27 |
* by the newest (\a _latest_news). |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
28 |
* |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
29 |
* \verbatim |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
30 |
* oldest current lastest |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
31 |
* | | | |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
32 |
* [O------------F-------------C---------L ] |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
33 |
* | |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
34 |
* forced |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
35 |
* \endverbatim |
5254
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
36 |
* |
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
37 |
* Of course by using an array we can have situations like |
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
38 |
* |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
39 |
* \verbatim |
5254
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
40 |
* [----L O-----F---------C-----------------] |
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
41 |
* This is where we have wrapped around the array and have |
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
42 |
* (MAX_NEWS - O) + L news items |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
43 |
* \endverbatim |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
44 |
*/ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
45 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
46 |
/** Number of news items in the FIFO queue */ |
427 | 47 |
#define MAX_NEWS 30 |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
48 |
#define NB_WIDG_PER_SETTING 4 |
427 | 49 |
|
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
50 |
typedef byte NewsID; |
427 | 51 |
#define INVALID_NEWS 255 |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
52 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
53 |
static NewsItem _news_items[MAX_NEWS]; ///< The news FIFO queue |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
54 |
static NewsID _current_news = INVALID_NEWS; ///< points to news item that should be shown next |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
55 |
static NewsID _oldest_news = 0; ///< points to first item in fifo queue |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
56 |
static NewsID _latest_news = INVALID_NEWS; ///< points to last item in fifo queue |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
57 |
|
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
58 |
/** Forced news item. |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
59 |
* Users can force an item by accessing the history or "last message". |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
60 |
* If the message being shown was forced by the user, its index is stored in |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
61 |
* _forced_news. Otherwise, \a _forced_news variable is INVALID_NEWS. */ |
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
62 |
static NewsID _forced_news = INVALID_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
63 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
64 |
static byte _total_news = 0; ///< Number of news items in FIFO queue @see _news_items |
0 | 65 |
|
6209
3a1a90cd67f3
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6197
diff
changeset
|
66 |
void DrawNewsNewVehicleAvail(Window *w); |
0 | 67 |
void DrawNewsBankrupcy(Window *w); |
6247 | 68 |
static void MoveToNextItem(); |
0 | 69 |
|
6209
3a1a90cd67f3
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6197
diff
changeset
|
70 |
StringID GetNewsStringNewVehicleAvail(const NewsItem *ni); |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
71 |
StringID GetNewsStringBankrupcy(const NewsItem *ni); |
0 | 72 |
|
73 |
static DrawNewsCallbackProc * const _draw_news_callback[] = { |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
74 |
DrawNewsNewVehicleAvail, ///< DNC_VEHICLEAVAIL |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
75 |
DrawNewsBankrupcy, ///< DNC_BANKRUPCY |
0 | 76 |
}; |
77 |
||
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
78 |
extern GetNewsStringCallbackProc * const _get_news_string_callback[]; |
0 | 79 |
GetNewsStringCallbackProc * const _get_news_string_callback[] = { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
80 |
GetNewsStringNewVehicleAvail, ///< DNC_VEHICLEAVAIL |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
81 |
GetNewsStringBankrupcy, ///< DNC_BANKRUPCY |
0 | 82 |
}; |
83 |
||
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
84 |
/** Initialize the news-items data structures */ |
6247 | 85 |
void InitNewsItemStructs() |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
86 |
{ |
427 | 87 |
memset(_news_items, 0, sizeof(_news_items)); |
88 |
_current_news = INVALID_NEWS; |
|
89 | 89 |
_oldest_news = 0; |
427 | 90 |
_latest_news = INVALID_NEWS; |
91 |
_forced_news = INVALID_NEWS; |
|
89 | 92 |
_total_news = 0; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
93 |
} |
0 | 94 |
|
427 | 95 |
void DrawNewsBorder(const Window *w) |
0 | 96 |
{ |
97 |
int left = 0; |
|
98 |
int right = w->width - 1; |
|
99 |
int top = 0; |
|
100 |
int bottom = w->height - 1; |
|
101 |
||
102 |
GfxFillRect(left, top, right, bottom, 0xF); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
103 |
|
0 | 104 |
GfxFillRect(left, top, left, bottom, 0xD7); |
105 |
GfxFillRect(right, top, right, bottom, 0xD7); |
|
106 |
GfxFillRect(left, top, right, top, 0xD7); |
|
107 |
GfxFillRect(left, bottom, right, bottom, 0xD7); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
108 |
|
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7598
diff
changeset
|
109 |
DrawString(left + 2, top + 1, STR_00C6, TC_FROMSTRING); |
0 | 110 |
} |
111 |
||
112 |
static void NewsWindowProc(Window *w, WindowEvent *e) |
|
113 |
{ |
|
427 | 114 |
switch (e->event) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
115 |
case WE_CREATE: { // If chatbar is open at creation time, we need to go above it |
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
116 |
const Window *w1 = FindWindowById(WC_SEND_NETWORK_MSG, 0); |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
117 |
w->message.msg = (w1 != NULL) ? w1->height : 0; |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
118 |
} break; |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
119 |
|
0 | 120 |
case WE_PAINT: { |
427 | 121 |
const NewsItem *ni = WP(w, news_d).ni; |
0 | 122 |
ViewPort *vp; |
123 |
||
427 | 124 |
switch (ni->display_mode) { |
125 |
case NM_NORMAL: |
|
126 |
case NM_THIN: { |
|
127 |
DrawNewsBorder(w); |
|
0 | 128 |
|
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7598
diff
changeset
|
129 |
DrawString(2, 1, STR_00C6, TC_FROMSTRING); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
130 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
131 |
SetDParam(0, ni->date); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7598
diff
changeset
|
132 |
DrawStringRightAligned(428, 1, STR_01FF, TC_FROMSTRING); |
427 | 133 |
|
134 |
if (!(ni->flags & NF_VIEWPORT)) { |
|
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
6624
diff
changeset
|
135 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
427 | 136 |
DrawStringMultiCenter(215, ni->display_mode == NM_NORMAL ? 76 : 56, |
6197
558f3a9b5bd4
(svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents:
5893
diff
changeset
|
137 |
ni->string_id, w->width - 4); |
427 | 138 |
} else { |
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6348
diff
changeset
|
139 |
/* Back up transparency options to draw news view */ |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
7824
diff
changeset
|
140 |
TransparencyOptionBits to_backup = _transparency_opt; |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
7824
diff
changeset
|
141 |
_transparency_opt = 0; |
427 | 142 |
DrawWindowViewport(w); |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
7824
diff
changeset
|
143 |
_transparency_opt = to_backup; |
427 | 144 |
|
145 |
/* Shade the viewport into gray, or color*/ |
|
146 |
vp = w->viewport; |
|
147 |
GfxFillRect(vp->left - w->left, vp->top - w->top, |
|
148 |
vp->left - w->left + vp->width - 1, vp->top - w->top + vp->height - 1, |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5595
diff
changeset
|
149 |
(ni->flags & NF_INCOLOR ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY) | (1 << USE_COLORTABLE) |
427 | 150 |
); |
151 |
||
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
6624
diff
changeset
|
152 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
6197
558f3a9b5bd4
(svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents:
5893
diff
changeset
|
153 |
DrawStringMultiCenter(w->width / 2, 20, ni->string_id, w->width - 4); |
427 | 154 |
} |
155 |
break; |
|
0 | 156 |
} |
427 | 157 |
|
158 |
case NM_CALLBACK: { |
|
159 |
_draw_news_callback[ni->callback](w); |
|
160 |
break; |
|
161 |
} |
|
162 |
||
163 |
default: { |
|
164 |
DrawWindowWidgets(w); |
|
165 |
if (!(ni->flags & NF_VIEWPORT)) { |
|
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
6624
diff
changeset
|
166 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
427 | 167 |
DrawStringMultiCenter(140, 38, ni->string_id, 276); |
168 |
} else { |
|
169 |
DrawWindowViewport(w); |
|
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
6624
diff
changeset
|
170 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
6197
558f3a9b5bd4
(svn r8977) -Codechange: Remove the hardcoded maximum width for some drawstrings and replace them with a portion of w->width. Only visible improvement is QueryWndProc which will not write exactly to the edge of the window anymore.
Darkvater
parents:
5893
diff
changeset
|
171 |
DrawStringMultiCenter(w->width / 2, w->height - 16, ni->string_id, w->width - 4); |
427 | 172 |
} |
173 |
break; |
|
0 | 174 |
} |
175 |
} |
|
176 |
} break; |
|
177 |
||
178 |
case WE_CLICK: { |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
179 |
switch (e->we.click.widget) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
180 |
case 1: { |
427 | 181 |
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
|
182 |
DeleteWindow(w); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
183 |
ni->duration = 0; |
427 | 184 |
_forced_news = INVALID_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
185 |
} break; |
0 | 186 |
case 0: { |
427 | 187 |
NewsItem *ni = WP(w, news_d).ni; |
0 | 188 |
if (ni->flags & NF_VEHICLE) { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
189 |
Vehicle *v = GetVehicle(ni->data_a); |
0 | 190 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
191 |
} else if (ni->flags & NF_TILE) { |
|
192 |
if (!ScrollMainWindowToTile(ni->data_a) && ni->data_b != 0) |
|
193 |
ScrollMainWindowToTile(ni->data_b); |
|
194 |
} |
|
195 |
} break; |
|
196 |
} |
|
197 |
} break; |
|
198 |
||
199 |
case WE_KEYPRESS: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
200 |
if (e->we.keypress.keycode == WKC_SPACE) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
201 |
/* Don't continue. */ |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
202 |
e->we.keypress.cont = false; |
0 | 203 |
DeleteWindow(w); |
204 |
} |
|
205 |
break; |
|
206 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
207 |
case WE_MESSAGE: // The chatbar has notified us that is was either created or closed |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
208 |
switch (e->we.message.msg) { |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
209 |
case WE_CREATE: w->message.msg = e->we.message.wparam; break; |
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
210 |
case WE_DESTROY: w->message.msg = 0; break; |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
211 |
} |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
212 |
break; |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
213 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
214 |
case WE_TICK: { // Scroll up newsmessages from the bottom in steps of 4 pixels |
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
215 |
int diff; |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
216 |
int y = max(w->top - 4, _screen.height - w->height - 12 - w->message.msg); |
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
217 |
if (y == w->top) return; |
0 | 218 |
|
219 |
if (w->viewport != NULL) |
|
220 |
w->viewport->top += y - w->top; |
|
221 |
||
7970
7d6b9ab57081
(svn r11526) -Codechange: Rename the function delta fitting to the naming style
skidd13
parents:
7891
diff
changeset
|
222 |
diff = Delta(w->top, y); |
0 | 223 |
w->top = y; |
224 |
||
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
225 |
SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height); |
0 | 226 |
} break; |
227 |
} |
|
228 |
} |
|
229 |
||
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
230 |
/** |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
231 |
* Return the correct index in the pseudo-fifo |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
232 |
* queue and deals with overflows when increasing the index |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
233 |
*/ |
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
234 |
static inline NewsID increaseIndex(NewsID i) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
235 |
{ |
5258
28d07c40ea82
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
236 |
assert(i != INVALID_NEWS); |
5245
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
237 |
return (i + 1) % MAX_NEWS; |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
238 |
} |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
239 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
240 |
/** |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
241 |
* Return the correct index in the pseudo-fifo |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
242 |
* queue and deals with overflows when decreasing the index |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
243 |
*/ |
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
244 |
static inline NewsID decreaseIndex(NewsID i) |
5245
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
245 |
{ |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
246 |
assert(i != INVALID_NEWS); |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
247 |
return (i + MAX_NEWS - 1) % MAX_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
248 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
249 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
250 |
/** |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
251 |
* Add a new newsitem to be shown. |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
252 |
* @param string String to display, can have special values based on parameter \a flags |
4873
11880cbbc9f6
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
253 |
* @param flags various control bits that will show various news-types. See macro NEWS_FLAGS() |
11880cbbc9f6
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
254 |
* @param data_a news-specific value based on news type |
11880cbbc9f6
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
255 |
* @param data_b news-specific value based on news type |
6481
85ad87daf4b0
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents:
6427
diff
changeset
|
256 |
* @note flags exists of 4 byte-sized extra parameters. |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
257 |
* -# Bits 0 - 7 display_mode, any of the NewsMode enums (NM_) |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
258 |
* -# Bits 8 - 15 news flags, any of the NewsFlags enums (NF_) |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
259 |
* -# Bits 16 - 23 news category, any of the NewsType enums (NT_) |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
260 |
* -# Bits 24 - 31 news callback function, any of the NewsCallback enums (DNC_) |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
261 |
* |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
262 |
* If the display mode is NM_CALLBACK, special news is shown and parameter |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
263 |
* \a string has a special meaning. |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
264 |
* - For DNC_TRAINAVAIL, DNC_ROADAVAIL, DNC_SHIPAVAIL, DNC_AIRCRAFTAVAIL messages: StringID is |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
265 |
* the index of the engine that is shown |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
266 |
* |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
267 |
* - For DNC_BANKRUPCY: bytes 0-3 of StringID contains the player that is in trouble, |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
268 |
* and 4-7 contains what kind of bankrupcy message is shown. |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
269 |
* @see NewsBankrupcy |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
270 |
* |
4873
11880cbbc9f6
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
271 |
* @see NewsMode |
11880cbbc9f6
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
272 |
* @see NewsFlags |
11880cbbc9f6
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
273 |
* @see NewsType |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
274 |
* @see NewsCallback |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
275 |
*/ |
0 | 276 |
void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b) |
277 |
{ |
|
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
278 |
NewsID l_news; |
0 | 279 |
|
4000
4009d092b306
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3155
diff
changeset
|
280 |
if (_game_mode == GM_MENU) return; |
0 | 281 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
282 |
/* check the rare case that the oldest (to be overwritten) news item is open */ |
5245
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
283 |
if (_total_news == MAX_NEWS && (_oldest_news == _current_news || _oldest_news == _forced_news)) |
5253
ff50454e0604
(svn r7383) -Codechange: fix up typo in news-gui s/MoveToNexItem/MoveToNextItem/.
Darkvater
parents:
5246
diff
changeset
|
284 |
MoveToNextItem(); |
102
1d277a07f1f1
(svn r103) Fix: rare newspaper crash with too many messages [ 1009976 ] (thx to blathij)s
dominik
parents:
94
diff
changeset
|
285 |
|
427 | 286 |
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
|
287 |
|
5258
28d07c40ea82
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
288 |
/* Increase _latest_news. If we have no news yet, use _oldest news as an |
28d07c40ea82
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
289 |
* index. We cannot use 0 as _oldest_news can jump around due to |
28d07c40ea82
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
290 |
* DeleteVehicleNews */ |
5244
af95451c3b88
(svn r7368) -Fix: [FS#332] Vehicle Deletion Crash [News Window Related?] (r3757).
Darkvater
parents:
5108
diff
changeset
|
291 |
l_news = _latest_news; |
5258
28d07c40ea82
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
292 |
_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
|
293 |
|
5244
af95451c3b88
(svn r7368) -Fix: [FS#332] Vehicle Deletion Crash [News Window Related?] (r3757).
Darkvater
parents:
5108
diff
changeset
|
294 |
/* If the fifo-buffer is full, overwrite the oldest entry */ |
5245
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
295 |
if (l_news != INVALID_NEWS && _latest_news == _oldest_news) { |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
296 |
assert(_total_news == MAX_NEWS); |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
297 |
_oldest_news = increaseIndex(_oldest_news); |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
298 |
} |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
299 |
|
5595
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
300 |
/*DEBUG(misc, 0, "+cur %3d, old %2d, lat %3d, for %3d, tot %2d", |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
301 |
_current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/ |
5520
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
302 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
303 |
/* Add news to _latest_news */ |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
304 |
{ |
5245
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
305 |
Window *w; |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
306 |
NewsItem *ni = &_news_items[_latest_news]; |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
307 |
memset(ni, 0, sizeof(*ni)); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
308 |
|
5245
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
309 |
ni->string_id = string; |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
310 |
ni->display_mode = (byte)flags; |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
311 |
ni->flags = (byte)(flags >> 8); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
312 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
313 |
/* show this news message in color? */ |
5245
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
314 |
if (_cur_year >= _patches.colored_news_year) ni->flags |= NF_INCOLOR; |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
315 |
|
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
316 |
ni->type = (byte)(flags >> 16); |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
317 |
ni->callback = (byte)(flags >> 24); |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
318 |
ni->data_a = data_a; |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
319 |
ni->data_b = data_b; |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
320 |
ni->date = _date; |
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
6624
diff
changeset
|
321 |
CopyOutDParam(ni->params, 0, lengthof(ni->params)); |
5245
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
322 |
|
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
323 |
w = FindWindowById(WC_MESSAGE_HISTORY, 0); |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
324 |
if (w == NULL) return; |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
325 |
SetWindowDirty(w); |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
326 |
w->vscroll.count = _total_news; |
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
327 |
} |
0 | 328 |
} |
329 |
||
715
28dd55cc55ae
(svn r1167) Feature: Added the possibility to add validation functions to NewsItems. This is now done for "Train in depot" messages. Before displaying such a message, it checks if the train really still is in the depot. Can be applied to other news items as well.
dominik
parents:
541
diff
changeset
|
330 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
331 |
/** |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
332 |
* Maximum age of news items. |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
333 |
* Don't show item if it's older than x days, corresponds with NewsType in news.h |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
334 |
* @see NewsType |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
335 |
*/ |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
336 |
static const byte _news_items_age[NT_END] = { |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
337 |
60, ///< NT_ARRIVAL_PLAYER |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
338 |
60, ///< NT_ARRIVAL_OTHER |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
339 |
90, ///< NT_ACCIDENT |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
340 |
60, ///< NT_COMPANY_INFO |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
341 |
90, ///< NT_OPENCLOSE |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
342 |
30, ///< NT_ECONOMY |
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
343 |
30, ///< NT_INDUSTRY_PLAYER |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
344 |
30, ///< NT_INDUSTRY_OTHER |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
345 |
30, ///< NT_INDUSTRY_NOBODY |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
346 |
150, ///< NT_ADVICE |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
347 |
30, ///< NT_NEW_VEHICLES |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
348 |
90, ///< NT_ACCEPTANCE |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
349 |
180, ///< NT_SUBSIDIES |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
350 |
60 ///< NT_GENERAL |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
351 |
}; |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
352 |
|
0 | 353 |
|
354 |
static const Widget _news_type13_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
355 |
{ WWT_PANEL, RESIZE_NONE, 15, 0, 429, 0, 169, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
356 |
{ 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
|
357 |
{ WIDGETS_END}, |
0 | 358 |
}; |
359 |
||
360 |
static WindowDesc _news_type13_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7266
diff
changeset
|
361 |
WDP_CENTER, 476, 430, 170, 430, 170, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5839
diff
changeset
|
362 |
WC_NEWS_WINDOW, WC_NONE, |
0 | 363 |
WDF_DEF_WIDGET, |
364 |
_news_type13_widgets, |
|
365 |
NewsWindowProc |
|
366 |
}; |
|
367 |
||
368 |
static const Widget _news_type2_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
369 |
{ WWT_PANEL, RESIZE_NONE, 15, 0, 429, 0, 129, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
370 |
{ 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
|
371 |
{ WIDGETS_END}, |
0 | 372 |
}; |
373 |
||
374 |
static WindowDesc _news_type2_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7266
diff
changeset
|
375 |
WDP_CENTER, 476, 430, 130, 430, 130, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5839
diff
changeset
|
376 |
WC_NEWS_WINDOW, WC_NONE, |
0 | 377 |
WDF_DEF_WIDGET, |
378 |
_news_type2_widgets, |
|
379 |
NewsWindowProc |
|
380 |
}; |
|
381 |
||
382 |
static const Widget _news_type0_widgets[] = { |
|
4344
7e123fec5b0b
(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
|
383 |
{ WWT_PANEL, RESIZE_NONE, 5, 0, 279, 14, 86, 0x0, STR_NULL}, |
7e123fec5b0b
(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
|
384 |
{ WWT_CLOSEBOX, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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
|
385 |
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 279, 0, 13, STR_012C_MESSAGE, STR_NULL}, |
4939
bef7c24a6027
(svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents:
4938
diff
changeset
|
386 |
{ 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
|
387 |
{ WIDGETS_END}, |
0 | 388 |
}; |
389 |
||
390 |
static WindowDesc _news_type0_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7266
diff
changeset
|
391 |
WDP_CENTER, 476, 280, 87, 280, 87, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5839
diff
changeset
|
392 |
WC_NEWS_WINDOW, WC_NONE, |
0 | 393 |
WDF_DEF_WIDGET, |
394 |
_news_type0_widgets, |
|
395 |
NewsWindowProc |
|
396 |
}; |
|
397 |
||
6283
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
398 |
static const SoundFx _news_sounds[NT_END] = { |
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
399 |
SND_1D_APPLAUSE, ///< NT_ARRIVAL_PLAYER |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
400 |
SND_1D_APPLAUSE, ///< NT_ARRIVAL_OTHER |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
401 |
SND_BEGIN, ///< NT_ACCIDENT |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
402 |
SND_BEGIN, ///< NT_COMPANY_INFO |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
403 |
SND_BEGIN, ///< NT_OPENCLOSE |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
404 |
SND_BEGIN, ///< NT_ECONOMY |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
405 |
SND_BEGIN, ///< NT_INDUSTRY_PLAYER |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
406 |
SND_BEGIN, ///< NT_INDUSTRY_OTHER |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
407 |
SND_BEGIN, ///< NT_INDUSTRY_NOBODY |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
408 |
SND_BEGIN, ///< NT_ADVICE |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
409 |
SND_1E_OOOOH, ///< NT_NEW_VEHICLES |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
410 |
SND_BEGIN, ///< NT_ACCEPTANCE |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
411 |
SND_BEGIN, ///< NT_SUBSIDIES |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
412 |
SND_BEGIN, ///< NT_GENERAL |
6283
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
413 |
}; |
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
414 |
|
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
415 |
const char *_news_display_name[NT_END] = { |
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
416 |
"arrival_player", |
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
417 |
"arrival_other", |
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
418 |
"accident", |
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
419 |
"company_info", |
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
420 |
"openclose", |
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
421 |
"economy", |
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
422 |
"production_player", |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
423 |
"production_other", |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
424 |
"production_nobody", |
6283
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
425 |
"advice", |
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
426 |
"new_vehicles", |
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
427 |
"acceptance", |
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
428 |
"subsidies", |
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
429 |
"general", |
427 | 430 |
}; |
0 | 431 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
432 |
/** |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
433 |
* Get the value of an item of the news-display settings. This is |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
434 |
* a little tricky since on/off/summary must use 2 bits to store the value |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
435 |
* @param item the item whose value is requested |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
436 |
* @return return the found value which is between 0-2 |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
437 |
*/ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
438 |
static inline byte GetNewsDisplayValue(byte item) |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
439 |
{ |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
440 |
assert(item < NT_END && GB(_news_display_opt, item * 2, 2) <= 2); |
2549 | 441 |
return GB(_news_display_opt, item * 2, 2); |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
442 |
} |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
443 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
444 |
/** |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
445 |
* Set the value of an item in the news-display settings. This is |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
446 |
* a little tricky since on/off/summary must use 2 bits to store the value |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
447 |
* @param item the item whose value is being set |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
448 |
* @param val new value |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
449 |
*/ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
450 |
static inline void SetNewsDisplayValue(byte item, byte val) |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
451 |
{ |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
452 |
assert(item < NT_END && val <= 2); |
2549 | 453 |
SB(_news_display_opt, item * 2, 2, val); |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
454 |
} |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
455 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
456 |
/** Open up an own newspaper window for the news item */ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
457 |
static void ShowNewspaper(NewsItem *ni) |
0 | 458 |
{ |
459 |
Window *w; |
|
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2227
diff
changeset
|
460 |
SoundFx sound; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
461 |
int top; |
4874
afafed841c6d
(svn r6804) -Codechange: Remove the unused NF_NOEXPIRE flag.
Darkvater
parents:
4873
diff
changeset
|
462 |
ni->flags &= ~NF_FORCE_BIG; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
463 |
ni->duration = 555; |
0 | 464 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
465 |
sound = _news_sounds[ni->type]; |
2639 | 466 |
if (sound != 0) SndPlayFx(sound); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
467 |
|
1648
41c3d5de9994
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
468 |
top = _screen.height; |
427 | 469 |
switch (ni->display_mode) { |
470 |
case NM_NORMAL: |
|
471 |
case NM_CALLBACK: { |
|
472 |
_news_type13_desc.top = top; |
|
473 |
w = AllocateWindowDesc(&_news_type13_desc); |
|
474 |
if (ni->flags & NF_VIEWPORT) |
|
475 |
AssignWindowViewport(w, 2, 58, 0x1AA, 0x6E, |
|
6624
880e29b1f25e
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6542
diff
changeset
|
476 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS); |
427 | 477 |
break; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
478 |
} |
427 | 479 |
|
480 |
case NM_THIN: { |
|
481 |
_news_type2_desc.top = top; |
|
482 |
w = AllocateWindowDesc(&_news_type2_desc); |
|
483 |
if (ni->flags & NF_VIEWPORT) |
|
484 |
AssignWindowViewport(w, 2, 58, 0x1AA, 0x46, |
|
6624
880e29b1f25e
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6542
diff
changeset
|
485 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS); |
427 | 486 |
break; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
487 |
} |
427 | 488 |
|
489 |
default: { |
|
490 |
_news_type0_desc.top = top; |
|
491 |
w = AllocateWindowDesc(&_news_type0_desc); |
|
492 |
if (ni->flags & NF_VIEWPORT) |
|
493 |
AssignWindowViewport(w, 3, 17, 0x112, 0x2F, |
|
6624
880e29b1f25e
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6542
diff
changeset
|
494 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS); |
427 | 495 |
break; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
496 |
} |
0 | 497 |
} |
5520
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
498 |
|
5595
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
499 |
/*DEBUG(misc, 0, " cur %3d, old %2d, lat %3d, for %3d, tot %2d", |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
500 |
_current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/ |
5520
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
501 |
|
427 | 502 |
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
|
503 |
w->flags4 |= WF_DISABLE_VP_SCROLL; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
504 |
} |
0 | 505 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
506 |
/** Show news item in the ticker */ |
427 | 507 |
static void ShowTicker(const NewsItem *ni) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
508 |
{ |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
509 |
Window *w; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
510 |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
511 |
if (_news_ticker_sound) SndPlayFx(SND_16_MORSE); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
512 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
513 |
_statusbar_news_item = *ni; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
514 |
w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 515 |
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
|
516 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
517 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
518 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
519 |
/** |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
520 |
* Are we ready to show another news item? |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
521 |
* Only if nothing is in the newsticker and no newspaper is displayed |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
522 |
*/ |
6247 | 523 |
static bool ReadyForNextItem() |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
524 |
{ |
427 | 525 |
const Window *w; |
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
526 |
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
|
527 |
NewsItem *ni; |
20b4c7536349
(svn r93) Fix: memory leak in news system (blathijs)
dominik
parents:
89
diff
changeset
|
528 |
|
427 | 529 |
if (item >= MAX_NEWS) return true; |
92
20b4c7536349
(svn r93) Fix: memory leak in news system (blathijs)
dominik
parents:
89
diff
changeset
|
530 |
ni = &_news_items[item]; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
531 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
532 |
/* Ticker message |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
533 |
* Check if the status bar message is still being displayed? */ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
534 |
w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 535 |
if (w != NULL && WP(w, const def_d).data_1 > -1280) return false; |
0 | 536 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
537 |
/* Newspaper message, decrement duration counter */ |
5264
1e3cd1ed1ee6
(svn r7402) -Fix: [FS#255] Long Delay for Message Windows to Appear. Immediately show a new message
Darkvater
parents:
5258
diff
changeset
|
538 |
if (ni->duration != 0) ni->duration--; |
0 | 539 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
540 |
/* neither newsticker nor newspaper are running */ |
5264
1e3cd1ed1ee6
(svn r7402) -Fix: [FS#255] Long Delay for Message Windows to Appear. Immediately show a new message
Darkvater
parents:
5258
diff
changeset
|
541 |
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
|
542 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
543 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
544 |
/** Move to the next news item */ |
6247 | 545 |
static void MoveToNextItem() |
79
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 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
427 | 548 |
_forced_news = INVALID_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
549 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
550 |
/* if we're not at the last item, then move on */ |
427 | 551 |
if (_current_news != _latest_news) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
552 |
NewsItem *ni; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
553 |
|
5258
28d07c40ea82
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
554 |
_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
|
555 |
ni = &_news_items[_current_news]; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
556 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
557 |
/* check the date, don't show too old items */ |
2639 | 558 |
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
|
559 |
|
2639 | 560 |
switch (GetNewsDisplayValue(ni->type)) { |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
561 |
default: NOT_REACHED(); |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
562 |
case 0: { // Off - show nothing only a small reminder in the status bar |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
563 |
Window *w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 564 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
565 |
if (w != NULL) { |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
566 |
WP(w, def_d).data_2 = 91; |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
567 |
SetWindowDirty(w); |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
568 |
} |
2639 | 569 |
break; |
570 |
} |
|
571 |
||
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
572 |
case 1: // Summary - show ticker, but if forced big, cascade to full |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
573 |
if (!(ni->flags & NF_FORCE_BIG)) { |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
574 |
ShowTicker(ni); |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
575 |
break; |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
576 |
} |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
577 |
/* Fallthrough */ |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
578 |
|
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
579 |
case 2: // Full - show newspaper |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
580 |
ShowNewspaper(ni); |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
581 |
break; |
2639 | 582 |
} |
0 | 583 |
} |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
584 |
} |
0 | 585 |
|
6247 | 586 |
void NewsLoop() |
0 | 587 |
{ |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
588 |
/* no news item yet */ |
427 | 589 |
if (_total_news == 0) return; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
590 |
|
5253
ff50454e0604
(svn r7383) -Codechange: fix up typo in news-gui s/MoveToNexItem/MoveToNextItem/.
Darkvater
parents:
5246
diff
changeset
|
591 |
if (ReadyForNextItem()) MoveToNextItem(); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
592 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
593 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
594 |
/** Do a forced show of a specific message */ |
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
595 |
static void ShowNewsMessage(NewsID i) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
596 |
{ |
427 | 597 |
if (_total_news == 0) return; |
89 | 598 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
599 |
/* Delete the news window */ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
600 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
601 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
602 |
/* setup forced news item */ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
603 |
_forced_news = i; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
604 |
|
427 | 605 |
if (_forced_news != INVALID_NEWS) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
606 |
NewsItem *ni = &_news_items[_forced_news]; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
607 |
ni->duration = 555; |
4874
afafed841c6d
(svn r6804) -Codechange: Remove the unused NF_NOEXPIRE flag.
Darkvater
parents:
4873
diff
changeset
|
608 |
ni->flags |= NF_FORCE_BIG; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
609 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
610 |
ShowNewspaper(ni); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
611 |
} |
0 | 612 |
} |
613 |
||
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
614 |
/** Show previous news item */ |
6247 | 615 |
void ShowLastNewsMessage() |
0 | 616 |
{ |
5595
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
617 |
if (_forced_news == INVALID_NEWS) { |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
618 |
/* Not forced any news yet, show the current one, unless a news window is |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
619 |
* open (which can only be the current one), then show the previous item */ |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
620 |
const Window *w = FindWindowById(WC_NEWS_WINDOW, 0); |
5839
15e33fa8f9f7
(svn r8409) -Regression (r8049): When the latest news was deleted, the news queue wrapped back to the oldest item, showing all news again.
Darkvater
parents:
5668
diff
changeset
|
621 |
ShowNewsMessage((w == NULL || (_current_news == _oldest_news)) ? _current_news : decreaseIndex(_current_news)); |
5595
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
622 |
} else if (_forced_news == _oldest_news) { |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
623 |
/* We have reached the oldest news, start anew with the latest */ |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
624 |
ShowNewsMessage(_latest_news); |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
625 |
} else { |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
626 |
/* 'Scrolling' through news history show each one in turn */ |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
627 |
ShowNewsMessage(decreaseIndex(_forced_news)); |
83
bd21afea96d8
(svn r84) Improved news system code a little to avoid potential memory leaks
dominik
parents:
80
diff
changeset
|
628 |
} |
0 | 629 |
} |
630 |
||
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
631 |
|
89 | 632 |
/* return news by number, with 0 being the most |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
633 |
* recent news. Returns INVALID_NEWS if end of queue reached. */ |
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
634 |
static NewsID getNews(NewsID i) |
89 | 635 |
{ |
2639 | 636 |
if (i >= _total_news) return INVALID_NEWS; |
89 | 637 |
|
2639 | 638 |
if (_latest_news < i) { |
89 | 639 |
i = _latest_news + MAX_NEWS - i; |
2639 | 640 |
} else { |
89 | 641 |
i = _latest_news - i; |
2639 | 642 |
} |
89 | 643 |
|
427 | 644 |
i %= MAX_NEWS; |
89 | 645 |
return i; |
646 |
} |
|
647 |
||
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
648 |
/** |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
649 |
* Draw an unformatted news message truncated to a maximum length. If |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
650 |
* length exceeds maximum length it will be postfixed by '...' |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
651 |
* @param x,y position of the string |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
652 |
* @param color the color the string will be shown in |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
653 |
* @param *ni NewsItem being printed |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
654 |
* @param maxw maximum width of string in pixels |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
655 |
*/ |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
656 |
static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint maxw) |
89 | 657 |
{ |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
658 |
char buffer[512], buffer2[512]; |
5108
aeaef6fe53b7
(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
|
659 |
const char *ptr; |
aeaef6fe53b7
(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
|
660 |
char *dest; |
89 | 661 |
StringID str; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
662 |
|
7854
8232d650df92
(svn r11404) -Codechange: remove 2 magical numbers
belugas
parents:
7849
diff
changeset
|
663 |
if (ni->display_mode == NM_CALLBACK) { |
89 | 664 |
str = _get_news_string_callback[ni->callback](ni); |
665 |
} else { |
|
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
6624
diff
changeset
|
666 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
667 |
str = ni->string_id; |
89 | 668 |
} |
669 |
||
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4874
diff
changeset
|
670 |
GetString(buffer, str, lastof(buffer)); |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
671 |
/* Copy the just gotten string to another buffer to remove any formatting |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
672 |
* from it such as big fonts, etc. */ |
5108
aeaef6fe53b7
(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
|
673 |
ptr = buffer; |
aeaef6fe53b7
(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
|
674 |
dest = buffer2; |
6542
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
675 |
WChar c_last = '\0'; |
5108
aeaef6fe53b7
(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
|
676 |
for (;;) { |
aeaef6fe53b7
(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
|
677 |
WChar c = Utf8Consume(&ptr); |
aeaef6fe53b7
(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
|
678 |
if (c == 0) break; |
6542
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
679 |
/* Make a space from a newline, but ignore multiple newlines */ |
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
680 |
if (c == '\n' && c_last != '\n') { |
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
681 |
dest[0] = ' '; |
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
682 |
dest++; |
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
683 |
} else if (c == '\r') { |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
684 |
dest[0] = dest[1] = dest[2] = dest[3] = ' '; |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
685 |
dest += 4; |
5108
aeaef6fe53b7
(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
|
686 |
} else if (IsPrintable(c)) { |
aeaef6fe53b7
(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
|
687 |
dest += Utf8Encode(dest, c); |
89 | 688 |
} |
6542
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
689 |
c_last = c; |
89 | 690 |
} |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
691 |
|
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
692 |
*dest = '\0'; |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
693 |
/* Truncate and show string; postfixed by '...' if neccessary */ |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
694 |
DoDrawStringTruncated(buffer2, x, y, color, maxw); |
89 | 695 |
} |
696 |
||
697 |
||
698 |
static void MessageHistoryWndProc(Window *w, WindowEvent *e) |
|
699 |
{ |
|
427 | 700 |
switch (e->event) { |
89 | 701 |
case WE_PAINT: { |
427 | 702 |
int y = 19; |
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
703 |
NewsID p, show; |
89 | 704 |
|
3155
c4673c936039
(svn r3778) - Fix crash when resizing news history window.
peter1138
parents:
3143
diff
changeset
|
705 |
SetVScrollCount(w, _total_news); |
89 | 706 |
DrawWindowWidgets(w); |
707 |
||
427 | 708 |
if (_total_news == 0) break; |
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
709 |
show = min(_total_news, w->vscroll.cap); |
89 | 710 |
|
427 | 711 |
for (p = w->vscroll.pos; p < w->vscroll.pos + show; p++) { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
712 |
/* get news in correct order */ |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
713 |
const NewsItem *ni = &_news_items[getNews(p)]; |
89 | 714 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
715 |
SetDParam(0, ni->date); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7598
diff
changeset
|
716 |
DrawString(4, y, STR_SHORT_DATE, TC_WHITE); |
89 | 717 |
|
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7598
diff
changeset
|
718 |
DrawNewsString(82, y, TC_WHITE, ni, w->width - 95); |
89 | 719 |
y += 12; |
720 |
} |
|
721 |
break; |
|
722 |
} |
|
723 |
||
724 |
case WE_CLICK: |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
725 |
switch (e->we.click.widget) { |
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
726 |
case 3: { |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
727 |
int y = (e->we.click.pt.y - 19) / 12; |
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
728 |
NewsID p = getNews(y + w->vscroll.pos); |
89 | 729 |
|
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
730 |
if (p == INVALID_NEWS) break; |
89 | 731 |
|
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
732 |
ShowNewsMessage(p); |
89 | 733 |
break; |
734 |
} |
|
735 |
} |
|
736 |
break; |
|
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
737 |
|
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
738 |
case WE_RESIZE: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4549
diff
changeset
|
739 |
w->vscroll.cap += e->we.sizing.diff.y / 12; |
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
740 |
break; |
89 | 741 |
} |
742 |
} |
|
743 |
||
744 |
static const Widget _message_history_widgets[] = { |
|
4344
7e123fec5b0b
(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
|
745 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
7e123fec5b0b
(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
|
746 |
{ WWT_CAPTION, RESIZE_RIGHT, 13, 11, 387, 0, 13, STR_MESSAGE_HISTORY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
7e123fec5b0b
(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
|
747 |
{ WWT_STICKYBOX, RESIZE_LR, 13, 388, 399, 0, 13, 0x0, STR_STICKY_BUTTON}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
748 |
{ WWT_PANEL, RESIZE_RB, 13, 0, 387, 14, 139, 0x0, STR_MESSAGE_HISTORY_TIP}, |
4344
7e123fec5b0b
(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
|
749 |
{ WWT_SCROLLBAR, RESIZE_LRB, 13, 388, 399, 14, 127, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
7e123fec5b0b
(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
|
750 |
{ 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
|
751 |
{ WIDGETS_END}, |
89 | 752 |
}; |
753 |
||
754 |
static const WindowDesc _message_history_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7266
diff
changeset
|
755 |
240, 22, 400, 140, 400, 140, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5839
diff
changeset
|
756 |
WC_MESSAGE_HISTORY, WC_NONE, |
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
757 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
89 | 758 |
_message_history_widgets, |
759 |
MessageHistoryWndProc |
|
760 |
}; |
|
761 |
||
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
762 |
/** Display window with news messages history */ |
6247 | 763 |
void ShowMessageHistory() |
89 | 764 |
{ |
765 |
Window *w; |
|
766 |
||
767 |
DeleteWindowById(WC_MESSAGE_HISTORY, 0); |
|
768 |
w = AllocateWindowDesc(&_message_history_desc); |
|
769 |
||
427 | 770 |
if (w != NULL) { |
89 | 771 |
w->vscroll.cap = 10; |
772 |
w->vscroll.count = _total_news; |
|
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
773 |
w->resize.step_height = 12; |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
774 |
w->resize.height = w->height - 12 * 6; // minimum of 4 items in the list, each item 12 high |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
775 |
w->resize.step_width = 1; |
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
776 |
w->resize.width = 200; // can't make window any smaller than 200 pixel |
89 | 777 |
SetWindowDirty(w); |
778 |
} |
|
779 |
} |
|
780 |
||
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
781 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
782 |
/** News settings window widget offset constants */ |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
783 |
enum { |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
784 |
WIDGET_NEWSOPT_BTN_SUMMARY = 4, ///< Button that adjusts at once the level for all settings |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
785 |
WIDGET_NEWSOPT_DROP_SUMMARY, ///< Drop down button for same upper button |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
786 |
WIDGET_NEWSOPT_SOUNDTICKER = 7, ///< Button activating sound on events |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
787 |
WIDGET_NEWSOPT_START_OPTION = 9, ///< First widget that is part of a group [<] .. [.] |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
788 |
}; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
789 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
790 |
/** |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
791 |
* Setup the disabled/enabled buttons in the message window |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
792 |
* If the value is 'off' disable the [<] widget, and enable the [>] one |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
793 |
* Same-wise for all the others. Starting value of 4 is the first widget |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
794 |
* group. These are grouped as [<][>] .. [<][>], etc. |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
795 |
* @param w Window been used |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
796 |
* @param value to set in the widget |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
797 |
* @param element index of the group of widget to set |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
798 |
*/ |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
799 |
static void SetMessageButtonStates(Window *w, byte value, int element) |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
800 |
{ |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
801 |
element *= NB_WIDG_PER_SETTING; |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
802 |
|
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7970
diff
changeset
|
803 |
w->SetWidgetDisabledState(element + WIDGET_NEWSOPT_START_OPTION, value == 0); |
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7970
diff
changeset
|
804 |
w->SetWidgetDisabledState(element + WIDGET_NEWSOPT_START_OPTION + 2, value == 2); |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
805 |
} |
0 | 806 |
|
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
807 |
/** |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
808 |
* Event handler of the Message Options window |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
809 |
* @param w window pointer |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
810 |
* @param e event been triggered |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
811 |
*/ |
0 | 812 |
static void MessageOptionsWndProc(Window *w, WindowEvent *e) |
813 |
{ |
|
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
814 |
static const StringID message_opt[] = {STR_OFF, STR_SUMMARY, STR_FULL, INVALID_STRING_ID}; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
815 |
|
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
816 |
/* WP(w, def_d).data_1 stores state of the ALL on/off/summary button */ |
427 | 817 |
switch (e->event) { |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
818 |
case WE_CREATE: { |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
819 |
uint32 val = _news_display_opt; |
6302
b7d7554b7418
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6283
diff
changeset
|
820 |
uint32 all_val; |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
821 |
int i; |
0 | 822 |
|
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
823 |
/* Set up the initial disabled buttons in the case of 'off' or 'full' */ |
6302
b7d7554b7418
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6283
diff
changeset
|
824 |
all_val = val & 0x3; |
b7d7554b7418
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6283
diff
changeset
|
825 |
for (i = 0; i < NT_END; i++, val >>= 2) { |
b7d7554b7418
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6283
diff
changeset
|
826 |
SetMessageButtonStates(w, val & 0x3, i); |
b7d7554b7418
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6283
diff
changeset
|
827 |
/* If the value doesn't match the ALL-button value, set the ALL-button value to 'off' */ |
b7d7554b7418
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6283
diff
changeset
|
828 |
if ((val & 0x3) != all_val) all_val = 0; |
b7d7554b7418
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6283
diff
changeset
|
829 |
} |
b7d7554b7418
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6283
diff
changeset
|
830 |
/* If all values are the same value, the ALL-button will take over this value */ |
b7d7554b7418
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6283
diff
changeset
|
831 |
WP(w, def_d).data_1 = all_val; |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
832 |
} break; |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
833 |
|
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
834 |
case WE_PAINT: { |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
835 |
uint32 val = _news_display_opt; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
836 |
int i, y; |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
837 |
|
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7970
diff
changeset
|
838 |
if (_news_ticker_sound) w->LowerWidget(WIDGET_NEWSOPT_SOUNDTICKER); |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
839 |
DrawWindowWidgets(w); |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
840 |
|
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
841 |
/* Draw the string of each setting on each button. */ |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
842 |
for (i = 0, y = 26; i < NT_END; i++, y += 12, val >>= 2) { |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
843 |
/* 51 comes from 13 + 89 (left and right of the button)+1, shiefted by one as to get division, |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
844 |
* which will give centered position */ |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7598
diff
changeset
|
845 |
DrawStringCentered(51, y + 1, message_opt[val & 0x3], TC_BLACK); |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
846 |
} |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
847 |
|
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
848 |
/* Draw the general bottom button string as well */ |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7598
diff
changeset
|
849 |
DrawStringCentered(51, y + 10, message_opt[WP(w, def_d).data_1], TC_BLACK); |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
850 |
} break; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
851 |
|
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
852 |
case WE_CLICK: |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
853 |
switch (e->we.click.widget) { |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
854 |
case WIDGET_NEWSOPT_BTN_SUMMARY: |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
855 |
case WIDGET_NEWSOPT_DROP_SUMMARY: // Dropdown menu for all settings |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
856 |
ShowDropDownMenu(w, message_opt, WP(w, def_d).data_1, WIDGET_NEWSOPT_DROP_SUMMARY, 0, 0); |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
857 |
break; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
858 |
|
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
859 |
case WIDGET_NEWSOPT_SOUNDTICKER: // Change ticker sound on/off |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
860 |
_news_ticker_sound ^= 1; |
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7970
diff
changeset
|
861 |
w->ToggleWidgetLoweredState(e->we.click.widget); |
8028
e578ea22f371
(svn r11588) -Codechange: use the new member introduced in r11551
glx
parents:
7997
diff
changeset
|
862 |
w->InvalidateWidget(e->we.click.widget); |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
863 |
break; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
864 |
|
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
865 |
default: { // Clicked on the [<] .. [>] widgets |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
866 |
int wid = e->we.click.widget - WIDGET_NEWSOPT_START_OPTION; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
867 |
if (wid >= 0 && wid < (NB_WIDG_PER_SETTING * NT_END)) { |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
868 |
int element = wid / NB_WIDG_PER_SETTING; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
869 |
byte val = (GetNewsDisplayValue(element) + ((wid % NB_WIDG_PER_SETTING) ? 1 : -1)) % 3; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
870 |
|
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
871 |
SetMessageButtonStates(w, val, element); |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
872 |
SetNewsDisplayValue(element, val); |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
873 |
SetWindowDirty(w); |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
874 |
} |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
875 |
} break; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
876 |
} break; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
877 |
|
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
878 |
case WE_DROPDOWN_SELECT: { // Select all settings for newsmessages |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
879 |
int i; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
880 |
|
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
881 |
WP(w, def_d).data_1 = e->we.dropdown.index; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
882 |
|
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
883 |
for (i = 0; i < NT_END; i++) { |
6283
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
884 |
SetMessageButtonStates(w, e->we.dropdown.index, i); |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
885 |
SetNewsDisplayValue(i, e->we.dropdown.index); |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
886 |
} |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
887 |
SetWindowDirty(w); |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
888 |
} break; |
0 | 889 |
} |
890 |
} |
|
891 |
||
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
892 |
|
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
893 |
/* |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
894 |
* The news settings window widgets |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
895 |
* |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
896 |
* Main part of the window is a list of news-setting lines, one for each news category. |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
897 |
* Each line is constructed by an expansion of the \c NEWS_SETTINGS_LINE macro |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
898 |
*/ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
899 |
|
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
900 |
/** |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
901 |
* Macro to construct one news-setting line in the news-settings window. |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
902 |
* One line consists of four widgets, namely |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
903 |
* - A [<] button |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
904 |
* - A [...] label |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
905 |
* - A [>] button |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
906 |
* - A text label describing the news category |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
907 |
* Horizontal positions of the widgets are hard-coded, vertical start position is (\a basey + \a linenum * \c NEWS_SETTING_BASELINE_SKIP). |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
908 |
* Height of one line is 12, with the text label shifted 1 pixel down. |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
909 |
* |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
910 |
* First line should be widget number WIDGET_NEWSOPT_START_OPTION |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
911 |
* |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
912 |
* @param basey: Base Y coordinate |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
913 |
* @param linenum: Count, news-setting is the \a linenum-th line |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
914 |
* @param text: StringID for the text label to display |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
915 |
*/ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
916 |
#define NEWS_SETTINGS_LINE(basey, linenum, text) \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
917 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_YELLOW, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
918 |
4, 12, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
919 |
SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
920 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
921 |
13, 89, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
922 |
STR_EMPTY, STR_NULL}, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
923 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_YELLOW, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
924 |
90, 98, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
925 |
SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
926 |
{ WWT_TEXT, RESIZE_NONE, COLOUR_YELLOW, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
927 |
103, 409, basey + 1 + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 13 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
928 |
text, STR_NULL} |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
929 |
|
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
930 |
static const int NEWS_SETTING_BASELINE_SKIP = 12; ///< Distance between two news-setting lines, should be at least 12 |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
931 |
|
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
932 |
|
0 | 933 |
static const Widget _message_options_widgets[] = { |
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
934 |
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_BROWN, 0, 10, 0, 13, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
935 |
STR_00C5, STR_018B_CLOSE_WINDOW}, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
936 |
{ WWT_CAPTION, RESIZE_NONE, COLOUR_BROWN, 11, 409, 0, 13, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
937 |
STR_0204_MESSAGE_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
938 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_BROWN, 0, 409, 14, 64 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
939 |
0x0, STR_NULL}, |
4344
7e123fec5b0b
(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
|
940 |
|
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
941 |
/* Text at the top of the main panel, in black */ |
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
942 |
{ WWT_LABEL, RESIZE_NONE, COLOUR_BROWN, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
943 |
0, 409, 13, 26, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
944 |
STR_0205_MESSAGE_TYPES, STR_NULL}, |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
945 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
946 |
/* General drop down and sound button, widgets WIDGET_NEWSOPT_BTN_SUMMARY and WIDGET_NEWSOPT_DROP_SUMMARY */ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
947 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_YELLOW, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
948 |
4, 86, 34 + NT_END * NEWS_SETTING_BASELINE_SKIP, 45 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
949 |
0x0, STR_NULL}, |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
950 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
951 |
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_YELLOW, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
952 |
87, 98, 34 + NT_END * NEWS_SETTING_BASELINE_SKIP, 45 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
953 |
STR_0225, STR_NULL}, |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
954 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
955 |
{ WWT_TEXT, RESIZE_NONE, COLOUR_YELLOW, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
956 |
103, 409, 35 + NT_END * NEWS_SETTING_BASELINE_SKIP, 47 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
957 |
STR_MESSAGES_ALL, STR_NULL}, |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
958 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
959 |
/* Below is widget WIDGET_NEWSOPT_SOUNDTICKER */ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
960 |
{ WWT_TEXTBTN_2, RESIZE_NONE, COLOUR_YELLOW, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
961 |
4, 98, 46 + NT_END * NEWS_SETTING_BASELINE_SKIP, 57 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
962 |
STR_02DB_OFF, STR_NULL}, |
6283
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
963 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
964 |
{ WWT_TEXT, RESIZE_NONE, COLOUR_YELLOW, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
965 |
103, 409, 47 + NT_END * NEWS_SETTING_BASELINE_SKIP, 59 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
966 |
STR_MESSAGE_SOUND, STR_NULL}, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
967 |
|
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
968 |
/* List of news-setting lines (4 widgets for each line). |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
969 |
* First widget must be number WIDGET_NEWSOPT_START_OPTION |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
970 |
*/ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
971 |
NEWS_SETTINGS_LINE(26, NT_ARRIVAL_PLAYER, STR_0206_ARRIVAL_OF_FIRST_VEHICLE), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
972 |
NEWS_SETTINGS_LINE(26, NT_ARRIVAL_OTHER, STR_0207_ARRIVAL_OF_FIRST_VEHICLE), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
973 |
NEWS_SETTINGS_LINE(26, NT_ACCIDENT, STR_0208_ACCIDENTS_DISASTERS), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
974 |
NEWS_SETTINGS_LINE(26, NT_COMPANY_INFO, STR_0209_COMPANY_INFORMATION), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
975 |
NEWS_SETTINGS_LINE(26, NT_OPENCLOSE, STR_NEWS_OPEN_CLOSE), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
976 |
NEWS_SETTINGS_LINE(26, NT_ECONOMY, STR_020A_ECONOMY_CHANGES), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
977 |
NEWS_SETTINGS_LINE(26, NT_INDUSTRY_PLAYER, STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
978 |
NEWS_SETTINGS_LINE(26, NT_INDUSTRY_OTHER, STR_INDUSTRY_CHANGES_SERVED_BY_OTHER), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
979 |
NEWS_SETTINGS_LINE(26, NT_INDUSTRY_NOBODY, STR_OTHER_INDUSTRY_PRODUCTION_CHANGES), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
980 |
NEWS_SETTINGS_LINE(26, NT_ADVICE, STR_020B_ADVICE_INFORMATION_ON_PLAYER), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
981 |
NEWS_SETTINGS_LINE(26, NT_NEW_VEHICLES, STR_020C_NEW_VEHICLES), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
982 |
NEWS_SETTINGS_LINE(26, NT_ACCEPTANCE, STR_020D_CHANGES_OF_CARGO_ACCEPTANCE), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
983 |
NEWS_SETTINGS_LINE(26, NT_SUBSIDIES, STR_020E_SUBSIDIES), |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
984 |
NEWS_SETTINGS_LINE(26, NT_GENERAL, STR_020F_GENERAL_INFORMATION), |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
985 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
102
diff
changeset
|
986 |
{ WIDGETS_END}, |
0 | 987 |
}; |
988 |
||
989 |
static const WindowDesc _message_options_desc = { |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
990 |
270, 22, 410, 65 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
991 |
410, 65 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5839
diff
changeset
|
992 |
WC_GAME_OPTIONS, WC_NONE, |
0 | 993 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
994 |
_message_options_widgets, |
|
995 |
MessageOptionsWndProc |
|
996 |
}; |
|
997 |
||
6247 | 998 |
void ShowMessageOptions() |
0 | 999 |
{ |
1000 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
1001 |
AllocateWindowDesc(&_message_options_desc); |
|
1002 |
} |
|
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1003 |
|
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1004 |
|
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1005 |
void DeleteVehicleNews(VehicleID vid, StringID news) |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1006 |
{ |
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
1007 |
NewsID n; |
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1008 |
|
5254
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1009 |
for (n = _oldest_news; _latest_news != INVALID_NEWS; n = increaseIndex(n)) { |
5245
2dae2048ac0a
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
1010 |
const NewsItem *ni = &_news_items[n]; |
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1011 |
|
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1012 |
if (ni->flags & NF_VEHICLE && |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1013 |
ni->data_a == vid && |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1014 |
(news == INVALID_STRING_ID || ni->string_id == news)) { |
4171 | 1015 |
Window *w; |
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1016 |
|
5595
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
1017 |
/* If we delete a forced news and it is just before the current news |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
1018 |
* then we need to advance to the next news (if any) */ |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
1019 |
if (_forced_news == n) MoveToNextItem(); |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
1020 |
if (_forced_news == INVALID_NEWS && _current_news == n) MoveToNextItem(); |
5254
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1021 |
_total_news--; |
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1022 |
|
5520
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
1023 |
/* If this is the last news item, invalidate _latest_news */ |
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
1024 |
if (_total_news == 0) { |
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
1025 |
assert(_latest_news == _oldest_news); |
5254
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1026 |
_latest_news = INVALID_NEWS; |
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1027 |
} |
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1028 |
|
5254
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1029 |
/* Since we only imitate a FIFO removing an arbitrary element does need |
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1030 |
* some magic. Remove the item by shifting head towards the tail. eg |
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1031 |
* oldest remove last |
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1032 |
* | | | |
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1033 |
* [------O--------n-----L--] |
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1034 |
* will become (change dramatized to make clear) |
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1035 |
* [---------O-----------L--] |
5520
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
1036 |
* We also need an update of the current, forced and visible (open window) |
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
1037 |
* news's as this shifting could change the items they were pointing to */ |
5254
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1038 |
if (_total_news != 0) { |
5520
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
1039 |
w = FindWindowById(WC_NEWS_WINDOW, 0); |
5595
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
1040 |
NewsID visible_news = (w != NULL) ? (NewsID)(WP(w, news_d).ni - _news_items) : INVALID_NEWS; |
5520
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
1041 |
|
5595
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
1042 |
for (NewsID i = n;; i = decreaseIndex(i)) { |
5246
fb214a312549
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
1043 |
_news_items[i] = _news_items[decreaseIndex(i)]; |
5254
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1044 |
|
5839
15e33fa8f9f7
(svn r8409) -Regression (r8049): When the latest news was deleted, the news queue wrapped back to the oldest item, showing all news again.
Darkvater
parents:
5668
diff
changeset
|
1045 |
if (i != _latest_news) { |
15e33fa8f9f7
(svn r8409) -Regression (r8049): When the latest news was deleted, the news queue wrapped back to the oldest item, showing all news again.
Darkvater
parents:
5668
diff
changeset
|
1046 |
if (i == _current_news) _current_news = increaseIndex(_current_news); |
15e33fa8f9f7
(svn r8409) -Regression (r8049): When the latest news was deleted, the news queue wrapped back to the oldest item, showing all news again.
Darkvater
parents:
5668
diff
changeset
|
1047 |
if (i == _forced_news) _forced_news = increaseIndex(_forced_news); |
15e33fa8f9f7
(svn r8409) -Regression (r8049): When the latest news was deleted, the news queue wrapped back to the oldest item, showing all news again.
Darkvater
parents:
5668
diff
changeset
|
1048 |
if (i == visible_news) WP(w, news_d).ni = &_news_items[increaseIndex(visible_news)]; |
15e33fa8f9f7
(svn r8409) -Regression (r8049): When the latest news was deleted, the news queue wrapped back to the oldest item, showing all news again.
Darkvater
parents:
5668
diff
changeset
|
1049 |
} |
5520
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
1050 |
|
5533
9336b14a5ef2
(svn r7861) -Fix (r7823): Crash when oldest news was deleted. First check the index for oldest news
Darkvater
parents:
5520
diff
changeset
|
1051 |
if (i == _oldest_news) break; |
9336b14a5ef2
(svn r7861) -Fix (r7823): Crash when oldest news was deleted. First check the index for oldest news
Darkvater
parents:
5520
diff
changeset
|
1052 |
} |
5244
af95451c3b88
(svn r7368) -Fix: [FS#332] Vehicle Deletion Crash [News Window Related?] (r3757).
Darkvater
parents:
5108
diff
changeset
|
1053 |
_oldest_news = increaseIndex(_oldest_news); |
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1054 |
} |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1055 |
|
5595
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
1056 |
/*DEBUG(misc, 0, "-cur %3d, old %2d, lat %3d, for %3d, tot %2d", |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
1057 |
_current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/ |
5520
dd1482ee78c4
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5475
diff
changeset
|
1058 |
|
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1059 |
w = FindWindowById(WC_MESSAGE_HISTORY, 0); |
3143 | 1060 |
if (w != NULL) { |
1061 |
SetWindowDirty(w); |
|
1062 |
w->vscroll.count = _total_news; |
|
1063 |
} |
|
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1064 |
} |
5254
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1065 |
|
bce68eeaab3b
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
1066 |
if (n == _latest_news) break; |
3139
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1067 |
} |
b17abef09e15
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
1068 |
} |