misc: chore: [ci skip] Play Report Analyzer: Added Multi Value formatters
This commit is contained in:
parent
c638a7daf8
commit
e55629a908
@ -23698,4 +23698,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -108,6 +108,25 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
Application = appMeta, PackedValue = valuePackObject
|
Application = appMeta, PackedValue = valuePackObject
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (GameSpec.MultiFormatterSpec formatSpec in spec.MultiValueFormatters.OrderBy(x => x.Priority))
|
||||||
|
{
|
||||||
|
List<MessagePackObject> packedObjects = [];
|
||||||
|
foreach (var reportKey in formatSpec.ReportKeys)
|
||||||
|
{
|
||||||
|
if (!playReport.AsDictionary().TryGetValue(reportKey, out MessagePackObject valuePackObject))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
packedObjects.Add(valuePackObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packedObjects.Count != formatSpec.ReportKeys.Length)
|
||||||
|
return FormattedValue.Unhandled;
|
||||||
|
|
||||||
|
return formatSpec.ValueFormatter(packedObjects
|
||||||
|
.Select(packObject => new Value { Application = appMeta, PackedValue = packObject })
|
||||||
|
.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
return FormattedValue.Unhandled;
|
return FormattedValue.Unhandled;
|
||||||
}
|
}
|
||||||
@ -178,6 +197,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
{
|
{
|
||||||
public required string[] TitleIds { get; init; }
|
public required string[] TitleIds { get; init; }
|
||||||
public List<FormatterSpec> SimpleValueFormatters { get; } = [];
|
public List<FormatterSpec> SimpleValueFormatters { get; } = [];
|
||||||
|
public List<MultiFormatterSpec> MultiValueFormatters { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a value formatter to the current <see cref="GameSpec"/>
|
/// Add a value formatter to the current <see cref="GameSpec"/>
|
||||||
@ -212,6 +232,25 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameSpec AddMultiValueFormatter(string[] reportKeys, PlayReportMultiValueFormatter valueFormatter)
|
||||||
|
{
|
||||||
|
MultiValueFormatters.Add(new MultiFormatterSpec
|
||||||
|
{
|
||||||
|
Priority = SimpleValueFormatters.Count, ReportKeys = reportKeys, ValueFormatter = valueFormatter
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameSpec AddMultiValueFormatter(int priority, string[] reportKeys,
|
||||||
|
PlayReportMultiValueFormatter valueFormatter)
|
||||||
|
{
|
||||||
|
MultiValueFormatters.Add(new MultiFormatterSpec
|
||||||
|
{
|
||||||
|
Priority = priority, ReportKeys = reportKeys, ValueFormatter = valueFormatter
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A struct containing the data for a mapping of a key in a Play Report to a formatter for its potential value.
|
/// A struct containing the data for a mapping of a key in a Play Report to a formatter for its potential value.
|
||||||
@ -222,6 +261,16 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
public required string ReportKey { get; init; }
|
public required string ReportKey { get; init; }
|
||||||
public PlayReportValueFormatter ValueFormatter { get; init; }
|
public PlayReportValueFormatter ValueFormatter { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A struct containing the data for a mapping of an arbitrary key set in a Play Report to a formatter for their potential values.
|
||||||
|
/// </summary>
|
||||||
|
public struct MultiFormatterSpec
|
||||||
|
{
|
||||||
|
public required int Priority { get; init; }
|
||||||
|
public required string[] ReportKeys { get; init; }
|
||||||
|
public PlayReportMultiValueFormatter ValueFormatter { get; init; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -269,7 +318,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The delegate type that powers the entire analysis system (as it currently is).<br/>
|
/// The delegate type that powers single value formatters.<br/>
|
||||||
/// Takes in the result value from the Play Report, and outputs:
|
/// Takes in the result value from the Play Report, and outputs:
|
||||||
/// <br/>
|
/// <br/>
|
||||||
/// a formatted string,
|
/// a formatted string,
|
||||||
@ -279,4 +328,16 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// OR a signal to reset the value that the caller is using the <see cref="Analyzer"/> for.
|
/// OR a signal to reset the value that the caller is using the <see cref="Analyzer"/> for.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public delegate Analyzer.FormattedValue PlayReportValueFormatter(Value value);
|
public delegate Analyzer.FormattedValue PlayReportValueFormatter(Value value);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The delegate type that powers multiple value formatters.<br/>
|
||||||
|
/// Takes in the result value from the Play Report, and outputs:
|
||||||
|
/// <br/>
|
||||||
|
/// a formatted string,
|
||||||
|
/// <br/>
|
||||||
|
/// a signal that nothing was available to handle it,
|
||||||
|
/// <br/>
|
||||||
|
/// OR a signal to reset the value that the caller is using the <see cref="Analyzer"/> for.
|
||||||
|
/// </summary>
|
||||||
|
public delegate Analyzer.FormattedValue PlayReportMultiValueFormatter(Value[] value);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,8 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
)
|
)
|
||||||
.AddSpec(
|
.AddSpec(
|
||||||
"0100f2c0115b6000",
|
"0100f2c0115b6000",
|
||||||
spec => spec.AddValueFormatter("PlayerPosY", TearsOfTheKingdom_CurrentField))
|
spec => spec
|
||||||
|
.AddValueFormatter("PlayerPosY", TearsOfTheKingdom_CurrentField))
|
||||||
.AddSpec(
|
.AddSpec(
|
||||||
"0100000000010000",
|
"0100000000010000",
|
||||||
spec =>
|
spec =>
|
||||||
@ -40,6 +41,11 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
.AddValueFormatter("team_circle", PokemonSVUnionCircle)
|
.AddValueFormatter("team_circle", PokemonSVUnionCircle)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static FormattedValue Botw(Value[] values)
|
||||||
|
{
|
||||||
|
return $"{values[0].BoxedValue}, {values[1].BoxedValue}";
|
||||||
|
}
|
||||||
|
|
||||||
private static FormattedValue BreathOfTheWild_MasterMode(Value value)
|
private static FormattedValue BreathOfTheWild_MasterMode(Value value)
|
||||||
=> value.BoxedValue is 1 ? "Playing Master Mode" : FormattedValue.ForceReset;
|
=> value.BoxedValue is 1 ? "Playing Master Mode" : FormattedValue.ForceReset;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user