ResourceShortType Class |
Namespace: KSPDev.GUIUtils.TypeFormatters
The ResourceShortType type exposes the following members.
Name | Description | |
---|---|---|
ResourceShortType(Int32) | Constructs an object from a resource ID. | |
ResourceShortType(String) | Constructs an object from a resource nane. |
Name | Description | |
---|---|---|
Format(Int32) | Formats the value into a human friendly localized string. | |
Format(String) | Formats the value into a human friendly localized string. | |
ToString | Returns a string formatted as a human friendly resource name. (Overrides ObjectToString.) |
Name | Description | |
---|---|---|
(Int32 to ResourceShortType) | Coverts a resource ID value into a type object. | |
(String to ResourceShortType) | Coverts a resource name value into a type object. | |
(ResourceShortType to String) | Converts a type object into a resource name. | |
(ResourceShortType to Int32) | Converts a type object into a resource ID. |
Name | Description | |
---|---|---|
resourceId | A wrapped resource ID value. |
This class resolves the resource type/ID into it's short localized name. It's usually 2 letters long, but it's not mandatory.
Use it as a generic parameter when creating a LocalizableMessage descendants.
public class ResourceShortTypeDemo1 : PartModule { static readonly Message<ResourceShortType> msg1 = new Message<ResourceShortType>( "#TypeDemo_msg1", defaultTemplate: "Resource is: <<1>>"); void Show() { Debug.Log(msg1.Format(StockResourceNames.ElectricCharge)); // Prints: "Resource is: EC" Debug.Log(msg1.Format(PartResourceLibrary.ElectricityHashcode)); // Prints: "Resource is: EC" } }
Debug.Log(ResourceShortType.Format(StockResourceNames.ElectricCharge)); // Prints: "Resource is: EC" Debug.Log(ResourceShortType.Format(PartResourceLibrary.ElectricityHashcode)); // Prints: "Resource is: EC"