diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-03-26 22:54:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-26 22:54:45 +0100 |
commit | e3d183f2cf00c50f64d34e0d6e691c552c4d3902 (patch) | |
tree | 08409403bc569dc446fea818b6e9cd1048c5b99b | |
parent | 96ffcc4d52029d5712e1a7b8d454c5751c26ceb0 (diff) | |
parent | 356fac206d51c600fb597cdd03aba4a594dbc8c7 (diff) |
Merge pull request #59560 from Sauermann/proposal-subviewportcontainer-configuration-warning
Add configuration warning for SubViewportContainer
-rw-r--r-- | scene/gui/subviewport_container.cpp | 17 | ||||
-rw-r--r-- | scene/gui/subviewport_container.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp index c66e145bc4..799eea7eac 100644 --- a/scene/gui/subviewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -223,6 +223,23 @@ void SubViewportContainer::unhandled_input(const Ref<InputEvent> &p_event) { } } +TypedArray<String> SubViewportContainer::get_configuration_warnings() const { + TypedArray<String> warnings = Node::get_configuration_warnings(); + + bool has_viewport = false; + for (int i = 0; i < get_child_count(); i++) { + if (Object::cast_to<SubViewport>(get_child(i))) { + has_viewport = true; + break; + } + } + if (!has_viewport) { + warnings.push_back(TTR("This node doesn't have a SubViewport as child, so it can't display its intended content.\nConsider adding a SubViewport as a child to provide something displayable.")); + } + + return warnings; +} + void SubViewportContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_stretch", "enable"), &SubViewportContainer::set_stretch); ClassDB::bind_method(D_METHOD("is_stretch_enabled"), &SubViewportContainer::is_stretch_enabled); diff --git a/scene/gui/subviewport_container.h b/scene/gui/subviewport_container.h index f52f01e4e2..55b7802aa4 100644 --- a/scene/gui/subviewport_container.h +++ b/scene/gui/subviewport_container.h @@ -58,6 +58,8 @@ public: virtual Vector<int> get_allowed_size_flags_horizontal() const override; virtual Vector<int> get_allowed_size_flags_vertical() const override; + TypedArray<String> get_configuration_warnings() const override; + SubViewportContainer(); }; |