feat: updated engine version to 4.4-rc1

This commit is contained in:
Sara 2025-02-23 14:38:14 +01:00
parent ee00efde1f
commit 21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions

View file

@ -30,7 +30,6 @@
#include "sprite_frames_editor_plugin.h"
#include "core/config/project_settings.h"
#include "core/io/resource_loader.h"
#include "core/os/keyboard.h"
#include "editor/editor_command_palette.h"
@ -39,10 +38,13 @@
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/filesystem_dock.h"
#include "editor/gui/editor_bottom_panel.h"
#include "editor/gui/editor_file_dialog.h"
#include "editor/scene_tree_dock.h"
#include "editor/themes/editor_scale.h"
#include "scene/2d/animated_sprite_2d.h"
#include "scene/3d/sprite_3d.h"
#include "scene/gui/center_container.h"
#include "scene/gui/flow_container.h"
#include "scene/gui/margin_container.h"
@ -498,12 +500,88 @@ void SpriteFramesEditor::_toggle_show_settings() {
void SpriteFramesEditor::_update_show_settings() {
if (is_layout_rtl()) {
toggle_settings_button->set_icon(get_editor_theme_icon(split_sheet_settings_vb->is_visible() ? SNAME("Back") : SNAME("Forward")));
toggle_settings_button->set_button_icon(get_editor_theme_icon(split_sheet_settings_vb->is_visible() ? SNAME("Back") : SNAME("Forward")));
} else {
toggle_settings_button->set_icon(get_editor_theme_icon(split_sheet_settings_vb->is_visible() ? SNAME("Forward") : SNAME("Back")));
toggle_settings_button->set_button_icon(get_editor_theme_icon(split_sheet_settings_vb->is_visible() ? SNAME("Forward") : SNAME("Back")));
}
}
void SpriteFramesEditor::_auto_slice_sprite_sheet() {
if (updating_split_settings) {
return;
}
updating_split_settings = true;
const Size2i size = split_sheet_preview->get_texture()->get_size();
const Size2i split_sheet = _estimate_sprite_sheet_size(split_sheet_preview->get_texture());
split_sheet_h->set_value(split_sheet.x);
split_sheet_v->set_value(split_sheet.y);
split_sheet_size_x->set_value(size.x / split_sheet.x);
split_sheet_size_y->set_value(size.y / split_sheet.y);
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;
frames_selected.clear();
selected_count = 0;
last_frame_selected = -1;
split_sheet_preview->queue_redraw();
}
bool SpriteFramesEditor::_matches_background_color(const Color &p_background_color, const Color &p_pixel_color) {
if ((p_background_color.a == 0 && p_pixel_color.a == 0) || p_background_color.is_equal_approx(p_pixel_color)) {
return true;
}
Color d = p_background_color - p_pixel_color;
// 0.04f is the threshold for how much a colour can deviate from background colour and still be considered a match. Arrived at through experimentation, can be tweaked.
return (d.r * d.r) + (d.g * d.g) + (d.b * d.b) + (d.a * d.a) < 0.04f;
}
Size2i SpriteFramesEditor::_estimate_sprite_sheet_size(const Ref<Texture2D> p_texture) {
Ref<Image> image = p_texture->get_image();
Size2i size = p_texture->get_size();
Color assumed_background_color = image->get_pixel(0, 0);
Size2i sheet_size;
bool previous_line_background = true;
for (int x = 0; x < size.x; x++) {
int y = 0;
while (y < size.y && _matches_background_color(assumed_background_color, image->get_pixel(x, y))) {
y++;
}
bool current_line_background = (y == size.y);
if (previous_line_background && !current_line_background) {
sheet_size.x++;
}
previous_line_background = current_line_background;
}
previous_line_background = true;
for (int y = 0; y < size.y; y++) {
int x = 0;
while (x < size.x && _matches_background_color(assumed_background_color, image->get_pixel(x, y))) {
x++;
}
bool current_line_background = (x == size.x);
if (previous_line_background && !current_line_background) {
sheet_size.y++;
}
previous_line_background = current_line_background;
}
if (sheet_size == Size2i(0, 0) || sheet_size == Size2i(1, 1)) {
sheet_size = Size2i(4, 4);
}
return sheet_size;
}
void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) {
Ref<Texture2D> texture = ResourceLoader::load(p_file);
if (texture.is_null()) {
@ -530,10 +608,11 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) {
// 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);
const Size2i split_sheet = Size2i(4, 4);
split_sheet_h->set_value(split_sheet.x);
split_sheet_v->set_value(split_sheet.y);
split_sheet_size_x->set_value(size.x / split_sheet.x);
split_sheet_size_y->set_value(size.y / split_sheet.y);
split_sheet_sep_x->set_value(0);
split_sheet_sep_y->set_value(0);
split_sheet_offset_x->set_value(0);
@ -562,31 +641,32 @@ void SpriteFramesEditor::_notification(int p_what) {
pause_icon = get_editor_theme_icon(SNAME("Pause"));
_update_stop_icon();
autoplay->set_icon(get_editor_theme_icon(SNAME("AutoPlay")));
anim_loop->set_icon(get_editor_theme_icon(SNAME("Loop")));
play->set_icon(get_editor_theme_icon(SNAME("PlayStart")));
play_from->set_icon(get_editor_theme_icon(SNAME("Play")));
play_bw->set_icon(get_editor_theme_icon(SNAME("PlayStartBackwards")));
play_bw_from->set_icon(get_editor_theme_icon(SNAME("PlayBackwards")));
autoplay->set_button_icon(get_editor_theme_icon(SNAME("AutoPlay")));
anim_loop->set_button_icon(get_editor_theme_icon(SNAME("Loop")));
play->set_button_icon(get_editor_theme_icon(SNAME("PlayStart")));
play_from->set_button_icon(get_editor_theme_icon(SNAME("Play")));
play_bw->set_button_icon(get_editor_theme_icon(SNAME("PlayStartBackwards")));
play_bw_from->set_button_icon(get_editor_theme_icon(SNAME("PlayBackwards")));
load->set_icon(get_editor_theme_icon(SNAME("Load")));
load_sheet->set_icon(get_editor_theme_icon(SNAME("SpriteSheet")));
copy->set_icon(get_editor_theme_icon(SNAME("ActionCopy")));
paste->set_icon(get_editor_theme_icon(SNAME("ActionPaste")));
empty_before->set_icon(get_editor_theme_icon(SNAME("InsertBefore")));
empty_after->set_icon(get_editor_theme_icon(SNAME("InsertAfter")));
move_up->set_icon(get_editor_theme_icon(SNAME("MoveLeft")));
move_down->set_icon(get_editor_theme_icon(SNAME("MoveRight")));
delete_frame->set_icon(get_editor_theme_icon(SNAME("Remove")));
zoom_out->set_icon(get_editor_theme_icon(SNAME("ZoomLess")));
zoom_reset->set_icon(get_editor_theme_icon(SNAME("ZoomReset")));
zoom_in->set_icon(get_editor_theme_icon(SNAME("ZoomMore")));
add_anim->set_icon(get_editor_theme_icon(SNAME("New")));
delete_anim->set_icon(get_editor_theme_icon(SNAME("Remove")));
load->set_button_icon(get_editor_theme_icon(SNAME("Load")));
load_sheet->set_button_icon(get_editor_theme_icon(SNAME("SpriteSheet")));
copy->set_button_icon(get_editor_theme_icon(SNAME("ActionCopy")));
paste->set_button_icon(get_editor_theme_icon(SNAME("ActionPaste")));
empty_before->set_button_icon(get_editor_theme_icon(SNAME("InsertBefore")));
empty_after->set_button_icon(get_editor_theme_icon(SNAME("InsertAfter")));
move_up->set_button_icon(get_editor_theme_icon(SNAME("MoveLeft")));
move_down->set_button_icon(get_editor_theme_icon(SNAME("MoveRight")));
delete_frame->set_button_icon(get_editor_theme_icon(SNAME("Remove")));
zoom_out->set_button_icon(get_editor_theme_icon(SNAME("ZoomLess")));
zoom_reset->set_button_icon(get_editor_theme_icon(SNAME("ZoomReset")));
zoom_in->set_button_icon(get_editor_theme_icon(SNAME("ZoomMore")));
add_anim->set_button_icon(get_editor_theme_icon(SNAME("New")));
duplicate_anim->set_button_icon(get_editor_theme_icon(SNAME("Duplicate")));
delete_anim->set_button_icon(get_editor_theme_icon(SNAME("Remove")));
anim_search_box->set_right_icon(get_editor_theme_icon(SNAME("Search")));
split_sheet_zoom_out->set_icon(get_editor_theme_icon(SNAME("ZoomLess")));
split_sheet_zoom_reset->set_icon(get_editor_theme_icon(SNAME("ZoomReset")));
split_sheet_zoom_in->set_icon(get_editor_theme_icon(SNAME("ZoomMore")));
split_sheet_zoom_out->set_button_icon(get_editor_theme_icon(SNAME("ZoomLess")));
split_sheet_zoom_reset->set_button_icon(get_editor_theme_icon(SNAME("ZoomReset")));
split_sheet_zoom_in->set_button_icon(get_editor_theme_icon(SNAME("ZoomMore")));
split_sheet_scroll->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree")));
_update_show_settings();
@ -1102,6 +1182,41 @@ void SpriteFramesEditor::_animation_add() {
animations->grab_focus();
}
void SpriteFramesEditor::_animation_duplicate() {
if (updating) {
return;
}
if (!frames->has_animation(edited_anim)) {
return;
}
int counter = 1;
String new_name = edited_anim;
PackedStringArray name_component = new_name.rsplit("_", true, 1);
String base_name = name_component[0];
if (name_component.size() > 1 && name_component[1].is_valid_int() && name_component[1].to_int() >= 0) {
counter = name_component[1].to_int();
}
new_name = base_name + "_" + itos(counter);
while (frames->has_animation(new_name)) {
counter++;
new_name = base_name + "_" + itos(counter);
}
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Duplicate Animation"), UndoRedo::MERGE_DISABLE, EditorNode::get_singleton()->get_edited_scene());
undo_redo->add_do_method(frames.ptr(), "duplicate_animation", edited_anim, new_name);
undo_redo->add_undo_method(frames.ptr(), "remove_animation", new_name);
undo_redo->add_do_method(this, "_select_animation", new_name);
undo_redo->add_undo_method(this, "_select_animation", edited_anim);
undo_redo->add_do_method(this, "_update_library");
undo_redo->add_undo_method(this, "_update_library");
undo_redo->commit_action();
animations->grab_focus();
}
void SpriteFramesEditor::_animation_remove() {
if (updating) {
return;
@ -1169,6 +1284,10 @@ void SpriteFramesEditor::_animation_loop_changed() {
undo_redo->commit_action();
}
void SpriteFramesEditor::_animation_speed_resized() {
anim_speed->update_minimum_size();
}
void SpriteFramesEditor::_animation_speed_changed(double p_value) {
if (updating) {
return;
@ -1195,10 +1314,43 @@ void SpriteFramesEditor::_frame_list_gui_input(const Ref<InputEvent> &p_event) {
_zoom_out();
// Don't scroll down after zooming out.
accept_event();
} else if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) {
Point2 pos = mb->get_position();
right_clicked_frame = frame_list->get_item_at_position(pos, true);
if (right_clicked_frame != -1) {
Ref<Texture2D> tex = frames->get_frame_texture(edited_anim, right_clicked_frame);
if (tex.is_null()) {
return;
}
if (!menu) {
menu = memnew(PopupMenu);
add_child(menu);
menu->connect(SceneStringName(id_pressed), callable_mp(this, &SpriteFramesEditor::_menu_selected));
menu->add_icon_item(get_editor_theme_icon(SNAME("ShowInFileSystem")), TTRC("Show in FileSystem"));
}
menu->set_position(get_screen_position() + get_local_mouse_position());
menu->popup();
}
}
}
}
void SpriteFramesEditor::_menu_selected(int p_index) {
switch (p_index) {
case MENU_SHOW_IN_FILESYSTEM: {
String path = frames->get_frame_texture(edited_anim, right_clicked_frame)->get_path();
// Check if the file is an atlas resource, if it is find the source texture.
Ref<AtlasTexture> at = frames->get_frame_texture(edited_anim, right_clicked_frame);
while (at.is_valid() && at->get_atlas().is_valid()) {
path = at->get_atlas()->get_path();
at = at->get_atlas();
}
FileSystemDock::get_singleton()->navigate_to_path(path);
} break;
}
}
void SpriteFramesEditor::_frame_list_item_selected(int p_index, bool p_selected) {
if (updating) {
return;
@ -1464,6 +1616,7 @@ void SpriteFramesEditor::edit(Ref<SpriteFrames> p_frames) {
_zoom_reset();
add_anim->set_disabled(read_only);
duplicate_anim->set_disabled(read_only);
delete_anim->set_disabled(read_only);
anim_speed->set_editable(!read_only);
anim_loop->set_disabled(read_only);
@ -1626,9 +1779,9 @@ void SpriteFramesEditor::_update_stop_icon() {
is_playing = animated_sprite->call("is_playing");
}
if (is_playing) {
stop->set_icon(pause_icon);
stop->set_button_icon(pause_icon);
} else {
stop->set_icon(stop_icon);
stop->set_button_icon(stop_icon);
}
}
@ -1784,12 +1937,17 @@ SpriteFramesEditor::SpriteFramesEditor() {
sub_vb->add_child(hbc_animlist);
add_anim = memnew(Button);
add_anim->set_theme_type_variation("FlatButton");
add_anim->set_theme_type_variation(SceneStringName(FlatButton));
hbc_animlist->add_child(add_anim);
add_anim->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_animation_add));
duplicate_anim = memnew(Button);
duplicate_anim->set_theme_type_variation(SceneStringName(FlatButton));
hbc_animlist->add_child(duplicate_anim);
duplicate_anim->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_animation_duplicate));
delete_anim = memnew(Button);
delete_anim->set_theme_type_variation("FlatButton");
delete_anim->set_theme_type_variation(SceneStringName(FlatButton));
hbc_animlist->add_child(delete_anim);
delete_anim->set_disabled(true);
delete_anim->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_animation_remove));
@ -1800,7 +1958,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
autoplay_container->add_child(memnew(VSeparator));
autoplay = memnew(Button);
autoplay->set_theme_type_variation("FlatButton");
autoplay->set_theme_type_variation(SceneStringName(FlatButton));
autoplay->set_tooltip_text(TTR("Autoplay on Load"));
autoplay_container->add_child(autoplay);
@ -1808,7 +1966,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
anim_loop = memnew(Button);
anim_loop->set_toggle_mode(true);
anim_loop->set_theme_type_variation("FlatButton");
anim_loop->set_theme_type_variation(SceneStringName(FlatButton));
anim_loop->set_tooltip_text(TTR("Animation Looping"));
anim_loop->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_animation_loop_changed));
hbc_animlist->add_child(anim_loop);
@ -1820,6 +1978,8 @@ SpriteFramesEditor::SpriteFramesEditor() {
anim_speed->set_step(0.01);
anim_speed->set_custom_arrow_step(1);
anim_speed->set_tooltip_text(TTR("Animation Speed"));
anim_speed->get_line_edit()->set_expand_to_text_length_enabled(true);
anim_speed->get_line_edit()->connect(SceneStringName(resized), callable_mp(this, &SpriteFramesEditor::_animation_speed_resized));
anim_speed->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_animation_speed_changed));
hbc_animlist->add_child(anim_speed);
@ -1837,12 +1997,15 @@ SpriteFramesEditor::SpriteFramesEditor() {
// HACK: The cell_selected signal is emitted before the FPS spinbox loses focus and applies the change.
animations->connect("cell_selected", callable_mp(this, &SpriteFramesEditor::_animation_selected), CONNECT_DEFERRED);
animations->connect("item_edited", callable_mp(this, &SpriteFramesEditor::_animation_name_edited));
animations->set_theme_type_variation("TreeSecondary");
animations->set_allow_reselect(true);
add_anim->set_shortcut_context(animations);
add_anim->set_shortcut(ED_SHORTCUT("sprite_frames/new_animation", TTR("Add Animation"), KeyModifierMask::CMD_OR_CTRL | Key::N));
add_anim->set_shortcut(ED_SHORTCUT("sprite_frames/new_animation", TTRC("Add Animation"), KeyModifierMask::CMD_OR_CTRL | Key::N));
duplicate_anim->set_shortcut_context(animations);
duplicate_anim->set_shortcut(ED_SHORTCUT("sprite_frames/duplicate_animation", TTRC("Duplicate Animation"), KeyModifierMask::CMD_OR_CTRL | Key::D));
delete_anim->set_shortcut_context(animations);
delete_anim->set_shortcut(ED_SHORTCUT("sprite_frames/delete_animation", TTR("Delete Animation"), Key::KEY_DELETE));
delete_anim->set_shortcut(ED_SHORTCUT("sprite_frames/delete_animation", TTRC("Delete Animation"), Key::KEY_DELETE));
missing_anim_label = memnew(Label);
missing_anim_label->set_text(TTR("This resource does not have any animations."));
@ -1865,34 +2028,35 @@ SpriteFramesEditor::SpriteFramesEditor() {
sub_vb->add_child(hfc);
playback_container = memnew(HBoxContainer);
playback_container->set_layout_direction(LAYOUT_DIRECTION_LTR);
hfc->add_child(playback_container);
play_bw_from = memnew(Button);
play_bw_from->set_theme_type_variation("FlatButton");
play_bw_from->set_theme_type_variation(SceneStringName(FlatButton));
play_bw_from->set_tooltip_text(TTR("Play selected animation backwards from current pos. (A)"));
playback_container->add_child(play_bw_from);
play_bw = memnew(Button);
play_bw->set_theme_type_variation("FlatButton");
play_bw->set_theme_type_variation(SceneStringName(FlatButton));
play_bw->set_tooltip_text(TTR("Play selected animation backwards from end. (Shift+A)"));
playback_container->add_child(play_bw);
stop = memnew(Button);
stop->set_theme_type_variation("FlatButton");
stop->set_theme_type_variation(SceneStringName(FlatButton));
stop->set_tooltip_text(TTR("Pause/stop animation playback. (S)"));
playback_container->add_child(stop);
play = memnew(Button);
play->set_theme_type_variation("FlatButton");
play->set_theme_type_variation(SceneStringName(FlatButton));
play->set_tooltip_text(TTR("Play selected animation from start. (Shift+D)"));
playback_container->add_child(play);
play_from = memnew(Button);
play_from->set_theme_type_variation("FlatButton");
play_from->set_theme_type_variation(SceneStringName(FlatButton));
play_from->set_tooltip_text(TTR("Play selected animation from current pos. (D)"));
playback_container->add_child(play_from);
playback_container->add_child(memnew(VSeparator));
hfc->add_child(memnew(VSeparator));
autoplay->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_autoplay_pressed));
autoplay->set_toggle_mode(true);
@ -1906,45 +2070,45 @@ SpriteFramesEditor::SpriteFramesEditor() {
hfc->add_child(hbc_actions);
load = memnew(Button);
load->set_theme_type_variation("FlatButton");
load->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(load);
load_sheet = memnew(Button);
load_sheet->set_theme_type_variation("FlatButton");
load_sheet->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(load_sheet);
hbc_actions->add_child(memnew(VSeparator));
copy = memnew(Button);
copy->set_theme_type_variation("FlatButton");
copy->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(copy);
paste = memnew(Button);
paste->set_theme_type_variation("FlatButton");
paste->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(paste);
hbc_actions->add_child(memnew(VSeparator));
empty_before = memnew(Button);
empty_before->set_theme_type_variation("FlatButton");
empty_before->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(empty_before);
empty_after = memnew(Button);
empty_after->set_theme_type_variation("FlatButton");
empty_after->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(empty_after);
hbc_actions->add_child(memnew(VSeparator));
move_up = memnew(Button);
move_up->set_theme_type_variation("FlatButton");
move_up->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(move_up);
move_down = memnew(Button);
move_down->set_theme_type_variation("FlatButton");
move_down->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(move_down);
delete_frame = memnew(Button);
delete_frame->set_theme_type_variation("FlatButton");
delete_frame->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(delete_frame);
hbc_actions->add_child(memnew(VSeparator));
@ -1979,19 +2143,19 @@ SpriteFramesEditor::SpriteFramesEditor() {
zoom_out = memnew(Button);
zoom_out->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_zoom_out));
zoom_out->set_flat(true);
zoom_out->set_tooltip_text(TTR("Zoom Out"));
zoom_out->set_tooltip_text(TTRC("Zoom Out"));
hbc_zoom->add_child(zoom_out);
zoom_reset = memnew(Button);
zoom_reset->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_zoom_reset));
zoom_reset->set_flat(true);
zoom_reset->set_tooltip_text(TTR("Zoom Reset"));
zoom_reset->set_tooltip_text(TTRC("Zoom Reset"));
hbc_zoom->add_child(zoom_reset);
zoom_in = memnew(Button);
zoom_in->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_zoom_in));
zoom_in->set_flat(true);
zoom_in->set_tooltip_text(TTR("Zoom In"));
zoom_in->set_tooltip_text(TTRC("Zoom In"));
hbc_zoom->add_child(zoom_in);
file = memnew(EditorFileDialog);
@ -2006,7 +2170,6 @@ SpriteFramesEditor::SpriteFramesEditor() {
frame_list->set_select_mode(ItemList::SELECT_MULTI);
frame_list->set_max_columns(0);
frame_list->set_icon_mode(ItemList::ICON_MODE_TOP);
frame_list->set_max_text_lines(2);
SET_DRAG_FORWARDING_GCD(frame_list, SpriteFramesEditor);
frame_list->connect(SceneStringName(gui_input), callable_mp(this, &SpriteFramesEditor::_frame_list_gui_input));
@ -2029,36 +2192,36 @@ SpriteFramesEditor::SpriteFramesEditor() {
move_down->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_down_pressed));
load->set_shortcut_context(frame_list);
load->set_shortcut(ED_SHORTCUT("sprite_frames/load_from_file", TTR("Add frame from file"), KeyModifierMask::CMD_OR_CTRL | Key::O));
load->set_shortcut(ED_SHORTCUT("sprite_frames/load_from_file", TTRC("Add frame from file"), KeyModifierMask::CMD_OR_CTRL | Key::O));
load_sheet->set_shortcut_context(frame_list);
load_sheet->set_shortcut(ED_SHORTCUT("sprite_frames/load_from_sheet", TTR("Add frames from sprite sheet"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::O));
load_sheet->set_shortcut(ED_SHORTCUT("sprite_frames/load_from_sheet", TTRC("Add frames from sprite sheet"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::O));
delete_frame->set_shortcut_context(frame_list);
delete_frame->set_shortcut(ED_SHORTCUT("sprite_frames/delete", TTR("Delete Frame"), Key::KEY_DELETE));
delete_frame->set_shortcut(ED_SHORTCUT("sprite_frames/delete", TTRC("Delete Frame"), Key::KEY_DELETE));
copy->set_shortcut_context(frame_list);
copy->set_shortcut(ED_SHORTCUT("sprite_frames/copy", TTR("Copy Frame(s)"), KeyModifierMask::CMD_OR_CTRL | Key::C));
copy->set_shortcut(ED_SHORTCUT("sprite_frames/copy", TTRC("Copy Frame(s)"), KeyModifierMask::CMD_OR_CTRL | Key::C));
paste->set_shortcut_context(frame_list);
paste->set_shortcut(ED_SHORTCUT("sprite_frames/paste", TTR("Paste Frame(s)"), KeyModifierMask::CMD_OR_CTRL | Key::V));
paste->set_shortcut(ED_SHORTCUT("sprite_frames/paste", TTRC("Paste Frame(s)"), KeyModifierMask::CMD_OR_CTRL | Key::V));
empty_before->set_shortcut_context(frame_list);
empty_before->set_shortcut(ED_SHORTCUT("sprite_frames/empty_before", TTR("Insert Empty (Before Selected)"), KeyModifierMask::ALT | Key::LEFT));
empty_before->set_shortcut(ED_SHORTCUT("sprite_frames/empty_before", TTRC("Insert Empty (Before Selected)"), KeyModifierMask::ALT | Key::LEFT));
empty_after->set_shortcut_context(frame_list);
empty_after->set_shortcut(ED_SHORTCUT("sprite_frames/empty_after", TTR("Insert Empty (After Selected)"), KeyModifierMask::ALT | Key::RIGHT));
empty_after->set_shortcut(ED_SHORTCUT("sprite_frames/empty_after", TTRC("Insert Empty (After Selected)"), KeyModifierMask::ALT | Key::RIGHT));
move_up->set_shortcut_context(frame_list);
move_up->set_shortcut(ED_SHORTCUT("sprite_frames/move_left", TTR("Move Frame Left"), KeyModifierMask::CMD_OR_CTRL | Key::LEFT));
move_up->set_shortcut(ED_SHORTCUT("sprite_frames/move_left", TTRC("Move Frame Left"), KeyModifierMask::CMD_OR_CTRL | Key::LEFT));
move_down->set_shortcut_context(frame_list);
move_down->set_shortcut(ED_SHORTCUT("sprite_frames/move_right", TTR("Move Frame Right"), KeyModifierMask::CMD_OR_CTRL | Key::RIGHT));
move_down->set_shortcut(ED_SHORTCUT("sprite_frames/move_right", TTRC("Move Frame Right"), KeyModifierMask::CMD_OR_CTRL | Key::RIGHT));
zoom_out->set_shortcut_context(frame_list);
zoom_out->set_shortcut(ED_SHORTCUT_ARRAY("sprite_frames/zoom_out", TTR("Zoom Out"),
zoom_out->set_shortcut(ED_SHORTCUT_ARRAY("sprite_frames/zoom_out", TTRC("Zoom Out"),
{ int32_t(KeyModifierMask::CMD_OR_CTRL | Key::MINUS), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::KP_SUBTRACT) }));
zoom_in->set_shortcut_context(frame_list);
zoom_in->set_shortcut(ED_SHORTCUT_ARRAY("sprite_frames/zoom_in", TTR("Zoom In"),
zoom_in->set_shortcut(ED_SHORTCUT_ARRAY("sprite_frames/zoom_in", TTRC("Zoom In"),
{ int32_t(KeyModifierMask::CMD_OR_CTRL | Key::EQUAL), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::KP_ADD) }));
loading_scene = false;
updating = false;
edited_anim = "default";
edited_anim = SceneStringName(default_);
delete_dialog = memnew(ConfirmationDialog);
add_child(delete_dialog);
@ -2112,7 +2275,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
toggle_settings_button = memnew(Button);
toggle_settings_button->set_h_size_flags(SIZE_SHRINK_END);
toggle_settings_button->set_theme_type_variation("FlatButton");
toggle_settings_button->set_theme_type_variation(SceneStringName(FlatButton));
toggle_settings_button->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_toggle_show_settings));
toggle_settings_button->set_tooltip_text(TTR("Toggle Settings Panel"));
split_sheet_menu_hb->add_child(toggle_settings_button);
@ -2150,21 +2313,21 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_zoom_margin->add_child(split_sheet_zoom_hb);
split_sheet_zoom_out = memnew(Button);
split_sheet_zoom_out->set_theme_type_variation("FlatButton");
split_sheet_zoom_out->set_theme_type_variation(SceneStringName(FlatButton));
split_sheet_zoom_out->set_focus_mode(FOCUS_NONE);
split_sheet_zoom_out->set_tooltip_text(TTR("Zoom Out"));
split_sheet_zoom_out->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_sheet_zoom_out));
split_sheet_zoom_hb->add_child(split_sheet_zoom_out);
split_sheet_zoom_reset = memnew(Button);
split_sheet_zoom_reset->set_theme_type_variation("FlatButton");
split_sheet_zoom_reset->set_theme_type_variation(SceneStringName(FlatButton));
split_sheet_zoom_reset->set_focus_mode(FOCUS_NONE);
split_sheet_zoom_reset->set_tooltip_text(TTR("Zoom Reset"));
split_sheet_zoom_reset->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_sheet_zoom_reset));
split_sheet_zoom_hb->add_child(split_sheet_zoom_reset);
split_sheet_zoom_in = memnew(Button);
split_sheet_zoom_in->set_theme_type_variation("FlatButton");
split_sheet_zoom_in->set_theme_type_variation(SceneStringName(FlatButton));
split_sheet_zoom_in->set_focus_mode(FOCUS_NONE);
split_sheet_zoom_in->set_tooltip_text(TTR("Zoom In"));
split_sheet_zoom_in->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_sheet_zoom_in));
@ -2290,6 +2453,11 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_offset_hb->add_child(split_sheet_offset_vb);
split_sheet_settings_vb->add_child(split_sheet_offset_hb);
Button *auto_slice = memnew(Button);
auto_slice->set_text(TTR("Auto Slice"));
auto_slice->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_auto_slice_sprite_sheet));
split_sheet_settings_vb->add_child(auto_slice);
split_sheet_hb->add_child(split_sheet_settings_vb);
file_split_sheet = memnew(EditorFileDialog);
@ -2363,7 +2531,7 @@ void SpriteFramesEditorPlugin::make_visible(bool p_visible) {
SpriteFramesEditorPlugin::SpriteFramesEditorPlugin() {
frames_editor = memnew(SpriteFramesEditor);
frames_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
button = EditorNode::get_bottom_panel()->add_item(TTR("SpriteFrames"), frames_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_sprite_frames_bottom_panel", TTR("Toggle SpriteFrames Bottom Panel")));
button = EditorNode::get_bottom_panel()->add_item(TTR("SpriteFrames"), frames_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_sprite_frames_bottom_panel", TTRC("Toggle SpriteFrames Bottom Panel")));
button->hide();
}