Added an option to save the library and updated the library
@ -109,17 +109,27 @@ func add_item(item, item_name, item_icon = null, item_parent = null, force_expan
|
|||||||
new_parent.set_text(0, prefix)
|
new_parent.set_text(0, prefix)
|
||||||
return add_item(item, suffix, item_icon, new_parent, force_expand)
|
return add_item(item, suffix, item_icon, new_parent, force_expand)
|
||||||
|
|
||||||
func serialize_library(array : Array, library_name : String = "", item : TreeItem = null) -> void:
|
func serialize_library(array : Array, library_name : String = "", item : TreeItem = null, icon_path : String = "") -> void:
|
||||||
if item == null:
|
if item == null:
|
||||||
item = tree.get_root()
|
item = tree.get_root()
|
||||||
item = item.get_children()
|
item = item.get_children()
|
||||||
while item != null:
|
while item != null:
|
||||||
if item.get_metadata(0) != null:
|
if item.get_metadata(0) != null:
|
||||||
var m : Dictionary = item.get_metadata(0)
|
var m : Dictionary = item.get_metadata(0)
|
||||||
|
if icon_path != "":
|
||||||
|
pass
|
||||||
if library_name == "" or (m.has("library") and m.library == library_name):
|
if library_name == "" or (m.has("library") and m.library == library_name):
|
||||||
var copy : Dictionary = m.duplicate()
|
var copy : Dictionary = m.duplicate()
|
||||||
copy.erase("library")
|
copy.erase("library")
|
||||||
|
copy.collapsed = item.collapsed
|
||||||
array.append(copy)
|
array.append(copy)
|
||||||
|
elif !item.collapsed:
|
||||||
|
var item_path = item.get_text(0)
|
||||||
|
var item_parent = item.get_parent()
|
||||||
|
while item_parent != tree.get_root():
|
||||||
|
item_path = item_parent.get_text(0)+"/"+item_path
|
||||||
|
item_parent = item_parent.get_parent()
|
||||||
|
array.append({ tree_item=item_path, collapsed=false })
|
||||||
serialize_library(array, library_name, item)
|
serialize_library(array, library_name, item)
|
||||||
item = item.get_next()
|
item = item.get_next()
|
||||||
|
|
||||||
@ -131,5 +141,16 @@ func save_library(library_name : String, item : TreeItem = null) -> void:
|
|||||||
file.store_string(JSON.print({lib=array}, "\t", true))
|
file.store_string(JSON.print({lib=array}, "\t", true))
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
func _on_Filter_text_changed(filter) -> void:
|
func _on_Filter_text_changed(filter : String) -> void:
|
||||||
update_tree(filter)
|
update_tree(filter)
|
||||||
|
|
||||||
|
func export_libraries(path : String) -> void:
|
||||||
|
var dir : Directory = Directory.new()
|
||||||
|
var icon_path = path.get_basename()
|
||||||
|
dir.make_dir(icon_path)
|
||||||
|
var array = []
|
||||||
|
serialize_library(array, "", null, icon_path)
|
||||||
|
var file = File.new()
|
||||||
|
if file.open(path, File.WRITE) == OK:
|
||||||
|
file.store_string(JSON.print({lib=array}, "\t", true))
|
||||||
|
file.close()
|
||||||
|
BIN
addons/material_maker/library/base/blur.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 79 B After Width: | Height: | Size: 241 B |
BIN
addons/material_maker/library/base/circle.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
addons/material_maker/library/base/circular.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
addons/material_maker/library/base/directional.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
addons/material_maker/library/base/emboss.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
addons/material_maker/library/base/fibers.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
addons/material_maker/library/base/gradient.png
Normal file
After Width: | Height: | Size: 282 B |
BIN
addons/material_maker/library/base/image.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 393 B |
BIN
addons/material_maker/library/base/radial.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
addons/material_maker/library/base/scratches.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
addons/material_maker/library/base/uniform.png
Normal file
After Width: | Height: | Size: 277 B |
Before Width: | Height: | Size: 478 B After Width: | Height: | Size: 597 B |
BIN
addons/material_maker/library/base/warp1.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
addons/material_maker/library/base/warp2.png
Normal file
After Width: | Height: | Size: 7.0 KiB |
@ -36,6 +36,7 @@ const MENU = [
|
|||||||
{ menu="Tools", command="make_selected_nodes_editable", shortcut="Control+E", description="Make selected nodes editable" },
|
{ menu="Tools", command="make_selected_nodes_editable", shortcut="Control+E", description="Make selected nodes editable" },
|
||||||
{ menu="Tools" },
|
{ menu="Tools" },
|
||||||
{ menu="Tools", command="add_to_user_library", description="Add selected node to user library" },
|
{ menu="Tools", command="add_to_user_library", description="Add selected node to user library" },
|
||||||
|
{ menu="Tools", command="export_library", description="Export the nodes library" },
|
||||||
|
|
||||||
{ menu="Help", command="show_doc", description="User manual" },
|
{ menu="Help", command="show_doc", description="User manual" },
|
||||||
{ menu="Help", command="bug_report", description="Report a bug" },
|
{ menu="Help", command="bug_report", description="Report a bug" },
|
||||||
@ -351,6 +352,19 @@ func do_add_to_user_library(name, nodes) -> void:
|
|||||||
library.add_item(data, name, library.get_preview_texture(data))
|
library.add_item(data, name, library.get_preview_texture(data))
|
||||||
library.save_library("user://library/user.json")
|
library.save_library("user://library/user.json")
|
||||||
|
|
||||||
|
func export_library() -> void:
|
||||||
|
var dialog : FileDialog = FileDialog.new()
|
||||||
|
add_child(dialog)
|
||||||
|
dialog.rect_min_size = Vector2(500, 500)
|
||||||
|
dialog.access = FileDialog.ACCESS_FILESYSTEM
|
||||||
|
dialog.mode = FileDialog.MODE_SAVE_FILE
|
||||||
|
dialog.add_filter("*.json;JSON files")
|
||||||
|
dialog.connect("file_selected", self, "do_export_library")
|
||||||
|
dialog.popup_centered()
|
||||||
|
|
||||||
|
func do_export_library(path : String) -> void:
|
||||||
|
library.export_libraries(path)
|
||||||
|
|
||||||
func show_doc() -> void:
|
func show_doc() -> void:
|
||||||
var base_dir = OS.get_executable_path().replace("\\", "/").get_base_dir()
|
var base_dir = OS.get_executable_path().replace("\\", "/").get_base_dir()
|
||||||
|
|
||||||
|