mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
More remote node updates (only serialize is missing I guess...)
This commit is contained in:
parent
bd24b3e87e
commit
027a311554
@ -30,7 +30,9 @@ func get_parameter_defs():
|
|||||||
match w.type:
|
match w.type:
|
||||||
"config_control":
|
"config_control":
|
||||||
var p = { name="param"+str(i), label=w.label, type="enum", values=[] }
|
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 })
|
p.values.push_back({ name=c, value=c })
|
||||||
rv.append(p)
|
rv.append(p)
|
||||||
i += 1
|
i += 1
|
||||||
@ -61,7 +63,9 @@ func set_parameter(p, v):
|
|||||||
parent.get_node(w.node).set_parameter(w.widget, v)
|
parent.get_node(w.node).set_parameter(w.widget, v)
|
||||||
"config_control":
|
"config_control":
|
||||||
if v < widget.configurations.size():
|
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)
|
parent.get_node(w.node).set_parameter(w.widget, w.value)
|
||||||
else:
|
else:
|
||||||
# incorrect configuration index
|
# incorrect configuration index
|
||||||
@ -81,7 +85,7 @@ func create_linked_control(label):
|
|||||||
|
|
||||||
func create_config_control(label):
|
func create_config_control(label):
|
||||||
var index = widgets.size()
|
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
|
return index
|
||||||
|
|
||||||
func can_link_parameter(index, generator, param):
|
func can_link_parameter(index, generator, param):
|
||||||
@ -90,13 +94,47 @@ func can_link_parameter(index, generator, param):
|
|||||||
func link_parameter(index, generator, param):
|
func link_parameter(index, generator, param):
|
||||||
if !can_link_parameter(index, generator, param):
|
if !can_link_parameter(index, generator, param):
|
||||||
return
|
return
|
||||||
widgets[index].linked_widgets.push_back({ node=generator.name, widget=param })
|
var widget = widgets[index]
|
||||||
if widgets[index].linked_widgets.size() == 1:
|
widget.linked_widgets.push_back({ node=generator.name, widget=param })
|
||||||
parameters["param"+str(index)] = generator.parameters[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)
|
emit_signal("parameter_changed", "", null)
|
||||||
|
|
||||||
func remove_parameter(index):
|
func remove_parameter(index):
|
||||||
for i in range(index, widgets.size()-2):
|
for i in range(index, widgets.size()-2):
|
||||||
parameters["param"+str(i)] = parameters["param"+str(i+1)]
|
parameters["param"+str(i)] = parameters["param"+str(i+1)]
|
||||||
widgets.remove(index)
|
widgets.remove(index)
|
||||||
emit_signal("parameter_changed", "", null)
|
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)
|
||||||
|
@ -96,6 +96,7 @@ tab_align = 0
|
|||||||
tab_close_display_policy = 1
|
tab_close_display_policy = 1
|
||||||
|
|
||||||
[node name="Renderer" parent="." instance=ExtResource( 5 )]
|
[node name="Renderer" parent="." instance=ExtResource( 5 )]
|
||||||
|
debug_path = null
|
||||||
|
|
||||||
[node name="NodeFactory" type="Node" parent="."]
|
[node name="NodeFactory" type="Node" parent="."]
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
|
@ -47,12 +47,37 @@ func update_node():
|
|||||||
func _on_value_changed(new_value, variable):
|
func _on_value_changed(new_value, variable):
|
||||||
var param_index = variable.trim_prefix("param").to_int()
|
var param_index = variable.trim_prefix("param").to_int()
|
||||||
var widget = generator.widgets[param_index]
|
var widget = generator.widgets[param_index]
|
||||||
if widget.type == "config_control" and new_value >= widget.configurations.size():
|
if widget.type == "config_control":
|
||||||
var command = new_value - widget.configurations.size()
|
var configuration_count = widget.configurations.size()
|
||||||
print(command)
|
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:
|
else:
|
||||||
._on_value_changed(new_value, variable)
|
._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():
|
func _on_AddLink_pressed():
|
||||||
var widget = Control.new()
|
var widget = Control.new()
|
||||||
add_control("Unnamed", widget)
|
add_control("Unnamed", widget)
|
||||||
|
@ -3,25 +3,8 @@
|
|||||||
[ext_resource path="res://addons/material_maker/widgets/linked_widgets/editable_label.gd" type="Script" id=1]
|
[ext_resource path="res://addons/material_maker/widgets/linked_widgets/editable_label.gd" type="Script" id=1]
|
||||||
|
|
||||||
[node name="Label" type="Label"]
|
[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_right = 40.0
|
||||||
margin_bottom = 14.0
|
margin_bottom = 14.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 0
|
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 )
|
script = ExtResource( 1 )
|
||||||
_sections_unfolded = [ "Mouse" ]
|
|
||||||
|
|
||||||
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
|
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,6 +132,9 @@ config/name="Material Maker"
|
|||||||
run/main_scene="res://addons/material_maker/main_window.tscn"
|
run/main_scene="res://addons/material_maker/main_window.tscn"
|
||||||
config/use_custom_user_dir=true
|
config/use_custom_user_dir=true
|
||||||
config/custom_user_dir_name="material_maker"
|
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/icon="res://icon.png"
|
||||||
config/release="0.6"
|
config/release="0.6"
|
||||||
|
|
||||||
|
BIN
rodz_labs_logo.png
Normal file
BIN
rodz_labs_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue
Block a user