From c69de2ba46463adeadf90f38660d6b6e034d7e0b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 19 Jul 2018 18:58:15 -0300 Subject: [PATCH] -Project/Editor settings now use new inspector -Project/Editor settings now show tooltips properly -Settings thar require restart now will show a restart warning -Video driver is now visible all the time, can be changed easily -Added function to request current video driver --- core/message_queue.cpp | 2 +- core/os/os.cpp | 12 + core/os/os.h | 10 +- core/project_settings.cpp | 12 +- core/project_settings.h | 7 +- core/register_core_types.cpp | 2 +- drivers/coreaudio/audio_driver_coreaudio.cpp | 4 +- drivers/gles3/rasterizer_canvas_gles3.cpp | 4 +- drivers/gles3/rasterizer_scene_gles3.cpp | 2 +- drivers/gles3/rasterizer_storage_gles3.cpp | 2 +- .../pulseaudio/audio_driver_pulseaudio.cpp | 4 +- drivers/rtaudio/audio_driver_rtaudio.cpp | 4 +- drivers/wasapi/audio_driver_wasapi.cpp | 2 +- drivers/xaudio2/audio_driver_xaudio2.cpp | 2 +- editor/editor_inspector.cpp | 41 ++- editor/editor_inspector.h | 10 + editor/editor_node.cpp | 97 +++++- editor/editor_node.h | 11 + editor/editor_sectioned_inspector.cpp | 306 ++++++++++++++++++ editor/editor_sectioned_inspector.h | 42 +++ editor/editor_settings.cpp | 26 +- editor/editor_settings.h | 7 +- editor/editor_spin_slider.cpp | 3 +- editor/icons/icon_g_l_e_s_2.svg | 69 ++++ editor/icons/icon_g_l_e_s_3.svg | 67 ++++ editor/icons/icon_vulkan.svg | 127 ++++++++ editor/project_settings_editor.cpp | 73 ++++- editor/project_settings_editor.h | 15 +- editor/settings_config_dialog.cpp | 70 +++- editor/settings_config_dialog.h | 18 +- main/main.cpp | 13 +- platform/android/audio_driver_jandroid.cpp | 4 +- platform/android/os_android.cpp | 5 + platform/android/os_android.h | 3 + platform/haiku/audio_driver_media_kit.cpp | 2 +- platform/iphone/os_iphone.cpp | 6 + platform/iphone/os_iphone.h | 4 + platform/javascript/os_javascript.cpp | 5 + platform/javascript/os_javascript.h | 4 + platform/osx/os_osx.h | 3 + platform/osx/os_osx.mm | 6 + platform/windows/os_windows.cpp | 6 + platform/windows/os_windows.h | 3 + platform/x11/os_x11.cpp | 10 +- platform/x11/os_x11.h | 3 + servers/audio/audio_driver_dummy.cpp | 2 +- servers/audio_server.cpp | 6 +- 47 files changed, 1055 insertions(+), 81 deletions(-) create mode 100644 editor/editor_sectioned_inspector.cpp create mode 100644 editor/editor_sectioned_inspector.h create mode 100644 editor/icons/icon_g_l_e_s_2.svg create mode 100644 editor/icons/icon_g_l_e_s_3.svg create mode 100644 editor/icons/icon_vulkan.svg diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 25ee6eafaec..3adaad868a6 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -342,7 +342,7 @@ MessageQueue::MessageQueue() { buffer_end = 0; buffer_max_used = 0; - buffer_size = GLOBAL_DEF("memory/limits/message_queue/max_size_kb", DEFAULT_QUEUE_SIZE_KB); + buffer_size = GLOBAL_DEF_RST("memory/limits/message_queue/max_size_kb", DEFAULT_QUEUE_SIZE_KB); buffer_size *= 1024; buffer = memnew_arr(uint8_t, buffer_size); } diff --git a/core/os/os.cpp b/core/os/os.cpp index d0a7bc6fbe6..f99e98c240c 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -659,6 +659,18 @@ const char *OS::get_audio_driver_name(int p_driver) const { return AudioDriverManager::get_driver(p_driver)->get_name(); } +void OS::set_restart_on_exit(bool p_restart, const List &p_restart_arguments) { + restart_on_exit = p_restart; + restart_commandline = p_restart_arguments; +} + +bool OS::is_restart_on_exit_set() const { + return restart_on_exit; +} +List OS::get_restart_on_exit_argumens() const { + return restart_commandline; +} + OS::OS() { void *volatile stack_bottom; diff --git a/core/os/os.h b/core/os/os.h index adf01a90e7a..2e4888dfba7 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -74,6 +74,9 @@ class OS { CompositeLogger *_logger; + bool restart_on_exit; + List restart_commandline; + protected: void _set_logger(CompositeLogger *p_logger); @@ -182,7 +185,7 @@ public: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - + virtual int get_current_video_driver() const = 0; virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; @@ -496,6 +499,11 @@ public: bool is_layered_allowed() const { return _allow_layered; } bool is_hidpi_allowed() const { return _allow_hidpi; } + + void set_restart_on_exit(bool p_restart, const List &p_restart_arguments); + bool is_restart_on_exit_set() const; + List get_restart_on_exit_argumens() const; + OS(); virtual ~OS(); }; diff --git a/core/project_settings.cpp b/core/project_settings.cpp index db1d0a604c9..60e8933751b 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -105,6 +105,11 @@ void ProjectSettings::set_initial_value(const String &p_name, const Variant &p_v ERR_FAIL_COND(!props.has(p_name)); props[p_name].initial = p_value; } +void ProjectSettings::set_restart_if_changed(const String &p_name, bool p_restart) { + + ERR_FAIL_COND(!props.has(p_name)); + props[p_name].restart_if_changed = p_restart; +} String ProjectSettings::globalize_path(const String &p_path) const { @@ -225,6 +230,9 @@ void ProjectSettings::_get_property_list(List *p_list) const { else vc.flags = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE; + if (v->restart_if_changed) { + vc.flags |= PROPERTY_USAGE_RESTART_IF_CHANGED; + } vclist.insert(vc); } @@ -817,7 +825,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust return OK; } -Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) { +Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed) { Variant ret; if (!ProjectSettings::get_singleton()->has_setting(p_var)) { @@ -827,6 +835,7 @@ Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) { ProjectSettings::get_singleton()->set_initial_value(p_var, p_default); ProjectSettings::get_singleton()->set_builtin_order(p_var); + ProjectSettings::get_singleton()->set_restart_if_changed(p_var, p_restart_if_changed); return ret; } @@ -1080,7 +1089,6 @@ ProjectSettings::ProjectSettings() { custom_prop_info["rendering/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded"); custom_prop_info["physics/2d/thread_model"] = PropertyInfo(Variant::INT, "physics/2d/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded"); custom_prop_info["rendering/quality/intended_usage/framebuffer_allocation"] = PropertyInfo(Variant::INT, "rendering/quality/intended_usage/framebuffer_allocation", PROPERTY_HINT_ENUM, "2D,2D Without Sampling,3D,3D Without Effects"); - GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_mode", 2); GLOBAL_DEF("debug/settings/profiler/max_functions", 16384); diff --git a/core/project_settings.h b/core/project_settings.h index 045d942b31d..28b96a81447 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -59,11 +59,13 @@ protected: Variant initial; bool hide_from_editor; bool overridden; + bool restart_if_changed; VariantContainer() : order(0), persist(false), hide_from_editor(false), overridden(false) { + restart_if_changed = false; } VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false) : order(p_order), @@ -71,6 +73,7 @@ protected: variant(p_variant), hide_from_editor(false), overridden(false) { + restart_if_changed = false; } }; @@ -120,6 +123,7 @@ public: String globalize_path(const String &p_path) const; void set_initial_value(const String &p_name, const Variant &p_value); + void set_restart_if_changed(const String &p_name, bool p_restart); bool property_can_revert(const String &p_name); Variant property_get_revert(const String &p_name); @@ -158,8 +162,9 @@ public: }; //not a macro any longer -Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default); +Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed = false); #define GLOBAL_DEF(m_var, m_value) _GLOBAL_DEF(m_var, m_value) +#define GLOBAL_DEF_RST(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true) #define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get(m_var) #endif diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 2a611ccf6a1..9bcc2d4530b 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -191,7 +191,7 @@ void register_core_types() { void register_core_settings() { //since in register core types, globals may not e present - GLOBAL_DEF("network/limits/packet_peer_stream/max_buffer_po2", (16)); + GLOBAL_DEF_RST("network/limits/packet_peer_stream/max_buffer_po2", (16)); } void register_core_singletons() { diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp index 63af4506f35..ac21de91e47 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.cpp +++ b/drivers/coreaudio/audio_driver_coreaudio.cpp @@ -102,7 +102,7 @@ Error AudioDriverCoreAudio::init() { break; } - mix_rate = GLOBAL_DEF("audio/mix_rate", DEFAULT_MIX_RATE); + mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE); zeromem(&strdesc, sizeof(strdesc)); strdesc.mFormatID = kAudioFormatLinearPCM; @@ -117,7 +117,7 @@ Error AudioDriverCoreAudio::init() { result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputBus, &strdesc, sizeof(strdesc)); ERR_FAIL_COND_V(result != noErr, FAILED); - int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY); + int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY); // Sample rate is independent of channels (ref: https://stackoverflow.com/questions/11048825/audio-sample-frequency-rely-on-channels) buffer_frames = closest_power_of_2(latency * mix_rate / 1000); diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index f859e49b5bd..5e13bed1981 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1895,7 +1895,7 @@ void RasterizerCanvasGLES3::initialize() { } { - uint32_t poly_size = GLOBAL_DEF("rendering/limits/buffers/canvas_polygon_buffer_size_kb", 128); + uint32_t poly_size = GLOBAL_DEF_RST("rendering/limits/buffers/canvas_polygon_buffer_size_kb", 128); poly_size *= 1024; //kb poly_size = MAX(poly_size, (2 + 2 + 4) * 4 * sizeof(float)); glGenBuffers(1, &data.polygon_buffer); @@ -1942,7 +1942,7 @@ void RasterizerCanvasGLES3::initialize() { glGenVertexArrays(1, &data.polygon_buffer_pointer_array); - uint32_t index_size = GLOBAL_DEF("rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", 128); + uint32_t index_size = GLOBAL_DEF_RST("rendering/limits/buffers/canvas_polygon_index_buffer_size_kb", 128); index_size *= 1024; //kb glGenBuffers(1, &data.polygon_index_buffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, data.polygon_index_buffer); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 9d0fb462f4c..85b63a64812 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -4866,7 +4866,7 @@ void RasterizerSceneGLES3::initialize() { glBufferData(GL_UNIFORM_BUFFER, sizeof(State::EnvironmentRadianceUBO), &state.env_radiance_ubo, GL_DYNAMIC_DRAW); glBindBuffer(GL_UNIFORM_BUFFER, 0); - render_list.max_elements = GLOBAL_DEF("rendering/limits/rendering/max_renderable_elements", (int)RenderList::DEFAULT_MAX_ELEMENTS); + render_list.max_elements = GLOBAL_DEF_RST("rendering/limits/rendering/max_renderable_elements", (int)RenderList::DEFAULT_MAX_ELEMENTS); if (render_list.max_elements > 1000000) render_list.max_elements = 1000000; if (render_list.max_elements < 1024) diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index eb25d6c7a14..e67b0bea210 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -7463,7 +7463,7 @@ void RasterizerStorageGLES3::initialize() { { //transform feedback buffers - uint32_t xf_feedback_size = GLOBAL_DEF("rendering/limits/buffers/blend_shape_max_buffer_size_kb", 4096); + uint32_t xf_feedback_size = GLOBAL_DEF_RST("rendering/limits/buffers/blend_shape_max_buffer_size_kb", 4096); for (int i = 0; i < 2; i++) { glGenBuffers(1, &resources.transform_feedback_buffers[i]); diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index ed6af04b9de..3622e48ecd6 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -155,7 +155,7 @@ Error AudioDriverPulseAudio::init_device() { break; } - int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY); + int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY); buffer_frames = closest_power_of_2(latency * mix_rate / 1000); pa_buffer_size = buffer_frames * pa_map.channels; @@ -204,7 +204,7 @@ Error AudioDriverPulseAudio::init() { thread_exited = false; exit_thread = false; - mix_rate = GLOBAL_DEF("audio/mix_rate", DEFAULT_MIX_RATE); + mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE); pa_ml = pa_mainloop_new(); ERR_FAIL_COND_V(pa_ml == NULL, ERR_CANT_OPEN); diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp index 457486797f7..365788e1927 100644 --- a/drivers/rtaudio/audio_driver_rtaudio.cpp +++ b/drivers/rtaudio/audio_driver_rtaudio.cpp @@ -88,7 +88,7 @@ Error AudioDriverRtAudio::init() { // FIXME: Adapt to the OutputFormat -> SpeakerMode change /* - String channels = GLOBAL_DEF("audio/output","stereo"); + String channels = GLOBAL_DEF_RST("audio/output","stereo"); if (channels=="5.1") output_format=OUTPUT_5_1; @@ -108,7 +108,7 @@ Error AudioDriverRtAudio::init() { options.numberOfBuffers = 4; parameters.firstChannel = 0; - mix_rate = GLOBAL_DEF("audio/mix_rate", DEFAULT_MIX_RATE); + mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE); int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY); unsigned int buffer_frames = closest_power_of_2(latency * mix_rate / 1000); diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index 3c54c429d9f..1d96f9ee7d7 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -318,7 +318,7 @@ Error AudioDriverWASAPI::finish_device() { Error AudioDriverWASAPI::init() { - mix_rate = GLOBAL_DEF("audio/mix_rate", DEFAULT_MIX_RATE); + mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE); Error err = init_device(); if (err != OK) { diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp index 66754593137..db108f9c6bb 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.cpp +++ b/drivers/xaudio2/audio_driver_xaudio2.cpp @@ -50,7 +50,7 @@ Error AudioDriverXAudio2::init() { speaker_mode = SPEAKER_MODE_STEREO; channels = 2; - int latency = GLOBAL_DEF("audio/output_latency", 25); + int latency = GLOBAL_DEF_RST("audio/output_latency", 25); buffer_size = closest_power_of_2(latency * mix_rate / 1000); samples_in = memnew_arr(int32_t, buffer_size * channels); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 482b0dec350..5e600a95815 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1507,12 +1507,19 @@ void EditorInspector::update_tree() { checked = p.usage & PROPERTY_USAGE_CHECKED; } + if (p.usage & PROPERTY_USAGE_RESTART_IF_CHANGED) { + restart_request_props.insert(p.name); + } + String doc_hint; if (use_doc_hints) { StringName classname = object->get_class_name(); - StringName propname = p.name; + if (object_class != String()) { + classname = object_class; + } + StringName propname = property_prefix + p.name; String descr; bool found = false; @@ -1580,9 +1587,9 @@ void EditorInspector::update_tree() { ep->connect("resource_selected", this, "_resource_selected", varray(), CONNECT_DEFERRED); ep->connect("object_id_selected", this, "_object_id_selected", varray(), CONNECT_DEFERRED); if (doc_hint != String()) { - ep->set_tooltip(TTR("Property: ") + p.name + "\n\n" + doc_hint); + ep->set_tooltip(TTR("Property: ") + property_prefix + p.name + "\n\n" + doc_hint); } else { - ep->set_tooltip(TTR("Property: ") + p.name); + ep->set_tooltip(TTR("Property: ") + property_prefix + p.name); } ep->set_draw_red(draw_red); ep->set_use_folding(use_folding); @@ -1659,6 +1666,7 @@ void EditorInspector::_clear() { editor_property_map.clear(); sections.clear(); pending.clear(); + restart_request_props.clear(); } void EditorInspector::refresh() { @@ -1902,6 +1910,10 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v if (changing) this->changing--; + + if (restart_request_props.has(p_path)) { + emit_signal("restart_requested"); + } } void EditorInspector::_property_changed_update_all(const String &p_path, const Variant &p_value) { @@ -1921,6 +1933,9 @@ void EditorInspector::_multiple_properties_changed(Vector p_paths, Array undo_redo->create_action(TTR("Set Multiple:") + " " + names, UndoRedo::MERGE_ENDS); for (int i = 0; i < p_paths.size(); i++) { _edit_set(p_paths[i], p_values[i], false, ""); + if (restart_request_props.has(p_paths[i])) { + emit_signal("restart_requested"); + } } changing++; undo_redo->commit_action(); @@ -1993,6 +2008,8 @@ void EditorInspector::_property_selected(const String &p_path, int p_focusable) E->get()->deselect(); } } + + emit_signal("property_selected", p_path); } void EditorInspector::_object_id_selected(const String &p_path, ObjectID p_id) { @@ -2090,6 +2107,21 @@ void EditorInspector::_vscroll_changed(double p_offset) { scroll_cache[object->get_instance_id()] = p_offset; } } +void EditorInspector::set_property_prefix(const String &p_prefix) { + property_prefix = p_prefix; +} + +String EditorInspector::get_property_prefix() const { + return property_prefix; +} + +void EditorInspector::set_object_class(const String &p_class) { + object_class = p_class; +} + +String EditorInspector::get_object_class() const { + return object_class; +} void EditorInspector::_bind_methods() { @@ -2110,9 +2142,12 @@ void EditorInspector::_bind_methods() { ClassDB::bind_method("refresh", &EditorInspector::refresh); + ADD_SIGNAL(MethodInfo("property_selected", PropertyInfo(Variant::STRING, "property"))); ADD_SIGNAL(MethodInfo("property_keyed", PropertyInfo(Variant::STRING, "property"))); ADD_SIGNAL(MethodInfo("resource_selected", PropertyInfo(Variant::OBJECT, "res"), PropertyInfo(Variant::STRING, "prop"))); ADD_SIGNAL(MethodInfo("object_id_selected", PropertyInfo(Variant::INT, "id"))); + ADD_SIGNAL(MethodInfo("property_edited", PropertyInfo(Variant::STRING, "property"))); + ADD_SIGNAL(MethodInfo("restart_requested")); } EditorInspector::EditorInspector() { diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 320641c6939..d9b66b05b2a 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -267,9 +267,13 @@ class EditorInspector : public ScrollContainer { Map > descr_cache; Map class_descr_cache; + Set restart_request_props; Map scroll_cache; + String property_prefix; //used for sectioned inspector + String object_class; + void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field); void _property_changed(const String &p_path, const Variant &p_value, bool changing = false); @@ -343,6 +347,12 @@ public: void set_scroll_offset(int p_offset); int get_scroll_offset() const; + void set_property_prefix(const String &p_prefix); + String get_property_prefix() const; + + void set_object_class(const String &p_class); + String get_object_class() const; + void set_use_sub_inspector_bg(bool p_enable); EditorInspector(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 52f6f1ed0e2..88266f468a6 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1068,6 +1068,32 @@ void EditorNode::_save_scene(String p_file, int idx) { } } +void EditorNode::save_all_scenes_and_restart() { + + _menu_option_confirm(RUN_STOP, true); + exiting = true; + + _save_all_scenes(); + + String to_reopen; + if (get_tree()->get_edited_scene_root()) { + to_reopen = get_tree()->get_edited_scene_root()->get_filename(); + } + + get_tree()->quit(); + String exec = OS::get_singleton()->get_executable_path(); + + List args; + args.push_back("--path"); + args.push_back(ProjectSettings::get_singleton()->get_resource_path()); + args.push_back("-e"); + if (to_reopen != String()) { + args.push_back(to_reopen); + } + + OS::get_singleton()->set_restart_on_exit(true, args); +} + void EditorNode::_save_all_scenes() { for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { @@ -2204,6 +2230,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { about->popup_centered_minsize(Size2(780, 500) * EDSCALE); } break; + case SET_VIDEO_DRIVER_SAVE_AND_RESTART: { + + ProjectSettings::get_singleton()->set("rendering/quality/driver/driver_name", video_driver_request); + ProjectSettings::get_singleton()->save(); + + save_all_scenes_and_restart(); + } break; default: { if (p_option >= IMPORT_PLUGIN_BASE) { } @@ -4390,6 +4423,21 @@ void EditorNode::_bottom_panel_raise_toggled(bool p_pressed) { } } +void EditorNode::_video_driver_selected(int p_which) { + + String driver = video_driver->get_item_metadata(p_which); + + String current = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver()); + + if (driver == current) { + return; + } + + video_driver_request = driver; + video_restart_dialog->popup_centered_minsize(); + video_driver->select(video_driver_current); +} + void EditorNode::_bind_methods() { ClassDB::bind_method("_menu_option", &EditorNode::_menu_option); @@ -4460,6 +4508,8 @@ void EditorNode::_bind_methods() { ClassDB::bind_method(D_METHOD("_resources_reimported"), &EditorNode::_resources_reimported); ClassDB::bind_method(D_METHOD("_bottom_panel_raise_toggled"), &EditorNode::_bottom_panel_raise_toggled); + ClassDB::bind_method(D_METHOD("_video_driver_selected"), &EditorNode::_video_driver_selected); + ADD_SIGNAL(MethodInfo("play_pressed")); ADD_SIGNAL(MethodInfo("pause_pressed")); ADD_SIGNAL(MethodInfo("stop_pressed")); @@ -4656,19 +4706,19 @@ EditorNode::EditorNode() { ClassDB::set_class_enabled("RootMotionView", true); //defs here, use EDITOR_GET in logic - EDITOR_DEF("interface/scene_tabs/always_show_close_button", false); - EDITOR_DEF("interface/scene_tabs/resize_if_many_tabs", true); - EDITOR_DEF("interface/scene_tabs/minimum_width", 50); + EDITOR_DEF_RST("interface/scene_tabs/always_show_close_button", false); + EDITOR_DEF_RST("interface/scene_tabs/resize_if_many_tabs", true); + EDITOR_DEF_RST("interface/scene_tabs/minimum_width", 50); EDITOR_DEF("run/output/always_clear_output_on_play", true); EDITOR_DEF("run/output/always_open_output_on_play", true); EDITOR_DEF("run/output/always_close_output_on_stop", true); EDITOR_DEF("run/auto_save/save_before_running", true); - EDITOR_DEF("interface/editor/save_each_scene_on_quit", true); + EDITOR_DEF_RST("interface/editor/save_each_scene_on_quit", true); EDITOR_DEF("interface/editor/quit_confirmation", true); - EDITOR_DEF("interface/scene_tabs/restore_scenes_on_load", false); - EDITOR_DEF("interface/scene_tabs/show_thumbnail_on_hover", true); - EDITOR_DEF("interface/inspector/capitalize_properties", true); - EDITOR_DEF("interface/inspector/disable_folding", false); + EDITOR_DEF_RST("interface/scene_tabs/restore_scenes_on_load", false); + EDITOR_DEF_RST("interface/scene_tabs/show_thumbnail_on_hover", true); + EDITOR_DEF_RST("interface/inspector/capitalize_properties", true); + EDITOR_DEF_RST("interface/inspector/disable_folding", false); EDITOR_DEF("interface/inspector/open_resources_in_current_inspector", true); EDITOR_DEF("interface/inspector/resources_types_to_open_in_new_inspector", "SpatialMaterial"); EDITOR_DEF("run/auto_save/save_before_running", true); @@ -5191,6 +5241,37 @@ EditorNode::EditorNode() { play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5)); #endif + video_driver = memnew(OptionButton); + video_driver->set_flat(true); + video_driver->set_focus_mode(Control::FOCUS_NONE); + video_driver->set_v_size_flags(Control::SIZE_SHRINK_CENTER); + String video_drivers = ProjectSettings::get_singleton()->get_custom_property_info()["rendering/quality/driver/driver_name"].hint_string; + String current_video_driver = OS::get_singleton()->get_video_driver_name(OS::get_singleton()->get_current_video_driver()); + menu_hb->add_child(video_driver); + video_driver_current = 0; + for (int i = 0; i < video_drivers.get_slice_count(","); i++) { + String driver = video_drivers.get_slice(",", i); + if (gui_base->has_icon(driver, "EditorIcons")) { + video_driver->add_icon_item(gui_base->get_icon(driver, "EditorIcons"), ""); + } else { + video_driver->add_item(driver); + } + + video_driver->set_item_metadata(i, driver); + + if (current_video_driver == driver) { + video_driver->select(i); + video_driver_current = i; + } + } + + video_driver->connect("item_selected", this, "_video_driver_selected"); + video_restart_dialog = memnew(ConfirmationDialog); + video_restart_dialog->set_text(TTR("Changing the video driver requires restarting the editor.")); + video_restart_dialog->get_ok()->set_text(TTR("Save & Restart")); + video_restart_dialog->connect("confirmed", this, "_menu_option", varray(SET_VIDEO_DRIVER_SAVE_AND_RESTART)); + add_child(video_restart_dialog); + progress_hb = memnew(BackgroundProgress); HBoxContainer *right_menu_hb = memnew(HBoxContainer); diff --git a/editor/editor_node.h b/editor/editor_node.h index 88fe008b34a..38e68b2e090 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -182,6 +182,8 @@ private: HELP_COMMUNITY, HELP_ABOUT, + SET_VIDEO_DRIVER_SAVE_AND_RESTART, + IMPORT_PLUGIN_BASE = 100, TOOL_MENU_BASE = 1000 @@ -194,6 +196,13 @@ private: Control *gui_base; VBoxContainer *main_vbox; PanelContainer *play_button_panel; + OptionButton *video_driver; + + ConfirmationDialog *video_restart_dialog; + + int video_driver_current; + String video_driver_request; + void _video_driver_selected(int); //split @@ -745,6 +754,8 @@ public: void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu); void remove_tool_menu_item(const String &p_name); + void save_all_scenes_and_restart(); + void dim_editor(bool p_dimming); void edit_current() { _edit_current(); }; diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp new file mode 100644 index 00000000000..72050cd79b4 --- /dev/null +++ b/editor/editor_sectioned_inspector.cpp @@ -0,0 +1,306 @@ +#include "editor_sectioned_inspector.h" +#include "editor_scale.h" +class SectionedInspectorFilter : public Object { + + GDCLASS(SectionedInspectorFilter, Object); + + Object *edited; + String section; + bool allow_sub; + + bool _set(const StringName &p_name, const Variant &p_value) { + + if (!edited) + return false; + + String name = p_name; + if (section != "") { + name = section + "/" + name; + } + + bool valid; + edited->set(name, p_value, &valid); + return valid; + } + + bool _get(const StringName &p_name, Variant &r_ret) const { + + if (!edited) + return false; + + String name = p_name; + if (section != "") { + name = section + "/" + name; + } + + bool valid = false; + + r_ret = edited->get(name, &valid); + return valid; + } + void _get_property_list(List *p_list) const { + + if (!edited) + return; + + List pinfo; + edited->get_property_list(&pinfo); + for (List::Element *E = pinfo.front(); E; E = E->next()) { + + PropertyInfo pi = E->get(); + int sp = pi.name.find("/"); + + if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/")) //skip resource stuff + continue; + + if (sp == -1) { + pi.name = "global/" + pi.name; + } + + if (pi.name.begins_with(section + "/")) { + pi.name = pi.name.replace_first(section + "/", ""); + if (!allow_sub && pi.name.find("/") != -1) + continue; + p_list->push_back(pi); + } + } + } + + bool property_can_revert(const String &p_name) { + + return edited->call("property_can_revert", section + "/" + p_name); + } + + Variant property_get_revert(const String &p_name) { + + return edited->call("property_get_revert", section + "/" + p_name); + } + +protected: + static void _bind_methods() { + + ClassDB::bind_method("property_can_revert", &SectionedInspectorFilter::property_can_revert); + ClassDB::bind_method("property_get_revert", &SectionedInspectorFilter::property_get_revert); + } + +public: + void set_section(const String &p_section, bool p_allow_sub) { + + section = p_section; + allow_sub = p_allow_sub; + _change_notify(); + } + + void set_edited(Object *p_edited) { + edited = p_edited; + _change_notify(); + } + + SectionedInspectorFilter() { + edited = NULL; + } +}; + +void SectionedInspector::_bind_methods() { + + ClassDB::bind_method("_section_selected", &SectionedInspector::_section_selected); + ClassDB::bind_method("_search_changed", &SectionedInspector::_search_changed); + + ClassDB::bind_method("update_category_list", &SectionedInspector::update_category_list); +} + +void SectionedInspector::_section_selected() { + + if (!sections->get_selected()) + return; + + filter->set_section(sections->get_selected()->get_metadata(0), sections->get_selected()->get_children() == NULL); + inspector->set_property_prefix(String(sections->get_selected()->get_metadata(0)) + "/"); +} + +void SectionedInspector::set_current_section(const String &p_section) { + + if (section_map.has(p_section)) { + section_map[p_section]->select(0); + } +} + +String SectionedInspector::get_current_section() const { + + if (sections->get_selected()) + return sections->get_selected()->get_metadata(0); + else + return ""; +} + +String SectionedInspector::get_full_item_path(const String &p_item) { + + String base = get_current_section(); + + if (base != "") + return base + "/" + p_item; + else + return p_item; +} + +void SectionedInspector::edit(Object *p_object) { + + if (!p_object) { + obj = -1; + sections->clear(); + + filter->set_edited(NULL); + inspector->edit(NULL); + + return; + } + + ObjectID id = p_object->get_instance_id(); + + inspector->set_object_class(p_object->get_class()); + + if (obj != id) { + + obj = id; + update_category_list(); + + filter->set_edited(p_object); + inspector->edit(filter); + + if (sections->get_root()->get_children()) { + sections->get_root()->get_children()->select(0); + } + } else { + + update_category_list(); + } +} + +void SectionedInspector::update_category_list() { + + String selected_category = get_current_section(); + sections->clear(); + + Object *o = ObjectDB::get_instance(obj); + + if (!o) + return; + + List pinfo; + o->get_property_list(&pinfo); + + section_map.clear(); + + TreeItem *root = sections->create_item(); + section_map[""] = root; + + for (List::Element *E = pinfo.front(); E; E = E->next()) { + + PropertyInfo pi = E->get(); + + if (pi.usage & PROPERTY_USAGE_CATEGORY) + continue; + else if (!(pi.usage & PROPERTY_USAGE_EDITOR)) + continue; + + if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path" || pi.name == "resource_local_to_scene") + continue; + + if (search_box && search_box->get_text() != String() && pi.name.findn(search_box->get_text()) == -1) + continue; + + int sp = pi.name.find("/"); + if (sp == -1) + pi.name = "Global/" + pi.name; + + Vector sectionarr = pi.name.split("/"); + String metasection; + + int sc = MIN(2, sectionarr.size() - 1); + + for (int i = 0; i < sc; i++) { + + TreeItem *parent = section_map[metasection]; + parent->set_custom_bg_color(0, get_color("prop_subsection", "Editor")); + + if (i > 0) { + metasection += "/" + sectionarr[i]; + } else { + metasection = sectionarr[i]; + } + + if (!section_map.has(metasection)) { + TreeItem *ms = sections->create_item(parent); + section_map[metasection] = ms; + ms->set_text(0, sectionarr[i].capitalize()); + ms->set_metadata(0, metasection); + ms->set_selectable(0, false); + } + + if (i == sc - 1) { + //if it has children, make selectable + section_map[metasection]->set_selectable(0, true); + } + } + } + + if (section_map.has(selected_category)) { + section_map[selected_category]->select(0); + } + + inspector->update_tree(); +} + +void SectionedInspector::register_search_box(LineEdit *p_box) { + + search_box = p_box; + inspector->register_text_enter(p_box); + search_box->connect("text_changed", this, "_search_changed"); +} + +void SectionedInspector::_search_changed(const String &p_what) { + + update_category_list(); +} + +EditorInspector *SectionedInspector::get_inspector() { + + return inspector; +} + +SectionedInspector::SectionedInspector() { + + obj = -1; + + search_box = NULL; + + add_constant_override("autohide", 1); // Fixes the dragger always showing up + + VBoxContainer *left_vb = memnew(VBoxContainer); + left_vb->set_custom_minimum_size(Size2(170, 0) * EDSCALE); + add_child(left_vb); + + sections = memnew(Tree); + sections->set_v_size_flags(SIZE_EXPAND_FILL); + sections->set_hide_root(true); + + left_vb->add_child(sections, true); + + VBoxContainer *right_vb = memnew(VBoxContainer); + right_vb->set_custom_minimum_size(Size2(300, 0) * EDSCALE); + right_vb->set_h_size_flags(SIZE_EXPAND_FILL); + add_child(right_vb); + + filter = memnew(SectionedInspectorFilter); + inspector = memnew(EditorInspector); + inspector->set_v_size_flags(SIZE_EXPAND_FILL); + right_vb->add_child(inspector, true); + inspector->set_use_doc_hints(true); + + sections->connect("cell_selected", this, "_section_selected"); +} + +SectionedInspector::~SectionedInspector() { + + memdelete(filter); +} diff --git a/editor/editor_sectioned_inspector.h b/editor/editor_sectioned_inspector.h new file mode 100644 index 00000000000..75b51a1581f --- /dev/null +++ b/editor/editor_sectioned_inspector.h @@ -0,0 +1,42 @@ +#ifndef EDITOR_SECTIONED_INSPECTOR_H +#define EDITOR_SECTIONED_INSPECTOR_H + +#include "editor/editor_inspector.h" +#include "scene/gui/split_container.h" +#include "scene/gui/tree.h" + +class SectionedInspectorFilter; + +class SectionedInspector : public HSplitContainer { + + GDCLASS(SectionedInspector, HSplitContainer); + + ObjectID obj; + + Tree *sections; + SectionedInspectorFilter *filter; + + Map section_map; + EditorInspector *inspector; + LineEdit *search_box; + + static void _bind_methods(); + void _section_selected(); + + void _search_changed(const String &p_what); + +public: + void register_search_box(LineEdit *p_box); + EditorInspector *get_inspector(); + void edit(Object *p_object); + String get_full_item_path(const String &p_item); + + void set_current_section(const String &p_section); + String get_current_section() const; + + void update_category_list(); + + SectionedInspector(); + ~SectionedInspector(); +}; +#endif // EDITOR_SECTIONED_INSPECTOR_H diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 4045d6c3d3a..4cfdb6f6d36 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -165,6 +165,7 @@ struct _EVCSort { Variant::Type type; int order; bool save; + bool restart_if_changed; bool operator<(const _EVCSort &p_vcs) const { return order < p_vcs.order; } }; @@ -188,6 +189,7 @@ void EditorSettings::_get_property_list(List *p_list) const { vc.order = v->order; vc.type = v->variant.get_type(); vc.save = v->save; + vc.restart_if_changed = v->restart_if_changed; vclist.insert(vc); } @@ -210,6 +212,10 @@ void EditorSettings::_get_property_list(List *p_list) const { if (hints.has(E->get().name)) pi = hints[E->get().name]; + if (E->get().restart_if_changed) { + pi.usage |= PROPERTY_USAGE_RESTART_IF_CHANGED; + } + p_list->push_back(pi); } @@ -280,6 +286,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { } _initial_set("interface/editor/editor_language", best); + set_restart_if_changed("interface/editor/editor_language", true); hints["interface/editor/editor_language"] = PropertyInfo(Variant::STRING, "interface/editor/editor_language", PROPERTY_HINT_ENUM, lang_hint, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); } @@ -1017,6 +1024,14 @@ void EditorSettings::raise_order(const String &p_setting) { props[p_setting].order = ++last_order; } +void EditorSettings::set_restart_if_changed(const StringName &p_setting, bool p_restart) { + _THREAD_SAFE_METHOD_ + + if (!props.has(p_setting)) + return; + props[p_setting].restart_if_changed = p_restart; +} + void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value, bool p_update_current) { _THREAD_SAFE_METHOD_ @@ -1030,16 +1045,19 @@ void EditorSettings::set_initial_value(const StringName &p_setting, const Varian } } -Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default) { +Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_restart_if_changed) { Variant ret = p_default; - if (EditorSettings::get_singleton()->has_setting(p_setting)) + if (EditorSettings::get_singleton()->has_setting(p_setting)) { ret = EditorSettings::get_singleton()->get(p_setting); - else + } else { EditorSettings::get_singleton()->set_manually(p_setting, p_default); + EditorSettings::get_singleton()->set_restart_if_changed(p_setting, p_restart_if_changed); + } - if (!EditorSettings::get_singleton()->has_default_value(p_setting)) + if (!EditorSettings::get_singleton()->has_default_value(p_setting)) { EditorSettings::get_singleton()->set_initial_value(p_setting, p_default); + } return ret; } diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 420e067cadb..e5b61abf547 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -70,6 +70,7 @@ private: bool has_default_value; bool hide_from_editor; bool save; + bool restart_if_changed; VariantContainer() { variant = Variant(); initial = Variant(); @@ -77,6 +78,7 @@ private: hide_from_editor = false; has_default_value = false; save = false; + restart_if_changed = false; } VariantContainer(const Variant &p_variant, int p_order) { variant = p_variant; @@ -85,6 +87,7 @@ private: hide_from_editor = false; has_default_value = false; save = false; + restart_if_changed = false; } }; @@ -145,6 +148,7 @@ public: void erase(const String &p_setting); void raise_order(const String &p_setting); void set_initial_value(const StringName &p_setting, const Variant &p_value, bool p_update_current = false); + void set_restart_if_changed(const StringName &p_setting, bool p_restart); void set_manually(const StringName &p_setting, const Variant &p_value, bool p_emit_signal = false) { if (p_emit_signal) _set(p_setting, p_value); @@ -200,7 +204,8 @@ public: //not a macro any longer #define EDITOR_DEF(m_var, m_val) _EDITOR_DEF(m_var, Variant(m_val)) -Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default); +#define EDITOR_DEF_RST(m_var, m_val) _EDITOR_DEF(m_var, Variant(m_val), true) +Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default, bool p_restart_if_changed = false); #define EDITOR_GET(m_var) _EDITOR_GET(m_var) Variant _EDITOR_GET(const String &p_setting); diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index 79023a1f284..0e6d81d13ba 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -268,7 +268,8 @@ void EditorSpinSlider::_notification(int p_what) { update(); } if (p_what == NOTIFICATION_FOCUS_ENTER) { - /* Sorry, I dont like this, it makes navigating the different fields with arrows more difficult + /* Sorry, I dont like this, it makes navigating the different fields with arrows more difficult. + * Just press enter to edit. * if (!Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && !value_input_just_closed) { _focus_entered(); }*/ diff --git a/editor/icons/icon_g_l_e_s_2.svg b/editor/icons/icon_g_l_e_s_2.svg new file mode 100644 index 00000000000..efc4f01e4fc --- /dev/null +++ b/editor/icons/icon_g_l_e_s_2.svg @@ -0,0 +1,69 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/editor/icons/icon_g_l_e_s_3.svg b/editor/icons/icon_g_l_e_s_3.svg new file mode 100644 index 00000000000..dfa3c26b384 --- /dev/null +++ b/editor/icons/icon_g_l_e_s_3.svg @@ -0,0 +1,67 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/editor/icons/icon_vulkan.svg b/editor/icons/icon_vulkan.svg new file mode 100644 index 00000000000..1d5fed03057 --- /dev/null +++ b/editor/icons/icon_vulkan.svg @@ -0,0 +1,127 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 7e4e589bb42..e6ae2d64e73 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -106,6 +106,12 @@ void ProjectSettingsEditor::_notification(int p_what) { translation_res_file_open->add_filter("*." + E->get()); translation_res_option_file_open->add_filter("*." + E->get()); } + + restart_close_button->set_icon(get_icon("Close", "EditorIcons")); + restart_container->add_style_override("panel", get_stylebox("bg", "Tree")); + restart_icon->set_texture(get_icon("StatusWarning", "EditorIcons")); + restart_label->add_color_override("font_color", get_color("error_color", "Editor")); + } break; case NOTIFICATION_POPUP_HIDE: { EditorSettings::get_singleton()->set("interface/dialogs/project_settings_bounds", get_rect()); @@ -800,15 +806,13 @@ void ProjectSettingsEditor::popup_project_settings() { plugin_settings->update_plugins(); } -void ProjectSettingsEditor::_item_selected() { +void ProjectSettingsEditor::_item_selected(const String &p_path) { - TreeItem *ti = globals_editor->get_property_editor()->get_property_tree()->get_selected(); - if (!ti) - return; - if (!ti->get_parent()) + String selected_path = p_path; + if (selected_path == String()) return; category->set_text(globals_editor->get_current_section()); - property->set_text(ti->get_text(0)); + property->set_text(selected_path); popup_copy_to_feature->set_disabled(false); } @@ -865,7 +869,7 @@ void ProjectSettingsEditor::_item_add() { void ProjectSettingsEditor::_item_del() { - String path = globals_editor->get_property_editor()->get_selected_path(); + String path = globals_editor->get_inspector()->get_selected_path(); if (path == String()) { EditorNode::get_singleton()->show_warning(TTR("Select a setting item first!")); return; @@ -1043,7 +1047,7 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() { void ProjectSettingsEditor::_copy_to_platform(int p_which) { - String path = globals_editor->get_property_editor()->get_selected_path(); + String path = globals_editor->get_inspector()->get_selected_path(); if (path == String()) { EditorNode::get_singleton()->show_warning(TTR("Select a setting item first!")); return; @@ -1572,7 +1576,7 @@ void ProjectSettingsEditor::_update_translations() { void ProjectSettingsEditor::_toggle_search_bar(bool p_pressed) { - globals_editor->get_property_editor()->set_use_filter(p_pressed); + globals_editor->get_inspector()->set_use_filter(p_pressed); if (p_pressed) { @@ -1593,7 +1597,7 @@ void ProjectSettingsEditor::_clear_search_box() { return; search_box->clear(); - globals_editor->get_property_editor()->update_tree(); + globals_editor->get_inspector()->update_tree(); } void ProjectSettingsEditor::set_plugins_page() { @@ -1606,6 +1610,18 @@ TabContainer *ProjectSettingsEditor::get_tabs() { return tab_container; } +void ProjectSettingsEditor::_editor_restart() { + EditorNode::get_singleton()->save_all_scenes_and_restart(); +} + +void ProjectSettingsEditor::_editor_restart_request() { + restart_container->show(); +} + +void ProjectSettingsEditor::_editor_restart_close() { + restart_container->hide(); +} + void ProjectSettingsEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_item_selected"), &ProjectSettingsEditor::_item_selected); @@ -1651,6 +1667,10 @@ void ProjectSettingsEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_copy_to_platform_about_to_show"), &ProjectSettingsEditor::_copy_to_platform_about_to_show); + ClassDB::bind_method(D_METHOD("_editor_restart_request"), &ProjectSettingsEditor::_editor_restart_request); + ClassDB::bind_method(D_METHOD("_editor_restart"), &ProjectSettingsEditor::_editor_restart); + ClassDB::bind_method(D_METHOD("_editor_restart_close"), &ProjectSettingsEditor::_editor_restart_close); + ClassDB::bind_method(D_METHOD("get_tabs"), &ProjectSettingsEditor::get_tabs); } @@ -1737,16 +1757,17 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { search_bar->add_child(clear_button); clear_button->connect("pressed", this, "_clear_search_box"); - globals_editor = memnew(SectionedPropertyEditor); + globals_editor = memnew(SectionedInspector); props_base->add_child(globals_editor); - globals_editor->get_property_editor()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo()); - globals_editor->get_property_editor()->set_property_selectable(true); + globals_editor->get_inspector()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo()); + globals_editor->get_inspector()->set_property_selectable(true); //globals_editor->hide_top_label(); globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); globals_editor->register_search_box(search_box); - globals_editor->get_property_editor()->get_property_tree()->connect("cell_selected", this, "_item_selected"); - globals_editor->get_property_editor()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED); - globals_editor->get_property_editor()->connect("property_edited", this, "_settings_prop_edited"); + globals_editor->get_inspector()->connect("property_selected", this, "_item_selected"); + //globals_editor->get_inspector()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED); + globals_editor->get_inspector()->connect("property_edited", this, "_settings_prop_edited"); + globals_editor->get_inspector()->connect("restart_requested", this, "_editor_restart_request"); Button *del = memnew(Button); hbc->add_child(del); @@ -1766,6 +1787,26 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { get_ok()->set_text(TTR("Close")); set_hide_on_ok(true); + restart_container = memnew(PanelContainer); + props_base->add_child(restart_container); + HBoxContainer *restart_hb = memnew(HBoxContainer); + restart_container->add_child(restart_hb); + restart_icon = memnew(TextureRect); + restart_icon->set_v_size_flags(SIZE_SHRINK_CENTER); + restart_hb->add_child(restart_icon); + restart_label = memnew(Label); + restart_label->set_text(TTR("Editor must be restarted for changes to take effect")); + restart_hb->add_child(restart_label); + restart_hb->add_spacer(); + Button *restart_button = memnew(Button); + restart_button->connect("pressed", this, "_editor_restart"); + restart_hb->add_child(restart_button); + restart_button->set_text(TTR("Save & Restart")); + restart_close_button = memnew(ToolButton); + restart_close_button->connect("pressed", this, "_editor_restart_close"); + restart_hb->add_child(restart_close_button); + restart_container->hide(); + message = memnew(AcceptDialog); add_child(message); diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index 0ced88d7f6a..3b74ae19091 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -35,7 +35,7 @@ #include "editor/editor_autoload_settings.h" #include "editor/editor_data.h" #include "editor/editor_plugin_settings.h" -#include "editor/property_editor.h" +#include "editor/editor_sectioned_inspector.h" #include "scene/gui/dialogs.h" #include "scene/gui/tab_container.h" @@ -64,7 +64,7 @@ class ProjectSettingsEditor : public AcceptDialog { EditorData *data; UndoRedo *undo_redo; - SectionedPropertyEditor *globals_editor; + SectionedInspector *globals_editor; HBoxContainer *search_bar; Button *search_button; @@ -112,7 +112,7 @@ class ProjectSettingsEditor : public AcceptDialog { EditorPluginSettings *plugin_settings; - void _item_selected(); + void _item_selected(const String &); void _item_adds(String); void _item_add(); void _item_del(); @@ -166,6 +166,15 @@ class ProjectSettingsEditor : public AcceptDialog { static ProjectSettingsEditor *singleton; + Label *restart_label; + TextureRect *restart_icon; + PanelContainer *restart_container; + ToolButton *restart_close_button; + + void _editor_restart_request(); + void _editor_restart(); + void _editor_restart_close(); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index ae88b3a0353..fe379703e57 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -54,12 +54,12 @@ void EditorSettingsDialog::_settings_changed() { void EditorSettingsDialog::_settings_property_edited(const String &p_name) { - String full_name = property_editor->get_full_item_path(p_name); + String full_name = inspector->get_full_item_path(p_name); // Small usability workaround to update the text color settings when the // color theme is changed if (full_name == "text_editor/theme/color_theme") { - property_editor->get_property_editor()->update_tree(); + inspector->get_inspector()->update_tree(); } else if (full_name == "interface/theme/accent_color" || full_name == "interface/theme/base_color" || full_name == "interface/theme/contrast") { EditorSettings::get_singleton()->set_manually("interface/theme/preset", "Custom"); // set preset to Custom } else if (full_name.begins_with("text_editor/highlighting")) { @@ -88,8 +88,8 @@ void EditorSettingsDialog::popup_edit_settings() { EditorSettings::get_singleton()->list_text_editor_themes(); // make sure we have an up to date list of themes - property_editor->edit(EditorSettings::get_singleton()); - property_editor->get_property_editor()->update_tree(); + inspector->edit(EditorSettings::get_singleton()); + inspector->get_inspector()->update_tree(); search_box->select_all(); search_box->grab_focus(); @@ -120,7 +120,7 @@ void EditorSettingsDialog::_clear_search_box() { return; search_box->clear(); - property_editor->get_property_editor()->update_tree(); + inspector->get_inspector()->update_tree(); } void EditorSettingsDialog::_clear_shortcut_search_box() { @@ -158,7 +158,7 @@ void EditorSettingsDialog::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { _update_icons(); // Update theme colors. - property_editor->update_category_list(); + inspector->update_category_list(); _update_shortcuts(); } break; } @@ -202,6 +202,11 @@ void EditorSettingsDialog::_update_icons() { shortcut_search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons")); clear_button->set_icon(get_icon("Close", "EditorIcons")); shortcut_clear_button->set_icon(get_icon("Close", "EditorIcons")); + + restart_close_button->set_icon(get_icon("Close", "EditorIcons")); + restart_container->add_style_override("panel", get_stylebox("bg", "Tree")); + restart_icon->set_texture(get_icon("StatusWarning", "EditorIcons")); + restart_label->add_color_override("font_color", get_color("error_color", "Editor")); } void EditorSettingsDialog::_update_shortcuts() { @@ -388,6 +393,18 @@ void EditorSettingsDialog::_focus_current_search_box() { } } +void EditorSettingsDialog::_editor_restart() { + EditorNode::get_singleton()->save_all_scenes_and_restart(); +} + +void EditorSettingsDialog::_editor_restart_request() { + restart_container->show(); +} + +void EditorSettingsDialog::_editor_restart_close() { + restart_container->hide(); +} + void EditorSettingsDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("_unhandled_input"), &EditorSettingsDialog::_unhandled_input); @@ -402,6 +419,10 @@ void EditorSettingsDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("_press_a_key_confirm"), &EditorSettingsDialog::_press_a_key_confirm); ClassDB::bind_method(D_METHOD("_wait_for_key"), &EditorSettingsDialog::_wait_for_key); ClassDB::bind_method(D_METHOD("_tabs_tab_changed"), &EditorSettingsDialog::_tabs_tab_changed); + + ClassDB::bind_method(D_METHOD("_editor_restart_request"), &EditorSettingsDialog::_editor_restart_request); + ClassDB::bind_method(D_METHOD("_editor_restart"), &EditorSettingsDialog::_editor_restart); + ClassDB::bind_method(D_METHOD("_editor_restart_close"), &EditorSettingsDialog::_editor_restart_close); } EditorSettingsDialog::EditorSettingsDialog() { @@ -434,14 +455,35 @@ EditorSettingsDialog::EditorSettingsDialog() { hbc->add_child(clear_button); clear_button->connect("pressed", this, "_clear_search_box"); - property_editor = memnew(SectionedPropertyEditor); - //property_editor->hide_top_label(); - property_editor->get_property_editor()->set_use_filter(true); - property_editor->register_search_box(search_box); - property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); - property_editor->get_property_editor()->set_undo_redo(undo_redo); - tab_general->add_child(property_editor); - property_editor->get_property_editor()->connect("property_edited", this, "_settings_property_edited"); + inspector = memnew(SectionedInspector); + //inspector->hide_top_label(); + inspector->get_inspector()->set_use_filter(true); + inspector->register_search_box(search_box); + inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL); + inspector->get_inspector()->set_undo_redo(undo_redo); + tab_general->add_child(inspector); + inspector->get_inspector()->connect("property_edited", this, "_settings_property_edited"); + inspector->get_inspector()->connect("restart_requested", this, "_editor_restart_request"); + + restart_container = memnew(PanelContainer); + tab_general->add_child(restart_container); + HBoxContainer *restart_hb = memnew(HBoxContainer); + restart_container->add_child(restart_hb); + restart_icon = memnew(TextureRect); + restart_icon->set_v_size_flags(SIZE_SHRINK_CENTER); + restart_hb->add_child(restart_icon); + restart_label = memnew(Label); + restart_label->set_text(TTR("Editor must be restarted for changes to take effect")); + restart_hb->add_child(restart_label); + restart_hb->add_spacer(); + Button *restart_button = memnew(Button); + restart_button->connect("pressed", this, "_editor_restart"); + restart_hb->add_child(restart_button); + restart_button->set_text(TTR("Save & Restart")); + restart_close_button = memnew(ToolButton); + restart_close_button->connect("pressed", this, "_editor_restart_close"); + restart_hb->add_child(restart_close_button); + restart_container->hide(); // Shortcuts Tab diff --git a/editor/settings_config_dialog.h b/editor/settings_config_dialog.h index 6676e870d05..6cf2eb6bdf5 100644 --- a/editor/settings_config_dialog.h +++ b/editor/settings_config_dialog.h @@ -31,9 +31,14 @@ #ifndef SETTINGS_CONFIG_DIALOG_H #define SETTINGS_CONFIG_DIALOG_H -#include "property_editor.h" +#include "editor/editor_sectioned_inspector.h" +#include "editor_inspector.h" +#include "scene/gui/dialogs.h" +#include "scene/gui/panel_container.h" #include "scene/gui/rich_text_label.h" #include "scene/gui/tab_container.h" +#include "scene/gui/texture_rect.h" +#include "scene/gui/tool_button.h" class EditorSettingsDialog : public AcceptDialog { @@ -49,7 +54,7 @@ class EditorSettingsDialog : public AcceptDialog { LineEdit *shortcut_search_box; ToolButton *clear_button; ToolButton *shortcut_clear_button; - SectionedPropertyEditor *property_editor; + SectionedInspector *inspector; Timer *timer; @@ -89,6 +94,15 @@ class EditorSettingsDialog : public AcceptDialog { static void _undo_redo_callback(void *p_self, const String &p_name); + Label *restart_label; + TextureRect *restart_icon; + PanelContainer *restart_container; + ToolButton *restart_close_button; + + void _editor_restart_request(); + void _editor_restart(); + void _editor_restart_close(); + protected: static void _bind_methods(); diff --git a/main/main.cpp b/main/main.cpp index 23f2776737f..530b264615c 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -825,7 +825,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->set_cmdline(execpath, main_args); GLOBAL_DEF("rendering/quality/driver/driver_name", "GLES3"); - ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/driver/driver_name", PropertyInfo(Variant::STRING, "rendering/quality/driver/driver_name", PROPERTY_HINT_ENUM, "GLES3,GLES2")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/driver/driver_name", PropertyInfo(Variant::STRING, "rendering/quality/driver/driver_name", PROPERTY_HINT_ENUM, "GLES2,GLES3")); if (video_driver == "") { video_driver = GLOBAL_GET("rendering/quality/driver/driver_name"); } @@ -914,7 +914,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } if (audio_driver == "") { // specified in project.godot - audio_driver = GLOBAL_DEF("audio/driver", OS::get_singleton()->get_audio_driver_name(0)); + audio_driver = GLOBAL_DEF_RST("audio/driver", OS::get_singleton()->get_audio_driver_name(0)); } for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) { @@ -1957,6 +1957,15 @@ void Main::cleanup() { if (engine) memdelete(engine); + if (OS::get_singleton()->is_restart_on_exit_set()) { + //attempt to restart with arguments + String exec = OS::get_singleton()->get_executable_path(); + List args = OS::get_singleton()->get_restart_on_exit_argumens(); + OS::ProcessID pid = 0; + OS::get_singleton()->execute(exec, args, false, &pid); + OS::get_singleton()->set_restart_on_exit(false, List()); //clear list (uses memory) + } + unregister_core_driver_types(); unregister_core_types(); diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index 3d80e767070..b9f1f1eab05 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -78,9 +78,9 @@ Error AudioDriverAndroid::init() { // __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device"); JNIEnv *env = ThreadAndroid::get_env(); - int mix_rate = GLOBAL_DEF("audio/mix_rate", 44100); + int mix_rate = GLOBAL_DEF_RST("audio/mix_rate", 44100); - int latency = GLOBAL_DEF("audio/output_latency", 25); + int latency = GLOBAL_DEF_RST("audio/output_latency", 25); unsigned int buffer_size = next_power_of_2(latency * mix_rate / 1000); if (OS::get_singleton()->is_stdout_verbose()) { print_line("audio buffer size: " + itos(buffer_size)); diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 9188f09f213..3648f6f37aa 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -123,6 +123,9 @@ void OS_Android::set_opengl_extensions(const char *p_gl_extensions) { ERR_FAIL_COND(!p_gl_extensions); gl_extensions = p_gl_extensions; } +int OS_Android::get_current_video_driver() const { + return video_driver_index; +} Error OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { @@ -136,9 +139,11 @@ Error OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int if (use_gl2) { RasterizerGLES2::register_config(); RasterizerGLES2::make_current(); + video_driver_index = VIDEO_DRIVER_GLES2; } else { RasterizerGLES3::register_config(); RasterizerGLES3::make_current(); + video_driver_index = VIDEO_DRIVER_GLES3; } visual_server = memnew(VisualServerRaster); diff --git a/platform/android/os_android.h b/platform/android/os_android.h index ac901d4832b..c4220906a38 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -137,6 +137,7 @@ private: AlertFunc alert_func; //power_android *power_manager; + int video_driver_index; public: // functions used by main to initialize/deintialize the OS @@ -146,6 +147,8 @@ public: virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; + virtual int get_current_video_driver() const; + virtual void initialize_core(); virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp index 278a994c547..1f901c49190 100644 --- a/platform/haiku/audio_driver_media_kit.cpp +++ b/platform/haiku/audio_driver_media_kit.cpp @@ -43,7 +43,7 @@ Error AudioDriverMediaKit::init() { speaker_mode = SPEAKER_MODE_STEREO; channels = 2; - int latency = GLOBAL_DEF("audio/output_latency", 25); + int latency = GLOBAL_DEF_RST("audio/output_latency", 25); buffer_size = next_power_of_2(latency * mix_rate / 1000); samples_in = memnew_arr(int32_t, buffer_size * channels); diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 4caf4bd933b..098ad632cf1 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -93,8 +93,14 @@ void OSIPhone::initialize_core() { set_data_dir(data_dir); }; +int OSIPhone::get_current_video_driver() const { + return video_driver_index; +} + Error OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { + video_driver = p_video_driver; //this may be misleading + RasterizerGLES3::register_config(); RasterizerGLES3::make_current(); diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 8dc1ae6dc29..db2912ad934 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -77,6 +77,8 @@ private: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; + virtual int get_current_video_driver() const; + virtual void initialize_core(); virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); @@ -112,6 +114,8 @@ private: int virtual_keyboard_height; + int video_driver_index; + public: bool iterate(); diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index c05ae03ec6e..b9d586e2337 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -643,6 +643,9 @@ const char *OS_JavaScript::get_audio_driver_name(int p_driver) const { } // Lifecycle +int OS_JavaScript::get_current_video_driver() const { + return video_driver_index; +} void OS_JavaScript::initialize_core() { @@ -669,6 +672,8 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, RasterizerGLES2::make_current(); break; } + + video_driver_index = p_video_driver; EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context(NULL, &attributes); ERR_EXPLAIN("WebGL " + itos(attributes.majorVersion) + ".0 not available"); ERR_FAIL_COND_V(emscripten_webgl_make_context_current(ctx) != EMSCRIPTEN_RESULT_SUCCESS, ERR_UNAVAILABLE); diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 503c92585b7..915320fe39c 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -81,7 +81,11 @@ class OS_JavaScript : public OS_Unix { static void file_access_close_callback(const String &p_file, int p_flags); + int video_driver_index; + protected: + virtual int get_current_video_driver() const; + virtual void initialize_core(); virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 7bd5b16f36f..3d14a6d4fbc 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -137,6 +137,9 @@ public: void _update_window(); + int video_driver_index; + virtual int get_current_video_driver() const; + protected: virtual void initialize_core(); virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 41a19ac9923..282f5e2d1b2 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1176,6 +1176,10 @@ static void displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplay displays_arrangement_dirty = true; } +int OS_OSX::get_current_video_driver() const { + return video_driver_index; +} + Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { /*** OSX INITIALIZATION ***/ @@ -1272,6 +1276,8 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a ADD_ATTR2(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core); } + video_driver_index = p_video_driver; + ADD_ATTR2(NSOpenGLPFAColorSize, colorBits); /* diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 05d16a5964e..ac37e1246da 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1012,6 +1012,10 @@ typedef enum _SHC_PROCESS_DPI_AWARENESS { SHC_PROCESS_PER_MONITOR_DPI_AWARE = 2 } SHC_PROCESS_DPI_AWARENESS; +int OS_Windows::get_current_video_driver() const { + return video_driver_index; +} + Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { main_loop = NULL; @@ -1181,6 +1185,8 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int RasterizerGLES3::make_current(); } + video_driver_index = p_video_driver; // FIXME TODO - FIX IF DRIVER DETECTION HAPPENS AND GLES2 MUST BE USED + gl_context->set_use_vsync(video_mode.use_vsync); #endif diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 19af63bae0f..b99d3e3422f 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -134,6 +134,7 @@ class OS_Windows : public OS { PowerWindows *power_manager; + int video_driver_index; #ifdef WASAPI_ENABLED AudioDriverWASAPI driver_wasapi; #endif @@ -153,6 +154,8 @@ class OS_Windows : public OS { // functions used by main to initialize/deintialize the OS protected: + virtual int get_current_video_driver() const; + virtual void initialize_core(); virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 2adc8bfb50c..af0e02173f8 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -84,6 +84,10 @@ void OS_X11::initialize_core() { OS_Unix::initialize_core(); } +int OS_X11::get_current_video_driver() const { + return video_driver_index; +} + Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { long im_event_mask = 0; @@ -285,6 +289,8 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a } break; } + video_driver_index = p_video_driver; // FIXME TODO - FIX IF DRIVER DETECTION HAPPENS AND GLES2 MUST BE USED + context_gl->set_use_vsync(current_videomode.use_vsync); #endif @@ -1825,8 +1831,8 @@ void OS_X11::process_xevents() { GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime); } #ifdef TOUCH_ENABLED - // Grab touch devices to avoid OS gesture interference - /*for (int i = 0; i < touch.devices.size(); ++i) { + // Grab touch devices to avoid OS gesture interference + /*for (int i = 0; i < touch.devices.size(); ++i) { XIGrabDevice(x11_display, touch.devices[i], x11_window, CurrentTime, None, XIGrabModeAsync, XIGrabModeAsync, False, &touch.event_mask); }*/ #endif diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 8cab23fe63f..4045a6e7ade 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -180,6 +180,7 @@ class OS_X11 : public OS_Unix { CrashHandler crash_handler; + int video_driver_index; int audio_driver_index; unsigned int capture_idle; bool maximized; @@ -206,6 +207,8 @@ protected: bool is_window_maximize_allowed(); public: + virtual int get_current_video_driver() const; + virtual String get_name(); virtual void set_cursor_shape(CursorShape p_shape); diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp index 1ca23343927..be36c3b748c 100644 --- a/servers/audio/audio_driver_dummy.cpp +++ b/servers/audio/audio_driver_dummy.cpp @@ -44,7 +44,7 @@ Error AudioDriverDummy::init() { speaker_mode = SPEAKER_MODE_STEREO; channels = 2; - int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY); + int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY); buffer_frames = closest_power_of_2(latency * mix_rate / 1000); samples_in = memnew_arr(int32_t, buffer_frames * channels); diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index ef794ac3807..ceb843c031a 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -903,8 +903,8 @@ void AudioServer::init_channels_and_buffers() { void AudioServer::init() { - channel_disable_threshold_db = GLOBAL_DEF("audio/channel_disable_threshold_db", -60.0); - channel_disable_frames = float(GLOBAL_DEF("audio/channel_disable_time", 2.0)) * get_mix_rate(); + channel_disable_threshold_db = GLOBAL_DEF_RST("audio/channel_disable_threshold_db", -60.0); + channel_disable_frames = float(GLOBAL_DEF_RST("audio/channel_disable_time", 2.0)) * get_mix_rate(); buffer_size = 1024; //hardcoded for now init_channels_and_buffers(); @@ -920,7 +920,7 @@ void AudioServer::init() { set_edited(false); //avoid editors from thinking this was edited #endif - GLOBAL_DEF("audio/video_delay_compensation_ms", 0); + GLOBAL_DEF_RST("audio/video_delay_compensation_ms", 0); } void AudioServer::update() {