diff options
34 files changed, 228 insertions, 414 deletions
diff --git a/.travis.yml b/.travis.yml index ca110a3073..6be9f1f603 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,8 @@ env: - GODOT_TARGET=windows matrix: + include: + - env: STATIC_CHECKS=yes exclude: - os: linux env: GODOT_TARGET=iphone @@ -42,6 +44,9 @@ matrix: addons: apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-3.9 packages: - build-essential - scons @@ -65,6 +70,9 @@ addons: - g++-mingw-w64-x86-64 - mingw-w64 + # For style checks. + - clang-format-3.9 + before_script: - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; brew install scons; fi @@ -75,4 +83,8 @@ before_script: fi script: - - scons platform=$GODOT_TARGET CXX=$CXX openssl=builtin + - if [ "$STATIC_CHECKS" = "yes" ]; then + sh ./misc/travis/clang-format.sh; + else + scons platform=$GODOT_TARGET CXX=$CXX openssl=builtin; + fi diff --git a/SConstruct b/SConstruct index 2e7683d17a..e9a6bc44b6 100644 --- a/SConstruct +++ b/SConstruct @@ -73,6 +73,8 @@ env_base.AppendENVPath('PKG_CONFIG_PATH', os.getenv('PKG_CONFIG_PATH')) env_base.global_defaults = global_defaults env_base.android_maven_repos = [] env_base.android_dependencies = [] +env_base.android_gradle_plugins = [] +env_base.android_gradle_classpath = [] env_base.android_java_dirs = [] env_base.android_res_dirs = [] env_base.android_aidl_dirs = [] @@ -96,6 +98,8 @@ env_base.__class__.android_add_default_config = methods.android_add_default_conf env_base.__class__.android_add_to_manifest = methods.android_add_to_manifest env_base.__class__.android_add_to_permissions = methods.android_add_to_permissions env_base.__class__.android_add_to_attributes = methods.android_add_to_attributes +env_base.__class__.android_add_gradle_plugin = methods.android_add_gradle_plugin +env_base.__class__.android_add_gradle_classpath = methods.android_add_gradle_classpath env_base.__class__.disable_module = methods.disable_module env_base.__class__.add_source_files = methods.add_source_files diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index ce3d65b448..c9c74094d3 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -2078,7 +2078,7 @@ void _Marshalls::_bind_methods() { ClassDB::bind_method(D_METHOD("base64_to_variant:Variant", "base64_str"), &_Marshalls::base64_to_variant); ClassDB::bind_method(D_METHOD("raw_to_base64:String", "array"), &_Marshalls::raw_to_base64); - ClassDB::bind_method(D_METHOD("base64_to_raw:RawArray", "base64_str"), &_Marshalls::base64_to_raw); + ClassDB::bind_method(D_METHOD("base64_to_raw:PoolByteArray", "base64_str"), &_Marshalls::base64_to_raw); ClassDB::bind_method(D_METHOD("utf8_to_base64:String", "utf8_str"), &_Marshalls::utf8_to_base64); ClassDB::bind_method(D_METHOD("base64_to_utf8:String", "base64_str"), &_Marshalls::base64_to_utf8); diff --git a/core/object.cpp b/core/object.cpp index e9b332fafa..fe6f120c17 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1587,7 +1587,7 @@ void Object::_bind_methods() { ClassDB::bind_method(D_METHOD("get_class"), &Object::get_class); ClassDB::bind_method(D_METHOD("is_class", "type"), &Object::is_class); ClassDB::bind_method(D_METHOD("set", "property", "value"), &Object::_set_bind); - ClassDB::bind_method(D_METHOD("get", "property"), &Object::_get_bind); + ClassDB::bind_method(D_METHOD("get:Variant", "property"), &Object::_get_bind); ClassDB::bind_method(D_METHOD("get_property_list"), &Object::_get_property_list_bind); ClassDB::bind_method(D_METHOD("get_method_list"), &Object::_get_method_list_bind); ClassDB::bind_method(D_METHOD("notification", "what", "reversed"), &Object::notification, DEFVAL(false)); diff --git a/core/os/input.cpp b/core/os/input.cpp index 63efbe4d11..22ca94d449 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -83,6 +83,7 @@ void Input::_bind_methods() { ClassDB::bind_method(D_METHOD("action_press", "action"), &Input::action_press); ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release); ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image:Texture", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(Vector2())); + ClassDB::bind_method(D_METHOD("parse_input_event", "event"), &Input::parse_input_event); BIND_CONSTANT(MOUSE_MODE_VISIBLE); BIND_CONSTANT(MOUSE_MODE_HIDDEN); diff --git a/core/os/input.h b/core/os/input.h index 86755e632c..2f6359632e 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -102,6 +102,8 @@ public: virtual int get_joy_button_index_from_string(String p_button) = 0; virtual int get_joy_axis_index_from_string(String p_axis) = 0; + virtual void parse_input_event(const InputEvent &p_event) = 0; + Input(); }; diff --git a/core/variant.cpp b/core/variant.cpp index 771d97a4eb..6d98ba7306 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -166,7 +166,7 @@ String Variant::get_type_name(Variant::Type p_type) { } break; case POOL_REAL_ARRAY: { - return "PoolFloatArray"; + return "PoolRealArray"; } break; case POOL_STRING_ARRAY: { diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 71594887fc..0b6e2d99ea 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -9810,6 +9810,14 @@ <description> </description> </method> + <method name="has_point" qualifiers="virtual"> + <return type="bool"> + </return> + <argument index="0" name="point" type="Vector2"> + </argument> + <description> + </description> + </method> <method name="has_stylebox" qualifiers="const"> <return type="bool"> </return> diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 526b4ab9ce..b081936b99 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -6280,7 +6280,9 @@ void RasterizerStorageGLES3::initialize() { shaders.cubemap_filter.init(); shaders.particles.init(); +#ifdef GLES_OVER_GL glEnable(_EXT_TEXTURE_CUBE_MAP_SEAMLESS); +#endif frame.count = 0; frame.prev_tick = 0; diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index af62a2293b..442ef1fbd3 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -32,14 +32,11 @@ #include "editor_node.h" #include "print_string.h" #include "scene/gui/box_container.h" - -#if 1 - #include "editor_help.h" #include "editor_settings.h" #include "os/keyboard.h" -void CreateDialog::popup(bool p_dontclear) { +void CreateDialog::popup_create(bool p_dontclear) { recent->clear(); @@ -85,34 +82,19 @@ void CreateDialog::popup(bool p_dontclear) { } memdelete(f); - } else { -#if 0 -// I think this was way too confusing - if (base_type=="Node") { - //harcode some favorites :D - favorite_list.push_back("Panel"); - favorite_list.push_back("Button"); - favorite_list.push_back("Label"); - favorite_list.push_back("LineEdit"); - favorite_list.push_back("Node2D"); - favorite_list.push_back("Sprite"); - favorite_list.push_back("Camera2D"); - favorite_list.push_back("Area2D"); - favorite_list.push_back("CollisionShape2D"); - favorite_list.push_back("Spatial"); - favorite_list.push_back("Camera"); - favorite_list.push_back("Area"); - favorite_list.push_back("CollisionShape"); - favorite_list.push_back("TestCube"); - favorite_list.push_back("AnimationPlayer"); - - } -#endif } _update_favorite_list(); - popup_centered_ratio(); + + // Restore valid window bounds or pop up at default size. + if (EditorSettings::get_singleton()->has("interface/dialogs/create_new_node_bounds")) { + popup(EditorSettings::get_singleton()->get("interface/dialogs/create_new_node_bounds")); + } else { + popup_centered_ratio(); + } + + if (p_dontclear) search_box->select_all(); else { @@ -334,23 +316,23 @@ void CreateDialog::_confirmed() { void CreateDialog::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - - connect("confirmed", this, "_confirmed"); - favorite->set_icon(get_icon("Favorites", "EditorIcons")); - } - if (p_what == NOTIFICATION_EXIT_TREE) { - - disconnect("confirmed", this, "_confirmed"); - } - - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - - if (is_visible_in_tree()) { - - search_box->call_deferred("grab_focus"); // still not visible - search_box->select_all(); - } + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + connect("confirmed", this, "_confirmed"); + favorite->set_icon(get_icon("Favorites", "EditorIcons")); + } break; + case NOTIFICATION_EXIT_TREE: { + disconnect("confirmed", this, "_confirmed"); + } break; + case NOTIFICATION_VISIBILITY_CHANGED: { + if (is_visible_in_tree()) { + search_box->call_deferred("grab_focus"); // still not visible + search_box->select_all(); + } + } break; + case NOTIFICATION_POPUP_HIDE: { + EditorSettings::get_singleton()->set("interface/dialogs/create_new_node_bounds", get_rect()); + } break; } } @@ -608,6 +590,8 @@ void CreateDialog::_bind_methods() { CreateDialog::CreateDialog() { + set_resizable(true); + HSplitContainer *hbc = memnew(HSplitContainer); add_child(hbc); @@ -660,227 +644,3 @@ CreateDialog::CreateDialog() { vbc->add_margin_child(TTR("Description:"), help_bit); help_bit->connect("request_hide", this, "_closed"); } - -#else - -//old create dialog, disabled - -void CreateDialog::_notification(int p_what) { - - if (p_what == NOTIFICATION_READY) { - connect("confirmed", this, "_create"); - update_tree(); - } - if (p_what == NOTIFICATION_DRAW) { - - //RID ci = get_canvas_item(); - //get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size())); - } -} - -void CreateDialog::_create() { - - if (tree->get_selected()) - emit_signal("create"); - hide(); -} - -void CreateDialog::_cancel() { - - hide(); -} - -void CreateDialog::_text_changed(String p_text) { - - update_tree(); -} - -void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root) { - - if (p_types.has(p_type)) - return; - if (!ClassDB::is_type(p_type, base) || p_type == base) - return; - - String inherits = ClassDB::type_inherits_from(p_type); - - TreeItem *parent = p_root; - - if (inherits.length()) { - - if (!p_types.has(inherits)) { - - add_type(inherits, p_types, p_root); - } - - if (p_types.has(inherits)) - parent = p_types[inherits]; - } - - TreeItem *item = tree->create_item(parent); - item->set_text(0, p_type); - if (!ClassDB::can_instance(p_type)) { - item->set_custom_color(0, Color(0.5, 0.5, 0.5)); - item->set_selectable(0, false); - } - - if (has_icon(p_type, "EditorIcons")) { - - item->set_icon(0, get_icon(p_type, "EditorIcons")); - } - - p_types[p_type] = item; -} - -void CreateDialog::update_tree() { - - tree->clear(); - - List<String> type_list; - ClassDB::get_type_list(&type_list); - - HashMap<String, TreeItem *> types; - - TreeItem *root = tree->create_item(); - - root->set_text(0, base); - - List<String>::Element *I = type_list.front(); - - for (; I; I = I->next()) { - - String type = I->get(); - - if (!ClassDB::can_instance(type)) - continue; // cant create what can't be instanced - if (filter->get_text() == "") - add_type(type, types, root); - else { - - bool found = false; - String type = I->get(); - while (type != "" && ClassDB::is_type(type, base) && type != base) { - if (type.findn(filter->get_text()) != -1) { - - found = true; - break; - } - - type = ClassDB::type_inherits_from(type); - } - - if (found) - add_type(I->get(), types, root); - } - - if (EditorNode::get_editor_data().get_custom_types().has(type)) { - //there are custom types based on this... cool. - - const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type]; - for (int i = 0; i < ct.size(); i++) { - - bool show = filter->get_text() == "" || ct[i].name.findn(filter->get_text()) != -1; - - if (!show) - continue; - if (!types.has(type)) - add_type(type, types, root); - - TreeItem *ti; - if (types.has(type)) - ti = types[type]; - else - ti = tree->get_root(); - - TreeItem *item = tree->create_item(ti); - item->set_metadata(0, type); - item->set_text(0, ct[i].name); - if (ct[i].icon.is_valid()) { - item->set_icon(0, ct[i].icon); - } - } - } - } -} - -Object *CreateDialog::instance_selected() { - - if (!tree->get_selected()) - return NULL; - - String base = String(tree->get_selected()->get_metadata(0)); - if (base != "") { - - String name = tree->get_selected()->get_text(0); - if (EditorNode::get_editor_data().get_custom_types().has(base)) { - - const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[base]; - for (int i = 0; i < ct.size(); i++) { - - if (ct[i].name == name) { - - Object *obj = ClassDB::instance(base); - ERR_FAIL_COND_V(!obj, NULL); - obj->set_script(ct[i].script.get_ref_ptr()); - if (ct[i].icon.is_valid()) - obj->set_meta("_editor_icon", ct[i].icon); - return obj; - } - } - } - - ERR_FAIL_V(NULL); - } - - return ClassDB::instance(tree->get_selected()->get_text(0)); -} - -void CreateDialog::_bind_methods() { - - ClassDB::bind_method("_create", &CreateDialog::_create); - ClassDB::bind_method("_cancel", &CreateDialog::_cancel); - ClassDB::bind_method("_text_changed", &CreateDialog::_text_changed); - ADD_SIGNAL(MethodInfo("create")); -} - -void CreateDialog::set_base_type(const String &p_base) { - - set_title(vformat("Create %s Type", p_base)); - - if (base == p_base) - return; - base = p_base; - if (is_inside_scene()) - update_tree(); -} - -String CreateDialog::get_base_type() const { - - return base; -} - -CreateDialog::CreateDialog() { - - VBoxContainer *vbc = memnew(VBoxContainer); - add_child(vbc); - - get_ok()->set_text("Create"); - - tree = memnew(Tree); - vbc->add_margin_child("Type:", tree, true); - //tree->set_hide_root(true); - - filter = memnew(LineEdit); - vbc->add_margin_child("Filter:", filter); - - base = "Node"; - set_as_toplevel(true); - - tree->connect("item_activated", this, "_create"); - filter->connect("text_changed", this, "_text_changed"); -} - -CreateDialog::~CreateDialog() { -} - -#endif diff --git a/editor/create_dialog.h b/editor/create_dialog.h index aff6b9c62b..5f0b16bc34 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -40,8 +40,6 @@ @author Juan Linietsky <reduzio@gmail.com> */ -#if 1 - class CreateDialog : public ConfirmationDialog { GDCLASS(CreateDialog, ConfirmationDialog) @@ -92,47 +90,9 @@ public: void set_base_type(const String &p_base); String get_base_type() const; - void popup(bool p_dontclear); + void popup_create(bool p_dontclear); CreateDialog(); }; -#else - -//old create dialog, disabled - -class CreateDialog : public ConfirmationDialog { - - GDCLASS(CreateDialog, ConfirmationDialog); - - Tree *tree; - Button *create; - Button *cancel; - LineEdit *filter; - - void update_tree(); - void _create(); - void _cancel(); - void add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem - *p_root); - - String base; - void _text_changed(String p_text); - virtual void _post_popup() { tree->grab_focus(); } - -protected: - static void _bind_methods(); - void _notification(int p_what); - -public: - Object *instance_selected(); - - void set_base_type(const String &p_base); - String get_base_type() const; - CreateDialog(); - ~CreateDialog(); -}; - -#endif - #endif diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 6a2222345a..3319f1cbee 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2294,7 +2294,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { #endif case RESOURCE_NEW: { - create_dialog->popup(true); + create_dialog->popup_create(true); } break; case RESOURCE_LOAD: { @@ -5857,18 +5857,17 @@ EditorNode::EditorNode() { about = memnew(AcceptDialog); about->set_title(TTR("Thanks from the Godot community!")); - //about->get_cancel()->hide(); about->get_ok()->set_text(TTR("Thanks!")); about->set_hide_on_ok(true); + gui_base->add_child(about); + HBoxContainer *hbc = memnew(HBoxContainer); + about->add_child(hbc); Label *about_text = memnew(Label); about_text->set_text(VERSION_FULL_NAME "\n(c) 2008-2017 Juan Linietsky, Ariel Manzur.\n"); - about_text->set_pos(Point2(gui_base->get_icon("Logo", "EditorIcons")->get_size().width + 30, 20)); - gui_base->add_child(about); - about->add_child(about_text); TextureRect *logo = memnew(TextureRect); - about->add_child(logo); - logo->set_pos(Point2(20, 20)); logo->set_texture(gui_base->get_icon("Logo", "EditorIcons")); + hbc->add_child(logo); + hbc->add_child(about_text); warning = memnew(AcceptDialog); gui_base->add_child(warning); diff --git a/editor/project_settings.cpp b/editor/project_settings.cpp index 43c5ccf3a2..b47f95010b 100644 --- a/editor/project_settings.cpp +++ b/editor/project_settings.cpp @@ -39,7 +39,7 @@ ProjectSettings *ProjectSettings::singleton = NULL; static const char *_button_names[JOY_BUTTON_MAX] = { - "PS X, XBox A, Nintendo B", + "PS Cross, XBox A, Nintendo B", "PS Circle, XBox B, Nintendo A", "PS Square, XBox X, Nintendo Y", "PS Triangle, XBox Y, Nintendo X", diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index f8234d93fd..cc26769939 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -541,7 +541,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: create_dialog->set_base_type("Object"); } - create_dialog->popup(false); + create_dialog->popup_create(false); hide(); updating = false; return false; diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 04b10959ef..f9baa7ea3c 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -276,7 +276,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!_validate_no_foreign()) break; */ - create_dialog->popup(true); + create_dialog->popup_create(true); } break; case TOOL_INSTANCE: { @@ -316,7 +316,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } break; case TOOL_REPLACE: { - create_dialog->popup(false); + create_dialog->popup_create(false); } break; case TOOL_CONNECT: { diff --git a/main/input_default.h b/main/input_default.h index a1a055366c..fecdb215d7 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -201,7 +201,8 @@ public: virtual void warp_mouse_pos(const Vector2 &p_to); - void parse_input_event(const InputEvent &p_event); + virtual void parse_input_event(const InputEvent &p_event); + void set_gravity(const Vector3 &p_gravity); void set_accelerometer(const Vector3 &p_accel); void set_magnetometer(const Vector3 &p_magnetometer); diff --git a/methods.py b/methods.py index 7177dcb804..a86fa1937d 100644 --- a/methods.py +++ b/methods.py @@ -1381,6 +1381,11 @@ def android_add_jni_dir(self, subpath): base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + subpath self.android_jni_dirs.append(base_path) +def android_add_gradle_plugin(self, plugin): + self.android_gradle_plugins.append(plugin) + +def android_add_gradle_classpath(self, classpath): + self.android_gradle_classpath.append(classpath) def android_add_default_config(self, config): self.android_default_config.append(config) diff --git a/misc/travis/clang-format.sh b/misc/travis/clang-format.sh new file mode 100755 index 0000000000..5ecc1b37d8 --- /dev/null +++ b/misc/travis/clang-format.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +CLANG_FORMAT=clang-format-3.9 + +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then + # Check the whole commit range against $TRAVIS_BRANCH, the base merge branch + # We could use $TRAVIS_COMMIT_RANGE but it doesn't play well with force pushes + RANGE="$(git rev-parse $TRAVIS_BRANCH) HEAD" +else + # Test only the last commit + RANGE=HEAD +fi + +FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -v thirdparty/ | grep -e "\.cpp$" -e "\.h$" -e "\.inc$") +echo "Checking files:\n$FILES" + +# create a random filename to store our generated patch +prefix="static-check-clang-format" +suffix="$(date +%s)" +patch="/tmp/$prefix-$suffix.patch" + +for file in $FILES; do + "$CLANG_FORMAT" -style=file "$file" | \ + diff -u "$file" - | \ + sed -e "1s|--- |--- a/|" -e "2s|+++ -|+++ b/$file|" >> "$patch" +done + +# if no patch has been generated all is ok, clean up the file stub and exit +if [ ! -s "$patch" ] ; then + printf "Files in this commit comply with the clang-format rules.\n" + rm -f "$patch" + exit 0 +fi + +# a patch has been created, notify the user and exit +printf "\n*** The following differences were found between the code to commit " +printf "and the clang-format rules:\n\n" +cat "$patch" +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n" +exit 1 diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index e4dd1c36a0..5b1e1c189f 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -2,7 +2,7 @@ Import('env') -# Not building in a separate env as core needs it +# Not building in a separate env as scene needs it # Thirdparty source files if (env['builtin_freetype'] != 'no'): @@ -64,24 +64,20 @@ if (env['builtin_freetype'] != 'no'): if (env['builtin_libpng'] != 'no'): env.Append(CPPPATH=["#thirdparty/libpng"]) - """ FIXME: Remove this commented code if Windows can handle the monolithic lib - # fix for Windows' shell miserably failing on long lines, split in two libraries - half1 = [] - half2 = [] - for x in thirdparty_sources: - if (x.find("src/base") != -1 and x.find("src/sfnt") != -1): - half1.append(x) - else: - half2.append(x) - - lib = env.Library("freetype_builtin1", half2) - env.Append(LIBS = [lib]) - lib = env.Library("freetype_builtin2", half1) - env.Append(LIBS = [lib]) - """ - lib = env.Library("freetype_builtin", thirdparty_sources) - env.Append(LIBS=[lib]) + # Needs to be appended to arrive after libscene in the linker call, + # but we don't want it to arrive *after* system libs, so manual hack + # LIBS contains first SCons Library objects ("SCons.Node.FS.File object") + # and then plain strings for system library. We insert between the two. + inserted = False + print(env["LIBS"]) + for idx, linklib in enumerate(env["LIBS"]): + if isinstance(linklib, basestring): # first system lib such as "X11", otherwise SCons lib object + env["LIBS"].insert(idx, lib) + inserted = True + break + if not inserted: + env.Append(LIBS=[lib]) # Godot source files env.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index bd428941e0..702876ecdc 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -405,7 +405,7 @@ static Ref<Reference> _get_parent_class(GDCompletionContext &context) { if (script.is_null()) { return REF(); } - if (script->is_valid()) { + if (!script->is_valid()) { return REF(); } diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 5b1b496f72..ae2d4d5df3 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -2271,7 +2271,7 @@ Control *VisualScriptEditor::get_edit_menu() { void VisualScriptEditor::_change_base_type() { - select_base_type->popup(true); + select_base_type->popup_create(true); } void VisualScriptEditor::_change_base_type_callback() { diff --git a/platform/android/SCsub b/platform/android/SCsub index 86f8c40f83..e8536953a3 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -49,10 +49,11 @@ gradle_text = gradle_basein.read() gradle_maven_repos_text = "" if len(env.android_maven_repos) > 0: - gradle_maven_repos_text += "maven {\n" + gradle_maven_repos_text += "" for x in env.android_maven_repos: + gradle_maven_repos_text += "\tmaven {\n" gradle_maven_repos_text += "\t\t" + x + "\n" - gradle_maven_repos_text += "\t}\n" + gradle_maven_repos_text += "\t}\n" gradle_maven_dependencies_text = "" @@ -64,7 +65,14 @@ gradle_java_dirs_text = "" for x in env.android_java_dirs: gradle_java_dirs_text += ",'" + x.replace("\\", "/") + "'" +gradle_plugins = "" +for x in env.android_gradle_plugins: + gradle_plugins += "apply plugin: \"" + x + "\"\n" +gradle_classpath = "" +for x in env.android_gradle_classpath: + gradle_classpath += "\t\tclasspath \"" + x + "\"\n" + gradle_res_dirs_text = "" for x in env.android_res_dirs: @@ -95,7 +103,8 @@ gradle_text = gradle_text.replace("$$GRADLE_ASSET_DIRS$$", gradle_asset_dirs_tex gradle_text = gradle_text.replace("$$GRADLE_AIDL_DIRS$$", gradle_aidl_dirs_text) gradle_text = gradle_text.replace("$$GRADLE_JNI_DIRS$$", gradle_jni_dirs_text) gradle_text = gradle_text.replace("$$GRADLE_DEFAULT_CONFIG$$", gradle_default_config_text) - +gradle_text = gradle_text.replace("$$GRADLE_PLUGINS$$", gradle_plugins) +gradle_text = gradle_text.replace("$$GRADLE_CLASSPATH$$", gradle_classpath) gradle_baseout.write(gradle_text) gradle_baseout.close() diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template index c46a15bd12..24aab8e01f 100644 --- a/platform/android/build.gradle.template +++ b/platform/android/build.gradle.template @@ -4,6 +4,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.1.0' + $$GRADLE_CLASSPATH$$ } } @@ -83,3 +84,5 @@ android { variant.outputs.get(0).setOutputFile(new File("${projectDir}/../../../bin", "android_${variant.name}.apk")) } } + +$$GRADLE_PLUGINS$$ diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 60719f6d42..705f0df46e 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -421,6 +421,7 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> ev.mouse_button.y = touch[0].pos.y; ev.mouse_button.global_x = touch[0].pos.x; ev.mouse_button.global_y = touch[0].pos.y; + input->set_mouse_pos(Point2(touch[0].pos.x,touch[0].pos.y)); last_mouse = touch[0].pos; input->parse_input_event(ev); } @@ -503,6 +504,7 @@ void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> ev.mouse_button.y = touch[0].pos.y; ev.mouse_button.global_x = touch[0].pos.x; ev.mouse_button.global_y = touch[0].pos.y; + input->set_mouse_pos(Point2(touch[0].pos.x,touch[0].pos.y)); input->parse_input_event(ev); for (int i = 0; i < touch.size(); i++) { diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index c828045179..f82eae9ff2 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -28,7 +28,6 @@ def get_flags(): return [ ('tools', 'no'), ('module_etc1_enabled', 'no'), - ('module_mpc_enabled', 'no'), ('module_theora_enabled', 'no'), ] @@ -70,13 +69,16 @@ def configure(env): env['LIBSUFFIX'] = '.bc' if (env["target"] == "release"): - env.Append(CCFLAGS=['-O2']) + env.Append(CCFLAGS=['-O3']) + env.Append(LINKFLAGS=['-O3']) elif (env["target"] == "release_debug"): env.Append(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) + env.Append(LINKFLAGS=['-O2']) + # retain function names at the cost of file size, for backtraces and profiling + env.Append(LINKFLAGS=['--profiling-funcs']) elif (env["target"] == "debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED']) - #env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-g4', '-DDEBUG_ENABLED']) - env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) + env.Append(CCFLAGS=['-O1', '-D_DEBUG', '-Wall', '-g', '-DDEBUG_ENABLED']) + env.Append(LINKFLAGS=['-O1', '-g']) # TODO: Move that to opus module's config if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"): @@ -84,16 +86,15 @@ def configure(env): # These flags help keep the file size down env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti']) - env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL', '-DMPC_FIXED_POINT', '-DTYPED_METHOD_BIND', '-DNO_THREADS']) + env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DTYPED_METHOD_BIND', '-DNO_THREADS']) env.Append(CPPFLAGS=['-DGLES3_ENABLED']) + env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1']) - if env['wasm'] == 'yes': + if (env['wasm'] == 'yes'): env.Append(LINKFLAGS=['-s', 'BINARYEN=1']) - # Maximum memory size is baked into the WebAssembly binary during - # compilation, so we need to enable memory growth to allow setting - # TOTAL_MEMORY at runtime. The value set at runtime must be higher than - # what is set during compilation, check TOTAL_MEMORY in Emscripten's - # src/settings.js for the default. + # In contrast to asm.js, enabling memory growth on WebAssembly has no + # major performance impact, and causes only a negligible increase in + # memory size. env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1']) env.extra_suffix = '.webassembly' + env.extra_suffix else: @@ -103,8 +104,5 @@ def configure(env): if env['javascript_eval'] == 'yes': env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED']) - env.Append(LINKFLAGS=['-O2']) - env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1']) - # env.Append(LINKFLAGS=['-g4']) import methods diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 4f79f2fb5d..d7cb69f2b9 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -332,12 +332,11 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au WARN_PRINT("XCreateIC couldn't create xic"); } - XcursorSetTheme(x11_display, "default"); cursor_size = XcursorGetDefaultSize(x11_display); cursor_theme = XcursorGetTheme(x11_display); if (!cursor_theme) { - print_line("not found theme"); + WARN_PRINT("Could not find cursor theme"); cursor_theme = "default"; } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 7779391bae..a8e364a4cd 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -692,7 +692,7 @@ Size2 Control::get_minimum_size() const { if (si) { Variant::CallError ce; - Variant s = si->call(SceneStringNames::get_singleton()->get_minimum_size, NULL, 0, ce); + Variant s = si->call(SceneStringNames::get_singleton()->_get_minimum_size, NULL, 0, ce); if (ce.error == Variant::CallError::CALL_OK) return s; } @@ -2419,7 +2419,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("_font_changed"), &Control::_font_changed); BIND_VMETHOD(MethodInfo("_gui_input", PropertyInfo(Variant::INPUT_EVENT, "event"))); - BIND_VMETHOD(MethodInfo(Variant::VECTOR2, "get_minimum_size")); + BIND_VMETHOD(MethodInfo(Variant::VECTOR2, "_get_minimum_size")); BIND_VMETHOD(MethodInfo(Variant::OBJECT, "get_drag_data", PropertyInfo(Variant::VECTOR2, "pos"))); BIND_VMETHOD(MethodInfo(Variant::BOOL, "can_drop_data", PropertyInfo(Variant::VECTOR2, "pos"), PropertyInfo(Variant::NIL, "data"))); BIND_VMETHOD(MethodInfo("drop_data", PropertyInfo(Variant::VECTOR2, "pos"), PropertyInfo(Variant::NIL, "data"))); @@ -2514,6 +2514,8 @@ void Control::_bind_methods() { ADD_SIGNAL(MethodInfo("size_flags_changed")); ADD_SIGNAL(MethodInfo("minimum_size_changed")); ADD_SIGNAL(MethodInfo("modal_closed")); + + BIND_VMETHOD(MethodInfo("has_point", PropertyInfo(Variant::VECTOR2, "point"))); } Control::Control() { diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 0245944154..c13ed232a7 100644..100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1719,6 +1719,9 @@ void Node::get_owned_by(Node *p_by, List<Node *> *p_owned) { void Node::_set_owner_nocheck(Node *p_owner) { + if (data.owner == p_owner) + return; + ERR_FAIL_COND(data.owner); data.owner = p_owner; data.owner->data.owned.push_back(this); @@ -2020,12 +2023,13 @@ void Node::remove_and_skip() { bool clear = true; for (int i = 0; i < data.children.size(); i++) { - if (!data.children[i]->get_owner()) + Node *c_node = data.children[i]; + if (!c_node->get_owner()) continue; - remove_child(data.children[i]); - data.children[i]->_propagate_replace_owner(this, NULL); - children.push_back(data.children[i]); + remove_child(c_node); + c_node->_propagate_replace_owner(this, NULL); + children.push_back(c_node); clear = false; break; } @@ -2036,9 +2040,9 @@ void Node::remove_and_skip() { while (!children.empty()) { - Node *c = children.front()->get(); - data.parent->add_child(c); - c->_propagate_replace_owner(NULL, new_owner); + Node *c_node = children.front()->get(); + data.parent->add_child(c_node); + c_node->_propagate_replace_owner(NULL, new_owner); children.pop_front(); } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index e46d9db7bc..76c6543a2f 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -1516,34 +1516,41 @@ Array SceneState::get_connection_binds(int p_idx) const { return binds; } -bool SceneState::has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method) const { +bool SceneState::has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method) { - for (int i = 0; i < connections.size(); i++) { - const ConnectionData &c = connections[i]; + // this method cannot be const because of this + Ref<SceneState> ss = this; - NodePath np_from; + do { + for (int i = 0; i < ss->connections.size(); i++) { + const ConnectionData &c = ss->connections[i]; - if (c.from & FLAG_ID_IS_PATH) { - np_from = node_paths[c.from & FLAG_MASK]; - } else { - np_from = get_node_path(c.from); - } + NodePath np_from; - NodePath np_to; + if (c.from & FLAG_ID_IS_PATH) { + np_from = ss->node_paths[c.from & FLAG_MASK]; + } else { + np_from = ss->get_node_path(c.from); + } - if (c.to & FLAG_ID_IS_PATH) { - np_to = node_paths[c.to & FLAG_MASK]; - } else { - np_to = get_node_path(c.to); - } + NodePath np_to; - StringName sn_signal = names[c.signal]; - StringName sn_method = names[c.method]; + if (c.to & FLAG_ID_IS_PATH) { + np_to = ss->node_paths[c.to & FLAG_MASK]; + } else { + np_to = ss->get_node_path(c.to); + } - if (np_from == p_node_from && sn_signal == p_signal && np_to == p_node_to && sn_method == p_method) { - return true; + StringName sn_signal = ss->names[c.signal]; + StringName sn_method = ss->names[c.method]; + + if (np_from == p_node_from && sn_signal == p_signal && np_to == p_node_to && sn_method == p_method) { + return true; + } } - } + + ss = ss->_get_base_scene_state(); + } while (ss.is_valid()); return false; } diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h index b0e89205cb..fe451884f5 100644 --- a/scene/resources/packed_scene.h +++ b/scene/resources/packed_scene.h @@ -163,7 +163,7 @@ public: int get_connection_flags(int p_idx) const; Array get_connection_binds(int p_idx) const; - bool has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method) const; + bool has_connection(const NodePath &p_node_from, const StringName &p_signal, const NodePath &p_node_to, const StringName &p_method); Vector<NodePath> get_editable_instances() const; diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index ae939ead5f..f0a33e0d3b 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -145,7 +145,7 @@ SceneStringNames::SceneStringNames() { _update_remote = StaticCString::create("_update_remote"); _update_pairs = StaticCString::create("_update_pairs"); - get_minimum_size = StaticCString::create("get_minimum_size"); + _get_minimum_size = StaticCString::create("_get_minimum_size"); area_entered = StaticCString::create("area_entered"); area_exited = StaticCString::create("area_exited"); diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index e16e1e04e6..8900bbe1d9 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -167,7 +167,7 @@ public: StringName area_entered; StringName area_exited; - StringName get_minimum_size; + StringName _get_minimum_size; StringName play_play; diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 5419c5cfe7..8f45d0966f 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -864,39 +864,39 @@ void AudioServer::remove_callback(AudioCallback p_callback, void *p_userdata) { unlock(); } -void AudioServer::set_bus_layout(const Ref<AudioBusLayout> &p_state) { +void AudioServer::set_bus_layout(const Ref<AudioBusLayout> &p_bus_layout) { - ERR_FAIL_COND(p_state.is_null() || p_state->buses.size() == 0); + ERR_FAIL_COND(p_bus_layout.is_null() || p_bus_layout->buses.size() == 0); lock(); for (int i = 0; i < buses.size(); i++) { memdelete(buses[i]); } - buses.resize(p_state->buses.size()); + buses.resize(p_bus_layout->buses.size()); bus_map.clear(); - for (int i = 0; i < p_state->buses.size(); i++) { + for (int i = 0; i < p_bus_layout->buses.size(); i++) { Bus *bus = memnew(Bus); if (i == 0) { bus->name = "Master"; } else { - bus->name = p_state->buses[i].name; - bus->send = p_state->buses[i].send; + bus->name = p_bus_layout->buses[i].name; + bus->send = p_bus_layout->buses[i].send; } - bus->solo = p_state->buses[i].solo; - bus->mute = p_state->buses[i].mute; - bus->bypass = p_state->buses[i].bypass; - bus->volume_db = p_state->buses[i].volume_db; + bus->solo = p_bus_layout->buses[i].solo; + bus->mute = p_bus_layout->buses[i].mute; + bus->bypass = p_bus_layout->buses[i].bypass; + bus->volume_db = p_bus_layout->buses[i].volume_db; - for (int j = 0; j < p_state->buses[i].effects.size(); j++) { + for (int j = 0; j < p_bus_layout->buses[i].effects.size(); j++) { - Ref<AudioEffect> fx = p_state->buses[i].effects[j].effect; + Ref<AudioEffect> fx = p_bus_layout->buses[i].effects[j].effect; if (fx.is_valid()) { Bus::Effect bfx; bfx.effect = fx; - bfx.enabled = p_state->buses[i].effects[j].enabled; + bfx.enabled = p_bus_layout->buses[i].effects[j].enabled; bus->effects.push_back(bfx); } } @@ -988,8 +988,8 @@ void AudioServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_speaker_mode"), &AudioServer::get_speaker_mode); ClassDB::bind_method(D_METHOD("get_mix_rate"), &AudioServer::get_mix_rate); - ClassDB::bind_method(D_METHOD("set_state", "state:AudioServerState"), &AudioServer::set_bus_layout); - ClassDB::bind_method(D_METHOD("generate_state:AudioServerState"), &AudioServer::generate_bus_layout); + ClassDB::bind_method(D_METHOD("set_bus_layout", "bus_layout:AudioBusLayout"), &AudioServer::set_bus_layout); + ClassDB::bind_method(D_METHOD("generate_bus_layout:AudioBusLayout"), &AudioServer::generate_bus_layout); ADD_SIGNAL(MethodInfo("bus_layout_changed")); } diff --git a/servers/audio_server.h b/servers/audio_server.h index 46f845f2d4..eed0a5e4c6 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -275,7 +275,7 @@ public: void add_callback(AudioCallback p_callback, void *p_userdata); void remove_callback(AudioCallback p_callback, void *p_userdata); - void set_bus_layout(const Ref<AudioBusLayout> &p_state); + void set_bus_layout(const Ref<AudioBusLayout> &p_bus_layout); Ref<AudioBusLayout> generate_bus_layout() const; AudioServer(); |