diff options
author | Ninni Pipping <over999ships@gmail.com> | 2023-07-02 10:45:16 +0200 |
---|---|---|
committer | Ninni Pipping <over999ships@gmail.com> | 2023-07-02 10:45:16 +0200 |
commit | c7e4b3bf5f287044dc62d25e76b235dc049565b3 (patch) | |
tree | 82b928726572da5d873b7427c4edde8c4b17d988 | |
parent | 46424488edc341b65467ee7fd3ac423e4d49ad34 (diff) | |
download | redot-engine-c7e4b3bf5f287044dc62d25e76b235dc049565b3.tar.gz |
Add compatibility properties to `TouchScreenButton`
Added support for `3.x` properties:
* `normal` -> `texture_normal`
* `pressed` -> `texture_pressed`
-rw-r--r-- | scene/2d/touch_screen_button.cpp | 13 | ||||
-rw-r--r-- | scene/2d/touch_screen_button.h | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp index 7da2fc3cb3..10a9e7edec 100644 --- a/scene/2d/touch_screen_button.cpp +++ b/scene/2d/touch_screen_button.cpp @@ -369,6 +369,19 @@ bool TouchScreenButton::is_passby_press_enabled() const { return passby_press; } +#ifndef DISABLE_DEPRECATED +bool TouchScreenButton::_set(const StringName &p_name, const Variant &p_value) { + if (p_name == SNAME("normal")) { // Compatibility with Godot 3.x. + set_texture_normal(p_value); + return true; + } else if (p_name == SNAME("pressed")) { // Compatibility with Godot 3.x. + set_texture_pressed(p_value); + return true; + } + return false; +} +#endif // DISABLE_DEPRECATED + void TouchScreenButton::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture_normal", "texture"), &TouchScreenButton::set_texture_normal); ClassDB::bind_method(D_METHOD("get_texture_normal"), &TouchScreenButton::get_texture_normal); diff --git a/scene/2d/touch_screen_button.h b/scene/2d/touch_screen_button.h index 492aa377e6..c7dc0a323e 100644 --- a/scene/2d/touch_screen_button.h +++ b/scene/2d/touch_screen_button.h @@ -71,6 +71,9 @@ private: protected: void _notification(int p_what); static void _bind_methods(); +#ifndef DISABLE_DEPRECATED + bool _set(const StringName &p_name, const Variant &p_value); +#endif // DISABLE_DEPRECATED public: #ifdef TOOLS_ENABLED |