src/news.h
author peter1138
Tue, 12 Feb 2008 13:23:57 +0000
changeset 8544 47b99dc2da26
parent 8270 e7c342f6b14c
permissions -rw-r--r--
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2101
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2101
diff changeset
     2
6348
6dd01da7a02b (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6283
diff changeset
     3
/** @file news.h */
6dd01da7a02b (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6283
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#ifndef NEWS_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#define NEWS_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
8106
e6790dd9e750 (svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
rubidium
parents: 7891
diff changeset
     8
#include "window_type.h"
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8106
diff changeset
     9
#include "vehicle_type.h"
8138
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8119
diff changeset
    10
#include "tile_type.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8138
diff changeset
    11
#include "date_type.h"
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8140
diff changeset
    12
#include "strings_type.h"
8106
e6790dd9e750 (svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
rubidium
parents: 7891
diff changeset
    13
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
struct NewsItem {
7598
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    15
	StringID string_id; ///< Message text (sometimes also used for storing other info)
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    16
	uint16 duration;    ///< Remaining time for showing this news message
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    17
	Date date;          ///< Date of the news
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    18
	byte flags;         ///< NewsFlags bits @see NewsFlags
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    19
	byte display_mode;  ///< Display mode value @see NewsMode
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    20
	byte type;          ///< News category @see NewsType
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    21
	byte callback;      ///< Call-back function
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
7598
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    23
	TileIndex data_a;   ///< Reference to tile or vehicle
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    24
	TileIndex data_b;   ///< Reference to second tile or vehicle
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
7006
bfa3974da32b (svn r10262) -Fix (r10258): some places that needed to be changed to uint64 were hidden/forgotten, which caused memory corruptions and that in caused all kinds of assertions to trigger.
rubidium
parents: 6491
diff changeset
    26
	uint64 params[10];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
715
28dd55cc55ae (svn r1167) Feature: Added the possibility to add validation functions to NewsItems. This is now done for "Train in depot" messages. Before displaying such a message, it checks if the train really still is in the depot. Can be applied to other news items as well.
dominik
parents: 427
diff changeset
    29
typedef bool ValidationProc ( uint data_a, uint data_b );
28dd55cc55ae (svn r1167) Feature: Added the possibility to add validation functions to NewsItems. This is now done for "Train in depot" messages. Before displaying such a message, it checks if the train really still is in the depot. Can be applied to other news items as well.
dominik
parents: 427
diff changeset
    30
typedef void DrawNewsCallbackProc(Window *w);
2101
822f0b48ce64 (svn r2611) - CodeChange: use standardized truncutation with the newsmessage-history window as well
Darkvater
parents: 715
diff changeset
    31
typedef StringID GetNewsStringCallbackProc(const NewsItem *ni);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
7598
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    33
/**
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    34
 * Macro for creating news flags.
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    35
 * @param mode (bits 0 - 7) Display_mode, one of the NewsMode enums (NM_)
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    36
 * @param flag (bits 8 - 15) OR-able news flags, any of the NewsFlags enums (NF_)
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    37
 * @param type (bits 16-23) News category, one of the NewsType enums (NT_)
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    38
 * @param cb (bits 24-31) Call-back function, one of the NewsCallback enums (DNC_) or 0 if no callback
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    39
 * @see NewsMode
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    40
 * @see NewsFlags
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    41
 * @see NewsType
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    42
 * @see NewsCallback
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    43
 * @see AddNewsItem
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    44
 */
6491
00dc414c909d (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6348
diff changeset
    45
#define NEWS_FLAGS(mode, flag, type, cb) ((cb) << 24 | (type) << 16 | (flag) << 8 | (mode))
7598
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    46
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6209
diff changeset
    48
void NewsLoop();
427
1f488221b3d9 (svn r626) Merge r438 to trunk:
tron
parents: 0
diff changeset
    49
void DrawNewsBorder(const Window *w);
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6209
diff changeset
    50
void InitNewsItemStructs();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
8268
5027ad5e70a0 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents: 8264
diff changeset
    52
extern NewsItem _statusbar_news_item;
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8268
diff changeset
    53
extern uint32 _news_display_opt;
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8268
diff changeset
    54
extern bool _news_ticker_sound;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
7598
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    56
/** Type of news. */
4873
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
    57
enum NewsType {
7598
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    58
	NT_ARRIVAL_PLAYER,  ///< Cargo arrived for player
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    59
	NT_ARRIVAL_OTHER,   ///< Cargo arrived for competitor
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    60
	NT_ACCIDENT,        ///< An accident or disaster has occurred
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    61
	NT_COMPANY_INFO,    ///< Company info (new companies, bankrupcy messages)
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    62
	NT_OPENCLOSE,       ///< Opening and closing of industries
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    63
	NT_ECONOMY,         ///< Economic changes (recession, industry up/dowm)
7891
aef0c16244d7 (svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents: 7598
diff changeset
    64
	NT_INDUSTRY_PLAYER, ///< Production changes of industry serviced by local player
aef0c16244d7 (svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents: 7598
diff changeset
    65
	NT_INDUSTRY_OTHER,  ///< Production changes of industry serviced by competitor(s)
aef0c16244d7 (svn r11442) -Feature: make news messages related to the industry (production) changes better configurable; you can now disable news messages popping up for industries you are not servicing. Patch by Alberth.
rubidium
parents: 7598
diff changeset
    66
	NT_INDUSTRY_NOBODY, ///< Other industry production changes
7598
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    67
	NT_ADVICE,          ///< Bits of news about vehicles of the player
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    68
	NT_NEW_VEHICLES,    ///< New vehicle has become available
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    69
	NT_ACCEPTANCE,      ///< A type of cargo is (no longer) accepted
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    70
	NT_SUBSIDIES,       ///< News about subsidies (announcements, expirations, acceptance)
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    71
	NT_GENERAL,         ///< General news (from towns)
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    72
	NT_END,             ///< end-of-array marker
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
6283
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6279
diff changeset
    75
extern const char *_news_display_name[NT_END];
f9d97d412b0f (svn r9097) -Fix [FS#525]: open and close messages now have their own setting, so you can hide economy changes, but do show open/close of industries
truelight
parents: 6279
diff changeset
    76
7598
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    77
/**
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    78
 * News mode.
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    79
 * @see NEWS_FLAGS
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    80
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
enum NewsMode {
4873
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
    82
	NM_SMALL    = 0, ///< Show only a small popup informing us about vehicle age for example
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
    83
	NM_NORMAL   = 1, ///< Show a simple news message (height 170 pixels)
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
    84
	NM_THIN     = 2, ///< Show a simple news message (height 130 pixels)
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
    85
	NM_CALLBACK = 3, ///< Do some special processing before displaying news message. Which callback to call is in NewsCallback
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
7598
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    88
/**
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    89
 * Various OR-able news-item flags.
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    90
 * note: NF_INCOLOR is set automatically if needed
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    91
 * @see NEWS_FLAGS
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
    92
 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
enum NewsFlags {
4873
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
    94
	NF_VIEWPORT  = (1 << 1), ///< Does the news message have a viewport? (ingame picture of happening)
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
    95
	NF_TILE      = (1 << 2), ///< When clicked on the news message scroll to a given tile? Tile is in data_a/data_b
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
    96
	NF_VEHICLE   = (1 << 3), ///< When clicked on the message scroll to the vehicle? VehicleID is in data_a
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
    97
	NF_FORCE_BIG = (1 << 4), ///< Force the appearance of a news message if it has already been shown (internal)
4874
afafed841c6d (svn r6804) -Codechange: Remove the unused NF_NOEXPIRE flag.
Darkvater
parents: 4873
diff changeset
    98
	NF_INCOLOR   = (1 << 5), ///< Show the newsmessage in colour, otherwise it defaults to black & white
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
7598
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
   101
/** Special news items */
4873
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
   102
enum NewsCallback {
6209
3a1a90cd67f3 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents: 5475
diff changeset
   103
	DNC_VEHICLEAVAIL  = 0, ///< Show new vehicle available message. StringID is EngineID
3a1a90cd67f3 (svn r9001) -Codechange: remove duplication of functions and strings with respect to the news of new vehicles.
rubidium
parents: 5475
diff changeset
   104
	DNC_BANKRUPCY     = 1, ///< Show bankrupcy message. StringID is PlayerID (0-3) and NewsBankrupcy (4-7)
4873
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
   105
};
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
   106
7598
626c6a804e6d (svn r11125) -Documentation: add/update the documentation of news*. Based on a patch by Progman.
rubidium
parents: 7006
diff changeset
   107
/** Kinds of bankrupcy */
4873
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
   108
enum NewsBankrupcy {
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
   109
	NB_BTROUBLE    = (1 << 4), ///< Company is in trouble (warning)
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
   110
	NB_BMERGER     = (2 << 4), ///< Company has been bought by another company
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
   111
	NB_BBANKRUPT   = (3 << 4), ///< Company has gone bankrupt
11880cbbc9f6 (svn r6803) -Codechange: Substitute magic numbers by an enum for the news windows
Darkvater
parents: 4344
diff changeset
   112
	NB_BNEWCOMPANY = (4 << 4), ///< A new company has been started
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
3139
b17abef09e15 (svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents: 2186
diff changeset
   115
/**
b17abef09e15 (svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents: 2186
diff changeset
   116
 * Delete a news item type about a vehicle
b17abef09e15 (svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents: 2186
diff changeset
   117
 * if the news item type is INVALID_STRING_ID all news about the vehicle get
b17abef09e15 (svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents: 2186
diff changeset
   118
 * deleted
b17abef09e15 (svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents: 2186
diff changeset
   119
 */
b17abef09e15 (svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents: 2186
diff changeset
   120
void DeleteVehicleNews(VehicleID, StringID news);
b17abef09e15 (svn r3757) -Feature: Delete news items about vehicles, when they get stale
tron
parents: 2186
diff changeset
   121
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
#endif /* NEWS_H */