diff options
Diffstat (limited to 'scene/resources')
| -rw-r--r-- | scene/resources/font.cpp | 116 | ||||
| -rw-r--r-- | scene/resources/primitive_meshes.cpp | 30 | ||||
| -rw-r--r-- | scene/resources/resource_format_text.cpp | 1 | ||||
| -rw-r--r-- | scene/resources/style_box.h | 1 | ||||
| -rw-r--r-- | scene/resources/syntax_highlighter.h | 1 | ||||
| -rw-r--r-- | scene/resources/theme.cpp | 6 |
6 files changed, 57 insertions, 98 deletions
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 9d546c90c7..c8a98a6831 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -2779,48 +2779,25 @@ Ref<Font> FontVariation::_get_base_font_or_default() const { return base_font; } - // Check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_project_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); + StringName theme_name = "font"; + List<StringName> theme_types; + ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types); - for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - Ref<Font> f = ThemeDB::get_singleton()->get_project_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - if (f == this) { - continue; - } - if (f.is_valid()) { - theme_font = f; - theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); - } - return f; - } + ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_null()) { + continue; } - } - - // Lastly, fall back on the items defined in the default Theme, if they exist. - if (ThemeDB::get_singleton()->get_default_theme().is_valid()) { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_default_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - if (f == this) { - continue; - } - if (f.is_valid()) { - theme_font = f; - theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); - } - return f; + if (!theme->has_font(theme_name, E)) { + continue; } - } - // If they don't exist, use any type to return the default/empty value. - Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName()); - if (f != this) { + Ref<Font> f = theme->get_font(theme_name, E); + if (f == this) { + continue; + } if (f.is_valid()) { theme_font = f; theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); @@ -2829,6 +2806,15 @@ Ref<Font> FontVariation::_get_base_font_or_default() const { } } + Ref<Font> f = global_context->get_fallback_theme()->get_font(theme_name, StringName()); + if (f != this) { + if (f.is_valid()) { + theme_font = f; + theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<FontVariation *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); + } + return f; + } + return Ref<Font>(); } @@ -3131,48 +3117,25 @@ Ref<Font> SystemFont::_get_base_font_or_default() const { return base_font; } - // Check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_project_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); + StringName theme_name = "font"; + List<StringName> theme_types; + ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types); - for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - Ref<Font> f = ThemeDB::get_singleton()->get_project_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - if (f == this) { - continue; - } - if (f.is_valid()) { - theme_font = f; - theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); - } - return f; - } + ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_null()) { + continue; } - } - - // Lastly, fall back on the items defined in the default Theme, if they exist. - if (ThemeDB::get_singleton()->get_default_theme().is_valid()) { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_default_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - if (f == this) { - continue; - } - if (f.is_valid()) { - theme_font = f; - theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); - } - return f; + if (!theme->has_font(theme_name, E)) { + continue; } - } - // If they don't exist, use any type to return the default/empty value. - Ref<Font> f = ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName()); - if (f != this) { + Ref<Font> f = theme->get_font(theme_name, E); + if (f == this) { + continue; + } if (f.is_valid()) { theme_font = f; theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); @@ -3181,6 +3144,15 @@ Ref<Font> SystemFont::_get_base_font_or_default() const { } } + Ref<Font> f = global_context->get_fallback_theme()->get_font(theme_name, StringName()); + if (f != this) { + if (f.is_valid()) { + theme_font = f; + theme_font->connect_changed(callable_mp(reinterpret_cast<Font *>(const_cast<SystemFont *>(this)), &Font::_invalidate_rids), CONNECT_REFERENCE_COUNTED); + } + return f; + } + return Ref<Font>(); } diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index a64ae07f05..6d848f5494 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -3466,32 +3466,24 @@ Ref<Font> TextMesh::_get_font_or_default() const { return font_override; } - // Check the project-defined Theme resource. - if (ThemeDB::get_singleton()->get_project_theme().is_valid()) { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_project_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); - - for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_project_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - return ThemeDB::get_singleton()->get_project_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); - } + StringName theme_name = "font"; + List<StringName> theme_types; + ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types); + + ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context(); + for (const Ref<Theme> &theme : global_context->get_themes()) { + if (theme.is_null()) { + continue; } - } - - // Lastly, fall back on the items defined in the default Theme, if they exist. - { - List<StringName> theme_types; - ThemeDB::get_singleton()->get_default_theme()->get_type_dependencies(get_class_name(), StringName(), &theme_types); for (const StringName &E : theme_types) { - if (ThemeDB::get_singleton()->get_default_theme()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) { - return ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E); + if (theme->has_font(theme_name, E)) { + return theme->get_font(theme_name, E); } } } - // If they don't exist, use any type to return the default/empty value. - return ThemeDB::get_singleton()->get_default_theme()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName()); + return global_context->get_fallback_theme()->get_font(theme_name, StringName()); } void TextMesh::set_font_size(int p_size) { diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index a2c04698e1..31f6d6a84a 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -34,6 +34,7 @@ #include "core/io/dir_access.h" #include "core/io/missing_resource.h" #include "core/io/resource_format_binary.h" +#include "core/object/script_language.h" #include "core/version.h" // Version 2: changed names for Basis, AABB, Vectors, etc. diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 3f9a96be2f..3d3a059d0b 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -34,7 +34,6 @@ #include "core/io/resource.h" #include "core/object/class_db.h" #include "core/object/gdvirtual.gen.inc" -#include "core/object/script_language.h" class CanvasItem; diff --git a/scene/resources/syntax_highlighter.h b/scene/resources/syntax_highlighter.h index bf263f9490..cac2807ee2 100644 --- a/scene/resources/syntax_highlighter.h +++ b/scene/resources/syntax_highlighter.h @@ -33,7 +33,6 @@ #include "core/io/resource.h" #include "core/object/gdvirtual.gen.inc" -#include "core/object/script_language.h" class TextEdit; diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 799a8471b9..d2a1519d49 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -1263,11 +1263,7 @@ void Theme::get_type_dependencies(const StringName &p_base_type, const StringNam } // Continue building the chain using native class hierarchy. - StringName class_name = p_base_type; - while (class_name != StringName()) { - p_list->push_back(class_name); - class_name = ClassDB::get_parent_class_nocheck(class_name); - } + ThemeDB::get_singleton()->get_native_type_dependencies(p_base_type, p_list); } // Internal methods for getting lists as a Vector of String (compatible with public API). |
