Click or drag to resize

MessageT1, T2, T3, T4, T5 Class

A class to wrap a localizable UI string with parameter(s).
Inheritance Hierarchy
SystemObject
  KSPDev.GUIUtilsLocalizableMessage
    KSPDev.GUIUtilsMessageT1, T2, T3, T4, T5

Namespace:  KSPDev.GUIUtils
Assembly:  KSPDev_Utils.2.0 (in KSPDev_Utils.2.0.dll) Version: 2.0 for KSP v1.8+
Syntax
C#
public class Message<T1, T2, T3, T4, T5> : LocalizableMessage
Request Example View Source

Type Parameters

T1
Type of argument <<1>> in the Lingoona template.
T2
Type of argument <<2>> in the Lingoona template.
T3
Type of argument <<3>> in the Lingoona template.
T4
Type of argument <<4>> in the Lingoona template.
T5
Type of argument <<5>> in the Lingoona template.

The MessageT1, T2, T3, T4, T5 type exposes the following members.

Constructors
Methods
  NameDescription
Public methodCode exampleFormat
Formats the message template string with the provided arguments.
Top
Operators
Remarks

Define the parameter(s) type via the generic argument(s). When the string needs to be presented, use the Format(T1, T2, T3, T4, T5) 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.

Examples
public class Message5Demo : PartModule {
  // The encouraged way of defining a message.
  static readonly Message<string, int, string, int, float> msg1 =
      new Message<string, int, string, int, float>(
          "#myLocalizationTag",
          defaultTemplate: "<<1>> = <<2>>, <<3>> = <<4>>, avg = <<5>>",
          description: "A string to present in the KSPDevUtils documentation example. It"
          + " illustrates how the class can be used to localize a message.",
          example: "v1 = 1, v2 = 2, avg = 1.5");

  // A simple way when no extra details are provided.
  static readonly Message<string, int, string, int, float> 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("v1", 1, "v2", 2, 1.5f));

    // The next example will only work if there is a localizable string defined. Otherwise, it will
    // print the tag.
    HostedDebugLog.Info(this, msg2.Format("v1", 1, "v2", 2, 1.5f));
  }
}
See Also

Reference

KSPDev.GUIUtilsMessageT1, T2, T3, T4, T5

Other Resources