@@ -280,6 +280,10 @@ void SpriteFramesEditor::_sheet_scroll_input(const Ref<InputEvent> &p_event) {
280
280
}
281
281
282
282
void SpriteFramesEditor::_sheet_add_frames () {
283
+ if (frames.is_null ()) {
284
+ return ;
285
+ }
286
+
283
287
const Size2i frame_count = _get_frame_count ();
284
288
const Size2i frame_size = _get_frame_size ();
285
289
const Size2i offset = _get_offset ();
@@ -688,6 +692,10 @@ void SpriteFramesEditor::_notification(int p_what) {
688
692
}
689
693
690
694
void SpriteFramesEditor::_file_load_request (const Vector<String> &p_path, int p_at_pos) {
695
+ if (frames.is_null ()) {
696
+ return ;
697
+ }
698
+
691
699
ERR_FAIL_COND (!frames->has_animation (edited_anim));
692
700
693
701
List<Ref<Texture2D>> resources;
@@ -747,6 +755,10 @@ Size2i SpriteFramesEditor::_get_separation() const {
747
755
}
748
756
749
757
void SpriteFramesEditor::_load_pressed () {
758
+ if (frames.is_null ()) {
759
+ return ;
760
+ }
761
+
750
762
ERR_FAIL_COND (!frames->has_animation (edited_anim));
751
763
loading_scene = false ;
752
764
@@ -762,6 +774,10 @@ void SpriteFramesEditor::_load_pressed() {
762
774
}
763
775
764
776
void SpriteFramesEditor::_paste_pressed () {
777
+ if (frames.is_null ()) {
778
+ return ;
779
+ }
780
+
765
781
ERR_FAIL_COND (!frames->has_animation (edited_anim));
766
782
767
783
Ref<ClipboardSpriteFrames> clipboard_frames = EditorSettings::get_singleton ()->get_resource_clipboard ();
@@ -778,6 +794,10 @@ void SpriteFramesEditor::_paste_pressed() {
778
794
}
779
795
780
796
void SpriteFramesEditor::_paste_frame_array (const Ref<ClipboardSpriteFrames> &p_clipboard_frames) {
797
+ if (frames.is_null ()) {
798
+ return ;
799
+ }
800
+
781
801
if (p_clipboard_frames->frames .is_empty ()) {
782
802
return ;
783
803
}
@@ -805,6 +825,10 @@ void SpriteFramesEditor::_paste_frame_array(const Ref<ClipboardSpriteFrames> &p_
805
825
}
806
826
807
827
void SpriteFramesEditor::_paste_texture (const Ref<Texture2D> &p_texture) {
828
+ if (frames.is_null ()) {
829
+ return ;
830
+ }
831
+
808
832
float duration = 1.0 ;
809
833
810
834
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton ();
@@ -821,6 +845,10 @@ void SpriteFramesEditor::_paste_texture(const Ref<Texture2D> &p_texture) {
821
845
}
822
846
823
847
void SpriteFramesEditor::_copy_pressed () {
848
+ if (frames.is_null ()) {
849
+ return ;
850
+ }
851
+
824
852
ERR_FAIL_COND (!frames->has_animation (edited_anim));
825
853
826
854
Vector<int > selected_items = frame_list->get_selected_items ();
@@ -847,6 +875,10 @@ void SpriteFramesEditor::_copy_pressed() {
847
875
}
848
876
849
877
void SpriteFramesEditor::_empty_pressed () {
878
+ if (frames.is_null ()) {
879
+ return ;
880
+ }
881
+
850
882
ERR_FAIL_COND (!frames->has_animation (edited_anim));
851
883
852
884
int from = -1 ;
@@ -872,6 +904,10 @@ void SpriteFramesEditor::_empty_pressed() {
872
904
}
873
905
874
906
void SpriteFramesEditor::_empty2_pressed () {
907
+ if (frames.is_null ()) {
908
+ return ;
909
+ }
910
+
875
911
ERR_FAIL_COND (!frames->has_animation (edited_anim));
876
912
877
913
int from = -1 ;
@@ -897,6 +933,10 @@ void SpriteFramesEditor::_empty2_pressed() {
897
933
}
898
934
899
935
void SpriteFramesEditor::_up_pressed () {
936
+ if (frames.is_null ()) {
937
+ return ;
938
+ }
939
+
900
940
ERR_FAIL_COND (!frames->has_animation (edited_anim));
901
941
902
942
Vector<int > selected_items = frame_list->get_selected_items ();
@@ -943,6 +983,10 @@ void SpriteFramesEditor::_up_pressed() {
943
983
}
944
984
945
985
void SpriteFramesEditor::_down_pressed () {
986
+ if (frames.is_null ()) {
987
+ return ;
988
+ }
989
+
946
990
ERR_FAIL_COND (!frames->has_animation (edited_anim));
947
991
948
992
Vector<int > selected_items = frame_list->get_selected_items ();
@@ -989,6 +1033,10 @@ void SpriteFramesEditor::_down_pressed() {
989
1033
}
990
1034
991
1035
void SpriteFramesEditor::_delete_pressed () {
1036
+ if (frames.is_null ()) {
1037
+ return ;
1038
+ }
1039
+
992
1040
ERR_FAIL_COND (!frames->has_animation (edited_anim));
993
1041
994
1042
Vector<int > selected_items = frame_list->get_selected_items ();
@@ -1038,7 +1086,7 @@ void SpriteFramesEditor::_sync_animation() {
1038
1086
}
1039
1087
1040
1088
void SpriteFramesEditor::_select_animation (const String &p_name, bool p_update_node) {
1041
- if (frames. is_null () || !frames->has_animation (p_name)) {
1089
+ if (!frames->has_animation (p_name)) {
1042
1090
return ;
1043
1091
}
1044
1092
edited_anim = p_name;
@@ -1081,6 +1129,10 @@ static void _find_anim_sprites(Node *p_node, List<Node *> *r_nodes, Ref<SpriteFr
1081
1129
}
1082
1130
1083
1131
void SpriteFramesEditor::_animation_name_edited () {
1132
+ if (frames.is_null ()) {
1133
+ return ;
1134
+ }
1135
+
1084
1136
if (updating) {
1085
1137
return ;
1086
1138
}
@@ -1134,6 +1186,10 @@ void SpriteFramesEditor::_animation_name_edited() {
1134
1186
}
1135
1187
1136
1188
void SpriteFramesEditor::_rename_node_animation (EditorUndoRedoManager *undo_redo, bool is_undo, const String &p_filter, const String &p_new_animation, const String &p_new_autoplay) {
1189
+ if (frames.is_null ()) {
1190
+ return ;
1191
+ }
1192
+
1137
1193
List<Node *> nodes;
1138
1194
_find_anim_sprites (EditorNode::get_singleton ()->get_edited_scene (), &nodes, Ref<SpriteFrames>(frames));
1139
1195
@@ -1188,6 +1244,10 @@ void SpriteFramesEditor::_animation_add() {
1188
1244
}
1189
1245
1190
1246
void SpriteFramesEditor::_animation_duplicate () {
1247
+ if (frames.is_null ()) {
1248
+ return ;
1249
+ }
1250
+
1191
1251
if (updating) {
1192
1252
return ;
1193
1253
}
@@ -1223,6 +1283,10 @@ void SpriteFramesEditor::_animation_duplicate() {
1223
1283
}
1224
1284
1225
1285
void SpriteFramesEditor::_animation_remove () {
1286
+ if (frames.is_null ()) {
1287
+ return ;
1288
+ }
1289
+
1226
1290
if (updating) {
1227
1291
return ;
1228
1292
}
@@ -1236,6 +1300,10 @@ void SpriteFramesEditor::_animation_remove() {
1236
1300
}
1237
1301
1238
1302
void SpriteFramesEditor::_animation_remove_confirmed () {
1303
+ if (frames.is_null ()) {
1304
+ return ;
1305
+ }
1306
+
1239
1307
StringName new_edited;
1240
1308
List<StringName> anim_names;
1241
1309
frames->get_animation_list (&anim_names);
@@ -1276,6 +1344,10 @@ void SpriteFramesEditor::_animation_search_text_changed(const String &p_text) {
1276
1344
}
1277
1345
1278
1346
void SpriteFramesEditor::_animation_loop_changed () {
1347
+ if (frames.is_null ()) {
1348
+ return ;
1349
+ }
1350
+
1279
1351
if (updating) {
1280
1352
return ;
1281
1353
}
@@ -1294,6 +1366,10 @@ void SpriteFramesEditor::_animation_speed_resized() {
1294
1366
}
1295
1367
1296
1368
void SpriteFramesEditor::_animation_speed_changed (double p_value) {
1369
+ if (frames.is_null ()) {
1370
+ return ;
1371
+ }
1372
+
1297
1373
if (updating) {
1298
1374
return ;
1299
1375
}
@@ -1308,6 +1384,10 @@ void SpriteFramesEditor::_animation_speed_changed(double p_value) {
1308
1384
}
1309
1385
1310
1386
void SpriteFramesEditor::_frame_list_gui_input (const Ref<InputEvent> &p_event) {
1387
+ if (frames.is_null ()) {
1388
+ return ;
1389
+ }
1390
+
1311
1391
const Ref<InputEventMouseButton> mb = p_event;
1312
1392
1313
1393
if (mb.is_valid ()) {
@@ -1342,6 +1422,10 @@ void SpriteFramesEditor::_frame_list_gui_input(const Ref<InputEvent> &p_event) {
1342
1422
}
1343
1423
1344
1424
void SpriteFramesEditor::_menu_selected (int p_id) {
1425
+ if (frames.is_null ()) {
1426
+ return ;
1427
+ }
1428
+
1345
1429
switch (p_id) {
1346
1430
case MENU_SHOW_IN_FILESYSTEM: {
1347
1431
Ref<Texture2D> frame_texture = frames->get_frame_texture (edited_anim, right_clicked_frame);
@@ -1359,6 +1443,10 @@ void SpriteFramesEditor::_menu_selected(int p_id) {
1359
1443
}
1360
1444
1361
1445
void SpriteFramesEditor::_frame_list_item_selected (int p_index, bool p_selected) {
1446
+ if (frames.is_null ()) {
1447
+ return ;
1448
+ }
1449
+
1362
1450
if (updating) {
1363
1451
return ;
1364
1452
}
@@ -1374,6 +1462,10 @@ void SpriteFramesEditor::_frame_list_item_selected(int p_index, bool p_selected)
1374
1462
}
1375
1463
1376
1464
void SpriteFramesEditor::_frame_duration_changed (double p_value) {
1465
+ if (frames.is_null ()) {
1466
+ return ;
1467
+ }
1468
+
1377
1469
if (updating) {
1378
1470
return ;
1379
1471
}
@@ -1399,6 +1491,10 @@ void SpriteFramesEditor::_frame_duration_changed(double p_value) {
1399
1491
}
1400
1492
1401
1493
void SpriteFramesEditor::_zoom_in () {
1494
+ if (frames.is_null ()) {
1495
+ return ;
1496
+ }
1497
+
1402
1498
// Do not zoom in or out with no visible frames
1403
1499
if (frames->get_frame_count (edited_anim) <= 0 ) {
1404
1500
return ;
@@ -1412,6 +1508,10 @@ void SpriteFramesEditor::_zoom_in() {
1412
1508
}
1413
1509
1414
1510
void SpriteFramesEditor::_zoom_out () {
1511
+ if (frames.is_null ()) {
1512
+ return ;
1513
+ }
1514
+
1415
1515
// Do not zoom in or out with no visible frames
1416
1516
if (frames->get_frame_count (edited_anim) <= 0 ) {
1417
1517
return ;
@@ -1645,6 +1745,10 @@ Ref<SpriteFrames> SpriteFramesEditor::get_sprite_frames() const {
1645
1745
}
1646
1746
1647
1747
Variant SpriteFramesEditor::get_drag_data_fw (const Point2 &p_point, Control *p_from) {
1748
+ if (frames.is_null ()) {
1749
+ return false ;
1750
+ }
1751
+
1648
1752
if (read_only) {
1649
1753
return false ;
1650
1754
}
@@ -1718,6 +1822,10 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
1718
1822
}
1719
1823
1720
1824
void SpriteFramesEditor::drop_data_fw (const Point2 &p_point, const Variant &p_data, Control *p_from) {
1825
+ if (frames.is_null ()) {
1826
+ return ;
1827
+ }
1828
+
1721
1829
if (!can_drop_data_fw (p_point, p_data, p_from)) {
1722
1830
return ;
1723
1831
}
0 commit comments