From 488c0238381df50ccfd6a63dc8d83786fe18a4bb Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Fri, 22 Nov 2024 02:08:17 +0200 Subject: [PATCH] Add a way to show the indices of each tile, WIP --- src/UI/Canvas/Canvas.tscn | 4 ++++ src/UI/Canvas/TileModeIndices.gd | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/UI/Canvas/TileModeIndices.gd diff --git a/src/UI/Canvas/Canvas.tscn b/src/UI/Canvas/Canvas.tscn index 339f87727..2a3adbef4 100644 --- a/src/UI/Canvas/Canvas.tscn +++ b/src/UI/Canvas/Canvas.tscn @@ -18,6 +18,7 @@ [ext_resource type="Shader" path="res://src/Shaders/AutoInvertColors.gdshader" id="17_lowhf"] [ext_resource type="Script" path="res://src/UI/Canvas/ReferenceImages.gd" id="17_qfjb4"] [ext_resource type="Script" path="res://src/UI/Canvas/color_index.gd" id="18_o3xx2"] +[ext_resource type="Script" path="res://src/UI/Canvas/TileModeIndices.gd" id="19_7a6wb"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_6b0ox"] shader = ExtResource("1_253dh") @@ -113,3 +114,6 @@ script = ExtResource("16_nxilb") [node name="ReferenceImages" type="Node2D" parent="."] script = ExtResource("17_qfjb4") + +[node name="TileModeIndices" type="Node2D" parent="."] +script = ExtResource("19_7a6wb") diff --git a/src/UI/Canvas/TileModeIndices.gd b/src/UI/Canvas/TileModeIndices.gd new file mode 100644 index 000000000..980d9c6a5 --- /dev/null +++ b/src/UI/Canvas/TileModeIndices.gd @@ -0,0 +1,16 @@ +extends Node2D + + +func _input(event: InputEvent) -> void: + queue_redraw() + + +func _draw() -> void: + var current_cel := Global.current_project.get_current_cel() + if current_cel is CelTileMap: + var tilemap_cel := current_cel as CelTileMap + for i in tilemap_cel.indices.size(): + var x := float(tilemap_cel.tileset.tile_size.x) * (i % tilemap_cel.indices_x) + var y := float(tilemap_cel.tileset.tile_size.y) * (i / tilemap_cel.indices_x) + var pos := Vector2i(x, y + tilemap_cel.tileset.tile_size.y) + draw_string(Themes.get_font(), pos, str(tilemap_cel.indices[i]), 0, -1, 12)