Skip to content

Commit

Permalink
Release 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiamo2 committed Nov 13, 2024
1 parent aa1a81b commit a319aa5
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 30 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.1.1 / 1.7.1] - 2024-11-13

### Added
- Like 'instance' now also propagate 'XXXbody' tile class types to tilemap objects

### Fixed
- Fixed issue #63

## [2.1.0 / 1.7.0] - 2024-10-21

### Added
- Added new string option 'Custom Data Prefix' (Default value: 'data_') to make it possible to explicitly assign
the custom property of a tile to Godot's Tile Custom Data.
Properties with a name not starting with that prefix are now assigned only to the tile's meta data.
(If neccessary, set the option to an empty string to generate the previous behavior)

### Fixed
- Fixed problem with tile objects being slightly off with tileset images having separation and/or margins.
- Fixed problems resulting from unreliable tileset entries (tilecount / columns).
(Both are now calculated from the width and height of the tileset image)
Expand Down
19 changes: 14 additions & 5 deletions CSharp/addons/YATI/TilemapCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -770,13 +770,18 @@ private static void SetSpriteOffset(Sprite2D objSprite, float width, float heigh
};
}

private static void ConvertMetaDataToObjProperties(TileData td, Dictionary obj)
private void ConvertMetaDataToObjProperties(TileData td, Dictionary obj)
{
var metaList = td.GetMetaList();
foreach (var metaName in metaList)
{
if (((string)metaName)?.ToLower() is ClassInternal or GodotNodeTypeProperty)
switch (((string)metaName)?.ToLower())
{
case GodotNodeTypeProperty:
case ClassInternal when !_addClassAsMetadata:
continue;
}

var metaVal = td.GetMeta(metaName);
var metaType = metaVal.VariantType;
var propDict = new Dictionary();
Expand Down Expand Up @@ -1055,7 +1060,7 @@ private void HandleObject(Dictionary obj, Node layerNode, TileSet tileset, Vecto
td = gidSource.GetTileData(Vector2I.Zero, 0);
}

// Tile objects could also be classified as instance...
// Tile objects may already have been classified as instance in the tileset
var objIsInstance = godotType == GodotType.Instance && !obj.ContainsKey("template") && !obj.ContainsKey("text");
var tileClass = "";
if (td.HasMeta(ClassInternal))
Expand Down Expand Up @@ -1107,6 +1112,12 @@ private void HandleObject(Dictionary obj, Node layerNode, TileSet tileset, Vecto

return;
}

// Tile objects may already have been classified as ...body in the tileset
if (tileClass != "" && godotType == GodotType.Empty)
godotType = GetGodotType(tileClass);

ConvertMetaDataToObjProperties(td, obj);

var idx = (int)td.GetCustomData(CustomDataInternal);
if (idx > 0)
Expand Down Expand Up @@ -1138,8 +1149,6 @@ private void HandleObject(Dictionary obj, Node layerNode, TileSet tileset, Vecto
}
}

ConvertMetaDataToObjProperties(td, obj);

objSprite.FlipH = flippedH;
objSprite.FlipV = flippedV;

Expand Down
2 changes: 1 addition & 1 deletion CSharp/addons/YATI/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="YATI"
description=""
author="Roland Helmerichs"
version="2.1.0"
version="2.1.1"
script="TiledImport.cs"
19 changes: 14 additions & 5 deletions CSharp/runtime/TilemapCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,18 @@ private static void SetSpriteOffset(Sprite2D objSprite, float width, float heigh
};
}

private static void ConvertMetaDataToObjProperties(TileData td, Dictionary obj)
private void ConvertMetaDataToObjProperties(TileData td, Dictionary obj)
{
var metaList = td.GetMetaList();
foreach (var metaName in metaList)
{
if (((string)metaName)?.ToLower() is ClassInternal or GodotNodeTypeProperty)
switch (((string)metaName)?.ToLower())
{
case GodotNodeTypeProperty:
case ClassInternal when !_addClassAsMetadata:
continue;
}

var metaVal = td.GetMeta(metaName);
var metaType = metaVal.VariantType;
var propDict = new Dictionary();
Expand Down Expand Up @@ -1053,7 +1058,7 @@ private void HandleObject(Dictionary obj, Node layerNode, TileSet tileset, Vecto
td = gidSource.GetTileData(Vector2I.Zero, 0);
}

// Tile objects could also be classified as instance...
// Tile objects may already have been classified as instance in the tileset
var objIsInstance = godotType == GodotType.Instance && !obj.ContainsKey("template") && !obj.ContainsKey("text");
var tileClass = "";
if (td.HasMeta(ClassInternal))
Expand Down Expand Up @@ -1105,6 +1110,12 @@ private void HandleObject(Dictionary obj, Node layerNode, TileSet tileset, Vecto

return;
}

// Tile objects may already have been classified as ...body in the tileset
if (tileClass != "" && godotType == GodotType.Empty)
godotType = GetGodotType(tileClass);

ConvertMetaDataToObjProperties(td, obj);

var idx = (int)td.GetCustomData(CustomDataInternal);
if (idx > 0)
Expand Down Expand Up @@ -1136,8 +1147,6 @@ private void HandleObject(Dictionary obj, Node layerNode, TileSet tileset, Vecto
}
}

ConvertMetaDataToObjProperties(td, obj);

objSprite.FlipH = flippedH;
objSprite.FlipV = flippedV;

Expand Down
1 change: 0 additions & 1 deletion CSharp/runtime/XmlParserCtrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class XmlParserCtrl
private readonly XmlParser _parser = new();
private string _parsedFileName;


public Error Open(string sourceFile)
{
_parsedFileName = sourceFile;
Expand Down
14 changes: 10 additions & 4 deletions GDScript/addons/YATI/TilemapCreator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,9 @@ func set_sprite_offset(obj_sprite: Sprite2D, width: float, height: float, alignm
func convert_metadata_to_obj_properties(td: TileData, obj: Dictionary) -> void:
var meta_list = td.get_meta_list()
for meta_name in meta_list:
if meta_name.to_lower() in [CLASS_INTERNAL, GODOT_NODE_TYPE_PROPERTY]:
if meta_name.to_lower() == GODOT_NODE_TYPE_PROPERTY:
continue
if meta_name.to_lower() == CLASS_INTERNAL and not _add_class_as_metadata:
continue
var meta_val = td.get_meta(meta_name)
var meta_type = typeof(meta_val)
Expand Down Expand Up @@ -868,7 +870,7 @@ func handle_object(obj: Dictionary, layer_node: Node, tileset: TileSet, offset:
obj_sprite.scale = Vector2(scale_x, scale_y)
td = gid_source.get_tile_data(Vector2i.ZERO, 0)

# Tile objects could also be classified as instance...
# Tile objects may already have been classified as instance in the tileset
var obj_is_instance = godot_type == _godot_type.INSTANCE and not obj.has("template") and not obj.has("text")
var tile_class = ""
if td.has_meta(CLASS_INTERNAL):
Expand Down Expand Up @@ -910,6 +912,12 @@ func handle_object(obj: Dictionary, layer_node: Node, tileset: TileSet, offset:
handle_properties(instance, obj["properties"])
return

# Tile objects may already have been classified as ...body in the tileset
if tile_class != "" and godot_type == _godot_type.EMPTY:
godot_type = get_godot_type(tile_class)

convert_metadata_to_obj_properties(td, obj)

var idx = td.get_custom_data(CUSTOM_DATA_INTERNAL)
if idx > 0:
var parent = {
Expand All @@ -934,8 +942,6 @@ func handle_object(obj: Dictionary, layer_node: Node, tileset: TileSet, offset:
if obj.has("properties"):
handle_properties(parent, obj["properties"])

convert_metadata_to_obj_properties(td, obj)

obj_sprite.flip_h = flippedH
obj_sprite.flip_v = flippedV

Expand Down
2 changes: 1 addition & 1 deletion GDScript/addons/YATI/TilesetCreator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func create_or_append(tile_set: Dictionary):

_current_atlas_source.texture = texture
_columns = _current_atlas_source.texture.get_width() / _tile_size.x
_tile_count = _columns * _current_atlas_source.texture.get_width() / _tile_size.x
_tile_count = _columns * _current_atlas_source.texture.get_height() / _tile_size.x

register_atlas_source(added_source_id, _tile_count, -1, _tile_offset)
var atlas_grid_size = _current_atlas_source.get_atlas_grid_size()
Expand Down
2 changes: 1 addition & 1 deletion GDScript/addons/YATI/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="YATI"
description=""
author="Roland Helmerichs"
version="2.1.0"
version="2.1.1"
script="TiledImport.gd"
14 changes: 10 additions & 4 deletions GDScript/runtime/TilemapCreator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,9 @@ func set_sprite_offset(obj_sprite: Sprite2D, width: float, height: float, alignm
func convert_metadata_to_obj_properties(td: TileData, obj: Dictionary) -> void:
var meta_list = td.get_meta_list()
for meta_name in meta_list:
if meta_name.to_lower() in [CLASS_INTERNAL, GODOT_NODE_TYPE_PROPERTY]:
if meta_name.to_lower() == GODOT_NODE_TYPE_PROPERTY:
continue
if meta_name.to_lower() == CLASS_INTERNAL and not _add_class_as_metadata:
continue
var meta_val = td.get_meta(meta_name)
var meta_type = typeof(meta_val)
Expand Down Expand Up @@ -867,7 +869,7 @@ func handle_object(obj: Dictionary, layer_node: Node, tileset: TileSet, offset:
obj_sprite.scale = Vector2(scale_x, scale_y)
td = gid_source.get_tile_data(Vector2i.ZERO, 0)

# Tile objects could also be classified as instance...
# Tile objects may already have been classified as instance in the tileset
var obj_is_instance = godot_type == _godot_type.INSTANCE and not obj.has("template") and not obj.has("text")
var tile_class = ""
if td.has_meta(CLASS_INTERNAL):
Expand Down Expand Up @@ -909,6 +911,12 @@ func handle_object(obj: Dictionary, layer_node: Node, tileset: TileSet, offset:
handle_properties(instance, obj["properties"])
return

# Tile objects may already have been classified as ...body in the tileset
if tile_class != "" and godot_type == _godot_type.EMPTY:
godot_type = get_godot_type(tile_class)

convert_metadata_to_obj_properties(td, obj)

var idx = td.get_custom_data(CUSTOM_DATA_INTERNAL)
if idx > 0:
var parent = {
Expand All @@ -933,8 +941,6 @@ func handle_object(obj: Dictionary, layer_node: Node, tileset: TileSet, offset:
if obj.has("properties"):
handle_properties(parent, obj["properties"])

convert_metadata_to_obj_properties(td, obj)

obj_sprite.flip_h = flippedH
obj_sprite.flip_v = flippedV

Expand Down
2 changes: 1 addition & 1 deletion GDScript/runtime/TilesetCreator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func create_or_append(tile_set: Dictionary):

_current_atlas_source.texture = texture
_columns = _current_atlas_source.texture.get_width() / _tile_size.x
_tile_count = _columns * _current_atlas_source.texture.get_width() / _tile_size.x
_tile_count = _columns * _current_atlas_source.texture.get_height() / _tile_size.x

register_atlas_source(added_source_id, _tile_count, -1, _tile_offset)
var atlas_grid_size = _current_atlas_source.get_atlas_grid_size()
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ created by the [Tiled Map Editor](http://www.mapeditor.org).

Tested on Windows 10 with Godot 4.3/4.2.2 and Tiled 1.11.0 (Tiled maps from older Tiled versions may work too)

Latest version: 2.1.0 (needs Godot 4.3.0 or higher)
Downloads: [GDScript version](../../releases/download/v2.1.0/v2.1.0-gdscript.zip) / [CSharp version](../../releases/download/v2.1.0/v2.1.0-csharp.zip)
Latest version: 2.1.1 (needs Godot 4.3.0 or higher)
Downloads: [GDScript version](../../releases/download/v2.1.1/v2.1.1-gdscript.zip) / [CSharp version](../../releases/download/v2.1.1/v2.1.1-csharp.zip)

Latest version for Godot 4.2.x: 1.7.0
Version 1.7.0 downloads: [GDScript version](../../releases/download/v1.7.0/v1.7.0-gdscript.zip) / [CSharp version](../../releases/download/v1.7.0/v1.7.0-csharp.zip)
Latest version for Godot 4.2.x: 1.7.1
Version 1.7.1 downloads: [GDScript version](../../releases/download/v1.7.1/v1.7.1-gdscript.zip) / [CSharp version](../../releases/download/v1.7.1/v1.7.1-csharp.zip)

**New since v1.5.2:** Runtime packages are now additionally available.
For installation and usage please refer to the [runtime document](Runtime.md)
Expand All @@ -20,7 +20,7 @@ For installation and usage please refer to the [runtime document](Runtime.md)

The addon is available in GDScript as well as in C# for the Mono version of Godot 4.

- Download either the [GDScript version](../../releases/download/v2.1.0/v2.1.0-gdscript.zip) or the [CSharp version](../../releases/download/v2.1.0/v2.1.0-csharp.zip)
- Download either the [GDScript version](../../releases/download/v2.1.1/v2.1.1-gdscript.zip) or the [CSharp version](../../releases/download/v2.1.1/v2.1.1-csharp.zip)
- Move the unzipped addon folder with its entire content to your Godot project folder
- After starting your project in Godot the plugin should appear at Project>>Project Settings...>>Plugins

Expand Down
4 changes: 2 additions & 2 deletions Runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
The YATI runtime package allows for importing Tiled maps during (game) runtime.
To offer such a package was proposed by Jeff Brooks (see issue #16) as being of value for several users.

Like for the editor plugin there's a [GDScript version](../../releases/download/v2.1.0/runtime-v2.1.0-gdscript.zip) and a [CSharp version](../../releases/download/v2.1.0/runtime-v2.1.0-csharp.zip) available.
Like for the editor plugin there's a [GDScript version](../../releases/download/v2.1.1/runtime-v2.1.1-gdscript.zip) and a [CSharp version](../../releases/download/v2.1.1/runtime-v2.1.1-csharp.zip) available.

(Runtime downloads for Godot 4.2.x: [GDScript version](../../releases/download/v1.7.0/runtime-v1.7.0-gdscript.zip) and a [CSharp version](../../releases/download/v1.7.0/runtime-v1.7.0-csharp.zip))
(Runtime downloads for Godot 4.2.x: [GDScript version](../../releases/download/v1.7.1/runtime-v1.7.1-gdscript.zip) and a [CSharp version](../../releases/download/v1.7.1/runtime-v1.7.1-csharp.zip))

## Installation

Expand Down

0 comments on commit a319aa5

Please sign in to comment.