diff options
48 files changed, 397 insertions, 278 deletions
diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 18071d7748..9e745ecb98 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -67,8 +67,8 @@ static _GlobalConstant _global_constants[] = { BIND_GLOBAL_CONSTANT(KEY_TAB), BIND_GLOBAL_CONSTANT(KEY_BACKTAB), BIND_GLOBAL_CONSTANT(KEY_BACKSPACE), - BIND_GLOBAL_CONSTANT(KEY_RETURN), BIND_GLOBAL_CONSTANT(KEY_ENTER), + BIND_GLOBAL_CONSTANT(KEY_KP_ENTER), BIND_GLOBAL_CONSTANT(KEY_INSERT), BIND_GLOBAL_CONSTANT(KEY_DELETE), BIND_GLOBAL_CONSTANT(KEY_PAUSE), diff --git a/core/input_map.cpp b/core/input_map.cpp index 24d0624e98..85e627f352 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -219,11 +219,11 @@ void InputMap::load_default() { add_action("ui_accept"); key.instance(); - key->set_scancode(KEY_RETURN); + key->set_scancode(KEY_ENTER); action_add_event("ui_accept", key); key.instance(); - key->set_scancode(KEY_ENTER); + key->set_scancode(KEY_KP_ENTER); action_add_event("ui_accept", key); key.instance(); diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index e154b1934d..9b3e376ea6 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -42,8 +42,8 @@ static const _KeyCodeText _keycodes[] = { {KEY_TAB ,"Tab"}, {KEY_BACKTAB ,"BackTab"}, {KEY_BACKSPACE ,"BackSpace"}, - {KEY_RETURN ,"Return"}, {KEY_ENTER ,"Enter"}, + {KEY_KP_ENTER ,"Kp Enter"}, {KEY_INSERT ,"Insert"}, {KEY_DELETE ,"Delete"}, {KEY_PAUSE ,"Pause"}, @@ -294,8 +294,8 @@ bool keycode_has_unicode(uint32_t p_keycode) { case KEY_TAB: case KEY_BACKTAB: case KEY_BACKSPACE: - case KEY_RETURN: case KEY_ENTER: + case KEY_KP_ENTER: case KEY_INSERT: case KEY_DELETE: case KEY_PAUSE: diff --git a/core/os/keyboard.h b/core/os/keyboard.h index c6985c887d..1ed93e3540 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -57,8 +57,8 @@ enum KeyList { KEY_TAB = SPKEY | 0x02, KEY_BACKTAB = SPKEY | 0x03, KEY_BACKSPACE = SPKEY | 0x04, - KEY_RETURN = SPKEY | 0x05, - KEY_ENTER = SPKEY | 0x06, + KEY_ENTER = SPKEY | 0x05, + KEY_KP_ENTER = SPKEY | 0x06, KEY_INSERT = SPKEY | 0x07, KEY_DELETE = SPKEY | 0x08, KEY_PAUSE = SPKEY | 0x09, diff --git a/core/project_settings.cpp b/core/project_settings.cpp index b31f78ec20..f6e0d2e991 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -925,10 +925,10 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("application/config/use_shared_user_dir", true); key.instance(); - key->set_scancode(KEY_RETURN); + key->set_scancode(KEY_ENTER); va.push_back(key); key.instance(); - key->set_scancode(KEY_ENTER); + key->set_scancode(KEY_KP_ENTER); va.push_back(key); key.instance(); key->set_scancode(KEY_SPACE); diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 268bfeca1a..cd5b950f57 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -846,10 +846,10 @@ <constant name="KEY_BACKSPACE" value="16777220"> Backspace Key </constant> - <constant name="KEY_RETURN" value="16777221"> + <constant name="KEY_ENTER" value="16777221"> Return Key (On Main Keyboard) </constant> - <constant name="KEY_ENTER" value="16777222"> + <constant name="KEY_KP_ENTER" value="16777222"> Enter Key (On Numpad) </constant> <constant name="KEY_INSERT" value="16777223"> diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 89bea1e8cc..f7ecc3b158 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -6902,17 +6902,19 @@ void RasterizerStorageGLES3::initialize() { config.use_fast_texture_filter = int(ProjectSettings::get_singleton()->get("rendering/quality/filters/use_nearest_mipmap_filter")); config.use_anisotropic_filter = config.extensions.has("rendering/quality/filters/anisotropic_filter_level"); - config.s3tc_supported = config.extensions.has("GL_EXT_texture_compression_dxt1") || config.extensions.has("GL_EXT_texture_compression_s3tc") || config.extensions.has("WEBGL_compressed_texture_s3tc"); config.etc_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture"); config.latc_supported = config.extensions.has("GL_EXT_texture_compression_latc"); - config.rgtc_supported = config.extensions.has("GL_EXT_texture_compression_rgtc"); config.bptc_supported = config.extensions.has("GL_ARB_texture_compression_bptc"); #ifdef GLES_OVER_GL config.hdr_supported = true; config.etc2_supported = false; + config.s3tc_supported = true; + config.rgtc_supported = true; //RGTC - core since OpenGL version 3.0 #else config.etc2_supported = true; config.hdr_supported = false; + config.s3tc_supported = config.extensions.has("GL_EXT_texture_compression_dxt1") || config.extensions.has("GL_EXT_texture_compression_s3tc") || config.extensions.has("WEBGL_compressed_texture_s3tc"); + config.rgtc_supported = config.extensions.has("GL_EXT_texture_compression_rgtc") || config.extensions.has("GL_ARB_texture_compression_rgtc"); #endif config.pvrtc_supported = config.extensions.has("GL_IMG_texture_compression_pvrtc"); diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 340a1f24d2..efb82441f4 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1929,7 +1929,7 @@ FRAGMENT_SHADER_CODE if (fog_depth_enabled) { - float fog_z = smoothstep(fog_depth_begin,z_far,-vertex.z); + float fog_z = smoothstep(fog_depth_begin,z_far,length(vertex)); fog_amount = pow(fog_z,fog_depth_curve); if (fog_transmit_enabled) { diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp index da998db66f..3de25c32ad 100644 --- a/drivers/rtaudio/audio_driver_rtaudio.cpp +++ b/drivers/rtaudio/audio_driver_rtaudio.cpp @@ -79,7 +79,7 @@ int AudioDriverRtAudio::callback(void *outputBuffer, void *inputBuffer, unsigned Error AudioDriverRtAudio::init() { active = false; - mutex = NULL; + mutex = Mutex::create(true); dac = memnew(RtAudio); ERR_EXPLAIN("Cannot initialize RtAudio audio driver: No devices present.") @@ -136,7 +136,6 @@ Error AudioDriverRtAudio::init() { try { dac->openStream(¶meters, NULL, RTAUDIO_SINT32, mix_rate, &buffer_size, &callback, this, &options); - mutex = Mutex::create(true); active = true; break; @@ -162,6 +161,7 @@ Error AudioDriverRtAudio::init() { try { dac->closeStream(); + active = false; } catch (RtAudioError &e) { ERR_PRINT(e.what()); ERR_FAIL_V(ERR_UNAVAILABLE); @@ -212,17 +212,27 @@ void AudioDriverRtAudio::unlock() { void AudioDriverRtAudio::finish() { - if (active && dac->isStreamOpen()) + lock(); + if (active && dac->isStreamOpen()) { dac->closeStream(); - if (mutex) + active = false; + } + unlock(); + + if (mutex) { memdelete(mutex); - if (dac) + mutex = NULL; + } + if (dac) { memdelete(dac); + dac = NULL; + } } AudioDriverRtAudio::AudioDriverRtAudio() { mutex = NULL; + dac = NULL; mix_rate = 44100; speaker_mode = SPEAKER_MODE_STEREO; } diff --git a/editor/asset_library_editor_plugin.cpp b/editor/asset_library_editor_plugin.cpp index f92b70d0c0..559a0db57b 100644 --- a/editor/asset_library_editor_plugin.cpp +++ b/editor/asset_library_editor_plugin.cpp @@ -281,7 +281,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { description = memnew(RichTextLabel); description->connect("meta_clicked", this, "_link_click"); desc_bg->add_child(description); - desc_bg->add_style_override("panel", get_stylebox("normal", "TextEdit")); + desc_bg->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("normal", "TextEdit")); preview = memnew(TextureRect); preview->set_custom_minimum_size(Size2(640, 345)); @@ -290,7 +290,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { PanelContainer *previews_bg = memnew(PanelContainer); vbox->add_child(previews_bg); previews_bg->set_custom_minimum_size(Size2(0, 85)); - previews_bg->add_style_override("panel", get_stylebox("normal", "TextEdit")); + previews_bg->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("normal", "TextEdit")); previews = memnew(ScrollContainer); previews_bg->add_child(previews); @@ -1362,7 +1362,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { PanelContainer *library_scroll_bg = memnew(PanelContainer); library_main->add_child(library_scroll_bg); - library_scroll_bg->add_style_override("panel", get_stylebox("normal", "TextEdit")); + library_scroll_bg->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("bg", "Tree")); library_scroll_bg->set_v_size_flags(SIZE_EXPAND_FILL); library_scroll = memnew(ScrollContainer); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index e890082ee1..8b1f558c0a 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1621,12 +1621,18 @@ void EditorHelp::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { - //forward->set_icon(get_icon("Forward","EditorIcons")); //back->set_icon(get_icon("Back","EditorIcons")); _update_doc(); + } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + Ref<StyleBoxFlat> style(memnew(StyleBoxFlat)); + style->set_bg_color(EditorSettings::get_singleton()->get("text_editor/highlighting/background_color")); + background_panel->add_style_override("panel", style); } break; + + default: break; } } @@ -1695,14 +1701,14 @@ EditorHelp::EditorHelp() { //class_list->set_selection_enabled(true); { - Panel *pc = memnew(Panel); + background_panel = memnew(Panel); Ref<StyleBoxFlat> style(memnew(StyleBoxFlat)); style->set_bg_color(EditorSettings::get_singleton()->get("text_editor/highlighting/background_color")); - pc->set_v_size_flags(SIZE_EXPAND_FILL); - pc->add_style_override("panel", style); //get_stylebox("normal","TextEdit")); - vbc->add_child(pc); + background_panel->set_v_size_flags(SIZE_EXPAND_FILL); + background_panel->add_style_override("panel", style); //get_stylebox("normal","TextEdit")); + vbc->add_child(background_panel); class_desc = memnew(RichTextLabel); - pc->add_child(class_desc); + background_panel->add_child(class_desc); class_desc->set_area_as_parent_rect(8); class_desc->connect("meta_clicked", this, "_class_desc_select"); class_desc->connect("gui_input", this, "_class_desc_input"); @@ -1782,7 +1788,7 @@ void EditorHelpBit::_bind_methods() { void EditorHelpBit::_notification(int p_what) { if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles")); + add_style_override("panel", get_stylebox("ScriptPanel", "EditorStyles")); } } diff --git a/editor/editor_help.h b/editor/editor_help.h index 46d83490f4..de30b543fc 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -129,6 +129,7 @@ class EditorHelp : public VBoxContainer { HSplitContainer *h_split; static DocData *doc; + Panel *background_panel; ConfirmationDialog *search_dialog; LineEdit *search; diff --git a/editor/editor_name_dialog.cpp b/editor/editor_name_dialog.cpp index 7435e9a9f7..6ebfcbf313 100644 --- a/editor/editor_name_dialog.cpp +++ b/editor/editor_name_dialog.cpp @@ -42,8 +42,8 @@ void EditorNameDialog::_line_gui_input(const Ref<InputEvent> &p_event) { return; switch (k->get_scancode()) { - case KEY_ENTER: - case KEY_RETURN: { + case KEY_KP_ENTER: + case KEY_ENTER: { if (get_hide_on_ok()) hide(); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 755ac75180..07af60d634 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -216,17 +216,43 @@ Variant _EDITOR_DEF(const String &p_var, const Variant &p_default) { return p_default; } +static Dictionary _get_builtin_script_templates() { + Dictionary templates; + + //No Comments + templates["no_comments.gd"] = + "extends %BASE%\n" + "\n" + "func _ready():\n" + "%TS%pass\n"; + + //Empty + templates["empty.gd"] = + "extends %BASE%" + "\n" + "\n"; + + return templates; +} + static void _create_script_templates(const String &p_path) { - FileAccess *file = FileAccess::open(p_path.plus_file("no_comments.gd"), FileAccess::WRITE); - ERR_FAIL_COND(!file); - String script = String("extends %BASE%\n\nfunc _ready():\n%TS%pass\n"); - file->store_string(script); - file->close(); - file->reopen(p_path.plus_file("empty.gd"), FileAccess::WRITE); - script = "extends %BASE%\n\n"; - file->store_string(script); - file->close(); + Dictionary templates = _get_builtin_script_templates(); + List<Variant> keys; + templates.get_key_list(&keys); + FileAccess *file = FileAccess::create(FileAccess::ACCESS_FILESYSTEM); + + DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + dir->change_dir(p_path); + for (int i = 0; i < keys.size(); i++) { + if (!dir->file_exists(keys[i])) { + file->reopen(p_path.plus_file((String)keys[i]), FileAccess::WRITE); + ERR_FAIL_COND(!file); + file->store_string(templates[keys[i]]); + file->close(); + } + } + memdelete(file); } @@ -308,10 +334,10 @@ void EditorSettings::create() { if (dir->change_dir("script_templates") != OK) { dir->make_dir("script_templates"); - _create_script_templates(dir->get_current_dir() + "/script_templates"); } else { dir->change_dir(".."); } + _create_script_templates(dir->get_current_dir() + "/script_templates"); if (dir->change_dir("tmp") != OK) { dir->make_dir("tmp"); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index df16de947e..807aed4267 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -143,7 +143,7 @@ Ref<Theme> create_editor_theme() { Color light_color_1 = base_color.linear_interpolate(Color(1, 1, 1, 1), contrast); Color light_color_2 = base_color.linear_interpolate(Color(1, 1, 1, 1), contrast * 1.5); - const int border_width = (border_size % 3) * EDSCALE; + const int border_width = CLAMP(border_size, 0, 3) * EDSCALE; Color title_color_hl = base_color; if (highlight_tabs) @@ -238,7 +238,7 @@ Ref<Theme> create_editor_theme() { theme->set_stylebox("panel", "TabContainer", style_content_panel); theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp); - Ref<StyleBoxFlat> style_button_type = make_flat_stylebox(dark_color_1, 4, 4, 6, 4); + Ref<StyleBoxFlat> style_button_type = make_flat_stylebox(dark_color_1, 6, 4, 6, 4); style_button_type->set_draw_center(true); style_button_type->set_border_size(border_width); style_button_type->set_light_color(light_color_1); @@ -287,12 +287,12 @@ Ref<Theme> create_editor_theme() { // PopupMenu Ref<StyleBoxFlat> style_popup_menu = make_flat_stylebox(dark_color_1, 8, 8, 8, 8); - style_popup_menu->set_border_size(border_width); + style_popup_menu->set_border_size(MAX(EDSCALE, border_width)); style_popup_menu->set_light_color(light_color_1); style_popup_menu->set_dark_color(light_color_1); style_popup_menu->set_border_blend(false); theme->set_stylebox("panel", "PopupMenu", style_popup_menu); - theme->set_stylebox("separator", "PopupMenu", make_line_stylebox(separator_color, border_width, 8 - border_width)); + theme->set_stylebox("separator", "PopupMenu", make_line_stylebox(separator_color, MAX(EDSCALE, border_width), 8 - MAX(EDSCALE, border_width))); // Tree & ItemList background Ref<StyleBoxFlat> style_tree_bg = make_flat_stylebox(dark_color_1, 2, 4, 2, 4); @@ -431,7 +431,7 @@ Ref<Theme> create_editor_theme() { // WindowDialog Ref<StyleBoxFlat> style_window = make_flat_stylebox(dark_color_2, 4, 4, 4, 4); - style_window->set_border_size(border_width); + style_window->set_border_size(MAX(EDSCALE, border_width)); style_window->set_border_blend(false); style_window->set_light_color(title_color_hl); style_window->set_dark_color(title_color_hl); @@ -478,6 +478,9 @@ Ref<Theme> create_editor_theme() { theme->set_icon("grabber", "VSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons")); theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons")); + //RichTextLabel + theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox()); + // Panel theme->set_stylebox("panel", "Panel", style_panel); diff --git a/editor/io_plugins/editor_scene_import_plugin.cpp b/editor/io_plugins/editor_scene_import_plugin.cpp index aa96f731ce..1890ca906a 100644 --- a/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/editor/io_plugins/editor_scene_import_plugin.cpp @@ -1307,7 +1307,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce //confirm_import->set_child_rect(cvb); PanelContainer *pc = memnew( PanelContainer ); - pc->add_style_override("panel",get_stylebox("normal","TextEdit")); + pc->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("normal","TextEdit")); //ec->add_child(pc); missing_files = memnew( RichTextLabel ); cvb->add_margin_child(TTR("The Following Files are Missing:"),pc,true); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index c4e79bf263..ecae272b6d 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1246,7 +1246,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) { set_focus_mode(FOCUS_ALL); player = NULL; - add_style_override("panel", get_stylebox("panel", "Panel")); + add_style_override("panel", editor->get_gui_base()->get_stylebox("panel", "Panel")); Label *l; diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 2703da12fe..ccefbc1843 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -362,7 +362,7 @@ void ResourcePreloaderEditor::_bind_methods() { ResourcePreloaderEditor::ResourcePreloaderEditor() { - //add_style_override("panel", get_stylebox("panel","Panel")); + //add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel")); VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); diff --git a/editor/plugins/sample_editor_plugin.cpp b/editor/plugins/sample_editor_plugin.cpp index 739a8abb53..aee208caf0 100644 --- a/editor/plugins/sample_editor_plugin.cpp +++ b/editor/plugins/sample_editor_plugin.cpp @@ -360,7 +360,7 @@ SampleEditor::SampleEditor() { player = memnew(SamplePlayer); add_child(player); - add_style_override("panel", get_stylebox("panel","Panel")); + add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel")); library = Ref<SampleLibrary>(memnew(SampleLibrary)); player->set_sample_library(library); sample_texframe = memnew( TextureRect ); diff --git a/editor/plugins/sample_library_editor_plugin.cpp b/editor/plugins/sample_library_editor_plugin.cpp index 5ccfde15ff..00168685b6 100644 --- a/editor/plugins/sample_library_editor_plugin.cpp +++ b/editor/plugins/sample_library_editor_plugin.cpp @@ -432,7 +432,7 @@ SampleLibraryEditor::SampleLibraryEditor() { player = memnew(SamplePlayer); add_child(player); - add_style_override("panel", get_stylebox("panel","Panel")); + add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel")); load = memnew( Button ); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 77c540b746..1873a3f58b 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -211,9 +211,11 @@ void ScriptEditorQuickOpen::_confirmed() { void ScriptEditorQuickOpen::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { - connect("confirmed", this, "_confirmed"); + connect("confirmed", this, "_confirmed"); + } break; } } @@ -1064,58 +1066,73 @@ void ScriptEditor::_tab_changed(int p_which) { void ScriptEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - - editor->connect("play_pressed", this, "_editor_play"); - editor->connect("pause_pressed", this, "_editor_pause"); - editor->connect("stop_pressed", this, "_editor_stop"); - editor->connect("script_add_function_request", this, "_add_callback"); - editor->connect("resource_saved", this, "_res_saved_callback"); - script_list->connect("item_selected", this, "_script_selected"); - members_overview->connect("item_selected", this, "_members_overview_selected"); - script_split->connect("dragged", this, "_script_split_dragged"); - autosave_timer->connect("timeout", this, "_autosave_scripts"); - { - float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs"); - if (autosave_time > 0) { - autosave_timer->set_wait_time(autosave_time); - autosave_timer->start(); - } else { - autosave_timer->stop(); + switch (p_what) { + + case NOTIFICATION_ENTER_TREE: { + + editor->connect("play_pressed", this, "_editor_play"); + editor->connect("pause_pressed", this, "_editor_pause"); + editor->connect("stop_pressed", this, "_editor_stop"); + editor->connect("script_add_function_request", this, "_add_callback"); + editor->connect("resource_saved", this, "_res_saved_callback"); + script_list->connect("item_selected", this, "_script_selected"); + members_overview->connect("item_selected", this, "_members_overview_selected"); + script_split->connect("dragged", this, "_script_split_dragged"); + autosave_timer->connect("timeout", this, "_autosave_scripts"); + { + float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs"); + if (autosave_time > 0) { + autosave_timer->set_wait_time(autosave_time); + autosave_timer->start(); + } else { + autosave_timer->stop(); + } } - } - EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed"); - help_search->set_icon(get_icon("HelpSearch", "EditorIcons")); - site_search->set_icon(get_icon("Instance", "EditorIcons")); - class_search->set_icon(get_icon("ClassList", "EditorIcons")); + EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed"); + help_search->set_icon(get_icon("HelpSearch", "EditorIcons")); + site_search->set_icon(get_icon("Instance", "EditorIcons")); + class_search->set_icon(get_icon("ClassList", "EditorIcons")); - script_forward->set_icon(get_icon("Forward", "EditorIcons")); - script_back->set_icon(get_icon("Back", "EditorIcons")); - } + script_forward->set_icon(get_icon("Forward", "EditorIcons")); + script_back->set_icon(get_icon("Back", "EditorIcons")); + } break; - if (p_what == NOTIFICATION_READY) { + case NOTIFICATION_READY: { - get_tree()->connect("tree_changed", this, "_tree_changed"); - editor->connect("request_help", this, "_request_help"); - editor->connect("request_help_search", this, "_help_search"); - editor->connect("request_help_index", this, "_help_index"); - } + get_tree()->connect("tree_changed", this, "_tree_changed"); + editor->connect("request_help", this, "_request_help"); + editor->connect("request_help_search", this, "_help_search"); + editor->connect("request_help_index", this, "_help_index"); + } break; - if (p_what == NOTIFICATION_EXIT_TREE) { + case NOTIFICATION_EXIT_TREE: { - editor->disconnect("play_pressed", this, "_editor_play"); - editor->disconnect("pause_pressed", this, "_editor_pause"); - editor->disconnect("stop_pressed", this, "_editor_stop"); - } + editor->disconnect("play_pressed", this, "_editor_play"); + editor->disconnect("pause_pressed", this, "_editor_pause"); + editor->disconnect("stop_pressed", this, "_editor_stop"); + } break; - if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { + case MainLoop::NOTIFICATION_WM_FOCUS_IN: { - _test_script_times_on_disk(); - _update_modified_scripts_for_external_editor(); - } + _test_script_times_on_disk(); + _update_modified_scripts_for_external_editor(); + } break; + + case NOTIFICATION_PROCESS: { + } break; - if (p_what == NOTIFICATION_PROCESS) { + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + + tab_container->add_style_override("panel", editor->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles")); + + Ref<StyleBox> sb = editor->get_gui_base()->get_stylebox("panel", "TabContainer")->duplicate(); + sb->set_default_margin(MARGIN_TOP, 0); + add_style_override("panel", sb); + } break; + + default: + break; } } diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 2d77bfb2c1..def4dd0b63 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -57,6 +57,12 @@ #define FREELOOK_MIN_SPEED 0.1 +#define MIN_Z 0.01 +#define MAX_Z 10000 + +#define MIN_FOV 0.01 +#define MAX_FOV 179 + void SpatialEditorViewport::_update_camera() { if (orthogonal) { //camera->set_orthogonal(size.width*cursor.distance,get_znear(),get_zfar()); @@ -153,26 +159,15 @@ int SpatialEditorViewport::get_selected_count() const { float SpatialEditorViewport::get_znear() const { - float val = spatial_editor->get_znear(); - if (val < 0.001) - val = 0.001; - return val; + return CLAMP(spatial_editor->get_znear(), MIN_Z, MAX_Z); } float SpatialEditorViewport::get_zfar() const { - float val = spatial_editor->get_zfar(); - if (val < 0.001) - val = 0.001; - return val; + return CLAMP(spatial_editor->get_zfar(), MIN_Z, MAX_Z); } float SpatialEditorViewport::get_fov() const { - float val = spatial_editor->get_fov(); - if (val < 0.001) - val = 0.001; - if (val > 89) - val = 89; - return val; + return CLAMP(spatial_editor->get_fov(), MIN_FOV, MAX_FOV); } Transform SpatialEditorViewport::_get_camera_transform() const { @@ -2390,7 +2385,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu = memnew(MenuButton); surface->add_child(view_menu); - view_menu->set_position(Point2(4, 4)); + view_menu->set_position(Point2(4, 4) * EDSCALE); view_menu->set_self_modulate(Color(1, 1, 1, 0.5)); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP); view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM); @@ -2434,8 +2429,8 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed preview_camera = memnew(Button); preview_camera->set_toggle_mode(true); - preview_camera->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, 90); - preview_camera->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10); + preview_camera->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, 90 * EDSCALE); + preview_camera->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE); preview_camera->set_text("preview"); surface->add_child(preview_camera); preview_camera->hide(); @@ -2455,7 +2450,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed selection_menu = memnew(PopupMenu); add_child(selection_menu); - selection_menu->set_custom_minimum_size(Vector2(100, 0)); + selection_menu->set_custom_minimum_size(Size2(100, 0) * EDSCALE); selection_menu->connect("id_pressed", this, "_selection_result_pressed"); selection_menu->connect("popup_hide", this, "_selection_menu_hide"); @@ -2464,7 +2459,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed viewport->set_as_audio_listener(true); } - name = TTR("Top"); + name = ""; _update_name(); EditorSettings::get_singleton()->connect("settings_changed", this, "update_transform_gizmo_view"); @@ -3933,27 +3928,27 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { settings_dialog->set_title(TTR("Viewport Settings")); add_child(settings_dialog); settings_vbc = memnew(VBoxContainer); - settings_vbc->set_custom_minimum_size(Size2(200, 0)); + settings_vbc->set_custom_minimum_size(Size2(200, 0) * EDSCALE); settings_dialog->add_child(settings_vbc); //settings_dialog->set_child_rect(settings_vbc); settings_fov = memnew(SpinBox); - settings_fov->set_max(179); - settings_fov->set_min(1); + settings_fov->set_max(MAX_FOV); + settings_fov->set_min(MIN_FOV); settings_fov->set_step(0.01); settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 55.0)); settings_vbc->add_margin_child(TTR("Perspective FOV (deg.):"), settings_fov); settings_znear = memnew(SpinBox); - settings_znear->set_max(10000); - settings_znear->set_min(0.1); + settings_znear->set_max(MAX_Z); + settings_znear->set_min(MIN_Z); settings_znear->set_step(0.01); settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.1)); settings_vbc->add_margin_child(TTR("View Z-Near:"), settings_znear); settings_zfar = memnew(SpinBox); - settings_zfar->set_max(10000); - settings_zfar->set_min(0.1); + settings_zfar->set_max(MAX_Z); + settings_zfar->set_min(MIN_Z); settings_zfar->set_step(0.01); settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500)); settings_vbc->add_margin_child(TTR("View Z-Far:"), settings_zfar); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 6a010062f2..0f008552d0 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -714,7 +714,7 @@ void SpriteFramesEditor::_bind_methods() { SpriteFramesEditor::SpriteFramesEditor() { - //add_style_override("panel", get_stylebox("panel","Panel")); + //add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel")); split = memnew(HSplitContainer); add_child(split); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 82f17b80d5..d5a56f644f 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -573,7 +573,7 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { switch (k->get_scancode()) { - case KEY_RETURN: { + case KEY_ENTER: { _open_project(); } break; diff --git a/platform/haiku/key_mapping_haiku.cpp b/platform/haiku/key_mapping_haiku.cpp index 9df7b2f047..3db31fa3e4 100644 --- a/platform/haiku/key_mapping_haiku.cpp +++ b/platform/haiku/key_mapping_haiku.cpp @@ -83,7 +83,7 @@ static _HaikuTranslatePair _fn_to_keycode[] = { static _HaikuTranslatePair _hb_to_keycode[] = { { KEY_BACKSPACE, B_BACKSPACE }, { KEY_TAB, B_TAB }, - { KEY_RETURN, B_RETURN }, + { KEY_ENTER, B_RETURN }, { KEY_CAPSLOCK, B_CAPS_LOCK }, { KEY_ESCAPE, B_ESCAPE }, { KEY_SPACE, B_SPACE }, diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index cb5c022764..ae1d09ecda 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -224,11 +224,9 @@ void OSIPhone::mouse_button(int p_idx, int p_x, int p_y, bool p_pressed, bool p_ Ref<InputEventMouseButton> ev; ev.instance(); - // swaped it for tilted screen - //ev->get_pos().x = ev.mouse_button.global_x = video_mode.height - p_y; - //ev->get_pos().y = ev.mouse_button.global_y = p_x; - ev->set_position(Vector2(video_mode.height - p_y, p_x)); - ev->set_global_position(Vector2(video_mode.height - p_y, p_x)); + + ev->set_position(Vector2(p_x, p_y)); + ev->set_global_position(Vector2(p_x, p_y)); //mouse_list.pressed[p_idx] = p_pressed; diff --git a/platform/javascript/dom_keys.h b/platform/javascript/dom_keys.h index 979731d157..4b8b764c45 100644 --- a/platform/javascript/dom_keys.h +++ b/platform/javascript/dom_keys.h @@ -249,7 +249,7 @@ int dom2godot_scancode(int dom_keycode) { case DOM_VK_RETURN: case DOM_VK_ENTER: // unused according to MDN - return KEY_RETURN; + return KEY_ENTER; case DOM_VK_SHIFT: return KEY_SHIFT; case DOM_VK_CONTROL: return KEY_CONTROL; diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 0708d46196..5513fca809 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -96,30 +96,18 @@ static EM_BOOL _browser_resize_callback(int event_type, const EmscriptenUiEvent ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_RESIZE, false); OS_JavaScript *os = static_cast<OS_JavaScript *>(user_data); - - // the order in which _browser_resize_callback and - // _fullscreen_change_callback are called is browser-dependent, - // so try adjusting for fullscreen in both - if (os->is_window_fullscreen() || os->is_window_maximized()) { - - OS::VideoMode vm = os->get_video_mode(); - vm.width = ui_event->windowInnerWidth; - vm.height = ui_event->windowInnerHeight; - os->set_video_mode(vm); - emscripten_set_canvas_size(ui_event->windowInnerWidth, ui_event->windowInnerHeight); - } + // The order of the fullscreen change event and the window size change + // event varies, even within just one browser, so defer handling + os->request_canvas_size_adjustment(); return false; } -static Size2 _windowed_size; - static EM_BOOL _fullscreen_change_callback(int event_type, const EmscriptenFullscreenChangeEvent *event, void *user_data) { ERR_FAIL_COND_V(event_type != EMSCRIPTEN_EVENT_FULLSCREENCHANGE, false); OS_JavaScript *os = static_cast<OS_JavaScript *>(user_data); String id = String::utf8(event->id); - // empty id is canvas if (id.empty() || id == "canvas") { @@ -127,18 +115,8 @@ static EM_BOOL _fullscreen_change_callback(int event_type, const EmscriptenFulls // this event property is the only reliable information on // browser fullscreen state vm.fullscreen = event->isFullscreen; - - if (event->isFullscreen) { - vm.width = event->screenWidth; - vm.height = event->screenHeight; - os->set_video_mode(vm); - emscripten_set_canvas_size(vm.width, vm.height); - } else { - os->set_video_mode(vm); - if (!os->is_window_maximized()) { - os->set_window_size(_windowed_size); - } - } + os->set_video_mode(vm); + os->request_canvas_size_adjustment(); } return false; } @@ -719,14 +697,17 @@ Size2 OS_JavaScript::get_screen_size(int p_screen) const { void OS_JavaScript::set_window_size(const Size2 p_size) { - window_maximized = false; + windowed_size = p_size; if (is_window_fullscreen()) { + window_maximized = false; set_window_fullscreen(false); + } else if (is_window_maximized()) { + set_window_maximized(false); + } else { + video_mode.width = p_size.x; + video_mode.height = p_size.y; + emscripten_set_canvas_size(p_size.x, p_size.y); } - _windowed_size = p_size; - video_mode.width = p_size.x; - video_mode.height = p_size.y; - emscripten_set_canvas_size(p_size.x, p_size.y); } Size2 OS_JavaScript::get_window_size() const { @@ -739,20 +720,30 @@ Size2 OS_JavaScript::get_window_size() const { void OS_JavaScript::set_window_maximized(bool p_enabled) { window_maximized = p_enabled; - if (p_enabled) { - - if (is_window_fullscreen()) { - // _browser_resize callback will set canvas size - set_window_fullscreen(false); - } else { - /* clang-format off */ - video_mode.width = EM_ASM_INT_V(return window.innerWidth); - video_mode.height = EM_ASM_INT_V(return window.innerHeight); - /* clang-format on */ - emscripten_set_canvas_size(video_mode.width, video_mode.height); - } - } else { - set_window_size(_windowed_size); + if (is_window_fullscreen()) { + set_window_fullscreen(false); + return; + } + // Calling emscripten_enter_soft_fullscreen mutltiple times hides all + // page elements except the canvas permanently, so track state + if (p_enabled && !soft_fs_enabled) { + + EmscriptenFullscreenStrategy strategy; + strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; + strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF; + strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; + strategy.canvasResizedCallback = NULL; + emscripten_enter_soft_fullscreen(NULL, &strategy); + soft_fs_enabled = true; + video_mode.width = get_window_size().width; + video_mode.height = get_window_size().height; + } else if (!p_enabled) { + + emscripten_exit_soft_fullscreen(); + soft_fs_enabled = false; + video_mode.width = windowed_size.width; + video_mode.height = windowed_size.height; + emscripten_set_canvas_size(video_mode.width, video_mode.height); } } @@ -766,9 +757,17 @@ void OS_JavaScript::set_window_fullscreen(bool p_enable) { // _browser_resize_callback or _fullscreen_change_callback EMSCRIPTEN_RESULT result; if (p_enable) { - /* clang-format off */ - EM_ASM(Module.requestFullscreen(false, false);); - /* clang-format on */ + if (window_maximized) { + // soft fs during real fs can cause issues + set_window_maximized(false); + window_maximized = true; + } + EmscriptenFullscreenStrategy strategy; + strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH; + strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF; + strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; + strategy.canvasResizedCallback = NULL; + emscripten_request_fullscreen_strategy(NULL, false, &strategy); } else { result = emscripten_exit_fullscreen(); if (result != EMSCRIPTEN_RESULT_SUCCESS) { @@ -782,6 +781,11 @@ bool OS_JavaScript::is_window_fullscreen() const { return video_mode.fullscreen; } +void OS_JavaScript::request_canvas_size_adjustment() { + + canvas_size_adjustment_requested = true; +} + void OS_JavaScript::get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen) const { Size2 screen = get_screen_size(); @@ -841,6 +845,17 @@ bool OS_JavaScript::main_loop_iterate() { } } process_joypads(); + if (canvas_size_adjustment_requested) { + + if (video_mode.fullscreen || window_maximized) { + video_mode.width = get_window_size().width; + video_mode.height = get_window_size().height; + } + if (!video_mode.fullscreen) { + set_window_maximized(window_maximized); + } + canvas_size_adjustment_requested = false; + } return Main::iteration(); } @@ -857,7 +872,11 @@ void OS_JavaScript::process_accelerometer(const Vector3 &p_accelerometer) { bool OS_JavaScript::has_touchscreen_ui_hint() const { - return false; //??? + /* clang-format off */ + return EM_ASM_INT_V( + return 'ontouchstart' in window; + ); + /* clang-format on */ } void OS_JavaScript::main_loop_request_quit() { @@ -980,6 +999,8 @@ OS_JavaScript::OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_d main_loop = NULL; gl_extensions = NULL; window_maximized = false; + soft_fs_enabled = false; + canvas_size_adjustment_requested = false; get_data_dir_func = p_get_data_dir_func; FileAccessUnix::close_notification_func = _close_notification_funcs; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 24e96e20dd..13c500b3dc 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -59,7 +59,10 @@ class OS_JavaScript : public OS_Unix { const char *gl_extensions; InputDefault *input; + Vector2 windowed_size; bool window_maximized; + bool soft_fs_enabled; + bool canvas_size_adjustment_requested; VideoMode video_mode; CursorShape cursor_shape; MainLoop *main_loop; @@ -130,6 +133,8 @@ public: virtual void set_window_fullscreen(bool p_enable); virtual bool is_window_fullscreen() const; + void request_canvas_size_adjustment(); + virtual String get_name(); virtual MainLoop *get_main_loop() const; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index cc46f5d967..a34f6cc5dd 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -521,7 +521,7 @@ static int translateKey(unsigned int key) { /* 21 */ KEY_BRACELEFT, /* 22 */ KEY_I, /* 23 */ KEY_P, - /* 24 */ KEY_RETURN, + /* 24 */ KEY_ENTER, /* 25 */ KEY_L, /* 26 */ KEY_J, /* 27 */ KEY_APOSTROPHE, @@ -561,7 +561,7 @@ static int translateKey(unsigned int key) { /* 49 */ KEY_UNKNOWN, /* VolumeDown */ /* 4a */ KEY_UNKNOWN, /* Mute */ /* 4b */ KEY_KP_DIVIDE, - /* 4c */ KEY_ENTER, + /* 4c */ KEY_KP_ENTER, /* 4d */ KEY_UNKNOWN, /* 4e */ KEY_KP_SUBTRACT, /* 4f */ KEY_UNKNOWN, @@ -1123,18 +1123,13 @@ void OS_OSX::warp_mouse_pos(const Point2 &p_to) { mouse_y = p_to.y; } else { //set OS position - /* this code has not been tested, please be a kind soul and fix it if it fails! */ - //local point in window coords - NSPoint localPoint = { p_to.x, p_to.y }; - - NSPoint pointInWindow = [window_view convertPoint:localPoint toView:nil]; - NSRect pointInWindowRect; - pointInWindowRect.origin = pointInWindow; + const NSRect contentRect = [window_view frame]; + NSRect pointInWindowRect = NSMakeRect(p_to.x / display_scale, contentRect.size.height - (p_to.y / display_scale) - 1, 0, 0); NSPoint pointOnScreen = [[window_view window] convertRectToScreen:pointInWindowRect].origin; //point in scren coords - CGPoint lMouseWarpPos = { pointOnScreen.x, pointOnScreen.y }; + CGPoint lMouseWarpPos = { pointOnScreen.x, CGDisplayBounds(CGMainDisplayID()).size.height - pointOnScreen.y }; //do the warping CGEventSourceRef lEventRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState); diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp index 34e36f7b66..f3d4eb99c8 100644 --- a/platform/uwp/joypad_uwp.cpp +++ b/platform/uwp/joypad_uwp.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "joypad_uwp.h" +#include "core/os/os.h" using namespace Windows::Gaming::Input; using namespace Windows::Foundation; @@ -45,27 +46,44 @@ void JoypadUWP::process_controllers() { for (int i = 0; i < MAX_CONTROLLERS; i++) { - if (!controllers[i].connected) break; + ControllerDevice &joy = controllers[i]; - switch (controllers[i].type) { + if (!joy.connected) break; + + switch (joy.type) { case ControllerType::GAMEPAD_CONTROLLER: { - GamepadReading reading = ((Gamepad ^)controllers[i].controller_reference)->GetCurrentReading(); + GamepadReading reading = ((Gamepad ^) joy.controller_reference)->GetCurrentReading(); int button_mask = (int)GamepadButtons::Menu; for (int j = 0; j < 14; j++) { - input->joy_button(controllers[i].id, j, (int)reading.Buttons & button_mask); + input->joy_button(joy.id, j, (int)reading.Buttons & button_mask); button_mask *= 2; } - input->joy_axis(controllers[i].id, JOY_AXIS_0, axis_correct(reading.LeftThumbstickX)); - input->joy_axis(controllers[i].id, JOY_AXIS_1, axis_correct(reading.LeftThumbstickY, true)); - input->joy_axis(controllers[i].id, JOY_AXIS_2, axis_correct(reading.RightThumbstickX)); - input->joy_axis(controllers[i].id, JOY_AXIS_3, axis_correct(reading.RightThumbstickY, true)); - input->joy_axis(controllers[i].id, JOY_AXIS_4, axis_correct(reading.LeftTrigger, false, true)); - input->joy_axis(controllers[i].id, JOY_AXIS_5, axis_correct(reading.RightTrigger, false, true)); + input->joy_axis(joy.id, JOY_AXIS_0, axis_correct(reading.LeftThumbstickX)); + input->joy_axis(joy.id, JOY_AXIS_1, axis_correct(reading.LeftThumbstickY, true)); + input->joy_axis(joy.id, JOY_AXIS_2, axis_correct(reading.RightThumbstickX)); + input->joy_axis(joy.id, JOY_AXIS_3, axis_correct(reading.RightThumbstickY, true)); + input->joy_axis(joy.id, JOY_AXIS_4, axis_correct(reading.LeftTrigger, false, true)); + input->joy_axis(joy.id, JOY_AXIS_5, axis_correct(reading.RightTrigger, false, true)); + + uint64_t timestamp = input->get_joy_vibration_timestamp(joy.id); + if (timestamp > joy.ff_timestamp) { + Vector2 strength = input->get_joy_vibration_strength(joy.id); + float duration = input->get_joy_vibration_duration(joy.id); + if (strength.x == 0 && strength.y == 0) { + joypad_vibration_stop(i, timestamp); + } else { + joypad_vibration_start(i, strength.x, strength.y, duration, timestamp); + } + } else if (joy.vibrating && joy.ff_end_timestamp != 0) { + uint64_t current_time = OS::get_singleton()->get_ticks_usec(); + if (current_time >= joy.ff_end_timestamp) + joypad_vibration_stop(i, current_time); + } break; } @@ -122,15 +140,7 @@ void JoypadUWP::OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Inp ERR_FAIL_COND(idx == -1); - for (int i = idx + 1; i < MAX_CONTROLLERS - 1; i++) { - - if (!controllers[i].connected) { - break; - } - - controllers[i - 1] = controllers[i]; - } - controllers[MAX_CONTROLLERS - 1] = ControllerDevice(); + controllers[idx] = ControllerDevice(); input->joy_connection_changed(idx, false, "Xbox Controller"); } @@ -144,3 +154,30 @@ InputDefault::JoyAxis JoypadUWP::axis_correct(double p_val, bool p_negate, bool return jx; } + +void JoypadUWP::joypad_vibration_start(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp) { + ControllerDevice &joy = controllers[p_device]; + if (joy.connected) { + GamepadVibration vibration; + vibration.LeftMotor = p_strong_magnitude; + vibration.RightMotor = p_weak_magnitude; + ((Gamepad ^) joy.controller_reference)->Vibration = vibration; + + joy.ff_timestamp = p_timestamp; + joy.ff_end_timestamp = p_duration == 0 ? 0 : p_timestamp + (uint64_t)(p_duration * 1000000.0); + joy.vibrating = true; + } +} + +void JoypadUWP::joypad_vibration_stop(int p_device, uint64_t p_timestamp) { + ControllerDevice &joy = controllers[p_device]; + if (joy.connected) { + GamepadVibration vibration; + vibration.LeftMotor = 0.0; + vibration.RightMotor = 0.0; + ((Gamepad ^) joy.controller_reference)->Vibration = vibration; + + joy.ff_timestamp = p_timestamp; + joy.vibrating = false; + } +} diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h index 7337ffb3ce..c55e1e7ab7 100644 --- a/platform/uwp/joypad_uwp.h +++ b/platform/uwp/joypad_uwp.h @@ -62,11 +62,17 @@ private: int id; bool connected; ControllerType type; + float ff_timestamp; + float ff_end_timestamp; + bool vibrating; ControllerDevice() { id = -1; connected = false; type = ControllerType::GAMEPAD_CONTROLLER; + ff_timestamp = 0.0f; + ff_end_timestamp = 0.0f; + vibrating = false; } }; @@ -78,6 +84,8 @@ private: void OnGamepadRemoved(Platform::Object ^ sender, Windows::Gaming::Input::Gamepad ^ value); InputDefault::JoyAxis axis_correct(double p_val, bool p_negate = false, bool p_trigger = false) const; + void joypad_vibration_start(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration, uint64_t p_timestamp); + void joypad_vibration_stop(int p_device, uint64_t p_timestamp); }; #endif diff --git a/platform/windows/key_mapping_win.cpp b/platform/windows/key_mapping_win.cpp index bffacb3a82..83e2af72b2 100644 --- a/platform/windows/key_mapping_win.cpp +++ b/platform/windows/key_mapping_win.cpp @@ -44,7 +44,7 @@ static _WinTranslatePair _vk_to_keycode[] = { //VK_CLEAR (0x0C) - { KEY_RETURN, VK_RETURN }, //(0x0D) + { KEY_ENTER, VK_RETURN }, //(0x0D) { KEY_SHIFT, VK_SHIFT }, //(0x10) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index da14d5c284..9cab19fffb 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -807,7 +807,7 @@ void OS_Windows::process_key_events() { if ((ke.lParam & (1 << 24)) && (ke.wParam == VK_RETURN)) { // Special case for Numpad Enter key - k->set_scancode(KEY_ENTER); + k->set_scancode(KEY_KP_ENTER); } else { k->set_scancode(KeyMappingWindows::get_keysym(ke.wParam)); } @@ -1192,10 +1192,6 @@ void OS_Windows::finalize() { main_loop = NULL; - for (int i = 0; i < get_audio_driver_count(); i++) { - AudioDriverManager::get_driver(i)->finish(); - } - memdelete(joypad); memdelete(input); diff --git a/platform/x11/key_mapping_x11.cpp b/platform/x11/key_mapping_x11.cpp index 1d7eb1692c..32a9806b22 100644 --- a/platform/x11/key_mapping_x11.cpp +++ b/platform/x11/key_mapping_x11.cpp @@ -44,7 +44,7 @@ static _XTranslatePair _xkeysym_to_keycode[] = { { XK_Tab, KEY_TAB }, { XK_ISO_Left_Tab, KEY_BACKTAB }, { XK_BackSpace, KEY_BACKSPACE }, - { XK_Return, KEY_RETURN }, + { XK_Return, KEY_ENTER }, { XK_Insert, KEY_INSERT }, { XK_Delete, KEY_DELETE }, { XK_Clear, KEY_DELETE }, @@ -78,7 +78,7 @@ static _XTranslatePair _xkeysym_to_keycode[] = { { XK_Help, KEY_HELP }, { XK_KP_Space, KEY_SPACE }, { XK_KP_Tab, KEY_TAB }, - { XK_KP_Enter, KEY_ENTER }, + { XK_KP_Enter, KEY_KP_ENTER }, { XK_Home, KEY_HOME }, { XK_Left, KEY_LEFT }, { XK_Up, KEY_UP }, diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 1dde328eda..ade3a0a0c5 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -529,10 +529,6 @@ void OS_X11::finalize() { memdelete(main_loop); main_loop = NULL; - for (int i = 0; i < get_audio_driver_count(); i++) { - AudioDriverManager::get_driver(i)->finish(); - } - /* if (debugger_connection_console) { memdelete(debugger_connection_console); diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index aa9258c7b4..b56f4f9ad9 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -396,6 +396,7 @@ Particles2D::Particles2D() { set_randomness_ratio(0); set_visibility_rect(Rect2(Vector2(-100, -100), Vector2(200, 200))); set_use_local_coordinates(true); + set_draw_order(DRAW_ORDER_INDEX); set_speed_scale(1); h_frames = 1; v_frames = 1; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 543b64bd15..85a9ada38a 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1268,7 +1268,7 @@ void AnimationPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationPlayer::advance); - ADD_GROUP("Playback", "playback_"); + ADD_GROUP("Playback Options", "playback_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Fixed,Idle"), "set_animation_process_mode", "get_animation_process_mode"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_default_blend_time", "get_default_blend_time"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "root_node"), "set_root", "get_root"); diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index f4dd3e92cd..8556ce5db1 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -229,8 +229,8 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { bool handled = true; switch (code) { - case KEY_ENTER: - case KEY_RETURN: { + case KEY_KP_ENTER: + case KEY_ENTER: { emit_signal("text_entered", text); if (OS::get_singleton()->has_virtual_keyboard()) diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index f59a2e06eb..b673f9d68a 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -249,8 +249,8 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { } } } break; - case KEY_RETURN: - case KEY_ENTER: { + case KEY_ENTER: + case KEY_KP_ENTER: { if (mouse_over >= 0 && mouse_over < items.size() && !items[mouse_over].separator) { diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 24eb19fbc2..a2deef4eea 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -226,7 +226,6 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { if (found != -1) { set_current_tab(found); - emit_signal("tab_changed", found); } } } @@ -419,6 +418,7 @@ int Tabs::get_tab_count() const { void Tabs::set_current_tab(int p_current) { + if (current == p_current) return; ERR_FAIL_INDEX(p_current, get_tab_count()); current = p_current; @@ -426,6 +426,8 @@ void Tabs::set_current_tab(int p_current) { _change_notify("current_tab"); _update_cache(); update(); + + emit_signal("tab_changed", p_current); } int Tabs::get_current_tab() const { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 2fc3204f3a..a7c31361e8 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1805,7 +1805,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_ENTER || k->get_scancode() == KEY_RETURN || k->get_scancode() == KEY_TAB) { + if (k->get_scancode() == KEY_KP_ENTER || k->get_scancode() == KEY_ENTER || k->get_scancode() == KEY_TAB) { _confirm_completion(); accept_event(); @@ -1974,8 +1974,8 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { switch (k->get_scancode()) { - case KEY_ENTER: - case KEY_RETURN: { + case KEY_KP_ENTER: + case KEY_ENTER: { if (readonly) break; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 0b57841be7..9499ba9dcd 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1917,8 +1917,8 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool void Tree::_text_editor_modal_close() { if (Input::get_singleton()->is_key_pressed(KEY_ESCAPE) || - Input::get_singleton()->is_key_pressed(KEY_ENTER) || - Input::get_singleton()->is_key_pressed(KEY_RETURN)) { + Input::get_singleton()->is_key_pressed(KEY_KP_ENTER) || + Input::get_singleton()->is_key_pressed(KEY_ENTER)) { return; } @@ -2237,8 +2237,8 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } break; case KEY_F2: - case KEY_RETURN: - case KEY_ENTER: { + case KEY_ENTER: + case KEY_KP_ENTER: { if (selected_item) { //bring up editor if possible diff --git a/scene/main/node.cpp b/scene/main/node.cpp index c3849f79df..fcb9c1a842 100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -705,12 +705,12 @@ void Node::rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, co ERR_FAIL_COND(!is_inside_tree()); bool skip_rpc = false; + bool call_local_native = false; + bool call_local_script = false; if (p_peer_id == 0 || p_peer_id == get_tree()->get_network_unique_id() || (p_peer_id < 0 && p_peer_id != -get_tree()->get_network_unique_id())) { //check that send mode can use local call - bool call_local = false; - Map<StringName, RPCMode>::Element *E = data.rpc_methods.find(p_method); if (E) { @@ -724,29 +724,22 @@ void Node::rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, co } break; case RPC_MODE_SYNC: { //call it, sync always results in call - call_local = true; + call_local_native = true; } break; case RPC_MODE_MASTER: { - call_local = is_network_master(); - if (call_local) { + call_local_native = is_network_master(); + if (call_local_native) { skip_rpc = true; //no other master so.. } } break; case RPC_MODE_SLAVE: { - call_local = !is_network_master(); + call_local_native = !is_network_master(); } break; } } - if (call_local) { - Variant::CallError ce; - call(p_method, p_arg, p_argcount, ce); - if (ce.error != Variant::CallError::CALL_OK) { - String error = Variant::get_call_error_text(this, p_method, p_arg, p_argcount, ce); - error = "rpc() aborted in local call: - " + error; - ERR_PRINTS(error); - return; - } + if (call_local_native) { + // done below } else if (get_script_instance()) { //attempt with script ScriptInstance::RPCMode rpc_mode = get_script_instance()->get_rpc_mode(p_method); @@ -761,37 +754,47 @@ void Node::rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, co } break; case ScriptInstance::RPC_MODE_SYNC: { //call it, sync always results in call - call_local = true; + call_local_script = true; } break; case ScriptInstance::RPC_MODE_MASTER: { - call_local = is_network_master(); - if (call_local) { + call_local_script = is_network_master(); + if (call_local_script) { skip_rpc = true; //no other master so.. } } break; case ScriptInstance::RPC_MODE_SLAVE: { - call_local = !is_network_master(); + call_local_script = !is_network_master(); } break; } - - if (call_local) { - Variant::CallError ce; - ce.error = Variant::CallError::CALL_OK; - get_script_instance()->call(p_method, p_arg, p_argcount, ce); - if (ce.error != Variant::CallError::CALL_OK) { - String error = Variant::get_call_error_text(this, p_method, p_arg, p_argcount, ce); - error = "rpc() aborted in script local call: - " + error; - ERR_PRINTS(error); - return; - } - } } } - if (skip_rpc) - return; + if (!skip_rpc) { + get_tree()->_rpc(this, p_peer_id, p_unreliable, false, p_method, p_arg, p_argcount); + } + + if (call_local_native) { + Variant::CallError ce; + call(p_method, p_arg, p_argcount, ce); + if (ce.error != Variant::CallError::CALL_OK) { + String error = Variant::get_call_error_text(this, p_method, p_arg, p_argcount, ce); + error = "rpc() aborted in local call: - " + error; + ERR_PRINTS(error); + return; + } + } - get_tree()->_rpc(this, p_peer_id, p_unreliable, false, p_method, p_arg, p_argcount); + if (call_local_script) { + Variant::CallError ce; + ce.error = Variant::CallError::CALL_OK; + get_script_instance()->call(p_method, p_arg, p_argcount, ce); + if (ce.error != Variant::CallError::CALL_OK) { + String error = Variant::get_call_error_text(this, p_method, p_arg, p_argcount, ce); + error = "rpc() aborted in script local call: - " + error; + ERR_PRINTS(error); + return; + } + } } /******** RSET *********/ diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 2b078f1985..f69c83bf08 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -73,7 +73,7 @@ void Texture::_bind_methods() { ClassDB::bind_method(D_METHOD("draw", "canvas_item", "pos", "modulate", "transpose", "normal_map:Texture"), &Texture::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map:Texture"), &Texture::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map:Texture", "clip_uv"), &Texture::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true)); - ClassDB::bind_method(D_METHOD("get_data:Image", "cube_side"), &ImageTexture::get_data); + ClassDB::bind_method(D_METHOD("get_data:Image"), &Texture::get_data); BIND_CONSTANT(FLAG_MIPMAPS); BIND_CONSTANT(FLAG_REPEAT); diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index ec71333ded..f247e7cde8 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -142,9 +142,9 @@ SceneStringNames::SceneStringNames() { h_offset = StaticCString::create("h_offset"); v_offset = StaticCString::create("v_offset"); - transform_pos = StaticCString::create("transform/pos"); - transform_rot = StaticCString::create("transform/rot"); - transform_scale = StaticCString::create("transform/scale"); + transform_pos = StaticCString::create("position"); + transform_rot = StaticCString::create("rotation_deg"); + transform_scale = StaticCString::create("scale"); _update_remote = StaticCString::create("_update_remote"); _update_pairs = StaticCString::create("_update_pairs"); @@ -158,8 +158,6 @@ SceneStringNames::SceneStringNames() { line_separation = StaticCString::create("line_separation"); - play_play = StaticCString::create("play/play"); - get_drag_data = StaticCString::create("get_drag_data"); drop_data = StaticCString::create("drop_data"); can_drop_data = StaticCString::create("can_drop_data"); diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index 0bfe42a7b8..0b70cd36ff 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -173,8 +173,6 @@ public: StringName _get_minimum_size; - StringName play_play; - StringName _im_update; StringName _queue_update; diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 0d2550e53b..d5f351454d 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -772,10 +772,11 @@ void AudioServer::finish() { buses.clear(); - if (AudioDriver::get_singleton()) { - AudioDriver::get_singleton()->finish(); + for (int i = 0; i < AudioDriverManager::get_driver_count(); i++) { + AudioDriverManager::get_driver(i)->finish(); } } + void AudioServer::update() { } |