extends Reference class_name GDB_Property # special types const TYPE_HEADER = -1 const TYPE_ENTITY = -2 const TYPE_PROPERTY = -3 const FLAG_READONLY = (1 << 0) # the user should not be able to change this const FLAG_HIDDEN = (1 << 1) # completely hidden from UI var _name := "" var _icon : Texture = null var _value = null var _type := TYPE_INT# var _content_type := TYPE_NIL var _flags := 0 ################ # overridables # ################ func get_name() -> String: return _name func set_name(name : String) -> void: if _name != name: _name = name emit_signal("name_changed") func get_icon() -> Texture: return _icon func set_icon(icon : Texture) -> void: if _icon != icon: _icon = icon emit_signal("icon_changed") func get_value(): return _value func set_value(value) -> void: if value != _value: _value = value emit_signal("value_changed") func get_type() -> int: return _type func set_type(type : int) -> void: if type != _type: _type = type emit_signal("type_changed") func get_content_type() -> int: return _content_type func set_content_type(type : int) -> void: if type != _content_type: _content_type = type emit_signal("type_changed") func get_flags() -> int: return _flags func set_flags(flags : int) -> void: if flags != _flags: _flags = flags emit_signal("flags_changed") ################ # static stuff # ################ static func is_valid_property(object : Object) -> bool: return object != null \ && object.has_method("get_name") \ && object.has_method("get_value") \ && object.has_method("get_type") static func get_prop_icon(property : Object) -> Texture: return __get_prop_optional(property, "icon") static func get_prop_flags(property : Object) -> int: return __get_prop_optional(property, "flags", 0) static func get_prop_content_type(property : Object) -> int: return __get_prop_optional(property, "content_type", TYPE_NIL) static func is_prop_value_valid(property : Object, value) -> bool: if property.has_method("is_value_valud"): return property.is_value_valid(value) match property.get_type(): TYPE_HEADER: return false TYPE_BOOL: return value is bool TYPE_INT: return value is int TYPE_REAL: return value is float TYPE_STRING: return value is String TYPE_ARRAY: return value is Array _: # TODO: more default checks return true static func get_prop_value_as_string(property : Object) -> String: if property.has_method("get_value_as_string"): return property.get_value_as_string() return str(property.get_value()) static func __get_prop_optional(property : Object, name : String, default = null): var value = default if property.has_method("get_" + name): value = property.call("get_" + name) else: var val = property.get(name) if typeof(default) == TYPE_NIL || typeof(val) == typeof(default): value = val return value ########### # signals # ########### signal name_changed() signal icon_changed() signal value_changed() signal type_changed() signal flags_changed() signal value_added(value) signal value_removed(value)