RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo) { scene_tree_editor = p_scene_tree_editor; undo_redo = p_undo_redo; preview_node = NULL; set_title(TTR("Batch Rename")); VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); // -- Search/Replace Area GridContainer *grd_main = memnew(GridContainer); grd_main->set_columns(2); grd_main->set_v_size_flags(SIZE_EXPAND_FILL); vbc->add_child(grd_main); // ---- 1st & 2nd row Label *lbl_search = memnew(Label); lbl_search->set_text(TTR("Search")); lne_search = memnew(LineEdit); lne_search->set_placeholder(TTR("Search")); lne_search->set_name("lne_search"); lne_search->set_h_size_flags(SIZE_EXPAND_FILL); Label *lbl_replace = memnew(Label); lbl_replace->set_text(TTR("Replace")); lne_replace = memnew(LineEdit); lne_replace->set_placeholder(TTR("Replace")); lne_replace->set_name("lne_replace"); lne_replace->set_h_size_flags(SIZE_EXPAND_FILL); grd_main->add_child(lbl_search); grd_main->add_child(lbl_replace); grd_main->add_child(lne_search); grd_main->add_child(lne_replace); // ---- 3rd & 4th row Label *lbl_prefix = memnew(Label); lbl_prefix->set_text(TTR("Prefix")); lne_prefix = memnew(LineEdit); lne_prefix->set_placeholder(TTR("Prefix")); lne_prefix->set_name("lne_prefix"); lne_prefix->set_h_size_flags(SIZE_EXPAND_FILL); Label *lbl_suffix = memnew(Label); lbl_suffix->set_text(TTR("Suffix")); lne_suffix = memnew(LineEdit); lne_suffix->set_placeholder(TTR("Suffix")); lne_suffix->set_name("lne_suffix"); lne_suffix->set_h_size_flags(SIZE_EXPAND_FILL); grd_main->add_child(lbl_prefix); grd_main->add_child(lbl_suffix); grd_main->add_child(lne_prefix); grd_main->add_child(lne_suffix); // -- Feature Tabs const int feature_min_height = 160; Ref<Theme> collapse_theme = create_editor_theme(); collapse_theme->set_icon("checked", "CheckBox", collapse_theme->get_icon("GuiTreeArrowDown", "EditorIcons")); collapse_theme->set_icon("unchecked", "CheckBox", collapse_theme->get_icon("GuiTreeArrowRight", "EditorIcons")); CheckBox *chk_collapse_features = memnew(CheckBox); chk_collapse_features->set_text(TTR("Advanced options")); chk_collapse_features->set_theme(collapse_theme); chk_collapse_features->set_focus_mode(FOCUS_NONE); vbc->add_child(chk_collapse_features); tabc_features = memnew(TabContainer); tabc_features->set_tab_align(TabContainer::ALIGN_LEFT); vbc->add_child(tabc_features); // ---- Tab Substitute VBoxContainer *vbc_substitute = memnew(VBoxContainer); vbc_substitute->set_h_size_flags(SIZE_EXPAND_FILL); vbc_substitute->set_custom_minimum_size(Size2(0, feature_min_height)); vbc_substitute->set_name(TTR("Substitute")); tabc_features->add_child(vbc_substitute); cbut_substitute = memnew(CheckButton); cbut_substitute->set_text(TTR("Substitute")); vbc_substitute->add_child(cbut_substitute); GridContainer *grd_substitute = memnew(GridContainer); grd_substitute->set_columns(3); vbc_substitute->add_child(grd_substitute); // Name but_insert_name = memnew(Button); but_insert_name->set_text("NAME"); but_insert_name->set_tooltip(String("${NAME}\n") + TTR("Node name")); but_insert_name->set_focus_mode(FOCUS_NONE); but_insert_name->connect("pressed", this, "_insert_text", make_binds("${NAME}")); but_insert_name->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_name); // Parent but_insert_parent = memnew(Button); but_insert_parent->set_text("PARENT"); but_insert_parent->set_tooltip(String("${PARENT}\n") + TTR("Node's parent name, if available")); but_insert_parent->set_focus_mode(FOCUS_NONE); but_insert_parent->connect("pressed", this, "_insert_text", make_binds("${PARENT}")); but_insert_parent->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_parent); // Type but_insert_type = memnew(Button); but_insert_type->set_text("TYPE"); but_insert_type->set_tooltip(String("${TYPE}\n") + TTR("Node type")); but_insert_type->set_focus_mode(FOCUS_NONE); but_insert_type->connect("pressed", this, "_insert_text", make_binds("${TYPE}")); but_insert_type->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_type); // Scene but_insert_scene = memnew(Button); but_insert_scene->set_text("SCENE"); but_insert_scene->set_tooltip(String("${SCENE}\n") + TTR("Current scene name")); but_insert_scene->set_focus_mode(FOCUS_NONE); but_insert_scene->connect("pressed", this, "_insert_text", make_binds("${SCENE}")); but_insert_scene->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_scene); // Root but_insert_root = memnew(Button); but_insert_root->set_text("ROOT"); but_insert_root->set_tooltip(String("${ROOT}\n") + TTR("Root node name")); but_insert_root->set_focus_mode(FOCUS_NONE); but_insert_root->connect("pressed", this, "_insert_text", make_binds("${ROOT}")); but_insert_root->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_root); // Count but_insert_count = memnew(Button); but_insert_count->set_text("COUNTER"); but_insert_count->set_tooltip(String("${COUNTER}\n") + TTR("Sequential integer counter.\nCompare counter options.")); but_insert_count->set_focus_mode(FOCUS_NONE); but_insert_count->connect("pressed", this, "_insert_text", make_binds("${COUNTER}")); but_insert_count->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_count); chk_per_level_counter = memnew(CheckBox); chk_per_level_counter->set_text(TTR("Per Level counter")); chk_per_level_counter->set_tooltip(TTR("If set the counter restarts for each group of child nodes")); vbc_substitute->add_child(chk_per_level_counter); HBoxContainer *hbc_count_options = memnew(HBoxContainer); vbc_substitute->add_child(hbc_count_options); Label *lbl_count_start = memnew(Label); lbl_count_start->set_text(TTR("Start")); lbl_count_start->set_tooltip(TTR("Initial value for the counter")); hbc_count_options->add_child(lbl_count_start); spn_count_start = memnew(SpinBox); spn_count_start->set_tooltip(TTR("Initial value for the counter")); spn_count_start->set_step(1); spn_count_start->set_min(0); hbc_count_options->add_child(spn_count_start); Label *lbl_count_step = memnew(Label); lbl_count_step->set_text(TTR("Step")); lbl_count_step->set_tooltip(TTR("Ammount by which counter is incremented for each node")); hbc_count_options->add_child(lbl_count_step); spn_count_step = memnew(SpinBox); spn_count_step->set_tooltip(TTR("Ammount by which counter is incremented for each node")); spn_count_step->set_step(1); hbc_count_options->add_child(spn_count_step); Label *lbl_count_padding = memnew(Label); lbl_count_padding->set_text(TTR("Padding")); lbl_count_padding->set_tooltip(TTR("Minium number of digits for the counter.\nMissing digits are padded with leading zeros.")); hbc_count_options->add_child(lbl_count_padding); spn_count_padding = memnew(SpinBox); spn_count_padding->set_tooltip(TTR("Minium number of digits for the counter.\nMissing digits are padded with leading zeros.")); spn_count_padding->set_step(1); hbc_count_options->add_child(spn_count_padding); // ---- Tab RegEx VBoxContainer *vbc_regex = memnew(VBoxContainer); vbc_regex->set_h_size_flags(SIZE_EXPAND_FILL); vbc_regex->set_name(TTR("Regular Expressions")); vbc_regex->set_custom_minimum_size(Size2(0, feature_min_height)); tabc_features->add_child(vbc_regex); cbut_regex = memnew(CheckButton); cbut_regex->set_text(TTR("Regular Expressions")); vbc_regex->add_child(cbut_regex); // ---- Tab Process VBoxContainer *vbc_process = memnew(VBoxContainer); vbc_process->set_h_size_flags(SIZE_EXPAND_FILL); vbc_process->set_name(TTR("Post-Process")); vbc_process->set_custom_minimum_size(Size2(0, feature_min_height)); tabc_features->add_child(vbc_process); cbut_process = memnew(CheckButton); cbut_process->set_text(TTR("Post-Process")); vbc_process->add_child(cbut_process); // ------ Style HBoxContainer *hbc_style = memnew(HBoxContainer); vbc_process->add_child(hbc_style); Label *lbl_style = memnew(Label); lbl_style->set_text(TTR("Style")); hbc_style->add_child(lbl_style); opt_style = memnew(OptionButton); opt_style->add_item(TTR("Keep")); opt_style->add_item(TTR("CamelCase to under_scored")); opt_style->add_item(TTR("under_scored to CamelCase")); hbc_style->add_child(opt_style); // ------ Case HBoxContainer *hbc_case = memnew(HBoxContainer); vbc_process->add_child(hbc_case); Label *lbl_case = memnew(Label); lbl_case->set_text(TTR("Case")); hbc_case->add_child(lbl_case); opt_case = memnew(OptionButton); opt_case->add_item(TTR("Keep")); opt_case->add_item(TTR("To Lowercase")); opt_case->add_item(TTR("To Uppercase")); hbc_case->add_child(opt_case); // -- Preview HSeparator *sep_preview = memnew(HSeparator); sep_preview->set_custom_minimum_size(Size2(10, 20)); vbc->add_child(sep_preview); lbl_preview_title = memnew(Label); lbl_preview_title->set_text(TTR("Preview")); vbc->add_child(lbl_preview_title); lbl_preview = memnew(Label); lbl_preview->set_text(""); lbl_preview->add_color_override("font_color", Color(1, 0.5f, 0, 1)); vbc->add_child(lbl_preview); // ---- Dialog related set_custom_minimum_size(Size2(383, 0)); set_as_toplevel(true); get_ok()->set_text(TTR("Rename")); Button *but_reset = add_button(TTR("Reset")); eh.errfunc = _error_handler; eh.userdata = this; // ---- Connections chk_collapse_features->connect("toggled", this, "_features_toggled"); // Substitite Buttons lne_search->connect("focus_entered", this, "_update_substitute"); lne_search->connect("focus_exited", this, "_update_substitute"); lne_replace->connect("focus_entered", this, "_update_substitute"); lne_replace->connect("focus_exited", this, "_update_substitute"); lne_prefix->connect("focus_entered", this, "_update_substitute"); lne_prefix->connect("focus_exited", this, "_update_substitute"); lne_suffix->connect("focus_entered", this, "_update_substitute"); lne_suffix->connect("focus_exited", this, "_update_substitute"); // Preview lne_prefix->connect("text_changed", this, "_update_preview"); lne_suffix->connect("text_changed", this, "_update_preview"); lne_search->connect("text_changed", this, "_update_preview"); lne_replace->connect("text_changed", this, "_update_preview"); spn_count_start->connect("value_changed", this, "_update_preview_int"); spn_count_step->connect("value_changed", this, "_update_preview_int"); spn_count_padding->connect("value_changed", this, "_update_preview_int"); opt_style->connect("item_selected", this, "_update_preview_int"); opt_case->connect("item_selected", this, "_update_preview_int"); cbut_substitute->connect("pressed", this, "_update_preview", varray("")); cbut_regex->connect("pressed", this, "_update_preview", varray("")); cbut_process->connect("pressed", this, "_update_preview", varray("")); but_reset->connect("pressed", this, "reset"); reset(); _features_toggled(false); }
ProjectManager::ProjectManager() { // load settings if (!EditorSettings::get_singleton()) EditorSettings::create(); EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came { int dpi_mode = EditorSettings::get_singleton()->get("global/hidpi_mode"); if (dpi_mode==0) { editor_set_scale( OS::get_singleton()->get_screen_dpi(0) > 150 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x>2000 ? 2.0 : 1.0 ); } else if (dpi_mode==1) { editor_set_scale(0.75); } else if (dpi_mode==2) { editor_set_scale(1.0); } else if (dpi_mode==3) { editor_set_scale(1.5); } else if (dpi_mode==4) { editor_set_scale(2.0); } } FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); set_area_as_parent_rect(); set_theme(create_editor_theme()); gui_base = memnew( Control ); add_child(gui_base); gui_base->set_area_as_parent_rect(); gui_base->set_theme(create_custom_theme()); Panel *panel = memnew( Panel ); gui_base->add_child(panel); panel->set_area_as_parent_rect(); VBoxContainer *vb = memnew( VBoxContainer ); panel->add_child(vb); vb->set_area_as_parent_rect(20*EDSCALE); vb->set_margin(MARGIN_TOP,4*EDSCALE); vb->set_margin(MARGIN_BOTTOM,4*EDSCALE); vb->add_constant_override("separation",15*EDSCALE); String cp; cp.push_back(0xA9); cp.push_back(0); OS::get_singleton()->set_window_title(_MKSTR(VERSION_NAME)+String(" - ")+TTR("Project Manager")+" - "+cp+" 2008-2016 Juan Linietsky, Ariel Manzur."); HBoxContainer *top_hb = memnew( HBoxContainer); vb->add_child(top_hb); CenterContainer *ccl = memnew( CenterContainer ); Label *l = memnew( Label ); l->set_text(_MKSTR(VERSION_NAME)+String(" - ")+TTR("Project Manager")); l->add_font_override("font", gui_base->get_font("doc","EditorFonts")); ccl->add_child(l); top_hb->add_child(ccl); top_hb->add_spacer(); l = memnew( Label ); l->set_text("v" VERSION_MKSTRING); //l->add_font_override("font",get_font("bold","Fonts")); l->set_align(Label::ALIGN_CENTER); top_hb->add_child(l); //vb->add_child(memnew(HSeparator)); //vb->add_margin_child("\n",memnew(Control)); tabs = memnew( TabContainer ); vb->add_child(tabs); tabs->set_v_size_flags(SIZE_EXPAND_FILL); HBoxContainer *tree_hb = memnew( HBoxContainer); projects_hb = tree_hb; projects_hb->set_name(TTR("Project List")); tabs->add_child(tree_hb); VBoxContainer *search_tree_vb = memnew(VBoxContainer); search_tree_vb->set_h_size_flags(SIZE_EXPAND_FILL); tree_hb->add_child(search_tree_vb); HBoxContainer *search_box = memnew(HBoxContainer); search_box->add_spacer(true); project_filter = memnew(ProjectListFilter); search_box->add_child(project_filter); project_filter->connect("filter_changed", this, "_load_recent_projects"); project_filter->set_custom_minimum_size(Size2(250,10)); search_tree_vb->add_child(search_box); PanelContainer *pc = memnew( PanelContainer); pc->add_style_override("panel", gui_base->get_stylebox("bg","Tree")); search_tree_vb->add_child(pc); pc->set_v_size_flags(SIZE_EXPAND_FILL); scroll = memnew( ScrollContainer ); pc->add_child(scroll); scroll->set_enable_h_scroll(false); VBoxContainer *tree_vb = memnew( VBoxContainer); tree_hb->add_child(tree_vb); scroll_childs = memnew( VBoxContainer ); scroll_childs->set_h_size_flags(SIZE_EXPAND_FILL); scroll->add_child(scroll_childs); //HBoxContainer *hb = memnew( HBoxContainer ); //vb->add_child(hb); Button *open = memnew( Button ); open->set_text(TTR("Edit")); tree_vb->add_child(open); open->connect("pressed", this,"_open_project"); open_btn=open; Button *run = memnew( Button ); run->set_text(TTR("Run")); tree_vb->add_child(run); run->connect("pressed", this,"_run_project"); run_btn=run; tree_vb->add_child(memnew( HSeparator )); Button *scan = memnew( Button ); scan->set_text(TTR("Scan")); tree_vb->add_child(scan); scan->connect("pressed", this,"_scan_projects"); tree_vb->add_child(memnew( HSeparator )); scan_dir = memnew( FileDialog ); scan_dir->set_access(FileDialog::ACCESS_FILESYSTEM); scan_dir->set_mode(FileDialog::MODE_OPEN_DIR); scan_dir->set_title(TTR("Select a Folder to Scan")); // must be after mode or it's overridden scan_dir->set_current_dir( EditorSettings::get_singleton()->get("global/default_project_path") ); gui_base->add_child(scan_dir); scan_dir->connect("dir_selected",this,"_scan_begin"); Button* create = memnew( Button ); create->set_text(TTR("New Project")); tree_vb->add_child(create); create->connect("pressed", this,"_new_project"); Button* import = memnew( Button ); import->set_text(TTR("Import")); tree_vb->add_child(import); import->connect("pressed", this,"_import_project"); Button* erase = memnew( Button ); erase->set_text(TTR("Remove")); tree_vb->add_child(erase); erase->connect("pressed", this,"_erase_project"); erase_btn=erase; tree_vb->add_spacer(); if (StreamPeerSSL::is_available()) { asset_library = memnew( EditorAssetLibrary(true) ); asset_library->set_name("Templates"); tabs->add_child(asset_library); asset_library->connect("install_asset",this,"_install_project"); } else { WARN_PRINT("Asset Library not available, as it requires SSL to work."); } CenterContainer *cc = memnew( CenterContainer ); Button * cancel = memnew( Button ); cancel->set_text(TTR("Exit")); cancel->set_custom_minimum_size(Size2(100,1)*EDSCALE); cc->add_child(cancel); cancel->connect("pressed", this,"_exit_dialog"); vb->add_child(cc); // erase_ask = memnew( ConfirmationDialog ); erase_ask->get_ok()->set_text(TTR("Remove")); erase_ask->get_ok()->connect("pressed", this,"_erase_project_confirm"); gui_base->add_child(erase_ask); multi_open_ask = memnew( ConfirmationDialog ); multi_open_ask->get_ok()->set_text(TTR("Edit")); multi_open_ask->get_ok()->connect("pressed", this, "_open_project_confirm"); gui_base->add_child(multi_open_ask); multi_run_ask = memnew( ConfirmationDialog ); multi_run_ask->get_ok()->set_text(TTR("Run")); multi_run_ask->get_ok()->connect("pressed", this, "_run_project_confirm"); gui_base->add_child(multi_run_ask); multi_scan_ask = memnew( ConfirmationDialog ); multi_scan_ask->get_ok()->set_text(TTR("Scan")); gui_base->add_child(multi_scan_ask); OS::get_singleton()->set_low_processor_usage_mode(true); npdialog = memnew( NewProjectDialog ); gui_base->add_child(npdialog); npdialog->connect("project_created", this,"_load_recent_projects"); _load_recent_projects(); if ( EditorSettings::get_singleton()->get("global/autoscan_project_path") ) { _scan_begin( EditorSettings::get_singleton()->get("global/autoscan_project_path") ); } //get_ok()->set_text("Open"); //get_ok()->set_text("Exit"); last_clicked = ""; SceneTree::get_singleton()->connect("files_dropped", this, "_files_dropped"); }