mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
Updated remote to automatically show configurations with "True" and "False" configs as toggle buttons.
This commit is contained in:
parent
724c03feeb
commit
421af6e439
@ -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] ]
|
||||
"rgba":
|
||||
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():
|
||||
rv.textures[t] = src_code.textures[t]
|
||||
rv[convolution_params.output_type] = "%s_%d" % [ genname, variant_index ]
|
||||
|
@ -80,11 +80,15 @@ func get_parameter_defs() -> Array:
|
||||
for w in widgets:
|
||||
match w.type:
|
||||
"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()
|
||||
configurations.sort()
|
||||
for c in configurations:
|
||||
p.values.push_back({ name=c, value=c })
|
||||
if configurations == [ "False", "True" ]:
|
||||
p.type = "boolean"
|
||||
else:
|
||||
p.values=[]
|
||||
for c in configurations:
|
||||
p.values.push_back({ name=c, value=c })
|
||||
rv.append(p)
|
||||
i += 1
|
||||
"linked_control":
|
||||
@ -119,6 +123,8 @@ func set_parameter(p : String, v) -> void:
|
||||
if node != null:
|
||||
node.set_parameter(w.widget, v)
|
||||
"config_control":
|
||||
if v is bool:
|
||||
v = 1 if v else 0
|
||||
if v < widget.configurations.size():
|
||||
var configurations = widget.configurations.keys()
|
||||
configurations.sort()
|
||||
|
@ -40,7 +40,7 @@ func update_node() -> void:
|
||||
control.name = p.name
|
||||
controls[control.name] = 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
|
||||
if control.get_item_count() > 0:
|
||||
control.selected = generator.parameters[p.name]
|
||||
@ -60,30 +60,31 @@ func _on_value_changed(new_value, variable : String) -> void:
|
||||
if widget.type == "config_control":
|
||||
var configuration_count = widget.configurations.size()
|
||||
var control = controls[variable]
|
||||
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", [ variable ])
|
||||
dialog.popup_centered()
|
||||
3:
|
||||
generator.update_configuration(variable, current)
|
||||
4:
|
||||
generator.parameters[variable] = 0
|
||||
generator.remove_configuration(variable, current)
|
||||
_:
|
||||
print(command)
|
||||
else:
|
||||
._on_value_changed(new_value, variable)
|
||||
if control is OptionButton:
|
||||
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", [ variable ])
|
||||
dialog.popup_centered()
|
||||
3:
|
||||
generator.update_configuration(variable, current)
|
||||
4:
|
||||
generator.parameters[variable] = 0
|
||||
generator.remove_configuration(variable, current)
|
||||
_:
|
||||
print(command)
|
||||
return
|
||||
._on_value_changed(new_value, variable)
|
||||
|
||||
func do_add_configuration(config_name : String, param_name : String) -> void:
|
||||
generator.add_configuration(param_name, config_name)
|
||||
|
Loading…
Reference in New Issue
Block a user