瀏覽代碼

Ask about selecting a main scene if one has not been selected.

Juan Linietsky 9 年之前
父節點
當前提交
972c2ad09f
共有 2 個文件被更改,包括 41 次插入11 次删除
  1. 39 11
      tools/editor/editor_node.cpp
  2. 2 0
      tools/editor/editor_node.h

+ 39 - 11
tools/editor/editor_node.cpp

@@ -1161,7 +1161,11 @@ void EditorNode::_dialog_action(String p_file) {
 
 
 			load_scene(p_file);
 			load_scene(p_file);
 		} break;
 		} break;
+		case SETTINGS_PICK_MAIN_SCENE: {
 
 
+			Globals::get_singleton()->set("application/main_scene",p_file);
+			//would be nice to show the project manager opened with the hilighted field..
+		} break;
 		case FILE_SAVE_OPTIMIZED: {
 		case FILE_SAVE_OPTIMIZED: {
 
 
 
 
@@ -1850,9 +1854,8 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
 
 
 			current_option=-1;
 			current_option=-1;
 			//accept->get_cancel()->hide();
 			//accept->get_cancel()->hide();
-			accept->get_ok()->set_text(TTR("I see.."));
-			accept->set_text(TTR("No main scene has ever been defined.\nSelect one from \"Project Settings\" under the 'application' category."));
-			accept->popup_centered_minsize();
+			pick_main_scene->set_text(TTR("No main scene has ever been defined, select one?\nYou can change it later in later in \"Project Settings\" under the 'application' category."));
+			pick_main_scene->popup_centered_minsize();
 			return;
 			return;
 		}
 		}
 
 
@@ -1860,9 +1863,8 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
 
 
 			current_option=-1;
 			current_option=-1;
 			//accept->get_cancel()->hide();
 			//accept->get_cancel()->hide();
-			accept->get_ok()->set_text(TTR("I see.."));
-			accept->set_text(TTR("Selected scene '"+run_filename+"' does not exist.\nSelect one from \"Project Settings\" under the 'application' category."));
-			accept->popup_centered_minsize();
+			pick_main_scene->set_text(TTR("Selected scene '"+run_filename+"' does not exist, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."));
+			pick_main_scene->popup_centered_minsize();
 			return;
 			return;
 
 
 		}
 		}
@@ -1871,9 +1873,8 @@ void EditorNode::_run(bool p_current,const String& p_custom) {
 
 
 			current_option=-1;
 			current_option=-1;
 			//accept->get_cancel()->hide();
 			//accept->get_cancel()->hide();
-			accept->get_ok()->set_text(TTR("I see.."));
-			accept->set_text(TTR("Selected scene '"+run_filename+"' is not a scene file.\nSelect a scene from \"Project Settings\" under the 'application' category."));
-			accept->popup_centered_minsize();
+			pick_main_scene->set_text(TTR("Selected scene '"+run_filename+"' is not a scene file, select a valid one?\nYou can change it later in \"Project Settings\" under the 'application' category."));
+			pick_main_scene->popup_centered_minsize();
 			return;
 			return;
 
 
 		}
 		}
@@ -2790,6 +2791,30 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
 
 
 			file_templates->popup_centered_ratio();
 			file_templates->popup_centered_ratio();
 
 
+		} break;
+		case SETTINGS_PICK_MAIN_SCENE: {
+
+
+			//print_tree();
+			file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
+			//not for now?
+			List<String> extensions;
+			ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions);
+			file->clear_filters();
+			for(int i=0;i<extensions.size();i++) {
+
+				file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper());
+			}
+
+
+			//file->set_current_path(current_path);
+			Node *scene = editor_data.get_edited_scene_root();
+			if (scene) {
+				file->set_current_path(scene->get_filename());
+			};
+			file->set_title(TTR("Pick a Manu Scene"));
+			file->popup_centered_ratio();
+
 		} break;
 		} break;
 		case SETTINGS_ABOUT: {
 		case SETTINGS_ABOUT: {
 
 
@@ -6456,7 +6481,7 @@ EditorNode::EditorNode() {
 	load_error_dialog->add_child(load_errors);
 	load_error_dialog->add_child(load_errors);
 	load_error_dialog->set_title(TTR("Load Errors"));
 	load_error_dialog->set_title(TTR("Load Errors"));
 	load_error_dialog->set_child_rect(load_errors);
 	load_error_dialog->set_child_rect(load_errors);
-	add_child(load_error_dialog);
+	gui_base->add_child(load_error_dialog);
 
 
 	//EditorImport::add_importer( Ref<EditorImporterCollada>( memnew(EditorImporterCollada )));
 	//EditorImport::add_importer( Ref<EditorImporterCollada>( memnew(EditorImporterCollada )));
 
 
@@ -6481,7 +6506,10 @@ EditorNode::EditorNode() {
 	Node::set_human_readable_collision_renaming(true);
 	Node::set_human_readable_collision_renaming(true);
 
 
 
 
-
+	pick_main_scene = memnew( ConfirmationDialog );
+	gui_base->add_child(pick_main_scene);
+	pick_main_scene->get_ok()->set_text("Select");
+	pick_main_scene->connect("confirmed",this,"_menu_option",varray(SETTINGS_PICK_MAIN_SCENE));
 
 
 //	Ref<ImageTexture> it = gui_base->get_icon("logo","Icons");
 //	Ref<ImageTexture> it = gui_base->get_icon("logo","Icons");
 //	OS::get_singleton()->set_icon( it->get_data() );
 //	OS::get_singleton()->set_icon( it->get_data() );

+ 2 - 0
tools/editor/editor_node.h

@@ -185,6 +185,7 @@ private:
 		SETTINGS_LAYOUT_DELETE,
 		SETTINGS_LAYOUT_DELETE,
 		SETTINGS_LAYOUT_DEFAULT,
 		SETTINGS_LAYOUT_DEFAULT,
 		SETTINGS_LOAD_EXPORT_TEMPLATES,
 		SETTINGS_LOAD_EXPORT_TEMPLATES,
+		SETTINGS_PICK_MAIN_SCENE,
 		SETTINGS_HELP,
 		SETTINGS_HELP,
 		SETTINGS_ABOUT,
 		SETTINGS_ABOUT,
 		SOURCES_REIMPORT,
 		SOURCES_REIMPORT,
@@ -287,6 +288,7 @@ private:
 	ConfirmationDialog *confirmation;
 	ConfirmationDialog *confirmation;
 	ConfirmationDialog *import_confirmation;
 	ConfirmationDialog *import_confirmation;
 	ConfirmationDialog *open_recent_confirmation;
 	ConfirmationDialog *open_recent_confirmation;
+	ConfirmationDialog *pick_main_scene;
 	AcceptDialog *accept;
 	AcceptDialog *accept;
 	AcceptDialog *about;
 	AcceptDialog *about;
 	AcceptDialog *warning;
 	AcceptDialog *warning;