mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 16:15:43 +00:00
ZoneCodeGenerator: Change block Statement to get the number of fastfileblock from the enum entry instead of manually specifying it
This commit is contained in:
parent
7ab7447827
commit
799d3cbce7
@ -52,13 +52,13 @@ asset FootstepFXTableDef ASSET_TYPE_FOOTSTEPFX_TABLE;
|
||||
asset ZBarrierDef ASSET_TYPE_ZBARRIER;
|
||||
|
||||
// Setup blocks
|
||||
block 0 temp XFILE_BLOCK_TEMP default;
|
||||
block 1 runtime XFILE_BLOCK_RUNTIME_VIRTUAL default;
|
||||
block 2 runtime XFILE_BLOCK_RUNTIME_PHYSICAL;
|
||||
block 3 delay XFILE_BLOCK_DELAY_VIRTUAL default;
|
||||
block 4 delay XFILE_BLOCK_DELAY_PHYSICAL;
|
||||
block 5 normal XFILE_BLOCK_VIRTUAL default;
|
||||
block 6 normal XFILE_BLOCK_PHYSICAL;
|
||||
block temp XFILE_BLOCK_TEMP default;
|
||||
block runtime XFILE_BLOCK_RUNTIME_VIRTUAL default;
|
||||
block runtime XFILE_BLOCK_RUNTIME_PHYSICAL;
|
||||
block delay XFILE_BLOCK_DELAY_VIRTUAL default;
|
||||
block delay XFILE_BLOCK_DELAY_PHYSICAL;
|
||||
block normal XFILE_BLOCK_VIRTUAL default;
|
||||
block normal XFILE_BLOCK_PHYSICAL;
|
||||
|
||||
// =========================================
|
||||
// XModelPieces
|
||||
|
@ -11,7 +11,7 @@
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
public int Index { get; }
|
||||
public long Index { get; }
|
||||
public Type BlockType { get; }
|
||||
public bool IsDefault { get; }
|
||||
public bool IsTemp => BlockType == Type.Temp;
|
||||
@ -19,7 +19,7 @@
|
||||
public bool IsDelay => BlockType == Type.Delay;
|
||||
public bool IsNormal => BlockType == Type.Normal;
|
||||
|
||||
public FastFileBlock(string name, int index, Type blockType, bool isDefault)
|
||||
public FastFileBlock(string name, long index, Type blockType, bool isDefault)
|
||||
{
|
||||
Name = name;
|
||||
Index = index;
|
||||
|
@ -9,19 +9,17 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
|
||||
{
|
||||
class TestBlock : AbstractTokenTest<ICommandParserState>
|
||||
{
|
||||
private const string BlockNumberToken = "num";
|
||||
private const string BlockTypeToken = "type";
|
||||
private const string BlockNameToken = "name";
|
||||
private const string BlockEnumMemberToken = "enumEntry";
|
||||
private const string DefaultToken = "default";
|
||||
|
||||
private static readonly TokenMatcher[] matchers = {
|
||||
new MatcherLiteral("block"),
|
||||
new MatcherNumber().WithName(BlockNumberToken),
|
||||
new MatcherLiteral("block"),
|
||||
new MatcherName().WithName(BlockTypeToken),
|
||||
new MatcherName().WithName(BlockNameToken),
|
||||
new MatcherGroupLoop(MatcherGroupLoop.LoopMode.ZeroOneMultiple,new MatcherGroupOr(
|
||||
new MatcherName().WithName(BlockEnumMemberToken),
|
||||
new MatcherGroupOptional(
|
||||
new MatcherLiteral("default").WithName(DefaultToken)
|
||||
)),
|
||||
),
|
||||
new MatcherLiteral(";")
|
||||
};
|
||||
|
||||
@ -32,8 +30,14 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
|
||||
|
||||
protected override void ProcessMatch(ICommandParserState state)
|
||||
{
|
||||
var blockName = NextMatch(BlockNameToken);
|
||||
var blockNumber = int.Parse(NextMatch(BlockNumberToken));
|
||||
var blockEnumEntryName = NextMatch(BlockEnumMemberToken);
|
||||
var blockEnumEntry = state.Repository.GetAllEnums()
|
||||
.SelectMany(_enum => _enum.Members)
|
||||
.FirstOrDefault(member => member.Name.Equals(blockEnumEntryName));
|
||||
if (blockEnumEntry == null)
|
||||
{
|
||||
throw new TestFailedException($"Could not find enum entry '{blockEnumEntryName}' for block.");
|
||||
}
|
||||
|
||||
var blockTypeInput = NextMatch(BlockTypeToken);
|
||||
if (!Enum.TryParse(blockTypeInput, true, out FastFileBlock.Type blockType))
|
||||
@ -44,7 +48,7 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
|
||||
throw new TestFailedException($"Unknown fastfile block type '{blockTypeInput}'. Must be one of the following: {string.Join(", ", blockTypeValues)}");
|
||||
}
|
||||
|
||||
var block = new FastFileBlock(blockName, blockNumber, blockType, HasMatcherTokens(DefaultToken));
|
||||
var block = new FastFileBlock(blockEnumEntry.Name, blockEnumEntry.Value, blockType, HasMatcherTokens(DefaultToken));
|
||||
|
||||
state.FastFileBlocks.Add(block);
|
||||
}
|
||||
|
@ -6,19 +6,6 @@ namespace T6
|
||||
{
|
||||
#include "T6_Assets.h"
|
||||
|
||||
enum XFileBlock
|
||||
{
|
||||
XFILE_BLOCK_TEMP,
|
||||
XFILE_BLOCK_RUNTIME_VIRTUAL,
|
||||
XFILE_BLOCK_RUNTIME_PHYSICAL,
|
||||
XFILE_BLOCK_DELAY_VIRTUAL,
|
||||
XFILE_BLOCK_DELAY_PHYSICAL,
|
||||
XFILE_BLOCK_VIRTUAL,
|
||||
XFILE_BLOCK_PHYSICAL,
|
||||
XFILE_BLOCK_STREAMER_RESERVE,
|
||||
MAX_XFILE_COUNT,
|
||||
};
|
||||
|
||||
struct ScriptStringList
|
||||
{
|
||||
int count;
|
||||
|
@ -285,6 +285,19 @@ enum XAssetType
|
||||
ASSET_TYPE_FULL_COUNT = 0x40,
|
||||
};
|
||||
|
||||
enum XFileBlock
|
||||
{
|
||||
XFILE_BLOCK_TEMP,
|
||||
XFILE_BLOCK_RUNTIME_VIRTUAL,
|
||||
XFILE_BLOCK_RUNTIME_PHYSICAL,
|
||||
XFILE_BLOCK_DELAY_VIRTUAL,
|
||||
XFILE_BLOCK_DELAY_PHYSICAL,
|
||||
XFILE_BLOCK_VIRTUAL,
|
||||
XFILE_BLOCK_PHYSICAL,
|
||||
XFILE_BLOCK_STREAMER_RESERVE,
|
||||
MAX_XFILE_COUNT,
|
||||
};
|
||||
|
||||
union XAssetHeader
|
||||
{
|
||||
//XModelPieces *xmodelPieces; // Not an asset
|
||||
|
Loading…
x
Reference in New Issue
Block a user