No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PortraitEntry.gd 814B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. tool
  2. extends HBoxContainer
  3. var editor_reference
  4. var image_node
  5. func _ready():
  6. pass
  7. func _on_ButtonDelete_pressed():
  8. if $NameEdit.text == 'Default':
  9. $PathEdit.text = ''
  10. update_preview('')
  11. else:
  12. queue_free()
  13. func _on_ButtonSelect_pressed():
  14. editor_reference.godot_dialog("*.png, *.svg")
  15. editor_reference.godot_dialog_connect(self, "_on_file_selected")
  16. func _on_file_selected(path, target):
  17. update_preview(path)
  18. $PathEdit.text = path
  19. if $NameEdit.text == '':
  20. $NameEdit.text = DialogicResources.get_filename_from_path(path)
  21. func _on_focus_entered():
  22. if $PathEdit.text != '':
  23. update_preview($PathEdit.text)
  24. func update_preview(path):
  25. if path == '':
  26. image_node.texture = null
  27. else:
  28. if '.png' in path or '.svg' in path:
  29. image_node.texture = load(path)
  30. return true
  31. return false