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