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