Use int64_t for EditorPropertyInteger and warn when out of double range
This commit is contained in:
parent
e889100f2f
commit
5e1dad3b28
@ -805,10 +805,10 @@ EditorPropertyLayers::EditorPropertyLayers() {
|
|||||||
|
|
||||||
///////////////////// INT /////////////////////////
|
///////////////////// INT /////////////////////////
|
||||||
|
|
||||||
void EditorPropertyInteger::_value_changed(double val) {
|
void EditorPropertyInteger::_value_changed(int64_t val) {
|
||||||
if (setting)
|
if (setting)
|
||||||
return;
|
return;
|
||||||
emit_changed(get_edited_property(), (int64_t)val);
|
emit_changed(get_edited_property(), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPropertyInteger::update_property() {
|
void EditorPropertyInteger::update_property() {
|
||||||
@ -816,14 +816,19 @@ void EditorPropertyInteger::update_property() {
|
|||||||
setting = true;
|
setting = true;
|
||||||
spin->set_value(val);
|
spin->set_value(val);
|
||||||
setting = false;
|
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() {
|
void EditorPropertyInteger::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_value_changed"), &EditorPropertyInteger::_value_changed);
|
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_min(p_min);
|
||||||
spin->set_max(p_max);
|
spin->set_max(p_max);
|
||||||
spin->set_step(p_step);
|
spin->set_step(p_step);
|
||||||
|
@ -263,14 +263,14 @@ class EditorPropertyInteger : public EditorProperty {
|
|||||||
GDCLASS(EditorPropertyInteger, EditorProperty);
|
GDCLASS(EditorPropertyInteger, EditorProperty);
|
||||||
EditorSpinSlider *spin;
|
EditorSpinSlider *spin;
|
||||||
bool setting;
|
bool setting;
|
||||||
void _value_changed(double p_val);
|
void _value_changed(int64_t p_val);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void update_property();
|
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();
|
EditorPropertyInteger();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user