From bc034c1d4dbb6a5c4ceb09bb8708adfa14fe51f2 Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Mon, 7 Aug 2017 21:41:04 +0200 Subject: [PATCH] ProjectManager: Show error dialog if unable to run project. --- editor/project_manager.cpp | 27 +++++++++++++++++---------- editor/project_manager.h | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index d5a56f644fd..b77544befa9 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -491,17 +491,8 @@ void ProjectManager::_update_project_buttons() { item->update(); } - bool has_runnable_scene = false; - for (Map::Element *E = selected_list.front(); E; E = E->next()) { - const String &selected_main = E->get(); - if (selected_main == "") continue; - has_runnable_scene = true; - break; - } - erase_btn->set_disabled(selected_list.size() < 1); open_btn->set_disabled(selected_list.size() < 1); - run_btn->set_disabled(!has_runnable_scene); } void ProjectManager::_panel_input(const Ref &p_ev, Node *p_hb) { @@ -969,10 +960,22 @@ void ProjectManager::_run_project_confirm() { for (Map::Element *E = selected_list.front(); E; E = E->next()) { const String &selected_main = E->get(); - if (selected_main == "") continue; + if (selected_main == "") { + run_error_diag->set_text(TTR("Can't run project: no main scene defined.\nPlease edit the project and set the main scene in \"Project Settings\" under the \"Application\" category.")); + run_error_diag->popup_centered(); + return; + } + const String &selected = E->key(); String path = EditorSettings::get_singleton()->get("projects/" + selected); + + if (!DirAccess::exists(path + "/.import")) { + run_error_diag->set_text(TTR("Can't run project: Assets need to be imported.\nPlease edit the project to trigger the initial import.")); + run_error_diag->popup_centered(); + return; + } + print_line("OPENING: " + path + " (" + selected + ")"); List args; @@ -1390,6 +1393,10 @@ ProjectManager::ProjectManager() { last_clicked = ""; SceneTree::get_singleton()->connect("files_dropped", this, "_files_dropped"); + + run_error_diag = memnew(AcceptDialog); + gui_base->add_child(run_error_diag); + run_error_diag->set_title(TTR("Can't run project")); } ProjectManager::~ProjectManager() { diff --git a/editor/project_manager.h b/editor/project_manager.h index 27886132c59..181d3cc5d93 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -57,6 +57,7 @@ class ProjectManager : public Control { ConfirmationDialog *multi_open_ask; ConfirmationDialog *multi_run_ask; ConfirmationDialog *multi_scan_ask; + AcceptDialog *run_error_diag; NewProjectDialog *npdialog; ScrollContainer *scroll; VBoxContainer *scroll_childs;