tron@2186: /* $Id$ */ tron@2186: belugas@6674: /** @file news.h */ belugas@6674: truelight@0: #ifndef NEWS_H truelight@0: #define NEWS_H truelight@0: rubidium@8602: #include "window_type.h" rubidium@8615: #include "vehicle_type.h" rubidium@8634: #include "tile_type.h" rubidium@8636: #include "date_type.h" rubidium@8760: #include "strings_type.h" rubidium@8602: truelight@0: struct NewsItem { rubidium@8094: StringID string_id; ///< Message text (sometimes also used for storing other info) rubidium@8094: uint16 duration; ///< Remaining time for showing this news message rubidium@8094: Date date; ///< Date of the news rubidium@8094: byte flags; ///< NewsFlags bits @see NewsFlags rubidium@8094: byte display_mode; ///< Display mode value @see NewsMode rubidium@8094: byte type; ///< News category @see NewsType rubidium@8094: byte callback; ///< Call-back function truelight@0: rubidium@8094: TileIndex data_a; ///< Reference to tile or vehicle rubidium@8094: TileIndex data_b; ///< Reference to second tile or vehicle truelight@0: rubidium@7502: uint64 params[10]; truelight@0: }; truelight@0: dominik@715: typedef bool ValidationProc ( uint data_a, uint data_b ); dominik@715: typedef void DrawNewsCallbackProc(Window *w); Darkvater@2101: typedef StringID GetNewsStringCallbackProc(const NewsItem *ni); truelight@0: rubidium@8094: /** rubidium@8094: * Macro for creating news flags. rubidium@8094: * @param mode (bits 0 - 7) Display_mode, one of the NewsMode enums (NM_) rubidium@8094: * @param flag (bits 8 - 15) OR-able news flags, any of the NewsFlags enums (NF_) rubidium@8094: * @param type (bits 16-23) News category, one of the NewsType enums (NT_) rubidium@8094: * @param cb (bits 24-31) Call-back function, one of the NewsCallback enums (DNC_) or 0 if no callback rubidium@8094: * @see NewsMode rubidium@8094: * @see NewsFlags rubidium@8094: * @see NewsType rubidium@8094: * @see NewsCallback rubidium@8094: * @see AddNewsItem rubidium@8094: */ rubidium@6987: #define NEWS_FLAGS(mode, flag, type, cb) ((cb) << 24 | (type) << 16 | (flag) << 8 | (mode)) rubidium@8094: truelight@0: void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b); rubidium@6573: void NewsLoop(); tron@427: void DrawNewsBorder(const Window *w); rubidium@6573: void InitNewsItemStructs(); truelight@0: rubidium@8764: extern NewsItem _statusbar_news_item; rubidium@8766: extern uint32 _news_display_opt; rubidium@8766: extern bool _news_ticker_sound; truelight@0: rubidium@8094: /** Type of news. */ Darkvater@4873: enum NewsType { rubidium@8094: NT_ARRIVAL_PLAYER, ///< Cargo arrived for player rubidium@8094: NT_ARRIVAL_OTHER, ///< Cargo arrived for competitor rubidium@8094: NT_ACCIDENT, ///< An accident or disaster has occurred rubidium@8094: NT_COMPANY_INFO, ///< Company info (new companies, bankrupcy messages) rubidium@8094: NT_OPENCLOSE, ///< Opening and closing of industries rubidium@8094: NT_ECONOMY, ///< Economic changes (recession, industry up/dowm) rubidium@8387: NT_INDUSTRY_PLAYER, ///< Production changes of industry serviced by local player rubidium@8387: NT_INDUSTRY_OTHER, ///< Production changes of industry serviced by competitor(s) rubidium@8387: NT_INDUSTRY_NOBODY, ///< Other industry production changes rubidium@8094: NT_ADVICE, ///< Bits of news about vehicles of the player rubidium@8094: NT_NEW_VEHICLES, ///< New vehicle has become available rubidium@8094: NT_ACCEPTANCE, ///< A type of cargo is (no longer) accepted rubidium@8094: NT_SUBSIDIES, ///< News about subsidies (announcements, expirations, acceptance) rubidium@8094: NT_GENERAL, ///< General news (from towns) rubidium@8094: NT_END, ///< end-of-array marker truelight@0: }; truelight@0: truelight@6609: extern const char *_news_display_name[NT_END]; truelight@6609: rubidium@8094: /** rubidium@8094: * News mode. rubidium@8094: * @see NEWS_FLAGS rubidium@8094: */ truelight@0: enum NewsMode { Darkvater@4873: NM_SMALL = 0, ///< Show only a small popup informing us about vehicle age for example Darkvater@4873: NM_NORMAL = 1, ///< Show a simple news message (height 170 pixels) Darkvater@4873: NM_THIN = 2, ///< Show a simple news message (height 130 pixels) Darkvater@4873: NM_CALLBACK = 3, ///< Do some special processing before displaying news message. Which callback to call is in NewsCallback truelight@0: }; truelight@0: rubidium@8094: /** rubidium@8094: * Various OR-able news-item flags. rubidium@8094: * note: NF_INCOLOR is set automatically if needed rubidium@8094: * @see NEWS_FLAGS rubidium@8094: */ truelight@0: enum NewsFlags { Darkvater@4873: NF_VIEWPORT = (1 << 1), ///< Does the news message have a viewport? (ingame picture of happening) Darkvater@4873: NF_TILE = (1 << 2), ///< When clicked on the news message scroll to a given tile? Tile is in data_a/data_b Darkvater@4873: NF_VEHICLE = (1 << 3), ///< When clicked on the message scroll to the vehicle? VehicleID is in data_a Darkvater@4873: NF_FORCE_BIG = (1 << 4), ///< Force the appearance of a news message if it has already been shown (internal) Darkvater@4874: NF_INCOLOR = (1 << 5), ///< Show the newsmessage in colour, otherwise it defaults to black & white truelight@0: }; truelight@0: rubidium@8094: /** Special news items */ Darkvater@4873: enum NewsCallback { rubidium@6535: DNC_VEHICLEAVAIL = 0, ///< Show new vehicle available message. StringID is EngineID rubidium@6535: DNC_BANKRUPCY = 1, ///< Show bankrupcy message. StringID is PlayerID (0-3) and NewsBankrupcy (4-7) Darkvater@4873: }; Darkvater@4873: rubidium@8094: /** Kinds of bankrupcy */ Darkvater@4873: enum NewsBankrupcy { Darkvater@4873: NB_BTROUBLE = (1 << 4), ///< Company is in trouble (warning) Darkvater@4873: NB_BMERGER = (2 << 4), ///< Company has been bought by another company Darkvater@4873: NB_BBANKRUPT = (3 << 4), ///< Company has gone bankrupt Darkvater@4873: NB_BNEWCOMPANY = (4 << 4), ///< A new company has been started truelight@0: }; truelight@0: tron@3139: /** tron@3139: * Delete a news item type about a vehicle tron@3139: * if the news item type is INVALID_STRING_ID all news about the vehicle get tron@3139: * deleted tron@3139: */ tron@3139: void DeleteVehicleNews(VehicleID, StringID news); tron@3139: truelight@0: #endif /* NEWS_H */