diff options
author | Kostadin Damyanov <maxmight@gmail.com> | 2015-06-26 21:35:47 +0300 |
---|---|---|
committer | Kostadin Damyanov <maxmight@gmail.com> | 2015-06-26 21:35:47 +0300 |
commit | e0e54ea7d456c0fabd8f3f9b2667a69ff520f852 (patch) | |
tree | 9ce4e0b6db40ac2ab07b8582e57282fe63130165 /core | |
parent | f61eb5fd8e13642c82364f8ee66a0f6c791a4511 (diff) | |
parent | a67486a39ee629acac068a6d014015944cf83bb3 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'core')
-rw-r--r-- | core/io/resource_format_binary.cpp | 50 | ||||
-rw-r--r-- | core/io/resource_format_binary.h | 2 | ||||
-rw-r--r-- | core/io/resource_format_xml.cpp | 46 | ||||
-rw-r--r-- | core/io/resource_format_xml.h | 2 | ||||
-rw-r--r-- | core/math/math_2d.cpp | 34 | ||||
-rw-r--r-- | core/object.cpp | 67 | ||||
-rw-r--r-- | core/object.h | 7 | ||||
-rw-r--r-- | core/os/input_event.cpp | 10 | ||||
-rw-r--r-- | core/os/input_event.h | 2 | ||||
-rw-r--r-- | core/resource.cpp | 12 | ||||
-rw-r--r-- | core/resource.h | 4 | ||||
-rw-r--r-- | core/script_language.cpp | 8 | ||||
-rw-r--r-- | core/script_language.h | 17 | ||||
-rw-r--r-- | core/undo_redo.cpp | 128 | ||||
-rw-r--r-- | core/undo_redo.h | 7 | ||||
-rw-r--r-- | core/variant_call.cpp | 11 |
16 files changed, 387 insertions, 20 deletions
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 9fb17bcffb..0f6f8a74b1 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -663,14 +663,18 @@ Error ResourceInteractiveLoaderBinary::poll(){ //maybe it is loaded already String path; + int subindex=0; if (!main) { path=internal_resources[s].path; - if (path.begins_with("local://")) - path=path.replace("local://",res_path+"::"); + if (path.begins_with("local://")) { + path=path.replace_first("local://",""); + subindex = path.to_int(); + path=res_path+"::"+path; + } @@ -709,6 +713,7 @@ Error ResourceInteractiveLoaderBinary::poll(){ RES res = RES( r ); r->set_path(path); + r->set_subindex(subindex); int pc = f->get_32(); @@ -1434,14 +1439,14 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, save_unicode_string(path); } else { - if (!resource_map.has(res)) { + if (!resource_set.has(res)) { f->store_32(OBJECT_EMPTY); ERR_EXPLAIN("Resource was not pre cached for the resource section, bug?"); ERR_FAIL(); } f->store_32(OBJECT_INTERNAL_RESOURCE); - f->store_32(resource_map[res]); + f->store_32(res->get_subindex()); //internal resource } @@ -1598,7 +1603,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant& p_variant } - if (resource_map.has(res)) + if (resource_set.has(res)) return; List<PropertyInfo> property_list; @@ -1613,7 +1618,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant& p_variant } } - resource_map[ res ] = saved_resources.size(); + resource_set.insert(res); saved_resources.push_back(res); } break; @@ -1846,11 +1851,42 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ // save internal resource table f->store_32(saved_resources.size()); //amount of internal resources Vector<uint64_t> ofs_pos; + Set<int> used_indices; + + for(List<RES>::Element *E=saved_resources.front();E;E=E->next()) { + + RES r = E->get(); + if (r->get_path()=="" || r->get_path().find("::")!=-1) { + + if (r->get_subindex()!=0) { + if (used_indices.has(r->get_subindex())) { + r->set_subindex(0); //repeated + } else { + used_indices.insert(r->get_subindex()); + } + } + } + + } + + for(List<RES>::Element *E=saved_resources.front();E;E=E->next()) { + RES r = E->get(); if (r->get_path()=="" || r->get_path().find("::")!=-1) { - save_unicode_string("local://"+itos(ofs_pos.size())); + if (r->get_subindex()==0) { + int new_subindex=1; + if (used_indices.size()) { + new_subindex=used_indices.back()->get()+1; + } + + r->set_subindex(new_subindex); + used_indices.insert(new_subindex); + + } + + save_unicode_string("local://"+itos(r->get_subindex())); if (takeover_paths) { r->set_path(p_path+"::"+itos(ofs_pos.size()),true); } diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index ab2e640a86..da415d97a5 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -129,7 +129,7 @@ class ResourceFormatSaverBinaryInstance { int bin_meta_idx; FileAccess *f; String magic; - Map<RES,int> resource_map; + Set<RES> resource_set; Map<StringName,int> string_map; Vector<StringName> strings; diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 3c100d375a..36746a4111 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -1466,6 +1466,7 @@ Error ResourceInteractiveLoaderXML::poll() { String type; String path; + int subres=0; if (!main) { //loading resource @@ -1476,11 +1477,15 @@ Error ResourceInteractiveLoaderXML::poll() { ERR_EXPLAIN(local_path+":"+itos(get_current_line())+": <resource> missing 'type' field."); ERR_FAIL_COND_V(!tag->args.has("type"),ERR_FILE_CORRUPT); path=tag->args["path"]; + error=OK; if (path.begins_with("local://")) { //built-in resource (but really external) - path=path.replace("local://",local_path+"::"); + + path=path.replace("local://",""); + subres=path.to_int(); + path=local_path+"::"+path; } @@ -1519,6 +1524,7 @@ Error ResourceInteractiveLoaderXML::poll() { res = RES( r ); if (path!="") r->set_path(path); + r->set_subindex(subres); //load properties @@ -2029,9 +2035,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V //internal resource ERR_EXPLAIN("Resource was not pre cached for the resource section, bug?"); - ERR_FAIL_COND(!resource_map.has(res)); + ERR_FAIL_COND(!resource_set.has(res)); - params+=" path=\"local://"+itos(resource_map[res])+"\""; + params+=" path=\"local://"+itos(res->get_subindex())+"\""; } } break; @@ -2443,7 +2449,7 @@ void ResourceFormatSaverXMLInstance::_find_resources(const Variant& p_variant,bo return; } - if (resource_map.has(res)) + if (resource_set.has(res)) return; List<PropertyInfo> property_list; @@ -2466,7 +2472,7 @@ void ResourceFormatSaverXMLInstance::_find_resources(const Variant& p_variant,bo I=I->next(); } - resource_map[ res ] = resource_map.size(); //saved after, so the childs it needs are available when loaded + resource_set.insert( res ); //saved after, so the childs it needs are available when loaded saved_resources.push_back(res); } break; @@ -2537,12 +2543,27 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res write_string("\n",false); } + Set<int> used_indices; + + for(List<RES>::Element *E=saved_resources.front();E;E=E->next()) { + + RES res = E->get(); + if (E->next() && (res->get_path()=="" || res->get_path().find("::") != -1 )) { + if (res->get_subindex()!=0) { + if (used_indices.has(res->get_subindex())) { + res->set_subindex(0); //repeated + } else { + used_indices.insert(res->get_subindex()); + } + } + } + } for(List<RES>::Element *E=saved_resources.front();E;E=E->next()) { RES res = E->get(); - ERR_CONTINUE(!resource_map.has(res)); + ERR_CONTINUE(!resource_set.has(res)); bool main = (E->next()==NULL); write_tabs(); @@ -2552,7 +2573,18 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res else if (res->get_path().length() && res->get_path().find("::") == -1 ) enter_tag("resource","type=\""+res->get_type()+"\" path=\""+res->get_path()+"\""); //bundled else { - int idx = resource_map[res]; + + if (res->get_subindex()==0) { + int new_subindex=1; + if (used_indices.size()) { + new_subindex=used_indices.back()->get()+1; + } + + res->set_subindex(new_subindex); + used_indices.insert(new_subindex); + } + + int idx = res->get_subindex(); enter_tag("resource","type=\""+res->get_type()+"\" path=\"local://"+itos(idx)+"\""); if (takeover_paths) { res->set_path(p_path+"::"+itos(idx),true); diff --git a/core/io/resource_format_xml.h b/core/io/resource_format_xml.h index 711b607668..d5ba9eb800 100644 --- a/core/io/resource_format_xml.h +++ b/core/io/resource_format_xml.h @@ -123,7 +123,7 @@ class ResourceFormatSaverXMLInstance { bool skip_editor; FileAccess *f; int depth; - Map<RES,int> resource_map; + Set<RES> resource_set; List<RES> saved_resources; List<RES> external_resources; diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index 0a3963f88f..88717723ce 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -622,9 +622,39 @@ float Matrix32::basis_determinant() const { } Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) const { + + //extract parameters + Vector2 p1 = get_origin(); + Vector2 p2 = p_transform.get_origin(); + + real_t r1 = get_rotation(); + real_t r2 = p_transform.get_rotation(); + + Vector2 s1 = get_scale(); + Vector2 s2 = p_transform.get_scale(); + + //slerp rotation + Vector2 v1(Math::cos(r1), Math::sin(r1)); + Vector2 v2(Math::cos(r2), Math::sin(r2)); + + real_t dot = v1.dot(v2); + + dot = (dot < -1.0) ? -1.0 : ((dot > 1.0) ? 1.0 : dot); //clamp dot to [-1,1] + + Vector2 v; - - return Matrix32(); + if (dot > 0.9995) { + v = Vector2::linear_interpolate(v1, v2, p_c).normalized(); //linearly interpolate to avoid numerical precision issues + } else { + real_t angle = p_c*Math::acos(dot); + Vector2 v3 = (v2 - v1*dot).normalized(); + v = v1*Math::cos(angle) + v3*Math::sin(angle); + } + + //construct matrix + Matrix32 res(Math::atan2(v.y, v.x), Vector2::linear_interpolate(p1, p2, p_c)); + res.scale_basis(Vector2::linear_interpolate(s1, s2, p_c)); + return res; } Matrix32::operator String() const { diff --git a/core/object.cpp b/core/object.cpp index 83a6dada80..6bb7973cef 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -34,6 +34,7 @@ #include "core_string_names.h" #include "translation.h" #include "os/os.h" +#include "resource.h" #ifdef DEBUG_ENABLED @@ -1301,6 +1302,10 @@ Array Object::_get_signal_connection_list(const String& p_signal) const{ void Object::get_signal_list(List<MethodInfo> *p_signals ) const { + if (!script.is_null()) { + Ref<Script>(script)->get_script_signal_list(p_signals); + } + ObjectTypeDB::get_signal_list(get_type_name(),p_signals); //find maybe usersignals? const StringName *S=NULL; @@ -1312,6 +1317,7 @@ void Object::get_signal_list(List<MethodInfo> *p_signals ) const { p_signals->push_back(signal_map[*S].user); } } + } @@ -1350,6 +1356,10 @@ Error Object::connect(const StringName& p_signal, Object *p_to_object, const Str Signal *s = signal_map.getptr(p_signal); if (!s) { bool signal_is_valid = ObjectTypeDB::has_signal(get_type_name(),p_signal); + //check in script + if (!signal_is_valid && !script.is_null() && Ref<Script>(script)->has_script_signal(p_signal)) + signal_is_valid=true; + if (!signal_is_valid) { ERR_EXPLAIN("Attempt to connect nonexistent signal '"+p_signal+"' to method '"+p_to_method+"'"); ERR_FAIL_COND_V(!signal_is_valid,ERR_INVALID_PARAMETER); @@ -1464,6 +1474,63 @@ StringName Object::tr(const StringName& p_message) const { } + +void Object::_clear_internal_resource_paths(const Variant &p_var) { + + switch(p_var.get_type()) { + + case Variant::OBJECT: { + + RES r = p_var; + if (!r.is_valid()) + return; + + if (!r->get_path().begins_with("res://") || r->get_path().find("::")==-1) + return; //not an internal resource + + Object *object=p_var; + if (!object) + return; + + r->set_path(""); + r->clear_internal_resource_paths(); + } break; + case Variant::ARRAY: { + + Array a=p_var; + for(int i=0;i<a.size();i++) { + _clear_internal_resource_paths(a[i]); + } + + } break; + case Variant::DICTIONARY: { + + Dictionary d=p_var; + List<Variant> keys; + d.get_key_list(&keys); + + for (List<Variant>::Element *E=keys.front();E;E=E->next()) { + + _clear_internal_resource_paths(E->get()); + _clear_internal_resource_paths(d[E->get()]); + } + } break; + } + +} + +void Object::clear_internal_resource_paths() { + + List<PropertyInfo> pinfo; + + get_property_list(&pinfo); + + for(List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) { + + _clear_internal_resource_paths(get(E->get().name)); + } +} + void Object::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_type"),&Object::get_type); diff --git a/core/object.h b/core/object.h index 8d1f8ebc5a..9680af924a 100644 --- a/core/object.h +++ b/core/object.h @@ -451,6 +451,8 @@ protected: Array _get_property_list_bind() const; Array _get_method_list_bind() const; + void _clear_internal_resource_paths(const Variant &p_var); + public: //should be protected, but bug in clang++ static void initialize_type(); _FORCE_INLINE_ static void register_custom_data_to_otdb() {}; @@ -599,6 +601,9 @@ public: _FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate=p_enable; } _FORCE_INLINE_ bool can_translate_messages() const { return _can_translate; } + + void clear_internal_resource_paths(); + Object(); virtual ~Object(); @@ -651,6 +656,8 @@ public: #endif + + }; //needed by macros diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index fc23012281..2bd62927b0 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -173,6 +173,16 @@ bool InputEvent::is_action(const String& p_action) const { return InputMap::get_singleton()->event_is_action(*this,p_action); } +bool InputEvent::is_action_pressed(const String& p_action) const { + + return is_action(p_action) && is_pressed() && !is_echo(); +} + +bool InputEvent::is_action_released(const String& p_action) const { + + return is_action(p_action) && !is_pressed(); +} + uint32_t InputEventKey::get_scancode_with_modifiers() const { uint32_t sc=scancode; diff --git a/core/os/input_event.h b/core/os/input_event.h index 811d5504d5..4bb122ebc1 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -287,6 +287,8 @@ struct InputEvent { bool is_pressed() const; bool is_action(const String& p_action) const; + bool is_action_pressed(const String& p_action) const; + bool is_action_released(const String& p_action) const; bool is_echo() const; void set_as_action(const String& p_action, bool p_pressed); diff --git a/core/resource.cpp b/core/resource.cpp index 6e65693350..6967599f96 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -195,6 +195,17 @@ String Resource::get_path() const { return path_cache; } +void Resource::set_subindex(int p_sub_index) { + + subindex=p_sub_index; +} + +int Resource::get_subindex() const{ + + return subindex; +} + + void Resource::set_name(const String& p_name) { name=p_name; @@ -326,6 +337,7 @@ Resource::Resource() { last_modified_time=0; #endif + subindex=0; } diff --git a/core/resource.h b/core/resource.h index cf7ffcbd2c..9d9c445e1d 100644 --- a/core/resource.h +++ b/core/resource.h @@ -99,6 +99,7 @@ friend class ResourceCache; String name; String path_cache; + int subindex; virtual bool _use_builtin_script() const { return true; } @@ -132,6 +133,9 @@ public: void set_path(const String& p_path,bool p_take_over=false); String get_path() const; + void set_subindex(int p_sub_index); + int get_subindex() const; + Ref<Resource> duplicate(bool p_subresources=false); void set_import_metadata(const Ref<ResourceImportMetadata>& p_metadata); diff --git a/core/script_language.cpp b/core/script_language.cpp index 68ac7d0ae7..35c50b1022 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -136,6 +136,14 @@ ScriptInstance::~ScriptInstance() { } + +ScriptCodeCompletionCache *ScriptCodeCompletionCache::singleton=NULL; +ScriptCodeCompletionCache::ScriptCodeCompletionCache() { + singleton=this; +} + + + void ScriptLanguage::frame() { diff --git a/core/script_language.h b/core/script_language.h index 07ad571fda..7104fe4547 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -94,6 +94,10 @@ public: virtual ScriptLanguage *get_language() const=0; + virtual bool has_script_signal(const StringName& p_signal) const=0; + virtual void get_script_signal_list(List<MethodInfo> *r_signals) const=0; + + virtual void update_exports() {} //editor tool @@ -122,6 +126,19 @@ public: virtual ~ScriptInstance(); }; +class ScriptCodeCompletionCache { + + static ScriptCodeCompletionCache *singleton; +public: + + virtual RES get_cached_resource(const String& p_path)=0; + + static ScriptCodeCompletionCache* get_sigleton() { return singleton; } + + ScriptCodeCompletionCache(); + +}; + class ScriptLanguage { public: diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 5e7df3be7e..f565070216 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -282,6 +282,7 @@ void UndoRedo::undo() { return; //nothing to redo _process_operation_list(actions[current_action].undo_ops.front()); current_action--; + version--; } void UndoRedo::clear_history() { @@ -292,7 +293,7 @@ void UndoRedo::clear_history() { while(actions.size()) _pop_history_tail(); - version++; + //version++; } String UndoRedo::get_current_action_name() const { @@ -326,7 +327,7 @@ void UndoRedo::set_commit_notify_callback(CommitNotifyCallback p_callback,void* UndoRedo::UndoRedo() { - version=0; + version=1; action_level=0; current_action=-1; max_steps=-1; @@ -339,3 +340,126 @@ UndoRedo::~UndoRedo() { clear_history(); } + +Variant UndoRedo::_add_do_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { + + if (p_argcount<2) { + r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; + r_error.argument=0; + return Variant(); + } + + if (p_args[0]->get_type()!=Variant::OBJECT) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=0; + r_error.expected=Variant::OBJECT; + return Variant(); + } + + if (p_args[1]->get_type()!=Variant::STRING) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=1; + r_error.expected=Variant::STRING; + return Variant(); + } + + r_error.error=Variant::CallError::CALL_OK; + + Object* object = *p_args[0]; + String method = *p_args[1]; + + Variant v[VARIANT_ARG_MAX]; + + + for(int i=0;i<MIN(VARIANT_ARG_MAX,p_argcount-2);++i) { + + v[i]=*p_args[i+2]; + } + + add_do_method(object,method,v[0],v[1],v[2],v[3],v[4]); + return Variant(); +} + +Variant UndoRedo::_add_undo_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { + + if (p_argcount<2) { + r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; + r_error.argument=0; + return Variant(); + } + + if (p_args[0]->get_type()!=Variant::OBJECT) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=0; + r_error.expected=Variant::OBJECT; + return Variant(); + } + + if (p_args[1]->get_type()!=Variant::STRING) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=1; + r_error.expected=Variant::STRING; + return Variant(); + } + + r_error.error=Variant::CallError::CALL_OK; + + Object* object = *p_args[0]; + String method = *p_args[1]; + + Variant v[VARIANT_ARG_MAX]; + + + for(int i=0;i<MIN(VARIANT_ARG_MAX,p_argcount-2);++i) { + + v[i]=*p_args[i+2]; + } + + add_undo_method(object,method,v[0],v[1],v[2],v[3],v[4]); + return Variant(); +} + +void UndoRedo::_bind_methods() { + + ObjectTypeDB::bind_method(_MD("create_action","name","mergeable"),&UndoRedo::create_action, DEFVAL(false) ); + ObjectTypeDB::bind_method(_MD("commit_action"),&UndoRedo::commit_action); + + //ObjectTypeDB::bind_method(_MD("add_do_method","p_object", "p_method", "VARIANT_ARG_LIST"),&UndoRedo::add_do_method); + //ObjectTypeDB::bind_method(_MD("add_undo_method","p_object", "p_method", "VARIANT_ARG_LIST"),&UndoRedo::add_undo_method); + + { + MethodInfo mi; + mi.name="add_do_method"; + mi.arguments.push_back( PropertyInfo( Variant::OBJECT, "object")); + mi.arguments.push_back( PropertyInfo( Variant::STRING, "method")); + Vector<Variant> defargs; + for(int i=0;i<VARIANT_ARG_MAX;++i) { + mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i))); + defargs.push_back(Variant()); + } + + ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"add_do_method",&UndoRedo::_add_do_method,mi,defargs); + } + + { + MethodInfo mi; + mi.name="add_undo_method"; + mi.arguments.push_back( PropertyInfo( Variant::OBJECT, "object")); + mi.arguments.push_back( PropertyInfo( Variant::STRING, "method")); + Vector<Variant> defargs; + for(int i=0;i<VARIANT_ARG_MAX;++i) { + mi.arguments.push_back( PropertyInfo( Variant::NIL, "arg"+itos(i))); + defargs.push_back(Variant()); + } + + ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"add_undo_method",&UndoRedo::_add_undo_method,mi,defargs); + } + + ObjectTypeDB::bind_method(_MD("add_do_property","object", "property", "value:var"),&UndoRedo::add_do_property); + ObjectTypeDB::bind_method(_MD("add_undo_property","object", "property", "value:var"),&UndoRedo::add_undo_property); + ObjectTypeDB::bind_method(_MD("add_do_reference","object"),&UndoRedo::add_do_reference); + ObjectTypeDB::bind_method(_MD("add_undo_reference","object"),&UndoRedo::add_undo_reference); + ObjectTypeDB::bind_method(_MD("clear_history"),&UndoRedo::clear_history); + ObjectTypeDB::bind_method(_MD("get_current_action_name"),&UndoRedo::get_current_action_name); + ObjectTypeDB::bind_method(_MD("get_version"),&UndoRedo::get_version); +} diff --git a/core/undo_redo.h b/core/undo_redo.h index d1b2d3de9e..a9187534c1 100644 --- a/core/undo_redo.h +++ b/core/undo_redo.h @@ -38,9 +38,12 @@ class UndoRedo : public Object { OBJ_TYPE(UndoRedo,Object); + OBJ_SAVE_TYPE( UndoRedo ); public: typedef void (*CommitNotifyCallback)(void *p_ud,const String& p_name); + Variant _add_do_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error); + Variant _add_undo_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error); private: struct Operation { @@ -81,6 +84,10 @@ private: CommitNotifyCallback callback; void* callback_ud; + +protected: + static void _bind_methods(); + public: void create_action(const String& p_name="",bool p_mergeable=false); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 2f7e0205dc..4cca3420a1 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -715,6 +715,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_PTR0R( InputEvent, is_pressed ); VCALL_PTR1R( InputEvent, is_action ); + VCALL_PTR1R( InputEvent, is_action_pressed ); + VCALL_PTR1R( InputEvent, is_action_released ); VCALL_PTR0R( InputEvent, is_echo ); VCALL_PTR2( InputEvent, set_as_action ); @@ -750,6 +752,12 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var r_ret=Rect2(*p_args[0],*p_args[1],*p_args[2],*p_args[3]); } + static void Matrix32_init2(Variant& r_ret,const Variant** p_args) { + + Matrix32 m(*p_args[0], *p_args[1]); + r_ret=m; + } + static void Matrix32_init3(Variant& r_ret,const Variant** p_args) { Matrix32 m; @@ -1534,6 +1542,8 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_pressed,varray()); ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action,STRING,"action",varray()); + ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_pressed,STRING,"is_action_pressed",varray()); + ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action_released,STRING,"is_action_released",varray()); ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_echo,varray()); ADDFUNC2(INPUT_EVENT,NIL,InputEvent,set_as_action,STRING,"action",BOOL,"pressed",varray()); @@ -1544,6 +1554,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl _VariantCall::add_constructor(_VariantCall::Rect2_init1,Variant::RECT2,"pos",Variant::VECTOR2,"size",Variant::VECTOR2); _VariantCall::add_constructor(_VariantCall::Rect2_init2,Variant::RECT2,"x",Variant::REAL,"y",Variant::REAL,"width",Variant::REAL,"height",Variant::REAL); + _VariantCall::add_constructor(_VariantCall::Matrix32_init2,Variant::MATRIX32,"rot",Variant::REAL,"pos",Variant::VECTOR2); _VariantCall::add_constructor(_VariantCall::Matrix32_init3,Variant::MATRIX32,"x_axis",Variant::VECTOR2,"y_axis",Variant::VECTOR2,"origin",Variant::VECTOR2); _VariantCall::add_constructor(_VariantCall::Vector3_init1,Variant::VECTOR3,"x",Variant::REAL,"y",Variant::REAL,"z",Variant::REAL); |