src/news.h
branchnoai
changeset 9703 d2a6acdbd665
parent 9629 66dde6412125
child 6871 5a9dc001e1ad
equal deleted inserted replaced
9702:e782b59f1f6a 9703:d2a6acdbd665
     4 
     4 
     5 #ifndef NEWS_H
     5 #ifndef NEWS_H
     6 #define NEWS_H
     6 #define NEWS_H
     7 
     7 
     8 struct NewsItem {
     8 struct NewsItem {
     9 	StringID string_id;
     9 	StringID string_id; ///< Message text (sometimes also used for storing other info)
    10 	uint16 duration;
    10 	uint16 duration;    ///< Remaining time for showing this news message
    11 	Date date;
    11 	Date date;          ///< Date of the news
    12 	byte flags;
    12 	byte flags;         ///< NewsFlags bits @see NewsFlags
    13 	byte display_mode;
    13 	byte display_mode;  ///< Display mode value @see NewsMode
    14 	byte type;
    14 	byte type;          ///< News category @see NewsType
    15 	byte callback;
    15 	byte callback;      ///< Call-back function
    16 
    16 
    17 	TileIndex data_a;
    17 	TileIndex data_a;   ///< Reference to tile or vehicle
    18 	TileIndex data_b;
    18 	TileIndex data_b;   ///< Reference to second tile or vehicle
    19 
    19 
    20 	uint64 params[10];
    20 	uint64 params[10];
    21 };
    21 };
    22 
    22 
    23 typedef bool ValidationProc ( uint data_a, uint data_b );
    23 typedef bool ValidationProc ( uint data_a, uint data_b );
    24 typedef void DrawNewsCallbackProc(Window *w);
    24 typedef void DrawNewsCallbackProc(Window *w);
    25 typedef StringID GetNewsStringCallbackProc(const NewsItem *ni);
    25 typedef StringID GetNewsStringCallbackProc(const NewsItem *ni);
    26 
    26 
       
    27 /**
       
    28  * Macro for creating news flags.
       
    29  * @param mode (bits 0 - 7) Display_mode, one of the NewsMode enums (NM_)
       
    30  * @param flag (bits 8 - 15) OR-able news flags, any of the NewsFlags enums (NF_)
       
    31  * @param type (bits 16-23) News category, one of the NewsType enums (NT_)
       
    32  * @param cb (bits 24-31) Call-back function, one of the NewsCallback enums (DNC_) or 0 if no callback
       
    33  * @see NewsMode
       
    34  * @see NewsFlags
       
    35  * @see NewsType
       
    36  * @see NewsCallback
       
    37  * @see AddNewsItem
       
    38  */
    27 #define NEWS_FLAGS(mode, flag, type, cb) ((cb) << 24 | (type) << 16 | (flag) << 8 | (mode))
    39 #define NEWS_FLAGS(mode, flag, type, cb) ((cb) << 24 | (type) << 16 | (flag) << 8 | (mode))
       
    40 
    28 void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b);
    41 void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b);
    29 void NewsLoop();
    42 void NewsLoop();
    30 void DrawNewsBorder(const Window *w);
    43 void DrawNewsBorder(const Window *w);
    31 void InitNewsItemStructs();
    44 void InitNewsItemStructs();
    32 
    45 
    33 VARDEF NewsItem _statusbar_news_item;
    46 VARDEF NewsItem _statusbar_news_item;
    34 
    47 
       
    48 /** Type of news. */
    35 enum NewsType {
    49 enum NewsType {
    36 	NT_ARRIVAL_PLAYER,
    50 	NT_ARRIVAL_PLAYER,  ///< Cargo arrived for player
    37 	NT_ARRIVAL_OTHER,
    51 	NT_ARRIVAL_OTHER,   ///< Cargo arrived for competitor
    38 	NT_ACCIDENT,
    52 	NT_ACCIDENT,        ///< An accident or disaster has occurred
    39 	NT_COMPANY_INFO,
    53 	NT_COMPANY_INFO,    ///< Company info (new companies, bankrupcy messages)
    40 	NT_OPENCLOSE,
    54 	NT_OPENCLOSE,       ///< Opening and closing of industries
    41 	NT_ECONOMY,
    55 	NT_ECONOMY,         ///< Economic changes (recession, industry up/dowm)
    42 	NT_ADVICE,
    56 	NT_ADVICE,          ///< Bits of news about vehicles of the player
    43 	NT_NEW_VEHICLES,
    57 	NT_NEW_VEHICLES,    ///< New vehicle has become available
    44 	NT_ACCEPTANCE,
    58 	NT_ACCEPTANCE,      ///< A type of cargo is (no longer) accepted
    45 	NT_SUBSIDIES,
    59 	NT_SUBSIDIES,       ///< News about subsidies (announcements, expirations, acceptance)
    46 	NT_GENERAL,
    60 	NT_GENERAL,         ///< General news (from towns)
    47 	NT_END,
    61 	NT_END,             ///< end-of-array marker
    48 };
    62 };
    49 
    63 
    50 extern const char *_news_display_name[NT_END];
    64 extern const char *_news_display_name[NT_END];
    51 
    65 
       
    66 /**
       
    67  * News mode.
       
    68  * @see NEWS_FLAGS
       
    69  */
    52 enum NewsMode {
    70 enum NewsMode {
    53 	NM_SMALL    = 0, ///< Show only a small popup informing us about vehicle age for example
    71 	NM_SMALL    = 0, ///< Show only a small popup informing us about vehicle age for example
    54 	NM_NORMAL   = 1, ///< Show a simple news message (height 170 pixels)
    72 	NM_NORMAL   = 1, ///< Show a simple news message (height 170 pixels)
    55 	NM_THIN     = 2, ///< Show a simple news message (height 130 pixels)
    73 	NM_THIN     = 2, ///< Show a simple news message (height 130 pixels)
    56 	NM_CALLBACK = 3, ///< Do some special processing before displaying news message. Which callback to call is in NewsCallback
    74 	NM_CALLBACK = 3, ///< Do some special processing before displaying news message. Which callback to call is in NewsCallback
    57 };
    75 };
    58 
    76 
       
    77 /**
       
    78  * Various OR-able news-item flags.
       
    79  * note: NF_INCOLOR is set automatically if needed
       
    80  * @see NEWS_FLAGS
       
    81  */
    59 enum NewsFlags {
    82 enum NewsFlags {
    60 	NF_VIEWPORT  = (1 << 1), ///< Does the news message have a viewport? (ingame picture of happening)
    83 	NF_VIEWPORT  = (1 << 1), ///< Does the news message have a viewport? (ingame picture of happening)
    61 	NF_TILE      = (1 << 2), ///< When clicked on the news message scroll to a given tile? Tile is in data_a/data_b
    84 	NF_TILE      = (1 << 2), ///< When clicked on the news message scroll to a given tile? Tile is in data_a/data_b
    62 	NF_VEHICLE   = (1 << 3), ///< When clicked on the message scroll to the vehicle? VehicleID is in data_a
    85 	NF_VEHICLE   = (1 << 3), ///< When clicked on the message scroll to the vehicle? VehicleID is in data_a
    63 	NF_FORCE_BIG = (1 << 4), ///< Force the appearance of a news message if it has already been shown (internal)
    86 	NF_FORCE_BIG = (1 << 4), ///< Force the appearance of a news message if it has already been shown (internal)
    64 	NF_INCOLOR   = (1 << 5), ///< Show the newsmessage in colour, otherwise it defaults to black & white
    87 	NF_INCOLOR   = (1 << 5), ///< Show the newsmessage in colour, otherwise it defaults to black & white
    65 };
    88 };
    66 
    89 
       
    90 /** Special news items */
    67 enum NewsCallback {
    91 enum NewsCallback {
    68 	DNC_VEHICLEAVAIL  = 0, ///< Show new vehicle available message. StringID is EngineID
    92 	DNC_VEHICLEAVAIL  = 0, ///< Show new vehicle available message. StringID is EngineID
    69 	DNC_BANKRUPCY     = 1, ///< Show bankrupcy message. StringID is PlayerID (0-3) and NewsBankrupcy (4-7)
    93 	DNC_BANKRUPCY     = 1, ///< Show bankrupcy message. StringID is PlayerID (0-3) and NewsBankrupcy (4-7)
    70 };
    94 };
    71 
    95 
       
    96 /** Kinds of bankrupcy */
    72 enum NewsBankrupcy {
    97 enum NewsBankrupcy {
    73 	NB_BTROUBLE    = (1 << 4), ///< Company is in trouble (warning)
    98 	NB_BTROUBLE    = (1 << 4), ///< Company is in trouble (warning)
    74 	NB_BMERGER     = (2 << 4), ///< Company has been bought by another company
    99 	NB_BMERGER     = (2 << 4), ///< Company has been bought by another company
    75 	NB_BBANKRUPT   = (3 << 4), ///< Company has gone bankrupt
   100 	NB_BBANKRUPT   = (3 << 4), ///< Company has gone bankrupt
    76 	NB_BNEWCOMPANY = (4 << 4), ///< A new company has been started
   101 	NB_BNEWCOMPANY = (4 << 4), ///< A new company has been started