diff options
-rw-r--r-- | core/os/os.cpp | 28 | ||||
-rw-r--r-- | core/os/os.h | 7 | ||||
-rw-r--r-- | editor/project_manager.cpp | 27 | ||||
-rw-r--r-- | editor/project_manager.h | 4 | ||||
-rw-r--r-- | modules/gdnative/nativescript/nativescript.cpp | 60 | ||||
-rw-r--r-- | platform/javascript/godot_js.h | 1 | ||||
-rw-r--r-- | platform/javascript/js/libs/library_godot_display.js | 11 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 4 |
8 files changed, 106 insertions, 36 deletions
diff --git a/core/os/os.cpp b/core/os/os.cpp index 182bab4058..ca1b798e11 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -106,10 +106,18 @@ void OS::add_logger(Logger *p_logger) { } void OS::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, Logger::ErrorType p_type) { + if (!_stderr_enabled) { + return; + } + _logger->log_error(p_function, p_file, p_line, p_code, p_rationale, p_type); } void OS::print(const char *p_format, ...) { + if (!_stdout_enabled) { + return; + } + va_list argp; va_start(argp, p_format); @@ -119,6 +127,10 @@ void OS::print(const char *p_format, ...) { } void OS::printerr(const char *p_format, ...) { + if (!_stderr_enabled) { + return; + } + va_list argp; va_start(argp, p_format); @@ -163,6 +175,22 @@ bool OS::is_stdout_debug_enabled() const { return _debug_stdout; } +bool OS::is_stdout_enabled() const { + return _stdout_enabled; +} + +bool OS::is_stderr_enabled() const { + return _stderr_enabled; +} + +void OS::set_stdout_enabled(bool p_enabled) { + _stdout_enabled = p_enabled; +} + +void OS::set_stderr_enabled(bool p_enabled) { + _stderr_enabled = p_enabled; +} + void OS::dump_memory_to_file(const char *p_file) { //Memory::dump_static_mem_to_file(p_file); } diff --git a/core/os/os.h b/core/os/os.h index e41d788e12..7198607237 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -60,6 +60,8 @@ class OS { bool _allow_layered = false; bool _use_vsync; bool _vsync_via_compositor; + bool _stdout_enabled = true; + bool _stderr_enabled = true; char *last_error; @@ -219,6 +221,11 @@ public: bool is_stdout_verbose() const; bool is_stdout_debug_enabled() const; + bool is_stdout_enabled() const; + bool is_stderr_enabled() const; + void set_stdout_enabled(bool p_enabled); + void set_stderr_enabled(bool p_enabled); + virtual void disable_crash_handler() {} virtual bool is_disable_crash_handler() const { return false; } virtual void initialize_debugging() {} diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 595110f7b3..d3def86bd1 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1031,7 +1031,7 @@ public: int get_project_count() const; void select_project(int p_index); void select_first_visible_project(); - void erase_selected_projects(); + void erase_selected_projects(bool p_delete_project_contents); Vector<Item> get_selected_projects() const; const Set<String> &get_selected_project_keys() const; void ensure_project_visible(int p_index); @@ -1686,7 +1686,7 @@ void ProjectList::toggle_select(int p_index) { item.control->update(); } -void ProjectList::erase_selected_projects() { +void ProjectList::erase_selected_projects(bool p_delete_project_contents) { if (_selected_project_keys.size() == 0) { return; } @@ -1697,6 +1697,10 @@ void ProjectList::erase_selected_projects() { EditorSettings::get_singleton()->erase("projects/" + item.project_key); EditorSettings::get_singleton()->erase("favorite_projects/" + item.project_key); + if (p_delete_project_contents) { + OS::get_singleton()->move_to_trash(item.path); + } + memdelete(item.control); _projects.remove(i); --i; @@ -2217,7 +2221,7 @@ void ProjectManager::_rename_project() { } void ProjectManager::_erase_project_confirm() { - _project_list->erase_selected_projects(); + _project_list->erase_selected_projects(delete_project_contents->is_pressed()); _update_project_buttons(); } @@ -2235,12 +2239,13 @@ void ProjectManager::_erase_project() { String confirm_message; if (selected_list.size() >= 2) { - confirm_message = vformat(TTR("Remove %d projects from the list?\nThe project folders' contents won't be modified."), selected_list.size()); + confirm_message = vformat(TTR("Remove %d projects from the list?"), selected_list.size()); } else { - confirm_message = TTR("Remove this project from the list?\nThe project folder's contents won't be modified."); + confirm_message = TTR("Remove this project from the list?"); } - erase_ask->set_text(confirm_message); + erase_ask_label->set_text(confirm_message); + delete_project_contents->set_pressed(false); erase_ask->popup_centered(); } @@ -2665,6 +2670,16 @@ ProjectManager::ProjectManager() { erase_ask->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_erase_project_confirm)); add_child(erase_ask); + VBoxContainer *erase_ask_vb = memnew(VBoxContainer); + erase_ask->add_child(erase_ask_vb); + + erase_ask_label = memnew(Label); + erase_ask_vb->add_child(erase_ask_label); + + delete_project_contents = memnew(CheckBox); + delete_project_contents->set_text(TTR("Also delete project contents (no undo!)")); + erase_ask_vb->add_child(delete_project_contents); + multi_open_ask = memnew(ConfirmationDialog); multi_open_ask->get_ok_button()->set_text(TTR("Edit")); multi_open_ask->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_open_selected_projects)); diff --git a/editor/project_manager.h b/editor/project_manager.h index 49d672a8e5..d13315c022 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -67,7 +67,11 @@ class ProjectManager : public Control { FileDialog *scan_dir; ConfirmationDialog *language_restart_ask; + ConfirmationDialog *erase_ask; + Label *erase_ask_label; + CheckBox *delete_project_contents; + ConfirmationDialog *erase_missing_ask; ConfirmationDialog *multi_open_ask; ConfirmationDialog *multi_run_ask; diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 2a3202c0b8..f795bef59f 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -1727,44 +1727,48 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { if (S->get().size() == 0) { library_script_users.erase(S); - Map<String, Map<StringName, NativeScriptDesc>>::Element *L = library_classes.find(script->lib_path); - if (L) { - Map<StringName, NativeScriptDesc> classes = L->get(); - - for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) { - // free property stuff first - for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { - if (P.get().getter.free_func) { - P.get().getter.free_func(P.get().getter.method_data); + Map<String, Ref<GDNative>>::Element *G = library_gdnatives.find(script->lib_path); + if (G && G->get()->get_library()->is_reloadable()) { + // ONLY if the library is marked as reloadable, and no more instances of its scripts exist do we unload the library + + // First remove meta data related to the library + Map<String, Map<StringName, NativeScriptDesc>>::Element *L = library_classes.find(script->lib_path); + if (L) { + Map<StringName, NativeScriptDesc> classes = L->get(); + + for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) { + // free property stuff first + for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { + if (P.get().getter.free_func) { + P.get().getter.free_func(P.get().getter.method_data); + } + + if (P.get().setter.free_func) { + P.get().setter.free_func(P.get().setter.method_data); + } } - if (P.get().setter.free_func) { - P.get().setter.free_func(P.get().setter.method_data); + // free method stuff + for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) { + if (M->get().method.free_func) { + M->get().method.free_func(M->get().method.method_data); + } } - } - // free method stuff - for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) { - if (M->get().method.free_func) { - M->get().method.free_func(M->get().method.method_data); + // free constructor/destructor + if (C->get().create_func.free_func) { + C->get().create_func.free_func(C->get().create_func.method_data); } - } - // free constructor/destructor - if (C->get().create_func.free_func) { - C->get().create_func.free_func(C->get().create_func.method_data); + if (C->get().destroy_func.free_func) { + C->get().destroy_func.free_func(C->get().destroy_func.method_data); + } } - if (C->get().destroy_func.free_func) { - C->get().destroy_func.free_func(C->get().destroy_func.method_data); - } + library_classes.erase(script->lib_path); } - library_classes.erase(script->lib_path); - } - - Map<String, Ref<GDNative>>::Element *G = library_gdnatives.find(script->lib_path); - if (G && G->get()->get_library()->is_reloadable()) { + // now unload the library G->get()->terminate(); library_gdnatives.erase(G); } diff --git a/platform/javascript/godot_js.h b/platform/javascript/godot_js.h index 4448a35670..8927a83cb3 100644 --- a/platform/javascript/godot_js.h +++ b/platform/javascript/godot_js.h @@ -71,6 +71,7 @@ extern int godot_js_display_fullscreen_exit(); extern void godot_js_display_compute_position(int p_x, int p_y, int32_t *r_x, int32_t *r_y); extern void godot_js_display_window_title_set(const char *p_text); extern void godot_js_display_window_icon_set(const uint8_t *p_ptr, int p_len); +extern int godot_js_display_has_webgl(int p_version); // Display clipboard extern int godot_js_display_clipboard_set(const char *p_text); diff --git a/platform/javascript/js/libs/library_godot_display.js b/platform/javascript/js/libs/library_godot_display.js index 00e6a01679..91cab5eacc 100644 --- a/platform/javascript/js/libs/library_godot_display.js +++ b/platform/javascript/js/libs/library_godot_display.js @@ -719,6 +719,17 @@ const GodotDisplay = { GodotRuntime.setHeapValue(r_y, (y - rect.y) * rh, 'i32'); }, + godot_js_display_has_webgl__sig: 'ii', + godot_js_display_has_webgl: function (p_version) { + if (p_version !== 1 && p_version !== 2) { + return false; + } + try { + return !!document.createElement('canvas').getContext(p_version === 2 ? 'webgl2' : 'webgl'); + } catch (e) { /* Not available */ } + return false; + }, + /* * Canvas */ diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 65046d5d10..06c9cf1b63 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -1323,9 +1323,9 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { } if (b->get_button_index() == MOUSE_BUTTON_WHEEL_UP && Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { - set_zoom(zoom * ZOOM_SCALE); + set_zoom_custom(zoom * ZOOM_SCALE, b->get_position()); } else if (b->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN && Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { - set_zoom(zoom / ZOOM_SCALE); + set_zoom_custom(zoom / ZOOM_SCALE, b->get_position()); } else if (b->get_button_index() == MOUSE_BUTTON_WHEEL_UP && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * b->get_factor() / 8); } else if (b->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { |