author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9761 | 2fe11e6d2280 |
child 10123 | f73d96619303 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(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:
9094
diff
changeset
|
3 |
/** @file news_gui.cpp GUI functions related to news messages. */ |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1688
diff
changeset
|
6 |
#include "openttd.h" |
3155
c4673c936039
(svn r3778) - Fix crash when resizing news history window.
peter1138
parents:
3143
diff
changeset
|
7 |
#include "gui.h" |
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
8 |
#include "window_gui.h" |
8224
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8214
diff
changeset
|
9 |
#include "viewport_func.h" |
8763
81fadd257f67
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8343
diff
changeset
|
10 |
#include "news_func.h" |
8270
e7c342f6b14c
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8268
diff
changeset
|
11 |
#include "settings_type.h" |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
7824
diff
changeset
|
12 |
#include "transparency.h" |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8107
diff
changeset
|
13 |
#include "strings_func.h" |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8121
diff
changeset
|
14 |
#include "window_func.h" |
8140
0d0d8c94f84b
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8131
diff
changeset
|
15 |
#include "date_func.h" |
8144
65cec0877b78
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8140
diff
changeset
|
16 |
#include "vehicle_base.h" |
8157
1505def01945
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8144
diff
changeset
|
17 |
#include "sound_func.h" |
8214
971f861d5543
(svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents:
8157
diff
changeset
|
18 |
#include "string_func.h" |
8284
ebdc5ba08874
(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:
8270
diff
changeset
|
19 |
#include "widgets/dropdown_func.h" |
9026
690846c6ee99
(svn r12842) -Codechange [FS#1604]: scale message history by map size
glx
parents:
9010
diff
changeset
|
20 |
#include "map_func.h" |
9248
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9245
diff
changeset
|
21 |
#include "statusbar_gui.h" |
9281
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
22 |
#include "player_face.h" |
0 | 23 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8224
diff
changeset
|
24 |
#include "table/sprites.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8224
diff
changeset
|
25 |
#include "table/strings.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8224
diff
changeset
|
26 |
|
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
27 |
#define NB_WIDG_PER_SETTING 4 |
427 | 28 |
|
8268
5027ad5e70a0
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8264
diff
changeset
|
29 |
NewsItem _statusbar_news_item; |
8270
e7c342f6b14c
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8268
diff
changeset
|
30 |
bool _news_ticker_sound; |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
31 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
32 |
static uint MIN_NEWS_AMOUNT = 30; ///< prefered minimum amount of news messages |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
33 |
static uint _total_news = 0; ///< current number of news items |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
34 |
static NewsItem *_oldest_news = NULL; ///< head of news items queue |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
35 |
static NewsItem *_latest_news = NULL; ///< tail of news items queue |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
36 |
|
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
37 |
/** Forced news item. |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
38 |
* Users can force an item by accessing the history or "last message". |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
39 |
* If the message being shown was forced by the user, a pointer is stored |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
40 |
* in _forced_news. Otherwise, \a _forced_news variable is NULL. */ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
41 |
static NewsItem *_forced_news = NULL; ///< item the user has asked for |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
42 |
|
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
43 |
/** Current news item (last item shown regularly). */ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
44 |
static NewsItem *_current_news = NULL; |
0 | 45 |
|
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
46 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
47 |
typedef void DrawNewsCallbackProc(struct Window *w, const NewsItem *ni); |
8763
81fadd257f67
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8343
diff
changeset
|
48 |
void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni); |
9281
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
49 |
|
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
50 |
static void DrawNewsBankrupcy(Window *w, const NewsItem *ni) |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
51 |
{ |
9658
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
52 |
const CompanyNewsInformation *cni = (const CompanyNewsInformation*)ni->free_data; |
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
53 |
|
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
54 |
DrawPlayerFace(cni->face, cni->colour, 2, 23); |
9607
5a5728fb702a
(svn r13649) -Codechange: Split the GfxFillRect() special flags from 'color' into their own parameter.
frosch
parents:
9482
diff
changeset
|
55 |
GfxFillRect(3, 23, 3 + 91, 23 + 118, PALETTE_TO_STRUCT_GREY, FILLRECT_RECOLOR); |
9281
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
56 |
|
9658
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
57 |
SetDParamStr(0, cni->president_name); |
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
58 |
DrawStringMultiCenter(49, 148, STR_JUST_RAW_STRING, 94); |
9281
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
59 |
|
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
60 |
switch (ni->subtype) { |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
61 |
case NS_COMPANY_TROUBLE: |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
62 |
DrawStringCentered(w->width >> 1, 1, STR_7056_TRANSPORT_COMPANY_IN_TROUBLE, TC_FROMSTRING); |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
63 |
|
9658
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
64 |
SetDParam(0, ni->params[2]); |
9281
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
65 |
|
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
66 |
DrawStringMultiCenter( |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
67 |
((w->width - 101) >> 1) + 98, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
68 |
90, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
69 |
STR_7057_WILL_BE_SOLD_OFF_OR_DECLARED, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
70 |
w->width - 101); |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
71 |
break; |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
72 |
|
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
73 |
case NS_COMPANY_MERGER: |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
74 |
DrawStringCentered(w->width >> 1, 1, STR_7059_TRANSPORT_COMPANY_MERGER, TC_FROMSTRING); |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
75 |
SetDParam(0, ni->params[2]); |
9658
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
76 |
SetDParam(1, ni->params[3]); |
9281
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
77 |
SetDParam(2, ni->params[4]); |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
78 |
DrawStringMultiCenter( |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
79 |
((w->width - 101) >> 1) + 98, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
80 |
90, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
81 |
ni->params[4] == 0 ? STR_707F_HAS_BEEN_TAKEN_OVER_BY : STR_705A_HAS_BEEN_SOLD_TO_FOR, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
82 |
w->width - 101); |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
83 |
break; |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
84 |
|
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
85 |
case NS_COMPANY_BANKRUPT: |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
86 |
DrawStringCentered(w->width >> 1, 1, STR_705C_BANKRUPT, TC_FROMSTRING); |
9658
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
87 |
SetDParam(0, ni->params[2]); |
9281
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
88 |
DrawStringMultiCenter( |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
89 |
((w->width - 101) >> 1) + 98, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
90 |
90, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
91 |
STR_705D_HAS_BEEN_CLOSED_DOWN_BY, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
92 |
w->width - 101); |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
93 |
break; |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
94 |
|
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
95 |
case NS_COMPANY_NEW: |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
96 |
DrawStringCentered(w->width >> 1, 1, STR_705E_NEW_TRANSPORT_COMPANY_LAUNCHED, TC_FROMSTRING); |
9658
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
97 |
SetDParam(0, ni->params[2]); |
9281
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
98 |
SetDParam(1, ni->params[3]); |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
99 |
DrawStringMultiCenter( |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
100 |
((w->width - 101) >> 1) + 98, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
101 |
90, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
102 |
STR_705F_STARTS_CONSTRUCTION_NEAR, |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
103 |
w->width - 101); |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
104 |
break; |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
105 |
|
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
106 |
default: |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
107 |
NOT_REACHED(); |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
108 |
} |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
109 |
} |
18200114be76
(svn r13147) -Codechange: move the code to draw bankruptcy news to news_gui.cpp.
rubidium
parents:
9273
diff
changeset
|
110 |
|
0 | 111 |
|
9234
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
112 |
/** |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
113 |
* Data common to all news items of a given subtype (structure) |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
114 |
*/ |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
115 |
struct NewsSubtypeData { |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
116 |
NewsType type; ///< News category @see NewsType |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
117 |
NewsMode display_mode; ///< Display mode value @see NewsMode |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
118 |
NewsFlag flags; ///< Initial NewsFlags bits @see NewsFlag |
9313
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
119 |
DrawNewsCallbackProc *callback; ///< Call-back function |
9234
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
120 |
}; |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
121 |
|
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
122 |
/** |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
123 |
* Data common to all news items of a given subtype (actual data) |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
124 |
*/ |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
125 |
static const struct NewsSubtypeData _news_subtype_data[NS_END] = { |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
126 |
/* type, display_mode, flags, callback */ |
9313
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
127 |
{ NT_ARRIVAL_PLAYER, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ARRIVAL_PLAYER |
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
128 |
{ NT_ARRIVAL_OTHER, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ARRIVAL_OTHER |
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
129 |
{ NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_ACCIDENT_TILE |
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
130 |
{ NT_ACCIDENT, NM_THIN, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ACCIDENT_VEHICLE |
9469
520cbe2f5d14
(svn r13389) -Codechange: remove NM_CALLBACK because that information could be gathered from the fact that a callback has been specified. Patch by Cirdan.
rubidium
parents:
9434
diff
changeset
|
131 |
{ NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_TROUBLE |
520cbe2f5d14
(svn r13389) -Codechange: remove NM_CALLBACK because that information could be gathered from the fact that a callback has been specified. Patch by Cirdan.
rubidium
parents:
9434
diff
changeset
|
132 |
{ NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_MERGER |
520cbe2f5d14
(svn r13389) -Codechange: remove NM_CALLBACK because that information could be gathered from the fact that a callback has been specified. Patch by Cirdan.
rubidium
parents:
9434
diff
changeset
|
133 |
{ NT_COMPANY_INFO, NM_NORMAL, NF_NONE, DrawNewsBankrupcy }, ///< NS_COMPANY_BANKRUPT |
520cbe2f5d14
(svn r13389) -Codechange: remove NM_CALLBACK because that information could be gathered from the fact that a callback has been specified. Patch by Cirdan.
rubidium
parents:
9434
diff
changeset
|
134 |
{ NT_COMPANY_INFO, NM_NORMAL, NF_TILE, DrawNewsBankrupcy }, ///< NS_COMPANY_NEW |
9739
9cf125da8789
(svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents:
9735
diff
changeset
|
135 |
{ NT_INDUSTRY_OPEN, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_OPEN |
9cf125da8789
(svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents:
9735
diff
changeset
|
136 |
{ NT_INDUSTRY_CLOSE, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_CLOSE |
9313
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
137 |
{ NT_ECONOMY, NM_NORMAL, NF_NONE, NULL }, ///< NS_ECONOMY |
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
138 |
{ NT_INDUSTRY_PLAYER, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_PLAYER |
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
139 |
{ NT_INDUSTRY_OTHER, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_OTHER |
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
140 |
{ NT_INDUSTRY_NOBODY, NM_THIN, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_INDUSTRY_NOBODY |
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
141 |
{ NT_ADVICE, NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NULL }, ///< NS_ADVICE |
9469
520cbe2f5d14
(svn r13389) -Codechange: remove NM_CALLBACK because that information could be gathered from the fact that a callback has been specified. Patch by Cirdan.
rubidium
parents:
9434
diff
changeset
|
142 |
{ NT_NEW_VEHICLES, NM_NORMAL, NF_NONE, DrawNewsNewVehicleAvail }, ///< NS_NEW_VEHICLES |
9313
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
143 |
{ NT_ACCEPTANCE, NM_SMALL, NF_VIEWPORT|NF_TILE, NULL }, ///< NS_ACCEPTANCE |
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
144 |
{ NT_SUBSIDIES, NM_NORMAL, NF_TILE|NF_TILE2, NULL }, ///< NS_SUBSIDIES |
11c910ed6d40
(svn r13181) -Codechange: make news callback handling a little simpler. Patch by Cirdan.
rubidium
parents:
9288
diff
changeset
|
145 |
{ NT_GENERAL, NM_NORMAL, NF_TILE, NULL }, ///< NS_GENERAL |
9234
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
146 |
}; |
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
147 |
|
9405
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
148 |
/** |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
149 |
* Per-NewsType data |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
150 |
*/ |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
151 |
NewsTypeData _news_type_data[NT_END] = { |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
152 |
/* name, age, sound, display */ |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
153 |
{ "arrival_player", 60, SND_1D_APPLAUSE, ND_FULL }, ///< NT_ARRIVAL_PLAYER |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
154 |
{ "arrival_other", 60, SND_1D_APPLAUSE, ND_FULL }, ///< NT_ARRIVAL_OTHER |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
155 |
{ "accident", 90, SND_BEGIN, ND_FULL }, ///< NT_ACCIDENT |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
156 |
{ "company_info", 60, SND_BEGIN, ND_FULL }, ///< NT_COMPANY_INFO |
9739
9cf125da8789
(svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents:
9735
diff
changeset
|
157 |
{ "open", 90, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_OPEN |
9cf125da8789
(svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents:
9735
diff
changeset
|
158 |
{ "close", 90, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_CLOSE |
9405
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
159 |
{ "economy", 30, SND_BEGIN, ND_FULL }, ///< NT_ECONOMY |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
160 |
{ "production_player", 30, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_PLAYER |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
161 |
{ "production_other", 30, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_OTHER |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
162 |
{ "production_nobody", 30, SND_BEGIN, ND_FULL }, ///< NT_INDUSTRY_NOBODY |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
163 |
{ "advice", 150, SND_BEGIN, ND_FULL }, ///< NT_ADVICE |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
164 |
{ "new_vehicles", 30, SND_1E_OOOOH, ND_FULL }, ///< NT_NEW_VEHICLES |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
165 |
{ "acceptance", 90, SND_BEGIN, ND_FULL }, ///< NT_ACCEPTANCE |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
166 |
{ "subsidies", 180, SND_BEGIN, ND_FULL }, ///< NT_SUBSIDIES |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
167 |
{ "general", 60, SND_BEGIN, ND_FULL }, ///< NT_GENERAL |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
168 |
}; |
0 | 169 |
|
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
170 |
struct NewsWindow : Window { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
171 |
uint16 chat_height; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
172 |
NewsItem *ni; |
9430
345e3005810d
(svn r13345) -Codechange: only one of all the NewsItem's instance duration variable, so move it so there is only once instance of that variable. Patch by Cirdan.
rubidium
parents:
9413
diff
changeset
|
173 |
static uint duration; |
8763
81fadd257f67
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8343
diff
changeset
|
174 |
|
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
175 |
NewsWindow(const WindowDesc *desc, NewsItem *ni) : Window(desc), ni(ni) |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
176 |
{ |
9430
345e3005810d
(svn r13345) -Codechange: only one of all the NewsItem's instance duration variable, so move it so there is only once instance of that variable. Patch by Cirdan.
rubidium
parents:
9413
diff
changeset
|
177 |
NewsWindow::duration = 555; |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
178 |
const Window *w = FindWindowById(WC_SEND_NETWORK_MSG, 0); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
179 |
this->chat_height = (w != NULL) ? w->height : 0; |
8763
81fadd257f67
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8343
diff
changeset
|
180 |
|
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
181 |
this->ni = _forced_news == NULL ? _current_news : _forced_news; |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
182 |
this->flags4 |= WF_DISABLE_VP_SCROLL; |
0 | 183 |
|
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
184 |
this->FindWindowPlacementAndResize(desc); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
185 |
} |
8763
81fadd257f67
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8343
diff
changeset
|
186 |
|
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
187 |
void DrawNewsBorder() |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
188 |
{ |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
189 |
int left = 0; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
190 |
int right = this->width - 1; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
191 |
int top = 0; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
192 |
int bottom = this->height - 1; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
193 |
|
9761
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
194 |
GfxFillRect(left, top, right, bottom, 0xF); |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
195 |
|
9761
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
196 |
GfxFillRect(left, top, left, bottom, 0xD7); |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
197 |
GfxFillRect(right, top, right, bottom, 0xD7); |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
198 |
GfxFillRect(left, top, right, top, 0xD7); |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
199 |
GfxFillRect(left, bottom, right, bottom, 0xD7); |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
200 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
201 |
DrawString(left + 2, top + 1, STR_00C6, TC_FROMSTRING); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
202 |
} |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
203 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
204 |
virtual void OnPaint() |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
205 |
{ |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
206 |
const NewsMode display_mode = _news_subtype_data[this->ni->subtype].display_mode; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
207 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
208 |
switch (display_mode) { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
209 |
case NM_NORMAL: |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
210 |
case NM_THIN: { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
211 |
this->DrawNewsBorder(); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
212 |
|
9469
520cbe2f5d14
(svn r13389) -Codechange: remove NM_CALLBACK because that information could be gathered from the fact that a callback has been specified. Patch by Cirdan.
rubidium
parents:
9434
diff
changeset
|
213 |
if (_news_subtype_data[this->ni->subtype].callback != NULL) { |
520cbe2f5d14
(svn r13389) -Codechange: remove NM_CALLBACK because that information could be gathered from the fact that a callback has been specified. Patch by Cirdan.
rubidium
parents:
9434
diff
changeset
|
214 |
(_news_subtype_data[this->ni->subtype].callback)(this, ni); |
520cbe2f5d14
(svn r13389) -Codechange: remove NM_CALLBACK because that information could be gathered from the fact that a callback has been specified. Patch by Cirdan.
rubidium
parents:
9434
diff
changeset
|
215 |
break; |
520cbe2f5d14
(svn r13389) -Codechange: remove NM_CALLBACK because that information could be gathered from the fact that a callback has been specified. Patch by Cirdan.
rubidium
parents:
9434
diff
changeset
|
216 |
} |
520cbe2f5d14
(svn r13389) -Codechange: remove NM_CALLBACK because that information could be gathered from the fact that a callback has been specified. Patch by Cirdan.
rubidium
parents:
9434
diff
changeset
|
217 |
|
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
218 |
DrawString(2, 1, STR_00C6, TC_FROMSTRING); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
219 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
220 |
SetDParam(0, this->ni->date); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
221 |
DrawStringRightAligned(428, 1, STR_01FF, TC_FROMSTRING); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
222 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
223 |
if (!(this->ni->flags & NF_VIEWPORT)) { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
224 |
CopyInDParam(0, this->ni->params, lengthof(this->ni->params)); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
225 |
DrawStringMultiCenter(215, display_mode == NM_NORMAL ? 76 : 56, |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
226 |
this->ni->string_id, this->width - 4); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
227 |
} else { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
228 |
/* Back up transparency options to draw news view */ |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
229 |
TransparencyOptionBits to_backup = _transparency_opt; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
230 |
_transparency_opt = 0; |
9273
35e0224ea8f1
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
9249
diff
changeset
|
231 |
this->DrawViewport(); |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
232 |
_transparency_opt = to_backup; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
233 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
234 |
/* Shade the viewport into gray, or color*/ |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
235 |
ViewPort *vp = this->viewport; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
236 |
GfxFillRect(vp->left - this->left, vp->top - this->top, |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
237 |
vp->left - this->left + vp->width - 1, vp->top - this->top + vp->height - 1, |
9607
5a5728fb702a
(svn r13649) -Codechange: Split the GfxFillRect() special flags from 'color' into their own parameter.
frosch
parents:
9482
diff
changeset
|
238 |
(this->ni->flags & NF_INCOLOR ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY), FILLRECT_RECOLOR |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
239 |
); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
240 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
241 |
CopyInDParam(0, this->ni->params, lengthof(this->ni->params)); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
242 |
DrawStringMultiCenter(this->width / 2, 20, this->ni->string_id, this->width - 4); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
243 |
} |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
244 |
break; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
245 |
} |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
246 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
247 |
default: |
9273
35e0224ea8f1
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
9249
diff
changeset
|
248 |
this->DrawWidgets(); |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
249 |
if (!(this->ni->flags & NF_VIEWPORT)) { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
250 |
CopyInDParam(0, this->ni->params, lengthof(this->ni->params)); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
251 |
DrawStringMultiCenter(140, 38, this->ni->string_id, 276); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
252 |
} else { |
9273
35e0224ea8f1
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
9249
diff
changeset
|
253 |
this->DrawViewport(); |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
254 |
CopyInDParam(0, this->ni->params, lengthof(this->ni->params)); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
255 |
DrawStringMultiCenter(this->width / 2, this->height - 16, this->ni->string_id, this->width - 4); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
256 |
} |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
257 |
break; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
258 |
} |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
259 |
} |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
260 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
261 |
virtual void OnClick(Point pt, int widget) |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
262 |
{ |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
263 |
switch (widget) { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
264 |
case 1: |
9430
345e3005810d
(svn r13345) -Codechange: only one of all the NewsItem's instance duration variable, so move it so there is only once instance of that variable. Patch by Cirdan.
rubidium
parents:
9413
diff
changeset
|
265 |
NewsWindow::duration = 0; |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
266 |
delete this; |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
267 |
_forced_news = NULL; |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
268 |
break; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
269 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
270 |
case 0: |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
271 |
if (this->ni->flags & NF_VEHICLE) { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
272 |
Vehicle *v = GetVehicle(this->ni->data_a); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
273 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
274 |
} else if (this->ni->flags & NF_TILE) { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
275 |
if (_ctrl_pressed) { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
276 |
ShowExtraViewPortWindow(this->ni->data_a); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
277 |
if (this->ni->flags & NF_TILE2) { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
278 |
ShowExtraViewPortWindow(this->ni->data_b); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
279 |
} |
8763
81fadd257f67
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
8343
diff
changeset
|
280 |
} else { |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
281 |
if (!ScrollMainWindowToTile(this->ni->data_a) && this->ni->flags & NF_TILE2) { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
282 |
ScrollMainWindowToTile(this->ni->data_b); |
9093 | 283 |
} |
284 |
} |
|
285 |
} |
|
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
286 |
break; |
9093 | 287 |
} |
0 | 288 |
} |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
289 |
|
9285
235e5e2d7f55
(svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents:
9281
diff
changeset
|
290 |
virtual EventState OnKeyPress(uint16 key, uint16 keycode) |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
291 |
{ |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
292 |
if (keycode == WKC_SPACE) { |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
293 |
/* Don't continue. */ |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
294 |
delete this; |
9285
235e5e2d7f55
(svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents:
9281
diff
changeset
|
295 |
return ES_HANDLED; |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
296 |
} |
9285
235e5e2d7f55
(svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium
parents:
9281
diff
changeset
|
297 |
return ES_NOT_HANDLED; |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
298 |
} |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
299 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
300 |
virtual void OnInvalidateData(int data) |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
301 |
{ |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
302 |
/* The chatbar has notified us that is was either created or closed */ |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
303 |
this->chat_height = data; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
304 |
} |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
305 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
306 |
virtual void OnTick() |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
307 |
{ |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
308 |
/* Scroll up newsmessages from the bottom in steps of 4 pixels */ |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
309 |
int y = max(this->top - 4, _screen.height - this->height - 12 - this->chat_height); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
310 |
if (y == this->top) return; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
311 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
312 |
if (this->viewport != NULL) this->viewport->top += y - this->top; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
313 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
314 |
int diff = Delta(this->top, y); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
315 |
this->top = y; |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
316 |
|
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
317 |
SetDirtyBlocks(this->left, this->top - diff, this->left + this->width, this->top + this->height); |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
318 |
} |
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
319 |
}; |
0 | 320 |
|
9430
345e3005810d
(svn r13345) -Codechange: only one of all the NewsItem's instance duration variable, so move it so there is only once instance of that variable. Patch by Cirdan.
rubidium
parents:
9413
diff
changeset
|
321 |
/* static */ uint NewsWindow::duration; ///< Remaining time for showing current news message |
345e3005810d
(svn r13345) -Codechange: only one of all the NewsItem's instance duration variable, so move it so there is only once instance of that variable. Patch by Cirdan.
rubidium
parents:
9413
diff
changeset
|
322 |
|
0 | 323 |
|
324 |
static const Widget _news_type13_widgets[] = { |
|
9761
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
325 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 0, 429, 0, 169, 0x0, STR_NULL}, |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
326 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 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
|
327 |
{ WIDGETS_END}, |
0 | 328 |
}; |
329 |
||
330 |
static WindowDesc _news_type13_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7266
diff
changeset
|
331 |
WDP_CENTER, 476, 430, 170, 430, 170, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5839
diff
changeset
|
332 |
WC_NEWS_WINDOW, WC_NONE, |
0 | 333 |
WDF_DEF_WIDGET, |
334 |
_news_type13_widgets, |
|
335 |
}; |
|
336 |
||
337 |
static const Widget _news_type2_widgets[] = { |
|
9761
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
338 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 0, 429, 0, 129, 0x0, STR_NULL}, |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
339 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_WHITE, 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
|
340 |
{ WIDGETS_END}, |
0 | 341 |
}; |
342 |
||
343 |
static WindowDesc _news_type2_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7266
diff
changeset
|
344 |
WDP_CENTER, 476, 430, 130, 430, 130, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5839
diff
changeset
|
345 |
WC_NEWS_WINDOW, WC_NONE, |
0 | 346 |
WDF_DEF_WIDGET, |
347 |
_news_type2_widgets, |
|
348 |
}; |
|
349 |
||
350 |
static const Widget _news_type0_widgets[] = { |
|
9761
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
351 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 279, 14, 86, 0x0, STR_NULL}, |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
352 |
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_LIGHT_BLUE, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
353 |
{ WWT_CAPTION, RESIZE_NONE, COLOUR_LIGHT_BLUE, 11, 279, 0, 13, STR_012C_MESSAGE, STR_NULL}, |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
354 |
{ WWT_INSET, RESIZE_NONE, COLOUR_LIGHT_BLUE, 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
|
355 |
{ WIDGETS_END}, |
0 | 356 |
}; |
357 |
||
358 |
static WindowDesc _news_type0_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7266
diff
changeset
|
359 |
WDP_CENTER, 476, 280, 87, 280, 87, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5839
diff
changeset
|
360 |
WC_NEWS_WINDOW, WC_NONE, |
0 | 361 |
WDF_DEF_WIDGET, |
362 |
_news_type0_widgets, |
|
363 |
}; |
|
364 |
||
365 |
||
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
366 |
/** 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
|
367 |
static void ShowNewspaper(NewsItem *ni) |
0 | 368 |
{ |
9234
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
369 |
SoundFx sound = _news_type_data[_news_subtype_data[ni->subtype].type].sound; |
2639 | 370 |
if (sound != 0) SndPlayFx(sound); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
371 |
|
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
372 |
int top = _screen.height; |
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
373 |
Window *w; |
9234
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
374 |
switch (_news_subtype_data[ni->subtype].display_mode) { |
427 | 375 |
case NM_NORMAL: |
376 |
_news_type13_desc.top = top; |
|
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
377 |
w = new NewsWindow(&_news_type13_desc, ni); |
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
378 |
if (ni->flags & NF_VIEWPORT) { |
8994
fb5e761cf141
(svn r12789) -Codechange: rename AssignWindowViewport to InitializeWindowViewport because the viewport is now part of the window struct. Patch by Alberth.
rubidium
parents:
8990
diff
changeset
|
379 |
InitializeWindowViewport(w, 2, 58, 426, 110, |
6624
880e29b1f25e
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6542
diff
changeset
|
380 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS); |
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
381 |
} |
427 | 382 |
break; |
383 |
||
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
384 |
case NM_THIN: |
427 | 385 |
_news_type2_desc.top = top; |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
386 |
w = new NewsWindow(&_news_type2_desc, ni); |
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
387 |
if (ni->flags & NF_VIEWPORT) { |
8994
fb5e761cf141
(svn r12789) -Codechange: rename AssignWindowViewport to InitializeWindowViewport because the viewport is now part of the window struct. Patch by Alberth.
rubidium
parents:
8990
diff
changeset
|
388 |
InitializeWindowViewport(w, 2, 58, 426, 70, |
6624
880e29b1f25e
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6542
diff
changeset
|
389 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS); |
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
390 |
} |
427 | 391 |
break; |
392 |
||
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
393 |
default: |
427 | 394 |
_news_type0_desc.top = top; |
9236
0c4f622cbcec
(svn r13102) -Codechange: make a class of the NewsWindow.
rubidium
parents:
9234
diff
changeset
|
395 |
w = new NewsWindow(&_news_type0_desc, ni); |
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
396 |
if (ni->flags & NF_VIEWPORT) { |
8994
fb5e761cf141
(svn r12789) -Codechange: rename AssignWindowViewport to InitializeWindowViewport because the viewport is now part of the window struct. Patch by Alberth.
rubidium
parents:
8990
diff
changeset
|
397 |
InitializeWindowViewport(w, 3, 17, 274, 47, |
6624
880e29b1f25e
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6542
diff
changeset
|
398 |
ni->data_a | (ni->flags & NF_VEHICLE ? 0x80000000 : 0), ZOOM_LVL_NEWS); |
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
399 |
} |
427 | 400 |
break; |
0 | 401 |
} |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
402 |
} |
0 | 403 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
404 |
/** Show news item in the ticker */ |
427 | 405 |
static void ShowTicker(const NewsItem *ni) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
406 |
{ |
1688
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
407 |
if (_news_ticker_sound) SndPlayFx(SND_16_MORSE); |
af2bb9bcb2ed
(svn r2192) - Add greater control to the 'message options' window. Now you can turn off the telegraphc ticker sound for summarized messages, or turn off news-messages altogether (you get a red blot to notify you though). The [<][>] set the settings in one way, while clicking on the option itself, cycles it. This commit also 'fixes' bugs [1166973], [1121484] and patch [1169930].
Darkvater
parents:
1648
diff
changeset
|
408 |
|
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
409 |
_statusbar_news_item = *ni; |
9248
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9245
diff
changeset
|
410 |
InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_TICKER); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
411 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
412 |
|
9405
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
413 |
/** Initialize the news-items data structures */ |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
414 |
void InitNewsItemStructs() |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
415 |
{ |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
416 |
for (NewsItem *ni = _oldest_news; ni != NULL; ) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
417 |
NewsItem *next = ni->next; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
418 |
delete ni; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
419 |
ni = next; |
9405
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
420 |
} |
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
421 |
|
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
422 |
_total_news = 0; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
423 |
_oldest_news = NULL; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
424 |
_latest_news = NULL; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
425 |
_forced_news = NULL; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
426 |
_current_news = NULL; |
9405
69c042fc13a4
(svn r13316) -Codechange: move some functions around to make them grouped more logically.
rubidium
parents:
9354
diff
changeset
|
427 |
} |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
428 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
429 |
/** |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
430 |
* Are we ready to show another news item? |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
431 |
* Only if nothing is in the newsticker and no newspaper is displayed |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
432 |
*/ |
6247 | 433 |
static bool ReadyForNextItem() |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
434 |
{ |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
435 |
NewsItem *ni = _forced_news == NULL ? _current_news : _forced_news; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
436 |
if (ni == NULL) return true; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
437 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
438 |
/* Ticker message |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
439 |
* Check if the status bar message is still being displayed? */ |
9248
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9245
diff
changeset
|
440 |
if (IsNewsTickerShown()) return false; |
0 | 441 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
442 |
/* Newspaper message, decrement duration counter */ |
9430
345e3005810d
(svn r13345) -Codechange: only one of all the NewsItem's instance duration variable, so move it so there is only once instance of that variable. Patch by Cirdan.
rubidium
parents:
9413
diff
changeset
|
443 |
if (NewsWindow::duration != 0) NewsWindow::duration--; |
0 | 444 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
445 |
/* neither newsticker nor newspaper are running */ |
9430
345e3005810d
(svn r13345) -Codechange: only one of all the NewsItem's instance duration variable, so move it so there is only once instance of that variable. Patch by Cirdan.
rubidium
parents:
9413
diff
changeset
|
446 |
return (NewsWindow::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
|
447 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
448 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
449 |
/** Move to the next news item */ |
6247 | 450 |
static void MoveToNextItem() |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
451 |
{ |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
452 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
453 |
_forced_news = NULL; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
454 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
455 |
/* if we're not at the last item, then move on */ |
427 | 456 |
if (_current_news != _latest_news) { |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
457 |
_current_news = (_current_news == NULL) ? _oldest_news : _current_news->next; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
458 |
NewsItem *ni = _current_news; |
9234
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
459 |
const NewsType type = _news_subtype_data[ni->subtype].type; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
460 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
461 |
/* check the date, don't show too old items */ |
9234
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
462 |
if (_date - _news_type_data[type].age > ni->date) return; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
463 |
|
9234
bfc9d27d3d0d
(svn r13100) -Codechange: reduce the amount of parameters passed via AddNewsMessage as there is (for each news message type) a tuple of 4 parameters that is the same for all calls.
rubidium
parents:
9199
diff
changeset
|
464 |
switch (_news_type_data[type].display) { |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
465 |
default: NOT_REACHED(); |
9248
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9245
diff
changeset
|
466 |
case ND_OFF: // Off - show nothing only a small reminder in the status bar |
5c057d6b7e21
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
rubidium
parents:
9245
diff
changeset
|
467 |
InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_REMINDER); |
2639 | 468 |
break; |
469 |
||
9434
0b874f476134
(svn r13349) -Codechange: remove a pointless flag; the flag is set before calling a function and is then reset in the function without ever reading it. Patch by Cirdan.
rubidium
parents:
9430
diff
changeset
|
470 |
case ND_SUMMARY: // Summary - show ticker |
0b874f476134
(svn r13349) -Codechange: remove a pointless flag; the flag is set before calling a function and is then reset in the function without ever reading it. Patch by Cirdan.
rubidium
parents:
9430
diff
changeset
|
471 |
ShowTicker(ni); |
0b874f476134
(svn r13349) -Codechange: remove a pointless flag; the flag is set before calling a function and is then reset in the function without ever reading it. Patch by Cirdan.
rubidium
parents:
9430
diff
changeset
|
472 |
break; |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
473 |
|
9010
fa1aa6008a59
(svn r12805) -Codechange: remove some bit magic related to the news display states. Patch by cirdan.
rubidium
parents:
8994
diff
changeset
|
474 |
case ND_FULL: // Full - show newspaper |
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
475 |
ShowNewspaper(ni); |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
476 |
break; |
2639 | 477 |
} |
0 | 478 |
} |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
479 |
} |
0 | 480 |
|
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
481 |
/** |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
482 |
* Add a new newsitem to be shown. |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
483 |
* @param string String to display |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
484 |
* @param subtype news category, any of the NewsSubtype enums (NS_) |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
485 |
* @param data_a news-specific value based on news type |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
486 |
* @param data_b news-specific value based on news type |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
487 |
* |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
488 |
* @see NewsSubype |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
489 |
*/ |
9658
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
490 |
void AddNewsItem(StringID string, NewsSubtype subtype, uint data_a, uint data_b, void *free_data) |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
491 |
{ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
492 |
if (_game_mode == GM_MENU) return; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
493 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
494 |
/* Create new news item node */ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
495 |
NewsItem *ni = new NewsItem; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
496 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
497 |
ni->string_id = string; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
498 |
ni->subtype = subtype; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
499 |
ni->flags = _news_subtype_data[subtype].flags; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
500 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
501 |
/* show this news message in color? */ |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9406
diff
changeset
|
502 |
if (_cur_year >= _settings_client.gui.colored_news_year) ni->flags |= NF_INCOLOR; |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
503 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
504 |
ni->data_a = data_a; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
505 |
ni->data_b = data_b; |
9658
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
506 |
ni->free_data = free_data; |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
507 |
ni->date = _date; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
508 |
CopyOutDParam(ni->params, 0, lengthof(ni->params)); |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
509 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
510 |
if (_total_news++ == 0) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
511 |
assert(_oldest_news == NULL); |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
512 |
_oldest_news = ni; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
513 |
ni->prev = NULL; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
514 |
} else { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
515 |
assert(_latest_news->next == NULL); |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
516 |
_latest_news->next = ni; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
517 |
ni->prev = _latest_news; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
518 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
519 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
520 |
ni->next = NULL; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
521 |
_latest_news = ni; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
522 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
523 |
InvalidateWindow(WC_MESSAGE_HISTORY, 0); |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
524 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
525 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
526 |
/** Delete a news item from the queue */ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
527 |
static void DeleteNewsItem(NewsItem *ni) |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
528 |
{ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
529 |
if (_forced_news == ni) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
530 |
/* about to remove the currently forced item; skip to next */ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
531 |
MoveToNextItem(); |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
532 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
533 |
|
9482
36af6691f120
(svn r13434) -Fix (r13317): news window with invalid news item could be shown
smatz
parents:
9469
diff
changeset
|
534 |
if ((_current_news == ni) && (FindWindowById(WC_NEWS_WINDOW, 0) != NULL)) { |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
535 |
/* about to remove the currently displayed item; also skip */ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
536 |
MoveToNextItem(); |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
537 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
538 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
539 |
/* delete item */ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
540 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
541 |
if (ni->prev != NULL) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
542 |
ni->prev->next = ni->next; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
543 |
} else { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
544 |
assert(_oldest_news == ni); |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
545 |
_oldest_news = ni->next; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
546 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
547 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
548 |
if (ni->next != NULL) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
549 |
ni->next->prev = ni->prev; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
550 |
} else { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
551 |
assert(_latest_news == ni); |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
552 |
_latest_news = ni->prev; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
553 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
554 |
|
9658
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
555 |
free(ni->free_data); |
f5c4d3c04b5d
(svn r13730) -Fix: make a copy of the names for news messages about the deletion of companies as the removal of a company could lead to wrong names in the news messages.
rubidium
parents:
9607
diff
changeset
|
556 |
|
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
557 |
if (_current_news == ni) _current_news = ni->prev; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
558 |
_total_news--; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
559 |
delete ni; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
560 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
561 |
InvalidateWindow(WC_MESSAGE_HISTORY, 0); |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
562 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
563 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
564 |
void DeleteVehicleNews(VehicleID vid, StringID news) |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
565 |
{ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
566 |
NewsItem *ni = _oldest_news; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
567 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
568 |
while (ni != NULL) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
569 |
if (ni->flags & NF_VEHICLE && |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
570 |
ni->data_a == vid && |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
571 |
(news == INVALID_STRING_ID || ni->string_id == news)) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
572 |
/* grab a pointer to the next item before ni is freed */ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
573 |
NewsItem *p = ni->next; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
574 |
DeleteNewsItem(ni); |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
575 |
ni = p; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
576 |
} else { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
577 |
ni = ni->next; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
578 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
579 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
580 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
581 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
582 |
void RemoveOldNewsItems() |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
583 |
{ |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
584 |
NewsItem *next; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
585 |
for (NewsItem *cur = _oldest_news; _total_news > MIN_NEWS_AMOUNT && cur != NULL; cur = next) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
586 |
next = cur->next; |
9413
7042a8ec3fa8
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents:
9406
diff
changeset
|
587 |
if (_date - _news_type_data[_news_subtype_data[cur->subtype].type].age * _settings_client.gui.news_message_timeout > cur->date) DeleteNewsItem(cur); |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
588 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
589 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
590 |
|
6247 | 591 |
void NewsLoop() |
0 | 592 |
{ |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
593 |
/* no news item yet */ |
427 | 594 |
if (_total_news == 0) return; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
595 |
|
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
596 |
static byte _last_clean_month = 0; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
597 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
598 |
if (_last_clean_month != _cur_month) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
599 |
RemoveOldNewsItems(); |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
600 |
_last_clean_month = _cur_month; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
601 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
602 |
|
5253
ff50454e0604
(svn r7383) -Codechange: fix up typo in news-gui s/MoveToNexItem/MoveToNextItem/.
Darkvater
parents:
5246
diff
changeset
|
603 |
if (ReadyForNextItem()) MoveToNextItem(); |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
604 |
} |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
605 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
606 |
/** Do a forced show of a specific message */ |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
607 |
static void ShowNewsMessage(NewsItem *ni) |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
608 |
{ |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
609 |
assert(_total_news != 0); |
89 | 610 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
611 |
/* Delete the news window */ |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
612 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
613 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6302
diff
changeset
|
614 |
/* setup forced news item */ |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
615 |
_forced_news = ni; |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
616 |
|
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
617 |
if (_forced_news != NULL) { |
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
618 |
DeleteWindowById(WC_NEWS_WINDOW, 0); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
619 |
ShowNewspaper(ni); |
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
620 |
} |
0 | 621 |
} |
622 |
||
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
623 |
/** Show previous news item */ |
6247 | 624 |
void ShowLastNewsMessage() |
0 | 625 |
{ |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
626 |
if (_total_news == 0) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
627 |
return; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
628 |
} else if (_forced_news == NULL) { |
5595
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
629 |
/* Not forced any news yet, show the current one, unless a news window is |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
630 |
* open (which can only be the current one), then show the previous item */ |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
631 |
const Window *w = FindWindowById(WC_NEWS_WINDOW, 0); |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
632 |
ShowNewsMessage((w == NULL || (_current_news == _oldest_news)) ? _current_news : _current_news->prev); |
5595
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
633 |
} else if (_forced_news == _oldest_news) { |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
634 |
/* We have reached the oldest news, start anew with the latest */ |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
635 |
ShowNewsMessage(_latest_news); |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
636 |
} else { |
6d738ef8fd96
(svn r8049) -Regression (r7369): Removing certain news windows could cause a crash due to only
Darkvater
parents:
5587
diff
changeset
|
637 |
/* 'Scrolling' through news history show each one in turn */ |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
638 |
ShowNewsMessage(_forced_news->prev); |
83
bd21afea96d8
(svn r84) Improved news system code a little to avoid potential memory leaks
dominik
parents:
80
diff
changeset
|
639 |
} |
0 | 640 |
} |
641 |
||
79
15e3eef5f73d
(svn r80) New internal news system (implemented with fifo queue)
dominik
parents:
0
diff
changeset
|
642 |
|
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
643 |
/** |
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
644 |
* Draw an unformatted news message truncated to a maximum length. If |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
645 |
* length exceeds maximum length it will be postfixed by '...' |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
646 |
* @param x,y position of the string |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
647 |
* @param color the color the string will be shown in |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
648 |
* @param *ni NewsItem being printed |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
649 |
* @param maxw maximum width of string in pixels |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
650 |
*/ |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
651 |
static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint maxw) |
89 | 652 |
{ |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
653 |
char buffer[512], buffer2[512]; |
89 | 654 |
StringID str; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
655 |
|
9199
ce9fbdff6581
(svn r13065) -Codechange: remove the need for the news string callbacks. Patch by Cirdan.
rubidium
parents:
9184
diff
changeset
|
656 |
CopyInDParam(0, ni->params, lengthof(ni->params)); |
ce9fbdff6581
(svn r13065) -Codechange: remove the need for the news string callbacks. Patch by Cirdan.
rubidium
parents:
9184
diff
changeset
|
657 |
str = ni->string_id; |
89 | 658 |
|
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4874
diff
changeset
|
659 |
GetString(buffer, str, lastof(buffer)); |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
660 |
/* Copy the just gotten string to another buffer to remove any formatting |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
661 |
* from it such as big fonts, etc. */ |
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
662 |
const char *ptr = buffer; |
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
663 |
char *dest = buffer2; |
6542
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
664 |
WChar c_last = '\0'; |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
665 |
for (;;) { |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
666 |
WChar c = Utf8Consume(&ptr); |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
667 |
if (c == 0) break; |
6542
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
668 |
/* Make a space from a newline, but ignore multiple newlines */ |
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
669 |
if (c == '\n' && c_last != '\n') { |
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
670 |
dest[0] = ' '; |
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
671 |
dest++; |
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
672 |
} else if (c == '\r') { |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
673 |
dest[0] = dest[1] = dest[2] = dest[3] = ' '; |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
674 |
dest += 4; |
5108
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
675 |
} else if (IsPrintable(c)) { |
aeaef6fe53b7
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
4939
diff
changeset
|
676 |
dest += Utf8Encode(dest, c); |
89 | 677 |
} |
6542
47e288403035
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
truelight
parents:
6481
diff
changeset
|
678 |
c_last = c; |
89 | 679 |
} |
2101
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
680 |
|
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
681 |
*dest = '\0'; |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
682 |
/* Truncate and show string; postfixed by '...' if neccessary */ |
822f0b48ce64
(svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents:
1959
diff
changeset
|
683 |
DoDrawStringTruncated(buffer2, x, y, color, maxw); |
89 | 684 |
} |
685 |
||
686 |
||
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
687 |
struct MessageHistoryWindow : Window { |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
688 |
MessageHistoryWindow(const WindowDesc *desc) : Window(desc) |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
689 |
{ |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
690 |
this->vscroll.cap = 10; |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
691 |
this->vscroll.count = _total_news; |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
692 |
this->resize.step_height = 12; |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
693 |
this->resize.height = this->height - 12 * 6; // minimum of 4 items in the list, each item 12 high |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
694 |
this->resize.step_width = 1; |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
695 |
this->resize.width = 200; // can't make window any smaller than 200 pixel |
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
696 |
|
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
697 |
this->FindWindowPlacementAndResize(desc); |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
698 |
} |
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
699 |
|
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
700 |
virtual void OnPaint() |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
701 |
{ |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
702 |
int y = 19; |
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
703 |
|
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
704 |
SetVScrollCount(this, _total_news); |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
705 |
this->DrawWidgets(); |
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
706 |
|
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
707 |
if (_total_news == 0) return; |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
708 |
|
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
709 |
NewsItem *ni = _latest_news; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
710 |
for (int n = this->vscroll.pos; n > 0; n--) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
711 |
ni = ni->prev; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
712 |
if (ni == NULL) return; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
713 |
} |
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
714 |
|
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
715 |
for (int n = this->vscroll.cap; n > 0; n--) { |
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
716 |
SetDParam(0, ni->date); |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
717 |
DrawString(4, y, STR_SHORT_DATE, TC_WHITE); |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
718 |
|
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
719 |
DrawNewsString(82, y, TC_WHITE, ni, this->width - 95); |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
720 |
y += 12; |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
721 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
722 |
ni = ni->prev; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
723 |
if (ni == NULL) return; |
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
724 |
} |
89 | 725 |
} |
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
726 |
|
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
727 |
virtual void OnClick(Point pt, int widget) |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
728 |
{ |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
729 |
if (widget == 3) { |
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
730 |
NewsItem *ni = _latest_news; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
731 |
if (ni == NULL) return; |
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
732 |
|
9406
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
733 |
for (int n = (pt.y - 19) / 12 + this->vscroll.pos; n > 0; n--) { |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
734 |
ni = ni->prev; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
735 |
if (ni == NULL) return; |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
736 |
} |
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
737 |
|
f85d149506a9
(svn r13317) -Codechange: make news messages use a linked list instead of a moving circular buffer. This makes it possible to store more news messages in the history. Based on a patch by Cirdan.
rubidium
parents:
9405
diff
changeset
|
738 |
ShowNewsMessage(ni); |
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
739 |
} |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
740 |
} |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
741 |
|
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
742 |
virtual void OnResize(Point new_size, Point delta) |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
743 |
{ |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
744 |
this->vscroll.cap += delta.y / 12; |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
745 |
} |
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
746 |
}; |
89 | 747 |
|
748 |
static const Widget _message_history_widgets[] = { |
|
9761
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
749 |
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_BROWN, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
750 |
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_BROWN, 11, 387, 0, 13, STR_MESSAGE_HISTORY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
751 |
{ WWT_STICKYBOX, RESIZE_LR, COLOUR_BROWN, 388, 399, 0, 13, 0x0, STR_STICKY_BUTTON}, |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
752 |
{ WWT_PANEL, RESIZE_RB, COLOUR_BROWN, 0, 387, 14, 139, 0x0, STR_MESSAGE_HISTORY_TIP}, |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
753 |
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_BROWN, 388, 399, 14, 127, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
2fe11e6d2280
(svn r13897) -Codechange: Replace remaining numbers with Colours enum on news guis
belugas
parents:
9739
diff
changeset
|
754 |
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_BROWN, 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
|
755 |
{ WIDGETS_END}, |
89 | 756 |
}; |
757 |
||
758 |
static const WindowDesc _message_history_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7266
diff
changeset
|
759 |
240, 22, 400, 140, 400, 140, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5839
diff
changeset
|
760 |
WC_MESSAGE_HISTORY, WC_NONE, |
1097
196431cb50fe
(svn r1598) Feature: Message history now is stickyable and resizeable
dominik
parents:
1095
diff
changeset
|
761 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
89 | 762 |
_message_history_widgets, |
763 |
}; |
|
764 |
||
7598
626c6a804e6d
(svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents:
7341
diff
changeset
|
765 |
/** Display window with news messages history */ |
6247 | 766 |
void ShowMessageHistory() |
89 | 767 |
{ |
768 |
DeleteWindowById(WC_MESSAGE_HISTORY, 0); |
|
9288
82e1673da1db
(svn r13154) -Codechange: make a window class of the news message history window.
rubidium
parents:
9285
diff
changeset
|
769 |
new MessageHistoryWindow(&_message_history_desc); |
89 | 770 |
} |
771 |
||
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
772 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
773 |
/** News settings window widget offset constants */ |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
774 |
enum { |
8343
a6b70ddd862b
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8284
diff
changeset
|
775 |
WIDGET_NEWSOPT_DROP_SUMMARY = 4, ///< Dropdown that adjusts at once the level for all settings |
a6b70ddd862b
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8284
diff
changeset
|
776 |
WIDGET_NEWSOPT_SOUNDTICKER = 6, ///< Button activating sound on events |
a6b70ddd862b
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8284
diff
changeset
|
777 |
WIDGET_NEWSOPT_START_OPTION = 8, ///< First widget that is part of a group [<] .. [.] |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
778 |
}; |
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
779 |
|
9249
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
780 |
static const StringID _message_opt[] = {STR_OFF, STR_SUMMARY, STR_FULL, INVALID_STRING_ID}; |
8343
a6b70ddd862b
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8284
diff
changeset
|
781 |
|
9249
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
782 |
struct MessageOptionsWindow : Window { |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
783 |
int state; |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
784 |
|
9249
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
785 |
MessageOptionsWindow(const WindowDesc *desc) : Window(desc) |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
786 |
{ |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
787 |
NewsDisplay all_val; |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
788 |
|
9249
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
789 |
/* Set up the initial disabled buttons in the case of 'off' or 'full' */ |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
790 |
all_val = _news_type_data[0].display; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
791 |
for (int i = 0; i < NT_END; i++) { |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
792 |
this->SetMessageButtonStates(_news_type_data[i].display, i); |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
793 |
/* If the value doesn't match the ALL-button value, set the ALL-button value to 'off' */ |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
794 |
if (_news_type_data[i].display != all_val) all_val = ND_OFF; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
795 |
} |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
796 |
/* If all values are the same value, the ALL-button will take over this value */ |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
797 |
this->state = all_val; |
9333
2da01b3b71d8
(svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents:
9317
diff
changeset
|
798 |
|
2da01b3b71d8
(svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138
parents:
9317
diff
changeset
|
799 |
this->FindWindowPlacementAndResize(desc); |
9249
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
800 |
} |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
801 |
|
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
802 |
/** |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
803 |
* Setup the disabled/enabled buttons in the message window |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
804 |
* If the value is 'off' disable the [<] widget, and enable the [>] one |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
805 |
* Same-wise for all the others. Starting value of 4 is the first widget |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
806 |
* group. These are grouped as [<][>] .. [<][>], etc. |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
807 |
* @param value to set in the widget |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
808 |
* @param element index of the group of widget to set |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
809 |
*/ |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
810 |
void SetMessageButtonStates(byte value, int element) |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
811 |
{ |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
812 |
element *= NB_WIDG_PER_SETTING; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
813 |
|
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
814 |
this->SetWidgetDisabledState(element + WIDGET_NEWSOPT_START_OPTION, value == 0); |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
815 |
this->SetWidgetDisabledState(element + WIDGET_NEWSOPT_START_OPTION + 2, value == 2); |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
816 |
} |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
817 |
|
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
818 |
virtual void OnPaint() |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
819 |
{ |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
820 |
if (_news_ticker_sound) this->LowerWidget(WIDGET_NEWSOPT_SOUNDTICKER); |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
821 |
|
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
822 |
this->widget[WIDGET_NEWSOPT_DROP_SUMMARY].data = _message_opt[this->state]; |
9273
35e0224ea8f1
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
9249
diff
changeset
|
823 |
this->DrawWidgets(); |
9249
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
824 |
|
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
825 |
/* Draw the string of each setting on each button. */ |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
826 |
for (int i = 0, y = 26; i < NT_END; i++, y += 12) { |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
827 |
/* 51 comes from 13 + 89 (left and right of the button)+1, shiefted by one as to get division, |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
828 |
* which will give centered position */ |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
829 |
DrawStringCentered(51, y + 1, _message_opt[_news_type_data[i].display], TC_BLACK); |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
830 |
} |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
831 |
} |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
832 |
|
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
833 |
virtual void OnClick(Point pt, int widget) |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
834 |
{ |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
835 |
switch (widget) { |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
836 |
case WIDGET_NEWSOPT_DROP_SUMMARY: // Dropdown menu for all settings |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
837 |
ShowDropDownMenu(this, _message_opt, this->state, WIDGET_NEWSOPT_DROP_SUMMARY, 0, 0); |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
838 |
break; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
839 |
|
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
840 |
case WIDGET_NEWSOPT_SOUNDTICKER: // Change ticker sound on/off |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
841 |
_news_ticker_sound ^= 1; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
842 |
this->ToggleWidgetLoweredState(widget); |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
843 |
this->InvalidateWidget(widget); |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
844 |
break; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
845 |
|
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
846 |
default: { // Clicked on the [<] .. [>] widgets |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
847 |
int wid = widget - WIDGET_NEWSOPT_START_OPTION; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
848 |
if (wid >= 0 && wid < (NB_WIDG_PER_SETTING * NT_END)) { |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
849 |
int element = wid / NB_WIDG_PER_SETTING; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
850 |
byte val = (_news_type_data[element].display + ((wid % NB_WIDG_PER_SETTING) ? 1 : -1)) % 3; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
851 |
|
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
852 |
this->SetMessageButtonStates(val, element); |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
853 |
_news_type_data[element].display = (NewsDisplay)val; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
854 |
this->SetDirty(); |
9093 | 855 |
} |
9249
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
856 |
break; |
8776
1db57a00cba8
(svn r12475) -Codechange: cleanup coding style in news_gui.cpp.
rubidium
parents:
8763
diff
changeset
|
857 |
} |
9249
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
858 |
} |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
859 |
} |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
860 |
|
9249
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
861 |
virtual void OnDropdownSelect(int widget, int index) |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
862 |
{ |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
863 |
this->state = index; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
864 |
|
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
865 |
for (int i = 0; i < NT_END; i++) { |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
866 |
this->SetMessageButtonStates(index, i); |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
867 |
_news_type_data[i].display = (NewsDisplay)index; |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
868 |
} |
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
869 |
this->SetDirty(); |
0 | 870 |
} |
9249
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
871 |
}; |
0 | 872 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
873 |
|
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
874 |
/* |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
875 |
* The news settings window widgets |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
876 |
* |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
877 |
* Main part of the window is a list of news-setting lines, one for each news category. |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
878 |
* Each line is constructed by an expansion of the \c NEWS_SETTINGS_LINE macro |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
879 |
*/ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
880 |
|
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
881 |
/** |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
882 |
* Macro to construct one news-setting line in the news-settings window. |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
883 |
* One line consists of four widgets, namely |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
884 |
* - A [<] button |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
885 |
* - A [...] label |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
886 |
* - A [>] button |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
887 |
* - A text label describing the news category |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
888 |
* Horizontal positions of the widgets are hard-coded, vertical start position is (\a basey + \a linenum * \c NEWS_SETTING_BASELINE_SKIP). |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
889 |
* Height of one line is 12, with the text label shifted 1 pixel down. |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
890 |
* |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
891 |
* First line should be widget number WIDGET_NEWSOPT_START_OPTION |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
892 |
* |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
893 |
* @param basey: Base Y coordinate |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
894 |
* @param linenum: Count, news-setting is the \a linenum-th line |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
895 |
* @param text: StringID for the text label to display |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
896 |
*/ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
897 |
#define NEWS_SETTINGS_LINE(basey, linenum, text) \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
898 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_YELLOW, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
899 |
4, 12, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
900 |
SPR_ARROW_LEFT, STR_HSCROLL_BAR_SCROLLS_LIST}, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
901 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_YELLOW, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
902 |
13, 89, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
903 |
STR_EMPTY, STR_NULL}, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
904 |
{ WWT_PUSHIMGBTN, RESIZE_NONE, COLOUR_YELLOW, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
905 |
90, 98, basey + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 11 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
906 |
SPR_ARROW_RIGHT, STR_HSCROLL_BAR_SCROLLS_LIST}, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
907 |
{ WWT_TEXT, RESIZE_NONE, COLOUR_YELLOW, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
908 |
103, 409, basey + 1 + linenum * NEWS_SETTING_BASELINE_SKIP, basey + 13 + linenum * NEWS_SETTING_BASELINE_SKIP, \ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
909 |
text, STR_NULL} |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
910 |
|
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
911 |
static const int NEWS_SETTING_BASELINE_SKIP = 12; ///< Distance between two news-setting lines, should be at least 12 |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
912 |
|
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
913 |
|
0 | 914 |
static const Widget _message_options_widgets[] = { |
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
915 |
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_BROWN, 0, 10, 0, 13, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
916 |
STR_00C5, STR_018B_CLOSE_WINDOW}, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
917 |
{ WWT_CAPTION, RESIZE_NONE, COLOUR_BROWN, 11, 409, 0, 13, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
918 |
STR_0204_MESSAGE_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
919 |
{ WWT_PANEL, RESIZE_NONE, COLOUR_BROWN, 0, 409, 14, 64 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
920 |
0x0, STR_NULL}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4293
diff
changeset
|
921 |
|
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
922 |
/* Text at the top of the main panel, in black */ |
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
923 |
{ WWT_LABEL, RESIZE_NONE, COLOUR_BROWN, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
924 |
0, 409, 13, 26, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
925 |
STR_0205_MESSAGE_TYPES, STR_NULL}, |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
926 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
927 |
/* General drop down and sound button, widgets WIDGET_NEWSOPT_BTN_SUMMARY and WIDGET_NEWSOPT_DROP_SUMMARY */ |
8343
a6b70ddd862b
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8284
diff
changeset
|
928 |
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_YELLOW, |
a6b70ddd862b
(svn r11909) -Codechange: use dropdown widget for player livery, network lobby/setup and news settings windows
peter1138
parents:
8284
diff
changeset
|
929 |
4, 98, 34 + NT_END * NEWS_SETTING_BASELINE_SKIP, 45 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
930 |
0x0, STR_NULL}, |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
931 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
932 |
{ WWT_TEXT, RESIZE_NONE, COLOUR_YELLOW, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
933 |
103, 409, 35 + NT_END * NEWS_SETTING_BASELINE_SKIP, 47 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
934 |
STR_MESSAGES_ALL, STR_NULL}, |
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
935 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
936 |
/* Below is widget WIDGET_NEWSOPT_SOUNDTICKER */ |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
937 |
{ WWT_TEXTBTN_2, RESIZE_NONE, COLOUR_YELLOW, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
938 |
4, 98, 46 + NT_END * NEWS_SETTING_BASELINE_SKIP, 57 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
939 |
STR_02DB_OFF, STR_NULL}, |
6283
f9d97d412b0f
(svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents:
6279
diff
changeset
|
940 |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
941 |
{ WWT_TEXT, RESIZE_NONE, COLOUR_YELLOW, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
942 |
103, 409, 47 + NT_END * NEWS_SETTING_BASELINE_SKIP, 59 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
943 |
STR_MESSAGE_SOUND, STR_NULL}, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
944 |
|
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
945 |
/* List of news-setting lines (4 widgets for each line). |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
946 |
* First widget must be number WIDGET_NEWSOPT_START_OPTION |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
947 |
*/ |
9735 | 948 |
NEWS_SETTINGS_LINE(26, NT_ARRIVAL_PLAYER, STR_0206_ARRIVAL_OF_FIRST_VEHICLE), |
949 |
NEWS_SETTINGS_LINE(26, NT_ARRIVAL_OTHER, STR_0207_ARRIVAL_OF_FIRST_VEHICLE), |
|
950 |
NEWS_SETTINGS_LINE(26, NT_ACCIDENT, STR_0208_ACCIDENTS_DISASTERS), |
|
951 |
NEWS_SETTINGS_LINE(26, NT_COMPANY_INFO, STR_0209_COMPANY_INFORMATION), |
|
9739
9cf125da8789
(svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents:
9735
diff
changeset
|
952 |
NEWS_SETTINGS_LINE(26, NT_INDUSTRY_OPEN, STR_NEWS_INDUSTRY_OPEN), |
9cf125da8789
(svn r13872) -Feature: Split the news message announcing opening and closure of industries into two news of their own
belugas
parents:
9735
diff
changeset
|
953 |
NEWS_SETTINGS_LINE(26, NT_INDUSTRY_CLOSE, STR_NEWS_INDUSTRY_CLOSE), |
9735 | 954 |
NEWS_SETTINGS_LINE(26, NT_ECONOMY, STR_020A_ECONOMY_CHANGES), |
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
955 |
NEWS_SETTINGS_LINE(26, NT_INDUSTRY_PLAYER, STR_INDUSTRY_CHANGES_SERVED_BY_PLAYER), |
9735 | 956 |
NEWS_SETTINGS_LINE(26, NT_INDUSTRY_OTHER, STR_INDUSTRY_CHANGES_SERVED_BY_OTHER), |
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
957 |
NEWS_SETTINGS_LINE(26, NT_INDUSTRY_NOBODY, STR_OTHER_INDUSTRY_PRODUCTION_CHANGES), |
9735 | 958 |
NEWS_SETTINGS_LINE(26, NT_ADVICE, STR_020B_ADVICE_INFORMATION_ON_PLAYER), |
959 |
NEWS_SETTINGS_LINE(26, NT_NEW_VEHICLES, STR_020C_NEW_VEHICLES), |
|
960 |
NEWS_SETTINGS_LINE(26, NT_ACCEPTANCE, STR_020D_CHANGES_OF_CARGO_ACCEPTANCE), |
|
961 |
NEWS_SETTINGS_LINE(26, NT_SUBSIDIES, STR_020E_SUBSIDIES), |
|
962 |
NEWS_SETTINGS_LINE(26, NT_GENERAL, STR_020F_GENERAL_INFORMATION), |
|
6279
fdae79bd4dc7
(svn r9089) -Codechange: Remove the 32 widgets limit on News Options window.
belugas
parents:
6247
diff
changeset
|
963 |
|
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
102
diff
changeset
|
964 |
{ WIDGETS_END}, |
0 | 965 |
}; |
966 |
||
967 |
static const WindowDesc _message_options_desc = { |
|
7891
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
968 |
270, 22, 410, 65 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
aef0c16244d7
(svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents:
7854
diff
changeset
|
969 |
410, 65 + NT_END * NEWS_SETTING_BASELINE_SKIP, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5839
diff
changeset
|
970 |
WC_GAME_OPTIONS, WC_NONE, |
0 | 971 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
972 |
_message_options_widgets, |
|
973 |
}; |
|
974 |
||
6247 | 975 |
void ShowMessageOptions() |
0 | 976 |
{ |
977 |
DeleteWindowById(WC_GAME_OPTIONS, 0); |
|
9249
2b2f233edaed
(svn r13115) -Codechange: make a window subclass of the MessageOptionsWindow.
rubidium
parents:
9248
diff
changeset
|
978 |
new MessageOptionsWindow(&_message_options_desc); |
0 | 979 |
} |