Changeset - r27742:b304bebdbb90
[Not reviewed]
master
0 3 0
Andy - 14 months ago 2023-07-20 18:35:37
1780327+andythenorth@users.noreply.github.com
Add: [Script] GSIndustry.GetConstructionDate() method (#11145)
3 files changed with 17 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/script/api/game_changelog.hpp
Show inline comments
 
@@ -18,6 +18,7 @@
 
 * This version is not yet released. The following changes are not set in stone yet.
 
 *
 
 * API additions:
 
 * \li GSIndustry::GetConstructionDate
 
 * \li GSAsyncMode
 
 * \li GSCompanyMode::IsValid
 
 * \li GSCompanyMode::IsDeity
src/script/api/script_industry.cpp
Show inline comments
 
@@ -49,6 +49,13 @@
 
	return GetString(STR_INDUSTRY_NAME);
 
}
 

	
 
/* static */ ScriptDate::Date ScriptIndustry::GetConstructionDate(IndustryID industry_id)
 
{
 
	Industry *i = Industry::GetIfValid(industry_id);
 
	if (i == nullptr) return ScriptDate::DATE_INVALID;
 
	return (ScriptDate::Date)i->construction_date;
 
}
 

	
 
/* static */ bool ScriptIndustry::SetText(IndustryID industry_id, Text *text)
 
{
 
	CCountedPtr<Text> counter(text);
src/script/api/script_industry.hpp
Show inline comments
 
@@ -82,6 +82,15 @@ public:
 
	static std::optional<std::string> GetName(IndustryID industry_id);
 

	
 
	/**
 
	 * Get the construction date of an industry.
 
	 * @param industry_id The index of the industry.
 
	 * @pre IsValidIndustry(industry_id).
 
	 * @return Date the industry was constructed.
 
	 * @api -ai
 
	 */
 
	static ScriptDate::Date GetConstructionDate(IndustryID industry_id);
 

	
 
	/**
 
	 * Set the custom text of an industry, shown in the GUI.
 
	 * @param industry_id The industry to set the custom text of.
 
	 * @param text The text to set it to (can be either a raw string, or a ScriptText object). If null, or an empty string, is passed, the text will be removed.
0 comments (0 inline, 0 general)