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.

DefinitionPicker.gd 820B

1234567891011121314151617181920212223242526272829303132333435
  1. tool
  2. extends MenuButton
  3. var default_text = '[ Select a definition ]'
  4. func _ready():
  5. get_popup().connect("index_pressed", self, '_on_entry_selected')
  6. get_popup().clear()
  7. connect("about_to_show", self, "_on_MenuButton_about_to_show")
  8. func _on_MenuButton_about_to_show():
  9. get_popup().clear()
  10. var index = 0
  11. for d in DialogicResources.get_default_definitions()['variables']:
  12. get_popup().add_item(d['name'])
  13. get_popup().set_item_metadata(index, {
  14. 'id': d['id'],
  15. })
  16. index += 1
  17. func _on_entry_selected(index):
  18. var _text = get_popup().get_item_text(index)
  19. var metadata = get_popup().get_item_metadata(index)
  20. text = _text
  21. func load_definition(id):
  22. if id != '':
  23. for d in DialogicResources.get_default_definitions()['variables']:
  24. if d['id'] == id:
  25. text = d['name']
  26. else:
  27. text = default_text