mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-18 01:06:47 +01:00
Added an Add button to the mat maker's editor.
This commit is contained in:
parent
0c099d3325
commit
c5621036b2
65
game/addons/mat_maker_gd/editor/CreateNamePopup.gd
Normal file
65
game/addons/mat_maker_gd/editor/CreateNamePopup.gd
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
tool
|
||||||
|
extends ConfirmationDialog
|
||||||
|
|
||||||
|
signal ok_pressed
|
||||||
|
|
||||||
|
export(NodePath) var line_edit_path : NodePath
|
||||||
|
export(NodePath) var tree_path : NodePath
|
||||||
|
|
||||||
|
export(PoolStringArray) var type_folders : PoolStringArray
|
||||||
|
|
||||||
|
var _resource_type : String = "MMNode"
|
||||||
|
|
||||||
|
var _line_edit : LineEdit
|
||||||
|
var _tree : Tree
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
_line_edit = get_node(line_edit_path) as LineEdit
|
||||||
|
_tree = get_node(tree_path) as Tree
|
||||||
|
|
||||||
|
connect("confirmed", self, "_on_OK_pressed")
|
||||||
|
connect("about_to_show", self, "about_to_show")
|
||||||
|
|
||||||
|
func set_resource_type(resource_type : String) -> void:
|
||||||
|
_resource_type = resource_type
|
||||||
|
|
||||||
|
func about_to_show():
|
||||||
|
_tree.clear()
|
||||||
|
|
||||||
|
var root : TreeItem = _tree.create_item()
|
||||||
|
|
||||||
|
for s in type_folders:
|
||||||
|
evaluate_folder(s, root)
|
||||||
|
|
||||||
|
func evaluate_folder(folder : String, root : TreeItem) -> void:
|
||||||
|
var ti : TreeItem = _tree.create_item(root)
|
||||||
|
ti.set_text(0, folder.substr(folder.find_last("/") + 1))
|
||||||
|
|
||||||
|
var dir = Directory.new()
|
||||||
|
if dir.open(folder) == OK:
|
||||||
|
dir.list_dir_begin()
|
||||||
|
var file_name = dir.get_next()
|
||||||
|
while file_name != "":
|
||||||
|
if !dir.current_is_dir():
|
||||||
|
print("Found file: " + file_name)
|
||||||
|
var e : TreeItem = _tree.create_item(ti)
|
||||||
|
|
||||||
|
e.set_text(0, file_name.get_file())
|
||||||
|
e.set_meta("file", folder + "/" + file_name)
|
||||||
|
|
||||||
|
file_name = dir.get_next()
|
||||||
|
else:
|
||||||
|
print("An error occurred when trying to access the path.")
|
||||||
|
|
||||||
|
func _on_OK_pressed():
|
||||||
|
var selected : TreeItem = _tree.get_selected()
|
||||||
|
|
||||||
|
if selected:
|
||||||
|
if !selected.has_meta("file"):
|
||||||
|
hide()
|
||||||
|
return
|
||||||
|
|
||||||
|
var file_name : String = selected.get_meta("file")
|
||||||
|
emit_signal("ok_pressed", file_name)
|
||||||
|
|
||||||
|
hide()
|
61
game/addons/mat_maker_gd/editor/CreateNamePopup.tscn
Normal file
61
game/addons/mat_maker_gd/editor/CreateNamePopup.tscn
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://addons/mat_maker_gd/editor/CreateNamePopup.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="CreateNamePopup" type="ConfirmationDialog"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -245.5
|
||||||
|
margin_top = -220.0
|
||||||
|
margin_right = 245.5
|
||||||
|
margin_bottom = 220.0
|
||||||
|
window_title = "Create New Resource"
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
line_edit_path = NodePath("VBoxContainer/LineEdit")
|
||||||
|
tree_path = NodePath("VBoxContainer/Tree")
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
|
margin_left = 8.0
|
||||||
|
margin_top = 8.0
|
||||||
|
margin_right = 483.0
|
||||||
|
margin_bottom = 404.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Label2" type="Label" parent="VBoxContainer"]
|
||||||
|
margin_right = 475.0
|
||||||
|
margin_bottom = 14.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Type"
|
||||||
|
|
||||||
|
[node name="Tree" type="Tree" parent="VBoxContainer"]
|
||||||
|
margin_top = 18.0
|
||||||
|
margin_right = 475.0
|
||||||
|
margin_bottom = 350.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
hide_root = true
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer"]
|
||||||
|
visible = false
|
||||||
|
margin_top = 354.0
|
||||||
|
margin_right = 475.0
|
||||||
|
margin_bottom = 368.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Name"
|
||||||
|
|
||||||
|
[node name="LineEdit" type="LineEdit" parent="VBoxContainer"]
|
||||||
|
visible = false
|
||||||
|
margin_top = 372.0
|
||||||
|
margin_right = 475.0
|
||||||
|
margin_bottom = 396.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
caret_blink = true
|
13
game/addons/mat_maker_gd/editor/MatMakerGDEditor.gd
Normal file
13
game/addons/mat_maker_gd/editor/MatMakerGDEditor.gd
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
tool
|
||||||
|
extends MarginContainer
|
||||||
|
|
||||||
|
export(NodePath) var add_popup_path : NodePath = "Popups/AddPopup"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_AddButton_pressed():
|
||||||
|
get_node(add_popup_path).popup_centered()
|
||||||
|
|
||||||
|
func _on_AddPopup_ok_pressed(script_path : String):
|
||||||
|
#print(script_path)
|
||||||
|
pass
|
@ -1,4 +1,7 @@
|
|||||||
[gd_scene format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://addons/mat_maker_gd/editor/MatMakerGDEditor.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://addons/mat_maker_gd/editor/CreateNamePopup.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
[node name="MatMakerGDEditor" type="MarginContainer"]
|
[node name="MatMakerGDEditor" type="MarginContainer"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
@ -6,6 +9,7 @@ anchor_bottom = 1.0
|
|||||||
rect_min_size = Vector2( 0, 200 )
|
rect_min_size = Vector2( 0, 200 )
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
script = ExtResource( 1 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
@ -14,8 +18,36 @@ __meta__ = {
|
|||||||
margin_right = 1024.0
|
margin_right = 1024.0
|
||||||
margin_bottom = 600.0
|
margin_bottom = 600.0
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer"]
|
||||||
|
margin_right = 1024.0
|
||||||
|
margin_bottom = 34.0
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/PanelContainer"]
|
||||||
|
margin_left = 7.0
|
||||||
|
margin_top = 7.0
|
||||||
|
margin_right = 1017.0
|
||||||
|
margin_bottom = 27.0
|
||||||
|
|
||||||
|
[node name="AddButton" type="Button" parent="VBoxContainer/PanelContainer/HBoxContainer"]
|
||||||
|
margin_right = 37.0
|
||||||
|
margin_bottom = 20.0
|
||||||
|
text = "Add"
|
||||||
|
|
||||||
[node name="GraphEdit" type="GraphEdit" parent="VBoxContainer"]
|
[node name="GraphEdit" type="GraphEdit" parent="VBoxContainer"]
|
||||||
|
margin_top = 38.0
|
||||||
margin_right = 1024.0
|
margin_right = 1024.0
|
||||||
margin_bottom = 600.0
|
margin_bottom = 600.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
scroll_offset = Vector2( 0, -20 )
|
||||||
|
|
||||||
|
[node name="Popups" type="Control" parent="."]
|
||||||
|
margin_right = 1024.0
|
||||||
|
margin_bottom = 600.0
|
||||||
|
mouse_filter = 2
|
||||||
|
|
||||||
|
[node name="AddPopup" parent="Popups" instance=ExtResource( 2 )]
|
||||||
|
type_folders = PoolStringArray( "res://addons/mat_maker_gd/nodes/filter", "res://addons/mat_maker_gd/nodes/noise", "res://addons/mat_maker_gd/nodes/pattern", "res://addons/mat_maker_gd/nodes/sdf2d", "res://addons/mat_maker_gd/nodes/sdf3d", "res://addons/mat_maker_gd/nodes/simple" )
|
||||||
|
|
||||||
|
[connection signal="pressed" from="VBoxContainer/PanelContainer/HBoxContainer/AddButton" to="." method="_on_AddButton_pressed"]
|
||||||
|
[connection signal="ok_pressed" from="Popups/AddPopup" to="." method="_on_AddPopup_ok_pressed"]
|
||||||
|
@ -149,6 +149,11 @@ _global_script_classes=[ {
|
|||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/mat_maker_gd/nodes/mm_material.gd"
|
"path": "res://addons/mat_maker_gd/nodes/mm_material.gd"
|
||||||
}, {
|
}, {
|
||||||
|
"base": "Resource",
|
||||||
|
"class": "MMNode",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://addons/mat_maker_gd/nodes/mm_node.gd"
|
||||||
|
}, {
|
||||||
"base": "Node",
|
"base": "Node",
|
||||||
"class": "Main",
|
"class": "Main",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
@ -253,6 +258,7 @@ _global_script_class_icons={
|
|||||||
"ItemTemplateGD": "",
|
"ItemTemplateGD": "",
|
||||||
"LayeredTextureMaker": "",
|
"LayeredTextureMaker": "",
|
||||||
"MMMateial": "",
|
"MMMateial": "",
|
||||||
|
"MMNode": "",
|
||||||
"Main": "",
|
"Main": "",
|
||||||
"MainTPlanetGenerator": "",
|
"MainTPlanetGenerator": "",
|
||||||
"ManaResource": "",
|
"ManaResource": "",
|
||||||
@ -316,7 +322,7 @@ window/size/ui_scale_touch=1.0
|
|||||||
|
|
||||||
[editor_plugins]
|
[editor_plugins]
|
||||||
|
|
||||||
enabled=PoolStringArray( "res://addons/Godoxel/plugin.cfg", "res://addons/color-palette/plugin.cfg", "res://addons/mat_maker_gd/plugin.cfg", "res://addons/mesh_data_resource_editor/plugin.cfg" )
|
enabled=PoolStringArray( "res://addons/Godoxel/plugin.cfg", "res://addons/color-palette/plugin.cfg", "res://addons/godot-plugin-refresher/plugin.cfg", "res://addons/mat_maker_gd/plugin.cfg", "res://addons/mesh_data_resource_editor/plugin.cfg" )
|
||||||
|
|
||||||
[ess]
|
[ess]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user