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