feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -131,7 +131,7 @@ void SpriteFramesEditor::_sheet_preview_draw() {
}
_draw_shadowed_line(split_sheet_preview, draw_offset + Vector2(0, draw_size.y), Vector2(draw_size.x, 0), Vector2(0, 1), line_color, shadow_color);
if (frames_selected.size() == 0) {
if (frames_selected.is_empty()) {
split_sheet_dialog->get_ok_button()->set_disabled(true);
split_sheet_dialog->set_ok_button_text(TTR("No Frames Selected"));
return;
@ -183,7 +183,7 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) {
const int from = last_frame_selected;
const int to = idx;
const int diff = ABS(to - from);
const int diff = Math::abs(to - from);
const int dir = SIGN(to - from);
for (int i = 0; i <= diff; i++) {
@ -672,6 +672,11 @@ void SpriteFramesEditor::_notification(int p_what) {
_update_show_settings();
} break;
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
case NOTIFICATION_TRANSLATION_CHANGED: {
_update_show_settings();
} break;
case NOTIFICATION_READY: {
add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up.
} break;
@ -1099,7 +1104,7 @@ void SpriteFramesEditor::_animation_name_edited() {
new_name = "new_animation";
}
new_name = new_name.replace("/", "_").replace(",", " ");
new_name = new_name.replace_char('/', '_').replace_char(',', ' ');
String name = new_name;
int counter = 0;
@ -1289,6 +1294,10 @@ void SpriteFramesEditor::_animation_speed_resized() {
}
void SpriteFramesEditor::_animation_speed_changed(double p_value) {
if (frames.is_null()) {
return;
}
if (updating) {
return;
}
@ -1326,7 +1335,7 @@ void SpriteFramesEditor::_frame_list_gui_input(const Ref<InputEvent> &p_event) {
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->add_icon_item(get_editor_theme_icon(SNAME("ShowInFileSystem")), TTRC("Show in FileSystem"), MENU_SHOW_IN_FILESYSTEM);
}
menu->set_position(get_screen_position() + get_local_mouse_position());
@ -1336,12 +1345,14 @@ void SpriteFramesEditor::_frame_list_gui_input(const Ref<InputEvent> &p_event) {
}
}
void SpriteFramesEditor::_menu_selected(int p_index) {
switch (p_index) {
void SpriteFramesEditor::_menu_selected(int p_id) {
switch (p_id) {
case MENU_SHOW_IN_FILESYSTEM: {
String path = frames->get_frame_texture(edited_anim, right_clicked_frame)->get_path();
Ref<Texture2D> frame_texture = frames->get_frame_texture(edited_anim, right_clicked_frame);
ERR_FAIL_COND(frame_texture.is_null());
String path = frame_texture->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);
Ref<AtlasTexture> at = frame_texture;
while (at.is_valid() && at->get_atlas().is_valid()) {
path = at->get_atlas()->get_path();
at = at->get_atlas();
@ -1367,6 +1378,10 @@ void SpriteFramesEditor::_frame_list_item_selected(int p_index, bool p_selected)
}
void SpriteFramesEditor::_frame_duration_changed(double p_value) {
if (frames.is_null()) {
return;
}
if (updating) {
return;
}
@ -1646,7 +1661,14 @@ Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
return false;
}
int idx = frame_list->get_item_at_position(p_point, true);
int idx = -1;
if (p_point == Vector2(Math::INF, Math::INF)) {
if (frame_list->is_anything_selected()) {
idx = frame_list->get_selected_items()[0];
}
} else {
idx = frame_list->get_item_at_position(p_point, true);
}
if (idx < 0 || idx >= frames->get_frame_count(edited_anim)) {
return Variant();
@ -1692,7 +1714,7 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
if (String(d["type"]) == "files") {
Vector<String> files = d["files"];
if (files.size() == 0) {
if (files.is_empty()) {
return false;
}
@ -1721,7 +1743,14 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
return;
}
int at_pos = frame_list->get_item_at_position(p_point, true);
int at_pos = -1;
if (p_point == Vector2(Math::INF, Math::INF)) {
if (frame_list->is_anything_selected()) {
at_pos = frame_list->get_selected_items()[0];
}
} else {
at_pos = frame_list->get_item_at_position(p_point, true);
}
if (String(d["type"]) == "resource" && d.has("resource")) {
Ref<Resource> r = d["resource"];
@ -1804,8 +1833,9 @@ void SpriteFramesEditor::_remove_sprite_node() {
void SpriteFramesEditor::_fetch_sprite_node() {
Node *selected = nullptr;
EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection();
if (editor_selection->get_selected_node_list().size() == 1) {
selected = editor_selection->get_selected_node_list().front()->get();
const List<Node *> &top_node_list = editor_selection->get_top_selected_node_list();
if (top_node_list.size() == 1) {
selected = top_node_list.front()->get();
}
bool show_node_edit = false;
@ -1938,16 +1968,19 @@ SpriteFramesEditor::SpriteFramesEditor() {
add_anim = memnew(Button);
add_anim->set_theme_type_variation(SceneStringName(FlatButton));
add_anim->set_accessibility_name(TTRC("Add Animation"));
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));
duplicate_anim->set_accessibility_name(TTRC("Duplicate Animation"));
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(SceneStringName(FlatButton));
delete_anim->set_accessibility_name(TTRC("Delete Animation"));
hbc_animlist->add_child(delete_anim);
delete_anim->set_disabled(true);
delete_anim->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_animation_remove));
@ -1959,6 +1992,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
autoplay = memnew(Button);
autoplay->set_theme_type_variation(SceneStringName(FlatButton));
autoplay->set_accessibility_name(TTRC("Autoplay on Load"));
autoplay->set_tooltip_text(TTR("Autoplay on Load"));
autoplay_container->add_child(autoplay);
@ -1967,6 +2001,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
anim_loop = memnew(Button);
anim_loop->set_toggle_mode(true);
anim_loop->set_theme_type_variation(SceneStringName(FlatButton));
anim_loop->set_accessibility_name(TTRC("Animation Looping"));
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);
@ -1978,6 +2013,7 @@ 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->set_accessibility_name(TTRC("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));
@ -1987,6 +2023,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
sub_vb->add_child(anim_search_box);
anim_search_box->set_h_size_flags(SIZE_EXPAND_FILL);
anim_search_box->set_placeholder(TTR("Filter Animations"));
anim_search_box->set_accessibility_name(TTRC("Filter Animations"));
anim_search_box->set_clear_button_enabled(true);
anim_search_box->connect(SceneStringName(text_changed), callable_mp(this, &SpriteFramesEditor::_animation_search_text_changed));
@ -2034,26 +2071,31 @@ SpriteFramesEditor::SpriteFramesEditor() {
play_bw_from = memnew(Button);
play_bw_from->set_theme_type_variation(SceneStringName(FlatButton));
play_bw_from->set_tooltip_text(TTR("Play selected animation backwards from current pos. (A)"));
play_bw_from->set_accessibility_name(TTRC("Play Backwards"));
playback_container->add_child(play_bw_from);
play_bw = memnew(Button);
play_bw->set_theme_type_variation(SceneStringName(FlatButton));
play_bw->set_tooltip_text(TTR("Play selected animation backwards from end. (Shift+A)"));
play_bw->set_accessibility_name(TTRC("Play Backwards from End"));
playback_container->add_child(play_bw);
stop = memnew(Button);
stop->set_theme_type_variation(SceneStringName(FlatButton));
stop->set_tooltip_text(TTR("Pause/stop animation playback. (S)"));
stop->set_accessibility_name(TTRC("Pause/Stop"));
playback_container->add_child(stop);
play = memnew(Button);
play->set_theme_type_variation(SceneStringName(FlatButton));
play->set_tooltip_text(TTR("Play selected animation from start. (Shift+D)"));
play->set_accessibility_name(TTRC("Play from Start"));
playback_container->add_child(play);
play_from = memnew(Button);
play_from->set_theme_type_variation(SceneStringName(FlatButton));
play_from->set_tooltip_text(TTR("Play selected animation from current pos. (D)"));
play_from->set_accessibility_name(TTRC("Play"));
playback_container->add_child(play_from);
hfc->add_child(memnew(VSeparator));
@ -2070,44 +2112,53 @@ SpriteFramesEditor::SpriteFramesEditor() {
hfc->add_child(hbc_actions);
load = memnew(Button);
load->set_accessibility_name(TTRC("Load"));
load->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(load);
load_sheet = memnew(Button);
load_sheet->set_accessibility_name(TTRC("Load Sheet"));
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_accessibility_name(TTRC("Copy"));
copy->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(copy);
paste = memnew(Button);
paste->set_accessibility_name(TTRC("Paste"));
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_accessibility_name(TTRC("Empty Before"));
empty_before->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(empty_before);
empty_after = memnew(Button);
empty_after->set_accessibility_name(TTRC("Empty After"));
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_accessibility_name(TTRC("Move Up"));
move_up->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(move_up);
move_down = memnew(Button);
move_down->set_accessibility_name(TTRC("Move Down"));
move_down->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(move_down);
delete_frame = memnew(Button);
delete_frame->set_accessibility_name(TTRC("Delete Frame"));
delete_frame->set_theme_type_variation(SceneStringName(FlatButton));
hbc_actions->add_child(delete_frame);
@ -2129,6 +2180,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
frame_duration->set_allow_lesser(false);
frame_duration->set_allow_greater(true);
frame_duration->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_frame_duration_changed));
frame_duration->set_accessibility_name(TTRC("Frame Duration"));
hbc_frame_duration->add_child(frame_duration);
// Wide empty separation control. (like BoxContainer::add_spacer())
@ -2144,18 +2196,21 @@ SpriteFramesEditor::SpriteFramesEditor() {
zoom_out->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_zoom_out));
zoom_out->set_flat(true);
zoom_out->set_tooltip_text(TTRC("Zoom Out"));
zoom_out->set_accessibility_name(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(TTRC("Zoom Reset"));
zoom_reset->set_accessibility_name(TTRC("Reset Zoom"));
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(TTRC("Zoom In"));
zoom_in->set_accessibility_name(TTRC("Zoom In"));
hbc_zoom->add_child(zoom_in);
file = memnew(EditorFileDialog);
@ -2278,6 +2333,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
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"));
toggle_settings_button->set_accessibility_name(TTRC("Settings Panel"));
split_sheet_menu_hb->add_child(toggle_settings_button);
split_sheet_vb->add_child(split_sheet_menu_hb);
@ -2316,6 +2372,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
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->set_accessibility_name(TTRC("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);
@ -2323,6 +2380,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
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->set_accessibility_name(TTRC("Reset Zoom"));
split_sheet_zoom_reset->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_sheet_zoom_reset));
split_sheet_zoom_hb->add_child(split_sheet_zoom_reset);
@ -2330,6 +2388,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
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->set_accessibility_name(TTRC("Zoom In"));
split_sheet_zoom_in->connect(SceneStringName(pressed), callable_mp(this, &SpriteFramesEditor::_sheet_zoom_in));
split_sheet_zoom_hb->add_child(split_sheet_zoom_in);
@ -2349,6 +2408,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_h->set_max(128);
split_sheet_h->set_step(1);
split_sheet_h->set_select_all_on_focus(true);
split_sheet_h->set_accessibility_name(TTRC("Horizontal"));
split_sheet_h_hb->add_child(split_sheet_h);
split_sheet_h->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_FRAME_COUNT));
split_sheet_settings_vb->add_child(split_sheet_h_hb);
@ -2366,6 +2426,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_v->set_max(128);
split_sheet_v->set_step(1);
split_sheet_v->set_select_all_on_focus(true);
split_sheet_v->set_accessibility_name(TTRC("Vertical"));
split_sheet_v_hb->add_child(split_sheet_v);
split_sheet_v->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_FRAME_COUNT));
split_sheet_settings_vb->add_child(split_sheet_v_hb);
@ -2386,6 +2447,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_size_x->set_step(1);
split_sheet_size_x->set_suffix("px");
split_sheet_size_x->set_select_all_on_focus(true);
split_sheet_size_x->set_accessibility_name(TTRC("X Size"));
split_sheet_size_x->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_SIZE));
split_sheet_size_vb->add_child(split_sheet_size_x);
split_sheet_size_y = memnew(SpinBox);
@ -2394,6 +2456,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_size_y->set_step(1);
split_sheet_size_y->set_suffix("px");
split_sheet_size_y->set_select_all_on_focus(true);
split_sheet_size_y->set_accessibility_name(TTRC("Y Size"));
split_sheet_size_y->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_SIZE));
split_sheet_size_vb->add_child(split_sheet_size_y);
split_sheet_size_hb->add_child(split_sheet_size_vb);
@ -2414,6 +2477,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_sep_x->set_step(1);
split_sheet_sep_x->set_suffix("px");
split_sheet_sep_x->set_select_all_on_focus(true);
split_sheet_sep_x->set_accessibility_name(TTRC("X Separation"));
split_sheet_sep_x->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_USE_CURRENT));
split_sheet_sep_vb->add_child(split_sheet_sep_x);
split_sheet_sep_y = memnew(SpinBox);
@ -2421,6 +2485,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_sep_y->set_step(1);
split_sheet_sep_y->set_suffix("px");
split_sheet_sep_y->set_select_all_on_focus(true);
split_sheet_sep_y->set_accessibility_name(TTRC("Y Separation"));
split_sheet_sep_y->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_USE_CURRENT));
split_sheet_sep_vb->add_child(split_sheet_sep_y);
split_sheet_sep_hb->add_child(split_sheet_sep_vb);
@ -2441,6 +2506,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_offset_x->set_step(1);
split_sheet_offset_x->set_suffix("px");
split_sheet_offset_x->set_select_all_on_focus(true);
split_sheet_offset_x->set_accessibility_name(TTRC("X Offset"));
split_sheet_offset_x->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_USE_CURRENT));
split_sheet_offset_vb->add_child(split_sheet_offset_x);
split_sheet_offset_y = memnew(SpinBox);
@ -2448,6 +2514,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
split_sheet_offset_y->set_step(1);
split_sheet_offset_y->set_suffix("px");
split_sheet_offset_y->set_select_all_on_focus(true);
split_sheet_offset_y->set_accessibility_name(TTRC("Y Offset"));
split_sheet_offset_y->connect(SceneStringName(value_changed), callable_mp(this, &SpriteFramesEditor::_sheet_spin_changed).bind(PARAM_USE_CURRENT));
split_sheet_offset_vb->add_child(split_sheet_offset_y);
split_sheet_offset_hb->add_child(split_sheet_offset_vb);
@ -2534,6 +2601,3 @@ SpriteFramesEditorPlugin::SpriteFramesEditorPlugin() {
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();
}
SpriteFramesEditorPlugin::~SpriteFramesEditorPlugin() {
}