Compatibility fixes for Godot 3.1.2, updated switch to support more choices, and shader nodes to support inputs in enum values

This commit is contained in:
RodZill4 2019-12-04 22:26:54 +01:00
parent a95f1045d8
commit 8282ab24fe
4 changed files with 10 additions and 10 deletions

View File

@ -165,8 +165,6 @@ func subst(string, context, uv = "") -> Dictionary:
var tmp_string = replace_variable(string, "seed", str(get_seed()))
if tmp_string != string:
string = tmp_string
if uv != "":
string = replace_variable(string, "uv", "("+uv+")")
if shader_model.has("parameters") and typeof(shader_model.parameters) == TYPE_ARRAY:
for p in shader_model.parameters:
if !p.has("name") or !p.has("type"):
@ -191,6 +189,8 @@ func subst(string, context, uv = "") -> Dictionary:
print("Cannot replace parameter of type "+p.type)
if value_string != null:
string = replace_variable(string, p.name, value_string)
if uv != "":
string = replace_variable(string, "uv", "("+uv+")")
if shader_model.has("inputs") and typeof(shader_model.inputs) == TYPE_ARRAY:
var cont = true
while cont:

View File

@ -27,7 +27,7 @@ func update_node() -> void:
var lines_list = []
if generator.editable:
lines_list.push_back( { name="outputs", tooltip="Outputs count", min=1, max=5 } )
lines_list.push_back( { name="choices", tooltip="Choices count", min=2, max=5 } )
lines_list.push_back( { name="choices", tooltip="Choices count", min=2, max=10 } )
lines_list.push_back( { name="source", tooltip="Current choice", min=0, max=generator.parameters.choices-1 } )
for l in lines_list:
var sizer = HBoxContainer.new()

View File

@ -41,7 +41,7 @@ func find_control(gp) -> Dictionary:
if c.get("controls") != null:
for w in c.controls:
var widget = c.controls[w]
if Rect2(widget.rect_global_position, widget.rect_size*widget.get_global_transform().get_scale()).has_point(gp):
if widget != null and Rect2(widget.rect_global_position, widget.rect_size*widget.get_global_transform().get_scale()).has_point(gp):
return { node=c, widget=widget }
return {}
@ -67,7 +67,7 @@ func _input(event: InputEvent) -> void:
elif event is InputEventMouseMotion:
var control = find_control(event.global_position)
end = get_global_transform().xform_inv(event.global_position)
target = control.widget if !control.empty() and generator.can_link_parameter(param_name, control.node.generator, control.widget.name) else null
target = control.widget if control != null and !control.empty() and generator.can_link_parameter(param_name, control.node.generator, control.widget.name) else null
update()
elif event is InputEventMouseButton:
if event.pressed:

View File

@ -4,11 +4,11 @@ extends HBoxContainer
var enum_values = [ {name="Foo", value="foo"} ]
var enum_current = 0
const ENUM_ADD = -1
const ENUM_EDIT = -2
const ENUM_REMOVE = -3
const ENUM_UP = -4
const ENUM_DOWN = -5
const ENUM_ADD = 10000
const ENUM_EDIT = 10001
const ENUM_REMOVE = 10002
const ENUM_UP = 10003
const ENUM_DOWN = 10004
func _ready() -> void:
update_enum_list()