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.

SceneEvent.gd 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. tool
  2. extends Control
  3. var editor_reference
  4. var editorPopup
  5. var preview = "..."
  6. onready var toggler = get_node("PanelContainer/VBoxContainer/Header/VisibleToggle")
  7. # This is the information of this event and it will get parsed and saved to the JSON file.
  8. var event_data = {
  9. 'background': ''
  10. }
  11. func _ready():
  12. connect("gui_input", self, '_on_gui_input')
  13. load_image(event_data['background'])
  14. func _on_ImageButton_pressed():
  15. editor_reference.godot_dialog("*.png, *.jpg, *.jpeg, *.tga, *.svg, *.svgz, *.bmp, *.webp, *.tscn")
  16. editor_reference.godot_dialog_connect(self, "_on_file_selected")
  17. func _on_file_selected(path, target):
  18. target.load_image(path)
  19. func load_data(data):
  20. event_data = data
  21. load_image(event_data['background'])
  22. func load_image(img_src):
  23. event_data['background'] = img_src
  24. $PanelContainer/VBoxContainer/HBoxContainer/LineEdit.text = event_data['background']
  25. if event_data['background'] != '' and not event_data['background'].ends_with('.tscn'):
  26. $PanelContainer/VBoxContainer/TextureRect.texture = load(event_data['background'])
  27. $PanelContainer/VBoxContainer/TextureRect.rect_min_size = Vector2(200,200)
  28. preview = event_data['background']
  29. else:
  30. $PanelContainer/VBoxContainer/TextureRect.rect_min_size = Vector2(0,0)
  31. func _on_gui_input(event):
  32. if event is InputEventMouseButton and event.is_pressed() and event.doubleclick:
  33. if event.button_index == 1:
  34. if toggler.pressed:
  35. toggler.pressed = false
  36. else:
  37. toggler.pressed = true