diff options
35 files changed, 478 insertions, 227 deletions
diff --git a/core/global_config.cpp b/core/global_config.cpp index 5ce9a088b8..81b923f01e 100644 --- a/core/global_config.cpp +++ b/core/global_config.cpp @@ -242,7 +242,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { if (FileAccessNetworkClient::get_singleton()) { - if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { + if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) { _load_settings("res://override.cfg"); } @@ -259,7 +259,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { bool ok = _load_resource_pack(p_main_pack); ERR_FAIL_COND_V(!ok, ERR_CANT_OPEN); - if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { + if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) { //load override from location of the main pack _load_settings(p_main_pack.get_base_dir().plus_file("override.cfg")); } @@ -272,7 +272,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { if (_load_resource_pack(exec_path.get_basename() + ".pck")) { - if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { + if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) { //load override from location of executable _load_settings(exec_path.get_base_dir().plus_file("override.cfg")); } @@ -293,14 +293,14 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { // data.pck and data.zip are deprecated and no longer supported, apologies. // make sure this is loaded from the resource path - if (_load_settings("res://godot.cfg") == OK || _load_settings_binary("res://godot.cfb") == OK) { + if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://godot.cfb") == OK) { _load_settings("res://override.cfg"); } return OK; } - //Nothing was found, try to find a godot.cfg somewhere! + //Nothing was found, try to find a project.godot somewhere! DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); ERR_FAIL_COND_V(!d, ERR_CANT_CREATE); @@ -314,7 +314,7 @@ Error GlobalConfig::setup(const String &p_path, const String &p_main_pack) { while (true) { //try to load settings in ascending through dirs shape! - if (_load_settings(current_dir + "/godot.cfg") == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) { + if (_load_settings(current_dir + "/project.godot") == OK || _load_settings_binary(current_dir + "/godot.cfb") == OK) { _load_settings(current_dir + "/override.cfg"); candidate = current_dir; @@ -474,7 +474,7 @@ void GlobalConfig::clear(const String &p_name) { Error GlobalConfig::save() { - return save_custom(get_resource_path() + "/godot.cfg"); + return save_custom(get_resource_path() + "/project.godot"); } Error GlobalConfig::_save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom) { @@ -483,7 +483,7 @@ Error GlobalConfig::_save_settings_binary(const String &p_file, const Map<String FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err); if (err != OK) { - ERR_EXPLAIN("Coudln't save godot.cfb at " + p_file); + ERR_EXPLAIN("Couldn't save godot.cfb at " + p_file); ERR_FAIL_COND_V(err, err) } @@ -548,7 +548,7 @@ Error GlobalConfig::_save_settings_text(const String &p_file, const Map<String, FileAccess *file = FileAccess::open(p_file, FileAccess::WRITE, &err); if (err) { - ERR_EXPLAIN("Coudln't save godot.cfg - " + p_file); + ERR_EXPLAIN("Couldn't save project.godot - " + p_file); ERR_FAIL_COND_V(err, err) } @@ -674,7 +674,7 @@ Error GlobalConfig::save_custom(const String &p_path, const CustomMap &p_custom, Error err = file->open(dst_file,FileAccess::WRITE); if (err) { memdelete(file); - ERR_EXPLAIN("Coudln't save godot.cfg"); + ERR_EXPLAIN("Couldn't save project.godot"); ERR_FAIL_COND_V(err,err) } diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 5e12b230be..234156d39f 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -409,7 +409,7 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings, Token token; get_token(p_stream, token, line, r_err_str); if (token.type != TK_PARENTHESIS_OPEN) { - r_err_str = "Expected '(' in old-style godot.cfg construct"; + r_err_str = "Expected '(' in old-style project.godot construct"; return ERR_PARSE_ERROR; } @@ -420,7 +420,7 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings, CharType c = p_stream->get_char(); if (p_stream->is_eof()) { - r_err_str = "Unexpected EOF while parsing old-style godot.cfg construct"; + r_err_str = "Unexpected EOF while parsing old-style project.godot construct"; return ERR_PARSE_ERROR; } @@ -1273,7 +1273,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = arr; return OK; - } else if (id == "key") { // compatibility with godot.cfg + } else if (id == "key") { // compatibility with project.godot Vector<String> params; Error err = _parse_enginecfg(p_stream, params, line, r_err_str); @@ -1309,7 +1309,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = ie; return OK; - } else if (id == "mbutton") { // compatibility with godot.cfg + } else if (id == "mbutton") { // compatibility with project.godot Vector<String> params; Error err = _parse_enginecfg(p_stream, params, line, r_err_str); @@ -1324,7 +1324,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = ie; return OK; - } else if (id == "jbutton") { // compatibility with godot.cfg + } else if (id == "jbutton") { // compatibility with project.godot Vector<String> params; Error err = _parse_enginecfg(p_stream, params, line, r_err_str); @@ -1339,7 +1339,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = ie; return OK; - } else if (id == "jaxis") { // compatibility with godot.cfg + } else if (id == "jaxis") { // compatibility with project.godot Vector<String> params; Error err = _parse_enginecfg(p_stream, params, line, r_err_str); @@ -1357,19 +1357,19 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = ie; return OK; - } else if (id == "img") { // compatibility with godot.cfg + } else if (id == "img") { // compatibility with project.godot Token token; // FIXME: no need for this declaration? the first argument in line 509 is a Token& token. get_token(p_stream, token, line, r_err_str); if (token.type != TK_PARENTHESIS_OPEN) { - r_err_str = "Expected '(' in old-style godot.cfg construct"; + r_err_str = "Expected '(' in old-style project.godot construct"; return ERR_PARSE_ERROR; } while (true) { CharType c = p_stream->get_char(); if (p_stream->is_eof()) { - r_err_str = "Unexpected EOF in old style godot.cfg img()"; + r_err_str = "Unexpected EOF in old style project.godot img()"; return ERR_PARSE_ERROR; } if (c == ')') diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 96b311e788..03dd151eb2 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -16455,7 +16455,7 @@ Contains global variables accessible from everywhere. </brief_description> <description> - Contains global variables accessible from everywhere. Use the normal [Object] API, such as "Globals.get(variable)", "Globals.set(variable,value)" or "Globals.has(variable)" to access them. Variables stored in godot.cfg are also loaded into globals, making this object very useful for reading custom game configuration options. + Contains global variables accessible from everywhere. Use the normal [Object] API, such as "Globals.get(variable)", "Globals.set(variable,value)" or "Globals.has(variable)" to access them. Variables stored in project.godot are also loaded into globals, making this object very useful for reading custom game configuration options. </description> <methods> <method name="add_property_info"> diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 4214ee5a6d..db814ec721 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -72,7 +72,7 @@ RasterizerScene *RasterizerGLES3::get_scene() { #define _EXT_DEBUG_SEVERITY_LOW_ARB 0x9148 #define _EXT_DEBUG_OUTPUT 0x92E0 -#ifdef WINDOWS_ENABLED +#if (defined WINDOWS_ENABLED) && !(defined UWP_ENABLED) #define GLAPIENTRY APIENTRY #else #define GLAPIENTRY diff --git a/drivers/xaudio2/audio_driver_xaudio2.h b/drivers/xaudio2/audio_driver_xaudio2.h index 8d240de02e..7c1d31b57c 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.h +++ b/drivers/xaudio2/audio_driver_xaudio2.h @@ -34,7 +34,6 @@ #include "core/os/thread.h" #include "servers/audio_server.h" -#include <mmreg.h> #include <mmsystem.h> #include <windows.h> #include <wrl/client.h> diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index b719e4a487..4796640a3d 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1381,8 +1381,8 @@ Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const Set<StringName> exported; - if (FileAccess::exists("res://godot.cfg")) - exported.insert("res://godot.cfg"); + if (FileAccess::exists("res://project.godot")) + exported.insert("res://project.godot"); if (EditorImportExport::get_singleton()->get_export_filter()!=EditorImportExport::EXPORT_SELECTED) { @@ -1978,7 +1978,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func } - StringName engine_cfg="res://godot.cfg"; + StringName engine_cfg="res://project.godot"; StringName boot_splash; { String splash=GlobalConfig::get_singleton()->get("application/boot_splash"); //avoid splash from being converted @@ -2032,7 +2032,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func { - //make binary godot.cfg config + //make binary project.godot config Map<String,Variant> custom; diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 2612a2af16..b7070ab5f6 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -509,7 +509,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess if (f.begins_with(".")) //ignore hidden and . / .. continue; - if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this + if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) // skip if another project inside this continue; dirs.push_back(f); @@ -688,7 +688,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const int idx = p_dir->find_dir_index(f); if (idx == -1) { - if (FileAccess::exists(cd.plus_file(f).plus_file("godot.cfg"))) // skip if another project inside this + if (FileAccess::exists(cd.plus_file(f).plus_file("project.godot"))) // skip if another project inside this continue; EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index bff22655ff..6b23a02275 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -360,6 +360,7 @@ void EditorNode::_notification(int p_what) { if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); + property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/capitalize_properties", true))); } } @@ -4942,13 +4943,11 @@ EditorNode::EditorNode() { //top_dark_vb->add_child(scene_tabs); //left left_l_hsplit = memnew(HSplitContainer); - left_l_hsplit->add_constant_override("separation", 8 * EDSCALE); main_vbox->add_child(left_l_hsplit); left_l_hsplit->set_v_size_flags(Control::SIZE_EXPAND_FILL); left_l_vsplit = memnew(VSplitContainer); - left_l_vsplit->add_constant_override("separation", 8 * EDSCALE); left_l_hsplit->add_child(left_l_vsplit); dock_slot[DOCK_SLOT_LEFT_UL] = memnew(TabContainer); left_l_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_UL]); @@ -4959,10 +4958,8 @@ EditorNode::EditorNode() { dock_slot[DOCK_SLOT_LEFT_BL]->hide(); left_r_hsplit = memnew(HSplitContainer); - left_r_hsplit->add_constant_override("separation", 8 * EDSCALE); left_l_hsplit->add_child(left_r_hsplit); left_r_vsplit = memnew(VSplitContainer); - left_r_hsplit->add_constant_override("separation", 8 * EDSCALE); left_r_hsplit->add_child(left_r_vsplit); dock_slot[DOCK_SLOT_LEFT_UR] = memnew(TabContainer); left_r_vsplit->add_child(dock_slot[DOCK_SLOT_LEFT_UR]); @@ -4973,7 +4970,6 @@ EditorNode::EditorNode() { //dock_slot[DOCK_SLOT_LEFT_BR]->hide(); main_hsplit = memnew(HSplitContainer); - main_hsplit->add_constant_override("separation", 8 * EDSCALE); left_r_hsplit->add_child(main_hsplit); //main_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); VBoxContainer *center_vb = memnew(VBoxContainer); @@ -4981,18 +4977,15 @@ EditorNode::EditorNode() { center_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL); center_split = memnew(VSplitContainer); - center_split->add_constant_override("separation", 8 * EDSCALE); //main_hsplit->add_child(center_split); center_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); center_split->set_collapsed(false); center_vb->add_child(center_split); right_hsplit = memnew(HSplitContainer); - right_hsplit->add_constant_override("separation", 8 * EDSCALE); main_hsplit->add_child(right_hsplit); right_l_vsplit = memnew(VSplitContainer); - right_l_vsplit->add_constant_override("separation", 8 * EDSCALE); right_hsplit->add_child(right_l_vsplit); dock_slot[DOCK_SLOT_RIGHT_UL] = memnew(TabContainer); right_l_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_UL]); @@ -5003,7 +4996,6 @@ EditorNode::EditorNode() { //dock_slot[DOCK_SLOT_RIGHT_BL]->hide(); right_r_vsplit = memnew(VSplitContainer); - right_r_vsplit->add_constant_override("separation", 8 * EDSCALE); right_hsplit->add_child(right_r_vsplit); dock_slot[DOCK_SLOT_RIGHT_UR] = memnew(TabContainer); right_r_vsplit->add_child(dock_slot[DOCK_SLOT_RIGHT_UR]); @@ -5062,7 +5054,6 @@ EditorNode::EditorNode() { dock_slot[i]->set_v_size_flags(Control::SIZE_EXPAND_FILL); dock_slot[i]->set_popup(dock_select_popoup); dock_slot[i]->connect("pre_popup_pressed", this, "_dock_pre_popup", varray(i)); - dock_slot[i]->add_constant_override("side_margin", 0); //dock_slot[i]->set_tab_align(TabContainer::ALIGN_LEFT); } @@ -5073,7 +5064,6 @@ EditorNode::EditorNode() { dock_drag_timer->connect("timeout", this, "_save_docks"); top_split = memnew(VSplitContainer); - top_split->add_constant_override("separation", 8 * EDSCALE); center_split->add_child(top_split); top_split->set_v_size_flags(Control::SIZE_EXPAND_FILL); top_split->set_collapsed(true); @@ -5638,6 +5628,7 @@ EditorNode::EditorNode() { property_editor->set_show_categories(true); property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); property_editor->set_use_doc_hints(true); + property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/capitalize_properties", true))); property_editor->hide_top_label(); property_editor->register_text_enter(search_box); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 5f2a4d2269..1b4f77419b 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -558,6 +558,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("text_editor/completion/auto_brace_complete", false); set("text_editor/files/restore_scripts_on_load", true); set("text_editor/completion/complete_file_paths", true); + set("text_editor/files/maximum_recent_files", 20); + hints["text_editor/files/maximum_recent_files"] = PropertyInfo(Variant::INT, "text_editor/files/maximum_recent_files", PROPERTY_HINT_RANGE, "1, 200, 0"); //set("docks/scene_tree/display_old_action_buttons",false); set("docks/scene_tree/start_create_dialog_fully_expanded", false); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index dee83c6bc3..1457f6b421 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -69,6 +69,11 @@ Ref<Theme> create_editor_theme() { theme->set_stylebox("bg", "ItemList", style_bg); theme->set_stylebox("EditorBG", "EditorStyles", style_bg); + Ref<StyleBox> style_tree_btn = theme->get_stylebox("button_pressed", "Tree"); + style_tree_btn->set_default_margin(MARGIN_LEFT, 3 * EDSCALE); + style_tree_btn->set_default_margin(MARGIN_RIGHT, 3 * EDSCALE); + theme->set_stylebox("button_pressed", "Tree", style_tree_btn); + Ref<StyleBoxFlat> style_tab(memnew(StyleBoxFlat)); style_tab->set_default_margin(MARGIN_LEFT, 15 * EDSCALE); style_tab->set_default_margin(MARGIN_RIGHT, 15 * EDSCALE); @@ -114,6 +119,10 @@ Ref<Theme> create_editor_theme() { style_textedit_normal->set_default_margin(MARGIN_TOP, 0); theme->set_stylebox("normal", "TextEdit", style_textedit_normal); + theme->set_constant("separation", "HSplitContainer", 8 * EDSCALE); + theme->set_constant("separation", "VSplitContainer", 8 * EDSCALE); + theme->set_constant("side_margin", "TabContainer", 0); + // theme->set_color("prop_category","Editor",Color::hex(0x3f3a44ff)); // theme->set_color("prop_section","Editor",Color::hex(0x35313aff)); // theme->set_color("prop_subsection","Editor",Color::hex(0x312e37ff)); diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index dcbc509865..2cefcdbc4a 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -1863,7 +1863,7 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im node = node_name_map[at.target]; } else { - print_line("Coudlnt find node: " + at.target); + print_line("Couldnt find node: " + at.target); continue; } } else { diff --git a/editor/io_plugins/editor_scene_import_plugin.cpp b/editor/io_plugins/editor_scene_import_plugin.cpp index cd6acbb374..fed02b0e72 100644 --- a/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/editor/io_plugins/editor_scene_import_plugin.cpp @@ -1093,7 +1093,7 @@ const EditorSceneImportDialog::FlagInfo EditorSceneImportDialog::scene_flag_name {EditorSceneImportPlugin::SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,("Merge"),"Keep user-added Animation tracks.",true}, {EditorSceneImportPlugin::SCENE_FLAG_DETECT_ALPHA,("Materials"),"Set Alpha in Materials (-alpha)",true}, {EditorSceneImportPlugin::SCENE_FLAG_DETECT_VCOLOR,("Materials"),"Set Vert. Color in Materials (-vcol)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_COLLISIONS,("Create"),"Create Collisions and/or Rigid Bodies (-col,-colonly,-rigid)",true}, + {EditorSceneImportPlugin::SCENE_FLAG_CREATE_COLLISIONS,("Create"),"Create Collisions and/or Rigid Bodies (-col,-colonly,-rigid,-rigidonly)",true}, {EditorSceneImportPlugin::SCENE_FLAG_CREATE_PORTALS,("Create"),"Create Portals (-portal)",true}, {EditorSceneImportPlugin::SCENE_FLAG_CREATE_ROOMS,("Create"),"Create Rooms (-room)",true}, {EditorSceneImportPlugin::SCENE_FLAG_SIMPLIFY_ROOMS,("Create"),"Simplify Rooms",false}, @@ -1714,12 +1714,14 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> //mi->set_baked_light_texture_id(layer); } - if (p_flags&SCENE_FLAG_CREATE_COLLISIONS && _teststr(name,"colonly")) { + bool is_rigid = _teststr(name, "rigidonly"); + + if (p_flags & SCENE_FLAG_CREATE_COLLISIONS && (_teststr(name, "colonly") || is_rigid)) { if (isroot) return p_node; - - if (p_node->cast_to<MeshInstance>()) { + + if (p_node->cast_to<MeshInstance>() && !is_rigid) { MeshInstance *mi = p_node->cast_to<MeshInstance>(); Node * col = mi->create_trimesh_collision_node(); ERR_FAIL_COND_V(!col,NULL); @@ -1739,10 +1741,16 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> } else if (p_node->has_meta("empty_draw_type")) { String empty_draw_type = String(p_node->get_meta("empty_draw_type")); print_line(empty_draw_type); - StaticBody *sb = memnew( StaticBody); - sb->set_name(_fixstr(name,"colonly")); - sb->cast_to<Spatial>()->set_transform(p_node->cast_to<Spatial>()->get_transform()); - p_node->replace_by(sb); + PhysicsBody *pb; + if (is_rigid) { + pb = memnew(RigidBody); + pb->set_name(_fixstr(name, "rigidonly")); + } else { + pb = memnew(StaticBody); + pb->set_name(_fixstr(name, "colonly")); + } + pb->cast_to<Spatial>()->set_transform(p_node->cast_to<Spatial>()->get_transform()); + p_node->replace_by(pb); memdelete(p_node); CollisionShape *colshape = memnew( CollisionShape); if (empty_draw_type == "CUBE") { @@ -1755,7 +1763,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> rayShape->set_length(1); colshape->set_shape(rayShape); colshape->set_name("RayShape"); - sb->cast_to<Spatial>()->rotate_x(Math_PI / 2); + pb->cast_to<Spatial>()->rotate_x(Math_PI / 2); } else if (empty_draw_type == "IMAGE") { PlaneShape *planeShape = memnew( PlaneShape); colshape->set_shape(planeShape); @@ -1766,8 +1774,8 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> colshape->set_shape(sphereShape); colshape->set_name("SphereShape"); } - sb->add_child(colshape); - colshape->set_owner(sb->get_owner()); + pb->add_child(colshape); + colshape->set_owner(pb->get_owner()); } } else if (p_flags&SCENE_FLAG_CREATE_COLLISIONS && _teststr(name,"rigid") && p_node->cast_to<MeshInstance>()) { diff --git a/editor/io_plugins/editor_translation_import_plugin.cpp b/editor/io_plugins/editor_translation_import_plugin.cpp index 8fba33f787..caa0659046 100644 --- a/editor/io_plugins/editor_translation_import_plugin.cpp +++ b/editor/io_plugins/editor_translation_import_plugin.cpp @@ -347,7 +347,7 @@ public: add_to_project = memnew( CheckButton); add_to_project->set_pressed(true); - add_to_project->set_text(TTR("Add to Project (godot.cfg)")); + add_to_project->set_text(TTR("Add to Project (project.godot)")); tcomp->add_child(add_to_project); file_select = memnew(EditorFileDialog); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index b029f8a3fe..a5414325d0 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -411,6 +411,80 @@ void ScriptEditor::_go_to_tab(int p_idx) { _update_selected_editor_menu(); } +void ScriptEditor::_add_recent_script(String p_path) { + + if (p_path.empty()) { + return; + } + + // remove if already stored + int already_recent = previous_scripts.find(p_path); + if (already_recent >= 0) { + previous_scripts.remove(already_recent); + } + + // add to list + previous_scripts.insert(0, p_path); + + _update_recent_scripts(); +} + +void ScriptEditor::_update_recent_scripts() { + + // make sure we don't exceed max size + const int max_history = EDITOR_DEF("text_editor/files/maximum_recent_files", 20); + if (previous_scripts.size() > max_history) { + previous_scripts.resize(max_history); + } + + recent_scripts->clear(); + + recent_scripts->add_shortcut(ED_SHORTCUT("script_editor/open_recent", TTR("Open Recent"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_T)); + recent_scripts->add_separator(); + + const int max_shown = 8; + for (int i = 0; i < previous_scripts.size() && i <= max_shown; i++) { + String path = previous_scripts.get(i); + // just show script name and last dir + recent_scripts->add_item(path.get_slice("/", path.get_slice_count("/") - 2) + "/" + path.get_file()); + } + + recent_scripts->add_separator(); + recent_scripts->add_shortcut(ED_SHORTCUT("script_editor/clear_recent", TTR("Clear Recent Files"))); +} + +void ScriptEditor::_open_recent_script(int p_idx) { + + // clear button + if (p_idx == recent_scripts->get_item_count() - 1) { + previous_scripts.clear(); + _update_recent_scripts(); + return; + } + + // take two for the open recent button + if (p_idx > 0) { + p_idx -= 2; + } + + if (p_idx < previous_scripts.size() && p_idx >= 0) { + + String path = previous_scripts.get(p_idx); + // if its not on disk its a help file or deleted + if (FileAccess::exists(path)) { + Ref<Script> script = ResourceLoader::load(path); + if (script.is_valid()) { + edit(script, true); + } + // if it's a path then its most likely a delted file not help + } else if (!path.is_resource_file()) { + _help_class_open(path); + } + previous_scripts.remove(p_idx); + _update_recent_scripts(); + } +} + void ScriptEditor::_close_tab(int p_idx, bool p_save) { int selected = p_idx; @@ -420,12 +494,16 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) { Node *tselected = tab_container->get_child(selected); ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>(); if (current) { + _add_recent_script(current->get_edited_script()->get_path()); if (p_save) { apply_scripts(); } if (current->get_edit_menu()) { memdelete(current->get_edit_menu()); } + } else { + EditorHelp *help = tab_container->get_child(selected)->cast_to<EditorHelp>(); + _add_recent_script(help->get_class()); } //remove from history @@ -1978,6 +2056,7 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_close_discard_current_tab", &ScriptEditor::_close_discard_current_tab); ClassDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab); ClassDB::bind_method("_close_all_tabs", &ScriptEditor::_close_all_tabs); + ClassDB::bind_method("_open_recent_script", &ScriptEditor::_open_recent_script); ClassDB::bind_method("_editor_play", &ScriptEditor::_editor_play); ClassDB::bind_method("_editor_pause", &ScriptEditor::_editor_pause); ClassDB::bind_method("_editor_stop", &ScriptEditor::_editor_stop); @@ -2024,7 +2103,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { add_child(menu_hb); script_split = memnew(HSplitContainer); - script_split->add_constant_override("separation", 8 * EDSCALE); add_child(script_split); script_split->set_v_size_flags(SIZE_EXPAND_FILL); @@ -2049,6 +2127,14 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->set_text(TTR("File")); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new", TTR("New")), FILE_NEW); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/open", TTR("Open")), FILE_OPEN); + file_menu->get_popup()->add_submenu_item(TTR("Open Recent"), "RecentScripts", FILE_OPEN_RECENT); + + recent_scripts = memnew(PopupMenu); + recent_scripts->set_name("RecentScripts"); + file_menu->get_popup()->add_child(recent_scripts); + recent_scripts->connect("id_pressed", this, "_open_recent_script"); + _update_recent_scripts(); + file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save", TTR("Save"), KEY_MASK_ALT | KEY_MASK_CMD | KEY_S), FILE_SAVE); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_as", TTR("Save As..")), FILE_SAVE_AS); @@ -2355,6 +2441,9 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { EDITOR_DEF("text_editor/open_scripts/list_script_names_as", 0); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "text_editor/external/exec_path", PROPERTY_HINT_GLOBAL_FILE)); EDITOR_DEF("text_editor/external/exec_flags", ""); + + ED_SHORTCUT("script_editor/open_recent", TTR("Open Recent"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_T); + ED_SHORTCUT("script_editor/clear_recent", TTR("Clear Recent Files")); } ScriptEditorPlugin::~ScriptEditorPlugin() { diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 6a54609167..983847ddaf 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -120,6 +120,7 @@ class ScriptEditor : public VBoxContainer { enum { FILE_NEW, FILE_OPEN, + FILE_OPEN_RECENT, FILE_SAVE, FILE_SAVE_AS, FILE_SAVE_ALL, @@ -169,6 +170,8 @@ class ScriptEditor : public VBoxContainer { Timer *autosave_timer; uint64_t idle; + PopupMenu *recent_scripts; + Button *help_search; Button *site_search; Button *class_search; @@ -207,6 +210,8 @@ class ScriptEditor : public VBoxContainer { Vector<ScriptHistory> history; int history_pos; + Vector<String> previous_scripts; + EditorHelpIndex *help_index; void _tab_changed(int p_which); @@ -224,6 +229,10 @@ class ScriptEditor : public VBoxContainer { bool _test_script_times_on_disk(Ref<Script> p_for_script = Ref<Script>()); + void _add_recent_script(String p_path); + void _update_recent_scripts(); + void _open_recent_script(int p_idx); + void _close_tab(int p_idx, bool p_save = true); void _close_current_tab(); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index f2c04fe785..289655e9da 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -92,18 +92,18 @@ private: if (mode != MODE_IMPORT) { - if (d->file_exists("godot.cfg")) { + if (d->file_exists("project.godot")) { - error->set_text(TTR("Invalid project path, godot.cfg must not exist.")); + error->set_text(TTR("Invalid project path, project.godot must not exist.")); memdelete(d); return ""; } } else { - if (valid_path != "" && !d->file_exists("godot.cfg")) { + if (valid_path != "" && !d->file_exists("project.godot")) { - error->set_text(TTR("Invalid project path, godot.cfg must exist.")); + error->set_text(TTR("Invalid project path, project.godot must exist.")); memdelete(d); return ""; } @@ -136,7 +136,7 @@ private: String p = p_path; if (mode == MODE_IMPORT) { - if (p.ends_with("godot.cfg")) { + if (p.ends_with("project.godot")) { p = p.get_base_dir(); } @@ -162,7 +162,7 @@ private: fdialog->set_mode(FileDialog::MODE_OPEN_FILE); fdialog->clear_filters(); - fdialog->add_filter("godot.cfg ; " _MKSTR(VERSION_NAME) " Project"); + fdialog->add_filter("project.godot ; " _MKSTR(VERSION_NAME) " Project"); } else { fdialog->set_mode(FileDialog::MODE_OPEN_DIR); } @@ -186,9 +186,9 @@ private: } else { if (mode == MODE_NEW) { - FileAccess *f = FileAccess::open(dir.plus_file("/godot.cfg"), FileAccess::WRITE); + FileAccess *f = FileAccess::open(dir.plus_file("/project.godot"), FileAccess::WRITE); if (!f) { - error->set_text(TTR("Couldn't create godot.cfg in project path.")); + error->set_text(TTR("Couldn't create project.godot in project path.")); } else { f->store_line("; Engine configuration file."); @@ -741,7 +741,7 @@ void ProjectManager::_load_recent_projects() { continue; String project = _name.get_slice("/", 1); - String conf = path.plus_file("godot.cfg"); + String conf = path.plus_file("project.godot"); bool favorite = (_name.begins_with("favorite_projects/")) ? true : false; uint64_t last_modified = 0; @@ -1006,7 +1006,7 @@ void ProjectManager::_scan_dir(DirAccess *da, float pos, float total, List<Strin while (n != String()) { if (da->current_is_dir() && !n.begins_with(".")) { subdirs.push_front(n); - } else if (n == "godot.cfg") { + } else if (n == "project.godot") { r_projects->push_back(da->get_current_dir()); } n = da->get_next(); @@ -1117,7 +1117,7 @@ void ProjectManager::_files_dropped(PoolStringArray p_files, int p_screen) { dir->list_dir_begin(); String file = dir->get_next(); while (confirm && file != String()) { - if (!dir->current_is_dir() && file.ends_with("godot.cfg")) { + if (!dir->current_is_dir() && file.ends_with("project.godot")) { confirm = false; } file = dir->get_next(); diff --git a/editor/project_settings.cpp b/editor/project_settings.cpp index 858b9403a7..5795e41b92 100644 --- a/editor/project_settings.cpp +++ b/editor/project_settings.cpp @@ -1168,13 +1168,12 @@ void ProjectSettings::_bind_methods() { ProjectSettings::ProjectSettings(EditorData *p_data) { singleton = this; - set_title(TTR("Project Settings (godot.cfg)")); + set_title(TTR("Project Settings (project.godot)")); set_resizable(true); undo_redo = &p_data->get_undo_redo(); data = p_data; tab_container = memnew(TabContainer); - tab_container->add_constant_override("side_margin", 0); add_child(tab_container); //set_child_rect(tab_container); @@ -1265,7 +1264,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { //globals_editor->hide_top_label(); globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); globals_editor->get_property_editor()->register_text_enter(search_box); - globals_editor->get_property_editor()->set_capitalize_paths(false); + globals_editor->get_property_editor()->set_enable_capitalize_paths(false); globals_editor->get_property_editor()->get_scene_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"); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index f0717f1e6b..5ff5e680f6 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -2769,10 +2769,7 @@ TreeItem *PropertyEditor::get_parent_node(String p_path, HashMap<String, TreeIte item = tree->create_item(parent); String name = (p_path.find("/") != -1) ? p_path.right(p_path.find_last("/") + 1) : p_path; - if (capitalize_paths) - item->set_text(0, name.capitalize()); - else - item->set_text(0, name); + item->set_text(0, capitalize_paths ? name.capitalize() : name); item->set_tooltip(0, p_path); if (item->get_parent() != root) { item->set_icon(0, get_icon("Folder", "EditorIcons")); @@ -3405,6 +3402,13 @@ void PropertyEditor::update_tree() { item->set_icon(0, get_icon("ArrayData", "EditorIcons")); } break; + case Variant::DICTIONARY: { + + item->set_cell_mode(1, TreeItem::CELL_MODE_STRING); + item->set_editable(1, false); + item->set_text(1, obj->get(p.name).operator String()); + + } break; case Variant::POOL_INT_ARRAY: { @@ -4298,9 +4302,15 @@ String PropertyEditor::get_selected_path() const { return ""; } -void PropertyEditor::set_capitalize_paths(bool p_capitalize) { +bool PropertyEditor::is_capitalize_paths_enabled() const { + + return capitalize_paths; +} + +void PropertyEditor::set_enable_capitalize_paths(bool p_capitalize) { capitalize_paths = p_capitalize; + update_tree_pending = true; } void PropertyEditor::set_autoclear(bool p_enable) { diff --git a/editor/property_editor.h b/editor/property_editor.h index 3b68e80ac3..b88ba38e19 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -272,7 +272,8 @@ public: custom_editor->set_read_only(p_read_only); } - void set_capitalize_paths(bool p_capitalize); + bool is_capitalize_paths_enabled() const; + void set_enable_capitalize_paths(bool p_capitalize); void set_autoclear(bool p_enable); void set_show_categories(bool p_show); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index a5cee0c907..2bc00c62fb 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -1634,7 +1634,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { inspector->set_h_size_flags(SIZE_EXPAND_FILL); inspector->hide_top_label(); inspector->get_scene_tree()->set_column_title(0, TTR("Variable")); - inspector->set_capitalize_paths(false); + inspector->set_enable_capitalize_paths(false); inspector->set_read_only(true); sc->add_child(inspector); diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 70acb8a052..8c87857944 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -300,7 +300,6 @@ EditorSettingsDialog::EditorSettingsDialog() { set_resizable(true); tabs = memnew(TabContainer); - tabs->add_constant_override("side_margin", 0); add_child(tabs); //set_child_rect(tabs); diff --git a/main/main.cpp b/main/main.cpp index ad7ca84d6b..33095e8599 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -129,7 +129,7 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print(VERSION_FULL_NAME " (c) 2008-2017 Juan Linietsky, Ariel Manzur.\n"); OS::get_singleton()->print("Usage: %s [options] [scene]\n", p_binary); OS::get_singleton()->print("Options:\n"); - OS::get_singleton()->print("\t-path [dir] : Path to a game, containing godot.cfg\n"); + OS::get_singleton()->print("\t-path [dir] : Path to a game, containing project.godot\n"); #ifdef TOOLS_ENABLED OS::get_singleton()->print("\t-e,-editor : Bring up the editor instead of running the scene.\n"); #endif @@ -447,6 +447,23 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } else { goto error; } + } else if (I->get().ends_with("project.godot")) { + String path; + String file = I->get(); + int sep = MAX(file.find_last("/"), file.find_last("\\")); + if (sep == -1) + path = "."; + else { + path = file.substr(0, sep); + } + if (OS::get_singleton()->set_cwd(path) == OK) { + // path already specified, don't override + } else { + game_path = path; + } +#ifdef TOOLS_ENABLED + editor = true; +#endif } else if (I->get() == "-bp") { // /breakpoints if (I->next()) { @@ -673,7 +690,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph else input_map->load_from_globals(); //keys for game - if (video_driver == "") // specified in godot.cfg + if (video_driver == "") // specified in project.godot video_driver = GLOBAL_DEF("display/driver/name", Variant((const char *)OS::get_singleton()->get_video_driver_name(0))); if (!force_res && use_custom_res && globals->has("display/window/width")) @@ -725,7 +742,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph /* Determine Video Driver */ - if (audio_driver == "") { // specified in godot.cfg + if (audio_driver == "") { // specified in project.godot audio_driver = GLOBAL_DEF("audio/driver", OS::get_singleton()->get_audio_driver_name(0)); } diff --git a/misc/scripts/sort-demos.sh b/misc/scripts/sort-demos.sh index 2121d78c15..5e01b86b46 100644 --- a/misc/scripts/sort-demos.sh +++ b/misc/scripts/sort-demos.sh @@ -1,7 +1,7 @@ #!/bin/bash # When scanning for demos, the project manager sorts them based on their # timestamp, i.e. last modification date. This can make for a pretty -# messy output, so this script 'touches' each godot.cfg file in reverse +# messy output, so this script 'touches' each project.godot file in reverse # alphabetical order to ensure a nice listing. # # It's good practice to run it once before packaging demos on the build @@ -17,7 +17,7 @@ if [ -e demos.list ]; then fi for dir in 2d 3d gui misc viewport; do - find "demos/$dir" -name "godot.cfg" |sort >> demos.list + find "demos/$dir" -name "project.godot" |sort >> demos.list done cat demos.list |sort -r > demos_r.list diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp index c6835d4b62..3f7ad8b2c2 100644 --- a/modules/squish/image_compress_squish.cpp +++ b/modules/squish/image_compress_squish.cpp @@ -31,6 +31,12 @@ #include "print_string.h" +#if defined(__SSE2__) +#define SQUISH_USE_SSE 2 +#elif defined(__SSE__) +#define SQUISH_USE_SSE 1 +#endif + #include <squish.h> void image_compress_squish(Image *p_image) { diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index e122bb2e4d..6b1d574496 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -31,94 +31,50 @@ #include "io/resource_loader.h" #include "main/main.h" #include "os_javascript.h" -#include <GL/glut.h> -#include <string.h> OS_JavaScript *os = NULL; -static void _gfx_init(void *ud, bool gl2, int w, int h, bool fs) { +static void main_loop() { - glutInitWindowSize(w, h); - glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); - glutCreateWindow("godot"); + os->main_loop_iterate(); } -static void _gfx_idle() { +extern "C" void main_after_fs_sync() { - glutPostRedisplay(); -} - -int start_step = 0; - -static void _godot_draw(void) { - - if (start_step == 1) { - start_step = 2; - Main::start(); - os->main_loop_begin(); - } - - if (start_step == 2) { - os->main_loop_iterate(); - } - - glutSwapBuffers(); -} - -extern "C" { - -void main_after_fs_sync() { - - start_step = 1; -} + // Ease up compatibility + ResourceLoader::set_abort_on_missing_resources(false); + Main::start(); + os->main_loop_begin(); + emscripten_set_main_loop(main_loop, 0, false); } int main(int argc, char *argv[]) { - /* Initialize the window */ printf("let it go dude!\n"); - glutInit(&argc, argv); - os = new OS_JavaScript(argv[0], _gfx_init, NULL, NULL); - - Error err = Main::setup(argv[0], argc - 1, &argv[1]); - - ResourceLoader::set_abort_on_missing_resources(false); //ease up compatibility - - /* Set up glut callback functions */ - glutIdleFunc(_gfx_idle); - // glutReshapeFunc(gears_reshape); - glutDisplayFunc(_godot_draw); - //glutSpecialFunc(gears_special); - //mount persistent file system + // sync from persistent state into memory and then + // run the 'main_after_fs_sync' function /* clang-format off */ EM_ASM( + Module.noExitRuntime = true; FS.mkdir('/userfs'); FS.mount(IDBFS, {}, '/userfs'); - - // sync from persistent state into memory and then - // run the 'main_after_fs_sync' function FS.syncfs(true, function(err) { - if (err) { Module.setStatus('Failed to load persistent data\nPlease allow (third-party) cookies'); Module.printErr('Failed to populate IDB file system: ' + err.message); - Module.exit(); + Module.noExitRuntime = false; } else { Module.print('Successfully populated IDB file system'); - ccall('main_after_fs_sync', 'void', []); + ccall('main_after_fs_sync', null); } }); ); /* clang-format on */ - glutMainLoop(); + os = new OS_JavaScript(argv[0], NULL); + Error err = Main::setup(argv[0], argc - 1, &argv[1]); return 0; + // continued async in main_after_fs_sync() from syncfs() callback } - -/* - * - *09] <azakai|2__> reduz: yes, define TOTAL_MEMORY on Module. for example var Module = { TOTAL_MEMORY: 12345.. }; before the main - * - */ diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index e44f33f997..1cd1991608 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -390,14 +390,18 @@ void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, i print_line("Init OS"); - if (gfx_init_func) - gfx_init_func(gfx_init_ud, use_gl2, p_desired.width, p_desired.height, p_desired.fullscreen); + EmscriptenWebGLContextAttributes attributes; + emscripten_webgl_init_context_attributes(&attributes); + attributes.alpha = false; + attributes.antialias = false; + attributes.majorVersion = 2; + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context(NULL, &attributes); + ERR_FAIL_COND(emscripten_webgl_make_context_current(ctx) != EMSCRIPTEN_RESULT_SUCCESS); - // nothing to do here, can't fulfil fullscreen request due to - // browser security, window size is already set from HTML video_mode = p_desired; + // can't fulfil fullscreen request due to browser security video_mode.fullscreen = false; - _windowed_size = get_window_size(); + set_window_size(Size2(p_desired.width, p_desired.height)); // find locale, emscripten only sets "C" char locale_ptr[16]; @@ -513,20 +517,62 @@ void OS_JavaScript::alert(const String &p_alert, const String &p_title) { /* clang-format on */ } -void OS_JavaScript::set_mouse_show(bool p_show) { +void OS_JavaScript::set_css_cursor(const char *p_cursor) { - //javascript has no mouse... + /* clang-format off */ + EM_ASM_({ + Module.canvas.style.cursor = Module.UTF8ToString($0); + }, p_cursor); + /* clang-format on */ } -void OS_JavaScript::set_mouse_grab(bool p_grab) { +const char *OS_JavaScript::get_css_cursor() const { - //it really has no mouse...! + char cursor[16]; + /* clang-format off */ + EM_ASM_INT({ + Module.stringToUTF8(Module.canvas.style.cursor ? Module.canvas.style.cursor : 'auto', $0, 16); + }, cursor); + /* clang-format on */ + return cursor; } -bool OS_JavaScript::is_mouse_grab_enabled() const { +void OS_JavaScript::set_mouse_mode(OS::MouseMode p_mode) { - //*sigh* technology has evolved so much since i was a kid.. - return false; + ERR_FAIL_INDEX(p_mode, MOUSE_MODE_CONFINED + 1); + ERR_EXPLAIN("MOUSE_MODE_CONFINED is not supported for the HTML5 platform"); + ERR_FAIL_COND(p_mode == MOUSE_MODE_CONFINED); + if (p_mode == get_mouse_mode()) + return; + + if (p_mode == MOUSE_MODE_VISIBLE) { + + set_css_cursor("auto"); + emscripten_exit_pointerlock(); + + } else if (p_mode == MOUSE_MODE_HIDDEN) { + + set_css_cursor("none"); + emscripten_exit_pointerlock(); + + } else if (p_mode == MOUSE_MODE_CAPTURED) { + + EMSCRIPTEN_RESULT result = emscripten_request_pointerlock("canvas", false); + ERR_EXPLAIN("MOUSE_MODE_CAPTURED can only be entered from within an appropriate input callback"); + ERR_FAIL_COND(result == EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED); + ERR_FAIL_COND(result != EMSCRIPTEN_RESULT_SUCCESS); + set_css_cursor("auto"); + } +} + +OS::MouseMode OS_JavaScript::get_mouse_mode() const { + + if (!strcmp(get_css_cursor(), "none")) + return MOUSE_MODE_HIDDEN; + + EmscriptenPointerlockChangeEvent ev; + emscripten_get_pointerlock_status(&ev); + return ev.isActive && (strcmp(ev.id, "canvas") == 0) ? MOUSE_MODE_CAPTURED : MOUSE_MODE_VISIBLE; } Point2 OS_JavaScript::get_mouse_position() const { @@ -835,10 +881,8 @@ int OS_JavaScript::get_power_percent_left() { return power_manager->get_power_percent_left(); } -OS_JavaScript::OS_JavaScript(const char *p_execpath, GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, GetDataDirFunc p_get_data_dir_func) { +OS_JavaScript::OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_dir_func) { set_cmdline(p_execpath, get_cmdline_args()); - gfx_init_func = p_gfx_init_func; - gfx_init_ud = p_gfx_init_ud; main_loop = NULL; gl_extensions = NULL; window_maximized = false; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 0c956ecba6..ffd269b512 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -45,16 +45,10 @@ #include <emscripten/html5.h> -typedef void (*GFXInitFunc)(void *ud, bool gl2, int w, int h, bool fs); typedef String (*GetDataDirFunc)(); class OS_JavaScript : public OS_Unix { - GFXInitFunc gfx_init_func; - void *gfx_init_ud; - - bool use_gl2; - int64_t time_to_save_sync; int64_t last_sync_time; @@ -81,6 +75,9 @@ class OS_JavaScript : public OS_Unix { void process_joypads(); + void set_css_cursor(const char *); + const char *get_css_cursor() const; + public: // functions used by main to initialize/deintialize the OS virtual int get_video_driver_count() const; @@ -110,9 +107,8 @@ public: virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); - virtual void set_mouse_show(bool p_show); - virtual void set_mouse_grab(bool p_grab); - virtual bool is_mouse_grab_enabled() const; + virtual void set_mouse_mode(MouseMode p_mode); + virtual MouseMode get_mouse_mode() const; virtual Point2 get_mouse_position() const; virtual int get_mouse_button_state() const; virtual void set_window_title(const String &p_title); @@ -167,7 +163,7 @@ public: virtual int get_power_seconds_left(); virtual int get_power_percent_left(); - OS_JavaScript(const char *p_execpath, GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, GetDataDirFunc p_get_data_dir_func); + OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_dir_func); ~OS_JavaScript(); }; diff --git a/platform/uwp/SCsub b/platform/uwp/SCsub index 0167ea9e02..7ee5aa2ac3 100644 --- a/platform/uwp/SCsub +++ b/platform/uwp/SCsub @@ -9,6 +9,7 @@ files = [ '#platform/windows/stream_peer_winsock.cpp', '#platform/windows/key_mapping_win.cpp', 'joypad_uwp.cpp', + 'power_uwp.cpp', 'gl_context_egl.cpp', 'app.cpp', 'os_uwp.cpp', diff --git a/platform/uwp/app.h b/platform/uwp/app.h index 647ef0261b..9cbe7669c9 100644 --- a/platform/uwp/app.h +++ b/platform/uwp/app.h @@ -107,7 +107,7 @@ namespace GodotUWP int last_touch_y[32]; int number_of_contacts; Windows::Foundation::Point last_mouse_pos; - } + }; } /* clang-format on */ diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 8b7e821ab3..818b827e83 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -28,24 +28,22 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "os_uwp.h" -#include "drivers/gles2/rasterizer_gles2.h" +#include "drivers/gles3/rasterizer_gles3.h" +#include "drivers/unix/ip_unix.h" #include "drivers/windows/dir_access_windows.h" #include "drivers/windows/file_access_windows.h" #include "drivers/windows/mutex_windows.h" +#include "drivers/windows/rw_lock_windows.h" #include "drivers/windows/semaphore_windows.h" -#include "main/main.h" -#include "os/memory_pool_dynamic_static.h" -#include "servers/audio_server.h" -#include "servers/visual/visual_server_raster.h" -#include "thread_uwp.h" -//#include "servers/visual/visual_server_wrap_mt.h" -#include "drivers/unix/ip_unix.h" #include "global_config.h" #include "io/marshalls.h" -#include "os/memory_pool_dynamic_prealloc.h" +#include "main/main.h" #include "platform/windows/packet_peer_udp_winsock.h" #include "platform/windows/stream_peer_winsock.h" #include "platform/windows/tcp_server_winsock.h" +#include "servers/audio_server.h" +#include "servers/visual/visual_server_raster.h" +#include "thread_uwp.h" #include <ppltasks.h> #include <wrl.h> @@ -149,9 +147,6 @@ const char *OSUWP::get_audio_driver_name(int p_driver) const { return AudioDriverManager::get_driver(p_driver)->get_name(); } -static MemoryPoolStatic *mempool_static = NULL; -static MemoryPoolDynamic *mempool_dynamic = NULL; - void OSUWP::initialize_core() { last_button_state = 0; @@ -161,32 +156,19 @@ void OSUWP::initialize_core() { ThreadUWP::make_default(); SemaphoreWindows::make_default(); MutexWindows::make_default(); + RWLockWindows::make_default(); FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_RESOURCES); FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_USERDATA); FileAccess::make_default<FileAccessWindows>(FileAccess::ACCESS_FILESYSTEM); - //FileAccessBufferedFA<FileAccessWindows>::make_default(); DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_RESOURCES); DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_USERDATA); DirAccess::make_default<DirAccessWindows>(DirAccess::ACCESS_FILESYSTEM); - //TCPServerWinsock::make_default(); - //StreamPeerWinsock::make_default(); - TCPServerWinsock::make_default(); StreamPeerWinsock::make_default(); PacketPeerUDPWinsock::make_default(); - mempool_static = new MemoryPoolStaticMalloc; -#if 1 - mempool_dynamic = memnew(MemoryPoolDynamicStatic); -#else -#define DYNPOOL_SIZE 4 * 1024 * 1024 - void *buffer = malloc(DYNPOOL_SIZE); - mempool_dynamic = memnew(MemoryPoolDynamicPrealloc(buffer, DYNPOOL_SIZE)); - -#endif - // We need to know how often the clock is updated if (!QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second)) ticks_per_second = 1000; @@ -259,13 +241,18 @@ void OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_aud set_video_mode(vm); gl_context->make_current(); - rasterizer = memnew(RasterizerGLES2); - visual_server = memnew(VisualServerRaster(rasterizer)); + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); + + visual_server = memnew(VisualServerRaster); + // FIXME: Reimplement threaded rendering? Or remove? + /* if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); } + */ // physics_server = memnew(PhysicsServerSW); @@ -288,7 +275,7 @@ void OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_aud ERR_PRINT("Initializing audio failed."); } - power_manager = memnew(PowerWinRT); + power_manager = memnew(PowerUWP); managed_object->update_clipboard(); @@ -381,14 +368,6 @@ void OSUWP::finalize() { if (gl_context) memdelete(gl_context); #endif - if (rasterizer) - memdelete(rasterizer); - - /* - if (debugger_connection_console) { - memdelete(debugger_connection_console); - } - */ memdelete(input); @@ -400,11 +379,8 @@ void OSUWP::finalize() { joypad = nullptr; } -void OSUWP::finalize_core() { - if (mempool_dynamic) - memdelete(mempool_dynamic); - delete mempool_static; +void OSUWP::finalize_core() { } void OSUWP::vprint(const char *p_format, va_list p_list, bool p_stderr) { @@ -880,15 +856,20 @@ String OSUWP::get_data_dir() const { return String(data_folder->Path->Data()).replace("\\", "/"); } -PowerState OSWinrt::get_power_state() { +bool OSUWP::check_feature_support(const String &p_feature) { + + return VisualServer::get_singleton()->has_os_feature(p_feature); +} + +PowerState OSUWP::get_power_state() { return power_manager->get_power_state(); } -int OSWinrt::get_power_seconds_left() { +int OSUWP::get_power_seconds_left() { return power_manager->get_power_seconds_left(); } -int OSWinrt::get_power_percent_left() { +int OSUWP::get_power_percent_left() { return power_manager->get_power_percent_left(); } diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index 88a1dddae3..7d9e681da1 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -38,7 +38,7 @@ #include "main/input_default.h" #include "os/input.h" #include "os/os.h" -#include "power_winrt.h" +#include "power_uwp.h" #include "servers/audio_server.h" #include "servers/physics/physics_server_sw.h" #include "servers/physics_2d/physics_2d_server_sw.h" @@ -94,7 +94,6 @@ private: int old_x, old_y; Point2i center; VisualServer *visual_server; - Rasterizer *rasterizer; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; int pressrc; @@ -107,7 +106,7 @@ private: AudioDriverXAudio2 audio_driver; - PowerWinRT *power_manager; + PowerUWP *power_manager; MouseMode mouse_mode; bool alt_mem; @@ -237,6 +236,8 @@ public: virtual void move_window_to_foreground(); virtual String get_data_dir() const; + virtual bool check_feature_support(const String &p_feature); + void set_gl_context(ContextEGL *p_context); void screen_size_changed(); diff --git a/platform/uwp/power_uwp.cpp b/platform/uwp/power_uwp.cpp new file mode 100644 index 0000000000..a8f0f5ba6d --- /dev/null +++ b/platform/uwp/power_uwp.cpp @@ -0,0 +1,74 @@ +/*************************************************************************/ +/* power_uwp.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "power_uwp.h" + +PowerUWP::PowerUWP() + : nsecs_left(-1), percent_left(-1), power_state(POWERSTATE_UNKNOWN) { +} + +PowerUWP::~PowerUWP() { +} + +bool PowerUWP::UpdatePowerInfo() { + // TODO, WinRT: Battery info is available on at least one WinRT platform (Windows Phone 8). Implement UpdatePowerInfo as appropriate. */ + /* Notes from SDL: + - the Win32 function, GetSystemPowerStatus, is not available for use on WinRT + - Windows Phone 8 has a 'Battery' class, which is documented as available for C++ + - More info on WP8's Battery class can be found at http://msdn.microsoft.com/library/windowsphone/develop/jj207231 + */ + return false; +} + +PowerState PowerUWP::get_power_state() { + if (UpdatePowerInfo()) { + return power_state; + } else { + WARN_PRINT("Power management is not implemented on this platform, defaulting to POWERSTATE_UNKNOWN"); + return POWERSTATE_UNKNOWN; + } +} + +int PowerUWP::get_power_seconds_left() { + if (UpdatePowerInfo()) { + return nsecs_left; + } else { + WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); + return -1; + } +} + +int PowerUWP::get_power_percent_left() { + if (UpdatePowerInfo()) { + return percent_left; + } else { + WARN_PRINT("Power management is not implemented on this platform, defaulting to -1"); + return -1; + } +} diff --git a/platform/uwp/power_uwp.h b/platform/uwp/power_uwp.h new file mode 100644 index 0000000000..465473bc1d --- /dev/null +++ b/platform/uwp/power_uwp.h @@ -0,0 +1,55 @@ +/*************************************************************************/ +/* power_uwp.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef PLATFORM_UWP_POWER_UWP_H_ +#define PLATFORM_UWP_POWER_UWP_H_ + +#include "os/dir_access.h" +#include "os/file_access.h" +#include "os/power.h" + +class PowerUWP { + +private: + int nsecs_left; + int percent_left; + PowerState power_state; + + bool UpdatePowerInfo(); + +public: + PowerUWP(); + virtual ~PowerUWP(); + + PowerState get_power_state(); + int get_power_seconds_left(); + int get_power_percent_left(); +}; + +#endif /* PLATFORM_UWP_POWER_UWP_H_ */ diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 835775e13b..cf5321e907 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -54,20 +54,24 @@ void WindowDialog::_fix_size() { // Windows require additional padding to keep the window chrome visible. Ref<StyleBoxTexture> panel = get_stylebox("panel", "WindowDialog"); - float top = panel->get_expand_margin_size(MARGIN_TOP); - float left = panel->get_expand_margin_size(MARGIN_LEFT); - float bottom = panel->get_expand_margin_size(MARGIN_BOTTOM); - float right = panel->get_expand_margin_size(MARGIN_RIGHT); - pos.x = MAX(left, MIN(pos.x, viewport_size.x - size.x - right)); - pos.y = MAX(top, MIN(pos.y, viewport_size.y - size.y - bottom)); - set_global_position(pos); - - // Also resize the window to fit if a resize should be possible at all. - if (resizable) { - size.x = MIN(size.x, viewport_size.x - left - right); - size.y = MIN(size.y, viewport_size.y - top - bottom); - set_size(size); + // Check validity, because the theme could contain a different type of StyleBox + if (panel.is_valid()) { + float top = panel->get_expand_margin_size(MARGIN_TOP); + float left = panel->get_expand_margin_size(MARGIN_LEFT); + float bottom = panel->get_expand_margin_size(MARGIN_BOTTOM); + float right = panel->get_expand_margin_size(MARGIN_RIGHT); + + pos.x = MAX(left, MIN(pos.x, viewport_size.x - size.x - right)); + pos.y = MAX(top, MIN(pos.y, viewport_size.y - size.y - bottom)); + set_global_position(pos); + + // Also resize the window to fit if a resize should be possible at all. + if (resizable) { + size.x = MIN(size.x, viewport_size.x - left - right); + size.y = MIN(size.y, viewport_size.y - top - bottom); + set_size(size); + } } } diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index dd653ea891..9fe92f0fec 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -3751,7 +3751,7 @@ String ShaderLanguage::get_shader_type(const String &p_code) { String cur_identifier; - for (int i = 0; i < p_code.length() + 1; i++) { + for (int i = 0; i < p_code.length(); i++) { if (p_code[i] == ';') { break; |