mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-29 02:29:18 +01:00
The new tool can now save, also improved it's code, and fixed a few bugs.
This commit is contained in:
parent
7d66723e19
commit
c45c7eaa9a
@ -2,8 +2,8 @@ tool
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
class_name LayeredTextureMaker
|
class_name LayeredTextureMaker
|
||||||
|
|
||||||
export(Vector2) var texture_size = Vector2(16, 16) setget set_tex_size
|
export(Vector2) var texture_size : Vector2 = Vector2(16, 16) setget set_tex_size
|
||||||
export(String) var texture_name = ""
|
export(Texture) var texture : Texture = null
|
||||||
|
|
||||||
export(float) var refresh_rate : float = 2.0
|
export(float) var refresh_rate : float = 2.0
|
||||||
export(bool) var save : bool = false setget save_set
|
export(bool) var save : bool = false setget save_set
|
||||||
@ -12,46 +12,39 @@ var preview_node : Sprite = null
|
|||||||
var viewport : Viewport = null
|
var viewport : Viewport = null
|
||||||
|
|
||||||
var last_refresh : float = 0
|
var last_refresh : float = 0
|
||||||
|
var queued_save : bool = false
|
||||||
|
|
||||||
|
const DEBUG_TREE : bool = false
|
||||||
|
|
||||||
func _enter_tree():
|
func _enter_tree():
|
||||||
|
if not Engine.editor_hint:
|
||||||
|
return
|
||||||
|
|
||||||
set_meta("_edit_lock_", true)
|
set_meta("_edit_lock_", true)
|
||||||
emit_signal("item_lock_status_changed")
|
#emit_signal("item_lock_status_changed")
|
||||||
create_preview()
|
create_preview()
|
||||||
|
set_process(true)
|
||||||
|
|
||||||
func create_preview():
|
func create_preview():
|
||||||
for c in get_children():
|
for c in get_children():
|
||||||
if c.name == "Preview":
|
if c.name == "Preview":
|
||||||
preview_node = c
|
c.name = "------"
|
||||||
|
c.queue_free()
|
||||||
for ch in preview_node.get_children():
|
|
||||||
if ch is Viewport:
|
|
||||||
viewport = ch as Viewport
|
|
||||||
break
|
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if viewport != null:
|
|
||||||
viewport.queue_free()
|
|
||||||
|
|
||||||
if preview_node != null:
|
|
||||||
preview_node.queue_free()
|
|
||||||
|
|
||||||
|
|
||||||
preview_node = Sprite.new() as Sprite
|
preview_node = Sprite.new() as Sprite
|
||||||
preview_node.name = "Preview"
|
preview_node.name = "Preview"
|
||||||
preview_node.centered = false
|
preview_node.centered = false
|
||||||
add_child(preview_node)
|
add_child(preview_node)
|
||||||
|
|
||||||
#don't, so it won't show up in the inspector
|
if Engine.editor_hint and DEBUG_TREE:
|
||||||
#if Engine.editor_hint:
|
preview_node.owner = get_tree().edited_scene_root
|
||||||
# preview_node.owner = get_tree().edited_scene_root
|
|
||||||
|
|
||||||
viewport = Viewport.new()
|
viewport = Viewport.new()
|
||||||
preview_node.add_child(viewport)
|
preview_node.add_child(viewport)
|
||||||
|
|
||||||
#don't, so it won't show up in the inspector
|
if Engine.editor_hint and DEBUG_TREE:
|
||||||
#if Engine.editor_hint:
|
viewport.owner = get_tree().edited_scene_root
|
||||||
# viewport.owner = get_tree().edited_scene_root
|
|
||||||
|
|
||||||
viewport.set_vflip(true)
|
viewport.set_vflip(true)
|
||||||
viewport.set_size(texture_size)
|
viewport.set_size(texture_size)
|
||||||
@ -61,6 +54,9 @@ func create_preview():
|
|||||||
set_process(true)
|
set_process(true)
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
if (queued_save):
|
||||||
|
save()
|
||||||
|
|
||||||
#not the best solution, but works for now
|
#not the best solution, but works for now
|
||||||
last_refresh += delta
|
last_refresh += delta
|
||||||
|
|
||||||
@ -71,16 +67,29 @@ func _process(delta):
|
|||||||
ch.queue_free()
|
ch.queue_free()
|
||||||
|
|
||||||
for ch in get_children():
|
for ch in get_children():
|
||||||
viewport.add_child(ch.duplicate())
|
if ch.name == "Preview":
|
||||||
|
continue
|
||||||
|
|
||||||
|
var n = ch.duplicate()
|
||||||
|
viewport.add_child(n)
|
||||||
|
|
||||||
|
if Engine.editor_hint and DEBUG_TREE:
|
||||||
|
n.owner = get_tree().edited_scene_root
|
||||||
|
|
||||||
if get_children().has(preview_node) and get_child(get_child_count() - 1) != preview_node:
|
if get_children().has(preview_node) and get_child(get_child_count() - 1) != preview_node:
|
||||||
move_child(preview_node, get_child_count() - 1)
|
move_child(preview_node, get_child_count() - 1)
|
||||||
|
|
||||||
|
queued_save = true
|
||||||
|
|
||||||
|
|
||||||
func save() -> void:
|
func save() -> void:
|
||||||
if texture_name == "":
|
queued_save = false
|
||||||
print("Set a name for your texture!")
|
|
||||||
|
if texture == null:
|
||||||
|
#print("LayeredTextureMaker: Set a target texture!")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
texture.set_data(viewport.get_texture().get_data())
|
||||||
|
|
||||||
func preview_refresh() -> void:
|
func preview_refresh() -> void:
|
||||||
for ch in viewport.get_children():
|
for ch in viewport.get_children():
|
||||||
|
@ -1,10 +1,21 @@
|
|||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://texture_tools/LayeredTextureMaker.gd" type="Script" id=1]
|
[ext_resource path="res://texture_tools/LayeredTextureMaker.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://icon.png" type="Texture" id=2]
|
||||||
|
[ext_resource path="res://texture_tools/test/new_packerimageresource.tres" type="Texture" id=3]
|
||||||
|
|
||||||
[node name="LayeredTextureMaker" type="Node2D"]
|
[node name="LayeredTextureMaker" type="Node2D"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_lock_": true
|
"_edit_lock_": true
|
||||||
}
|
}
|
||||||
refresh_rate = 3.0
|
texture = ExtResource( 3 )
|
||||||
|
refresh_rate = 2.0
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
modulate = Color( 0.780392, 0.478431, 0.478431, 1 )
|
||||||
|
self_modulate = Color( 0.454902, 1, 0.796078, 1 )
|
||||||
|
position = Vector2( 8.29768, 10.7308 )
|
||||||
|
rotation = 0.724902
|
||||||
|
scale = Vector2( 0.152605, 0.115388 )
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
13
game/texture_tools/test/new_packerimageresource.tres
Normal file
13
game/texture_tools/test/new_packerimageresource.tres
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[gd_resource type="PackerImageResource" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[sub_resource type="Image" id=1]
|
||||||
|
data = {
|
||||||
|
"data": PoolByteArray( 73, 101, 123, 70, 79, 86, 75, 75, 75, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 80, 135, 173, 73, 111, 137, 73, 77, 79, 75, 75, 76, 76, 76, 76, 76, 76, 76, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 81, 139, 180, 81, 135, 174, 72, 97, 115, 74, 75, 76, 76, 76, 76, 75, 75, 75, 74, 74, 74, 74, 75, 75, 71, 77, 82, 72, 75, 78, 74, 75, 75, 75, 75, 75, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 81, 140, 181, 81, 139, 180, 80, 125, 157, 73, 93, 106, 74, 77, 79, 72, 74, 76, 73, 75, 76, 67, 79, 87, 69, 109, 136, 73, 109, 134, 70, 88, 100, 72, 76, 78, 75, 75, 75, 76, 76, 76, 76, 76, 76, 76, 76, 76, 81, 140, 181, 81, 140, 181, 81, 138, 179, 79, 132, 168, 74, 120, 152, 73, 103, 124, 70, 92, 108, 72, 106, 130, 73, 125, 161, 72, 135, 176, 74, 134, 174, 75, 113, 139, 70, 81, 89, 74, 74, 74, 76, 76, 76, 76, 76, 76, 81, 140, 181, 81, 140, 181, 81, 141, 181, 78, 139, 182, 75, 136, 185, 72, 135, 187, 73, 133, 177, 74, 131, 170, 73, 136, 179, 74, 141, 187, 74, 141, 187, 74, 138, 182, 75, 124, 158, 71, 85, 94, 74, 74, 74, 76, 76, 76, 82, 142, 182, 81, 141, 181, 81, 140, 182, 75, 139, 187, 73, 138, 190, 72, 138, 191, 72, 137, 190, 73, 140, 188, 74, 141, 188, 74, 142, 189, 74, 142, 189, 74, 141, 188, 74, 134, 176, 73, 105, 127, 72, 75, 76, 75, 75, 75, 120, 169, 200, 91, 146, 185, 110, 136, 158, 89, 135, 174, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191, 73, 140, 190, 74, 142, 189, 74, 142, 189, 74, 142, 189, 74, 139, 184, 67, 96, 115, 73, 74, 75, 76, 76, 76, 206, 224, 232, 189, 208, 221, 175, 183, 189, 132, 139, 151, 93, 134, 171, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191, 73, 140, 190, 74, 142, 189, 74, 141, 188, 74, 138, 181, 72, 105, 127, 72, 76, 78, 75, 75, 75, 159, 166, 172, 169, 171, 179, 197, 204, 210, 171, 181, 187, 126, 134, 147, 96, 133, 166, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 139, 191, 74, 142, 189, 74, 141, 187, 74, 133, 173, 68, 95, 113, 73, 75, 77, 77, 78, 80, 86, 88, 91, 111, 115, 118, 206, 210, 216, 141, 146, 157, 118, 127, 141, 96, 133, 165, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 139, 191, 74, 142, 189, 74, 141, 187, 74, 134, 175, 69, 99, 122, 87, 89, 91, 69, 69, 70, 76, 78, 80, 116, 117, 121, 203, 207, 212, 131, 144, 158, 90, 136, 171, 73, 141, 190, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 139, 191, 74, 142, 189, 74, 141, 188, 74, 135, 177, 167, 174, 175, 98, 101, 103, 71, 72, 74, 131, 133, 135, 222, 226, 233, 125, 165, 193, 76, 143, 189, 74, 142, 189, 74, 141, 189, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191, 74, 141, 189, 74, 142, 189, 153, 160, 162, 191, 197, 199, 148, 151, 153, 178, 182, 183, 128, 161, 183, 80, 144, 187, 74, 142, 189, 75, 142, 189, 74, 142, 189, 74, 142, 189, 72, 139, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191, 73, 141, 190, 96, 143, 174, 122, 125, 130, 155, 162, 163, 139, 169, 187, 87, 144, 183, 82, 144, 186, 79, 144, 189, 77, 143, 189, 77, 143, 189, 75, 142, 189, 74, 142, 189, 72, 139, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191, 86, 145, 185, 91, 142, 177, 106, 133, 153, 91, 146, 182, 86, 145, 185, 87, 147, 188, 86, 148, 190, 86, 149, 192, 97, 155, 196, 78, 143, 189, 75, 143, 189, 74, 142, 189, 72, 139, 191, 72, 138, 191, 72, 138, 191, 72, 138, 191 ),
|
||||||
|
"format": "RGB8",
|
||||||
|
"height": 16,
|
||||||
|
"mipmaps": false,
|
||||||
|
"width": 16
|
||||||
|
}
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
data = SubResource( 1 )
|
Loading…
Reference in New Issue
Block a user