Check for the presence of added methods so the plugin will partially work on unpatched engines.

This commit is contained in:
Nolan Darilek 2019-09-24 15:13:15 -05:00
parent d0afc9e4e3
commit eeb8a3a171

View File

@ -33,11 +33,17 @@ func click(item := node, button_index = BUTTON_LEFT):
node.get_tree().input_event(click) node.get_tree().input_event(click)
func guess_label(): func guess_label():
var parent = node.get_parent() var tokens = PoolStringArray([])
while parent: var to_check = node
if parent is EditorProperty and parent.label: while to_check:
return parent.label if to_check is EditorProperty and to_check.label:
parent = parent.get_parent() tokens.append(to_check.label)
if (to_check is EditorProperty or to_check.get_class() == "EditorInspectorCategory") and to_check.get_tooltip_text():
tokens.append(to_check.get_tooltip_text())
var label = tokens.join(": ")
if label:
return label
to_check = to_check.get_parent()
func close_key_event_dialog(): func close_key_event_dialog():
node.get_ok().emit_signal("pressed") node.get_ok().emit_signal("pressed")
@ -252,6 +258,7 @@ func tree_item_selected():
if button_count != 0: if button_count != 0:
button_index = 0 button_index = 0
tokens.append(str(button_count) + " " + singular_or_plural(button_count, "button", "buttons")) tokens.append(str(button_count) + " " + singular_or_plural(button_count, "button", "buttons"))
if cell.has_method("get_button_tooltip"):
var button_tooltip = cell.get_button_tooltip(i, button_index) var button_tooltip = cell.get_button_tooltip(i, button_index)
if button_tooltip: if button_tooltip:
tokens.append(button_tooltip) tokens.append(button_tooltip)
@ -297,7 +304,7 @@ func tree_input(event):
new_button_index -= 1 new_button_index -= 1
if new_button_index < 0: if new_button_index < 0:
new_button_index = item.get_button_count(column) - 1 new_button_index = item.get_button_count(column) - 1
if new_button_index != button_index: if new_button_index != button_index and item.has_method("get_button_tooltip"):
button_index = new_button_index button_index = new_button_index
var tokens = PoolStringArray([]) var tokens = PoolStringArray([])
var tooltip = item.get_button_tooltip(column, button_index) var tooltip = item.get_button_tooltip(column, button_index)