mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 23:31:53 -05:00
Improve use of Ref.is_null/valid
Use `is_null` over `!is_valid` and vice versa.
This commit is contained in:
committed by
AThousandShips
parent
0f95e9f8e6
commit
a1846b27ea
@@ -220,7 +220,7 @@ Rect2 AnimationTrackEditAudio::get_key_rect(int p_index, float p_pixels_sec) {
|
||||
|
||||
Ref<AudioStream> stream = object->call("get_stream");
|
||||
|
||||
if (!stream.is_valid()) {
|
||||
if (stream.is_null()) {
|
||||
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ void AnimationTrackEditAudio::draw_key(int p_index, float p_pixels_sec, int p_x,
|
||||
|
||||
Ref<AudioStream> stream = object->call("get_stream");
|
||||
|
||||
if (!stream.is_valid()) {
|
||||
if (stream.is_null()) {
|
||||
AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right);
|
||||
return;
|
||||
}
|
||||
@@ -379,7 +379,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
|
||||
|
||||
if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) {
|
||||
Ref<Texture2D> texture = object->call("get_texture");
|
||||
if (!texture.is_valid()) {
|
||||
if (texture.is_null()) {
|
||||
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
|
||||
}
|
||||
|
||||
Ref<Texture2D> texture = sf->get_frame_texture(animation_name, frame);
|
||||
if (!texture.is_valid()) {
|
||||
if (texture.is_null()) {
|
||||
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
|
||||
|
||||
if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) {
|
||||
texture = object->call("get_texture");
|
||||
if (!texture.is_valid()) {
|
||||
if (texture.is_null()) {
|
||||
AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right);
|
||||
return;
|
||||
}
|
||||
@@ -514,7 +514,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
|
||||
}
|
||||
|
||||
texture = sf->get_frame_texture(animation_name, frame);
|
||||
if (!texture.is_valid()) {
|
||||
if (texture.is_null()) {
|
||||
AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right);
|
||||
return;
|
||||
}
|
||||
@@ -808,7 +808,7 @@ int AnimationTrackEditTypeAudio::get_key_height() const {
|
||||
Rect2 AnimationTrackEditTypeAudio::get_key_rect(int p_index, float p_pixels_sec) {
|
||||
Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), p_index);
|
||||
|
||||
if (!stream.is_valid()) {
|
||||
if (stream.is_null()) {
|
||||
return AnimationTrackEdit::get_key_rect(p_index, p_pixels_sec);
|
||||
}
|
||||
|
||||
@@ -841,7 +841,7 @@ bool AnimationTrackEditTypeAudio::is_key_selectable_by_distance() const {
|
||||
|
||||
void AnimationTrackEditTypeAudio::draw_key(int p_index, float p_pixels_sec, int p_x, bool p_selected, int p_clip_left, int p_clip_right) {
|
||||
Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), p_index);
|
||||
if (!stream.is_valid()) {
|
||||
if (stream.is_null()) {
|
||||
AnimationTrackEdit::draw_key(p_index, p_pixels_sec, p_x, p_selected, p_clip_left, p_clip_right); // Draw diamond.
|
||||
return;
|
||||
}
|
||||
@@ -1025,7 +1025,7 @@ void AnimationTrackEditTypeAudio::gui_input(const Ref<InputEvent> &p_event) {
|
||||
for (int i = 0; i < get_animation()->track_get_key_count(get_track()); i++) {
|
||||
Ref<AudioStream> stream = get_animation()->audio_track_get_key_stream(get_track(), i);
|
||||
|
||||
if (!stream.is_valid()) {
|
||||
if (stream.is_null()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user