Read new image size properties in tmj from Tiled 1.11.1

This commit is contained in:
Daniel Cronqvist 2025-04-24 22:44:17 +02:00
parent c27049780a
commit 58bb446e2b
4 changed files with 11 additions and 7 deletions

View file

@ -19,7 +19,7 @@ public partial class TestData
CompressionLevel = -1,
BackgroundColor = new TiledColor { R = 0, G = 0, B = 0, A = 0 },
Version = "1.10",
TiledVersion = "1.11.0",
TiledVersion = "1.11.2",
NextLayerID = 8,
NextObjectID = 7,
Tilesets = [
@ -172,8 +172,8 @@ public partial class TestData
{
Format = ImageFormat.Png,
Source = "tileset.png",
Width = fileExt == "tmx" ? 256 : 0, // Currently, json format does not
Height = fileExt == "tmx" ? 96 : 0 // include image dimensions in image layer https://github.com/mapeditor/tiled/issues/4028
Width = 256,
Height = 96
},
RepeatX = true
},

View file

@ -114,6 +114,8 @@
{
"id":4,
"image":"tileset.png",
"imageheight":96,
"imagewidth":256,
"name":"ImageLayer",
"opacity":1,
"repeatx":true,
@ -149,7 +151,7 @@
"nextobjectid":7,
"orientation":"orthogonal",
"renderorder":"right-down",
"tiledversion":"1.11.0",
"tiledversion":"1.11.2",
"tileheight":32,
"tilesets":[
{

View file

@ -1,5 +1,5 @@
<?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="8" nextobjectid="7">
<map version="1.10" tiledversion="1.11.2" orientation="orthogonal" renderorder="right-down" width="5" height="5" tilewidth="32" tileheight="32" infinite="0" nextlayerid="8" nextobjectid="7">
<tileset firstgid="1" source="tileset.tsx"/>
<group id="2" name="Root">
<objectgroup id="3" name="Objects">

View file

@ -19,6 +19,8 @@ public abstract partial class TmjReaderBase
var properties = ResolveAndMergeProperties(@class, element.GetOptionalPropertyCustom("properties", ReadProperties).GetValueOr([]));
var image = element.GetRequiredProperty<string>("image");
var imageWidth = element.GetOptionalProperty<int>("imagewidth").GetValueOr(0);
var imageHeight = element.GetOptionalProperty<int>("imageheight").GetValueOr(0);
var repeatX = element.GetOptionalProperty<bool>("repeatx").GetValueOr(false);
var repeatY = element.GetOptionalProperty<bool>("repeaty").GetValueOr(false);
var transparentColor = element.GetOptionalPropertyParseable<TiledColor>("transparentcolor");
@ -28,8 +30,8 @@ public abstract partial class TmjReaderBase
var imgModel = new Image
{
Format = Helpers.ParseImageFormatFromSource(image),
Height = 0,
Width = 0,
Height = imageHeight,
Width = imageWidth,
Source = image,
TransparentColor = transparentColor
};