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_func.h Functions related to news. */
|
|
|
|
|
|
|
|
#ifndef NEWS_FUNC_H
|
|
|
|
#define NEWS_FUNC_H
|
|
|
|
|
|
|
|
#include "news_type.h"
|
|
|
|
#include "vehicle_type.h"
|
2008-09-13 10:19:51 +00:00
|
|
|
#include "station_type.h"
|
2009-05-24 16:52:42 +00:00
|
|
|
#include "industry_type.h"
|
|
|
|
|
2021-06-16 15:50:18 +00:00
|
|
|
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1 = NR_NONE, uint32 ref1 = UINT32_MAX, NewsReferenceType reftype2 = NR_NONE, uint32 ref2 = UINT32_MAX, const NewsAllocatedData *data = nullptr);
|
2009-05-24 16:52:42 +00:00
|
|
|
|
2012-05-26 14:15:46 +00:00
|
|
|
static inline void AddCompanyNewsItem(StringID string, CompanyNewsInformation *cni)
|
2009-05-24 16:52:42 +00:00
|
|
|
{
|
2012-05-26 14:16:03 +00:00
|
|
|
AddNewsItem(string, NT_COMPANY_INFO, NF_COMPANY, NR_NONE, UINT32_MAX, NR_NONE, UINT32_MAX, cni);
|
2009-05-24 16:52:42 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 20:06:39 +00:00
|
|
|
/**
|
|
|
|
* Adds a newsitem referencing a vehicle.
|
|
|
|
*
|
2012-05-26 14:15:52 +00:00
|
|
|
* @warning The DParams may not reference the vehicle due to autoreplace stuff. See AddVehicleAdviceNewsItem for how that can be done.
|
2009-08-10 20:06:39 +00:00
|
|
|
*/
|
2012-05-26 14:16:03 +00:00
|
|
|
static inline void AddVehicleNewsItem(StringID string, NewsType type, VehicleID vehicle, StationID station = INVALID_STATION)
|
2009-05-24 16:52:42 +00:00
|
|
|
{
|
2012-05-26 14:16:03 +00:00
|
|
|
AddNewsItem(string, type, NF_NO_TRANSPARENT | NF_SHADE | NF_THIN, NR_VEHICLE, vehicle, station == INVALID_STATION ? NR_NONE : NR_STATION, station);
|
2009-05-24 16:52:42 +00:00
|
|
|
}
|
|
|
|
|
2012-05-26 14:15:52 +00:00
|
|
|
/**
|
|
|
|
* Adds a vehicle-advice news item.
|
|
|
|
*
|
|
|
|
* @warning DParam 0 must reference the vehicle!
|
|
|
|
*/
|
|
|
|
static inline void AddVehicleAdviceNewsItem(StringID string, VehicleID vehicle)
|
|
|
|
{
|
2012-05-26 14:16:07 +00:00
|
|
|
AddNewsItem(string, NT_ADVICE, NF_INCOLOUR | NF_SMALL | NF_VEHICLE_PARAM0, NR_VEHICLE, vehicle);
|
2012-05-26 14:15:52 +00:00
|
|
|
}
|
|
|
|
|
2021-06-16 15:50:18 +00:00
|
|
|
static inline void AddTileNewsItem(StringID string, NewsType type, TileIndex tile, const NewsAllocatedData *data = nullptr, StationID station = INVALID_STATION)
|
2012-05-26 14:15:57 +00:00
|
|
|
{
|
2021-06-16 15:50:18 +00:00
|
|
|
AddNewsItem(string, type, NF_NO_TRANSPARENT | NF_SHADE | NF_THIN, NR_TILE, tile, station == INVALID_STATION ? NR_NONE : NR_STATION, station, data);
|
2012-05-26 14:15:57 +00:00
|
|
|
}
|
|
|
|
|
2023-08-06 14:05:04 +00:00
|
|
|
static inline void AddIndustryNewsItem(StringID string, NewsType type, IndustryID industry, const NewsAllocatedData *data = nullptr)
|
2009-05-24 16:52:42 +00:00
|
|
|
{
|
2023-08-06 14:05:04 +00:00
|
|
|
AddNewsItem(string, type, NF_NO_TRANSPARENT | NF_SHADE | NF_THIN, NR_INDUSTRY, industry, NR_NONE, UINT32_MAX, data);
|
2009-05-24 16:52:42 +00:00
|
|
|
}
|
2008-03-28 08:53:36 +00:00
|
|
|
|
|
|
|
void NewsLoop();
|
|
|
|
void InitNewsItemStructs();
|
|
|
|
|
2009-12-21 21:14:40 +00:00
|
|
|
extern const NewsItem *_statusbar_news_item;
|
2008-03-28 08:53:36 +00:00
|
|
|
|
2011-02-05 20:41:13 +00:00
|
|
|
void DeleteInvalidEngineNews();
|
2009-05-24 16:52:42 +00:00
|
|
|
void DeleteVehicleNews(VehicleID vid, StringID news);
|
|
|
|
void DeleteStationNews(StationID sid);
|
|
|
|
void DeleteIndustryNews(IndustryID iid);
|
2008-09-13 10:19:51 +00:00
|
|
|
|
2008-03-28 08:53:36 +00:00
|
|
|
#endif /* NEWS_FUNC_H */
|