Fix some daylength issues, possible division by zero in main menu.
[openttd-joker.git] / src / script / api / script_news.hpp
blob4d8ff3c64052b4e301ac6fc0f66626bf9def4831
1 /* $Id: script_news.hpp 24286 2012-05-26 14:16:12Z frosch $ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file script_news.hpp Everything to handle news messages. */
12 #ifndef SCRIPT_NEWS_HPP
13 #define SCRIPT_NEWS_HPP
15 #include "script_company.hpp"
16 #include "../../news_type.h"
18 /**
19 * Class that handles news messages.
20 * @api game
22 class ScriptNews : public ScriptObject {
23 public:
24 /**
25 * Enumeration for the news types that a script can create news for.
27 enum NewsType {
28 /* Arbitrary selection of NewsTypes which might make sense for scripts */
29 NT_ACCIDENT = ::NT_ACCIDENT, ///< Category accidents.
30 NT_COMPANY_INFO = ::NT_COMPANY_INFO, ///< Category company info.
31 NT_ECONOMY = ::NT_ECONOMY, ///< Category economy.
32 NT_ADVICE = ::NT_ADVICE, ///< Category vehicle advice.
33 NT_ACCEPTANCE = ::NT_ACCEPTANCE, ///< Category acceptance changes.
34 NT_SUBSIDIES = ::NT_SUBSIDIES, ///< Category subsidies.
35 NT_GENERAL = ::NT_GENERAL, ///< Category general.
38 /**
39 * Reference to a game element.
41 enum NewsReferenceType {
42 /* Selection of useful game elements to refer to. */
43 NR_NONE = ::NR_NONE, ///< No reference supplied.
44 NR_TILE = ::NR_TILE, ///< Reference location, scroll to the location when clicking on the news.
45 NR_STATION = ::NR_STATION, ///< Reference station, scroll to the station when clicking on the news. Delete news when the station is deleted.
46 NR_INDUSTRY = ::NR_INDUSTRY, ///< Reference industry, scrolls to the industry when clicking on the news. Delete news when the industry is deleted.
47 NR_TOWN = ::NR_TOWN, ///< Reference town, scroll to the town when clicking on the news.
50 /**
51 * Create a news message for everybody, or for one company.
52 * @param type The type of the news.
53 * @param text The text message to show (can be either a raw string, or a ScriptText object).
54 * @param company The company, or COMPANY_INVALID for all companies.
55 * @param ref_type Type of referred game element.
56 * @param reference The referenced game element of \a ref_type.
57 * - For #NR_NONE this parameter is ignored.
58 * - For #NR_TILE this parameter should be a valid location (ScriptMap::IsValidTile).
59 * - For #NR_STATION this parameter should be a valid stationID (ScriptStation::IsValidStation).
60 * - For #NR_INDUSTRY this parameter should be a valid industryID (ScriptIndustry::IsValidIndustry).
61 * - For #NR_TOWN this parameter should be a valid townID (ScriptTown::IsValidTown).
62 * @return True if the action succeeded.
63 * @pre type must be #NT_ECONOMY, #NT_SUBSIDIES, or #NT_GENERAL.
64 * @pre text != NULL.
65 * @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.
66 * @pre The \a reference condition must be fulfilled.
68 static bool Create(NewsType type, Text *text, ScriptCompany::CompanyID company, NewsReferenceType ref_type, uint32 reference);
71 #endif /* SCRIPT_NEWS_HPP */