Updated remote to automatically show configurations with "True" and "False" configs as toggle buttons.

This commit is contained in:
Rodolphe Suescun 2019-12-30 11:47:27 +01:00
parent 724c03feeb
commit 421af6e439
3 changed files with 37 additions and 29 deletions

View File

@ -169,7 +169,8 @@ func _get_shader_code(uv : String, output_index : int, context : MMGenContext) -
coef_str = "vec3(%.9f, %.9f, %.9f)" % [ coef[0] * sum[0], coef[1] * sum[1], coef[2] * sum[2] ] coef_str = "vec3(%.9f, %.9f, %.9f)" % [ coef[0] * sum[0], coef[1] * sum[1], coef[2] * sum[2] ]
"rgba": "rgba":
coef_str = "vec4(%.9f, %.9f, %.9f, %.9f)" % [ coef[0] * sum[0], coef[1] * sum[1], coef[2] * sum[2], coef[3] * sum[3] ] coef_str = "vec4(%.9f, %.9f, %.9f, %.9f)" % [ coef[0] * sum[0], coef[1] * sum[1], coef[2] * sum[2], coef[3] * sum[3] ]
rv.code += "%s_%d += %s*%s;\n" % [ genname, variant_index, coef_str, src_code[convolution_params.input_type] ] if src_code.has(convolution_params.input_type):
rv.code += "%s_%d += %s*%s;\n" % [ genname, variant_index, coef_str, src_code[convolution_params.input_type] ]
for t in src_code.textures.keys(): for t in src_code.textures.keys():
rv.textures[t] = src_code.textures[t] rv.textures[t] = src_code.textures[t]
rv[convolution_params.output_type] = "%s_%d" % [ genname, variant_index ] rv[convolution_params.output_type] = "%s_%d" % [ genname, variant_index ]

View File

@ -80,11 +80,15 @@ func get_parameter_defs() -> Array:
for w in widgets: for w in widgets:
match w.type: match w.type:
"config_control": "config_control":
var p : Dictionary = { name=w.name, label=w.label, type="enum", values=[] } var p : Dictionary = { name=w.name, label=w.label, type="enum" }
var configurations = w.configurations.keys() var configurations = w.configurations.keys()
configurations.sort() configurations.sort()
for c in configurations: if configurations == [ "False", "True" ]:
p.values.push_back({ name=c, value=c }) p.type = "boolean"
else:
p.values=[]
for c in configurations:
p.values.push_back({ name=c, value=c })
rv.append(p) rv.append(p)
i += 1 i += 1
"linked_control": "linked_control":
@ -119,6 +123,8 @@ func set_parameter(p : String, v) -> void:
if node != null: if node != null:
node.set_parameter(w.widget, v) node.set_parameter(w.widget, v)
"config_control": "config_control":
if v is bool:
v = 1 if v else 0
if v < widget.configurations.size(): if v < widget.configurations.size():
var configurations = widget.configurations.keys() var configurations = widget.configurations.keys()
configurations.sort() configurations.sort()

View File

@ -40,7 +40,7 @@ func update_node() -> void:
control.name = p.name control.name = p.name
controls[control.name] = control controls[control.name] = control
add_control(generator.get_widget(p.name).label, control) add_control(generator.get_widget(p.name).label, control)
if generator.widgets[i].type == "config_control": if generator.widgets[i].type == "config_control" and control is OptionButton:
var current = null var current = null
if control.get_item_count() > 0: if control.get_item_count() > 0:
control.selected = generator.parameters[p.name] control.selected = generator.parameters[p.name]
@ -60,30 +60,31 @@ func _on_value_changed(new_value, variable : String) -> void:
if widget.type == "config_control": if widget.type == "config_control":
var configuration_count = widget.configurations.size() var configuration_count = widget.configurations.size()
var control = controls[variable] var control = controls[variable]
if new_value < configuration_count: if control is OptionButton:
._on_value_changed(new_value, variable) if new_value < configuration_count:
var current = control.get_item_text(new_value) ._on_value_changed(new_value, variable)
control.set_item_text(configuration_count+3, "<update "+current+">") var current = control.get_item_text(new_value)
control.set_item_text(configuration_count+4, "<remove "+current+">") control.set_item_text(configuration_count+3, "<update "+current+">")
else: control.set_item_text(configuration_count+4, "<remove "+current+">")
var current = control.get_item_text(generator.parameters[variable]) else:
var command = new_value - widget.configurations.size() var current = control.get_item_text(generator.parameters[variable])
match command: var command = new_value - widget.configurations.size()
1: match command:
var dialog = preload("res://addons/material_maker/widgets/line_dialog.tscn").instance() 1:
add_child(dialog) var dialog = preload("res://addons/material_maker/widgets/line_dialog.tscn").instance()
dialog.set_texts("Configuration", "Enter a name for the new configuration") add_child(dialog)
dialog.connect("ok", self, "do_add_configuration", [ variable ]) dialog.set_texts("Configuration", "Enter a name for the new configuration")
dialog.popup_centered() dialog.connect("ok", self, "do_add_configuration", [ variable ])
3: dialog.popup_centered()
generator.update_configuration(variable, current) 3:
4: generator.update_configuration(variable, current)
generator.parameters[variable] = 0 4:
generator.remove_configuration(variable, current) generator.parameters[variable] = 0
_: generator.remove_configuration(variable, current)
print(command) _:
else: print(command)
._on_value_changed(new_value, variable) return
._on_value_changed(new_value, variable)
func do_add_configuration(config_name : String, param_name : String) -> void: func do_add_configuration(config_name : String, param_name : String) -> void:
generator.add_configuration(param_name, config_name) generator.add_configuration(param_name, config_name)