diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-01-16 08:01:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-16 08:01:03 +0100 |
commit | bd1a8aacdae0cb1fd7044d6ff2cd7822b0e518a8 (patch) | |
tree | 34fbe025fc63c86329fe37e382bcd2e5da27ac7b /editor | |
parent | dd3779c12e707a4429b5319628f2dc23be0d2b9e (diff) | |
parent | 5e1dad3b28eadc3423e99f7b1919da5d4b9fbab6 (diff) |
Merge pull request #35187 from aaronfranke/editor-property-int
Use int64_t for EditorPropertyInteger and warn when out of double range
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_properties.cpp | 13 | ||||
-rw-r--r-- | editor/editor_properties.h | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c049096c35..c134786b89 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -805,10 +805,10 @@ EditorPropertyLayers::EditorPropertyLayers() { ///////////////////// INT ///////////////////////// -void EditorPropertyInteger::_value_changed(double val) { +void EditorPropertyInteger::_value_changed(int64_t val) { if (setting) return; - emit_changed(get_edited_property(), (int64_t)val); + emit_changed(get_edited_property(), val); } void EditorPropertyInteger::update_property() { @@ -816,14 +816,19 @@ void EditorPropertyInteger::update_property() { setting = true; spin->set_value(val); setting = false; +#ifdef DEBUG_ENABLED + // If spin (currently EditorSplinSlider : Range) is changed so that it can use int64_t, then the below warning wouldn't be a problem. + if (val != (int64_t)(double)(val)) { + WARN_PRINT("Cannot reliably represent '" + itos(val) + "' in the inspector, value is too large."); + } +#endif } void EditorPropertyInteger::_bind_methods() { - ClassDB::bind_method(D_METHOD("_value_changed"), &EditorPropertyInteger::_value_changed); } -void EditorPropertyInteger::setup(int p_min, int p_max, int p_step, bool p_allow_greater, bool p_allow_lesser) { +void EditorPropertyInteger::setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_allow_greater, bool p_allow_lesser) { spin->set_min(p_min); spin->set_max(p_max); spin->set_step(p_step); diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 4c7358597e..1853a6b6e1 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -263,14 +263,14 @@ class EditorPropertyInteger : public EditorProperty { GDCLASS(EditorPropertyInteger, EditorProperty); EditorSpinSlider *spin; bool setting; - void _value_changed(double p_val); + void _value_changed(int64_t p_val); protected: static void _bind_methods(); public: virtual void update_property(); - void setup(int p_min, int p_max, int p_step, bool p_allow_greater, bool p_allow_lesser); + void setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_allow_greater, bool p_allow_lesser); EditorPropertyInteger(); }; |