コード例 #1
0
ファイル: main.cpp プロジェクト: BradWBeer/godot
Error Main::setup2() {


	OS::get_singleton()->initialize(video_mode,video_driver_idx,audio_driver_idx);
	if (init_use_custom_pos) {
		OS::get_singleton()->set_window_position(init_custom_pos);
	}


	register_core_singletons();

	MAIN_PRINT("Main: Setup Logo");

	bool show_logo=true;
#ifdef JAVASCRIPT_ENABLED
	show_logo=false;
#endif

	if (init_screen!=-1) {
		OS::get_singleton()->set_current_screen(init_screen);
	}
	if (init_windowed) {
		//do none..
	} else if (init_maximized) {
		OS::get_singleton()->set_window_maximized(true);
	} else if (init_fullscreen) {
		OS::get_singleton()->set_window_fullscreen(true);
	}
	MAIN_PRINT("Main: Load Remaps");

	path_remap->load_remaps();

	if (show_logo) { //boot logo!
		String boot_logo_path=GLOBAL_DEF("application/boot_splash",String());
		bool boot_logo_scale=GLOBAL_DEF("application/boot_splash_fullsize",true);
		Globals::get_singleton()->set_custom_property_info("application/boot_splash",PropertyInfo(Variant::STRING,"application/boot_splash",PROPERTY_HINT_FILE,"*.png"));

		Image boot_logo;

		boot_logo_path = boot_logo_path.strip_edges();

		if (boot_logo_path!=String() /*&& FileAccess::exists(boot_logo_path)*/) {
			print_line("Boot splash path: "+boot_logo_path);
			Error err = boot_logo.load(boot_logo_path);
		}

		if (!boot_logo.empty()) {
			OS::get_singleton()->_msec_splash=OS::get_singleton()->get_ticks_msec();
			Color clear = GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3));
			VisualServer::get_singleton()->set_default_clear_color(clear);
			Color boot_bg = GLOBAL_DEF("application/boot_bg_color", clear);
			VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg,boot_logo_scale);
#ifndef TOOLS_ENABLED
			//no tools, so free the boot logo (no longer needed)
		//	Globals::get_singleton()->set("application/boot_logo",Image());
#endif

		} else {
#ifndef NO_DEFAULT_BOOT_LOGO

			MAIN_PRINT("Main: Create bootsplash");
			Image splash(boot_splash_png);

			MAIN_PRINT("Main: ClearColor");
			VisualServer::get_singleton()->set_default_clear_color(boot_splash_bg_color);
			MAIN_PRINT("Main: Image");
			VisualServer::get_singleton()->set_boot_image(splash, boot_splash_bg_color,false);
#endif
			MAIN_PRINT("Main: DCC");
			VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3)));
			MAIN_PRINT("Main: END");
		}

		Image icon(app_icon_png);
		OS::get_singleton()->set_icon(icon);
	}
	GLOBAL_DEF("application/icon",String());
	Globals::get_singleton()->set_custom_property_info("application/icon",PropertyInfo(Variant::STRING,"application/icon",PROPERTY_HINT_FILE,"*.png,*.webp"));

	if (bool(GLOBAL_DEF("display/emulate_touchscreen",false))) {
		if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton()) {
			//only if no touchscreen ui hint, set emulation
			InputDefault *id = Input::get_singleton()->cast_to<InputDefault>();
			if (id)
				id->set_emulate_touch(true);
		}
	}



	MAIN_PRINT("Main: Load Remaps");

	MAIN_PRINT("Main: Load Scene Types");

	register_scene_types();
	register_server_types();

	GLOBAL_DEF("display/custom_mouse_cursor",String());
	GLOBAL_DEF("display/custom_mouse_cursor_hotspot",Vector2());
	Globals::get_singleton()->set_custom_property_info("display/custom_mouse_cursor",PropertyInfo(Variant::STRING,"display/custom_mouse_cursor",PROPERTY_HINT_FILE,"*.png,*.webp"));

	if (String(Globals::get_singleton()->get("display/custom_mouse_cursor"))!=String()) {

		//print_line("use custom cursor");
		Ref<Texture> cursor=ResourceLoader::load(Globals::get_singleton()->get("display/custom_mouse_cursor"));
		if (cursor.is_valid()) {
		//	print_line("loaded ok");
			Vector2 hotspot = Globals::get_singleton()->get("display/custom_mouse_cursor_hotspot");
			Input::get_singleton()->set_custom_mouse_cursor(cursor,hotspot);
		}
	}
#ifdef TOOLS_ENABLED
	EditorNode::register_editor_types();
	ObjectTypeDB::register_type<PCKPacker>(); // todo: move somewhere else
#endif

	MAIN_PRINT("Main: Load Scripts, Modules, Drivers");

	register_module_types();
	register_driver_types();

	ScriptServer::init_languages();

	MAIN_PRINT("Main: Load Translations");

	translation_server->setup(); //register translations, load them, etc.
	if (locale!="") {

		translation_server->set_locale(locale);
	}
	translation_server->load_translations();



	_start_success=true;
	locale=String();

	MAIN_PRINT("Main: Done");

	return OK;

}
コード例 #2
0
ファイル: main.cpp プロジェクト: aurodev/godot
Error Main::setup2() {


    OS::get_singleton()->initialize(video_mode,video_driver_idx,audio_driver_idx);

    register_core_singletons();

    MAIN_PRINT("Main: Setup Logo");

    bool show_logo=true;
#ifdef JAVASCRIPT_ENABLED
    show_logo=false;
#endif

    if (show_logo) { //boot logo!
        Image boot_logo=GLOBAL_DEF("application/boot_logo",Image());

        if (!boot_logo.empty()) {
            Color clear = GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3));
            VisualServer::get_singleton()->set_default_clear_color(clear);
            Color boot_bg = GLOBAL_DEF("application/boot_bg_color", clear);
            VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg);
#ifndef TOOLS_ENABLED
            //no tools, so free the boot logo (no longer needed)
            Globals::get_singleton()->set("application/boot_logo",Image());
#endif

        } else {
#ifndef NO_DEFAULT_BOOT_LOGO

            MAIN_PRINT("Main: Create botsplash");
            Image splash(boot_splash_png);

            MAIN_PRINT("Main: ClearColor");
            VisualServer::get_singleton()->set_default_clear_color(boot_splash_bg_color);
            MAIN_PRINT("Main: Image");
            VisualServer::get_singleton()->set_boot_image(splash, boot_splash_bg_color);
#endif
            MAIN_PRINT("Main: DCC");
            VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3)));
            MAIN_PRINT("Main: END");
        }

        Image icon(app_icon_png);
        OS::get_singleton()->set_icon(icon);
    }
    GLOBAL_DEF("application/icon",String());
    Globals::get_singleton()->set_custom_property_info("application/icon",PropertyInfo(Variant::STRING,"application/icon",PROPERTY_HINT_FILE,"*.png,*.webp"));

    MAIN_PRINT("Main: Load Remaps");

    path_remap->load_remaps();

    MAIN_PRINT("Main: Load Scene Types");

    register_scene_types();
    register_server_types();

#ifdef TOOLS_ENABLED
    EditorNode::register_editor_types();
    ObjectTypeDB::register_type<PCKPacker>(); // todo: move somewhere else
#endif

    MAIN_PRINT("Main: Load Scripts, Modules, Drivers");

    register_module_types();
    register_driver_types();

    MAIN_PRINT("Main: Load Translations");

    translation_server->setup(); //register translations, load them, etc.
    if (locale!="") {

        translation_server->set_locale(locale);
    }
    translation_server->load_translations();



    _start_success=true;
    locale=String();

    MAIN_PRINT("Main: Done");

    return OK;

}