summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorvolzhs <volzhs@gmail.com>2016-11-08 03:39:05 +0900
committervolzhs <volzhs@gmail.com>2016-11-08 03:39:05 +0900
commitb8f80e94509b0e6fe9a2fa8a8b4f78ba668f5492 (patch)
tree58f08cae7a4dfaabac7903904ebab85612504ebd /tools
parentcdc4664226cdc397d054b7390d0f75028d40412c (diff)
Select newly created or imported project automatically
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/project_manager.cpp45
-rw-r--r--tools/editor/project_manager.h2
2 files changed, 45 insertions, 2 deletions
diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp
index 1c99982155..ee0169027b 100644
--- a/tools/editor/project_manager.cpp
+++ b/tools/editor/project_manager.cpp
@@ -335,7 +335,7 @@ private:
hide();
- emit_signal("project_created");
+ emit_signal("project_created", dir);
}
@@ -882,6 +882,7 @@ void ProjectManager::_load_recent_projects() {
hb->add_child(tf);
VBoxContainer *vb = memnew(VBoxContainer);
+ vb->set_name("project");
hb->add_child(vb);
Control *ec = memnew( Control );
ec->set_custom_minimum_size(Size2(0,1));
@@ -891,6 +892,7 @@ void ProjectManager::_load_recent_projects() {
title->add_color_override("font_color",font_color);
vb->add_child(title);
Label *fpath = memnew( Label(path) );
+ fpath->set_name("path");
vb->add_child(fpath);
fpath->set_opacity(0.5);
fpath->add_color_override("font_color",font_color);
@@ -912,6 +914,43 @@ void ProjectManager::_load_recent_projects() {
tabs->set_current_tab(0);
}
+void ProjectManager::_on_project_created(const String& dir) {
+ bool has_already=false;
+ for (int i=0;i<scroll_childs->get_child_count();i++) {
+ HBoxContainer *hb=scroll_childs->get_child(i)->cast_to<HBoxContainer>();
+ Label *fpath=hb->get_node(NodePath("project/path"))->cast_to<Label>();
+ if (fpath->get_text()==dir) {
+ has_already=true;
+ break;
+ }
+ }
+ if (has_already) {
+ _update_scroll_pos(dir);
+ } else {
+ _load_recent_projects();
+ scroll->connect("draw", this, "_update_scroll_pos", varray(dir), CONNECT_ONESHOT);
+ }
+}
+
+void ProjectManager::_update_scroll_pos(const String& dir) {
+ for (int i=0;i<scroll_childs->get_child_count();i++) {
+ HBoxContainer *hb=scroll_childs->get_child(i)->cast_to<HBoxContainer>();
+ Label *fpath=hb->get_node(NodePath("project/path"))->cast_to<Label>();
+ if (fpath->get_text()==dir) {
+ last_clicked=hb->get_meta("name");
+ selected_list.clear();
+ 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;
+
+ if (offset_diff>0)
+ scroll->set_v_scroll(scroll->get_v_scroll()+offset_diff);
+ break;
+ }
+ }
+}
+
void ProjectManager::_open_project_confirm() {
for (Map<String,String>::Element *E=selected_list.front(); E; E=E->next()) {
@@ -1164,6 +1203,8 @@ void ProjectManager::_bind_methods() {
ObjectTypeDB::bind_method("_erase_project_confirm",&ProjectManager::_erase_project_confirm);
ObjectTypeDB::bind_method("_exit_dialog",&ProjectManager::_exit_dialog);
ObjectTypeDB::bind_method("_load_recent_projects",&ProjectManager::_load_recent_projects);
+ ObjectTypeDB::bind_method("_on_project_created",&ProjectManager::_on_project_created);
+ ObjectTypeDB::bind_method("_update_scroll_pos",&ProjectManager::_update_scroll_pos);
ObjectTypeDB::bind_method("_panel_draw",&ProjectManager::_panel_draw);
ObjectTypeDB::bind_method("_panel_input",&ProjectManager::_panel_input);
ObjectTypeDB::bind_method("_unhandled_input",&ProjectManager::_unhandled_input);
@@ -1382,7 +1423,7 @@ ProjectManager::ProjectManager() {
npdialog = memnew( NewProjectDialog );
gui_base->add_child(npdialog);
- npdialog->connect("project_created", this,"_load_recent_projects");
+ npdialog->connect("project_created", this,"_on_project_created");
_load_recent_projects();
if ( EditorSettings::get_singleton()->get("global/autoscan_project_path") ) {
diff --git a/tools/editor/project_manager.h b/tools/editor/project_manager.h
index 46f7aea3a5..af2d47aeb3 100644
--- a/tools/editor/project_manager.h
+++ b/tools/editor/project_manager.h
@@ -85,6 +85,8 @@ class ProjectManager : public Control {
void _scan_begin(const String& p_base);
void _load_recent_projects();
+ void _on_project_created(const String& dir);
+ void _update_scroll_pos(const String& dir);
void _scan_dir(DirAccess *da,float pos, float total,List<String> *r_projects);
void _install_project(const String& p_zip_path,const String& p_title);