Merge pull request #32992 from KoBeWi/AUTOVECTORZ

Auto-increment frame_coords when keying
This commit is contained in:
Rémi Verschelde 2019-10-23 07:42:52 +02:00 committed by GitHub
commit 19fa163d9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View File

@ -644,7 +644,19 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
emit_signal("property_keyed", property, use_keying_next()); emit_signal("property_keyed", property, use_keying_next());
if (use_keying_next()) { if (use_keying_next()) {
call_deferred("emit_changed", property, object->get(property).operator int64_t() + 1, "", false); if (property == "frame_coords" && (object->is_class("Sprite") || object->is_class("Sprite3D"))) {
Vector2 new_coords = object->get(property);
new_coords.x++;
if (new_coords.x >= object->get("hframes").operator int64_t()) {
new_coords.x = 0;
new_coords.y++;
}
call_deferred("emit_changed", property, new_coords, "", false);
} else {
call_deferred("emit_changed", property, object->get(property).operator int64_t() + 1, "", false);
}
call_deferred("update_property"); call_deferred("update_property");
} }
} }

View File

@ -387,6 +387,10 @@ void Sprite::_validate_property(PropertyInfo &property) const {
property.hint_string = "0," + itos(vframes * hframes - 1) + ",1"; property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";
property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS; property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
} }
if (property.name == "frame_coords") {
property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
}
} }
void Sprite::_texture_changed() { void Sprite::_texture_changed() {

View File

@ -662,6 +662,10 @@ void Sprite3D::_validate_property(PropertyInfo &property) const {
property.hint_string = "0," + itos(vframes * hframes - 1) + ",1"; property.hint_string = "0," + itos(vframes * hframes - 1) + ",1";
property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS; property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
} }
if (property.name == "frame_coords") {
property.usage |= PROPERTY_USAGE_KEYING_INCREMENTS;
}
} }
void Sprite3D::_bind_methods() { void Sprite3D::_bind_methods() {