MessageT1 Class |
Namespace: KSPDev.GUIUtils
public sealed class Message<T1> : LocalizableMessage
The MessageT1 type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() ![]() | (String to MessageT1) | Allows casting a string to a message. |
Define the parameter(s) type via the generic argument(s). When the string needs to be presented, use the Format(T1) method to get the final value.
The arguments can be complex types that override the ToString() method. This approach can be used to customize the output format of the specific argument types. E.g. such values as "distance" can be formatted in a user friendly manner using DistanceType.
public class Message1Demo : PartModule { // The encouraged way of defining a message. static readonly Message<int> msg1 = new Message<int>( "#myLocalizationTag", defaultTemplate: "The value is <<1>>", description: "A string to present in the KSPDevUtils documentation example. It illustrates" + " how the class can be used to localize a message.", example: "The value is 123"); // A simple way when no extra details are provided. static readonly Message<int> msg2 = "#myLocalizationTag"; public override void OnAwake() { base.OnAwake(); // This will load the localized string and print it into the log. HostedDebugLog.Info(this, msg1.Format(123)); // The next example will only work if there is a localizable string defined. Otherwise, it will // print the tag. HostedDebugLog.Info(this, msg2.Format(123)); } }