Skip to content

Commit

Permalink
Remember frames when selecting SpriteFrame frames
Browse files Browse the repository at this point in the history
  • Loading branch information
LeulMulugeta committed Mar 5, 2024
1 parent 7d80635 commit effad7b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 15 additions & 12 deletions editor/plugins/sprite_frames_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,18 +525,21 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) {
split_sheet_offset_x->set_max(size.x);
split_sheet_offset_y->set_max(size.y);

// Different texture, reset to 4x4.
dominant_param = PARAM_FRAME_COUNT;
updating_split_settings = true;
split_sheet_h->set_value(4);
split_sheet_v->set_value(4);
split_sheet_size_x->set_value(size.x / 4);
split_sheet_size_y->set_value(size.y / 4);
split_sheet_sep_x->set_value(0);
split_sheet_sep_y->set_value(0);
split_sheet_offset_x->set_value(0);
split_sheet_offset_y->set_value(0);
updating_split_settings = false;
if (size != previous_texture_size) {
// Different texture, reset to 4x4.
dominant_param = PARAM_FRAME_COUNT;
updating_split_settings = true;
split_sheet_h->set_value(4);
split_sheet_v->set_value(4);
split_sheet_size_x->set_value(size.x / 4);
split_sheet_size_y->set_value(size.y / 4);
split_sheet_sep_x->set_value(0);
split_sheet_sep_y->set_value(0);
split_sheet_offset_x->set_value(0);
split_sheet_offset_y->set_value(0);
updating_split_settings = false;
}
previous_texture_size = size;

// Reset zoom.
_sheet_zoom_reset();
Expand Down
2 changes: 2 additions & 0 deletions editor/plugins/sprite_frames_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ class SpriteFramesEditor : public HSplitContainer {
bool frames_need_sort = false;
int last_frame_selected = 0;

Size2i previous_texture_size;

float scale_ratio;
int thumbnail_default_size;
float thumbnail_zoom;
Expand Down

0 comments on commit effad7b

Please sign in to comment.