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 840B

123456789101112131415161718192021222324252627282930313233343536
  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 DialogicUtil.get_sorted_default_definitions_list():
  12. if d['type'] == 0:
  13. get_popup().add_item(d['name'])
  14. get_popup().set_item_metadata(index, {
  15. 'id': d['id'],
  16. })
  17. index += 1
  18. func _on_entry_selected(index):
  19. var _text = get_popup().get_item_text(index)
  20. var metadata = get_popup().get_item_metadata(index)
  21. text = _text
  22. func load_definition(id):
  23. if id != '':
  24. for d in DialogicResources.get_default_definitions()['variables']:
  25. if d['id'] == id:
  26. text = d['name']
  27. else:
  28. text = default_text