diff --git a/src/Lumina/Text/Expressions/BinaryExpression.cs b/src/Lumina/Text/Expressions/BinaryExpression.cs
index 4c19ba0d..cff78f50 100644
--- a/src/Lumina/Text/Expressions/BinaryExpression.cs
+++ b/src/Lumina/Text/Expressions/BinaryExpression.cs
@@ -41,12 +41,12 @@ public override string ToString()
{
return ExpressionType switch
{
- ExpressionType.GreaterThanOrEqualTo => $"BinExpr{{{Operand1} >= {Operand2}}}",
- ExpressionType.GreaterThan => $"BinExpr{{{Operand1} > {Operand2}}}",
- ExpressionType.LessThanOrEqualTo => $"BinExpr{{{Operand1} <= {Operand2}}}",
- ExpressionType.LessThan => $"BinExpr{{{Operand1} < {Operand2}}}",
- ExpressionType.Equal => $"BinExpr{{{Operand1} == {Operand2}}}",
- ExpressionType.NotEqual => $"BinExpr{{{Operand1} != {Operand2}}}",
+ ExpressionType.GreaterThanOrEqualTo => $"[{Operand1}>={Operand2}]",
+ ExpressionType.GreaterThan => $"[{Operand1}>{Operand2}]",
+ ExpressionType.LessThanOrEqualTo => $"[{Operand1}<={Operand2}]",
+ ExpressionType.LessThan => $"[{Operand1}<{Operand2}]",
+ ExpressionType.Equal => $"[{Operand1}=={Operand2}]",
+ ExpressionType.NotEqual => $"[{Operand1}!={Operand2}]",
_ => throw new NotImplementedException() // cannot reach, as this instance is immutable and this field is filtered from constructor
};
}
diff --git a/src/Lumina/Text/Expressions/ExpressionType.cs b/src/Lumina/Text/Expressions/ExpressionType.cs
index 92783541..d4c01f1d 100644
--- a/src/Lumina/Text/Expressions/ExpressionType.cs
+++ b/src/Lumina/Text/Expressions/ExpressionType.cs
@@ -2,25 +2,32 @@ namespace Lumina.Text.Expressions;
public enum ExpressionType : byte
{
- // Placeholder expressions (Zero arity): 0xD0 ~ 0xDF
- Hour = 0xDB, // 0 ~ 23
- Weekday = 0xDD, // 1(sunday) ~ 7(saturday)
+ // Placeholder expressions (Zero arity): 0xD8 ~ 0xDF
+ Millisecond = 0xD8, // t_msec
+ Second = 0xD9, // t_sec
+ Minute = 0xDA, // t_min
+ Hour = 0xDB, // t_hour 0 ~ 23
+ Day = 0xDC, // t_day
+ Weekday = 0xDD, // t_wday 1(sunday) ~ 7(saturday)
+ Month = 0xDE, // t_mon
+ Year = 0xDF, // t_year
// Binary expressions
- GreaterThanOrEqualTo = 0xE0,
- GreaterThan = 0xE1,
- LessThanOrEqualTo = 0xE2,
- LessThan = 0xE3,
- Equal = 0xE4,
- NotEqual = 0xE5,
+ GreaterThanOrEqualTo = 0xE0, // [gteq]
+ GreaterThan = 0xE1, // [gt]
+ LessThanOrEqualTo = 0xE2, // [lteq]
+ LessThan = 0xE3, // [lt]
+ Equal = 0xE4, // [eq]
+ NotEqual = 0xE5, // [neq]
// Parameter (unary expressions)
- IntegerParameter = 0xE8,
- PlayerParameter = 0xE9,
- StringParameter = 0xEA,
- ObjectParameter = 0xEB,
+ IntegerParameter = 0xE8, // lnum
+ PlayerParameter = 0xE9, // gnum
+ StringParameter = 0xEA, // lstr
+ ObjectParameter = 0xEB, // gstr
// Placeholder expressions also exist between 0xEC ~ 0xEF, where 0xEC is at least checked existing.
+ StackColor = 0xEC, // stackcolor
// Embedded SeString
SeString = 0xff, // Followed by length (including length) and data
diff --git a/src/Lumina/Text/Expressions/IntegerExpression.cs b/src/Lumina/Text/Expressions/IntegerExpression.cs
index 523d690e..7f58b135 100644
--- a/src/Lumina/Text/Expressions/IntegerExpression.cs
+++ b/src/Lumina/Text/Expressions/IntegerExpression.cs
@@ -92,7 +92,7 @@ public static int CalculateSize( uint value )
}
///
- public override string ToString() => Value.ToString();
+ public override string ToString() => ( (int)Value ).ToString();
///
/// Parse given Stream into an IntegerExpression.
diff --git a/src/Lumina/Text/Expressions/ParameterExpression.cs b/src/Lumina/Text/Expressions/ParameterExpression.cs
index 389b94ec..c58c2b64 100644
--- a/src/Lumina/Text/Expressions/ParameterExpression.cs
+++ b/src/Lumina/Text/Expressions/ParameterExpression.cs
@@ -35,10 +35,10 @@ public override string ToString()
{
return ExpressionType switch
{
- ExpressionType.IntegerParameter => $"IntegerParam{{{Operand}}}",
- ExpressionType.PlayerParameter => $"PlayerParam{{{Operand}}}",
- ExpressionType.StringParameter => $"StringParam{{{Operand}}}",
- ExpressionType.ObjectParameter => $"ObjectParam{{{Operand}}}",
+ ExpressionType.IntegerParameter => $"lnum{Operand}",
+ ExpressionType.PlayerParameter => $"gnum{Operand}",
+ ExpressionType.StringParameter => $"lstr{Operand}",
+ ExpressionType.ObjectParameter => $"gstr{Operand}",
_ => throw new NotImplementedException() // cannot reach, as this instance is immutable and this field is filtered from constructor
};
}
diff --git a/src/Lumina/Text/Expressions/PlaceholderExpression.cs b/src/Lumina/Text/Expressions/PlaceholderExpression.cs
index dee816af..78c3b4f2 100644
--- a/src/Lumina/Text/Expressions/PlaceholderExpression.cs
+++ b/src/Lumina/Text/Expressions/PlaceholderExpression.cs
@@ -28,7 +28,22 @@ public PlaceholderExpression( ExpressionType expressionType )
public override void Encode( Stream stream ) => stream.WriteByte( (byte)ExpressionType );
///
- public override string ToString() => $"Placeholder#{ExpressionType:X02}";
+ public override string ToString()
+ {
+ return ExpressionType switch
+ {
+ ExpressionType.Millisecond => "t_msec",
+ ExpressionType.Second => "t_sec",
+ ExpressionType.Minute => "t_min",
+ ExpressionType.Hour => "t_hour",
+ ExpressionType.Day => "t_day",
+ ExpressionType.Weekday => "t_wday",
+ ExpressionType.Month => "t_mon",
+ ExpressionType.Year => "t_year",
+ ExpressionType.StackColor => "stackcolor",
+ _ => $"Placeholder#{ExpressionType:X02}"
+ };
+ }
///
/// Identify whether the given type byte indicates a PlaceholderExpression.
diff --git a/src/Lumina/Text/Expressions/StringExpression.cs b/src/Lumina/Text/Expressions/StringExpression.cs
index 14dc95b6..e71e389a 100644
--- a/src/Lumina/Text/Expressions/StringExpression.cs
+++ b/src/Lumina/Text/Expressions/StringExpression.cs
@@ -45,7 +45,7 @@ public override void Encode( Stream stream )
}
///
- public override string ToString() => $"Str{{{Value?.ToString() ?? string.Empty}}}";
+ public override string ToString() => Value?.ToString() ?? string.Empty;
///
/// Parse given Stream into a StringExpression.
diff --git a/src/Lumina/Text/Payloads/BasePayload.cs b/src/Lumina/Text/Payloads/BasePayload.cs
index cd8ac41b..9cbc2f44 100644
--- a/src/Lumina/Text/Payloads/BasePayload.cs
+++ b/src/Lumina/Text/Payloads/BasePayload.cs
@@ -240,5 +240,32 @@ public BasePayload ToTypedPayload()
/// Extracts and concatenates the text payloads and integer constants.
///
public string RawString => _rawString.Value;
+
+ ///
+ public override string ToString()
+ {
+ if( PayloadType == PayloadType.Text )
+ return RawString.Replace( "<", "\\<" );
+
+ var code = (MacroCodes)PayloadType;
+ switch( code )
+ {
+ case MacroCodes.NewLine:
+ return "
";
+ case MacroCodes.NonBreakingSpace:
+ return "";
+ case MacroCodes.SoftHyphen:
+ return "-";
+ case MacroCodes.Hyphen:
+ return "--";
+ default:
+ {
+ if( Expressions.Count == 0 )
+ return $"<{code.ToString().ToLower()}>";
+
+ return $"<{code.ToString().ToLower()}({string.Join( ',', Expressions )})>";
+ }
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Lumina/Text/Payloads/MacroCodes.cs b/src/Lumina/Text/Payloads/MacroCodes.cs
new file mode 100644
index 00000000..f4107b37
--- /dev/null
+++ b/src/Lumina/Text/Payloads/MacroCodes.cs
@@ -0,0 +1,59 @@
+namespace Lumina.Text.Payloads;
+
+internal enum MacroCodes : byte
+{
+ SetResetTime = 0x06, // n N x
+ SetTime = 0x07, // n x
+ If = 0x08, // . . * x
+ Switch = 0x09, // . . .
+ PcName = 0x0A, // n x
+ IfPcGender = 0x0B, // n . . x
+ IfPcName = 0x0C, // n . . . x
+ Josa = 0x0D, // s s s x
+ Josaro = 0x0E, // s s s x
+ IfSelf = 0x0F, // n . . x
+ NewLine = 0x10, //
+ Wait = 0x11, // n x
+ Icon = 0x12, // n x
+ Color = 0x13, // n N x
+ EdgeColor = 0x14, // n N x
+ ShadowColor = 0x15, // n N x
+ SoftHyphen = 0x16, // -
+ Key = 0x17, //
+ Scale = 0x18, // n
+ Bold = 0x19, // n
+ Italic = 0x1A, // n
+ Edge = 0x1B, // n n
+ Shadow = 0x1C, // n n
+ NonBreakingSpace = 0x1D, //
+ Icon2 = 0x1E, // n N x
+ Hyphen = 0x1F, // --
+ Num = 0x20, // n x
+ Hex = 0x21, // n x
+ Kilo = 0x22, // . s x
+ Byte = 0x23, // n x
+ Sec = 0x24, // n x
+ Time = 0x25, // n x
+ Float = 0x26, // n n s x
+ Link = 0x27, // n n n n s
+ Sheet = 0x28, // s . . .
+ String = 0x29, // s x
+ Caps = 0x2A, // s x
+ Head = 0x2B, // s x
+ Split = 0x2C, // s s n x
+ HeadAll = 0x2D, // s x
+ Fixed = 0x2E, // n n . . .
+ Lower = 0x2F, // s x
+ JaNoun = 0x30, // s . .
+ EnNoun = 0x31, // s . .
+ DeNoun = 0x32, // s . .
+ FrNoun = 0x33, // s . .
+ ChNoun = 0x34, // s . .
+ LowerHead = 0x40, // s x
+ ColorType = 0x48, // n x
+ EdgeColorType = 0x49, // n x
+ Digit = 0x50, // n n x
+ Ordinal = 0x51, // n x
+ Sound = 0x60, // n n
+ LevelPos = 0x61 // n x
+}
diff --git a/src/Lumina/Text/SeString.cs b/src/Lumina/Text/SeString.cs
index 3e5d8f38..199ee805 100644
--- a/src/Lumina/Text/SeString.cs
+++ b/src/Lumina/Text/SeString.cs
@@ -170,7 +170,7 @@ private ImmutableList< BasePayload > BuildPayloads()
public override string ToString()
{
- return RawString;
+ return string.Concat( Payloads );
}
}
}
\ No newline at end of file