3 static const string FORMAT_TAG =
"##";
5 protected static bool AppendParam(out
string text,
string p)
7 text += FORMAT_TAG + p;
8 return p !=
string.Empty;
16 static string EncodeFormat(
string text,
string p1 =
string.Empty,
string p2 =
string.Empty,
string p3 =
string.Empty,
string p4 =
string.Empty,
string p5 =
string.Empty,
string p6 =
string.Empty,
string p7 =
string.Empty,
string p8 =
string.Empty,
string p9 =
string.Empty)
19 bool isParam = AppendParam(
params, p1)
27 || AppendParam(
params, p9);
30 return FORMAT_TAG + text +
params;
40 static string DecodeFormat(
string text, out
string p1, out
string p2, out
string p3, out
string p4, out
string p5, out
string p6, out
string p7, out
string p8, out
string p9)
42 if (!text.StartsWith(FORMAT_TAG))
45 array<string> segments = {};
46 text.Split(FORMAT_TAG, segments,
false);
66 static void SetTextFormat(TextWidget w,
string text)
68 if (text.StartsWith(FORMAT_TAG))
70 string p1, p2, p3, p4, p5, p6, p7, p8, p9;
71 text = DecodeFormat(text, p1, p2, p3, p4, p5, p6, p7, p8, p9);
72 w.SetTextFormat(text, p1, p2, p3, p4, p5, p6, p7, p8, p9);