diff options
Diffstat (limited to 'editor')
39 files changed, 616 insertions, 284 deletions
diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 16606b5d12..447f57a73f 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -1724,7 +1724,7 @@ bool AnimationKeyEditor::_edit_if_single_selection() { curve_edit->set_transition(animation->track_get_key_transition(idx, key)); /*key_edit_dialog->set_size( Size2( 200,200) ); - key_edit_dialog->set_pos( track_editor->get_global_pos() + ofs + mpos +Point2(-100,20)); + key_edit_dialog->set_position( track_editor->get_global_position() + ofs + mpos +Point2(-100,20)); key_edit_dialog->popup();*/ } @@ -1983,7 +1983,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent &p_input) { track_menu->add_item(TTR("Duplicate Transposed"), RIGHT_MENU_DUPLICATE_TRANSPOSE); track_menu->add_item(TTR("Remove Selection"), RIGHT_MENU_REMOVE); - track_menu->set_pos(te->get_global_pos() + mpos); + track_menu->set_position(te->get_global_position() + mpos); interp_editing = -1; cont_editing = -1; @@ -2064,7 +2064,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent &p_input) { Rect2 area(ofs.x, ofs.y + ((int(mpos.y) / h) + 1) * h, name_limit, h); track_name->set_text(animation->track_get_path(idx)); - track_name->set_pos(te->get_global_pos() + area.pos); + track_name->set_position(te->get_global_position() + area.pos); track_name->set_size(area.size); track_name->show_modal(); track_name->grab_focus(); @@ -2214,7 +2214,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent &p_input) { int popup_y = ofs.y + ((int(mpos.y) / h) + 2) * h; int popup_x = size.width - track_ofs[1]; - track_menu->set_pos(te->get_global_pos() + Point2(popup_x, popup_y)); + track_menu->set_position(te->get_global_position() + Point2(popup_x, popup_y)); wrap_editing = idx; interp_editing = -1; @@ -2237,7 +2237,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent &p_input) { int popup_y = ofs.y + ((int(mpos.y) / h) + 2) * h; int popup_x = size.width - track_ofs[2]; - track_menu->set_pos(te->get_global_pos() + Point2(popup_x, popup_y)); + track_menu->set_position(te->get_global_position() + Point2(popup_x, popup_y)); interp_editing = idx; cont_editing = -1; @@ -2260,7 +2260,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent &p_input) { int popup_y = ofs.y + ((int(mpos.y) / h) + 2) * h; int popup_x = size.width - track_ofs[3]; - track_menu->set_pos(te->get_global_pos() + Point2(popup_x, popup_y)); + track_menu->set_position(te->get_global_position() + Point2(popup_x, popup_y)); interp_editing = -1; wrap_editing = -1; @@ -2309,7 +2309,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const InputEvent &p_input) { cvi_track = idx; cvi_pos = pos; - type_menu->set_pos(get_global_pos() + mpos + ofs); + type_menu->set_position(get_global_position() + mpos + ofs); type_menu->popup(); return; } @@ -3749,7 +3749,7 @@ AnimationKeyEditor::AnimationKeyEditor() { root = NULL; //menu = memnew( MenuButton ); //menu->set_flat(true); - //menu->set_pos(Point2()); + //menu->set_position(Point2()); //add_child(menu); zoomicon = memnew(TextureRect); @@ -3891,7 +3891,7 @@ AnimationKeyEditor::AnimationKeyEditor() { /* l = memnew( Label ); l->set_text("Base: "); - l->set_pos(Point2(0,3)); + l->set_position(Point2(0,3)); //dr_panel->add_child(l);*/ //menu->get_popup()->connect("id_pressed",this,"_menu_callback"); diff --git a/editor/call_dialog.cpp b/editor/call_dialog.cpp index d2b46863b0..8cf9ed6ef4 100644 --- a/editor/call_dialog.cpp +++ b/editor/call_dialog.cpp @@ -290,8 +290,8 @@ CallDialog::CallDialog() { property_editor->hide_top_label(); add_child(property_editor); - method_label = memnew( Label ); - method_label->set_pos( Point2( 15,25) ); + method_label = memnew(Label); + method_label->set_position(Point2( 15,25)); method_label->set_text(TTR("Method List:")); add_child(method_label); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index cc20912612..4ec2a3c391 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -64,7 +64,7 @@ GotoLineDialog::GotoLineDialog() { set_title(TTR("Go to Line")); Label *l = memnew(Label); l->set_text(TTR("Line Number:")); - l->set_pos(Point2(5, 5)); + l->set_position(Point2(5, 5)); add_child(l); line = memnew(LineEdit); @@ -1071,7 +1071,8 @@ void CodeTextEditor::update_editor_settings() { text_editor->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete")); text_editor->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file")); - text_editor->set_tab_size(EditorSettings::get_singleton()->get("text_editor/indent/tab_size")); + text_editor->set_indent_using_spaces(EditorSettings::get_singleton()->get("text_editor/indent/type") == "Tabs" ? 0 : 1); + text_editor->set_indent_size(EditorSettings::get_singleton()->get("text_editor/indent/size")); text_editor->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs")); text_editor->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_numbers")); text_editor->set_line_numbers_zero_padded(EditorSettings::get_singleton()->get("text_editor/line_numbers/line_numbers_zero_padded")); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 67d9977149..6ef32a6afd 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -342,7 +342,7 @@ void EditorAudioBus::_effect_edited() { if (effect->get_metadata(0) == Variant()) { Rect2 area = effects->get_item_rect(effect); - effect_options->set_pos(effects->get_global_pos() + area.pos + Vector2(0, area.size.y)); + effect_options->set_position(effects->get_global_position() + area.pos + Vector2(0, area.size.y)); effect_options->popup(); //add effect } else { @@ -394,7 +394,7 @@ void EditorAudioBus::_gui_input(const InputEvent &p_event) { if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index == 2 && p_event.mouse_button.pressed) { Vector2 pos = Vector2(p_event.mouse_button.x, p_event.mouse_button.y); - delete_popup->set_pos(get_global_pos() + pos); + delete_popup->set_position(get_global_position() + pos); delete_popup->popup(); } } @@ -420,7 +420,7 @@ Variant EditorAudioBus::get_drag_data(const Point2 &p_point) { c->add_child(p); p->add_style_override("panel", get_stylebox("focus", "Button")); p->set_size(get_size()); - p->set_pos(-p_point); + p->set_position(-p_point); set_drag_preview(c); Dictionary d; d["type"] = "move_audio_bus"; @@ -576,7 +576,7 @@ void EditorAudioBus::_effect_rmb(const Vector2 &p_pos) { if (item->get_metadata(0).get_type() != Variant::INT) return; - delete_effect_popup->set_pos(get_global_mouse_pos()); + delete_effect_popup->set_position(get_global_mouse_position()); delete_effect_popup->popup(); } diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 2612a2af16..3fb2923696 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -487,6 +487,22 @@ bool EditorFileSystem::_check_missing_imported_files(const String &p_path) { return true; } +static bool _find_project(const String &p_path) { + DirAccess *dir_access = DirAccess::create_for_path(p_path); + bool ret = false; + while (true) { + bool is_dir; + String file = dir_access->get_next(&is_dir); + if (file == "") + break; + if (file.ends_with(".godot")) { + ret = true; + } + } + memdelete(dir_access); + return ret; +} + void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess *da, const ScanProgress &p_progress) { List<String> dirs; @@ -509,8 +525,9 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess if (f.begins_with(".")) //ignore hidden and . / .. continue; - if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this + if (_find_project(cd.plus_file(f))) { continue; + } dirs.push_back(f); @@ -676,34 +693,35 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const while (true) { bool isdir; - String f = da->get_next(&isdir); - if (f == "") + String file = da->get_next(&isdir); + if (file == "") break; if (isdir) { - if (f.begins_with(".")) //ignore hidden and . / .. + if (file.begins_with(".")) //ignore hidden and . / .. continue; - int idx = p_dir->find_dir_index(f); + int idx = p_dir->find_dir_index(file); if (idx == -1) { - if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this + if (_find_project(cd.plus_file(file))) { continue; + } EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory); efd->parent = p_dir; - efd->name = f; + efd->name = file; DirAccess *d = DirAccess::create(DirAccess::ACCESS_RESOURCES); - d->change_dir(cd.plus_file(f)); + d->change_dir(cd.plus_file(file)); _scan_new_dir(efd, d, p_progress.get_sub(1, 1)); memdelete(d); ItemAction ia; ia.action = ItemAction::ACTION_DIR_ADD; ia.dir = p_dir; - ia.file = f; + ia.file = file; ia.new_dir = efd; scan_actions.push_back(ia); } else { @@ -711,16 +729,16 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const } } else { - String ext = f.get_extension().to_lower(); + String ext = file.get_extension().to_lower(); if (!valid_extensions.has(ext)) continue; //invalid - int idx = p_dir->find_file_index(f); + int idx = p_dir->find_file_index(file); if (idx == -1) { //never seen this file, add actition to add it EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo); - fi->file = f; + fi->file = file; String path = cd.plus_file(fi->file); fi->modified_time = FileAccess::get_modified_time(path); @@ -731,7 +749,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const ItemAction ia; ia.action = ItemAction::ACTION_FILE_ADD; ia.dir = p_dir; - ia.file = f; + ia.file = file; ia.new_file = fi; scan_actions.push_back(ia); } @@ -739,14 +757,14 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const if (import_extensions.has(ext)) { //if it can be imported, and it was added, it needs to be reimported print_line("REIMPORT: file was not found before, reimport"); - print_line("at dir: " + p_dir->get_path() + " file: " + f); + print_line("at dir: " + p_dir->get_path() + " file: " + file); for (int i = 0; i < p_dir->files.size(); i++) { print_line(itos(i) + ": " + p_dir->files[i]->file); } ItemAction ia; ia.action = ItemAction::ACTION_FILE_REIMPORT; ia.dir = p_dir; - ia.file = f; + ia.file = file; scan_actions.push_back(ia); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 1bd91d753f..cc7ee44902 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -236,7 +236,7 @@ void EditorNode::_notification(int p_what) { Rect2 grect = scene_root_base->get_global_rect(); Rect2 grectsrp = scene_root_parent->get_global_rect(); if (grect!=grectsrp) { - scene_root_parent->set_pos(grect.pos); + scene_root_parent->set_position(grect.pos); scene_root_parent->set_size(grect.size); } } @@ -447,18 +447,6 @@ void EditorNode::_sources_changed(bool p_exist) { void EditorNode::_vp_resized() { } -void EditorNode::_rebuild_import_menu() { - PopupMenu *p = import_menu->get_popup(); - p->clear(); -//p->add_item(TTR("Node From Scene"), FILE_IMPORT_SUBSCENE); -//p->add_separator(); -#if 0 - for (int i = 0; i < editor_import_export->get_import_plugin_count(); i++) { - p->add_item(editor_import_export->get_import_plugin(i)->get_visible_name(), IMPORT_PLUGIN_BASE + i); - } -#endif -} - void EditorNode::_node_renamed() { if (property_editor) @@ -2815,7 +2803,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled) } if (!script->is_tool()) { - show_warning("Unable to load addon script from path: '" + path + "' Script is does not support tool mode."); + show_warning("Unable to load addon script from path: '" + path + "' Script is not in tool mode."); return; } @@ -4469,7 +4457,7 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { p_from->set_drag_preview(drag_control); //wait until it enters scene - label->set_pos(Point2((preview->get_width() - label->get_minimum_size().width) / 2, preview->get_height())); + label->set_position(Point2((preview->get_width() - label->get_minimum_size().width) / 2, preview->get_height())); Dictionary drag_data; drag_data["type"] = "resource"; @@ -5152,7 +5140,7 @@ EditorNode::EditorNode() { //left_menu_hb->add_child( prev_scene ); prev_scene->connect("pressed", this, "_menu_option", make_binds(FILE_OPEN_PREV)); gui_base->add_child(prev_scene); - prev_scene->set_pos(Point2(3, 24)); + prev_scene->set_position(Point2(3, 24)); prev_scene->hide(); ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD + KEY_TAB); @@ -5232,7 +5220,7 @@ EditorNode::EditorNode() { #if 0 node_menu = memnew( MenuButton ); node_menu->set_text("Node"); - node_menu->set_pos( Point2( 50,0) ); + node_menu->set_position( Point2( 50,0) ); menu_panel->add_child( node_menu ); p=node_menu->get_popup(); @@ -5253,19 +5241,10 @@ EditorNode::EditorNode() { resource_menu = memnew( MenuButton ); resource_menu->set_text("Resource"); - resource_menu->set_pos( Point2( 90,0) ); + resource_menu->set_position( Point2( 90,0) ); menu_panel->add_child( resource_menu ); #endif - import_menu = memnew(MenuButton); - import_menu->set_tooltip(TTR("Import assets to the project.")); - import_menu->set_text(TTR("Import")); - //import_menu->set_icon(gui_base->get_icon("Save","EditorIcons")); - left_menu_hb->add_child(import_menu); - - p = import_menu->get_popup(); - p->connect("id_pressed", this, "_menu_option"); - tool_menu = memnew(MenuButton); tool_menu->set_tooltip(TTR("Miscellaneous project or scene-wide tools.")); tool_menu->set_text(TTR("Tools")); @@ -5288,7 +5267,7 @@ EditorNode::EditorNode() { //Separator *s1 = memnew( VSeparator ); //menu_panel->add_child(s1); - //s1->set_pos(Point2(210,4)); + //s1->set_position(Point2(210,4)); //s1->set_size(Point2(10,15)); play_cc = memnew(CenterContainer); @@ -5403,7 +5382,7 @@ EditorNode::EditorNode() { /* run_settings_button = memnew( ToolButton ); menu_panel->add_child(run_settings_button); - run_settings_button->set_pos(Point2(305,0)); + run_settings_button->set_position(Point2(305,0)); run_settings_button->set_focus_mode(Control::FOCUS_NONE); run_settings_button->set_icon(gui_base->get_icon("Run","EditorIcons")); run_settings_button->connect("pressed", this,"_menu_option",make_binds(RUN_SETTINGS)); @@ -5496,7 +5475,7 @@ EditorNode::EditorNode() { /* Separator *s2 = memnew( VSeparator ); menu_panel->add_child(s2); - s2->set_pos(Point2(338,4)); + s2->set_position(Point2(338,4)); s2->set_size(Point2(10,15)); */ @@ -5728,7 +5707,7 @@ EditorNode::EditorNode() { /* animation_menu = memnew( ToolButton ); - animation_menu->set_pos(Point2(500,0)); + animation_menu->set_position(Point2(500,0)); animation_menu->set_size(Size2(20,20)); animation_menu->set_toggle_mode(true); animation_menu->set_focus_mode(Control::FOCUS_NONE); @@ -5960,8 +5939,6 @@ EditorNode::EditorNode() { circle_step_frame = Engine::get_singleton()->get_frames_drawn(); circle_step = 0; - _rebuild_import_menu(); - editor_plugin_screen = NULL; editor_plugins_over = memnew(EditorPluginList); diff --git a/editor/editor_node.h b/editor/editor_node.h index e7f4085fc5..7de713eae9 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -242,7 +242,6 @@ private: HBoxContainer *menu_hb; Control *viewport; MenuButton *file_menu; - MenuButton *import_menu; MenuButton *tool_menu; ToolButton *export_button; ToolButton *prev_scene; @@ -447,8 +446,6 @@ private: void _show_messages(); void _vp_resized(); - void _rebuild_import_menu(); - void _save_scene(String p_file, int idx = -1); void _instance_request(const Vector<String> &p_files); diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index 33dc30fb73..98e0808ba5 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -80,7 +80,7 @@ void EditorPath::_gui_input(const InputEvent &p_event) { objects.clear(); popup->clear(); _add_children_to_popup(obj); - popup->set_pos(get_global_pos() + Vector2(0, get_size().height)); + popup->set_position(get_global_position() + Vector2(0, get_size().height)); popup->set_size(Size2(get_size().width, 1)); popup->popup(); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 8ea5d16bbf..35373eb815 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -506,7 +506,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("interface/dim_editor_on_dialog_popup", true); set("interface/dim_amount", 0.6f); hints["interface/dim_amount"] = PropertyInfo(Variant::REAL, "interface/dim_amount", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_DEFAULT); - set("interface/dim_transition_time", 0.11f); + set("interface/dim_transition_time", 0.08f); hints["interface/dim_transition_time"] = PropertyInfo(Variant::REAL, "interface/dim_transition_time", PROPERTY_HINT_RANGE, "0,1,0.001", PROPERTY_USAGE_DEFAULT); set("filesystem/directories/autoscan_project_path", ""); @@ -529,8 +529,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("text_editor/highlighting/highlight_all_occurrences", true); set("text_editor/cursor/scroll_past_end_of_file", false); - set("text_editor/indent/tab_size", 4); - hints["text_editor/indent/tab_size"] = PropertyInfo(Variant::INT, "text_editor/indent/tab_size", PROPERTY_HINT_RANGE, "1, 64, 1"); // size of 0 crashes. + set("text_editor/indent/type", 0); + hints["text_editor/indent/type"] = PropertyInfo(Variant::STRING, "text_editor/indent/type", PROPERTY_HINT_ENUM, "Tabs,Spaces"); + set("text_editor/indent/size", 4); + hints["text_editor/indent/size"] = PropertyInfo(Variant::INT, "text_editor/indent/size", PROPERTY_HINT_RANGE, "1, 64, 1"); // size of 0 crashes. + set("text_editor/indent/convert_indent_on_save", false); set("text_editor/indent/draw_tabs", true); set("text_editor/line_numbers/show_line_numbers", true); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 79bce2c150..9d10117418 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1102,7 +1102,7 @@ void FileSystemDock::_dir_rmb_pressed(const Vector2 &p_pos) { folder_options->add_item(TTR("Expand all"), FOLDER_EXPAND_ALL); folder_options->add_item(TTR("Collapse all"), FOLDER_COLLAPSE_ALL); - folder_options->set_pos(tree->get_global_pos() + p_pos); + folder_options->set_position(tree->get_global_position() + p_pos); folder_options->popup(); } @@ -1526,7 +1526,7 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) { */ } - file_options->set_pos(files->get_global_pos() + p_pos); + file_options->set_position(files->get_global_position() + p_pos); file_options->popup(); } diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index c79bdef71d..0be7b202a8 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -87,7 +87,7 @@ void AnimationPlayerEditor::_notification(int p_what) { } last_active = player->is_playing(); - //seek->set_val(player->get_pos()); + //seek->set_val(player->get_position()); updating = false; } @@ -1386,13 +1386,13 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { add_child(name_dialog); name = memnew(LineEdit); name_dialog->add_child(name); - name->set_pos(Point2(18, 30)); + name->set_position(Point2(18, 30)); name->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 10); name_dialog->register_text_enter(name); l = memnew(Label); l->set_text(TTR("Animation Name:")); - l->set_pos(Point2(10, 10)); + l->set_position(Point2(10, 10)); name_dialog->add_child(l); name_title = l; diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index eb669f95b5..e126cdf40f 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -261,12 +261,12 @@ void AnimationTreeEditor::_popup_edit_dialog() { Ref<StyleBox> style = get_stylebox("panel", "PopupMenu"); Size2 size = get_node_size(edited_node); Point2 popup_pos(pos.x + style->get_margin(MARGIN_LEFT), pos.y + size.y - style->get_margin(MARGIN_BOTTOM)); - popup_pos += get_global_pos(); + popup_pos += get_global_position(); if (renaming_edit) { edit_label[0]->set_text(TTR("New name:")); - edit_label[0]->set_pos(Point2(5, 5)); + edit_label[0]->set_position(Point2(5, 5)); edit_label[0]->show(); edit_line[0]->set_begin(Point2(15, 25)); edit_line[0]->set_text(edited_node); @@ -294,18 +294,18 @@ void AnimationTreeEditor::_popup_edit_dialog() { master_anim_popup->add_item(E->get()); } - master_anim_popup->set_pos(popup_pos); + master_anim_popup->set_position(popup_pos); master_anim_popup->popup(); } else { property_editor->edit(this, "", Variant::OBJECT, anim_tree->animation_node_get_animation(edited_node), PROPERTY_HINT_RESOURCE_TYPE, "Animation"); - property_editor->set_pos(popup_pos); + property_editor->set_position(popup_pos); property_editor->popup(); updating_edit = false; } return; case AnimationTreePlayer::NODE_TIMESCALE: edit_label[0]->set_text(TTR("Scale:")); - edit_label[0]->set_pos(Point2(5, 5)); + edit_label[0]->set_position(Point2(5, 5)); edit_label[0]->show(); edit_line[0]->set_begin(Point2(15, 25)); edit_line[0]->set_text(rtos(anim_tree->timescale_node_get_scale(edited_node))); @@ -314,13 +314,13 @@ void AnimationTreeEditor::_popup_edit_dialog() { break; case AnimationTreePlayer::NODE_ONESHOT: edit_label[0]->set_text(TTR("Fade In (s):")); - edit_label[0]->set_pos(Point2(5, 5)); + edit_label[0]->set_position(Point2(5, 5)); edit_label[0]->show(); edit_line[0]->set_begin(Point2(15, 25)); edit_line[0]->set_text(rtos(anim_tree->oneshot_node_get_fadein_time(edited_node))); edit_line[0]->show(); edit_label[1]->set_text(TTR("Fade Out (s):")); - edit_label[1]->set_pos(Point2(5, 55)); + edit_label[1]->set_position(Point2(5, 55)); edit_label[1]->show(); edit_line[1]->set_begin(Point2(15, 75)); edit_line[1]->set_text(rtos(anim_tree->oneshot_node_get_fadeout_time(edited_node))); @@ -340,13 +340,13 @@ void AnimationTreeEditor::_popup_edit_dialog() { edit_check->show(); edit_label[2]->set_text(TTR("Restart (s):")); - edit_label[2]->set_pos(Point2(5, 145)); + edit_label[2]->set_position(Point2(5, 145)); edit_label[2]->show(); edit_line[2]->set_begin(Point2(15, 165)); edit_line[2]->set_text(rtos(anim_tree->oneshot_node_get_autorestart_delay(edited_node))); edit_line[2]->show(); edit_label[3]->set_text(TTR("Random Restart (s):")); - edit_label[3]->set_pos(Point2(5, 195)); + edit_label[3]->set_position(Point2(5, 195)); edit_label[3]->show(); edit_line[3]->set_begin(Point2(15, 215)); edit_line[3]->set_text(rtos(anim_tree->oneshot_node_get_autorestart_random_delay(edited_node))); @@ -367,7 +367,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { case AnimationTreePlayer::NODE_MIX: edit_label[0]->set_text(TTR("Amount:")); - edit_label[0]->set_pos(Point2(5, 5)); + edit_label[0]->set_position(Point2(5, 5)); edit_label[0]->show(); edit_scroll[0]->set_min(0); edit_scroll[0]->set_max(1); @@ -379,7 +379,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { break; case AnimationTreePlayer::NODE_BLEND2: edit_label[0]->set_text(TTR("Blend:")); - edit_label[0]->set_pos(Point2(5, 5)); + edit_label[0]->set_position(Point2(5, 5)); edit_label[0]->show(); edit_scroll[0]->set_min(0); edit_scroll[0]->set_max(1); @@ -394,7 +394,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { case AnimationTreePlayer::NODE_BLEND3: edit_label[0]->set_text(TTR("Blend:")); - edit_label[0]->set_pos(Point2(5, 5)); + edit_label[0]->set_position(Point2(5, 5)); edit_label[0]->show(); edit_scroll[0]->set_min(-1); edit_scroll[0]->set_max(1); @@ -407,7 +407,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { case AnimationTreePlayer::NODE_BLEND4: edit_label[0]->set_text(TTR("Blend 0:")); - edit_label[0]->set_pos(Point2(5, 5)); + edit_label[0]->set_position(Point2(5, 5)); edit_label[0]->show(); edit_scroll[0]->set_min(0); edit_scroll[0]->set_max(1); @@ -415,7 +415,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { edit_scroll[0]->set_begin(Point2(15, 25)); edit_scroll[0]->show(); edit_label[1]->set_text(TTR("Blend 1:")); - edit_label[1]->set_pos(Point2(5, 55)); + edit_label[1]->set_position(Point2(5, 55)); edit_label[1]->show(); edit_scroll[1]->set_min(0); edit_scroll[1]->set_max(1); @@ -429,14 +429,14 @@ void AnimationTreeEditor::_popup_edit_dialog() { case AnimationTreePlayer::NODE_TRANSITION: { edit_label[0]->set_text(TTR("X-Fade Time (s):")); - edit_label[0]->set_pos(Point2(5, 5)); + edit_label[0]->set_position(Point2(5, 5)); edit_label[0]->show(); edit_line[0]->set_begin(Point2(15, 25)); edit_line[0]->set_text(rtos(anim_tree->transition_node_get_xfade_time(edited_node))); edit_line[0]->show(); edit_label[1]->set_text(TTR("Current:")); - edit_label[1]->set_pos(Point2(5, 55)); + edit_label[1]->set_position(Point2(5, 55)); edit_label[1]->show(); edit_option->set_begin(Point2(15, 75)); @@ -455,7 +455,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { } } - edit_dialog->set_pos(popup_pos); + edit_dialog->set_position(popup_pos); edit_dialog->popup(); updating_edit = false; @@ -727,8 +727,8 @@ void AnimationTreeEditor::_node_edit_property(const StringName& p_node) { property_editor->edit(NULL,ph.name,ph.type,anim_tree->node_get_param(p_node),ph.hint,ph.hint_string); Point2 popup_pos=Point2( pos.x+(size.width-property_editor->get_size().width)/2.0,pos.y+(size.y-style->get_margin(MARGIN_BOTTOM))).floor(); - popup_pos+=get_global_pos(); - property_editor->set_pos(popup_pos); + popup_pos+=get_global_position(); + property_editor->set_position(popup_pos); property_editor->popup(); @@ -797,7 +797,7 @@ void AnimationTreeEditor::_gui_input(InputEvent p_event) { } } - node_popup->set_pos(rclick_pos + get_global_pos()); + node_popup->set_position(rclick_pos + get_global_position()); node_popup->popup(); } @@ -807,7 +807,7 @@ void AnimationTreeEditor::_gui_input(InputEvent p_event) { node_popup->add_item(TTR("Remove"), NODE_ERASE); if (anim_tree->node_get_type(rclick_node) == AnimationTreePlayer::NODE_TRANSITION) node_popup->add_item(TTR("Add Input"), NODE_ADD_INPUT); - node_popup->set_pos(rclick_pos + get_global_pos()); + node_popup->set_position(rclick_pos + get_global_position()); node_popup->popup(); } } @@ -1302,7 +1302,7 @@ AnimationTreeEditor::AnimationTreeEditor() { add_menu = memnew(MenuButton); //add_menu->set_ - add_menu->set_pos(Point2(0, 0)); + add_menu->set_position(Point2(0, 0)); add_menu->set_size(Point2(25, 15)); add_child(add_menu); @@ -1324,7 +1324,7 @@ AnimationTreeEditor::AnimationTreeEditor() { p->connect("id_pressed", this, "_add_menu_item"); play_button = memnew(Button); - play_button->set_pos(Point2(25, 0)); + play_button->set_position(Point2(25, 0)); play_button->set_size(Point2(25, 15)); add_child(play_button); play_button->set_toggle_mode(true); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 0c32671acc..1a533dce32 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -186,17 +186,17 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) { Vector2 motion_ofs = gpos - local_mouse_pos; - undo_redo->add_do_method(n2d, "set_global_pos", local_mouse_pos); + undo_redo->add_do_method(n2d, "set_global_position", local_mouse_pos); undo_redo->add_do_method(n2d, "edit_set_pivot", offset + n2d->get_global_transform().affine_inverse().basis_xform(motion_ofs)); - undo_redo->add_undo_method(n2d, "set_global_pos", gpos); + undo_redo->add_undo_method(n2d, "set_global_position", gpos); undo_redo->add_undo_method(n2d, "edit_set_pivot", offset); for (int i = 0; i < n2d->get_child_count(); i++) { Node2D *n2dc = n2d->get_child(i)->cast_to<Node2D>(); if (!n2dc) continue; - undo_redo->add_do_method(n2dc, "set_global_pos", n2dc->get_global_position()); - undo_redo->add_undo_method(n2dc, "set_global_pos", n2dc->get_global_position()); + undo_redo->add_do_method(n2dc, "set_global_position", n2dc->get_global_position()); + undo_redo->add_undo_method(n2dc, "set_global_position", n2dc->get_global_position()); } } } @@ -666,7 +666,7 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE } else if (Control *control = canvas_item->cast_to<Control>()) { - control->set_pos(control->get_pos() + drag); + control->set_position(control->get_position() + drag); } } } @@ -1014,7 +1014,7 @@ void CanvasItemEditor::_list_select(const InputEventMouseButton &b) { additive_selection = b.mod.shift; - selection_menu->set_global_pos(Vector2(b.global_x, b.global_y)); + selection_menu->set_global_position(Vector2(b.global_x, b.global_y)); selection_menu->popup(); selection_menu->call_deferred("grab_click_focus"); selection_menu->set_invalidate_click_until_motion(); @@ -1135,7 +1135,7 @@ void CanvasItemEditor::_viewport_gui_input(const InputEvent &p_event) { Node* scene = get_scene()->get_root_node()->cast_to<EditorNode>()->get_edited_scene(); if ( scene ) ref_item =_select_canvas_item_at_pos( Point2( b.x, b.y ), scene, transform ); #endif - //popup->set_pos(Point2(b.x,b.y)); + //popup->set_position(Point2(b.x,b.y)); //popup->popup(); } return; @@ -2703,7 +2703,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { Control *ctrl = canvas_item->cast_to<Control>(); if (key_pos) - AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect/pos", ctrl->get_pos(), existing); + AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect/pos", ctrl->get_position(), existing); if (key_scale) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect/size", ctrl->get_size(), existing); } @@ -2789,10 +2789,10 @@ void CanvasItemEditor::_popup_callback(int p_op) { Node2D *n2d = o->cast_to<Node2D>(); if (!n2d) continue; - undo_redo->add_do_method(n2d, "set_pos", E->get().pos); + undo_redo->add_do_method(n2d, "set_position", E->get().pos); undo_redo->add_do_method(n2d, "set_rot", E->get().rot); undo_redo->add_do_method(n2d, "set_scale", E->get().scale); - undo_redo->add_undo_method(n2d, "set_pos", n2d->get_position()); + undo_redo->add_undo_method(n2d, "set_position", n2d->get_position()); undo_redo->add_undo_method(n2d, "set_rot", n2d->get_rotation()); undo_redo->add_undo_method(n2d, "set_scale", n2d->get_scale()); } @@ -2826,7 +2826,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { Control *ctrl = canvas_item->cast_to<Control>(); if (key_pos) - ctrl->set_pos(Point2()); + ctrl->set_position(Point2()); /* if (key_scale) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl,"rect/size",ctrl->get_size()); @@ -3354,7 +3354,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { Label *l = memnew(Label); l->set_text(TTR("Snap (Pixels):")); - l->set_pos(Point2(5, 5)); + l->set_position(Point2(5, 5)); value_dialog->add_child(l); dialog_label = l; @@ -3474,8 +3474,8 @@ void CanvasItemEditorViewport::_on_change_type() { } void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const { - label->set_pos(get_global_pos() + Point2(14, 14)); - label_desc->set_pos(label->get_pos() + Point2(0, label->get_size().height)); + label->set_position(get_global_position() + Point2(14, 14)); + label_desc->set_position(label->get_position() + Point2(0, label->get_size().height)); for (int i = 0; i < files.size(); i++) { String path = files[i]; RES res = ResourceLoader::load(path); @@ -3576,8 +3576,8 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String & // locate at preview position Point2 pos; - if (parent->has_method("get_global_pos")) { - pos = parent->call("get_global_pos"); + if (parent->has_method("get_global_position")) { + pos = parent->call("get_global_position"); } Transform2D trans = canvas->get_canvas_transform(); Point2 target_pos = (p_point - trans.get_origin()) / trans.get_scale().x - pos; @@ -3626,7 +3626,7 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons } else { Control *parent_control = parent->cast_to<Control>(); if (parent_control) { - pos = parent_control->get_global_pos(); + pos = parent_control->get_global_position(); } } Transform2D trans = canvas->get_canvas_transform(); @@ -3834,7 +3834,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte for (int i = 0; i < types.size(); i++) { CheckBox *check = memnew(CheckBox); check->set_text(types[i]); - check->connect("button_selected", this, "_on_select_type", varray(check)); + check->connect("button_down", this, "_on_select_type", varray(check)); btn_group->add_child(check); check->set_button_group(button_group); } diff --git a/editor/plugins/cube_grid_theme_editor_plugin.cpp b/editor/plugins/cube_grid_theme_editor_plugin.cpp index 4633d5fe33..17149ef868 100644 --- a/editor/plugins/cube_grid_theme_editor_plugin.cpp +++ b/editor/plugins/cube_grid_theme_editor_plugin.cpp @@ -303,7 +303,7 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) { add_child(panel); MenuButton * options = memnew( MenuButton ); panel->add_child(options); - options->set_pos(Point2(1,1)); + options->set_position(Point2(1,1)); options->set_text("Theme"); options->get_popup()->add_item(TTR("Add Item"),MENU_OPTION_ADD_ITEM); options->get_popup()->add_item(TTR("Remove Selected Item"),MENU_OPTION_REMOVE_ITEM); diff --git a/editor/plugins/gradient_texture_editor_plugin.cpp b/editor/plugins/gradient_texture_editor_plugin.cpp index 1e82a1105a..9551fe19fa 100644 --- a/editor/plugins/gradient_texture_editor_plugin.cpp +++ b/editor/plugins/gradient_texture_editor_plugin.cpp @@ -39,7 +39,7 @@ void GradientTextureEdit::_show_color_picker() { return; Size2 ms = Size2(350, picker->get_combined_minimum_size().height + 10); picker->set_pick_color(points[grabbed].color); - popup->set_pos(get_global_pos() - Vector2(ms.width - get_size().width, ms.height)); + popup->set_position(get_global_position() - Vector2(ms.width - get_size().width, ms.height)); popup->set_size(ms); popup->popup(); } diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index 2b8189336b..4c84e831c1 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -113,48 +113,7 @@ void ParticlesEditor::_menu_option(int p_option) { switch (p_option) { case MENU_OPTION_GENERATE_AABB: { -#if 0 - Transform globalizer = node->get_global_transform(); - ParticleSystemSW pssw; - for (int i = 0; i < VS::PARTICLE_VAR_MAX; i++) { - - pssw.particle_vars[i] = node->get_variable((Particles::Variable)i); - pssw.particle_randomness[i] = node->get_randomness((Particles::Variable)i); - } - - pssw.emission_half_extents = node->get_emission_half_extents(); - pssw.emission_points = node->get_emission_points(); - pssw.emission_base_velocity = node->get_emission_base_velocity(); - pssw.amount = node->get_amount(); - pssw.gravity_normal = node->get_gravity_normal(); - pssw.emitting = true; - pssw.height_from_velocity = node->has_height_from_velocity(); - pssw.color_phase_count = 1; - - ParticleSystemProcessSW pp; - float delta = 0.01; - float lifetime = pssw.particle_vars[VS::PARTICLE_LIFETIME]; - - Transform localizer = globalizer.affine_inverse(); - AABB aabb; - for (float t = 0; t < lifetime; t += delta) { - - pp.process(&pssw, globalizer, delta); - for (int i = 0; i < pp.particle_data.size(); i++) { - - Vector3 p = localizer.xform(pp.particle_data[i].pos); - - if (t == 0 && i == 0) - aabb.pos = p; - else - aabb.expand_to(p); - } - } - - aabb.grow_by(aabb.get_longest_axis_size() * 0.2); - - node->set_visibility_aabb(aabb); -#endif + generate_aabb->popup_centered_minsize(); } break; case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH: { @@ -186,6 +145,33 @@ void ParticlesEditor::_menu_option(int p_option) { } } +void ParticlesEditor::_generate_aabb() { + + float time = generate_seconds->get_value(); + + float running = 0.0; + + EditorProgress ep("gen_aabb", TTR("Generating AABB"), int(time)); + + Rect3 rect; + while (running < time) { + + uint64_t ticks = OS::get_singleton()->get_ticks_usec(); + ep.step("Generating..", int(running), true); + OS::get_singleton()->delay_usec(1000); + + Rect3 capture = node->capture_aabb(); + if (rect == Rect3()) + rect = capture; + else + rect.merge_with(capture); + + running += (OS::get_singleton()->get_ticks_usec() - ticks) / 1000000.0; + } + + node->set_visibility_aabb(rect); +} + void ParticlesEditor::edit(Particles *p_particles) { node = p_particles; @@ -392,6 +378,7 @@ void ParticlesEditor::_bind_methods() { ClassDB::bind_method("_resource_seleted", &ParticlesEditor::_resource_seleted); ClassDB::bind_method("_node_selected", &ParticlesEditor::_node_selected); ClassDB::bind_method("_generate_emission_points", &ParticlesEditor::_generate_emission_points); + ClassDB::bind_method("_generate_aabb", &ParticlesEditor::_generate_aabb); //ClassDB::bind_method("_populate",&ParticlesEditor::_populate); } @@ -456,6 +443,20 @@ ParticlesEditor::ParticlesEditor() { emission_file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); + generate_aabb = memnew(ConfirmationDialog); + generate_aabb->set_title(TTR("Generate Visibility AABB")); + VBoxContainer *genvb = memnew(VBoxContainer); + generate_aabb->add_child(genvb); + generate_seconds = memnew(SpinBox); + genvb->add_margin_child(TTR("Generation Time (sec):"), generate_seconds); + generate_seconds->set_min(0.1); + generate_seconds->set_max(25); + generate_seconds->set_value(2); + + add_child(generate_aabb); + + generate_aabb->connect("confirmed", this, "_generate_aabb"); + //options->set_anchor(MARGIN_LEFT,Control::ANCHOR_END); //options->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END); } diff --git a/editor/plugins/particles_editor_plugin.h b/editor/plugins/particles_editor_plugin.h index 15881fe6a1..e9f9f43468 100644 --- a/editor/plugins/particles_editor_plugin.h +++ b/editor/plugins/particles_editor_plugin.h @@ -57,6 +57,9 @@ class ParticlesEditor : public Control { SpinBox *emission_amount; OptionButton *emission_fill; + ConfirmationDialog *generate_aabb; + SpinBox *generate_seconds; + enum Menu { MENU_OPTION_GENERATE_AABB, @@ -68,6 +71,7 @@ class ParticlesEditor : public Control { PoolVector<Face3> geometry; + void _generate_aabb(); void _generate_emission_points(); void _resource_seleted(const String &p_res); void _node_selected(const NodePath &p_path); diff --git a/editor/plugins/sample_editor_plugin.cpp b/editor/plugins/sample_editor_plugin.cpp index 0c4a85230c..a9af5823e3 100644 --- a/editor/plugins/sample_editor_plugin.cpp +++ b/editor/plugins/sample_editor_plugin.cpp @@ -381,14 +381,14 @@ SampleEditor::SampleEditor() { play = memnew( Button ); - play->set_pos(Point2( 5, 5 )); + play->set_position(Point2( 5, 5 )); play->set_size( Size2(1,1 ) ); play->set_toggle_mode(true); add_child(play); stop = memnew( Button ); - stop->set_pos(Point2( 35, 5 )); + stop->set_position(Point2( 35, 5 )); stop->set_size( Size2(1,1 ) ); stop->set_toggle_mode(true); add_child(stop); diff --git a/editor/plugins/sample_library_editor_plugin.cpp b/editor/plugins/sample_library_editor_plugin.cpp index 17f24d1a6b..9eb1af70d1 100644 --- a/editor/plugins/sample_library_editor_plugin.cpp +++ b/editor/plugins/sample_library_editor_plugin.cpp @@ -436,7 +436,7 @@ SampleLibraryEditor::SampleLibraryEditor() { load = memnew( Button ); - load->set_pos(Point2( 5, 5 )); + load->set_position(Point2( 5, 5 )); load->set_size( Size2(1,1 ) ); add_child(load); diff --git a/editor/plugins/sample_player_editor_plugin.cpp b/editor/plugins/sample_player_editor_plugin.cpp index 944f41637f..25f1fe9e17 100644 --- a/editor/plugins/sample_player_editor_plugin.cpp +++ b/editor/plugins/sample_player_editor_plugin.cpp @@ -118,7 +118,7 @@ SamplePlayerEditor::SamplePlayerEditor() { play = memnew( Button ); - play->set_pos(Point2( 5, 5 )); + play->set_position(Point2( 5, 5 )); play->set_toggle_mode(true); play->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,250); play->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,230); @@ -129,7 +129,7 @@ SamplePlayerEditor::SamplePlayerEditor() { stop = memnew( Button ); - stop->set_pos(Point2( 35, 5 )); + stop->set_position(Point2( 35, 5 )); stop->set_toggle_mode(true); stop->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,220); stop->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,200); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 20ded1d8fd..a99cd7a2d6 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -530,6 +530,15 @@ void ScriptEditor::_resave_scripts(const String &p_str) { if (trim_trailing_whitespace_on_save) { se->trim_trailing_whitespace(); } + + if (convert_indent_on_save) { + if (use_space_indentation) { + se->convert_indent_to_spaces(); + } else { + se->convert_indent_to_tabs(); + } + } + editor->save_resource(script); se->tag_saved_version(); } @@ -795,12 +804,28 @@ void ScriptEditor::_menu_option(int p_option) { if (trim_trailing_whitespace_on_save) current->trim_trailing_whitespace(); + + if (convert_indent_on_save) { + if (use_space_indentation) { + current->convert_indent_to_spaces(); + } else { + current->convert_indent_to_tabs(); + } + } editor->save_resource(current->get_edited_script()); } break; case FILE_SAVE_AS: { current->trim_trailing_whitespace(); + + if (convert_indent_on_save) { + if (use_space_indentation) { + current->convert_indent_to_spaces(); + } else { + current->convert_indent_to_tabs(); + } + } editor->push_item(current->get_edited_script()->cast_to<Object>()); editor->save_resource_as(current->get_edited_script()); @@ -878,28 +903,29 @@ void ScriptEditor::_menu_option(int p_option) { } } } - } + } else { - EditorHelp *help = tab_container->get_current_tab_control()->cast_to<EditorHelp>(); - if (help) { + EditorHelp *help = tab_container->get_current_tab_control()->cast_to<EditorHelp>(); + if (help) { - switch (p_option) { + switch (p_option) { - case HELP_SEARCH_FIND: { - help->popup_search(); - } break; - case HELP_SEARCH_FIND_NEXT: { - help->search_again(); - } break; - case FILE_CLOSE: { - _close_current_tab(); - } break; - case CLOSE_DOCS: { - _close_docs_tab(); - } break; - case CLOSE_ALL: { - _close_all_tabs(); - } break; + case HELP_SEARCH_FIND: { + help->popup_search(); + } break; + case HELP_SEARCH_FIND_NEXT: { + help->search_again(); + } break; + case FILE_CLOSE: { + _close_current_tab(); + } break; + case CLOSE_DOCS: { + _close_docs_tab(); + } break; + case CLOSE_ALL: { + _close_all_tabs(); + } break; + } } } } @@ -1515,6 +1541,14 @@ void ScriptEditor::save_all_scripts() { se->trim_trailing_whitespace(); } + if (convert_indent_on_save) { + if (use_space_indentation) { + se->convert_indent_to_spaces(); + } else { + se->convert_indent_to_tabs(); + } + } + Ref<Script> script = se->get_edited_script(); if (script.is_valid()) se->apply_code(); @@ -1614,6 +1648,9 @@ void ScriptEditor::_save_layout() { void ScriptEditor::_editor_settings_changed() { trim_trailing_whitespace_on_save = EditorSettings::get_singleton()->get("text_editor/files/trim_trailing_whitespace_on_save"); + convert_indent_on_save = EditorSettings::get_singleton()->get("text_editor/indent/convert_indent_on_save"); + use_space_indentation = EditorSettings::get_singleton()->get("text_editor/indent/type") == "Tabs" ? 0 : 1; + float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs"); if (autosave_time > 0) { autosave_timer->set_wait_time(autosave_time); @@ -2186,6 +2223,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { edit_pass = 0; trim_trailing_whitespace_on_save = false; + convert_indent_on_save = false; + use_space_indentation = false; ScriptServer::edit_request_func = _open_script_request; } diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index f3bb5b5546..6a54609167 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -91,6 +91,8 @@ public: virtual void set_edit_state(const Variant &p_state) = 0; virtual void goto_line(int p_line, bool p_with_error = false) = 0; virtual void trim_trailing_whitespace() = 0; + virtual void convert_indent_to_spaces() = 0; + virtual void convert_indent_to_tabs() = 0; virtual void ensure_focus() = 0; virtual void tag_saved_version() = 0; virtual void reload(bool p_soft) = 0; @@ -251,6 +253,8 @@ class ScriptEditor : public VBoxContainer { void _res_saved_callback(const Ref<Resource> &p_res); bool trim_trailing_whitespace_on_save; + bool use_space_indentation; + bool convert_indent_on_save; void _trim_trailing_whitespace(TextEdit *tx); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 8119acac53..052c19f34e 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -270,6 +270,96 @@ void ScriptTextEditor::trim_trailing_whitespace() { } } +void ScriptTextEditor::convert_indent_to_spaces() { + TextEdit *tx = code_editor->get_text_edit(); + Ref<Script> scr = get_edited_script(); + + if (scr.is_null()) { + return; + } + + int indent_size = EditorSettings::get_singleton()->get("text_editor/indent/size"); + String indent = ""; + + for (int i = 0; i < indent_size; i++) { + indent += " "; + } + + bool changed_indentation = false; + for (int i = 0; i < tx->get_line_count(); i++) { + String line = tx->get_line(i); + + if (line.length() <= 0) { + continue; + } + + int j = 0; + while (j < line.length() && (line[j] == ' ' || line[j] == '\t')) { + if (line[j] == '\t') { + if (!changed_indentation) { + tx->begin_complex_operation(); + changed_indentation = true; + } + line = line.left(j) + indent + line.right(j + 1); + } + j++; + } + tx->set_line(i, line); + } + if (changed_indentation) { + tx->end_complex_operation(); + tx->update(); + } +} + +void ScriptTextEditor::convert_indent_to_tabs() { + TextEdit *tx = code_editor->get_text_edit(); + Ref<Script> scr = get_edited_script(); + + if (scr.is_null()) { + return; + } + + int indent_size = EditorSettings::get_singleton()->get("text_editor/indent/size"); + indent_size -= 1; + + bool changed_indentation = false; + for (int i = 0; i < tx->get_line_count(); i++) { + String line = tx->get_line(i); + + if (line.length() <= 0) { + continue; + } + + int j = 0; + int space_count = -1; + while (j < line.length() && (line[j] == ' ' || line[j] == '\t')) { + if (line[j] != '\t') { + space_count++; + + if (space_count == indent_size) { + if (!changed_indentation) { + tx->begin_complex_operation(); + changed_indentation = true; + } + + line = line.left(j - indent_size) + "\t" + line.right(j + 1); + j = 0; + space_count = -1; + } + } else { + space_count = -1; + } + j++; + } + tx->set_line(i, line); + } + if (changed_indentation) { + tx->end_complex_operation(); + tx->update(); + } +} + void ScriptTextEditor::tag_saved_version() { code_editor->get_text_edit()->tag_saved_version(); @@ -807,6 +897,12 @@ void ScriptTextEditor::_edit_option(int p_op) { case EDIT_TRIM_TRAILING_WHITESAPCE: { trim_trailing_whitespace(); } break; + case EDIT_CONVERT_INDENT_TO_SPACES: { + convert_indent_to_spaces(); + } break; + case EDIT_CONVERT_INDENT_TO_TABS: { + convert_indent_to_tabs(); + } break; case EDIT_PICK_COLOR: { color_panel->popup(); } break; @@ -1075,8 +1171,8 @@ void ScriptTextEditor::_text_edit_gui_input(const InputEvent &ev) { int col, row; TextEdit *tx = code_editor->get_text_edit(); - tx->_get_mouse_pos(Point2i(mb.global_x, mb.global_y) - tx->get_global_pos(), row, col); - Vector2 mpos = Vector2(mb.global_x, mb.global_y) - tx->get_global_pos(); + tx->_get_mouse_pos(Point2i(mb.global_x, mb.global_y) - tx->get_global_position(), row, col); + Vector2 mpos = Vector2(mb.global_x, mb.global_y) - tx->get_global_position(); bool have_selection = (tx->get_selection_text().length() > 0); bool have_color = (tx->get_word_at_pos(mpos) == "Color"); if (have_color) { @@ -1104,7 +1200,7 @@ void ScriptTextEditor::_text_edit_gui_input(const InputEvent &ev) { float alpha = color.size() > 3 ? color[3] : 1.0f; color_picker->set_pick_color(Color(color[0], color[1], color[2], alpha)); } - color_panel->set_pos(get_global_transform().xform(get_local_mouse_pos())); + color_panel->set_position(get_global_transform().xform(get_local_mouse_pos())); Size2 ms = Size2(300, color_picker->get_combined_minimum_size().height + 10); color_panel->set_size(ms); } else { @@ -1154,7 +1250,7 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) { context_menu->add_separator(); context_menu->add_item(TTR("Pick Color"), EDIT_PICK_COLOR); } - context_menu->set_pos(get_global_transform().xform(get_local_mouse_pos())); + context_menu->set_position(get_global_transform().xform(get_local_mouse_pos())); context_menu->set_size(Vector2(1, 1)); context_menu->popup(); } @@ -1217,6 +1313,8 @@ ScriptTextEditor::ScriptTextEditor() { edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/complete_symbol"), EDIT_COMPLETE); #endif edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/auto_indent"), EDIT_AUTO_INDENT); edit_menu->get_popup()->connect("id_pressed", this, "_edit_option"); edit_menu->get_popup()->add_separator(); @@ -1285,6 +1383,8 @@ void ScriptTextEditor::register_editor() { ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CMD | KEY_SPACE); #endif ED_SHORTCUT("script_text_editor/trim_trailing_whitespace", TTR("Trim Trailing Whitespace"), KEY_MASK_CTRL | KEY_MASK_ALT | KEY_T); + ED_SHORTCUT("script_text_editor/convert_indent_to_spaces", TTR("Convert Indent To Spaces"), KEY_MASK_CTRL | KEY_MASK_SHIFT | KEY_Y); + ED_SHORTCUT("script_text_editor/convert_indent_to_tabs", TTR("Convert Indent To Tabs"), KEY_MASK_CTRL | KEY_MASK_SHIFT | KEY_X); ED_SHORTCUT("script_text_editor/auto_indent", TTR("Auto Indent"), KEY_MASK_CMD | KEY_I); ED_SHORTCUT("script_text_editor/toggle_breakpoint", TTR("Toggle Breakpoint"), KEY_F9); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 4bf525e2d1..8e089e1ebf 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -67,6 +67,8 @@ class ScriptTextEditor : public ScriptEditorBase { EDIT_COMPLETE, EDIT_AUTO_INDENT, EDIT_TRIM_TRAILING_WHITESAPCE, + EDIT_CONVERT_INDENT_TO_SPACES, + EDIT_CONVERT_INDENT_TO_TABS, EDIT_TOGGLE_COMMENT, EDIT_MOVE_LINE_UP, EDIT_MOVE_LINE_DOWN, @@ -125,6 +127,8 @@ public: virtual void set_edit_state(const Variant &p_state); virtual void ensure_focus(); virtual void trim_trailing_whitespace(); + virtual void convert_indent_to_spaces(); + virtual void convert_indent_to_tabs(); virtual void tag_saved_version(); virtual void goto_line(int p_line, bool p_with_error = false); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index dcb126a754..b5edd12b9c 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -370,7 +370,8 @@ void ShaderEditor::_editor_settings_changed() { shader_editor->get_text_edit()->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete")); shader_editor->get_text_edit()->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file")); - shader_editor->get_text_edit()->set_tab_size(EditorSettings::get_singleton()->get("text_editor/indent/tab_size")); + shader_editor->get_text_edit()->set_indent_size(EditorSettings::get_singleton()->get("text_editor/indent/size")); + shader_editor->get_text_edit()->set_indent_using_spaces(EditorSettings::get_singleton()->get("text_editor/indent/type") == "Tabs" ? 0 : 1); shader_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs")); shader_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_numbers")); shader_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting")); @@ -445,7 +446,7 @@ ShaderEditor::ShaderEditor() { edit_menu = memnew(MenuButton); hbc->add_child(edit_menu); - edit_menu->set_pos(Point2(5, -1)); + edit_menu->set_position(Point2(5, -1)); edit_menu->set_text(TTR("Edit")); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/undo", TTR("Undo"), KEY_MASK_CMD | KEY_Z), EDIT_UNDO); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/redo", TTR("Redo"), KEY_MASK_CMD | KEY_Y), EDIT_REDO); @@ -459,7 +460,7 @@ ShaderEditor::ShaderEditor() { search_menu = memnew(MenuButton); hbc->add_child(search_menu); - search_menu->set_pos(Point2(38, -1)); + search_menu->set_position(Point2(38, -1)); search_menu->set_text(TTR("Search")); search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find.."), KEY_MASK_CMD | KEY_F), SEARCH_FIND); search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_next", TTR("Find Next"), KEY_F3), SEARCH_FIND_NEXT); diff --git a/editor/plugins/shader_graph_editor_plugin.cpp b/editor/plugins/shader_graph_editor_plugin.cpp index 04dae641bc..0fd28a0b59 100644 --- a/editor/plugins/shader_graph_editor_plugin.cpp +++ b/editor/plugins/shader_graph_editor_plugin.cpp @@ -60,7 +60,7 @@ void GraphColorRampEdit::_gui_input(const InputEvent& p_event) { return; Size2 ms = Size2(350, picker->get_combined_minimum_size().height+10); picker->set_color(points[grabbed].color); - popup->set_pos(get_global_pos()-Size2(0,ms.height)); + popup->set_position(get_global_position()-Size2(0,ms.height)); popup->set_size(ms); popup->popup(); return; @@ -840,7 +840,7 @@ void ShaderGraphView::_xform_input_changed(int p_id, Node *p_button){ ToolButton *tb = p_button->cast_to<ToolButton>(); - ped_popup->set_pos(tb->get_global_pos()+Vector2(0,tb->get_size().height)); + ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height)); ped_popup->set_size(tb->get_size()); edited_id=p_id; edited_def=-1; @@ -851,7 +851,7 @@ void ShaderGraphView::_xform_input_changed(int p_id, Node *p_button){ void ShaderGraphView::_xform_const_changed(int p_id, Node *p_button){ ToolButton *tb = p_button->cast_to<ToolButton>(); - ped_popup->set_pos(tb->get_global_pos()+Vector2(0,tb->get_size().height)); + ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height)); ped_popup->set_size(tb->get_size()); edited_id=p_id; edited_def=-1; @@ -1075,7 +1075,7 @@ void ShaderGraphView::_input_name_changed(const String& p_name, int p_id, Node * void ShaderGraphView::_tex_edited(int p_id,Node* p_button) { ToolButton *tb = p_button->cast_to<ToolButton>(); - ped_popup->set_pos(tb->get_global_pos()+Vector2(0,tb->get_size().height)); + ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height)); ped_popup->set_size(tb->get_size()); edited_id=p_id; edited_def=-1; @@ -1085,7 +1085,7 @@ void ShaderGraphView::_tex_edited(int p_id,Node* p_button) { void ShaderGraphView::_cube_edited(int p_id,Node* p_button) { ToolButton *tb = p_button->cast_to<ToolButton>(); - ped_popup->set_pos(tb->get_global_pos()+Vector2(0,tb->get_size().height)); + ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height)); ped_popup->set_size(tb->get_size()); edited_id=p_id; edited_def=-1; @@ -1300,7 +1300,7 @@ void ShaderGraphView::_delete_nodes_request() void ShaderGraphView::_default_changed(int p_id, Node *p_button, int p_param, int v_type, String p_hint) { ToolButton *tb = p_button->cast_to<ToolButton>(); - ped_popup->set_pos(tb->get_global_pos()+Vector2(0,tb->get_size().height)); + ped_popup->set_position(tb->get_global_position()+Vector2(0,tb->get_size().height)); ped_popup->set_size(tb->get_size()); edited_id=p_id; edited_def=p_param; @@ -2751,7 +2751,7 @@ ShaderGraphView::ShaderGraphView(ShaderGraph::ShaderType p_type) { graph_edit->get_top_layer()->add_child(status); graph_edit->connect("_begin_node_move", this, "_begin_node_move"); graph_edit->connect("_end_node_move", this, "_end_node_move"); - status->set_pos(Vector2(5,5)); + status->set_position(Vector2(5,5)); status->add_color_override("font_color_shadow",Color(0,0,0)); status->add_color_override("font_color",Color(1,0.4,0.3)); status->add_constant_override("shadow_as_outline",1); @@ -2779,7 +2779,7 @@ void ShaderGraphEditor::_popup_requested(const Vector2 &p_position) { Vector2 scroll_ofs=graph_edits[tabs->get_current_tab()]->get_graph_edit()->get_scroll_ofs(); next_location = get_local_mouse_pos() + scroll_ofs; - popup->set_global_pos(p_position); + popup->set_global_position(p_position); popup->set_size( Size2( 200, 0) ); popup->popup(); popup->call_deferred("grab_click_focus"); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 4961de56d3..d73349f773 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -673,7 +673,7 @@ void SpatialEditorViewport::_list_select(InputEventMouseButton b) { "\nType: " + spat->get_class() + "\nPath: " + node_path); } - selection_menu->set_global_pos(Vector2(b.global_x, b.global_y)); + selection_menu->set_global_position(Vector2(b.global_x, b.global_y)); selection_menu->popup(); selection_menu->call_deferred("grab_click_focus"); selection_menu->set_invalidate_click_until_motion(); @@ -2166,7 +2166,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu = memnew(MenuButton); surface->add_child(view_menu); - view_menu->set_pos(Point2(4, 4)); + view_menu->set_position(Point2(4, 4)); view_menu->set_self_modulate(Color(1, 1, 1, 0.5)); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM); @@ -3572,7 +3572,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { view_menu = memnew(MenuButton); view_menu->set_text(TTR("View")); - view_menu->set_pos(Point2(212, 0)); + view_menu->set_position(Point2(212, 0)); hbc_menu->add_child(view_menu); p = view_menu->get_popup(); @@ -3717,44 +3717,44 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { add_child(xform_dialog); Label *l = memnew(Label); l->set_text(TTR("Translate:")); - l->set_pos(Point2(5, 5)); + l->set_position(Point2(5, 5)); xform_dialog->add_child(l); for (int i = 0; i < 3; i++) { xform_translate[i] = memnew(LineEdit); - xform_translate[i]->set_pos(Point2(15 + i * 60, 22)); + xform_translate[i]->set_position(Point2(15 + i * 60, 22)); xform_translate[i]->set_size(Size2(50, 12)); xform_dialog->add_child(xform_translate[i]); } l = memnew(Label); l->set_text(TTR("Rotate (deg.):")); - l->set_pos(Point2(5, 45)); + l->set_position(Point2(5, 45)); xform_dialog->add_child(l); for (int i = 0; i < 3; i++) { xform_rotate[i] = memnew(LineEdit); - xform_rotate[i]->set_pos(Point2(15 + i * 60, 62)); + xform_rotate[i]->set_position(Point2(15 + i * 60, 62)); xform_rotate[i]->set_size(Size2(50, 22)); xform_dialog->add_child(xform_rotate[i]); } l = memnew(Label); l->set_text(TTR("Scale (ratio):")); - l->set_pos(Point2(5, 85)); + l->set_position(Point2(5, 85)); xform_dialog->add_child(l); for (int i = 0; i < 3; i++) { xform_scale[i] = memnew(LineEdit); - xform_scale[i]->set_pos(Point2(15 + i * 60, 102)); + xform_scale[i]->set_position(Point2(15 + i * 60, 102)); xform_scale[i]->set_size(Size2(50, 22)); xform_dialog->add_child(xform_scale[i]); } l = memnew(Label); l->set_text(TTR("Transform Type")); - l->set_pos(Point2(5, 125)); + l->set_position(Point2(5, 125)); xform_dialog->add_child(l); xform_type = memnew(OptionButton); diff --git a/editor/plugins/stream_editor_plugin.cpp b/editor/plugins/stream_editor_plugin.cpp index 43f770ab10..dd97ce936d 100644 --- a/editor/plugins/stream_editor_plugin.cpp +++ b/editor/plugins/stream_editor_plugin.cpp @@ -84,7 +84,7 @@ StreamEditor::StreamEditor() { stop = memnew( Button ); - stop->set_pos(Point2( 35, 5 )); + stop->set_position(Point2( 35, 5 )); stop->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,30); stop->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,10); stop->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0); diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index 1d067ff975..d421b203e9 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -61,12 +61,12 @@ StyleBoxEditor::StyleBoxEditor() { Label *l = memnew(Label); l->set_text(TTR("StyleBox Preview:")); - l->set_pos(Point2(5, 5)); + l->set_position(Point2(5, 5)); panel->add_child(l); preview = memnew(Panel); panel->add_child(preview); - preview->set_pos(Point2(50, 50)); + preview->set_position(Point2(50, 50)); preview->set_size(Size2(200, 100)); } diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 4ff5951049..a83ea70508 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -640,7 +640,7 @@ ThemeEditor::ThemeEditor() { theme_menu->get_popup()->add_item(TTR("Create Empty Editor Template"), POPUP_CREATE_EDITOR_EMPTY); add_child(theme_menu); - theme_menu->set_pos(Vector2(3, 3) * EDSCALE); + theme_menu->set_position(Vector2(3, 3) * EDSCALE); theme_menu->get_popup()->connect("id_pressed", this, "_theme_menu_cbk"); HBoxContainer *main_hb = memnew(HBoxContainer); @@ -778,23 +778,23 @@ ThemeEditor::ThemeEditor() { /* test_h_scroll = memnew( HScrollBar ); - test_h_scroll->set_pos( Point2( 25, 225 ) ); + test_h_scroll->set_position( Point2( 25, 225 ) ); test_h_scroll->set_size( Point2( 150, 5 ) ); panel->add_child(test_h_scroll); line_edit = memnew( LineEdit ); - line_edit->set_pos( Point2( 25, 275 ) ); + line_edit->set_position( Point2( 25, 275 ) ); line_edit->set_size( Point2( 150, 5 ) ); line_edit->set_text("Line Edit"); panel->add_child(line_edit); test_v_scroll = memnew( VScrollBar ); - test_v_scroll->set_pos( Point2( 200, 25 ) ); + test_v_scroll->set_position( Point2( 200, 25 ) ); test_v_scroll->set_size( Point2( 5, 150 ) ); panel->add_child(test_v_scroll); test_tree = memnew(Tree); - test_tree->set_pos( Point2( 300, 25 ) ); + test_tree->set_position( Point2( 300, 25 ) ); test_tree->set_size( Point2( 200, 200 ) ); panel->add_child(test_tree); @@ -818,7 +818,7 @@ ThemeEditor::ThemeEditor() { item->set_range(0,2); Button *fd_button= memnew( Button ); - fd_button->set_pos(Point2(300,275)); + fd_button->set_position(Point2(300,275)); fd_button->set_text("Open File Dialog"); panel->add_child(fd_button); @@ -833,17 +833,17 @@ ThemeEditor::ThemeEditor() { add_child(add_del_dialog); Label *l = memnew(Label); - l->set_pos(Point2(5, 5) * EDSCALE); + l->set_position(Point2(5, 5) * EDSCALE); l->set_text(TTR("Type:")); add_del_dialog->add_child(l); dtype_select_label = l; type_edit = memnew(LineEdit); - type_edit->set_pos(Point2(5, 25) * EDSCALE); + type_edit->set_position(Point2(5, 25) * EDSCALE); type_edit->set_size(Point2(150, 5) * EDSCALE); add_del_dialog->add_child(type_edit); type_menu = memnew(MenuButton); - type_menu->set_pos(Point2(160, 25) * EDSCALE); + type_menu->set_position(Point2(160, 25) * EDSCALE); type_menu->set_size(Point2(30, 5) * EDSCALE); type_menu->set_text(".."); add_del_dialog->add_child(type_menu); @@ -851,17 +851,17 @@ ThemeEditor::ThemeEditor() { type_menu->get_popup()->connect("id_pressed", this, "_type_menu_cbk"); l = memnew(Label); - l->set_pos(Point2(200, 5) * EDSCALE); + l->set_position(Point2(200, 5) * EDSCALE); l->set_text(TTR("Name:")); add_del_dialog->add_child(l); name_select_label = l; name_edit = memnew(LineEdit); - name_edit->set_pos(Point2(200, 25) * EDSCALE); + name_edit->set_position(Point2(200, 25) * EDSCALE); name_edit->set_size(Point2(150, 5) * EDSCALE); add_del_dialog->add_child(name_edit); name_menu = memnew(MenuButton); - name_menu->set_pos(Point2(360, 25) * EDSCALE); + name_menu->set_position(Point2(360, 25) * EDSCALE); name_menu->set_size(Point2(30, 5) * EDSCALE); name_menu->set_text(".."); @@ -871,7 +871,7 @@ ThemeEditor::ThemeEditor() { name_menu->get_popup()->connect("id_pressed", this, "_name_menu_cbk"); type_select_label = memnew(Label); - type_select_label->set_pos(Point2(400, 5) * EDSCALE); + type_select_label->set_position(Point2(400, 5) * EDSCALE); type_select_label->set_text(TTR("Data Type:")); add_del_dialog->add_child(type_select_label); @@ -881,7 +881,7 @@ ThemeEditor::ThemeEditor() { type_select->add_item(TTR("Font")); type_select->add_item(TTR("Color")); type_select->add_item(TTR("Constant")); - type_select->set_pos(Point2(400, 25) * EDSCALE); + type_select->set_position(Point2(400, 25) * EDSCALE); type_select->set_size(Point2(80, 5) * EDSCALE); add_del_dialog->add_child(type_select); diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index cbd300a53c..e79cbd0d35 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -225,7 +225,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { add_child(panel); MenuButton *options = memnew(MenuButton); panel->add_child(options); - options->set_pos(Point2(1, 1)); + options->set_position(Point2(1, 1)); options->set_text("Theme"); options->get_popup()->add_item(TTR("Add Item"), MENU_OPTION_ADD_ITEM); options->get_popup()->add_item(TTR("Remove Item"), MENU_OPTION_REMOVE_ITEM); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index cb67d706c3..35b8973818 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -50,6 +50,19 @@ #include "scene/gui/tool_button.h" #include "version.h" +static String _find_project_file(DirAccess *p_da) { + p_da->list_dir_begin(); + while (true) { + String f = p_da->get_next(); + if (f == "") + break; + if (f.get_extension() == "godot") + return p_da->get_current_dir() + "/" + f; + } + p_da->list_dir_end(); + return ""; +} + class NewProjectDialog : public ConfirmationDialog { GDCLASS(NewProjectDialog, ConfirmationDialog); @@ -92,18 +105,18 @@ private: if (mode != MODE_IMPORT) { - if (d->file_exists("godot.cfg")) { + if (_find_project_file(d) != "") { - error->set_text(TTR("Invalid project path, godot.cfg must not exist.")); + error->set_text(TTR("Invalid project path, *.godot must not exist.")); memdelete(d); return ""; } } else { - if (valid_path != "" && !d->file_exists("godot.cfg")) { + if (valid_path != "" && _find_project_file(d) == "") { - error->set_text(TTR("Invalid project path, godot.cfg must exist.")); + error->set_text(TTR("Invalid project path, *.godot must exist.")); memdelete(d); return ""; } @@ -136,7 +149,7 @@ private: String p = p_path; if (mode == MODE_IMPORT) { - if (p.ends_with("godot.cfg")) { + if (p.get_extension() == "godot") { p = p.get_base_dir(); } @@ -162,7 +175,7 @@ private: fdialog->set_mode(FileDialog::MODE_OPEN_FILE); fdialog->clear_filters(); - fdialog->add_filter("godot.cfg ; " _MKSTR(VERSION_NAME) " Project"); + fdialog->add_filter("*.godot ; " _MKSTR(VERSION_NAME) " Project"); } else { fdialog->set_mode(FileDialog::MODE_OPEN_DIR); } @@ -186,9 +199,9 @@ private: } else { if (mode == MODE_NEW) { - FileAccess *f = FileAccess::open(dir.plus_file("/godot.cfg"), FileAccess::WRITE); + FileAccess *f = FileAccess::open(dir.plus_file("/" + project_name->get_text().replace(" ", "_") + ".godot"), FileAccess::WRITE); if (!f) { - error->set_text(TTR("Couldn't create godot.cfg in project path.")); + error->set_text(TTR("Couldn't create *.godot project file in project path.")); } else { f->store_line("; Engine configuration file."); @@ -405,7 +418,7 @@ public: l = memnew(Label); l->set_text(TTR("Project Name:")); - l->set_pos(Point2(5, 50)); + l->set_position(Point2(5, 50)); vb->add_child(l); pn = l; @@ -624,7 +637,7 @@ void ProjectManager::_unhandled_input(const InputEvent &p_ev) { selected_list.clear(); selected_list.insert(current, hb->get_meta("main_scene")); - int offset_diff = scroll->get_v_scroll() - hb->get_pos().y; + int offset_diff = scroll->get_v_scroll() - hb->get_position().y; if (offset_diff > 0) scroll->set_v_scroll(scroll->get_v_scroll() - offset_diff); @@ -662,7 +675,7 @@ void ProjectManager::_unhandled_input(const InputEvent &p_ev) { selected_list.insert(current, hb->get_meta("main_scene")); int last_y_visible = scroll->get_v_scroll() + scroll->get_size().y; - int offset_diff = (hb->get_pos().y + hb->get_size().y) - last_y_visible; + int offset_diff = (hb->get_position().y + hb->get_size().y) - last_y_visible; if (offset_diff > 0) scroll->set_v_scroll(scroll->get_v_scroll() + offset_diff); @@ -741,10 +754,17 @@ void ProjectManager::_load_recent_projects() { continue; String project = _name.get_slice("/", 1); - String conf = path.plus_file("godot.cfg"); + DirAccess *dir_access = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + if (dir_access->change_dir(path) != OK) { + EditorSettings::get_singleton()->erase(_name); + continue; + } + String conf = _find_project_file(dir_access); + memdelete(dir_access); bool favorite = (_name.begins_with("favorite_projects/")) ? true : false; uint64_t last_modified = 0; + if (FileAccess::exists(conf)) { last_modified = FileAccess::get_modified_time(conf); @@ -912,7 +932,7 @@ void ProjectManager::_update_scroll_pos(const String &dir) { selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene")); _update_project_buttons(); int last_y_visible = scroll->get_v_scroll() + scroll->get_size().y; - int offset_diff = (hb->get_pos().y + hb->get_size().y) - last_y_visible; + int offset_diff = (hb->get_position().y + hb->get_size().y) - last_y_visible; if (offset_diff > 0) scroll->set_v_scroll(scroll->get_v_scroll() + offset_diff); @@ -1006,7 +1026,7 @@ void ProjectManager::_scan_dir(DirAccess *da, float pos, float total, List<Strin while (n != String()) { if (da->current_is_dir() && !n.begins_with(".")) { subdirs.push_front(n); - } else if (n == "godot.cfg") { + } else if (n.get_extension() == "godot") { r_projects->push_back(da->get_current_dir()); } n = da->get_next(); @@ -1117,7 +1137,7 @@ void ProjectManager::_files_dropped(PoolStringArray p_files, int p_screen) { dir->list_dir_begin(); String file = dir->get_next(); while (confirm && file != String()) { - if (!dir->current_is_dir() && file.ends_with("godot.cfg")) { + if (!dir->current_is_dir() && file.get_extension() == "godot") { confirm = false; } file = dir->get_next(); diff --git a/editor/project_settings.cpp b/editor/project_settings.cpp index 77af64d9e3..bc1bdcf8af 100644 --- a/editor/project_settings.cpp +++ b/editor/project_settings.cpp @@ -397,12 +397,12 @@ void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_ ERR_FAIL_COND(!ti); if (p_id == 1) { - Point2 ofs = input_editor->get_global_pos(); + Point2 ofs = input_editor->get_global_position(); Rect2 ir = input_editor->get_item_rect(ti); ir.pos.y -= input_editor->get_scroll().y; ofs += ir.pos + ir.size; ofs.x -= 100; - popup_add->set_pos(ofs); + popup_add->set_position(ofs); popup_add->popup(); add_at = "input/" + ti->get_text(0); @@ -1168,7 +1168,8 @@ void ProjectSettings::_bind_methods() { ProjectSettings::ProjectSettings(EditorData *p_data) { singleton = this; - set_title(TTR("Project Settings (godot.cfg)")); + String project_file = "(" + GlobalConfig::get_singleton()->get_project_file_name() + ")"; + set_title(TTR("Project Settings " + project_file)); set_resizable(true); undo_redo = &p_data->get_undo_redo(); data = p_data; @@ -1326,7 +1327,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { l = memnew(Label); vbc->add_child(l); - l->set_pos(Point2(6, 5)); + l->set_position(Point2(6, 5)); l->set_text(TTR("Action:")); hbc = memnew(HBoxContainer); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 406dbac5d9..666bfa20b5 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -319,12 +319,12 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: CheckBox *c = checks20[0]; c->set_text("True"); - checks20gc->set_pos(Vector2(4, 4)); + checks20gc->set_position(Vector2(4, 4)); c->set_pressed(v); c->show(); checks20gc->set_size(checks20gc->get_minimum_size()); - set_size(checks20gc->get_pos() + checks20gc->get_size() + Vector2(4, 4) * EDSCALE); + set_size(checks20gc->get_position() + checks20gc->get_size() + Vector2(4, 4) * EDSCALE); } break; case Variant::INT: @@ -374,7 +374,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: for (int i = 0; i < options.size(); i++) { menu->add_item(options[i], i); } - menu->set_pos(get_pos()); + menu->set_position(get_position()); menu->popup(); hide(); updating = false; @@ -423,12 +423,12 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: value_label[0]->set_text(title); value_label[0]->show(); - value_label[0]->set_pos(Vector2(4, 4) * EDSCALE); + value_label[0]->set_position(Vector2(4, 4) * EDSCALE); - checks20gc->set_pos(Vector2(4, 4) * EDSCALE + Vector2(0, value_label[0]->get_size().height + 4 * EDSCALE)); + checks20gc->set_position(Vector2(4, 4) * EDSCALE + Vector2(0, value_label[0]->get_size().height + 4 * EDSCALE)); checks20gc->set_size(checks20gc->get_minimum_size()); - set_size(Vector2(4, 4) * EDSCALE + checks20gc->get_pos() + checks20gc->get_size()); + set_size(Vector2(4, 4) * EDSCALE + checks20gc->get_position() + checks20gc->get_size()); } else if (hint == PROPERTY_HINT_EXP_EASING) { @@ -466,7 +466,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: if (f & (1 << i)) menu->set_item_checked(menu->get_item_index(i), true); } - menu->set_pos(get_pos()); + menu->set_position(get_position()); menu->popup(); hide(); updating = false; @@ -502,7 +502,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: for (int i = 0; i < options.size(); i++) { menu->add_item(options[i], i); } - menu->set_pos(get_pos()); + menu->set_position(get_position()); menu->popup(); hide(); updating = false; @@ -838,15 +838,15 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: value_editor[i]->show(); value_label[i]->show(); - value_label[i]->set_pos(Point2(ofs,y)); + value_label[i]->set_position(Point2(ofs,y)); scroll[i]->set_min(0); scroll[i]->set_max(1.0); scroll[i]->set_page(0); - scroll[i]->set_pos(Point2(ofs+15,y+Math::floor((h-scroll[i]->get_minimum_size().height)/2.0))); + scroll[i]->set_position(Point2(ofs+15,y+Math::floor((h-scroll[i]->get_minimum_size().height)/2.0))); scroll[i]->set_val(values[i]); scroll[i]->set_size(Size2(120,1)); scroll[i]->show(); - value_editor[i]->set_pos(Point2(ofs+140,y)); + value_editor[i]->set_position(Point2(ofs+140,y)); value_editor[i]->set_size(Size2(40,h)); value_editor[i]->set_text( String::num(values[i],2 )); @@ -857,7 +857,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: value_label[2]->set_text("B"); value_label[3]->set_text("A"); - Size2 new_size = value_editor[3]->get_pos() + value_editor[3]->get_size() + Point2(10,10); + Size2 new_size = value_editor[3]->get_position() + value_editor[3]->get_size() + Point2(10,10); set_size( new_size ); */ @@ -981,7 +981,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } } - menu->set_pos(get_pos()); + menu->set_position(get_position()); menu->popup(); hide(); updating = false; @@ -1868,7 +1868,7 @@ void CustomPropertyEditor::config_action_buttons(const List<String> &p_strings) if (i < p_strings.size()) { action_buttons[i]->show(); action_buttons[i]->set_text(p_strings[i]); - action_buttons[i]->set_pos(Point2(m, m + i * (h + m))); + action_buttons[i]->set_position(Point2(m, m + i * (h + m))); action_buttons[i]->set_size(Size2(w - m * 2, h)); action_buttons[i]->set_flat(true); } else { @@ -1896,9 +1896,9 @@ void CustomPropertyEditor::config_value_editors(int p_amount, int p_columns, int value_editor[i]->show(); value_label[i]->show(); value_label[i]->set_text(i < p_strings.size() ? p_strings[i] : String("")); - value_editor[i]->set_pos(Point2(m + p_label_w + c * (w + m + p_label_w), m + r * (h + m))); + value_editor[i]->set_position(Point2(m + p_label_w + c * (w + m + p_label_w), m + r * (h + m))); value_editor[i]->set_size(Size2(w, h)); - value_label[i]->set_pos(Point2(m + c * (w + m + p_label_w), m + r * (h + m))); + value_label[i]->set_position(Point2(m + c * (w + m + p_label_w), m + r * (h + m))); value_editor[i]->set_editable(!read_only); } else { value_editor[i]->hide(); @@ -2388,6 +2388,10 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p RES res = obj->get(p_name).operator RefPtr(); if (res->is_class("Texture")) { int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width"); + Vector2 size(res->call("get_width"), res->call("get_height")); + if (size.width < size.height) { + tw = MAX((size.width / size.height) * tw, 1); + } p_item->set_icon_max_width(1, tw); p_item->set_icon(1, res); p_item->set_text(1, ""); @@ -2427,7 +2431,9 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p } } - if (!res->is_class("Texture")) { + if (res->is_class("Script")) { + p_item->set_text(1, res->get_path().get_file()); + } else if (!res->is_class("Texture")) { //texture already previews via itself EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_resource_preview_done", p_item->get_instance_ID()); } @@ -3618,6 +3624,10 @@ void PropertyEditor::update_tree() { if (res->is_class("Texture")) { int tw = EditorSettings::get_singleton()->get("docks/property_editor/texture_preview_width"); + Vector2 size(res->call("get_width"), res->call("get_height")); + if (size.width < size.height) { + tw = MAX((size.width / size.height) * tw, 1); + } item->set_icon_max_width(1, tw); item->set_icon(1, res); item->set_text(1, ""); @@ -3641,7 +3651,9 @@ void PropertyEditor::update_tree() { } else if (res.is_valid()) { item->set_tooltip(1, res->get_name() + " (" + res->get_class() + ")"); } - if (!res->is_class("Texture")) { + if (res->is_class("Script")) { + item->set_text(1, res->get_path().get_file()); + } else if (!res->is_class("Texture")) { //texture already previews via itself EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_resource_preview_done", item->get_instance_ID()); } @@ -3989,7 +4001,7 @@ void PropertyEditor::_custom_editor_request(bool p_arrow) { int hint = d.has("hint") ? d["hint"].operator int() : -1; String hint_text = d.has("hint_text") ? d["hint_text"] : ""; Rect2 where = tree->get_custom_popup_rect(); - custom_editor->set_pos(where.pos); + custom_editor->set_position(where.pos); if (custom_editor->edit(obj, name, type, v, hint, hint_text)) { custom_editor->popup(); @@ -4097,8 +4109,8 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { custom_editor->edit(obj, n, (Variant::Type)t, v, h, ht); Rect2 where = tree->get_item_rect(ti, 1); where.pos -= tree->get_scroll(); - where.pos += tree->get_global_pos(); - custom_editor->set_pos(where.pos); + where.pos += tree->get_global_position(); + custom_editor->set_position(where.pos); custom_editor->popup(); } else if (t == Variant::STRING) { @@ -4110,8 +4122,8 @@ void PropertyEditor::_edit_button(Object *p_item, int p_column, int p_button) { Rect2 where = tree->get_item_rect(ti, 1); where.pos -= tree->get_scroll(); - where.pos += tree->get_global_pos(); - custom_editor->set_pos(where.pos); + where.pos += tree->get_global_position(); + custom_editor->set_position(where.pos); custom_editor->popup(); } else { custom_editor->popup_centered_ratio(); @@ -4389,6 +4401,7 @@ PropertyEditor::PropertyEditor() { capitalize_paths = true; autoclear = false; tree->set_column_titles_visible(false); + tree->add_constant_override("button_margin", 0); keying = false; read_only = false; diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp index ffd4d704d5..acc511e004 100644 --- a/editor/reparent_dialog.cpp +++ b/editor/reparent_dialog.cpp @@ -95,7 +95,7 @@ ReparentDialog::ReparentDialog() { tree->get_scene_tree()->connect("item_activated", this, "_reparent"); //Label *label = memnew( Label ); - //label->set_pos( Point2( 15,8) ); + //label->set_position( Point2( 15,8) ); //label->set_text("Reparent Location (Select new Parent):"); keep_transform = memnew(CheckBox); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 1a0e67e71a..69b8723431 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1112,7 +1112,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V if (node->cast_to<Spatial>()) editor_data->get_undo_redo().add_do_method(node, "set_global_transform", node->cast_to<Spatial>()->get_global_transform()); if (node->cast_to<Control>()) - editor_data->get_undo_redo().add_do_method(node, "set_global_pos", node->cast_to<Control>()->get_global_pos()); + editor_data->get_undo_redo().add_do_method(node, "set_global_position", node->cast_to<Control>()->get_global_position()); } editor_data->get_undo_redo().add_do_method(this, "_set_owners", edited_scene, owners); @@ -1154,7 +1154,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V if (node->cast_to<Spatial>()) editor_data->get_undo_redo().add_undo_method(node, "set_transform", node->cast_to<Spatial>()->get_transform()); if (node->cast_to<Control>()) - editor_data->get_undo_redo().add_undo_method(node, "set_pos", node->cast_to<Control>()->get_pos()); + editor_data->get_undo_redo().add_undo_method(node, "set_position", node->cast_to<Control>()->get_position()); } } @@ -1669,7 +1669,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_icon_shortcut(get_icon("Instance", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/instance_scene"), TOOL_INSTANCE); menu->set_size(Size2(1, 1)); - menu->set_pos(p_menu_pos); + menu->set_position(p_menu_pos); menu->popup(); return; } @@ -1710,7 +1710,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { menu->add_separator(); menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_SHORTCUT("scene_tree/delete", TTR("Delete Node(s)"), KEY_DELETE), TOOL_ERASE); menu->set_size(Size2(1, 1)); - menu->set_pos(p_menu_pos); + menu->set_position(p_menu_pos); menu->popup(); } diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index b8bbe2c832..8fd0d13b32 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -162,16 +162,16 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i //open scene request Rect2 item_rect = tree->get_item_rect(item, 0); item_rect.pos.y -= tree->get_scroll().y; - item_rect.pos += tree->get_global_pos(); + item_rect.pos += tree->get_global_position(); if (n == get_scene_node()) { - inheritance_menu->set_pos(item_rect.pos + Vector2(0, item_rect.size.y)); + inheritance_menu->set_position(item_rect.pos + Vector2(0, item_rect.size.y)); inheritance_menu->set_size(Vector2(item_rect.size.x, 0)); inheritance_menu->popup(); instance_node = n->get_instance_ID(); } else { - instance_menu->set_pos(item_rect.pos + Vector2(0, item_rect.size.y)); + instance_menu->set_position(item_rect.pos + Vector2(0, item_rect.size.y)); instance_menu->set_size(Vector2(item_rect.size.x, 0)); if (EditorNode::get_singleton()->get_edited_scene()->is_editable_instance(n)) instance_menu->set_item_checked(0, true); @@ -1103,7 +1103,7 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope if (p_label) { Label *label = memnew(Label); - label->set_pos(Point2(10, 0)); + label->set_position(Point2(10, 0)); label->set_text(TTR("Scene Tree (Nodes):")); add_child(label); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 136490eb10..4781bb6a3b 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -2021,6 +2021,131 @@ VisibilityNotifierGizmo::VisibilityNotifierGizmo(VisibilityNotifier *p_notifier) /// +String ParticlesGizmo::get_handle_name(int p_idx) const { + + switch (p_idx) { + case 0: return "Size X"; + case 1: return "Size Y"; + case 2: return "Size Z"; + case 3: return "Pos X"; + case 4: return "Pos Y"; + case 5: return "Pos Z"; + } + + return ""; +} +Variant ParticlesGizmo::get_handle_value(int p_idx) const { + + return particles->get_visibility_aabb(); +} +void ParticlesGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) { + + Transform gt = particles->get_global_transform(); + //gt.orthonormalize(); + Transform gi = gt.affine_inverse(); + + bool move = p_idx >= 3; + p_idx = p_idx % 3; + + Rect3 aabb = particles->get_visibility_aabb(); + Vector3 ray_from = p_camera->project_ray_origin(p_point); + Vector3 ray_dir = p_camera->project_ray_normal(p_point); + + Vector3 sg[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; + + Vector3 ofs = aabb.pos + aabb.size * 0.5; + + Vector3 axis; + axis[p_idx] = 1.0; + + if (move) { + + Vector3 ra, rb; + Geometry::get_closest_points_between_segments(ofs - axis * 4096, ofs + axis * 4096, sg[0], sg[1], ra, rb); + + float d = ra[p_idx]; + + aabb.pos[p_idx] = d - 1.0 - aabb.size[p_idx] * 0.5; + particles->set_visibility_aabb(aabb); + + } else { + Vector3 ra, rb; + Geometry::get_closest_points_between_segments(ofs, ofs + axis * 4096, sg[0], sg[1], ra, rb); + + float d = ra[p_idx] - ofs[p_idx]; + if (d < 0.001) + d = 0.001; + //resize + aabb.pos[p_idx] = (aabb.pos[p_idx] + aabb.size[p_idx] * 0.5) - d; + aabb.size[p_idx] = d * 2; + particles->set_visibility_aabb(aabb); + } +} + +void ParticlesGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { + + if (p_cancel) { + particles->set_visibility_aabb(p_restore); + return; + } + + UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + ur->create_action(TTR("Change Particles AABB")); + ur->add_do_method(particles, "set_custom_aabb", particles->get_visibility_aabb()); + ur->add_undo_method(particles, "set_custom_aabb", p_restore); + ur->commit_action(); +} + +void ParticlesGizmo::redraw() { + + clear(); + + Vector<Vector3> lines; + Rect3 aabb = particles->get_visibility_aabb(); + + for (int i = 0; i < 12; i++) { + Vector3 a, b; + aabb.get_edge(i, a, b); + lines.push_back(a); + lines.push_back(b); + } + + Vector<Vector3> handles; + + for (int i = 0; i < 3; i++) { + + Vector3 ax; + ax[i] = aabb.pos[i] + aabb.size[i]; + ax[(i + 1) % 3] = aabb.pos[(i + 1) % 3] + aabb.size[(i + 1) % 3] * 0.5; + ax[(i + 2) % 3] = aabb.pos[(i + 2) % 3] + aabb.size[(i + 2) % 3] * 0.5; + handles.push_back(ax); + } + + Vector3 center = aabb.pos + aabb.size * 0.5; + for (int i = 0; i < 3; i++) { + + Vector3 ax; + ax[i] = 1.0; + handles.push_back(center + ax); + lines.push_back(center); + lines.push_back(center + ax); + } + + add_lines(lines, SpatialEditorGizmos::singleton->particles_material); + add_collision_segments(lines); + //add_unscaled_billboard(SpatialEditorGizmos::singleton->visi,0.05); + add_handles(handles); +} +ParticlesGizmo::ParticlesGizmo(Particles *p_particles) { + + particles = p_particles; + set_spatial_node(p_particles); +} + +//////// + +/// + String ReflectionProbeGizmo::get_handle_name(int p_idx) const { switch (p_idx) { @@ -2938,6 +3063,12 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) { return misg; } + if (p_spatial->cast_to<Particles>()) { + + Ref<ParticlesGizmo> misg = memnew(ParticlesGizmo(p_spatial->cast_to<Particles>())); + return misg; + } + if (p_spatial->cast_to<ReflectionProbe>()) { Ref<ReflectionProbeGizmo> misg = memnew(ReflectionProbeGizmo(p_spatial->cast_to<ReflectionProbe>())); @@ -3152,6 +3283,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() { raycast_material = create_line_material(Color(1.0, 0.8, 0.6)); car_wheel_material = create_line_material(Color(0.6, 0.8, 1.0)); visibility_notifier_material = create_line_material(Color(1.0, 0.5, 1.0)); + particles_material = create_line_material(Color(1.0, 1.0, 0.5)); reflection_probe_material = create_line_material(Color(0.5, 1.0, 0.7)); reflection_probe_material_internal = create_line_material(Color(0.3, 0.8, 0.5, 0.15)); gi_probe_material = create_line_material(Color(0.7, 1.0, 0.5)); diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index 3aecc8fc02..095586ab91 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -33,22 +33,22 @@ #include "editor/plugins/spatial_editor_plugin.h" #include "scene/3d/body_shape.h" #include "scene/3d/camera.h" +#include "scene/3d/collision_polygon.h" #include "scene/3d/gi_probe.h" #include "scene/3d/light.h" #include "scene/3d/listener.h" #include "scene/3d/mesh_instance.h" #include "scene/3d/navigation_mesh.h" +#include "scene/3d/particles.h" +#include "scene/3d/physics_joint.h" #include "scene/3d/portal.h" #include "scene/3d/position_3d.h" #include "scene/3d/ray_cast.h" #include "scene/3d/reflection_probe.h" #include "scene/3d/room_instance.h" #include "scene/3d/test_cube.h" -#include "scene/3d/visibility_notifier.h" - -#include "scene/3d/collision_polygon.h" -#include "scene/3d/physics_joint.h" #include "scene/3d/vehicle_body.h" +#include "scene/3d/visibility_notifier.h" class Camera; @@ -244,6 +244,22 @@ public: VisibilityNotifierGizmo(VisibilityNotifier *p_notifier = NULL); }; +class ParticlesGizmo : public EditorSpatialGizmo { + + GDCLASS(ParticlesGizmo, EditorSpatialGizmo); + + Particles *particles; + +public: + virtual String get_handle_name(int p_idx) const; + virtual Variant get_handle_value(int p_idx) const; + virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point); + virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false); + + void redraw(); + ParticlesGizmo(Particles *p_particles = NULL); +}; + class ReflectionProbeGizmo : public EditorSpatialGizmo { GDCLASS(ReflectionProbeGizmo, EditorSpatialGizmo); @@ -420,6 +436,7 @@ public: Ref<SpatialMaterial> portal_material; Ref<SpatialMaterial> raycast_material; Ref<SpatialMaterial> visibility_notifier_material; + Ref<SpatialMaterial> particles_material; Ref<SpatialMaterial> car_wheel_material; Ref<SpatialMaterial> joint_material; |