Merge pull request #84760 from KoBeWi/ultimate_get_property_list_reloaded
Fetch override list from ThemeDB
This commit is contained in:
@ -337,6 +337,7 @@ void ThemeDB::bind_class_item(Theme::DataType p_data_type, const StringName &p_c
|
||||
bind.setter = p_setter;
|
||||
|
||||
theme_item_binds[p_class_name][p_prop_name] = bind;
|
||||
theme_item_binds_list[p_class_name].push_back(bind);
|
||||
}
|
||||
|
||||
void ThemeDB::bind_class_external_item(Theme::DataType p_data_type, const StringName &p_class_name, const StringName &p_prop_name, const StringName &p_item_name, const StringName &p_type_name, ThemeItemSetter p_setter) {
|
||||
@ -351,6 +352,7 @@ void ThemeDB::bind_class_external_item(Theme::DataType p_data_type, const String
|
||||
bind.setter = p_setter;
|
||||
|
||||
theme_item_binds[p_class_name][p_prop_name] = bind;
|
||||
theme_item_binds_list[p_class_name].push_back(bind);
|
||||
}
|
||||
|
||||
void ThemeDB::update_class_instance_items(Node *p_instance) {
|
||||
@ -371,7 +373,7 @@ void ThemeDB::update_class_instance_items(Node *p_instance) {
|
||||
}
|
||||
}
|
||||
|
||||
void ThemeDB::get_class_own_items(const StringName &p_class_name, List<ThemeItemBind> *r_list) {
|
||||
void ThemeDB::get_class_items(const StringName &p_class_name, List<ThemeItemBind> *r_list, bool p_include_inherited) {
|
||||
List<StringName> class_hierarchy;
|
||||
StringName class_name = p_class_name;
|
||||
while (class_name != StringName()) {
|
||||
@ -381,23 +383,32 @@ void ThemeDB::get_class_own_items(const StringName &p_class_name, List<ThemeItem
|
||||
|
||||
HashSet<StringName> inherited_props;
|
||||
for (const StringName &theme_type : class_hierarchy) {
|
||||
HashMap<StringName, HashMap<StringName, ThemeItemBind>>::Iterator E = theme_item_binds.find(theme_type);
|
||||
HashMap<StringName, List<ThemeItemBind>>::Iterator E = theme_item_binds_list.find(theme_type);
|
||||
if (E) {
|
||||
for (const KeyValue<StringName, ThemeItemBind> &F : E->value) {
|
||||
if (inherited_props.has(F.value.item_name)) {
|
||||
for (const ThemeItemBind &F : E->value) {
|
||||
if (inherited_props.has(F.item_name)) {
|
||||
continue; // Skip inherited properties.
|
||||
}
|
||||
if (F.value.external || F.value.class_name != p_class_name) {
|
||||
inherited_props.insert(F.value.item_name);
|
||||
continue; // Track properties defined in parent classes, and skip them.
|
||||
if (F.external || F.class_name != p_class_name) {
|
||||
inherited_props.insert(F.item_name);
|
||||
|
||||
if (!p_include_inherited) {
|
||||
continue; // Track properties defined in parent classes, and skip them.
|
||||
}
|
||||
}
|
||||
|
||||
r_list->push_back(F.value);
|
||||
r_list->push_back(F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ThemeDB::_sort_theme_items() {
|
||||
for (KeyValue<StringName, List<ThemeDB::ThemeItemBind>> &E : theme_item_binds_list) {
|
||||
E.value.sort_custom<ThemeItemBind::SortByType>();
|
||||
}
|
||||
}
|
||||
|
||||
// Object methods.
|
||||
|
||||
void ThemeDB::_bind_methods() {
|
||||
@ -435,6 +446,9 @@ ThemeDB *ThemeDB::get_singleton() {
|
||||
|
||||
ThemeDB::ThemeDB() {
|
||||
singleton = this;
|
||||
if (MessageQueue::get_singleton()) { // May not exist in tests etc.
|
||||
callable_mp(this, &ThemeDB::_sort_theme_items).call_deferred();
|
||||
}
|
||||
}
|
||||
|
||||
ThemeDB::~ThemeDB() {
|
||||
|
||||
@ -107,10 +107,19 @@ public:
|
||||
bool external = false;
|
||||
|
||||
ThemeItemSetter setter;
|
||||
|
||||
struct SortByType {
|
||||
_FORCE_INLINE_ bool operator()(const ThemeItemBind &l, const ThemeItemBind &r) const {
|
||||
return l.data_type < r.data_type;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
private:
|
||||
HashMap<StringName, HashMap<StringName, ThemeItemBind>> theme_item_binds;
|
||||
HashMap<StringName, List<ThemeItemBind>> theme_item_binds_list; // Used for listing purposes.
|
||||
|
||||
void _sort_theme_items();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
@ -162,7 +171,7 @@ public:
|
||||
void bind_class_external_item(Theme::DataType p_data_type, const StringName &p_class_name, const StringName &p_prop_name, const StringName &p_item_name, const StringName &p_type_name, ThemeItemSetter p_setter);
|
||||
void update_class_instance_items(Node *p_instance);
|
||||
|
||||
void get_class_own_items(const StringName &p_class_name, List<ThemeItemBind> *r_list);
|
||||
void get_class_items(const StringName &p_class_name, List<ThemeItemBind> *r_list, bool p_include_inherited = false);
|
||||
|
||||
// Memory management, reference, and initialization.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user