Skip to content

Commit

Permalink
Add --import command-line flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mihe authored and dreed-sd committed Apr 18, 2024
1 parent 92c4a15 commit a345e60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions editor/editor_file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class EditorFileSystem : public Node {
EditorFileSystemDirectory *get_filesystem();
bool is_scanning() const;
bool is_importing() const { return importing; }
bool doing_first_scan() const { return first_scan; }
float get_scanning_progress() const;
void scan();
void scan_changes();
Expand Down
16 changes: 15 additions & 1 deletion main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
#include "editor/debugger/editor_debugger_node.h"
#include "editor/doc_data_class_path.gen.h"
#include "editor/doc_tools.h"
#include "editor/editor_file_system.h"
#include "editor/editor_help.h"
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
Expand Down Expand Up @@ -179,6 +180,7 @@ static OS::ProcessID editor_pid = 0;
static bool found_project = false;
static bool auto_build_solutions = false;
static String debug_server_uri;
static bool wait_for_import = false;
#ifndef DISABLE_DEPRECATED
static int converter_max_kb_file = 4 * 1024; // 4MB
static int converter_max_line_length = 100000;
Expand Down Expand Up @@ -510,6 +512,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" The target directory must exist.\n");
OS::get_singleton()->print(" --export-debug <preset> <path> Export the project in debug mode using the given preset and output path. See --export-release description for other considerations.\n");
OS::get_singleton()->print(" --export-pack <preset> <path> Export the project data only using the given preset and output path. The <path> extension determines whether it will be in PCK or ZIP format.\n");
OS::get_singleton()->print(" --import Starts the editor, waits for any resources to be imported, and then quits.\n");
#ifndef DISABLE_DEPRECATED
OS::get_singleton()->print(" --convert-3to4 [<max_file_kb>] [<max_line_size>]\n");
OS::get_singleton()->print(" Converts project from Godot 3.x to Godot 4.x.\n");
Expand Down Expand Up @@ -1290,12 +1293,17 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->print("Missing file to load argument after --validate-extension-api, aborting.");
goto error;
}

} else if (I->get() == "--import") {
editor = true;
cmdline_tool = true;
wait_for_import = true;
quit_after = 1;
} else if (I->get() == "--export-release" || I->get() == "--export-debug" ||
I->get() == "--export-pack") { // Export project
// Actually handling is done in start().
editor = true;
cmdline_tool = true;
wait_for_import = true;
main_args.push_back(I->get());
#ifndef DISABLE_DEPRECATED
} else if (I->get() == "--export") { // For users used to 3.x syntax.
Expand Down Expand Up @@ -3702,6 +3710,12 @@ bool Main::iteration() {
exit = true;
}

#ifdef TOOLS_ENABLED
if (wait_for_import && EditorFileSystem::get_singleton()->doing_first_scan()) {
exit = false;
}
#endif

if (fixed_fps != -1) {
return exit;
}
Expand Down

0 comments on commit a345e60

Please sign in to comment.