mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-18 13:57:43 +01:00
Add support for SheetSub payload (#2283)
This commit is contained in:
parent
d6aa6b8b64
commit
094fcc86d4
2 changed files with 70 additions and 4 deletions
|
|
@ -315,6 +315,9 @@ internal class SeStringEvaluator : IServiceType, ISeStringEvaluator
|
|||
case MacroCode.Sheet:
|
||||
return this.TryResolveSheet(in context, payload);
|
||||
|
||||
case MacroCode.SheetSub:
|
||||
return this.TryResolveSheetSub(in context, payload);
|
||||
|
||||
case MacroCode.String:
|
||||
return this.TryResolveString(in context, payload);
|
||||
|
||||
|
|
@ -757,6 +760,65 @@ internal class SeStringEvaluator : IServiceType, ISeStringEvaluator
|
|||
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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue