-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add template support #170
Add template support #170
Changes from 20 commits
6cf613c
cd6b0ae
9efbbfa
00f6f88
4e25921
332c93a
ebe7b74
ab4ba5b
edf3ba9
69aff69
aecbcb5
be57545
461e8a6
888ddba
4eb7734
695eb94
aa63476
fab0499
6707dca
09cca16
99bf1cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<map version="1.4" tiledversion="1.4.2" orientation="orthogonal" renderorder="right-down" width="3" height="3" tilewidth="32" tileheight="32" infinite="0" nextlayerid="3" nextobjectid="3"> | ||
<tileset firstgid="1" source="tilesheet.tsx"/> | ||
<layer id="1" name="Tile Layer 1" width="3" height="3"> | ||
<data encoding="csv"> | ||
6,7,8, | ||
20,21,22, | ||
34,35,36 | ||
</data> | ||
</layer> | ||
<objectgroup id="2" name="Object Layer 1"> | ||
<object id="1" template="tiled_object_template.tx" x="32" y="32"> | ||
<properties> | ||
</properties> | ||
</object> | ||
<object id="2" gid="45" x="0" y="32" width="32" height="32"/> | ||
</objectgroup> | ||
</map> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<template> | ||
<tileset firstgid="1" source="tilesheet_template.tsx"/> | ||
<object gid="45" width="32" height="32"> | ||
<properties> | ||
<property name="property" type="int" value="1"/> | ||
</properties> | ||
</object> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<tileset version="1.4" tiledversion="1.4.0" name="tilesheet_template" tilewidth="32" tileheight="32" tilecount="84" columns="14"> | ||
<properties> | ||
<property name="tileset property" value="tsp"/> | ||
</properties> | ||
<image source="tilesheet.png" width="448" height="192"/> | ||
<tile id="1"> | ||
<properties> | ||
<property name="a tile property" value="123"/> | ||
</properties> | ||
</tile> | ||
</tileset> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
use std::collections::HashMap; | ||
use std::path::Path; | ||
use std::{collections::HashMap, path::Path, sync::Arc}; | ||
|
||
use crate::{ | ||
error::Result, | ||
layers::{LayerData, LayerTag}, | ||
map::MapTilesetGid, | ||
properties::{parse_properties, Properties}, | ||
util::*, | ||
Error, Layer, | ||
Error, Layer, MapTilesetGid, ResourceCache, ResourceReader, Tileset, | ||
}; | ||
|
||
/// The raw data of a [`GroupLayer`]. Does not include a reference to its parent [`Map`](crate::Map). | ||
|
@@ -22,6 +20,9 @@ impl GroupLayerData { | |
infinite: bool, | ||
map_path: &Path, | ||
tilesets: &[MapTilesetGid], | ||
for_tileset: Option<Arc<Tileset>>, | ||
reader: &mut impl ResourceReader, | ||
cache: &mut impl ResourceCache, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that in many places we're passing around both a reader and a cache. Would it make sense to pass around a loader instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure, Loader owns the reader/cache There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does that pose a problem for passing |
||
) -> Result<(Self, Properties)> { | ||
let mut properties = HashMap::new(); | ||
let mut layers = Vec::new(); | ||
|
@@ -34,6 +35,8 @@ impl GroupLayerData { | |
infinite, | ||
map_path, | ||
tilesets, | ||
for_tileset.as_ref().cloned(),reader, | ||
cache | ||
)?); | ||
Ok(()) | ||
}, | ||
|
@@ -45,6 +48,8 @@ impl GroupLayerData { | |
infinite, | ||
map_path, | ||
tilesets, | ||
for_tileset.as_ref().cloned(),reader, | ||
cache | ||
)?); | ||
Ok(()) | ||
}, | ||
|
@@ -56,6 +61,8 @@ impl GroupLayerData { | |
infinite, | ||
map_path, | ||
tilesets, | ||
for_tileset.as_ref().cloned(),reader, | ||
cache | ||
)?); | ||
Ok(()) | ||
}, | ||
|
@@ -67,6 +74,8 @@ impl GroupLayerData { | |
infinite, | ||
map_path, | ||
tilesets, | ||
for_tileset.as_ref().cloned(),reader, | ||
cache | ||
)?); | ||
Ok(()) | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe these changes should be done in a different PR.