Add: [Script] ScriptCargo::GetName, to get the human readable name of a cargo (#8544)
Of course this translates into AICargo.GetName() for AIs and GSCargo.GetName() for GameScripts.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
* This version is not yet released. The following changes are not set in stone yet.
|
||||
*
|
||||
* API additions:
|
||||
* \li AICargo::GetName
|
||||
* \li AIPriorityQueue
|
||||
*
|
||||
* \b 1.10.0
|
||||
|
@@ -18,6 +18,7 @@
|
||||
* This version is not yet released. The following changes are not set in stone yet.
|
||||
*
|
||||
* API additions:
|
||||
* \li GSCargo::GetName
|
||||
* \li GSEventStoryPageButtonClick
|
||||
* \li GSEventStoryPageTileSelect
|
||||
* \li GSEventStoryPageVehicleSelect
|
||||
|
@@ -11,7 +11,9 @@
|
||||
#include "script_cargo.hpp"
|
||||
#include "../../economy_func.h"
|
||||
#include "../../core/bitmath_func.hpp"
|
||||
#include "../../strings_func.h"
|
||||
#include "../../settings_type.h"
|
||||
#include "table/strings.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
@@ -25,6 +27,14 @@
|
||||
return (towneffect_type >= (TownEffect)TE_BEGIN && towneffect_type < (TownEffect)TE_END);
|
||||
}
|
||||
|
||||
/* static */ char *ScriptCargo::GetName(CargoID cargo_type)
|
||||
{
|
||||
if (!IsValidCargo(cargo_type)) return nullptr;
|
||||
|
||||
::SetDParam(0, 1 << cargo_type);
|
||||
return GetString(STR_JUST_CARGO_LIST);
|
||||
}
|
||||
|
||||
/* static */ char *ScriptCargo::GetCargoLabel(CargoID cargo_type)
|
||||
{
|
||||
if (!IsValidCargo(cargo_type)) return nullptr;
|
||||
|
@@ -84,6 +84,14 @@ public:
|
||||
*/
|
||||
static bool IsValidTownEffect(TownEffect towneffect_type);
|
||||
|
||||
/**
|
||||
* Get the name of the cargo type.
|
||||
* @param cargo_type The cargo type to get the name of.
|
||||
* @pre IsValidCargo(cargo_type).
|
||||
* @return The name of the cargo type.
|
||||
*/
|
||||
static char *GetName(CargoID cargo_type);
|
||||
|
||||
/**
|
||||
* Gets the string representation of the cargo label.
|
||||
* @param cargo_type The cargo to get the string representation of.
|
||||
|
Reference in New Issue
Block a user