More remote node updates (only serialize is missing I guess...)

This commit is contained in:
RodZill4 2019-09-25 23:29:06 +02:00
parent bd24b3e87e
commit 027a311554
6 changed files with 77 additions and 27 deletions

View File

@ -30,7 +30,9 @@ func get_parameter_defs():
match w.type:
"config_control":
var p = { name="param"+str(i), label=w.label, type="enum", values=[] }
for c in w.configurations:
var configurations = w.configurations.keys()
configurations.sort()
for c in configurations:
p.values.push_back({ name=c, value=c })
rv.append(p)
i += 1
@ -61,7 +63,9 @@ func set_parameter(p, v):
parent.get_node(w.node).set_parameter(w.widget, v)
"config_control":
if v < widget.configurations.size():
for w in widget.configurations[widget.configurations.keys()[v]]:
var configurations = widget.configurations.keys()
configurations.sort()
for w in widget.configurations[configurations[v]]:
parent.get_node(w.node).set_parameter(w.widget, w.value)
else:
# incorrect configuration index
@ -81,7 +85,7 @@ func create_linked_control(label):
func create_config_control(label):
var index = widgets.size()
widgets.push_back({ label=label, type="config_control", linked_widgets=[], configurations=[] })
widgets.push_back({ label=label, type="config_control", linked_widgets=[], configurations={} })
return index
func can_link_parameter(index, generator, param):
@ -90,9 +94,14 @@ func can_link_parameter(index, generator, param):
func link_parameter(index, generator, param):
if !can_link_parameter(index, generator, param):
return
widgets[index].linked_widgets.push_back({ node=generator.name, widget=param })
if widgets[index].linked_widgets.size() == 1:
var widget = widgets[index]
widget.linked_widgets.push_back({ node=generator.name, widget=param })
if widget.linked_widgets.size() == 1:
match widget.type:
"linked_control":
parameters["param"+str(index)] = generator.parameters[param]
"config_control":
parameters["param"+str(index)] = 0
emit_signal("parameter_changed", "", null)
func remove_parameter(index):
@ -100,3 +109,32 @@ func remove_parameter(index):
parameters["param"+str(i)] = parameters["param"+str(i+1)]
widgets.remove(index)
emit_signal("parameter_changed", "", null)
func add_configuration(index, config_name):
var widget = widgets[index]
if widget.type == "config_control":
widget.configurations[config_name] = []
var configurations = widget.configurations.keys()
configurations.sort()
parameters["param"+str(index)] =configurations.find(config_name)
update_configuration(index, config_name)
func update_configuration(index, config_name):
var widget = widgets[index]
if widget.type == "config_control":
var c = []
var parent = get_parent()
for w in widget.linked_widgets:
var g = parent.get_node(w.node)
var value = g.parameters[w.widget]
if typeof(value) == TYPE_ARRAY or typeof(value) == TYPE_DICTIONARY:
value = value.duplicate()
c.push_back({ node=w.node, widget=w.widget, value=value })
widget.configurations[config_name] = c
emit_signal("parameter_changed", "", null)
func remove_configuration(index, config_name):
var widget = widgets[index]
if widget.type == "config_control":
widget.configurations.erase(config_name)
emit_signal("parameter_changed", "", null)

View File

@ -96,6 +96,7 @@ tab_align = 0
tab_close_display_policy = 1
[node name="Renderer" parent="." instance=ExtResource( 5 )]
debug_path = null
[node name="NodeFactory" type="Node" parent="."]
script = ExtResource( 6 )

View File

@ -47,12 +47,37 @@ func update_node():
func _on_value_changed(new_value, variable):
var param_index = variable.trim_prefix("param").to_int()
var widget = generator.widgets[param_index]
if widget.type == "config_control" and new_value >= widget.configurations.size():
if widget.type == "config_control":
var configuration_count = widget.configurations.size()
var control = $Controls.get_child(param_index*4+1)
if new_value < configuration_count:
._on_value_changed(new_value, variable)
var current = control.get_item_text(new_value)
control.set_item_text(configuration_count+3, "<update "+current+">")
control.set_item_text(configuration_count+4, "<remove "+current+">")
else:
var current = control.get_item_text(generator.parameters[variable])
var command = new_value - widget.configurations.size()
match command:
1:
var dialog = preload("res://addons/material_maker/widgets/line_dialog.tscn").instance()
add_child(dialog)
dialog.set_texts("Configuration", "Enter a name for the new configuration")
dialog.connect("ok", self, "do_add_configuration", [ param_index ])
dialog.popup_centered()
3:
generator.update_configuration(param_index, current)
4:
generator.parameters[variable] = 0
generator.remove_configuration(param_index, current)
_:
print(command)
else:
._on_value_changed(new_value, variable)
func do_add_configuration(config_name, param_index):
generator.add_configuration(param_index, config_name)
func _on_AddLink_pressed():
var widget = Control.new()
add_control("Unnamed", widget)

View File

@ -3,25 +3,8 @@
[ext_resource path="res://addons/material_maker/widgets/linked_widgets/editable_label.gd" type="Script" id=1]
[node name="Label" type="Label"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_right = 40.0
margin_bottom = 14.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 4
percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
script = ExtResource( 1 )
_sections_unfolded = [ "Mouse" ]
[connection signal="gui_input" from="." to="." method="_on_gui_input"]

View File

@ -132,6 +132,9 @@ config/name="Material Maker"
run/main_scene="res://addons/material_maker/main_window.tscn"
config/use_custom_user_dir=true
config/custom_user_dir_name="material_maker"
boot_splash/image="res://rodz_labs_logo.png"
boot_splash/fullsize=false
boot_splash/bg_color=Color( 0.0901961, 0.0941176, 0.141176, 1 )
config/icon="res://icon.png"
config/release="0.6"

BIN
rodz_labs_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB