-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from dcronqvist/enum-bug
Enum properties were not being properly parsed due to incorrect usage of Optional
- Loading branch information
Showing
7 changed files
with
227 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...a/Maps/map-with-custom-type-props-without-defs/map-with-custom-type-props-without-defs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System.Globalization; | ||
|
||
namespace DotTiled.Tests; | ||
|
||
public partial class TestData | ||
{ | ||
public static Map MapWithCustomTypePropsWithoutDefs() => new Map | ||
{ | ||
Class = "", | ||
Orientation = MapOrientation.Orthogonal, | ||
Width = 5, | ||
Height = 5, | ||
TileWidth = 32, | ||
TileHeight = 32, | ||
Infinite = false, | ||
ParallaxOriginX = 0, | ||
ParallaxOriginY = 0, | ||
RenderOrder = RenderOrder.RightDown, | ||
CompressionLevel = -1, | ||
BackgroundColor = Color.Parse("#00000000", CultureInfo.InvariantCulture), | ||
Version = "1.10", | ||
TiledVersion = "1.11.0", | ||
NextLayerID = 2, | ||
NextObjectID = 1, | ||
Layers = [ | ||
new TileLayer | ||
{ | ||
ID = 1, | ||
Name = "Tile Layer 1", | ||
Width = 5, | ||
Height = 5, | ||
Data = new Data | ||
{ | ||
Encoding = DataEncoding.Csv, | ||
GlobalTileIDs = new Optional<uint[]>([ | ||
0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0 | ||
]), | ||
FlippingFlags = new Optional<FlippingFlags[]>([ | ||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, | ||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, | ||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, | ||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, | ||
FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None, FlippingFlags.None | ||
]) | ||
} | ||
} | ||
], | ||
Properties = [ | ||
new ClassProperty | ||
{ | ||
Name = "customclassprop", | ||
PropertyType = "CustomClass", | ||
Value = [ | ||
new BoolProperty { Name = "boolinclass", Value = true }, | ||
new FloatProperty { Name = "floatinclass", Value = 13.37f }, | ||
new StringProperty { Name = "stringinclass", Value = "This is a set string" } | ||
] | ||
}, | ||
new IntProperty | ||
{ | ||
Name = "customenumintflagsprop", | ||
Value = 6 | ||
}, | ||
new IntProperty | ||
{ | ||
Name = "customenumintprop", | ||
Value = 3 | ||
}, | ||
new StringProperty | ||
{ | ||
Name = "customenumstringprop", | ||
Value = "CustomEnumString_2" | ||
}, | ||
new StringProperty | ||
{ | ||
Name = "customenumstringflagsprop", | ||
Value = "CustomEnumStringFlags_1,CustomEnumStringFlags_2" | ||
} | ||
] | ||
}; | ||
} |
68 changes: 68 additions & 0 deletions
68
.../Maps/map-with-custom-type-props-without-defs/map-with-custom-type-props-without-defs.tmj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ "compressionlevel":-1, | ||
"height":5, | ||
"infinite":false, | ||
"layers":[ | ||
{ | ||
"data":[0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0, | ||
0, 0, 0, 0, 0], | ||
"height":5, | ||
"id":1, | ||
"name":"Tile Layer 1", | ||
"opacity":1, | ||
"type":"tilelayer", | ||
"visible":true, | ||
"width":5, | ||
"x":0, | ||
"y":0 | ||
}], | ||
"nextlayerid":2, | ||
"nextobjectid":1, | ||
"orientation":"orthogonal", | ||
"properties":[ | ||
{ | ||
"name":"customclassprop", | ||
"propertytype":"CustomClass", | ||
"type":"class", | ||
"value": | ||
{ | ||
"boolinclass":true, | ||
"floatinclass":13.37, | ||
"stringinclass":"This is a set string" | ||
} | ||
}, | ||
{ | ||
"name":"customenumintflagsprop", | ||
"propertytype":"CustomEnumIntFlags", | ||
"type":"int", | ||
"value":6 | ||
}, | ||
{ | ||
"name":"customenumintprop", | ||
"propertytype":"CustomEnumInt", | ||
"type":"int", | ||
"value":3 | ||
}, | ||
{ | ||
"name":"customenumstringflagsprop", | ||
"propertytype":"CustomEnumStringFlags", | ||
"type":"string", | ||
"value":"CustomEnumStringFlags_1,CustomEnumStringFlags_2" | ||
}, | ||
{ | ||
"name":"customenumstringprop", | ||
"propertytype":"CustomEnumString", | ||
"type":"string", | ||
"value":"CustomEnumString_2" | ||
}], | ||
"renderorder":"right-down", | ||
"tiledversion":"1.11.0", | ||
"tileheight":32, | ||
"tilesets":[], | ||
"tilewidth":32, | ||
"type":"map", | ||
"version":"1.10", | ||
"width":5 | ||
} |
25 changes: 25 additions & 0 deletions
25
.../Maps/map-with-custom-type-props-without-defs/map-with-custom-type-props-without-defs.tmx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="5" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1"> | ||
<properties> | ||
<property name="customclassprop" type="class" propertytype="CustomClass"> | ||
<properties> | ||
<property name="boolinclass" type="bool" value="true"/> | ||
<property name="floatinclass" type="float" value="13.37"/> | ||
<property name="stringinclass" value="This is a set string"/> | ||
</properties> | ||
</property> | ||
<property name="customenumintflagsprop" type="int" propertytype="CustomEnumIntFlags" value="6"/> | ||
<property name="customenumintprop" type="int" propertytype="CustomEnumInt" value="3"/> | ||
<property name="customenumstringflagsprop" propertytype="CustomEnumStringFlags" value="CustomEnumStringFlags_1,CustomEnumStringFlags_2"/> | ||
<property name="customenumstringprop" propertytype="CustomEnumString" value="CustomEnumString_2"/> | ||
</properties> | ||
<layer id="1" name="Tile Layer 1" width="5" height="5"> | ||
<data encoding="csv"> | ||
0,0,0,0,0, | ||
0,0,0,0,0, | ||
0,0,0,0,0, | ||
0,0,0,0,0, | ||
0,0,0,0,0 | ||
</data> | ||
</layer> | ||
</map> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters