default values
This commit is contained in:
@@ -133,7 +133,7 @@ void DefinitionFile::WriteTypes(TemplateWriter& Template)
|
|||||||
{
|
{
|
||||||
bx::snprintf(Array, sizeof(Array), "[%u]", ArraySize);
|
bx::snprintf(Array, sizeof(Array), "[%u]", ArraySize);
|
||||||
}
|
}
|
||||||
Template.Write(WriteTemplates::StructField4, Type, t.FieldNames[fieldIdx], Array, "{}");
|
Template.Write(WriteTemplates::StructField4, Type, t.FieldNames[fieldIdx], Array, t.FieldVaules[fieldIdx]);
|
||||||
}
|
}
|
||||||
Template.Write(WriteTemplates::StructEnd);
|
Template.Write(WriteTemplates::StructEnd);
|
||||||
}
|
}
|
||||||
@@ -315,9 +315,14 @@ Parser::Result Parser::HandleType()
|
|||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
Def::Type& t = Definitions.Types[Definitions.TypeCount];
|
Def::Type& t = Definitions.Types[Definitions.TypeCount];
|
||||||
CHECK(ReadName(t.Name));
|
for (int32_t i = 0; i < Def::MaxFields; ++i)
|
||||||
|
{
|
||||||
|
bx::strCopy(t.FieldVaules[i], sizeof(t.FieldVaules[i]), "{}");
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK(ReadName(t.Name));
|
||||||
CHECK(SkipWhitespace());
|
CHECK(SkipWhitespace());
|
||||||
|
|
||||||
CHECK(ExpectChar("{"));
|
CHECK(ExpectChar("{"));
|
||||||
CHECK(SkipWhitespace());
|
CHECK(SkipWhitespace());
|
||||||
|
|
||||||
@@ -336,7 +341,7 @@ Parser::Result Parser::HandleType()
|
|||||||
bool NewLine = false;
|
bool NewLine = false;
|
||||||
CHECK(SkipWhitespace(&NewLine));
|
CHECK(SkipWhitespace(&NewLine));
|
||||||
|
|
||||||
if (!NewLine)
|
while (!NewLine)
|
||||||
{
|
{
|
||||||
Result Res;
|
Result Res;
|
||||||
if (CmpAdvance("Arr", Res, true) && Res == Result::OK)
|
if (CmpAdvance("Arr", Res, true) && Res == Result::OK)
|
||||||
@@ -345,9 +350,30 @@ Parser::Result Parser::HandleType()
|
|||||||
CHECK(ReadUint(t.FieldArraySizes[t.FieldCount]));
|
CHECK(ReadUint(t.FieldArraySizes[t.FieldCount]));
|
||||||
CHECK(ExpectChar(")"));
|
CHECK(ExpectChar(")"));
|
||||||
}
|
}
|
||||||
|
else if (CmpAdvance("Default", Res, true) && Res == OK)
|
||||||
|
{
|
||||||
|
CHECK(ExpectChar("("));
|
||||||
|
CHECK(ExpectChar("\""));
|
||||||
|
|
||||||
|
int32_t Remaining = bx::min(GetRemaining(), (int32_t)BX_COUNTOF(Def::Type::FieldVaules[0]));
|
||||||
|
for (int32_t i = 0; i < Remaining; ++i)
|
||||||
|
{
|
||||||
|
if (*ReadPtr != '\\' && CmpAdvance("\"", Res)) break;
|
||||||
|
t.FieldVaules[t.FieldCount][i] = *ReadPtr;
|
||||||
|
ReadPtr++;
|
||||||
|
}
|
||||||
|
if (Res != OK) return Res;
|
||||||
|
CHECK(ExpectChar(")"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_ERROR(Line, "Unknown token!");
|
||||||
|
ErrorLine();
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
CHECK(SkipWhitespace(&NewLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK(SkipWhitespace());
|
|
||||||
t.FieldCount++;
|
t.FieldCount++;
|
||||||
}
|
}
|
||||||
Definitions.TypeCount++;
|
Definitions.TypeCount++;
|
||||||
@@ -529,7 +555,6 @@ Parser::Result Parser::ReadOptionalEnumValues(Def::Enum& Enum, int32_t EntryIdx)
|
|||||||
int32_t Remaining = GetRemaining();
|
int32_t Remaining = GetRemaining();
|
||||||
for (int32_t i = 0; i < Remaining; ++i)
|
for (int32_t i = 0; i < Remaining; ++i)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (CmpAdvance("\"", Res)) break;
|
if (CmpAdvance("\"", Res)) break;
|
||||||
Enum.ExtraStringFields[extraIdx][EntryIdx][i] = *ReadPtr;
|
Enum.ExtraStringFields[extraIdx][EntryIdx][i] = *ReadPtr;
|
||||||
ReadPtr++;
|
ReadPtr++;
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ namespace Def
|
|||||||
FieldType FieldTypes[MaxFields];
|
FieldType FieldTypes[MaxFields];
|
||||||
char FieldNames[MaxFields][MaxNameLength];
|
char FieldNames[MaxFields][MaxNameLength];
|
||||||
uint32_t FieldArraySizes[MaxFields]{0};
|
uint32_t FieldArraySizes[MaxFields]{0};
|
||||||
|
char FieldVaules[MaxFields][128]{0};
|
||||||
char Name[MaxNameLength]{0};
|
char Name[MaxNameLength]{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,18 +24,23 @@ enum PuzzleElementType(u8)
|
|||||||
|
|
||||||
type PuzzleNode
|
type PuzzleNode
|
||||||
{
|
{
|
||||||
PuzzleElementType PlacedTypes
|
PuzzleElementType PlacedTypes Arr(4)
|
||||||
}
|
}
|
||||||
|
|
||||||
type StaticPuzzleCard
|
type StaticPuzzleCard
|
||||||
{
|
{
|
||||||
PuzzleNode Nodes Arr(8)
|
PuzzleNode Nodes Arr(4)
|
||||||
u16 ModelHandle
|
u16 ModelHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
type StaticPuzzleCardHandle
|
type StaticPuzzleCardHandle
|
||||||
{
|
{
|
||||||
u16 Idx
|
u16 Idx Default("UINT16_MAX")
|
||||||
|
}
|
||||||
|
|
||||||
|
type StaticPuzzleData
|
||||||
|
{
|
||||||
|
StaticPuzzleCard Cards Arr(64)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PuzzleCardStack
|
type PuzzleCardStack
|
||||||
@@ -58,10 +63,10 @@ type PuzzleData
|
|||||||
u8 WidthTiles
|
u8 WidthTiles
|
||||||
u8 HeightTiles
|
u8 HeightTiles
|
||||||
u32 AvailableCardCount
|
u32 AvailableCardCount
|
||||||
PuzzleCardStack AvailableCards Arr(8)
|
PuzzleCardStack AvailableCards Arr(16)
|
||||||
u32 PlacedCardCount
|
u32 PlacedCardCount
|
||||||
PlacedPuzzleCard PlacedCards Arr(8)
|
PlacedPuzzleCard PlacedCards Arr(256)
|
||||||
PuzzleNode PlacedNodes Arr(8)
|
PuzzleNode PlacedNodes Arr(1024)
|
||||||
u32 GoalPositionCount
|
u32 GoalPositionCount
|
||||||
ElemPos GoalPositions
|
ElemPos GoalPositions Arr(16)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,16 +52,20 @@ namespace Generated
|
|||||||
};
|
};
|
||||||
struct PuzzleNode
|
struct PuzzleNode
|
||||||
{
|
{
|
||||||
PuzzleElementType PlacedTypes = {};
|
PuzzleElementType PlacedTypes[4] = {};
|
||||||
};
|
};
|
||||||
struct StaticPuzzleCard
|
struct StaticPuzzleCard
|
||||||
{
|
{
|
||||||
PuzzleNode Nodes[8] = {};
|
PuzzleNode Nodes[4] = {};
|
||||||
uint16_t ModelHandle = {};
|
uint16_t ModelHandle = {};
|
||||||
};
|
};
|
||||||
struct StaticPuzzleCardHandle
|
struct StaticPuzzleCardHandle
|
||||||
{
|
{
|
||||||
uint16_t Idx = {};
|
uint16_t Idx = UINT16_MAX;
|
||||||
|
};
|
||||||
|
struct StaticPuzzleData
|
||||||
|
{
|
||||||
|
StaticPuzzleCard Cards[64] = {};
|
||||||
};
|
};
|
||||||
struct PuzzleCardStack
|
struct PuzzleCardStack
|
||||||
{
|
{
|
||||||
@@ -81,11 +85,11 @@ namespace Generated
|
|||||||
uint8_t WidthTiles = {};
|
uint8_t WidthTiles = {};
|
||||||
uint8_t HeightTiles = {};
|
uint8_t HeightTiles = {};
|
||||||
uint32_t AvailableCardCount = {};
|
uint32_t AvailableCardCount = {};
|
||||||
PuzzleCardStack AvailableCards[8] = {};
|
PuzzleCardStack AvailableCards[16] = {};
|
||||||
uint32_t PlacedCardCount = {};
|
uint32_t PlacedCardCount = {};
|
||||||
PlacedPuzzleCard PlacedCards[8] = {};
|
PlacedPuzzleCard PlacedCards[256] = {};
|
||||||
PuzzleNode PlacedNodes[8] = {};
|
PuzzleNode PlacedNodes[1024] = {};
|
||||||
uint32_t GoalPositionCount = {};
|
uint32_t GoalPositionCount = {};
|
||||||
ElemPos GoalPositions = {};
|
ElemPos GoalPositions[16] = {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user