diff options
Diffstat (limited to 'main/main.cpp')
| -rw-r--r-- | main/main.cpp | 117 | 
1 files changed, 63 insertions, 54 deletions
diff --git a/main/main.cpp b/main/main.cpp index e9b06f6b07..d67761db55 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -365,7 +365,7 @@ void Main::print_help(const char *p_binary) {  	OS::get_singleton()->print("                                               <path> should be absolute or relative to the project directory, and include the filename for the binary (e.g. 'builds/game.exe'). The target directory should exist.\n");  	OS::get_singleton()->print("  --export-debug <preset> <path>               Same as --export, but using the debug template.\n");  	OS::get_singleton()->print("  --export-pack <preset> <path>                Same as --export, but only export the game pack for the given preset. The <path> extension determines whether it will be in PCK or ZIP format.\n"); -	OS::get_singleton()->print("  --doctool <path>                             Dump the engine API reference to the given <path> in XML format, merging if existing files are found.\n"); +	OS::get_singleton()->print("  --doctool [<path>]                           Dump the engine API reference to the given <path> (defaults to current dir) in XML format, merging if existing files are found.\n");  	OS::get_singleton()->print("  --no-docbase                                 Disallow dumping the base types (used with --doctool).\n");  	OS::get_singleton()->print("  --build-solutions                            Build the scripting solutions (e.g. for C# projects). Implies --editor and requires a valid project to edit.\n");  #ifdef DEBUG_METHODS_ENABLED @@ -375,8 +375,8 @@ void Main::print_help(const char *p_binary) {  #ifdef TESTS_ENABLED  	OS::get_singleton()->print("  --test [--help]                              Run unit tests. Use --test --help for more information.\n");  #endif -	OS::get_singleton()->print("\n");  #endif +	OS::get_singleton()->print("\n");  }  #ifdef TESTS_ENABLED @@ -390,6 +390,8 @@ Error Main::test_setup() {  	register_core_types();  	register_core_driver_types(); +	packed_data = memnew(PackedData); +  	globals = memnew(ProjectSettings);  	GLOBAL_DEF("debug/settings/crash_handler/message", @@ -459,6 +461,9 @@ void Main::test_cleanup() {  	if (globals) {  		memdelete(globals);  	} +	if (packed_data) { +		memdelete(packed_data); +	}  	if (engine) {  		memdelete(engine);  	} @@ -529,7 +534,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph  	input_map = memnew(InputMap);  	globals = memnew(ProjectSettings); -	register_core_settings(); //here globals is present +	register_core_settings(); //here globals are present  	translation_server = memnew(TranslationServer);  	performance = memnew(Performance); @@ -538,8 +543,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph  	// Only flush stdout in debug builds by default, as spamming `print()` will  	// decrease performance if this is enabled. -	GLOBAL_DEF("application/run/flush_stdout_on_print", false); -	GLOBAL_DEF("application/run/flush_stdout_on_print.debug", true); +	GLOBAL_DEF_RST("application/run/flush_stdout_on_print", false); +	GLOBAL_DEF_RST("application/run/flush_stdout_on_print.debug", true);  	GLOBAL_DEF("debug/settings/crash_handler/message",  			String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues")); @@ -1174,6 +1179,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph  		_print_line_enabled = false;  	} +	Logger::set_flush_stdout_on_print(ProjectSettings::get_singleton()->get("application/run/flush_stdout_on_print")); +  	OS::get_singleton()->set_cmdline(execpath, main_args);  	GLOBAL_DEF("rendering/driver/driver_name", "Vulkan"); @@ -1246,6 +1253,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph  	}  	GLOBAL_DEF("internationalization/rendering/force_right_to_left_layout_direction", false); +	GLOBAL_DEF("internationalization/locale/include_text_server_data", false);  	if (!force_lowdpi) {  		OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", false); @@ -1319,23 +1327,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph  	}  	{ -		String orientation = GLOBAL_DEF("display/window/handheld/orientation", "landscape"); - -		if (orientation == "portrait") { -			window_orientation = DisplayServer::SCREEN_PORTRAIT; -		} else if (orientation == "reverse_landscape") { -			window_orientation = DisplayServer::SCREEN_REVERSE_LANDSCAPE; -		} else if (orientation == "reverse_portrait") { -			window_orientation = DisplayServer::SCREEN_REVERSE_PORTRAIT; -		} else if (orientation == "sensor_landscape") { -			window_orientation = DisplayServer::SCREEN_SENSOR_LANDSCAPE; -		} else if (orientation == "sensor_portrait") { -			window_orientation = DisplayServer::SCREEN_SENSOR_PORTRAIT; -		} else if (orientation == "sensor") { -			window_orientation = DisplayServer::SCREEN_SENSOR; -		} else { -			window_orientation = DisplayServer::SCREEN_LANDSCAPE; -		} +		window_orientation = DisplayServer::ScreenOrientation(int(GLOBAL_DEF_BASIC("display/window/handheld/orientation", DisplayServer::ScreenOrientation::SCREEN_LANDSCAPE)));  	}  	Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF_BASIC("physics/common/physics_fps", 60)); @@ -1453,6 +1445,12 @@ Error Main::setup2(Thread::ID p_main_tid_override) {  	}  #endif +#ifdef TOOLS_ENABLED +	if (editor || project_manager) { +		EditorNode::register_editor_paths(project_manager); +	} +#endif +  	/* Determine text driver */  	if (text_driver == "") { @@ -1515,7 +1513,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {  	input = memnew(Input); -	/* Iniitalize Display Server */ +	/* Initialize Display Server */  	{  		String rendering_driver; // temp broken @@ -1545,12 +1543,12 @@ Error Main::setup2(Thread::ID p_main_tid_override) {  		display_server->screen_set_orientation(window_orientation);  	} -	/* Initialize Pen Table Driver */ +	/* Initialize Pen Tablet Driver */  	{  		GLOBAL_DEF_RST_NOVAL("input_devices/pen_tablet/driver", ""); -		GLOBAL_DEF_RST_NOVAL("input_devices/pen_tablet/driver.windows", ""); -		ProjectSettings::get_singleton()->set_custom_property_info("input_devices/pen_tablet/driver.windows", PropertyInfo(Variant::STRING, "input_devices/pen_tablet/driver.windows", PROPERTY_HINT_ENUM, "wintab,winink")); +		GLOBAL_DEF_RST_NOVAL("input_devices/pen_tablet/driver.Windows", ""); +		ProjectSettings::get_singleton()->set_custom_property_info("input_devices/pen_tablet/driver.Windows", PropertyInfo(Variant::STRING, "input_devices/pen_tablet/driver.Windows", PROPERTY_HINT_ENUM, "wintab,winink"));  	}  	if (tablet_driver == "") { // specified in project.godot @@ -1660,7 +1658,13 @@ Error Main::setup2(Thread::ID p_main_tid_override) {  			}  		} -		Color boot_bg_color = GLOBAL_DEF("application/boot_splash/bg_color", boot_splash_bg_color); +#if defined(TOOLS_ENABLED) && !defined(NO_EDITOR_SPLASH) +		const Color boot_bg_color = +				GLOBAL_DEF("application/boot_splash/bg_color", +						(editor || project_manager) ? boot_splash_editor_bg_color : boot_splash_bg_color); +#else +		const Color boot_bg_color = GLOBAL_DEF("application/boot_splash/bg_color", boot_splash_bg_color); +#endif  		if (boot_logo.is_valid()) {  			RenderingServer::get_singleton()->set_boot_image(boot_logo, boot_bg_color, boot_logo_scale,  					boot_logo_filter); @@ -1742,6 +1746,19 @@ Error Main::setup2(Thread::ID p_main_tid_override) {  	register_scene_types(); +#ifdef TOOLS_ENABLED +	ClassDB::set_current_api(ClassDB::API_EDITOR); +	EditorNode::register_editor_types(); + +	ClassDB::set_current_api(ClassDB::API_CORE); + +#endif + +	MAIN_PRINT("Main: Load Modules, Physics, Drivers, Scripts"); + +	register_platform_apis(); +	register_module_types(); +  	GLOBAL_DEF("display/mouse_cursor/custom_image", String());  	GLOBAL_DEF("display/mouse_cursor/custom_image_hotspot", Vector2());  	GLOBAL_DEF("display/mouse_cursor/tooltip_position_offset", Point2(10, 10)); @@ -1758,18 +1775,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {  			Input::get_singleton()->set_custom_mouse_cursor(cursor, Input::CURSOR_ARROW, hotspot);  		}  	} -#ifdef TOOLS_ENABLED -	ClassDB::set_current_api(ClassDB::API_EDITOR); -	EditorNode::register_editor_types(); - -	ClassDB::set_current_api(ClassDB::API_CORE); - -#endif - -	MAIN_PRINT("Main: Load Modules, Physics, Drivers, Scripts"); - -	register_platform_apis(); -	register_module_types();  	camera_server = CameraServer::create(); @@ -1793,7 +1798,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {  	if (!project_manager) {  		// If not running the project manager, and now that the engine is  		// able to load resources, load the global shader variables. -		// If running on editor, dont load the textures because the editor +		// If running on editor, don't load the textures because the editor  		// may want to import them first. Editor will reload those later.  		rendering_server->global_variables_load_settings(!editor);  	} @@ -1801,7 +1806,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {  	_start_success = true;  	locale = String(); -	ClassDB::set_current_api(ClassDB::API_NONE); //no more api is registered at this point +	ClassDB::set_current_api(ClassDB::API_NONE); //no more APIs are registered at this point  	print_verbose("CORE API HASH: " + uitos(ClassDB::get_api_hash(ClassDB::API_CORE)));  	print_verbose("EDITOR API HASH: " + uitos(ClassDB::get_api_hash(ClassDB::API_EDITOR))); @@ -1817,8 +1822,7 @@ bool Main::start() {  	ERR_FAIL_COND_V(!_start_success, false);  	bool hasicon = false; -	String doc_tool; -	List<String> removal_docs; +	String doc_tool_path;  	String positional_arg;  	String game_path;  	String script; @@ -1872,9 +1876,11 @@ bool Main::start() {  				script = args[i + 1];  #ifdef TOOLS_ENABLED  			} else if (args[i] == "--doctool") { -				doc_tool = args[i + 1]; -				for (int j = i + 2; j < args.size(); j++) { -					removal_docs.push_back(args[j]); +				doc_tool_path = args[i + 1]; +				if (doc_tool_path.begins_with("-")) { +					// Assuming other command line arg, so default to cwd. +					doc_tool_path = "."; +					parsed_pair = false;  				}  			} else if (args[i] == "--export") {  				editor = true; //needs editor @@ -1895,16 +1901,19 @@ bool Main::start() {  			if (parsed_pair) {  				i++;  			} +		} else if (args[i] == "--doctool") { +			// Handle case where no path is given to --doctool. +			doc_tool_path = ".";  		}  	}  #ifdef TOOLS_ENABLED -	if (doc_tool != "") { +	if (doc_tool_path != "") {  		Engine::get_singleton()->set_editor_hint(  				true); // Needed to instance editor-only classes for their default values  		{ -			DirAccessRef da = DirAccess::open(doc_tool); +			DirAccessRef da = DirAccess::open(doc_tool_path);  			ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a valid directory path.");  		} @@ -1934,7 +1943,7 @@ bool Main::start() {  			// Custom modules are always located by absolute path.  			String path = _doc_data_class_paths[i].path;  			if (path.is_rel_path()) { -				path = doc_tool.plus_file(path); +				path = doc_tool_path.plus_file(path);  			}  			String name = _doc_data_class_paths[i].name;  			doc_data_classes[name] = path; @@ -1951,7 +1960,7 @@ bool Main::start() {  			}  		} -		String index_path = doc_tool.plus_file("doc/classes"); +		String index_path = doc_tool_path.plus_file("doc/classes");  		// Create the main documentation directory if it doesn't exist  		DirAccess *da = DirAccess::create_for_path(index_path);  		da->make_dir_recursive(index_path); @@ -2233,7 +2242,7 @@ bool Main::start() {  			ProjectSettings::get_singleton()->set_custom_property_info(  					"rendering/textures/canvas_textures/default_texture_filter",  					PropertyInfo(Variant::INT, "rendering/textures/canvas_textures/default_texture_filter", PROPERTY_HINT_ENUM, -							"Nearest,Linear,MipmapLinear,MipmapNearest")); +							"Nearest,Linear,Linear Mipmap,Nearest Mipmap"));  			GLOBAL_DEF_BASIC("rendering/textures/canvas_textures/default_texture_repeat", 0);  			ProjectSettings::get_singleton()->set_custom_property_info(  					"rendering/textures/canvas_textures/default_texture_repeat", @@ -2524,10 +2533,10 @@ bool Main::iteration() {  	if (frame > 1000000) {  		if (editor || project_manager) {  			if (print_fps) { -				print_line("Editor FPS: " + itos(frames)); +				print_line(vformat("Editor FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(1)));  			}  		} else if (GLOBAL_GET("debug/settings/stdout/print_fps") || print_fps) { -			print_line("Game FPS: " + itos(frames)); +			print_line(vformat("Project FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(1)));  		}  		Engine::get_singleton()->_fps = frames; @@ -2603,7 +2612,7 @@ void Main::cleanup(bool p_force) {  	// Sync pending commands that may have been queued from a different thread during ScriptServer finalization  	RenderingServer::get_singleton()->sync(); -	//clear global shader variables before scene and other graphics stuff is deinitialized. +	//clear global shader variables before scene and other graphics stuff are deinitialized.  	rendering_server->global_variables_clear();  #ifdef TOOLS_ENABLED  |