yagvm/UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenuItem.gd

66 lines
2.2 KiB
GDScript3
Raw Normal View History

extends HBoxContainer
class_name OverrideEditorSettingsMenuItem
# god help me
const TYPE_NAMES := {
TYPE_NIL: "Type: Nil",
TYPE_BOOL: "Type: Bool",
TYPE_INT: "Type: Int",
TYPE_FLOAT: "Type: Float",
TYPE_STRING: "Type: String",
TYPE_VECTOR2: "Type: Vector2",
TYPE_VECTOR2I: "Type: Vector2i",
TYPE_RECT2: "Type: Rect2",
TYPE_RECT2I: "Type: Rect2i",
TYPE_VECTOR3: "Type: Vector3",
TYPE_VECTOR3I: "Type: Vector3i",
TYPE_TRANSFORM2D: "Type: Transform2D",
TYPE_VECTOR4: "Type: Vector4",
TYPE_VECTOR4I: "Type: Vector4i",
TYPE_PLANE: "Type: Plane",
TYPE_QUATERNION: "Type: Quaternion",
TYPE_AABB: "Type: AABB",
TYPE_BASIS: "Type: Basis",
TYPE_TRANSFORM3D: "Type: Transform3D",
TYPE_PROJECTION: "Type: Projection",
TYPE_COLOR: "Type: Color",
TYPE_STRING_NAME: "Type: StringName",
TYPE_NODE_PATH: "Type: NodePath",
TYPE_RID: "Type: RID",
TYPE_OBJECT: "Type: Object",
TYPE_CALLABLE: "Type: Callable",
TYPE_SIGNAL: "Type: Signal",
TYPE_DICTIONARY: "Type: Dictionary",
TYPE_ARRAY: "Type: Array",
TYPE_PACKED_BYTE_ARRAY: "Type: PackedByteArray",
TYPE_PACKED_INT32_ARRAY: "Type: PackedInt32Array",
TYPE_PACKED_INT64_ARRAY: "Type: PackedInt64Array",
TYPE_PACKED_FLOAT32_ARRAY: "Type: PackedFloat32Array",
TYPE_PACKED_FLOAT64_ARRAY: "Type: PackedFloat64Array",
TYPE_PACKED_STRING_ARRAY: "Type: PackedStringArray",
TYPE_PACKED_VECTOR2_ARRAY: "Type: PackedVector2Array",
TYPE_PACKED_VECTOR3_ARRAY: "Type: PackedVector3Array",
TYPE_PACKED_COLOR_ARRAY: "Type: PackedColorArray",
}
@onready var property_name_line_edit: LineEdit = %PropertyNameLineEdit
@onready var property_type_option_button: OptionButton = %PropertyTypeOptionButton
@onready var property_value_line_edit: LineEdit = %PropertyValueLineEdit
@onready var delete_item_button: Button = %DeleteItemButton
func _ready() -> void:
# for now, type is just a hint for the convert function.
# in the future, there will be custom editors for types, like godot's inspector.
for type in TYPE_MAX:
property_type_option_button.add_item(TYPE_NAMES[type])
delete_item_button.pressed.connect(queue_free)
func get_property() -> Dictionary:
var prop_name = property_name_line_edit.text
var value = convert(property_value_line_edit.text, property_type_option_button.get_selected_id())
return {prop_name: value}