From 75688772b3efadb8a36b1bb7ccde9c08819bc58e Mon Sep 17 00:00:00 2001 From: reduz Date: Tue, 29 Jun 2021 16:42:12 -0300 Subject: Fix editor suffixes and degrees conversion * Functions to convert to/from degrees are all gone. Conversion is done by the editor. * Use PROPERTY_HINT_ANGLE instead of PROPERTY_HINT_RANGE to edit radian angles in degrees. * Added possibility to add suffixes to range properties, use "min,max[,step][,suffix:]" example "0,100,1,suffix:m" * In general, can add suffixes for EditorSpinSlider Not covered by this PR, will have to be addressed by future ones: * Ability to switch radians/degrees in the inspector for angle properties (if actually wanted). * Animations previously made will most likely break, need to add a way to make old ones compatible. * Only added a "px" suffix to 2D position and a "m" one to 3D position, someone needs to go through the rest of the engine and add all remaining suffixes. * Likely also need to track down usage of EditorSpinSlider outside properties to add suffixes to it too. --- editor/editor_properties.h | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'editor/editor_properties.h') diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 522f4eebf6..6b5bda295b 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -298,7 +298,8 @@ public: class EditorPropertyFloat : public EditorProperty { GDCLASS(EditorPropertyFloat, EditorProperty); EditorSpinSlider *spin; - bool setting; + bool setting = false; + bool angle_in_radians = false; void _value_changed(double p_val); protected: @@ -306,7 +307,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_exp_range, bool p_greater, bool p_lesser); + void setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_exp_range, bool p_greater, bool p_lesser, const String &p_suffix = String(), bool p_angle_in_radians = false); EditorPropertyFloat(); }; @@ -363,7 +364,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_no_slider); + void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String()); EditorPropertyVector2(bool p_force_wide = false); }; @@ -379,14 +380,15 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_no_slider); + void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String()); EditorPropertyRect2(bool p_force_wide = false); }; class EditorPropertyVector3 : public EditorProperty { GDCLASS(EditorPropertyVector3, EditorProperty); EditorSpinSlider *spin[3]; - bool setting; + bool setting = false; + bool angle_in_radians = false; void _value_changed(double p_val, const String &p_name); protected: @@ -397,7 +399,7 @@ public: virtual void update_property() override; virtual void update_using_vector(Vector3 p_vector); virtual Vector3 get_vector(); - void setup(double p_min, double p_max, double p_step, bool p_no_slider); + void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String(), bool p_angle_in_radians = false); EditorPropertyVector3(bool p_force_wide = false); }; @@ -413,7 +415,7 @@ protected: public: virtual void update_property() override; - void setup(int p_min, int p_max, bool p_no_slider); + void setup(int p_min, int p_max, bool p_no_slider, const String &p_suffix = String()); EditorPropertyVector2i(bool p_force_wide = false); }; @@ -429,7 +431,7 @@ protected: public: virtual void update_property() override; - void setup(int p_min, int p_max, bool p_no_slider); + void setup(int p_min, int p_max, bool p_no_slider, const String &p_suffix = String()); EditorPropertyRect2i(bool p_force_wide = false); }; @@ -445,7 +447,7 @@ protected: public: virtual void update_property() override; - void setup(int p_min, int p_max, bool p_no_slider); + void setup(int p_min, int p_max, bool p_no_slider, const String &p_suffix = String()); EditorPropertyVector3i(bool p_force_wide = false); }; @@ -461,7 +463,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_no_slider); + void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String()); EditorPropertyPlane(bool p_force_wide = false); }; @@ -477,7 +479,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_no_slider); + void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String()); EditorPropertyQuaternion(); }; @@ -493,7 +495,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_no_slider); + void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String()); EditorPropertyAABB(); }; @@ -509,7 +511,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_no_slider); + void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String()); EditorPropertyTransform2D(); }; @@ -525,7 +527,7 @@ protected: public: virtual void update_property() override; - void setup(double p_min, double p_max, double p_step, bool p_no_slider); + void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String()); EditorPropertyBasis(); }; @@ -542,7 +544,7 @@ protected: public: virtual void update_property() override; virtual void update_using_transform(Transform3D p_transform); - void setup(double p_min, double p_max, double p_step, bool p_no_slider); + void setup(double p_min, double p_max, double p_step, bool p_no_slider, const String &p_suffix = String()); EditorPropertyTransform3D(); }; -- cgit v1.2.3