2009-08-21 20:21:05 +00:00
/*
* This file is part of OpenTTD .
* OpenTTD is free software ; you can redistribute it and / or modify it under the terms of the GNU General Public License as published by the Free Software Foundation , version 2.
* OpenTTD is distributed in the hope that it will be useful , but WITHOUT ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
* See the GNU General Public License for more details . You should have received a copy of the GNU General Public License along with OpenTTD . If not , see < http : //www.gnu.org/licenses/>.
*/
2008-03-28 08:53:36 +00:00
/** @file news_type.h Types related to news. */
# ifndef NEWS_TYPE_H
# define NEWS_TYPE_H
2009-05-17 17:17:48 +00:00
# include "core/enum_type.hpp"
2008-03-28 08:53:36 +00:00
# include "date_type.h"
# include "strings_type.h"
2008-04-19 12:50:02 +00:00
# include "sound_type.h"
2008-03-28 08:53:36 +00:00
/**
* Type of news .
*/
enum NewsType {
2012-05-26 14:16:03 +00:00
NT_ARRIVAL_COMPANY , ///< First vehicle arrived for company
NT_ARRIVAL_OTHER , ///< First vehicle arrived for competitor
2008-03-28 08:53:36 +00:00
NT_ACCIDENT , ///< An accident or disaster has occurred
2009-09-01 12:28:46 +00:00
NT_COMPANY_INFO , ///< Company info (new companies, bankruptcy messages)
2008-07-30 01:53:03 +00:00
NT_INDUSTRY_OPEN , ///< Opening of industries
NT_INDUSTRY_CLOSE , ///< Closing of industries
2008-03-28 08:53:36 +00:00
NT_ECONOMY , ///< Economic changes (recession, industry up/dowm)
2008-09-30 20:39:50 +00:00
NT_INDUSTRY_COMPANY , ///< Production changes of industry serviced by local company
2008-03-28 08:53:36 +00:00
NT_INDUSTRY_OTHER , ///< Production changes of industry serviced by competitor(s)
NT_INDUSTRY_NOBODY , ///< Other industry production changes
2008-09-30 20:39:50 +00:00
NT_ADVICE , ///< Bits of news about vehicles of the company
2008-03-28 08:53:36 +00:00
NT_NEW_VEHICLES , ///< New vehicle has become available
NT_ACCEPTANCE , ///< A type of cargo is (no longer) accepted
NT_SUBSIDIES , ///< News about subsidies (announcements, expirations, acceptance)
NT_GENERAL , ///< General news (from towns)
NT_END , ///< end-of-array marker
} ;
2009-05-24 16:52:42 +00:00
/**
* References to objects in news .
2009-08-10 20:06:39 +00:00
*
* @ warning
* Be careful !
* Vehicles are a special case , as news are kept when vehicles are autoreplaced / renewed .
* You have to make sure , # ChangeVehicleNews catches the DParams of your message .
* This is NOT ensured by the references .
2009-05-24 16:52:42 +00:00
*/
enum NewsReferenceType {
NR_NONE , ///< Empty reference
NR_TILE , ///< Reference tile. Scroll to tile when clicking on the news.
NR_VEHICLE , ///< Reference vehicle. Scroll to vehicle when clicking on the news. Delete news when vehicle is deleted.
NR_STATION , ///< Reference station. Scroll to station when clicking on the news. Delete news when station is deleted.
NR_INDUSTRY , ///< Reference industry. Scroll to industry when clicking on the news. Delete news when industry is deleted.
NR_TOWN , ///< Reference town. Scroll to town when clicking on the news.
2011-12-19 17:48:04 +00:00
NR_ENGINE , ///< Reference engine.
2009-05-24 16:52:42 +00:00
} ;
2008-03-28 08:53:36 +00:00
/**
* Various OR - able news - item flags .
2009-08-16 07:31:36 +00:00
* @ note # NF_INCOLOUR is set automatically if needed .
2008-03-28 08:53:36 +00:00
*/
enum NewsFlag {
2012-05-26 14:16:03 +00:00
NFB_INCOLOUR = 0 , ///< News item is shown in colour (otherwise it is shown in black & white).
NFB_NO_TRANSPARENT = 1 , ///< News item disables transparency in the viewport.
NFB_SHADE = 2 , ///< News item uses shaded colours.
NFB_WINDOW_LAYOUT = 3 , ///< First bit for window layout.
NFB_WINDOW_LAYOUT_COUNT = 3 , ///< Number of bits for window layout.
2012-05-26 14:16:07 +00:00
NFB_VEHICLE_PARAM0 = 6 , ///< String param 0 contains a vehicle ID. (special autoreplace behaviour)
2012-05-26 14:16:03 +00:00
NF_INCOLOUR = 1 < < NFB_INCOLOUR , ///< Bit value for coloured news.
NF_NO_TRANSPARENT = 1 < < NFB_NO_TRANSPARENT , ///< Bit value for disabling transparency.
NF_SHADE = 1 < < NFB_SHADE , ///< Bit value for enabling shading.
2012-05-26 14:16:07 +00:00
NF_VEHICLE_PARAM0 = 1 < < NFB_VEHICLE_PARAM0 , ///< Bit value for specifying that string param 0 contains a vehicle ID. (special autoreplace behaviour)
2012-05-26 14:16:03 +00:00
NF_THIN = 0 < < NFB_WINDOW_LAYOUT , ///< Thin news item. (Newspaper with headline and viewport)
NF_SMALL = 1 < < NFB_WINDOW_LAYOUT , ///< Small news item. (Information window with text and viewport)
NF_NORMAL = 2 < < NFB_WINDOW_LAYOUT , ///< Normal news item. (Newspaper with text only)
NF_VEHICLE = 3 < < NFB_WINDOW_LAYOUT , ///< Vehicle news item. (new engine available)
NF_COMPANY = 4 < < NFB_WINDOW_LAYOUT , ///< Company news item. (Newspaper with face)
2008-03-28 08:53:36 +00:00
} ;
2010-03-23 22:25:43 +00:00
DECLARE_ENUM_AS_BIT_SET ( NewsFlag )
2008-03-28 08:53:36 +00:00
2008-04-20 11:40:33 +00:00
/**
* News display options
*/
enum NewsDisplay {
ND_OFF , ///< Only show a reminder in the status bar
ND_SUMMARY , ///< Show ticker
ND_FULL , ///< Show newspaper
} ;
2008-04-19 12:50:02 +00:00
/**
* Per - NewsType data
*/
struct NewsTypeData {
2009-05-13 17:39:00 +00:00
const char * const name ; ///< Name
const byte age ; ///< Maximum age of news items (in days)
const SoundFx sound ; ///< Sound
2011-05-02 16:14:23 +00:00
/**
* Construct this entry .
* @ param name The name of the type .
* @ param age The maximum age for these messages .
* @ param sound The sound to play .
*/
2012-12-23 21:07:12 +00:00
NewsTypeData ( const char * name , byte age , SoundFx sound ) :
2009-05-13 17:39:00 +00:00
name ( name ) ,
age ( age ) ,
2012-12-23 21:07:12 +00:00
sound ( sound )
2009-05-13 17:39:00 +00:00
{
}
2012-12-23 21:07:12 +00:00
NewsDisplay GetDisplay ( ) const ;
2008-04-19 12:50:02 +00:00
} ;
2011-05-02 16:14:23 +00:00
/** Information about a single item of news. */
2008-03-28 08:53:36 +00:00
struct NewsItem {
2009-05-24 16:52:42 +00:00
NewsItem * prev ; ///< Previous news item
NewsItem * next ; ///< Next news item
StringID string_id ; ///< Message text
Date date ; ///< Date of the news
2012-05-26 14:16:03 +00:00
NewsType type ; ///< Type of the news
2009-05-24 16:52:42 +00:00
NewsFlag flags ; ///< NewsFlags bits @see NewsFlag
NewsReferenceType reftype1 ; ///< Type of ref1
NewsReferenceType reftype2 ; ///< Type of ref2
2019-09-29 20:27:32 +00:00
uint32 ref1 ; ///< Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleting the news when the object is deleted.
uint32 ref2 ; ///< Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.
2009-05-24 16:52:42 +00:00
void * free_data ; ///< Data to be freed when the news item has reached its end.
2008-07-18 16:26:51 +00:00
2010-02-12 16:42:29 +00:00
~ NewsItem ( )
{
free ( this - > free_data ) ;
}
2011-05-02 16:14:23 +00:00
uint64 params [ 10 ] ; ///< Parameters for string resolving.
2008-03-28 08:53:36 +00:00
} ;
2008-07-18 16:26:51 +00:00
/**
* Data that needs to be stored for company news messages .
* The problem with company news messages are the custom name
* of the companies and the fact that the company data is reset ,
* resulting in wrong names and such .
*/
struct CompanyNewsInformation {
char company_name [ 64 ] ; ///< The name of the company
char president_name [ 64 ] ; ///< The name of the president
char other_company_name [ 64 ] ; ///< The name of the company taking over this one
uint32 face ; ///< The face of the president
byte colour ; ///< The colour related to the company
2019-04-10 21:07:06 +00:00
void FillData ( const struct Company * c , const struct Company * other = nullptr ) ;
2008-07-18 16:26:51 +00:00
} ;
2008-03-28 08:53:36 +00:00
# endif /* NEWS_TYPE_H */