diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-01-05 09:16:00 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-01-05 09:16:00 -0300 |
commit | 0f7af4ea51744cda23c4d3c7481f9c332973d1d4 (patch) | |
tree | 27b8914062558b5648655ccf3db13251d217af98 /main | |
parent | 9e477babb3bf0ce5179395c2a5155a3f3cd36798 (diff) |
-Changed most project settings in the engine, so they have major and minor categories.
-Changed SectionedPropertyEditor to support this
-Renamed Globals singleton to GlobalConfig, makes more sense.
-Changed the logic behind persisten global settings, instead of the persist checkbox, a revert button is now available
Diffstat (limited to 'main')
-rw-r--r-- | main/main.cpp | 164 |
1 files changed, 83 insertions, 81 deletions
diff --git a/main/main.cpp b/main/main.cpp index 6703da8b01..12995f2a14 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -78,7 +78,7 @@ #include "main/input_default.h" #include "performance.h" -static Globals *globals=NULL; +static GlobalConfig *globals=NULL; static InputMap *input_map=NULL; static bool _start_success=false; static ScriptDebugger *script_debugger=NULL; @@ -207,14 +207,15 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas Thread::_main_thread_id = Thread::get_caller_ID(); - globals = memnew( Globals ); + globals = memnew( GlobalConfig ); input_map = memnew( InputMap ); + register_core_settings(); //here globals is present path_remap = memnew( PathRemap ); translation_server = memnew( TranslationServer ); performance = memnew( Performance ); - globals->add_singleton(Globals::Singleton("Performance",performance)); + globals->add_singleton(GlobalConfig::Singleton("Performance",performance)); MAIN_PRINT("Main: Parse CMDLine"); @@ -538,7 +539,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (I->next()) { - Globals::get_singleton()->set("editor_scene",game_path=I->next()->get()); + GlobalConfig::get_singleton()->set("editor_scene",game_path=I->next()->get()); } else { goto error; @@ -562,7 +563,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (I->next()) { int editor_pid=I->next()->get().to_int(); - Globals::get_singleton()->set("editor_pid",editor_pid); + GlobalConfig::get_singleton()->set("editor_pid",editor_pid); N=I->next()->next(); } else { goto error; @@ -592,11 +593,13 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } - GLOBAL_DEF("debug/max_remote_stdout_chars_per_second",2048); + GLOBAL_DEF("network/debug/max_remote_stdout_chars_per_second",2048); + GLOBAL_DEF("network/debug/remote_port",6007); + if (debug_mode == "remote") { ScriptDebuggerRemote *sdr = memnew( ScriptDebuggerRemote ); - uint16_t debug_port = GLOBAL_DEF("debug/remote_port",6007); + uint16_t debug_port = GLOBAL_GET("network/debug/remote_port"); if (debug_host.find(":")!=-1) { debug_port=debug_host.get_slicec(':',1).to_int(); debug_host=debug_host.get_slicec(':',0); @@ -614,6 +617,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } + FileAccessNetwork::configure(); if (remotefs!="") { @@ -678,10 +682,10 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas use_custom_res=false; } - if (bool(Globals::get_singleton()->get("application/disable_stdout"))) { + if (bool(GlobalConfig::get_singleton()->get("application/disable_stdout"))) { quiet_stdout=true; } - if (bool(Globals::get_singleton()->get("application/disable_stderr"))) { + if (bool(GlobalConfig::get_singleton()->get("application/disable_stderr"))) { _print_error_enabled = false; }; @@ -692,7 +696,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas #ifdef TOOLS_ENABLED - if (main_args.size()==0 && (!Globals::get_singleton()->has("application/main_loop_type")) && (!Globals::get_singleton()->has("application/main_scene") || String(Globals::get_singleton()->get("application/main_scene"))=="")) + if (main_args.size()==0 && (!GlobalConfig::get_singleton()->has("application/main_loop_type")) && (!GlobalConfig::get_singleton()->has("application/main_scene") || String(GlobalConfig::get_singleton()->get("application/main_scene"))=="")) use_custom_res=false; //project manager (run without arguments) #endif @@ -703,25 +707,25 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas input_map->load_from_globals(); //keys for game if (video_driver=="") // specified in engine.cfg - video_driver=_GLOBAL_DEF("display/driver",Variant((const char*)OS::get_singleton()->get_video_driver_name(0))); + video_driver=_GLOBAL_DEF("display/driver/name",Variant((const char*)OS::get_singleton()->get_video_driver_name(0))); - if (!force_res && use_custom_res && globals->has("display/width")) - video_mode.width=globals->get("display/width"); - if (!force_res &&use_custom_res && globals->has("display/height")) - video_mode.height=globals->get("display/height"); - if (!editor && (!bool(globals->get("display/allow_hidpi")) || force_lowdpi)) { + if (!force_res && use_custom_res && globals->has("display/window/width")) + video_mode.width=globals->get("display/window/width"); + if (!force_res &&use_custom_res && globals->has("display/window/height")) + video_mode.height=globals->get("display/window/height"); + if (!editor && (!bool(globals->get("display/window/allow_hidpi")) || force_lowdpi)) { OS::get_singleton()->_allow_hidpi=false; } - if (use_custom_res && globals->has("display/fullscreen")) - video_mode.fullscreen=globals->get("display/fullscreen"); - if (use_custom_res && globals->has("display/resizable")) - video_mode.resizable=globals->get("display/resizable"); - if (use_custom_res && globals->has("display/borderless_window")) - video_mode.borderless_window = globals->get("display/borderless_window"); - - if (!force_res && use_custom_res && globals->has("display/test_width") && globals->has("display/test_height")) { - int tw = globals->get("display/test_width"); - int th = globals->get("display/test_height"); + if (use_custom_res && globals->has("display/window/fullscreen")) + video_mode.fullscreen=globals->get("display/window/fullscreen"); + if (use_custom_res && globals->has("display/window/resizable")) + video_mode.resizable=globals->get("display/window/resizable"); + if (use_custom_res && globals->has("display/window/borderless")) + video_mode.borderless_window = globals->get("display/window/borderless"); + + if (!force_res && use_custom_res && globals->has("display/window/test_width") && globals->has("display/window/test_height")) { + int tw = globals->get("display/window/test_width"); + int th = globals->get("display/window/test_height"); if (tw>0 && th>0) { video_mode.width=tw; video_mode.height=th; @@ -729,19 +733,19 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } - GLOBAL_DEF("display/width",video_mode.width); - GLOBAL_DEF("display/height",video_mode.height); - GLOBAL_DEF("display/allow_hidpi",false); - GLOBAL_DEF("display/fullscreen",video_mode.fullscreen); - GLOBAL_DEF("display/resizable",video_mode.resizable); - GLOBAL_DEF("display/borderless_window", video_mode.borderless_window); - use_vsync = GLOBAL_DEF("display/use_vsync", use_vsync); - GLOBAL_DEF("display/test_width",0); - GLOBAL_DEF("display/test_height",0); - OS::get_singleton()->_pixel_snap=GLOBAL_DEF("display/use_2d_pixel_snap",false); - OS::get_singleton()->_keep_screen_on=GLOBAL_DEF("display/keep_screen_on",true); + GLOBAL_DEF("display/window/width",video_mode.width); + GLOBAL_DEF("display/window/height",video_mode.height); + GLOBAL_DEF("display/window/allow_hidpi",false); + GLOBAL_DEF("display/window/fullscreen",video_mode.fullscreen); + GLOBAL_DEF("display/window/resizable",video_mode.resizable); + GLOBAL_DEF("display/window/borderless", video_mode.borderless_window); + use_vsync = GLOBAL_DEF("display/window/use_vsync", use_vsync); + GLOBAL_DEF("display/window/test_width",0); + GLOBAL_DEF("display/window/test_height",0); + OS::get_singleton()->_pixel_snap=GLOBAL_DEF("rendering/2d/use_pixel_snap",false); + OS::get_singleton()->_keep_screen_on=GLOBAL_DEF("display/energy_saving/keep_screen_on",true); if (rtm==-1) { - rtm=GLOBAL_DEF("render/thread_model",OS::RENDER_THREAD_SAFE); + rtm=GLOBAL_DEF("rendering/threads/thread_model",OS::RENDER_THREAD_SAFE); if (rtm>=1) //hack for now rtm=1; @@ -796,7 +800,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } { - String orientation = GLOBAL_DEF("display/orientation","landscape"); + String orientation = GLOBAL_DEF("display/handheld/orientation","landscape"); if (orientation=="portrait") OS::get_singleton()->set_screen_orientation(OS::SCREEN_PORTRAIT); @@ -815,11 +819,13 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } - OS::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/fixed_fps",60)); - OS::get_singleton()->set_target_fps(GLOBAL_DEF("debug/force_fps",0)); + OS::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/common/fixed_fps",60)); + OS::get_singleton()->set_target_fps(GLOBAL_DEF("debug/fps/force_fps",0)); + + GLOBAL_DEF("debug/stdout/print_fps", OS::get_singleton()->is_stdout_verbose()); if (!OS::get_singleton()->_verbose_stdout) //overrided - OS::get_singleton()->_verbose_stdout=GLOBAL_DEF("debug/verbose_stdout",false); + OS::get_singleton()->_verbose_stdout=GLOBAL_DEF("debug/stdout/verbose_stdout",false); if (frame_delay==0) { frame_delay=GLOBAL_DEF("application/frame_delay_msec",0); @@ -829,7 +835,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas message_queue = memnew( MessageQueue ); - Globals::get_singleton()->register_global_defaults(); + GlobalConfig::get_singleton()->register_global_defaults(); if (p_second_phase) return setup2(); @@ -918,10 +924,13 @@ Error Main::setup2() { path_remap->load_remaps(); + Color clear = GLOBAL_DEF("rendering/viewport/default_clear_color",Color(0.3,0.3,0.3)); + VisualServer::get_singleton()->set_default_clear_color(clear); + 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")); + GlobalConfig::get_singleton()->set_custom_property_info("application/boot_splash",PropertyInfo(Variant::STRING,"application/boot_splash",PROPERTY_HINT_FILE,"*.png")); Image boot_logo; @@ -936,13 +945,11 @@ Error Main::setup2() { 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()); + // GlobalConfig::get_singleton()->set("application/boot_logo",Image()); #endif } else { @@ -963,13 +970,13 @@ Error Main::setup2() { } MAIN_PRINT("Main: DCC"); - VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("render/default_clear_color",Color(0.3,0.3,0.3))); + VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF("rendering/viewport/default_clear_color",Color(0.3,0.3,0.3))); MAIN_PRINT("Main: END"); GLOBAL_DEF("application/icon",String()); - Globals::get_singleton()->set_custom_property_info("application/icon",PropertyInfo(Variant::STRING,"application/icon",PROPERTY_HINT_FILE,"*.png,*.webp")); + GlobalConfig::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 (bool(GLOBAL_DEF("display/handheld/emulate_touchscreen",false))) { if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton() && !editor) { //only if no touchscreen ui hint, set emulation InputDefault *id = Input::get_singleton()->cast_to<InputDefault>(); @@ -987,17 +994,17 @@ Error Main::setup2() { 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")); + GLOBAL_DEF("display/mouse_cursor/custom_image",String()); + GLOBAL_DEF("display/mouse_cursor/custom_image_hotspot",Vector2()); + GlobalConfig::get_singleton()->set_custom_property_info("display/mouse_cursor/custom_image",PropertyInfo(Variant::STRING,"display/mouse_cursor/custom_image",PROPERTY_HINT_FILE,"*.png,*.webp")); - if (String(Globals::get_singleton()->get("display/custom_mouse_cursor"))!=String()) { + if (String(GlobalConfig::get_singleton()->get("display/mouse_cursor/custom_image"))!=String()) { //print_line("use custom cursor"); - Ref<Texture> cursor=ResourceLoader::load(Globals::get_singleton()->get("display/custom_mouse_cursor")); + Ref<Texture> cursor=ResourceLoader::load(GlobalConfig::get_singleton()->get("display/mouse_cursor/custom_image")); if (cursor.is_valid()) { // print_line("loaded ok"); - Vector2 hotspot = Globals::get_singleton()->get("display/custom_mouse_cursor_hotspot"); + Vector2 hotspot = GlobalConfig::get_singleton()->get("display/mouse_cursor/custom_image_hotspot"); Input::get_singleton()->set_custom_mouse_cursor(cursor,hotspot); } } @@ -1122,8 +1129,7 @@ bool Main::start() { } } - if (editor) - Globals::get_singleton()->set("editor_active",true); + GLOBAL_DEF("editor/active",editor); String main_loop_type; @@ -1274,9 +1280,9 @@ bool Main::start() { if (!editor) { //standard helpers that can be changed from main config - String stretch_mode = GLOBAL_DEF("display/stretch_mode","disabled"); - String stretch_aspect = GLOBAL_DEF("display/stretch_aspect","ignore"); - Size2i stretch_size = Size2(GLOBAL_DEF("display/width",0),GLOBAL_DEF("display/height",0)); + String stretch_mode = GLOBAL_DEF("display/stretch/mode","disabled"); + String stretch_aspect = GLOBAL_DEF("display/stretch/aspect","ignore"); + Size2i stretch_size = Size2(GLOBAL_DEF("display/screen/width",0),GLOBAL_DEF("display/screen/height",0)); SceneTree::StretchMode sml_sm=SceneTree::STRETCH_MODE_DISABLED; if (stretch_mode=="2d") @@ -1295,7 +1301,7 @@ bool Main::start() { sml->set_screen_stretch(sml_sm,sml_aspect,stretch_size); sml->set_auto_accept_quit(GLOBAL_DEF("application/auto_accept_quit",true)); - String appname = Globals::get_singleton()->get("application/name"); + String appname = GlobalConfig::get_singleton()->get("application/name"); appname = TranslationServer::get_singleton()->translate(appname); OS::get_singleton()->set_window_title(appname); @@ -1312,23 +1318,23 @@ bool Main::start() { sml->get_root()->set_shadow_atlas_quadrant_subdiv(3,Viewport::ShadowAtlasQuadrantSubdiv(shadow_atlas_q3_subdiv)); } else { - GLOBAL_DEF("display/stretch_mode","disabled"); - Globals::get_singleton()->set_custom_property_info("display/stretch_mode",PropertyInfo(Variant::STRING,"display/stretch_mode",PROPERTY_HINT_ENUM,"disabled,2d,viewport")); - GLOBAL_DEF("display/stretch_aspect","ignore"); - Globals::get_singleton()->set_custom_property_info("display/stretch_aspect",PropertyInfo(Variant::STRING,"display/stretch_aspect",PROPERTY_HINT_ENUM,"ignore,keep,keep_width,keep_height")); + GLOBAL_DEF("display/stretch/mode","disabled"); + GlobalConfig::get_singleton()->set_custom_property_info("display/stretch/mode",PropertyInfo(Variant::STRING,"display/stretch/mode",PROPERTY_HINT_ENUM,"disabled,2d,viewport")); + GLOBAL_DEF("display/stretch/aspect","ignore"); + GlobalConfig::get_singleton()->set_custom_property_info("display/stretch/aspect",PropertyInfo(Variant::STRING,"display/stretch/aspect",PROPERTY_HINT_ENUM,"ignore,keep,keep_width,keep_height")); sml->set_auto_accept_quit(GLOBAL_DEF("application/auto_accept_quit",true)); GLOBAL_DEF("rendering/shadow_atlas/size",2048); - Globals::get_singleton()->set_custom_property_info("rendering/shadow_atlas/size",PropertyInfo(Variant::INT,"rendering/shadow_atlas/size",PROPERTY_HINT_RANGE,"256,16384")); + GlobalConfig::get_singleton()->set_custom_property_info("rendering/shadow_atlas/size",PropertyInfo(Variant::INT,"rendering/shadow_atlas/size",PROPERTY_HINT_RANGE,"256,16384")); GLOBAL_DEF("rendering/shadow_atlas/quadrant_0_subdiv",2); GLOBAL_DEF("rendering/shadow_atlas/quadrant_1_subdiv",2); GLOBAL_DEF("rendering/shadow_atlas/quadrant_2_subdiv",3); GLOBAL_DEF("rendering/shadow_atlas/quadrant_3_subdiv",4); - Globals::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_0_subdiv",PropertyInfo(Variant::INT,"rendering/shadow_atlas/quadrant_0_subdiv",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows")); - Globals::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_1_subdiv",PropertyInfo(Variant::INT,"rendering/shadow_atlas/quadrant_1_subdiv",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows")); - Globals::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_2_subdiv",PropertyInfo(Variant::INT,"rendering/shadow_atlas/quadrant_2_subdiv",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows")); - Globals::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_3_subdiv",PropertyInfo(Variant::INT,"rendering/shadow_atlas/quadrant_3_subdiv",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows")); + GlobalConfig::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_0_subdiv",PropertyInfo(Variant::INT,"rendering/shadow_atlas/quadrant_0_subdiv",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows")); + GlobalConfig::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_1_subdiv",PropertyInfo(Variant::INT,"rendering/shadow_atlas/quadrant_1_subdiv",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows")); + GlobalConfig::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_2_subdiv",PropertyInfo(Variant::INT,"rendering/shadow_atlas/quadrant_2_subdiv",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows")); + GlobalConfig::get_singleton()->set_custom_property_info("rendering/shadow_atlas/quadrant_3_subdiv",PropertyInfo(Variant::INT,"rendering/shadow_atlas/quadrant_3_subdiv",PROPERTY_HINT_ENUM,"Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows")); } @@ -1342,7 +1348,7 @@ bool Main::start() { if (!absolute) { - if (Globals::get_singleton()->is_using_datapack()) { + if (GlobalConfig::get_singleton()->is_using_datapack()) { local_game_path="res://"+local_game_path; @@ -1366,7 +1372,7 @@ bool Main::start() { } } - local_game_path=Globals::get_singleton()->localize_path(local_game_path); + local_game_path=GlobalConfig::get_singleton()->localize_path(local_game_path); #ifdef TOOLS_ENABLED if (editor) { @@ -1410,7 +1416,7 @@ bool Main::start() { if (game_path!="" || script!="") { //autoload List<PropertyInfo> props; - Globals::get_singleton()->get_property_list(&props); + GlobalConfig::get_singleton()->get_property_list(&props); //first pass, add the constants so they exist before any script is loaded for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) { @@ -1419,7 +1425,7 @@ bool Main::start() { if (!s.begins_with("autoload/")) continue; String name = s.get_slicec('/',1); - String path = Globals::get_singleton()->get(s); + String path = GlobalConfig::get_singleton()->get(s); bool global_var=false; if (path.begins_with("*")) { global_var=true; @@ -1441,7 +1447,7 @@ bool Main::start() { if (!s.begins_with("autoload/")) continue; String name = s.get_slicec('/',1); - String path = Globals::get_singleton()->get(s); + String path = GlobalConfig::get_singleton()->get(s); bool global_var=false; if (path.begins_with("*")) { global_var=true; @@ -1684,7 +1690,7 @@ bool Main::iteration() { if (frame>1000000) { - if (GLOBAL_DEF("debug/print_fps", OS::get_singleton()->is_stdout_verbose())) { + if (GLOBAL_DEF("debug/stdout/print_fps", OS::get_singleton()->is_stdout_verbose())) { print_line("FPS: "+itos(frames)); }; @@ -1694,10 +1700,6 @@ bool Main::iteration() { idle_process_max=0; fixed_process_max=0; - if (GLOBAL_DEF("debug/print_metrics", false)) { - - //PerformanceMetrics::print(); - }; frame%=1000000; frames=0; |