diff --git a/Dalamud/Game/Text/SeStringHandling/Payloads/AutoTranslatePayload.cs b/Dalamud/Game/Text/SeStringHandling/Payloads/AutoTranslatePayload.cs index 0315c0d6b..5c87ad43b 100644 --- a/Dalamud/Game/Text/SeStringHandling/Payloads/AutoTranslatePayload.cs +++ b/Dalamud/Game/Text/SeStringHandling/Payloads/AutoTranslatePayload.cs @@ -15,11 +15,11 @@ public class AutoTranslatePayload : Payload, ITextProvider { private string text; - [JsonProperty] - private uint group; + [JsonProperty("group")] + public uint Group { get; private set; } - [JsonProperty] - private uint key; + [JsonProperty("key")] + public uint Key { get; private set; } /// /// Initializes a new instance of the class. @@ -34,8 +34,8 @@ public class AutoTranslatePayload : Payload, ITextProvider public AutoTranslatePayload(uint group, uint key) { // TODO: friendlier ctor? not sure how to handle that given how weird the tables are - this.group = group; - this.key = key; + this.Group = group; + this.Key = key; } /// @@ -69,20 +69,20 @@ public class AutoTranslatePayload : Payload, ITextProvider /// A string that represents the current object. public override string ToString() { - return $"{this.Type} - Group: {this.group}, Key: {this.key}, Text: {this.Text}"; + return $"{this.Type} - Group: {this.Group}, Key: {this.Key}, Text: {this.Text}"; } /// protected override byte[] EncodeImpl() { - var keyBytes = MakeInteger(this.key); + var keyBytes = MakeInteger(this.Key); var chunkLen = keyBytes.Length + 2; var bytes = new List() { START_BYTE, (byte)SeStringChunkType.AutoTranslateKey, (byte)chunkLen, - (byte)this.group, + (byte)this.Group, }; bytes.AddRange(keyBytes); bytes.Add(END_BYTE); @@ -95,9 +95,9 @@ public class AutoTranslatePayload : Payload, ITextProvider { // this seems to always be a bare byte, and not following normal integer encoding // the values in the table are all <70 so this is presumably ok - this.group = reader.ReadByte(); + this.Group = reader.ReadByte(); - this.key = GetInteger(reader); + this.Key = GetInteger(reader); } private string Resolve() @@ -112,13 +112,13 @@ public class AutoTranslatePayload : Payload, ITextProvider // try to get the row in the Completion table itself, because this is 'easiest' // The row may not exist at all (if the Key is for another table), or it could be the wrong row // (again, if it's meant for another table) - row = sheet.GetRow(this.key); + row = sheet.GetRow(this.Key); } catch { } // don't care, row will be null - if (row?.Group == this.group) + if (row?.Group == this.Group) { // if the row exists in this table and the group matches, this is actually the correct data value = row.Text; @@ -129,30 +129,30 @@ public class AutoTranslatePayload : Payload, ITextProvider { // we need to get the linked table and do the lookup there instead // in this case, there will only be one entry for this group id - row = sheet.First(r => r.Group == this.group); + row = sheet.First(r => r.Group == this.Group); // many of the names contain valid id ranges after the table name, but we don't need those var actualTableName = row.LookupTable.RawString.Split('[')[0]; var name = actualTableName switch { - "Action" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "ActionComboRoute" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "BuddyAction" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "ClassJob" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "Companion" => this.DataResolver.GetExcelSheet().GetRow(this.key).Singular, - "CraftAction" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "GeneralAction" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "GuardianDeity" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "MainCommand" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "Mount" => this.DataResolver.GetExcelSheet().GetRow(this.key).Singular, - "Pet" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "PetAction" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "PetMirage" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "PlaceName" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, - "Race" => this.DataResolver.GetExcelSheet().GetRow(this.key).Masculine, + "Action" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "ActionComboRoute" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "BuddyAction" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "ClassJob" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "Companion" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Singular, + "CraftAction" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "GeneralAction" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "GuardianDeity" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "MainCommand" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "Mount" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Singular, + "Pet" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "PetAction" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "PetMirage" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "PlaceName" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, + "Race" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Masculine, "TextCommand" => this.ResolveTextCommand(), - "Tribe" => this.DataResolver.GetExcelSheet().GetRow(this.key).Masculine, - "Weather" => this.DataResolver.GetExcelSheet().GetRow(this.key).Name, + "Tribe" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Masculine, + "Weather" => this.DataResolver.GetExcelSheet().GetRow(this.Key).Name, _ => throw new Exception(actualTableName), }; @@ -160,7 +160,7 @@ public class AutoTranslatePayload : Payload, ITextProvider } catch (Exception e) { - Log.Error(e, $"AutoTranslatePayload - failed to resolve: {this.Type} - Group: {this.group}, Key: {this.key}"); + Log.Error(e, $"AutoTranslatePayload - failed to resolve: {this.Type} - Group: {this.Group}, Key: {this.Key}"); } } @@ -171,7 +171,7 @@ public class AutoTranslatePayload : Payload, ITextProvider { // TextCommands prioritize the `Alias` field, if it not empty // Example for this is /rangerpose2l which becomes /blackrangerposeb in chat - var result = this.DataResolver.GetExcelSheet().GetRow(this.key); + var result = this.DataResolver.GetExcelSheet().GetRow(this.Key); return result.Alias.Payloads.Count > 0 ? result.Alias : result.Command; } }