diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index cde328bc6f2..06b71f05c00 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -5,7 +5,7 @@ #include "io/base64.h" #include "core/globals.h" #include "io/file_access_encrypted.h" - +#include "os/keyboard.h" _ResourceLoader *_ResourceLoader::singleton=NULL; Ref _ResourceLoader::load_interactive(const String& p_path,const String& p_type_hint) { @@ -694,6 +694,20 @@ String _OS::get_custom_level() const { return OS::get_singleton()->get_custom_level(); } + +String _OS::get_scancode_string(uint32_t p_code) const { + + return keycode_get_string(p_code); +} +bool _OS::is_scancode_unicode(uint32_t p_unicode) const { + + return keycode_has_unicode(p_unicode); +} +int _OS::find_scancode_from_string(const String& p_code) const { + + return find_keycode(p_code); +} + _OS *_OS::singleton=NULL; void _OS::_bind_methods() { @@ -810,6 +824,9 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("native_video_stop"),&_OS::native_video_stop); ObjectTypeDB::bind_method(_MD("native_video_pause"),&_OS::native_video_pause); + ObjectTypeDB::bind_method(_MD("get_scancode_string","code"),&_OS::get_scancode_string); + ObjectTypeDB::bind_method(_MD("is_scancode_unicode","code"),&_OS::is_scancode_unicode); + ObjectTypeDB::bind_method(_MD("find_scancode_from_string","string"),&_OS::find_scancode_from_string); ObjectTypeDB::bind_method(_MD("set_use_file_access_save_and_swap","enabled"),&_OS::set_use_file_access_save_and_swap); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index ea8ca9af925..05f54dd64c3 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -178,6 +178,11 @@ public: String get_unique_ID() const; + String get_scancode_string(uint32_t p_code) const; + bool is_scancode_unicode(uint32_t p_unicode) const; + int find_scancode_from_string(const String& p_code) const; + + /* struct Date { diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 48269f44903..c9b00f49acc 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -343,6 +343,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a #endif if (!valid) { +#ifdef DEBUG_ENABLED + if (ret.get_type()==Variant::STRING) { //return a string when invalid with the error err_text=ret; @@ -350,7 +352,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } else { err_text="Invalid operands '"+Variant::get_type_name(a->get_type())+"' and '"+Variant::get_type_name(b->get_type())+"' in operator '"+Variant::get_operator_name(op)+"'."; } +#endif break; + } #ifdef DEBUG_ENABLED *dst=ret; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 5e5d2a54090..051f8427268 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -610,7 +610,42 @@ static Error _fix_imported_scene_paths(Node* node, Node* root, String save_path) }; -bool EditorNode::_find_and_save_edited_subresources(Object *obj,Set& processed,int32_t flags) { +bool EditorNode::_find_and_save_resource(RES res,Map& processed,int32_t flags) { + + if (res.is_null()) + return false; + + if (processed.has(res)) { + + return processed[res]; + } + + + bool changed = res->is_edited(); + res->set_edited(false); + + bool subchanged = _find_and_save_edited_subresources(res.ptr(),processed,flags); + +// print_line("checking if edited: "+res->get_type()+" :: "+res->get_name()+" :: "+res->get_path()+" :: "+itos(changed)+" :: SR "+itos(subchanged)); + + if (res->get_path().is_resource_file()) { + if (changed || subchanged) { + //save + print_line("Also saving modified external resource: "+res->get_path()); + Error err = ResourceSaver::save(res->get_path(),res,flags); + + } + processed[res]=false; //because it's a file + return false; + } else { + + + processed[res]=changed; + return changed; + } +} + +bool EditorNode::_find_and_save_edited_subresources(Object *obj,Map& processed,int32_t flags) { bool ret_changed=false; List pi; @@ -620,57 +655,45 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj,Set& proces if (!(E->get().usage&PROPERTY_USAGE_STORAGE)) continue; + + switch(E->get().type) { case Variant::OBJECT: { RES res = obj->get(E->get().name); - if (res.is_null() || processed.has(res)) - break; - - processed.insert(res); - - bool changed = res->is_edited(); - res->set_edited(false); - - bool subchanged = _find_and_save_edited_subresources(res.ptr(),processed,flags); - - if (res->get_path().is_resource_file()) { - if (changed || subchanged) { - //save - print_line("Also saving modified external resource: "+res->get_path()); - Error err = ResourceSaver::save(res->get_path(),res,flags); - - } - } else { - + if (_find_and_save_resource(res,processed,flags)) ret_changed=true; - } - } break; case Variant::ARRAY: { - /*Array varray=p_variant; + Array varray= obj->get(E->get().name); int len=varray.size(); for(int i=0;iget(E->get().name);; List keys; d.get_key_list(&keys); for(List::Element *E=keys.front();E;E=E->next()) { Variant v = d[E->get()]; - _find_resources(v); - } */ + RES res=v; + if (_find_and_save_resource(res,processed,flags)) + ret_changed=true; + } } break; default: {} } @@ -681,7 +704,7 @@ bool EditorNode::_find_and_save_edited_subresources(Object *obj,Set& proces } -void EditorNode::_save_edited_subresources(Node* scene,Set& processed,int32_t flags) { +void EditorNode::_save_edited_subresources(Node* scene,Map& processed,int32_t flags) { _find_and_save_edited_subresources(scene,processed,flags); @@ -741,7 +764,7 @@ void EditorNode::_save_scene(String p_file) { err = ResourceSaver::save(p_file,sdata,flg); - Set processed; + Map processed; _save_edited_subresources(scene,processed,flg); editor_data.save_editor_external_data(); if (err==OK) { diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index ae712004ba6..76e82b5a6b6 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -390,8 +390,9 @@ class EditorNode : public Node { void _cleanup_scene(); - bool _find_and_save_edited_subresources(Object *obj,Set& processed,int32_t flags); - void _save_edited_subresources(Node* scene,Set& processed,int32_t flags); + bool _find_and_save_resource(RES p_res,Map& processed,int32_t flags); + bool _find_and_save_edited_subresources(Object *obj,Map& processed,int32_t flags); + void _save_edited_subresources(Node* scene,Map& processed,int32_t flags); struct ExportDefer {