author | rubidium |
Sat, 10 May 2008 12:30:27 +0000 | |
changeset 10485 | 331014dcd0d3 |
parent 10478 | f7761642d9b6 |
child 10500 | 6f62be34657c |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10429
1b99254f9607
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
10411
diff
changeset
|
3 |
/** @file news_gui.cpp GUI functions related to news messages. */ |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1688
diff
changeset
|
6 |
#include "openttd.h" |
3155
b2cd7bc9f90f
(svn r3778) - Fix crash when resizing news history window.
peter1138
parents:
3143
diff
changeset
|
7 |
#include "gui.h" |
8603
88c5ce6a5215
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8602
diff
changeset
|
8 |
#include "window_gui.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8710
diff
changeset
|
9 |
#include "viewport_func.h" |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
10 |
#include "news_func.h" |
8766
c86cfa3a7580
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8764
diff
changeset
|
11 |
#include "settings_type.h" |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8320
diff
changeset
|
12 |
#include "transparency.h" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8603
diff
changeset
|
13 |
#include "strings_func.h" |
8627
448ebf3a8291
(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:
8617
diff
changeset
|
14 |
#include "window_func.h" |
8636
2b158acb649c
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8627
diff
changeset
|
15 |
#include "date_func.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8636
diff
changeset
|
16 |
#include "vehicle_base.h" |
8653
a83f7a536919
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8640
diff
changeset
|
17 |
#include "sound_func.h" |
8710
52015340050c
(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents:
8653
diff
changeset
|
18 |
#include "string_func.h" |
8780
6f3f3ec6c69a
(svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents:
8766
diff
changeset
|
19 |
#include "widgets/dropdown_func.h" |
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
20 |
#include "map_func.h" |
0 | 21 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8720
diff
changeset
|
22 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8720
diff
changeset
|
23 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8720
diff
changeset
|
24 |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
25 |
/** @file news_gui.cpp |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
26 |
* |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
27 |
* News system is realized as a FIFO queue (in an array) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
28 |
* The positions in the queue can't be rearranged, we only access |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
29 |
* the array elements through pointers to the elements. Once the |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
30 |
* array is full, the oldest entry (\a _oldest_news) is being overwritten |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
31 |
* by the newest (\a _latest_news). |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
32 |
* |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
33 |
* \verbatim |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
34 |
* oldest current lastest |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
35 |
* | | | |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
36 |
* [O------------F-------------C---------L ] |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
37 |
* | |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
38 |
* forced |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
39 |
* \endverbatim |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
40 |
* |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
41 |
* Of course by using an array we can have situations like |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
42 |
* |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
43 |
* \verbatim |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
44 |
* [----L O-----F---------C-----------------] |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
45 |
* This is where we have wrapped around the array and have |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
46 |
* (MAX_NEWS - O) + L news items |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
47 |
* \endverbatim |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
48 |
*/ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
49 |
|
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
50 |
#define NB_WIDG_PER_SETTING 4 |
427 | 51 |
|
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
52 |
typedef byte NewsID; |
427 | 53 |
#define INVALID_NEWS 255 |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
54 |
|
8764
65746a5248ec
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8760
diff
changeset
|
55 |
NewsItem _statusbar_news_item; |
8766
c86cfa3a7580
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8764
diff
changeset
|
56 |
bool _news_ticker_sound; |
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
57 |
static NewsItem *_news_items = NULL; ///< The news FIFO queue |
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
58 |
static uint _max_news_items = 0; ///< size of news FIFO queue |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
59 |
static NewsID _current_news = INVALID_NEWS; ///< points to news item that should be shown next |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
60 |
static NewsID _oldest_news = 0; ///< points to first item in fifo queue |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
61 |
static NewsID _latest_news = INVALID_NEWS; ///< points to last item in fifo queue |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
62 |
|
10218
aa6d38761cc4
(svn r12750) -Fix (r12749): viewport for industry new messages was not shown properly.
rubidium
parents:
10152
diff
changeset
|
63 |
struct news_d : vp_d { |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
64 |
uint16 follow_vehicle; |
10485
331014dcd0d3
(svn r13028) -Codechange: WE_MESSAGE and WE_INVALIDATE_DATA were doing the same thing.
rubidium
parents:
10478
diff
changeset
|
65 |
uint16 chat_height; |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
66 |
int32 scrollpos_x; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
67 |
int32 scrollpos_y; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
68 |
int32 dest_scrollpos_x; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
69 |
int32 dest_scrollpos_y; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
70 |
NewsItem *ni; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
71 |
}; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
72 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d)); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
73 |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
74 |
/** Forced news item. |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
75 |
* Users can force an item by accessing the history or "last message". |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
76 |
* If the message being shown was forced by the user, its index is stored in |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
77 |
* _forced_news. Otherwise, \a _forced_news variable is INVALID_NEWS. */ |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
78 |
static NewsID _forced_news = INVALID_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
79 |
|
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
80 |
static uint _total_news = 0; ///< Number of news items in FIFO queue @see _news_items |
0 | 81 |
|
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
82 |
void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
83 |
void DrawNewsBankrupcy(Window *w, const NewsItem *ni); |
6573 | 84 |
static void MoveToNextItem(); |
0 | 85 |
|
6535
1a5437f36d78
(svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents:
6523
diff
changeset
|
86 |
StringID GetNewsStringNewVehicleAvail(const NewsItem *ni); |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
87 |
StringID GetNewsStringBankrupcy(const NewsItem *ni); |
0 | 88 |
|
89 |
static DrawNewsCallbackProc * const _draw_news_callback[] = { |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
90 |
DrawNewsNewVehicleAvail, ///< DNC_VEHICLEAVAIL |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
91 |
DrawNewsBankrupcy, ///< DNC_BANKRUPCY |
0 | 92 |
}; |
93 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
94 |
extern GetNewsStringCallbackProc * const _get_news_string_callback[]; |
0 | 95 |
GetNewsStringCallbackProc * const _get_news_string_callback[] = { |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
96 |
GetNewsStringNewVehicleAvail, ///< DNC_VEHICLEAVAIL |
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
97 |
GetNewsStringBankrupcy, ///< DNC_BANKRUPCY |
0 | 98 |
}; |
99 |
||
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
100 |
/** Initialize the news-items data structures */ |
6573 | 101 |
void InitNewsItemStructs() |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
102 |
{ |
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
103 |
free(_news_items); |
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
104 |
_max_news_items = max(ScaleByMapSize(30), 30U); |
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
105 |
_news_items = CallocT<NewsItem>(_max_news_items); |
427 | 106 |
_current_news = INVALID_NEWS; |
89 | 107 |
_oldest_news = 0; |
427 | 108 |
_latest_news = INVALID_NEWS; |
109 |
_forced_news = INVALID_NEWS; |
|
89 | 110 |
_total_news = 0; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
111 |
} |
0 | 112 |
|
427 | 113 |
void DrawNewsBorder(const Window *w) |
0 | 114 |
{ |
115 |
int left = 0; |
|
116 |
int right = w->width - 1; |
|
117 |
int top = 0; |
|
118 |
int bottom = w->height - 1; |
|
119 |
||
120 |
GfxFillRect(left, top, right, bottom, 0xF); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
121 |
|
0 | 122 |
GfxFillRect(left, top, left, bottom, 0xD7); |
123 |
GfxFillRect(right, top, right, bottom, 0xD7); |
|
124 |
GfxFillRect(left, top, right, top, 0xD7); |
|
125 |
GfxFillRect(left, bottom, right, bottom, 0xD7); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
126 |
|
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8094
diff
changeset
|
127 |
DrawString(left + 2, top + 1, STR_00C6, TC_FROMSTRING); |
0 | 128 |
} |
129 |
||
130 |
static void NewsWindowProc(Window *w, WindowEvent *e) |
|
131 |
{ |
|
427 | 132 |
switch (e->event) { |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
133 |
case WE_CREATE: { // If chatbar is open at creation time, we need to go above it |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
134 |
const Window *w1 = FindWindowById(WC_SEND_NETWORK_MSG, 0); |
10485
331014dcd0d3
(svn r13028) -Codechange: WE_MESSAGE and WE_INVALIDATE_DATA were doing the same thing.
rubidium
parents:
10478
diff
changeset
|
135 |
WP(w, news_d).chat_height = (w1 != NULL) ? w1->height : 0; |
10410 | 136 |
break; |
137 |
} |
|
427 | 138 |
|
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
139 |
case WE_PAINT: { |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
140 |
const NewsItem *ni = WP(w, news_d).ni; |
427 | 141 |
|
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
142 |
switch (ni->display_mode) { |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
143 |
case NM_NORMAL: |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
144 |
case NM_THIN: { |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
145 |
DrawNewsBorder(w); |
427 | 146 |
|
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
147 |
DrawString(2, 1, STR_00C6, TC_FROMSTRING); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
148 |
|
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
149 |
SetDParam(0, ni->date); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
150 |
DrawStringRightAligned(428, 1, STR_01FF, TC_FROMSTRING); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
151 |
|
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
152 |
if (!(ni->flags & NF_VIEWPORT)) { |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
153 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
154 |
DrawStringMultiCenter(215, ni->display_mode == NM_NORMAL ? 76 : 56, |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
155 |
ni->string_id, w->width - 4); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
156 |
} else { |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
157 |
/* Back up transparency options to draw news view */ |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
158 |
TransparencyOptionBits to_backup = _transparency_opt; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
159 |
_transparency_opt = 0; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
160 |
DrawWindowViewport(w); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
161 |
_transparency_opt = to_backup; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
162 |
|
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
163 |
/* Shade the viewport into gray, or color*/ |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
164 |
ViewPort *vp = w->viewport; |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
165 |
GfxFillRect(vp->left - w->left, vp->top - w->top, |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
166 |
vp->left - w->left + vp->width - 1, vp->top - w->top + vp->height - 1, |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
167 |
(ni->flags & NF_INCOLOR ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY) | (1 << USE_COLORTABLE) |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
168 |
); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
169 |
|
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
170 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
171 |
DrawStringMultiCenter(w->width / 2, 20, ni->string_id, w->width - 4); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
172 |
} |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
173 |
break; |
427 | 174 |
} |
0 | 175 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
176 |
case NM_CALLBACK: |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
177 |
_draw_news_callback[ni->callback](w, ni); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
178 |
break; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
179 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
180 |
default: |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
181 |
DrawWindowWidgets(w); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
182 |
if (!(ni->flags & NF_VIEWPORT)) { |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
183 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
184 |
DrawStringMultiCenter(140, 38, ni->string_id, 276); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
185 |
} else { |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
186 |
DrawWindowViewport(w); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
187 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
188 |
DrawStringMultiCenter(w->width / 2, w->height - 16, ni->string_id, w->width - 4); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
189 |
} |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
190 |
break; |
0 | 191 |
} |
10410 | 192 |
break; |
193 |
} |
|
0 | 194 |
|
10410 | 195 |
case WE_CLICK: |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
196 |
switch (e->we.click.widget) { |
10410 | 197 |
case 1: { |
198 |
NewsItem *ni = WP(w, news_d).ni; |
|
10433
cca9f7948fe5
(svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents:
10429
diff
changeset
|
199 |
delete w; |
10410 | 200 |
ni->duration = 0; |
201 |
_forced_news = INVALID_NEWS; |
|
202 |
break; |
|
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
203 |
} |
10410 | 204 |
|
205 |
case 0: { |
|
206 |
NewsItem *ni = WP(w, news_d).ni; |
|
207 |
if (ni->flags & NF_VEHICLE) { |
|
208 |
Vehicle *v = GetVehicle(ni->data_a); |
|
209 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
|
210 |
} else if (ni->flags & NF_TILE) { |
|
10411
efe3b7a2746f
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
10410
diff
changeset
|
211 |
if (_ctrl_pressed) { |
efe3b7a2746f
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
10410
diff
changeset
|
212 |
ShowExtraViewPortWindow(ni->data_a); |
10478
f7761642d9b6
(svn r13021) -Codechange: free data_b for other uses when it is not used to store a second tile to skip to (in news messages). Patch by cirdan.
rubidium
parents:
10461
diff
changeset
|
213 |
if (ni->flags & NF_TILE2) { |
10411
efe3b7a2746f
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
10410
diff
changeset
|
214 |
ShowExtraViewPortWindow(ni->data_b); |
efe3b7a2746f
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
10410
diff
changeset
|
215 |
} |
efe3b7a2746f
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
10410
diff
changeset
|
216 |
} else { |
10478
f7761642d9b6
(svn r13021) -Codechange: free data_b for other uses when it is not used to store a second tile to skip to (in news messages). Patch by cirdan.
rubidium
parents:
10461
diff
changeset
|
217 |
if (!ScrollMainWindowToTile(ni->data_a) && ni->flags & NF_TILE2) { |
10411
efe3b7a2746f
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
10410
diff
changeset
|
218 |
ScrollMainWindowToTile(ni->data_b); |
efe3b7a2746f
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
10410
diff
changeset
|
219 |
} |
10410 | 220 |
} |
221 |
} |
|
222 |
break; |
|
223 |
} |
|
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
224 |
} |
10410 | 225 |
break; |
1648
747061dca705
(svn r2152) - Fix: Chatbar in MP games is now on-top of the news window.
darkvater
parents:
1390
diff
changeset
|
226 |
|
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
227 |
case WE_KEYPRESS: |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
228 |
if (e->we.keypress.keycode == WKC_SPACE) { |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
229 |
/* Don't continue. */ |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
230 |
e->we.keypress.cont = false; |
10433
cca9f7948fe5
(svn r12975) -Codechange: replace DeleteWindow(w) with delete w.
rubidium
parents:
10429
diff
changeset
|
231 |
delete w; |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
232 |
} |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
233 |
break; |
0 | 234 |
|
10485
331014dcd0d3
(svn r13028) -Codechange: WE_MESSAGE and WE_INVALIDATE_DATA were doing the same thing.
rubidium
parents:
10478
diff
changeset
|
235 |
case WE_INVALIDATE_DATA: // The chatbar has notified us that is was either created or closed |
331014dcd0d3
(svn r13028) -Codechange: WE_MESSAGE and WE_INVALIDATE_DATA were doing the same thing.
rubidium
parents:
10478
diff
changeset
|
236 |
WP(w, news_d).chat_height = e->we.invalidate.data; |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
237 |
break; |
0 | 238 |
|
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
239 |
case WE_TICK: { // Scroll up newsmessages from the bottom in steps of 4 pixels |
10485
331014dcd0d3
(svn r13028) -Codechange: WE_MESSAGE and WE_INVALIDATE_DATA were doing the same thing.
rubidium
parents:
10478
diff
changeset
|
240 |
int y = max(w->top - 4, _screen.height - w->height - 12 - WP(w, news_d).chat_height); |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
241 |
if (y == w->top) return; |
0 | 242 |
|
10410 | 243 |
if (w->viewport != NULL) { |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
244 |
w->viewport->top += y - w->top; |
10410 | 245 |
} |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
246 |
|
10410 | 247 |
int diff = Delta(w->top, y); |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
248 |
w->top = y; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
249 |
|
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
250 |
SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height); |
10410 | 251 |
break; |
252 |
} |
|
0 | 253 |
} |
254 |
} |
|
255 |
||
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
256 |
/** |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
257 |
* Return the correct index in the pseudo-fifo |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
258 |
* queue and deals with overflows when increasing the index |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
259 |
*/ |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
260 |
static inline NewsID IncreaseIndex(NewsID i) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
261 |
{ |
5258
eae66ac02803
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
262 |
assert(i != INVALID_NEWS); |
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
263 |
return (i + 1) % _max_news_items; |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
264 |
} |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
265 |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
266 |
/** |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
267 |
* Return the correct index in the pseudo-fifo |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
268 |
* queue and deals with overflows when decreasing the index |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
269 |
*/ |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
270 |
static inline NewsID DecreaseIndex(NewsID i) |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
271 |
{ |
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
272 |
assert(i != INVALID_NEWS); |
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
273 |
return (i + _max_news_items - 1) % _max_news_items; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
274 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
275 |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
276 |
/** |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
277 |
* Add a new newsitem to be shown. |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
278 |
* @param string String to display, can have special values based on parameter \a display_mode |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
279 |
* @param display_mode, any of the NewsMode enums (NM_) |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
280 |
* @param flags any of the NewsFlag enums (NF_) |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
281 |
* @param type news category, any of the NewsType enums (NT_) |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
282 |
* @param callback news callback function, any of the NewsCallback enums (DNC_) |
4873
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
283 |
* @param data_a news-specific value based on news type |
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
284 |
* @param data_b news-specific value based on news type |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
285 |
* |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
286 |
* @note If the display mode is NM_CALLBACK, special news is shown and parameter |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
287 |
* \a string has a special meaning. |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
288 |
* - For DNC_TRAINAVAIL, DNC_ROADAVAIL, DNC_SHIPAVAIL, DNC_AIRCRAFTAVAIL messages: StringID is |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
289 |
* the index of the engine that is shown |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
290 |
* |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
291 |
* - For DNC_BANKRUPCY: bytes 0-3 of StringID contains the player that is in trouble, |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
292 |
* and 4-7 contains what kind of bankrupcy message is shown. |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
293 |
* @see NewsBankrupcy |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
294 |
* |
4873
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
295 |
* @see NewsMode |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
296 |
* @see NewsFlag |
4873
7cb19235cf60
(svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents:
4719
diff
changeset
|
297 |
* @see NewsType |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
298 |
* @see NewsCallback |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
299 |
*/ |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
300 |
void AddNewsItem(StringID string, NewsMode display_mode, NewsFlag flags, NewsType type, NewsCallback callback, uint data_a, uint data_b) |
0 | 301 |
{ |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3155
diff
changeset
|
302 |
if (_game_mode == GM_MENU) return; |
0 | 303 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
304 |
/* check the rare case that the oldest (to be overwritten) news item is open */ |
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
305 |
if (_total_news == _max_news_items && (_oldest_news == _current_news || _oldest_news == _forced_news)) { |
5253
a9775de4e6b6
(svn r7383) -Codechange: fix up typo in news-gui s/MoveToNexItem/MoveToNextItem/.
Darkvater
parents:
5246
diff
changeset
|
306 |
MoveToNextItem(); |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
307 |
} |
102
1d277a07f1f1
(svn r103) Fix: rare newspaper crash with too many messages [ 1009976 ] (thx to blathij)s
dominik
parents:
94
diff
changeset
|
308 |
|
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
309 |
if (_total_news < _max_news_items) _total_news++; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
310 |
|
5258
eae66ac02803
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
311 |
/* Increase _latest_news. If we have no news yet, use _oldest news as an |
eae66ac02803
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
312 |
* index. We cannot use 0 as _oldest_news can jump around due to |
eae66ac02803
(svn r7388) -Fix (r7384 / r7368 / r3757): When adding a new news item for the first time (_latest_news
Darkvater
parents:
5254
diff
changeset
|
313 |
* DeleteVehicleNews */ |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
314 |
NewsID l_news = _latest_news; |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
315 |
_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
|
316 |
|
5244
e110f52333e8
(svn r7368) -Fix: [FS#332] Vehicle Deletion Crash [News Window Related?] (r3757).
Darkvater
parents:
5108
diff
changeset
|
317 |
/* If the fifo-buffer is full, overwrite the oldest entry */ |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
318 |
if (l_news != INVALID_NEWS && _latest_news == _oldest_news) { |
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
319 |
assert(_total_news == _max_news_items); |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
320 |
_oldest_news = IncreaseIndex(_oldest_news); |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
321 |
} |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
322 |
|
5846
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
323 |
/*DEBUG(misc, 0, "+cur %3d, old %2d, lat %3d, for %3d, tot %2d", |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
324 |
_current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/ |
5771
7288d4e4bfba
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5726
diff
changeset
|
325 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
326 |
/* Add news to _latest_news */ |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
327 |
NewsItem *ni = &_news_items[_latest_news]; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
328 |
memset(ni, 0, sizeof(*ni)); |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
329 |
|
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
330 |
ni->string_id = string; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
331 |
ni->display_mode = display_mode; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
332 |
ni->flags = flags; |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
333 |
|
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
334 |
/* show this news message in color? */ |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
335 |
if (_cur_year >= _patches.colored_news_year) ni->flags |= NF_INCOLOR; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
336 |
|
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
337 |
ni->type = type; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
338 |
ni->callback = callback; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
339 |
ni->data_a = data_a; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
340 |
ni->data_b = data_b; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
341 |
ni->date = _date; |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
342 |
CopyOutDParam(ni->params, 0, lengthof(ni->params)); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
343 |
|
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
344 |
Window *w = FindWindowById(WC_MESSAGE_HISTORY, 0); |
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
345 |
if (w == NULL) return; |
10434
d6accd017341
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
10433
diff
changeset
|
346 |
w->SetDirty(); |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8839
diff
changeset
|
347 |
w->vscroll.count = _total_news; |
0 | 348 |
} |
349 |
||
715
83805642c830
(svn r1167) Feature: Added the possibility to add validation functions to NewsItems. This is now done for "Train in depot" messages. Before displaying such a message, it checks if the train really still is in the depot. Can be applied to other news items as well.
dominik
parents:
541
diff
changeset
|
350 |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
351 |
/** |
10253
1627c1fef7c8
(svn r12785) -Codechange: put all news-type related constants in the same array. Patch by cirdan.
rubidium
parents:
10230
diff
changeset
|
352 |
* Per-NewsType data |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
353 |
*/ |
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
354 |
NewsTypeData _news_type_data[NT_END] = { |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
355 |
/* name, age, sound, display */ |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
356 |
{ "arrival_player", 60, SND_1D_APPLAUSE, ND_FULL }, ///< NT_ARRIVAL_PLAYER |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
357 |
{ "arrival_other", 60, SND_1D_APPLAUSE, ND_FULL }, ///< NT_ARRIVAL_OTHER |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
358 |
{ "accident", 90, SND_BEGIN, ND_FULL }, ///< NT_ACCIDENT |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
359 |
{ "company_info", 60, SND_BEGIN, ND_FULL }, ///< NT_COMPANY_INFO |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
360 |
{ "openclose", 90, SND_BEGIN, ND_FULL }, ///< NT_OPENCLOSE |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
361 |
{ "economy", 30, SND_BEGIN, ND_FULL }, ///< NT_ECONOMY |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
362 |
{ "production_player", 30, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_PLAYER |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
363 |
{ "production_other", 30, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_OTHER |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
364 |
{ "production_nobody", 30, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_NOBODY |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
365 |
{ "advice", 150, SND_BEGIN, ND_FULL }, ///< NT_ADVICE |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
366 |
{ "new_vehicles", 30, SND_1E_OOOOH, ND_FULL }, ///< NT_NEW_VEHICLES |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
367 |
{ "acceptance", 90, SND_BEGIN, ND_FULL }, ///< NT_ACCEPTANCE |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
368 |
{ "subsidies", 180, SND_BEGIN, ND_FULL }, ///< NT_SUBSIDIES |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
369 |
{ "general", 60, SND_BEGIN, ND_FULL }, ///< NT_GENERAL |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
370 |
}; |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
371 |
|
0 | 372 |
|
373 |
static const Widget _news_type13_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
374 |
{ WWT_PANEL, RESIZE_NONE, 15, 0, 429, 0, 169, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
375 |
{ 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
|
376 |
{ WIDGETS_END}, |
0 | 377 |
}; |
378 |
||
379 |
static WindowDesc _news_type13_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
380 |
WDP_CENTER, 476, 430, 170, 430, 170, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6090
diff
changeset
|
381 |
WC_NEWS_WINDOW, WC_NONE, |
0 | 382 |
WDF_DEF_WIDGET, |
383 |
_news_type13_widgets, |
|
384 |
NewsWindowProc |
|
385 |
}; |
|
386 |
||
387 |
static const Widget _news_type2_widgets[] = { |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
388 |
{ WWT_PANEL, RESIZE_NONE, 15, 0, 429, 0, 129, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
745
diff
changeset
|
389 |
{ 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
|
390 |
{ WIDGETS_END}, |
0 | 391 |
}; |
392 |
||
393 |
static WindowDesc _news_type2_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
394 |
WDP_CENTER, 476, 430, 130, 430, 130, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6090
diff
changeset
|
395 |
WC_NEWS_WINDOW, WC_NONE, |
0 | 396 |
WDF_DEF_WIDGET, |
397 |
_news_type2_widgets, |
|
398 |
NewsWindowProc |
|
399 |
}; |
|
400 |
||
401 |
static const Widget _news_type0_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
402 |
{ WWT_PANEL, RESIZE_NONE, 5, 0, 279, 14, 86, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
403 |
{ WWT_CLOSEBOX, RESIZE_NONE, 5, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
404 |
{ WWT_CAPTION, RESIZE_NONE, 5, 11, 279, 0, 13, STR_012C_MESSAGE, STR_NULL}, |
4939
ede0f6777b3c
(svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents:
4938
diff
changeset
|
405 |
{ 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
|
406 |
{ WIDGETS_END}, |
0 | 407 |
}; |
408 |
||
409 |
static WindowDesc _news_type0_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
410 |
WDP_CENTER, 476, 280, 87, 280, 87, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6090
diff
changeset
|
411 |
WC_NEWS_WINDOW, WC_NONE, |
0 | 412 |
WDF_DEF_WIDGET, |
413 |
_news_type0_widgets, |
|
414 |
NewsWindowProc |
|
415 |
}; |
|
416 |
||
417 |
||
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
418 |
/** 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
|
419 |
static void ShowNewspaper(NewsItem *ni) |
0 | 420 |
{ |
4874
b95cdd66085f
(svn r6804) -Codechange: Remove the unused NF_NOEXPIRE flag.
Darkvater
parents:
4873
diff
changeset
|
421 |
ni->flags &= ~NF_FORCE_BIG; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
422 |
ni->duration = 555; |
0 | 423 |
|
10253
1627c1fef7c8
(svn r12785) -Codechange: put all news-type related constants in the same array. Patch by cirdan.
rubidium
parents:
10230
diff
changeset
|
424 |
SoundFx sound = _news_type_data[ni->type].sound; |
2639 | 425 |
if (sound != 0) SndPlayFx(sound); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
426 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
427 |
int top = _screen.height; |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
428 |
Window *w; |
427 | 429 |
switch (ni->display_mode) { |
430 |
case NM_NORMAL: |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
431 |
case NM_CALLBACK: |
427 | 432 |
_news_type13_desc.top = top; |
10461
48556aee54da
(svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents:
10434
diff
changeset
|
433 |
w = new Window(&_news_type13_desc); |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
434 |
if (ni->flags & NF_VIEWPORT) { |
10257
fe75471234f3
(svn r12789) -Codechange: rename AssignWindowViewport to InitializeWindowViewport because the viewport is now part of the window struct. Patch by Alberth.
rubidium
parents:
10253
diff
changeset
|
435 |
InitializeWindowViewport(w, 2, 58, 426, 110, |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7038
diff
changeset
|
436 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS); |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
437 |
} |
427 | 438 |
break; |
439 |
||
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
440 |
case NM_THIN: |
427 | 441 |
_news_type2_desc.top = top; |
10461
48556aee54da
(svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents:
10434
diff
changeset
|
442 |
w = new Window(&_news_type2_desc); |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
443 |
if (ni->flags & NF_VIEWPORT) { |
10257
fe75471234f3
(svn r12789) -Codechange: rename AssignWindowViewport to InitializeWindowViewport because the viewport is now part of the window struct. Patch by Alberth.
rubidium
parents:
10253
diff
changeset
|
444 |
InitializeWindowViewport(w, 2, 58, 426, 70, |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7038
diff
changeset
|
445 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS); |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
446 |
} |
427 | 447 |
break; |
448 |
||
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
449 |
default: |
427 | 450 |
_news_type0_desc.top = top; |
10461
48556aee54da
(svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents:
10434
diff
changeset
|
451 |
w = new Window(&_news_type0_desc); |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
452 |
if (ni->flags & NF_VIEWPORT) { |
10257
fe75471234f3
(svn r12789) -Codechange: rename AssignWindowViewport to InitializeWindowViewport because the viewport is now part of the window struct. Patch by Alberth.
rubidium
parents:
10253
diff
changeset
|
453 |
InitializeWindowViewport(w, 3, 17, 274, 47, |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7038
diff
changeset
|
454 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS); |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
455 |
} |
427 | 456 |
break; |
0 | 457 |
} |
5771
7288d4e4bfba
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5726
diff
changeset
|
458 |
|
5846
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
459 |
/*DEBUG(misc, 0, " cur %3d, old %2d, lat %3d, for %3d, tot %2d", |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
460 |
_current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/ |
5771
7288d4e4bfba
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5726
diff
changeset
|
461 |
|
427 | 462 |
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
|
463 |
w->flags4 |= WF_DISABLE_VP_SCROLL; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
464 |
} |
0 | 465 |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
466 |
/** Show news item in the ticker */ |
427 | 467 |
static void ShowTicker(const NewsItem *ni) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
468 |
{ |
1688
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
469 |
if (_news_ticker_sound) SndPlayFx(SND_16_MORSE); |
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
470 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
471 |
_statusbar_news_item = *ni; |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
472 |
Window *w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 473 |
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
|
474 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
475 |
|
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
476 |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
477 |
/** |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
478 |
* Are we ready to show another news item? |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
479 |
* Only if nothing is in the newsticker and no newspaper is displayed |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
480 |
*/ |
6573 | 481 |
static bool ReadyForNextItem() |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
482 |
{ |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
483 |
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
|
484 |
|
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
485 |
if (item >= _max_news_items) return true; |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
486 |
NewsItem *ni = &_news_items[item]; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
487 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
488 |
/* Ticker message |
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
489 |
* Check if the status bar message is still being displayed? */ |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
490 |
const Window *w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 491 |
if (w != NULL && WP(w, const def_d).data_1 > -1280) return false; |
0 | 492 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
493 |
/* Newspaper message, decrement duration counter */ |
5264
b2b3c60af210
(svn r7402) -Fix: [FS#255] Long Delay for Message Windows to Appear. Immediately show a new message
Darkvater
parents:
5258
diff
changeset
|
494 |
if (ni->duration != 0) ni->duration--; |
0 | 495 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
496 |
/* neither newsticker nor newspaper are running */ |
5264
b2b3c60af210
(svn r7402) -Fix: [FS#255] Long Delay for Message Windows to Appear. Immediately show a new message
Darkvater
parents:
5258
diff
changeset
|
497 |
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
|
498 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
499 |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
500 |
/** Move to the next news item */ |
6573 | 501 |
static void MoveToNextItem() |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
502 |
{ |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
503 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
427 | 504 |
_forced_news = INVALID_NEWS; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
505 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
506 |
/* if we're not at the last item, then move on */ |
427 | 507 |
if (_current_news != _latest_news) { |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
508 |
_current_news = (_current_news == INVALID_NEWS) ? _oldest_news : IncreaseIndex(_current_news); |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
509 |
NewsItem *ni = &_news_items[_current_news]; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
510 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
511 |
/* check the date, don't show too old items */ |
10253
1627c1fef7c8
(svn r12785) -Codechange: put all news-type related constants in the same array. Patch by cirdan.
rubidium
parents:
10230
diff
changeset
|
512 |
if (_date - _news_type_data[ni->type].age > ni->date) return; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
513 |
|
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
514 |
switch (_news_type_data[ni->type].display) { |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
515 |
default: NOT_REACHED(); |
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
516 |
case ND_OFF: { // Off - show nothing only a small reminder in the status bar |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
517 |
Window *w = FindWindowById(WC_STATUS_BAR, 0); |
2639 | 518 |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
519 |
if (w != NULL) { |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
520 |
WP(w, def_d).data_2 = 91; |
10434
d6accd017341
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
10433
diff
changeset
|
521 |
w->SetDirty(); |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
522 |
} |
2639 | 523 |
break; |
524 |
} |
|
525 |
||
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
526 |
case ND_SUMMARY: // Summary - show ticker, but if forced big, cascade to full |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
527 |
if (!(ni->flags & NF_FORCE_BIG)) { |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
528 |
ShowTicker(ni); |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
529 |
break; |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
530 |
} |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
531 |
/* Fallthrough */ |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
532 |
|
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
533 |
case ND_FULL: // Full - show newspaper |
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
534 |
ShowNewspaper(ni); |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
535 |
break; |
2639 | 536 |
} |
0 | 537 |
} |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
538 |
} |
0 | 539 |
|
6573 | 540 |
void NewsLoop() |
0 | 541 |
{ |
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
542 |
/* no news item yet */ |
427 | 543 |
if (_total_news == 0) return; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
544 |
|
5253
a9775de4e6b6
(svn r7383) -Codechange: fix up typo in news-gui s/MoveToNexItem/MoveToNextItem/.
Darkvater
parents:
5246
diff
changeset
|
545 |
if (ReadyForNextItem()) 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 |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
548 |
/** Do a forced show of a specific message */ |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
549 |
static void ShowNewsMessage(NewsID i) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
550 |
{ |
427 | 551 |
if (_total_news == 0) return; |
89 | 552 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
553 |
/* Delete the news window */ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
554 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
555 |
|
6674
64f4781b4653
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6628
diff
changeset
|
556 |
/* setup forced news item */ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
557 |
_forced_news = i; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
558 |
|
427 | 559 |
if (_forced_news != INVALID_NEWS) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
560 |
NewsItem *ni = &_news_items[_forced_news]; |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
561 |
ni->duration = 555; |
4874
b95cdd66085f
(svn r6804) -Codechange: Remove the unused NF_NOEXPIRE flag.
Darkvater
parents:
4873
diff
changeset
|
562 |
ni->flags |= NF_FORCE_BIG; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
563 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
564 |
ShowNewspaper(ni); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
565 |
} |
0 | 566 |
} |
567 |
||
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
568 |
/** Show previous news item */ |
6573 | 569 |
void ShowLastNewsMessage() |
0 | 570 |
{ |
5846
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
571 |
if (_forced_news == INVALID_NEWS) { |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
572 |
/* Not forced any news yet, show the current one, unless a news window is |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
573 |
* open (which can only be the current one), then show the previous item */ |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
574 |
const Window *w = FindWindowById(WC_NEWS_WINDOW, 0); |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
575 |
ShowNewsMessage((w == NULL || (_current_news == _oldest_news)) ? _current_news : DecreaseIndex(_current_news)); |
5846
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
576 |
} else if (_forced_news == _oldest_news) { |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
577 |
/* We have reached the oldest news, start anew with the latest */ |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
578 |
ShowNewsMessage(_latest_news); |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
579 |
} else { |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
580 |
/* 'Scrolling' through news history show each one in turn */ |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
581 |
ShowNewsMessage(DecreaseIndex(_forced_news)); |
83
bd21afea96d8
(svn r84) Improved news system code a little to avoid potential memory leaks
dominik
parents:
80
diff
changeset
|
582 |
} |
0 | 583 |
} |
584 |
||
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
585 |
|
89 | 586 |
/* return news by number, with 0 being the most |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4345
diff
changeset
|
587 |
* recent news. Returns INVALID_NEWS if end of queue reached. */ |
5246
29224c621fd6
(svn r7370) -Cleanup: Use NewsID instead of byte for news identifiers, and some minor other things
Darkvater
parents:
5245
diff
changeset
|
588 |
static NewsID getNews(NewsID i) |
89 | 589 |
{ |
2639 | 590 |
if (i >= _total_news) return INVALID_NEWS; |
89 | 591 |
|
2639 | 592 |
if (_latest_news < i) { |
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
593 |
i = _latest_news + _max_news_items - i; |
2639 | 594 |
} else { |
89 | 595 |
i = _latest_news - i; |
2639 | 596 |
} |
89 | 597 |
|
10301
bae9252dd4c6
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
10273
diff
changeset
|
598 |
i %= _max_news_items; |
89 | 599 |
return i; |
600 |
} |
|
601 |
||
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
602 |
/** |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
603 |
* Draw an unformatted news message truncated to a maximum length. If |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
604 |
* length exceeds maximum length it will be postfixed by '...' |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
605 |
* @param x,y position of the string |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
606 |
* @param color the color the string will be shown in |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
607 |
* @param *ni NewsItem being printed |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
608 |
* @param maxw maximum width of string in pixels |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
609 |
*/ |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
610 |
static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint maxw) |
89 | 611 |
{ |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
612 |
char buffer[512], buffer2[512]; |
89 | 613 |
StringID str; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
614 |
|
8350
4cdf7891188e
(svn r11404) -Codechange: remove 2 magical numbers
belugas
parents:
8345
diff
changeset
|
615 |
if (ni->display_mode == NM_CALLBACK) { |
89 | 616 |
str = _get_news_string_callback[ni->callback](ni); |
617 |
} else { |
|
7762
03721db0ac1c
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7120
diff
changeset
|
618 |
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
|
619 |
str = ni->string_id; |
89 | 620 |
} |
621 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4874
diff
changeset
|
622 |
GetString(buffer, str, lastof(buffer)); |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
623 |
/* Copy the just gotten string to another buffer to remove any formatting |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
624 |
* from it such as big fonts, etc. */ |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
625 |
const char *ptr = buffer; |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
626 |
char *dest = buffer2; |
7038
60b0e082723c
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6977
diff
changeset
|
627 |
WChar c_last = '\0'; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
628 |
for (;;) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
629 |
WChar c = Utf8Consume(&ptr); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
630 |
if (c == 0) break; |
7038
60b0e082723c
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6977
diff
changeset
|
631 |
/* Make a space from a newline, but ignore multiple newlines */ |
60b0e082723c
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6977
diff
changeset
|
632 |
if (c == '\n' && c_last != '\n') { |
60b0e082723c
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6977
diff
changeset
|
633 |
dest[0] = ' '; |
60b0e082723c
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6977
diff
changeset
|
634 |
dest++; |
60b0e082723c
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6977
diff
changeset
|
635 |
} else if (c == '\r') { |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
636 |
dest[0] = dest[1] = dest[2] = dest[3] = ' '; |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
637 |
dest += 4; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
638 |
} else if (IsPrintable(c)) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
639 |
dest += Utf8Encode(dest, c); |
89 | 640 |
} |
7038
60b0e082723c
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6977
diff
changeset
|
641 |
c_last = c; |
89 | 642 |
} |
2101
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
643 |
|
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
644 |
*dest = '\0'; |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
645 |
/* Truncate and show string; postfixed by '...' if neccessary */ |
763d0d48f39c
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
646 |
DoDrawStringTruncated(buffer2, x, y, color, maxw); |
89 | 647 |
} |
648 |
||
649 |
||
650 |
static void MessageHistoryWndProc(Window *w, WindowEvent *e) |
|
651 |
{ |
|
427 | 652 |
switch (e->event) { |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
653 |
case WE_PAINT: { |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
654 |
int y = 19; |
89 | 655 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
656 |
SetVScrollCount(w, _total_news); |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
657 |
DrawWindowWidgets(w); |
89 | 658 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
659 |
if (_total_news == 0) break; |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
660 |
NewsID show = min(_total_news, w->vscroll.cap); |
89 | 661 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
662 |
for (NewsID p = w->vscroll.pos; p < w->vscroll.pos + show; p++) { |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
663 |
/* get news in correct order */ |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
664 |
const NewsItem *ni = &_news_items[getNews(p)]; |
89 | 665 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
666 |
SetDParam(0, ni->date); |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
667 |
DrawString(4, y, STR_SHORT_DATE, TC_WHITE); |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
668 |
|
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
669 |
DrawNewsString(82, y, TC_WHITE, ni, w->width - 95); |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
670 |
y += 12; |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
671 |
} |
89 | 672 |
break; |
673 |
} |
|
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
674 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
675 |
case WE_CLICK: |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
676 |
if (e->we.click.widget == 3) { |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
677 |
int y = (e->we.click.pt.y - 19) / 12; |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
678 |
NewsID p = getNews(y + w->vscroll.pos); |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
679 |
|
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
680 |
if (p != INVALID_NEWS) ShowNewsMessage(p); |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
681 |
} |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
682 |
break; |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
683 |
|
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
684 |
case WE_RESIZE: |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
685 |
w->vscroll.cap += e->we.sizing.diff.y / 12; |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
686 |
break; |
89 | 687 |
} |
688 |
} |
|
689 |
||
690 |
static const Widget _message_history_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
691 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
692 |
{ WWT_CAPTION, RESIZE_RIGHT, 13, 11, 387, 0, 13, STR_MESSAGE_HISTORY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
693 |
{ WWT_STICKYBOX, RESIZE_LR, 13, 388, 399, 0, 13, 0x0, STR_STICKY_BUTTON}, |
4938
074f734a91ca
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
694 |
{ WWT_PANEL, RESIZE_RB, 13, 0, 387, 14, 139, 0x0, STR_MESSAGE_HISTORY_TIP}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
695 |
{ WWT_SCROLLBAR, RESIZE_LRB, 13, 388, 399, 14, 127, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
696 |
{ 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
|
697 |
{ WIDGETS_END}, |
89 | 698 |
}; |
699 |
||
700 |
static const WindowDesc _message_history_desc = { |
|
7837
65d7362153a6
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7762
diff
changeset
|
701 |
240, 22, 400, 140, 400, 140, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6090
diff
changeset
|
702 |
WC_MESSAGE_HISTORY, WC_NONE, |
1097
653c846fb5d9
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
703 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
89 | 704 |
_message_history_widgets, |
705 |
MessageHistoryWndProc |
|
706 |
}; |
|
707 |
||
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
708 |
/** Display window with news messages history */ |
6573 | 709 |
void ShowMessageHistory() |
89 | 710 |
{ |
711 |
DeleteWindowById(WC_MESSAGE_HISTORY, 0); |
|
10461
48556aee54da
(svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents:
10434
diff
changeset
|
712 |
Window *w = new Window(&_message_history_desc); |
89 | 713 |
|
10410 | 714 |
if (w == NULL) return; |
715 |
||
716 |
w->vscroll.cap = 10; |
|
717 |
w->vscroll.count = _total_news; |
|
718 |
w->resize.step_height = 12; |
|
719 |
w->resize.height = w->height - 12 * 6; // minimum of 4 items in the list, each item 12 high |
|
720 |
w->resize.step_width = 1; |
|
721 |
w->resize.width = 200; // can't make window any smaller than 200 pixel |
|
10434
d6accd017341
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
10433
diff
changeset
|
722 |
w->SetDirty(); |
89 | 723 |
} |
724 |
||
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
725 |
|
8387
30f519812d62
(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:
8350
diff
changeset
|
726 |
/** News settings window widget offset constants */ |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
727 |
enum { |
8839
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
728 |
WIDGET_NEWSOPT_DROP_SUMMARY = 4, ///< Dropdown that adjusts at once the level for all settings |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
729 |
WIDGET_NEWSOPT_SOUNDTICKER = 6, ///< Button activating sound on events |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
730 |
WIDGET_NEWSOPT_START_OPTION = 8, ///< First widget that is part of a group [<] .. [.] |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
731 |
}; |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
732 |
|
8094
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
733 |
/** |
58a8fe00746a
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7837
diff
changeset
|
734 |
* Setup the disabled/enabled buttons in the message window |
1688
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
735 |
* If the value is 'off' disable the [<] widget, and enable the [>] one |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
736 |
* Same-wise for all the others. Starting value of 4 is the first widget |
1688
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
737 |
* group. These are grouped as [<][>] .. [<][>], etc. |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
738 |
* @param w Window been used |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
739 |
* @param value to set in the widget |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
740 |
* @param element index of the group of widget to set |
1688
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
741 |
*/ |
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
742 |
static void SetMessageButtonStates(Window *w, byte value, int element) |
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
743 |
{ |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
744 |
element *= NB_WIDG_PER_SETTING; |
4709
eff35edfb653
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4634
diff
changeset
|
745 |
|
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8466
diff
changeset
|
746 |
w->SetWidgetDisabledState(element + WIDGET_NEWSOPT_START_OPTION, value == 0); |
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8466
diff
changeset
|
747 |
w->SetWidgetDisabledState(element + WIDGET_NEWSOPT_START_OPTION + 2, value == 2); |
1688
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
748 |
} |
0 | 749 |
|
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
750 |
/** |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
751 |
* Event handler of the Message Options window |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
752 |
* @param w window pointer |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
753 |
* @param e event been triggered |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
754 |
*/ |
0 | 755 |
static void MessageOptionsWndProc(Window *w, WindowEvent *e) |
756 |
{ |
|
1688
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
757 |
static const StringID message_opt[] = {STR_OFF, STR_SUMMARY, STR_FULL, INVALID_STRING_ID}; |
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
758 |
|
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
759 |
/* WP(w, def_d).data_1 stores state of the ALL on/off/summary button */ |
427 | 760 |
switch (e->event) { |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
761 |
case WE_CREATE: { |
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
762 |
NewsDisplay all_val; |
0 | 763 |
|
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
764 |
/* Set up the initial disabled buttons in the case of 'off' or 'full' */ |
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
765 |
all_val = _news_type_data[0].display; |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
766 |
for (int i = 0; i < NT_END; i++) { |
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
767 |
SetMessageButtonStates(w, _news_type_data[i].display, i); |
6628
2b97a7deed52
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6609
diff
changeset
|
768 |
/* If the value doesn't match the ALL-button value, set the ALL-button value to 'off' */ |
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
769 |
if (_news_type_data[i].display != all_val) all_val = ND_OFF; |
6628
2b97a7deed52
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6609
diff
changeset
|
770 |
} |
2b97a7deed52
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6609
diff
changeset
|
771 |
/* If all values are the same value, the ALL-button will take over this value */ |
2b97a7deed52
(svn r9137) -Fix: if all news-setting buttons show 'full', make the ALL-button show 'full' too
truelight
parents:
6609
diff
changeset
|
772 |
WP(w, def_d).data_1 = all_val; |
10410 | 773 |
break; |
774 |
} |
|
1688
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
775 |
|
10410 | 776 |
case WE_PAINT: |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8466
diff
changeset
|
777 |
if (_news_ticker_sound) w->LowerWidget(WIDGET_NEWSOPT_SOUNDTICKER); |
8839
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
778 |
|
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
779 |
w->widget[WIDGET_NEWSOPT_DROP_SUMMARY].data = message_opt[WP(w, def_d).data_1]; |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
780 |
DrawWindowWidgets(w); |
1688
787400219027
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
781 |
|
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
782 |
/* Draw the string of each setting on each button. */ |
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
783 |
for (int i = 0, y = 26; i < NT_END; i++, y += 12) { |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
784 |
/* 51 comes from 13 + 89 (left and right of the button)+1, shiefted by one as to get division, |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
785 |
* which will give centered position */ |
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
786 |
DrawStringCentered(51, y + 1, message_opt[_news_type_data[i].display], TC_BLACK); |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
787 |
} |
10410 | 788 |
break; |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
789 |
|
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
790 |
case WE_CLICK: |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
791 |
switch (e->we.click.widget) { |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
792 |
case WIDGET_NEWSOPT_DROP_SUMMARY: // Dropdown menu for all settings |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
793 |
ShowDropDownMenu(w, message_opt, WP(w, def_d).data_1, WIDGET_NEWSOPT_DROP_SUMMARY, 0, 0); |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
794 |
break; |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
795 |
|
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
796 |
case WIDGET_NEWSOPT_SOUNDTICKER: // Change ticker sound on/off |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
797 |
_news_ticker_sound ^= 1; |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8466
diff
changeset
|
798 |
w->ToggleWidgetLoweredState(e->we.click.widget); |
8524
baf4ab1ba18d
(svn r11588) -Codechange: use the new member introduced in r11551
glx
parents:
8493
diff
changeset
|
799 |
w->InvalidateWidget(e->we.click.widget); |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
800 |
break; |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
801 |
|
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
802 |
default: { // Clicked on the [<] .. [>] widgets |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
803 |
int wid = e->we.click.widget - WIDGET_NEWSOPT_START_OPTION; |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
804 |
if (wid >= 0 && wid < (NB_WIDG_PER_SETTING * NT_END)) { |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
805 |
int element = wid / NB_WIDG_PER_SETTING; |
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
806 |
byte val = (_news_type_data[element].display + ((wid % NB_WIDG_PER_SETTING) ? 1 : -1)) % 3; |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
807 |
|
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
808 |
SetMessageButtonStates(w, val, element); |
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
809 |
_news_type_data[element].display = (NewsDisplay)val; |
10434
d6accd017341
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
10433
diff
changeset
|
810 |
w->SetDirty(); |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
811 |
} |
10410 | 812 |
break; |
813 |
} |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
814 |
} |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
815 |
break; |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
816 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
817 |
case WE_DROPDOWN_SELECT: // Select all settings for newsmessages |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
818 |
WP(w, def_d).data_1 = e->we.dropdown.index; |
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
819 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
820 |
for (int i = 0; i < NT_END; i++) { |
6609
7c466c7c850a
(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:
6605
diff
changeset
|
821 |
SetMessageButtonStates(w, e->we.dropdown.index, i); |
10273
248661824a1e
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
10257
diff
changeset
|
822 |
_news_type_data[i].display = (NewsDisplay)e->we.dropdown.index; |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
823 |
} |
10434
d6accd017341
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
10433
diff
changeset
|
824 |
w->SetDirty(); |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
825 |
break; |
0 | 826 |
} |
827 |
} |
|
828 |
||
8387
30f519812d62
(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:
8350
diff
changeset
|
829 |
|
30f519812d62
(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:
8350
diff
changeset
|
830 |
/* |
30f519812d62
(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:
8350
diff
changeset
|
831 |
* The news settings window widgets |
30f519812d62
(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:
8350
diff
changeset
|
832 |
* |
30f519812d62
(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:
8350
diff
changeset
|
833 |
* Main part of the window is a list of news-setting lines, one for each news category. |
30f519812d62
(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:
8350
diff
changeset
|
834 |
* Each line is constructed by an expansion of the \c NEWS_SETTINGS_LINE macro |
30f519812d62
(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:
8350
diff
changeset
|
835 |
*/ |
30f519812d62
(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:
8350
diff
changeset
|
836 |
|
30f519812d62
(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:
8350
diff
changeset
|
837 |
/** |
30f519812d62
(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:
8350
diff
changeset
|
838 |
* Macro to construct one news-setting line in the news-settings window. |
30f519812d62
(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:
8350
diff
changeset
|
839 |
* One line consists of four widgets, namely |
30f519812d62
(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:
8350
diff
changeset
|
840 |
* - A [<] button |
30f519812d62
(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:
8350
diff
changeset
|
841 |
* - A [...] label |
30f519812d62
(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:
8350
diff
changeset
|
842 |
* - A [>] button |
30f519812d62
(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:
8350
diff
changeset
|
843 |
* - A text label describing the news category |
30f519812d62
(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:
8350
diff
changeset
|
844 |
* Horizontal positions of the widgets are hard-coded, vertical start position is (\a basey + \a linenum * \c NEWS_SETTING_BASELINE_SKIP). |
30f519812d62
(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:
8350
diff
changeset
|
845 |
* Height of one line is 12, with the text label shifted 1 pixel down. |
30f519812d62
(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:
8350
diff
changeset
|
846 |
* |
30f519812d62
(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:
8350
diff
changeset
|
847 |
* First line should be widget number WIDGET_NEWSOPT_START_OPTION |
30f519812d62
(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:
8350
diff
changeset
|
848 |
* |
30f519812d62
(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:
8350
diff
changeset
|
849 |
* @param basey: Base Y coordinate |
30f519812d62
(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:
8350
diff
changeset
|
850 |
* @param linenum: Count, news-setting is the \a linenum-th line |
30f519812d62
(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:
8350
diff
changeset
|
851 |
* @param text: StringID for the text label to display |
30f519812d62
(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:
8350
diff
changeset
|
852 |
*/ |
30f519812d62
(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:
8350
diff
changeset
|
853 |
#define NEWS_SETTINGS_LINE(basey, linenum, text) \ |
30f519812d62
(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:
8350
diff
changeset
|
854 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_YELLOW, \ |
30f519812d62
(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:
8350
diff
changeset
|
855 |
4, 12, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
30f519812d62
(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:
8350
diff
changeset
|
856 |
SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, \ |
30f519812d62
(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:
8350
diff
changeset
|
857 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, \ |
30f519812d62
(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:
8350
diff
changeset
|
858 |
13, 89, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
30f519812d62
(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:
8350
diff
changeset
|
859 |
STR_EMPTY, STR_NULL}, \ |
30f519812d62
(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:
8350
diff
changeset
|
860 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_YELLOW, \ |
30f519812d62
(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:
8350
diff
changeset
|
861 |
90, 98, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
30f519812d62
(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:
8350
diff
changeset
|
862 |
SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, \ |
30f519812d62
(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:
8350
diff
changeset
|
863 |
{ WWT_TEXT, RESIZE_NONE, COLOUR_YELLOW, \ |
30f519812d62
(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:
8350
diff
changeset
|
864 |
103, 409, basey + 1 + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 13 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
30f519812d62
(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:
8350
diff
changeset
|
865 |
text, STR_NULL} |
30f519812d62
(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:
8350
diff
changeset
|
866 |
|
30f519812d62
(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:
8350
diff
changeset
|
867 |
static const int NEWS_SETTING_BASELINE_SKIP = 12; ///< Distance between two news-setting lines, should be at least 12 |
30f519812d62
(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:
8350
diff
changeset
|
868 |
|
30f519812d62
(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:
8350
diff
changeset
|
869 |
|
0 | 870 |
static const Widget _message_options_widgets[] = { |
8387
30f519812d62
(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:
8350
diff
changeset
|
871 |
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_BROWN, 0, 10, 0, 13, |
30f519812d62
(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:
8350
diff
changeset
|
872 |
STR_00C5, STR_018B_CLOSE_WINDOW}, |
30f519812d62
(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:
8350
diff
changeset
|
873 |
{ WWT_CAPTION, RESIZE_NONE, COLOUR_BROWN, 11, 409, 0, 13, |
30f519812d62
(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:
8350
diff
changeset
|
874 |
STR_0204_MESSAGE_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
30f519812d62
(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:
8350
diff
changeset
|
875 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_BROWN, 0, 409, 14, 64 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
30f519812d62
(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:
8350
diff
changeset
|
876 |
0x0, STR_NULL}, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
877 |
|
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
878 |
/* Text at the top of the main panel, in black */ |
8387
30f519812d62
(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:
8350
diff
changeset
|
879 |
{ WWT_LABEL, RESIZE_NONE, COLOUR_BROWN, |
30f519812d62
(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:
8350
diff
changeset
|
880 |
0, 409, 13, 26, |
30f519812d62
(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:
8350
diff
changeset
|
881 |
STR_0205_MESSAGE_TYPES, STR_NULL}, |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
882 |
|
8387
30f519812d62
(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:
8350
diff
changeset
|
883 |
/* General drop down and sound button, widgets WIDGET_NEWSOPT_BTN_SUMMARY and WIDGET_NEWSOPT_DROP_SUMMARY */ |
8839
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
884 |
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_YELLOW, |
bd8a5bb77cd7
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8780
diff
changeset
|
885 |
4, 98, 34 + NT_END * NEWS_SETTING_BASELINE_SKIP, 45 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
8387
30f519812d62
(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:
8350
diff
changeset
|
886 |
0x0, STR_NULL}, |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
887 |
|
8387
30f519812d62
(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:
8350
diff
changeset
|
888 |
{ WWT_TEXT, RESIZE_NONE, COLOUR_YELLOW, |
30f519812d62
(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:
8350
diff
changeset
|
889 |
103, 409, 35 + NT_END * NEWS_SETTING_BASELINE_SKIP, 47 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
30f519812d62
(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:
8350
diff
changeset
|
890 |
STR_MESSAGES_ALL, STR_NULL}, |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
891 |
|
8387
30f519812d62
(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:
8350
diff
changeset
|
892 |
/* Below is widget WIDGET_NEWSOPT_SOUNDTICKER */ |
30f519812d62
(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:
8350
diff
changeset
|
893 |
{ WWT_TEXTBTN_2, RESIZE_NONE, COLOUR_YELLOW, |
30f519812d62
(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:
8350
diff
changeset
|
894 |
4, 98, 46 + NT_END * NEWS_SETTING_BASELINE_SKIP, 57 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
30f519812d62
(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:
8350
diff
changeset
|
895 |
STR_02DB_OFF, STR_NULL}, |
6609
7c466c7c850a
(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:
6605
diff
changeset
|
896 |
|
8387
30f519812d62
(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:
8350
diff
changeset
|
897 |
{ WWT_TEXT, RESIZE_NONE, COLOUR_YELLOW, |
30f519812d62
(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:
8350
diff
changeset
|
898 |
103, 409, 47 + NT_END * NEWS_SETTING_BASELINE_SKIP, 59 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
30f519812d62
(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:
8350
diff
changeset
|
899 |
STR_MESSAGE_SOUND, STR_NULL}, |
30f519812d62
(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:
8350
diff
changeset
|
900 |
|
30f519812d62
(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:
8350
diff
changeset
|
901 |
/* List of news-setting lines (4 widgets for each line). |
30f519812d62
(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:
8350
diff
changeset
|
902 |
* First widget must be number WIDGET_NEWSOPT_START_OPTION |
30f519812d62
(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:
8350
diff
changeset
|
903 |
*/ |
30f519812d62
(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:
8350
diff
changeset
|
904 |
NEWS_SETTINGS_LINE(26, NT_ARRIVAL_PLAYER, STR_0206_ARRIVAL_OF_FIRST_VEHICLE), |
30f519812d62
(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:
8350
diff
changeset
|
905 |
NEWS_SETTINGS_LINE(26, NT_ARRIVAL_OTHER, STR_0207_ARRIVAL_OF_FIRST_VEHICLE), |
30f519812d62
(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:
8350
diff
changeset
|
906 |
NEWS_SETTINGS_LINE(26, NT_ACCIDENT, STR_0208_ACCIDENTS_DISASTERS), |
30f519812d62
(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:
8350
diff
changeset
|
907 |
NEWS_SETTINGS_LINE(26, NT_COMPANY_INFO, STR_0209_COMPANY_INFORMATION), |
30f519812d62
(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:
8350
diff
changeset
|
908 |
NEWS_SETTINGS_LINE(26, NT_OPENCLOSE, STR_NEWS_OPEN_CLOSE), |
30f519812d62
(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:
8350
diff
changeset
|
909 |
NEWS_SETTINGS_LINE(26, NT_ECONOMY, STR_020A_ECONOMY_CHANGES), |
30f519812d62
(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:
8350
diff
changeset
|
910 |
NEWS_SETTINGS_LINE(26, NT_INDUSTRY_PLAYER, STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER), |
30f519812d62
(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:
8350
diff
changeset
|
911 |
NEWS_SETTINGS_LINE(26, NT_INDUSTRY_OTHER, STR_INDUSTRY_CHANGES_SERVED_BY_OTHER), |
30f519812d62
(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:
8350
diff
changeset
|
912 |
NEWS_SETTINGS_LINE(26, NT_INDUSTRY_NOBODY, STR_OTHER_INDUSTRY_PRODUCTION_CHANGES), |
30f519812d62
(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:
8350
diff
changeset
|
913 |
NEWS_SETTINGS_LINE(26, NT_ADVICE, STR_020B_ADVICE_INFORMATION_ON_PLAYER), |
30f519812d62
(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:
8350
diff
changeset
|
914 |
NEWS_SETTINGS_LINE(26, NT_NEW_VEHICLES, STR_020C_NEW_VEHICLES), |
30f519812d62
(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:
8350
diff
changeset
|
915 |
NEWS_SETTINGS_LINE(26, NT_ACCEPTANCE, STR_020D_CHANGES_OF_CARGO_ACCEPTANCE), |
30f519812d62
(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:
8350
diff
changeset
|
916 |
NEWS_SETTINGS_LINE(26, NT_SUBSIDIES, STR_020E_SUBSIDIES), |
30f519812d62
(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:
8350
diff
changeset
|
917 |
NEWS_SETTINGS_LINE(26, NT_GENERAL, STR_020F_GENERAL_INFORMATION), |
6605
0d727f17ee17
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6573
diff
changeset
|
918 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
102
diff
changeset
|
919 |
{ WIDGETS_END}, |
0 | 920 |
}; |
921 |
||
922 |
static const WindowDesc _message_options_desc = { |
|
8387
30f519812d62
(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:
8350
diff
changeset
|
923 |
270, 22, 410, 65 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
30f519812d62
(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:
8350
diff
changeset
|
924 |
410, 65 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
6090
diff
changeset
|
925 |
WC_GAME_OPTIONS, WC_NONE, |
0 | 926 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
927 |
_message_options_widgets, |
|
928 |
MessageOptionsWndProc |
|
929 |
}; |
|
930 |
||
6573 | 931 |
void ShowMessageOptions() |
0 | 932 |
{ |
933 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
10461
48556aee54da
(svn r13004) -Codechange: replace AllocateWindow and AllocateWindowDesc with a Window constructor.
rubidium
parents:
10434
diff
changeset
|
934 |
new Window(&_message_options_desc); |
0 | 935 |
} |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
936 |
|
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
937 |
|
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
938 |
void DeleteVehicleNews(VehicleID vid, StringID news) |
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
939 |
{ |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
940 |
for (NewsID n = _oldest_news; _latest_news != INVALID_NEWS; n = IncreaseIndex(n)) { |
5245
5f1a514e8bfe
(svn r7369) -Cleanup: Some coding style, usage of increaseIndex and decreaseIndex to loop through the
Darkvater
parents:
5244
diff
changeset
|
941 |
const NewsItem *ni = &_news_items[n]; |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
942 |
|
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
943 |
if (ni->flags & NF_VEHICLE && |
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
944 |
ni->data_a == vid && |
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
945 |
(news == INVALID_STRING_ID || ni->string_id == news)) { |
5846
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
946 |
/* If we delete a forced news and it is just before the current news |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
947 |
* then we need to advance to the next news (if any) */ |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
948 |
if (_forced_news == n) MoveToNextItem(); |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
949 |
if (_forced_news == INVALID_NEWS && _current_news == n) MoveToNextItem(); |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
950 |
_total_news--; |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
951 |
|
5771
7288d4e4bfba
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5726
diff
changeset
|
952 |
/* If this is the last news item, invalidate _latest_news */ |
7288d4e4bfba
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5726
diff
changeset
|
953 |
if (_total_news == 0) { |
7288d4e4bfba
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5726
diff
changeset
|
954 |
assert(_latest_news == _oldest_news); |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
955 |
_latest_news = INVALID_NEWS; |
10152
919cffdd5d2e
(svn r12683) -Fix [FS#1906]: in some cases a news messages would not be shown.
rubidium
parents:
9272
diff
changeset
|
956 |
_current_news = INVALID_NEWS; |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
957 |
} |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
958 |
|
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
959 |
/* Since we only imitate a FIFO removing an arbitrary element does need |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
960 |
* some magic. Remove the item by shifting head towards the tail. eg |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
961 |
* oldest remove last |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
962 |
* | | | |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
963 |
* [------O--------n-----L--] |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
964 |
* will become (change dramatized to make clear) |
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
965 |
* [---------O-----------L--] |
5771
7288d4e4bfba
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5726
diff
changeset
|
966 |
* We also need an update of the current, forced and visible (open window) |
7288d4e4bfba
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5726
diff
changeset
|
967 |
* news's as this shifting could change the items they were pointing to */ |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
968 |
if (_total_news != 0) { |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
969 |
Window *w = FindWindowById(WC_NEWS_WINDOW, 0); |
5846
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
970 |
NewsID visible_news = (w != NULL) ? (NewsID)(WP(w, news_d).ni - _news_items) : INVALID_NEWS; |
5771
7288d4e4bfba
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5726
diff
changeset
|
971 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
972 |
for (NewsID i = n;; i = DecreaseIndex(i)) { |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
973 |
_news_items[i] = _news_items[DecreaseIndex(i)]; |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
974 |
|
6090
21f2934dee5c
(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:
5919
diff
changeset
|
975 |
if (i != _latest_news) { |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
976 |
if (i == _current_news) _current_news = IncreaseIndex(_current_news); |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
977 |
if (i == _forced_news) _forced_news = IncreaseIndex(_forced_news); |
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
978 |
if (i == visible_news) WP(w, news_d).ni = &_news_items[IncreaseIndex(visible_news)]; |
6090
21f2934dee5c
(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:
5919
diff
changeset
|
979 |
} |
5771
7288d4e4bfba
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5726
diff
changeset
|
980 |
|
5784
33ed39422ae6
(svn r7861) -Fix (r7823): Crash when oldest news was deleted. First check the index for oldest news
Darkvater
parents:
5771
diff
changeset
|
981 |
if (i == _oldest_news) break; |
33ed39422ae6
(svn r7861) -Fix (r7823): Crash when oldest news was deleted. First check the index for oldest news
Darkvater
parents:
5771
diff
changeset
|
982 |
} |
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
983 |
_oldest_news = IncreaseIndex(_oldest_news); |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
984 |
} |
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
985 |
|
5846
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
986 |
/*DEBUG(misc, 0, "-cur %3d, old %2d, lat %3d, for %3d, tot %2d", |
55f4c68b7616
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5838
diff
changeset
|
987 |
_current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/ |
5771
7288d4e4bfba
(svn r7823) -Fix (r7384 / r7368 / r3757 / r7388): News windows could still cause crashes because
Darkvater
parents:
5726
diff
changeset
|
988 |
|
9272
83630e52b5fe
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
9259
diff
changeset
|
989 |
Window *w = FindWindowById(WC_MESSAGE_HISTORY, 0); |
3143 | 990 |
if (w != NULL) { |
10434
d6accd017341
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
10433
diff
changeset
|
991 |
w->SetDirty(); |
3143 | 992 |
w->vscroll.count = _total_news; |
993 |
} |
|
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
994 |
} |
5254
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
995 |
|
0cf8d2dcc848
(svn r7384) -Fix: No vehicle was removed in DeleteVehicleNews when the fifo-array was full. Update the
Darkvater
parents:
5253
diff
changeset
|
996 |
if (n == _latest_news) break; |
3139
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
997 |
} |
4c950c7ec5c9
(svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents:
2791
diff
changeset
|
998 |
} |