Initial import from freelancer project
This commit is contained in:
commit
faecd672cd
7
plugin.cfg
Normal file
7
plugin.cfg
Normal file
|
@ -0,0 +1,7 @@
|
|||
[plugin]
|
||||
|
||||
name="Basic tools from thunderk.net"
|
||||
description="thunderk-basics"
|
||||
author="ThunderK"
|
||||
version="1.0"
|
||||
script="thunderk-basics.gd"
|
62
scene_tool.gd
Normal file
62
scene_tool.gd
Normal file
|
@ -0,0 +1,62 @@
|
|||
tool
|
||||
|
||||
static func empty_node(node: Node):
|
||||
""" Remove all children from a container node
|
||||
"""
|
||||
for child in node.get_children():
|
||||
child.queue_free()
|
||||
|
||||
static func set_parent(child: Node, parent: Node):
|
||||
""" Set a node's parent
|
||||
"""
|
||||
var cur_parent = child.get_parent()
|
||||
if cur_parent:
|
||||
if cur_parent == parent:
|
||||
return
|
||||
else:
|
||||
cur_parent.remove_child(child)
|
||||
parent.add_child(child)
|
||||
|
||||
static func set_owner(node: Node, owner: Node, force_inherited=false):
|
||||
""" Recursively set a owner
|
||||
"""
|
||||
if node != owner:
|
||||
node.set_owner(owner)
|
||||
if force_inherited or not node.filename:
|
||||
for child in node.get_children():
|
||||
set_owner(child, owner)
|
||||
|
||||
static func set_layer(node: Spatial, layer: int):
|
||||
""" Recursively set a display layer
|
||||
"""
|
||||
if node is VisualInstance:
|
||||
node.layers = layer
|
||||
else:
|
||||
for child in node.get_children():
|
||||
set_layer(child, layer)
|
||||
|
||||
static func pack(node: Node, update_owner=true) -> PackedScene:
|
||||
""" Pack a node as a PackedScene
|
||||
"""
|
||||
if update_owner:
|
||||
for child in node.get_children():
|
||||
set_owner(child, node)
|
||||
|
||||
var scene = PackedScene.new()
|
||||
if scene.pack(node) == OK:
|
||||
return scene
|
||||
else:
|
||||
return null
|
||||
|
||||
static func pack_as_file(node: Node, filename: String, update_owner=true):
|
||||
""" Pack a node in a file
|
||||
"""
|
||||
var scene = pack(node, update_owner)
|
||||
if scene:
|
||||
if ResourceSaver.save(filename, scene) != OK:
|
||||
push_error("Failed to save packed scene: %s" % filename)
|
||||
return FAILED
|
||||
else:
|
||||
push_error("Failed to pack packed scene: %s" % filename)
|
||||
return FAILED
|
||||
return OK
|
9
signal_tool.gd
Normal file
9
signal_tool.gd
Normal file
|
@ -0,0 +1,9 @@
|
|||
tool
|
||||
|
||||
static func add_to_signal_store(store: Array, path: NodePath, signal_name: String, method: String):
|
||||
store.append({"path": path, "signal": signal_name, "method": method})
|
||||
|
||||
static func apply_signal_store(base: Node, store: Array):
|
||||
for info in store:
|
||||
var node = base.get_node(info["path"])
|
||||
node.connect(info["signal"], base, info["method"], [node])
|
2
thunderk-basics.gd
Normal file
2
thunderk-basics.gd
Normal file
|
@ -0,0 +1,2 @@
|
|||
tool
|
||||
extends EditorPlugin
|
5
type_tool.gd
Normal file
5
type_tool.gd
Normal file
|
@ -0,0 +1,5 @@
|
|||
tool
|
||||
|
||||
static func update_dict(base: Dictionary, incoming: Dictionary):
|
||||
for key in incoming.keys():
|
||||
base[key] = incoming[key]
|
Reference in a new issue