Any idea on how to export_enum an array of resources?

Godot Version

v4.4.1.stable.official [49a5bc7b6]

Context/Question

I'm creating a base NPC scene that I will instantiate to create the majority of the characters in my game. They need to be able to store items, which I have set up as a NPCInventoryItemData resource. This resource contains variables for ItemData resource, and amount. I have a separate resource loaded as a singleton storing a list of all available items - ItemDB. I'm having trouble finding a way to select from the list in ItemDB when adding an item, if anyone could point me in the right direction that would be great! An array of strings tied to the keys of each item would work too, I just don't want to have to add items to multiple files if it's not necessary. I'll provide code and screenshots below.

Exported Variables In NonPlayerCharacter Scene

extends InteractableObjectData
class_name NonPlayerCharacter

@export_subgroup("Character Background")
@export var character_name : String
@export_enum("Human", "Elf", "Dwarf", "Halfling") var character_race : String
@export_enum("character", "vendor", "background_character", "law_enforcement") var character_type : String
@export_multiline var character_description : String


@export_subgroup("Character Inventory")
var inventory : NPCInventoryData = NPCInventoryData.new()
@export var storage : Array[NPCInventoryItemData]

Inspector Screenshot

You can use Object._validate_property() to modify programmatically how the property will behave in the inspector.

For example (assuming your ItemDB resource exports an array of strings):

@tool
class_name Inventory extends Resource


@export var items:Array


func _validate_property(property: Dictionary) -> void:
	if property.name == "items":
		# Load the item db
		var item_db = preload("res://item_db.tres")
		# Join the items array by comma
		var items = ",".join(item_db.items)
		# Create the hint string <type>/<hint>:<hint_string>
		property.hint_string = "%d/%d:%s" % [TYPE_INT, PROPERTY_HINT_ENUM, items]

Will show:

The values will be saved as an array of ints. In this case the indices of the entries of the ItemDB.items array.