Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions Dalamud/Game/Text/Evaluator/SeStringEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@
case MacroCode.Sheet:
return this.TryResolveSheet(in context, payload);

case MacroCode.SheetSub:

Check failure on line 320 in Dalamud/Game/Text/Evaluator/SeStringEvaluator.cs

View workflow job for this annotation

GitHub Actions / Build on Windows

'MacroCode' does not contain a definition for 'SheetSub'
return this.TryResolveSheetSub(in context, payload);

case MacroCode.String:
return this.TryResolveString(in context, payload);

Expand Down Expand Up @@ -759,6 +762,65 @@
return true;
}

private bool TryResolveSheetSub(in SeStringContext context, in ReadOnlySePayloadSpan payload)
{
var enu = payload.GetEnumerator();

if (!enu.MoveNext() || !enu.Current.TryGetString(out var eSheetNameStr))
return false;

if (!enu.MoveNext() || !this.TryResolveUInt(in context, enu.Current, out var eRowIdValue))
return false;

if (!enu.MoveNext() || !this.TryResolveUInt(in context, enu.Current, out var eSubrowIdValue))
return false;

if (!enu.MoveNext() || !this.TryResolveUInt(in context, enu.Current, out var eColIndexValue))
return false;

var secondaryRowId = this.GetSubrowSheetIntValue(context.Language, eSheetNameStr.ExtractText(), eRowIdValue, (ushort)eSubrowIdValue, eColIndexValue);
if (secondaryRowId == -1)
return false;

if (!enu.MoveNext() || !enu.Current.TryGetString(out var eSecondarySheetNameStr))
return false;

if (!enu.MoveNext() || !this.TryResolveUInt(in context, enu.Current, out var secondaryColIndex))
return false;

var text = this.FormatSheetValue(context.Language, eSecondarySheetNameStr.ExtractText(), (uint)secondaryRowId, secondaryColIndex, 0);
if (text.IsEmpty)
return false;

this.CreateSheetLink(context, eSecondarySheetNameStr.ExtractText(), text, eRowIdValue, eSubrowIdValue);

return true;
}

private int GetSubrowSheetIntValue(ClientLanguage language, string sheetName, uint rowId, ushort subrowId, uint colIndex)
{
if (!this.dataManager.Excel.SheetNames.Contains(sheetName))
return -1;

if (!this.dataManager.GetSubrowExcelSheet<RawSubrow>(language, sheetName)
.TryGetSubrow(rowId, subrowId, out var row))
return -1;

if (colIndex >= row.Columns.Count)
return -1;

var column = row.Columns[(int)colIndex];
return column.Type switch
{
ExcelColumnDataType.Int8 => row.ReadInt8(column.Offset),
ExcelColumnDataType.UInt8 => row.ReadUInt8(column.Offset),
ExcelColumnDataType.Int16 => row.ReadInt16(column.Offset),
ExcelColumnDataType.UInt16 => row.ReadUInt16(column.Offset),
ExcelColumnDataType.Int32 => row.ReadInt32(column.Offset),
_ => -1,
};
}

private ReadOnlySeString FormatSheetValue(ClientLanguage language, string sheetName, uint rowId, uint colIndex, uint colParam)
{
if (!this.dataManager.Excel.SheetNames.Contains(sheetName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
{ MacroCode.FrNoun, ["SheetName", "ArticleType", "RowId", "Amount", "Case", "UnkInt5"] },
{ MacroCode.ChNoun, ["SheetName", "ArticleType", "RowId", "Amount", "Case", "UnkInt5"] },
{ MacroCode.LowerHead, ["String"] },
{ MacroCode.SheetSub, ["SheetName", "RowId", "SubrowId", "ColumnIndex", "SecondarySheetName", "SecondarySheetColumnIndex"] },

Check failure on line 95 in Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringCreatorWidget.cs

View workflow job for this annotation

GitHub Actions / Build on Windows

'MacroCode' does not contain a definition for 'SheetSub'
{ MacroCode.ColorType, ["ColorType"] },
{ MacroCode.EdgeColorType, ["ColorType"] },
{ MacroCode.Ruby, ["StandardText", "RubyText"] },
Expand All @@ -106,13 +107,16 @@
{ LinkMacroPayloadType.Character, ["Flags", "WorldId"] },
{ LinkMacroPayloadType.Item, ["ItemId", "Rarity"] },
{ LinkMacroPayloadType.MapPosition, ["TerritoryType/MapId", "RawX", "RawY"] },
{ LinkMacroPayloadType.Quest, ["QuestId"] },
{ LinkMacroPayloadType.Achievement, ["AchievementId"] },
{ LinkMacroPayloadType.HowTo, ["HowToId"] },
{ LinkMacroPayloadType.Quest, ["RowId"] },
{ LinkMacroPayloadType.Achievement, ["RowId"] },
{ LinkMacroPayloadType.HowTo, ["RowId"] },
// PartyFinderNotification
{ LinkMacroPayloadType.Status, ["StatusId"] },
{ LinkMacroPayloadType.PartyFinder, ["ListingId", string.Empty, "WorldId"] },
{ LinkMacroPayloadType.AkatsukiNote, ["AkatsukiNoteId"] },
{ LinkMacroPayloadType.AkatsukiNote, ["RowId"] },
{ LinkMacroPayloadType.Description, ["RowId"] },

Check failure on line 117 in Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringCreatorWidget.cs

View workflow job for this annotation

GitHub Actions / Build on Windows

'LinkMacroPayloadType' does not contain a definition for 'Description'
{ LinkMacroPayloadType.WKSPioneeringTrail, ["RowId", "SubrowId"] },

Check failure on line 118 in Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringCreatorWidget.cs

View workflow job for this annotation

GitHub Actions / Build on Windows

'LinkMacroPayloadType' does not contain a definition for 'WKSPioneeringTrail'
{ LinkMacroPayloadType.MKDLore, ["RowId"] },

Check failure on line 119 in Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringCreatorWidget.cs

View workflow job for this annotation

GitHub Actions / Build on Windows

'LinkMacroPayloadType' does not contain a definition for 'MKDLore'
{ DalamudLinkType, ["CommandId", "Extra1", "Extra2", "ExtraString"] },
};

Expand Down
Loading