diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 16 | ||||
-rw-r--r-- | core/bind/core_bind.h | 4 | ||||
-rw-r--r-- | core/class_db.cpp | 22 | ||||
-rw-r--r-- | core/class_db.h | 1 | ||||
-rw-r--r-- | core/func_ref.cpp | 2 | ||||
-rw-r--r-- | core/global_constants.cpp | 2 | ||||
-rw-r--r-- | core/input_map.cpp | 4 | ||||
-rw-r--r-- | core/message_queue.cpp | 6 | ||||
-rw-r--r-- | core/object.cpp | 37 | ||||
-rw-r--r-- | core/object.h | 7 | ||||
-rw-r--r-- | core/os/keyboard.cpp | 4 | ||||
-rw-r--r-- | core/os/keyboard.h | 4 | ||||
-rw-r--r-- | core/os/os.cpp | 6 | ||||
-rw-r--r-- | core/os/os.h | 4 | ||||
-rw-r--r-- | core/os/thread.cpp | 8 | ||||
-rw-r--r-- | core/os/thread.h | 8 | ||||
-rw-r--r-- | core/os/thread_dummy.h | 2 | ||||
-rw-r--r-- | core/project_settings.cpp | 4 | ||||
-rw-r--r-- | core/reference.cpp | 4 | ||||
-rw-r--r-- | core/resource.cpp | 5 | ||||
-rw-r--r-- | core/script_debugger_remote.cpp | 6 | ||||
-rw-r--r-- | core/script_language.cpp | 33 | ||||
-rw-r--r-- | core/undo_redo.cpp | 12 | ||||
-rw-r--r-- | core/variant.cpp | 2 | ||||
-rw-r--r-- | core/variant.h | 2 |
25 files changed, 135 insertions, 70 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index ce08b3f754..3e289eeaf3 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -180,8 +180,8 @@ int _OS::get_mouse_button_state() const { return OS::get_singleton()->get_mouse_button_state(); } -String _OS::get_unique_ID() const { - return OS::get_singleton()->get_unique_ID(); +String _OS::get_unique_id() const { + return OS::get_singleton()->get_unique_id(); } bool _OS::has_touchscreen_ui_hint() const { @@ -369,9 +369,9 @@ Error _OS::kill(int p_pid) { return OS::get_singleton()->kill(p_pid); } -int _OS::get_process_ID() const { +int _OS::get_process_id() const { - return OS::get_singleton()->get_process_ID(); + return OS::get_singleton()->get_process_id(); }; bool _OS::has_environment(const String &p_var) const { @@ -800,7 +800,7 @@ void _OS::print_all_textures_by_size() { img.fmt = fmt; img.path = E->get()->get_path(); img.vram = Image::get_image_data_size(img.size.width, img.size.height, Image::Format(img.fmt)); - img.id = E->get()->get_instance_ID(); + img.id = E->get()->get_instance_id(); total += img.vram; imgs.push_back(img); } @@ -1019,7 +1019,7 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("execute", "path", "arguments", "blocking", "output"), &_OS::execute, DEFVAL(Array())); ClassDB::bind_method(D_METHOD("kill", "pid"), &_OS::kill); ClassDB::bind_method(D_METHOD("shell_open", "uri"), &_OS::shell_open); - ClassDB::bind_method(D_METHOD("get_process_ID"), &_OS::get_process_ID); + ClassDB::bind_method(D_METHOD("get_process_id"), &_OS::get_process_id); ClassDB::bind_method(D_METHOD("get_environment", "environment"), &_OS::get_environment); ClassDB::bind_method(D_METHOD("has_environment", "environment"), &_OS::has_environment); @@ -1074,7 +1074,7 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_data_dir"), &_OS::get_data_dir); ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir); - ClassDB::bind_method(D_METHOD("get_unique_ID"), &_OS::get_unique_ID); + ClassDB::bind_method(D_METHOD("get_unique_id"), &_OS::get_unique_id); ClassDB::bind_method(D_METHOD("is_ok_left_and_cancel_right"), &_OS::is_ok_left_and_cancel_right); @@ -2256,7 +2256,7 @@ String _Thread::get_id() const { if (!thread) return String(); - return itos(thread->get_ID()); + return itos(thread->get_id()); } bool _Thread::is_active() const { diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index ec4fd3f476..e18d663d85 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -175,7 +175,7 @@ public: Error kill(int p_pid); Error shell_open(String p_uri); - int get_process_ID() const; + int get_process_id() const; bool has_environment(const String &p_var) const; String get_environment(const String &p_var) const; @@ -204,7 +204,7 @@ public: bool is_debug_build() const; - String get_unique_ID() const; + String get_unique_id() const; String get_scancode_string(uint32_t p_code) const; bool is_scancode_unicode(uint32_t p_unicode) const; diff --git a/core/class_db.cpp b/core/class_db.cpp index 6b8c290a99..24d71f86b0 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -937,6 +937,28 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia return false; } +int ClassDB::get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid) { + + ClassInfo *type = classes.getptr(p_class); + ClassInfo *check = type; + while (check) { + const PropertySetGet *psg = check->property_setget.getptr(p_property); + if (psg) { + + if (r_is_valid) + *r_is_valid = true; + + return psg->index; + } + + check = check->inherits_ptr; + } + if (r_is_valid) + *r_is_valid = false; + + return -1; +} + Variant::Type ClassDB::get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid) { ClassInfo *type = classes.getptr(p_class); diff --git a/core/class_db.h b/core/class_db.h index 4f00a16e91..02eac0dbbc 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -480,6 +480,7 @@ public: static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = NULL); static bool get_property(Object *p_object, const StringName &p_property, Variant &r_value); static bool has_property(const StringName &p_class, const StringName &p_property, bool p_no_inheritance = false); + static int get_property_index(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL); static Variant::Type get_property_type(const StringName &p_class, const StringName &p_property, bool *r_is_valid = NULL); static StringName get_property_setter(StringName p_class, const StringName p_property); static StringName get_property_getter(StringName p_class, const StringName p_property); diff --git a/core/func_ref.cpp b/core/func_ref.cpp index 1121c6d3e4..2d74efd822 100644 --- a/core/func_ref.cpp +++ b/core/func_ref.cpp @@ -48,7 +48,7 @@ Variant FuncRef::call_func(const Variant **p_args, int p_argcount, Variant::Call void FuncRef::set_instance(Object *p_obj) { ERR_FAIL_NULL(p_obj); - id = p_obj->get_instance_ID(); + id = p_obj->get_instance_id(); } void FuncRef::set_function(const StringName &p_func) { diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 18071d7748..9e745ecb98 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -67,8 +67,8 @@ static _GlobalConstant _global_constants[] = { BIND_GLOBAL_CONSTANT(KEY_TAB), BIND_GLOBAL_CONSTANT(KEY_BACKTAB), BIND_GLOBAL_CONSTANT(KEY_BACKSPACE), - BIND_GLOBAL_CONSTANT(KEY_RETURN), BIND_GLOBAL_CONSTANT(KEY_ENTER), + BIND_GLOBAL_CONSTANT(KEY_KP_ENTER), BIND_GLOBAL_CONSTANT(KEY_INSERT), BIND_GLOBAL_CONSTANT(KEY_DELETE), BIND_GLOBAL_CONSTANT(KEY_PAUSE), diff --git a/core/input_map.cpp b/core/input_map.cpp index 24d0624e98..85e627f352 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -219,11 +219,11 @@ void InputMap::load_default() { add_action("ui_accept"); key.instance(); - key->set_scancode(KEY_RETURN); + key->set_scancode(KEY_ENTER); action_add_event("ui_accept", key); key.instance(); - key->set_scancode(KEY_ENTER); + key->set_scancode(KEY_KP_ENTER); action_add_event("ui_accept", key); key.instance(); diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 93d0b0730a..564069d8bb 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -153,16 +153,16 @@ Error MessageQueue::push_notification(ObjectID p_id, int p_notification) { Error MessageQueue::push_call(Object *p_object, const StringName &p_method, VARIANT_ARG_DECLARE) { - return push_call(p_object->get_instance_ID(), p_method, VARIANT_ARG_PASS); + return push_call(p_object->get_instance_id(), p_method, VARIANT_ARG_PASS); } Error MessageQueue::push_notification(Object *p_object, int p_notification) { - return push_notification(p_object->get_instance_ID(), p_notification); + return push_notification(p_object->get_instance_id(), p_notification); } Error MessageQueue::push_set(Object *p_object, const StringName &p_prop, const Variant &p_value) { - return push_set(p_object->get_instance_ID(), p_prop, p_value); + return push_set(p_object->get_instance_id(), p_prop, p_value); } void MessageQueue::statistics() { diff --git a/core/object.cpp b/core/object.cpp index 316c624268..de75257ede 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -599,7 +599,7 @@ Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Vari StringName method = *p_args[0]; - MessageQueue::get_singleton()->push_call(get_instance_ID(), method, &p_args[1], p_argcount - 1); + MessageQueue::get_singleton()->push_call(get_instance_id(), method, &p_args[1], p_argcount - 1); return Variant(); } @@ -1182,10 +1182,10 @@ Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Variant::Ca return Variant(); } -void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount) { +Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount) { if (_block_signals) - return; //no emit, signals blocked + return ERR_CANT_AQUIRE_RESOURCE; //no emit, signals blocked Signal *s = signal_map.getptr(p_name); if (!s) { @@ -1194,11 +1194,11 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p //check in script if (!signal_is_valid && !script.is_null() && !Ref<Script>(script)->has_script_signal(p_name)) { ERR_EXPLAIN("Can't emit non-existing signal " + String("\"") + p_name + "\"."); - ERR_FAIL(); + ERR_FAIL_V(ERR_UNAVAILABLE); } #endif //not connected? just return - return; + return ERR_UNAVAILABLE; } List<_ObjectSignalDisconnectData> disconnect_data; @@ -1214,6 +1214,8 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p Vector<const Variant *> bind_mem; + Error err = OK; + for (int i = 0; i < ssize; i++) { const Connection &c = slot_map.getv(i).conn; @@ -1245,16 +1247,18 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p } if (c.flags & CONNECT_DEFERRED) { - MessageQueue::get_singleton()->push_call(target->get_instance_ID(), c.method, args, argc, true); + MessageQueue::get_singleton()->push_call(target->get_instance_id(), c.method, args, argc, true); } else { Variant::CallError ce; target->call(c.method, args, argc, ce); + if (ce.error != Variant::CallError::CALL_OK) { if (ce.error == Variant::CallError::CALL_ERROR_INVALID_METHOD && !ClassDB::class_exists(target->get_class_name())) { //most likely object is not initialized yet, do not throw error. } else { ERR_PRINTS("Error calling method from signal '" + String(p_name) + "': " + Variant::get_call_error_text(target, c.method, args, argc, ce)); + err = ERR_METHOD_NOT_FOUND; } } } @@ -1274,21 +1278,24 @@ void Object::emit_signal(const StringName &p_name, const Variant **p_args, int p disconnect(dd.signal, dd.target, dd.method); disconnect_data.pop_front(); } + + return err; } -void Object::emit_signal(const StringName &p_name, VARIANT_ARG_DECLARE) { +Error Object::emit_signal(const StringName &p_name, VARIANT_ARG_DECLARE) { VARIANT_ARGPTRS; int argc = 0; for (int i = 0; i < VARIANT_ARG_MAX; i++) { + if (argptr[i]->get_type() == Variant::NIL) break; argc++; } - emit_signal(p_name, argptr, argc); + return emit_signal(p_name, argptr, argc); } void Object::_add_user_signal(const String &p_name, const Array &p_args) { @@ -1471,7 +1478,7 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str s = &signal_map[p_signal]; } - Signal::Target target(p_to_object->get_instance_ID(), p_to_method); + Signal::Target target(p_to_object->get_instance_id(), p_to_method); if (s->slot_map.has(target)) { ERR_EXPLAIN("Signal '" + p_signal + "'' already connected to given method '" + p_to_method + "' in that object."); ERR_FAIL_COND_V(s->slot_map.has(target), ERR_INVALID_PARAMETER); @@ -1509,7 +1516,7 @@ bool Object::is_connected(const StringName &p_signal, Object *p_to_object, const ERR_FAIL_COND_V(!s, false); } - Signal::Target target(p_to_object->get_instance_ID(), p_to_method); + Signal::Target target(p_to_object->get_instance_id(), p_to_method); return s->slot_map.has(target); //const Map<Signal::Target,Signal::Slot>::Element *E = s->slot_map.find(target); @@ -1529,7 +1536,7 @@ void Object::disconnect(const StringName &p_signal, Object *p_to_object, const S ERR_FAIL_COND(s->lock > 0); } - Signal::Target target(p_to_object->get_instance_ID(), p_to_method); + Signal::Target target(p_to_object->get_instance_id(), p_to_method); if (!s->slot_map.has(target)) { ERR_EXPLAIN("Disconnecting nonexistent signal '" + p_signal + "', slot: " + itos(target._id) + ":" + target.method); @@ -1660,7 +1667,7 @@ void Object::_bind_methods() { 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)); - ClassDB::bind_method(D_METHOD("get_instance_ID"), &Object::get_instance_ID); + ClassDB::bind_method(D_METHOD("get_instance_id"), &Object::get_instance_id); ClassDB::bind_method(D_METHOD("set_script", "script:Script"), &Object::set_script); ClassDB::bind_method(D_METHOD("get_script:Script"), &Object::get_script); @@ -1929,7 +1936,7 @@ ObjectID ObjectDB::instance_counter = 1; HashMap<Object *, ObjectID, ObjectDB::ObjectPtrHash> ObjectDB::instance_checks; ObjectID ObjectDB::add_instance(Object *p_object) { - ERR_FAIL_COND_V(p_object->get_instance_ID() != 0, 0); + ERR_FAIL_COND_V(p_object->get_instance_id() != 0, 0); rw_lock->write_lock(); instances[++instance_counter] = p_object; @@ -1945,7 +1952,7 @@ void ObjectDB::remove_instance(Object *p_object) { rw_lock->write_lock(); - instances.erase(p_object->get_instance_ID()); + instances.erase(p_object->get_instance_id()); #ifdef DEBUG_ENABLED instance_checks.erase(p_object); #endif @@ -2008,7 +2015,7 @@ void ObjectDB::cleanup() { String node_name; if (instances[*K]->is_class("Node")) node_name = " - Node Name: " + String(instances[*K]->call("get_name")); - if (instances[*K]->is_class("Resoucre")) + if (instances[*K]->is_class("Resource")) node_name = " - Resource Name: " + String(instances[*K]->call("get_name")) + " Path: " + String(instances[*K]->call("get_path")); print_line("Leaked Instance: " + String(instances[*K]->get_class()) + ":" + itos(*K) + node_name); } diff --git a/core/object.h b/core/object.h index 148a73fbc4..f0147080b4 100644 --- a/core/object.h +++ b/core/object.h @@ -105,6 +105,7 @@ enum PropertyUsageFlags { PROPERTY_USAGE_STORE_IF_NULL = 16384, PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768, PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536, + PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE = 1 << 17, PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK, PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNATIONALIZED, @@ -533,7 +534,7 @@ public: bool _is_gpl_reversed() const { return false; } - _FORCE_INLINE_ ObjectID get_instance_ID() const { return _instance_ID; } + _FORCE_INLINE_ ObjectID get_instance_id() const { return _instance_ID; } // this is used for editors void add_change_receptor(Object *p_receptor); @@ -654,8 +655,8 @@ public: void set_script_and_instance(const RefPtr &p_script, ScriptInstance *p_instance); //some script languages can't control instance creation, so this function eases the process void add_user_signal(const MethodInfo &p_signal); - void emit_signal(const StringName &p_name, VARIANT_ARG_LIST); - void emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount); + Error emit_signal(const StringName &p_name, VARIANT_ARG_LIST); + Error emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount); void get_signal_list(List<MethodInfo> *p_signals) const; void get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const; void get_all_signal_connections(List<Connection> *p_connections) const; diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index e154b1934d..9b3e376ea6 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -42,8 +42,8 @@ static const _KeyCodeText _keycodes[] = { {KEY_TAB ,"Tab"}, {KEY_BACKTAB ,"BackTab"}, {KEY_BACKSPACE ,"BackSpace"}, - {KEY_RETURN ,"Return"}, {KEY_ENTER ,"Enter"}, + {KEY_KP_ENTER ,"Kp Enter"}, {KEY_INSERT ,"Insert"}, {KEY_DELETE ,"Delete"}, {KEY_PAUSE ,"Pause"}, @@ -294,8 +294,8 @@ bool keycode_has_unicode(uint32_t p_keycode) { case KEY_TAB: case KEY_BACKTAB: case KEY_BACKSPACE: - case KEY_RETURN: case KEY_ENTER: + case KEY_KP_ENTER: case KEY_INSERT: case KEY_DELETE: case KEY_PAUSE: diff --git a/core/os/keyboard.h b/core/os/keyboard.h index c6985c887d..1ed93e3540 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -57,8 +57,8 @@ enum KeyList { KEY_TAB = SPKEY | 0x02, KEY_BACKTAB = SPKEY | 0x03, KEY_BACKSPACE = SPKEY | 0x04, - KEY_RETURN = SPKEY | 0x05, - KEY_ENTER = SPKEY | 0x06, + KEY_ENTER = SPKEY | 0x05, + KEY_KP_ENTER = SPKEY | 0x06, KEY_INSERT = SPKEY | 0x07, KEY_DELETE = SPKEY | 0x08, KEY_PAUSE = SPKEY | 0x09, diff --git a/core/os/os.cpp b/core/os/os.cpp index 8e4c357195..3a06a3fa8f 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -129,7 +129,7 @@ String OS::get_executable_path() const { return _execpath; } -int OS::get_process_ID() const { +int OS::get_process_id() const { return -1; }; @@ -175,7 +175,7 @@ static void _OS_printres(Object *p_obj) { if (!res) return; - String str = itos(res->get_instance_ID()) + String(res->get_class()) + ":" + String(res->get_name()) + " - " + res->get_path(); + String str = itos(res->get_instance_id()) + String(res->get_class()) + ":" + String(res->get_name()) + " - " + res->get_path(); if (_OSPRF) _OSPRF->store_line(str); else @@ -412,7 +412,7 @@ void OS::make_rendering_thread() { void OS::swap_buffers() { } -String OS::get_unique_ID() const { +String OS::get_unique_id() const { ERR_FAIL_V(""); } diff --git a/core/os/os.h b/core/os/os.h index 703c6a6bcd..8e2257a0e4 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -197,7 +197,7 @@ public: virtual String get_executable_path() const; virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL) = 0; virtual Error kill(const ProcessID &p_pid) = 0; - virtual int get_process_ID() const; + virtual int get_process_id() const; virtual Error shell_open(String p_uri); virtual Error set_cwd(const String &p_cwd); @@ -370,7 +370,7 @@ public: virtual int get_processor_count() const; - virtual String get_unique_ID() const; + virtual String get_unique_id() const; virtual Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); virtual bool native_video_is_playing() const; diff --git a/core/os/thread.cpp b/core/os/thread.cpp index 98f1968629..bd565334c3 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -30,16 +30,16 @@ #include "thread.h" Thread *(*Thread::create_func)(ThreadCreateCallback, void *, const Settings &) = NULL; -Thread::ID (*Thread::get_thread_ID_func)() = NULL; +Thread::ID (*Thread::get_thread_id_func)() = NULL; void (*Thread::wait_to_finish_func)(Thread *) = NULL; Error (*Thread::set_name_func)(const String &) = NULL; Thread::ID Thread::_main_thread_id = 0; -Thread::ID Thread::get_caller_ID() { +Thread::ID Thread::get_caller_id() { - if (get_thread_ID_func) - return get_thread_ID_func(); + if (get_thread_id_func) + return get_thread_id_func(); return 0; } diff --git a/core/os/thread.h b/core/os/thread.h index 3ad5d4bf2c..1103f67ff2 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -58,7 +58,7 @@ public: protected: static Thread *(*create_func)(ThreadCreateCallback p_callback, void *, const Settings &); - static ID (*get_thread_ID_func)(); + static ID (*get_thread_id_func)(); static void (*wait_to_finish_func)(Thread *); static Error (*set_name_func)(const String &); @@ -69,11 +69,11 @@ protected: Thread(); public: - virtual ID get_ID() const = 0; + virtual ID get_id() const = 0; static Error set_name(const String &p_name); - _FORCE_INLINE_ static ID get_main_ID() { return _main_thread_id; } ///< get the ID of the main thread - static ID get_caller_ID(); ///< get the ID of the caller function ID + _FORCE_INLINE_ static ID get_main_id() { return _main_thread_id; } ///< get the ID of the main thread + static ID get_caller_id(); ///< get the ID of the caller function ID static void wait_to_finish(Thread *p_thread); ///< waits until thread is finished, and deallocates it. static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings()); ///< Static function to create a thread, will call p_callback diff --git a/core/os/thread_dummy.h b/core/os/thread_dummy.h index 4155103bbf..64941a71f8 100644 --- a/core/os/thread_dummy.h +++ b/core/os/thread_dummy.h @@ -39,7 +39,7 @@ class ThreadDummy : public Thread { static Thread *create(ThreadCreateCallback p_callback, void *p_user, const Settings &p_settings = Settings()); public: - virtual ID get_ID() const { return 0; }; + virtual ID get_id() const { return 0; }; static void make_default(); }; diff --git a/core/project_settings.cpp b/core/project_settings.cpp index b31f78ec20..f6e0d2e991 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -925,10 +925,10 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("application/config/use_shared_user_dir", true); key.instance(); - key->set_scancode(KEY_RETURN); + key->set_scancode(KEY_ENTER); va.push_back(key); key.instance(); - key->set_scancode(KEY_ENTER); + key->set_scancode(KEY_KP_ENTER); va.push_back(key); key.instance(); key->set_scancode(KEY_SPACE); diff --git a/core/reference.cpp b/core/reference.cpp index 060608eacb..066dc8059e 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -108,12 +108,12 @@ Variant WeakRef::get_ref() const { } void WeakRef::set_obj(Object *p_object) { - ref = p_object ? p_object->get_instance_ID() : 0; + ref = p_object ? p_object->get_instance_id() : 0; } void WeakRef::set_ref(const REF &p_ref) { - ref = p_ref.is_valid() ? p_ref->get_instance_ID() : 0; + ref = p_ref.is_valid() ? p_ref->get_instance_id() : 0; } WeakRef::WeakRef() { diff --git a/core/resource.cpp b/core/resource.cpp index 5625784396..9bce343cba 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -32,6 +32,7 @@ #include "core_string_names.h" #include "io/resource_loader.h" #include "os/file_access.h" +#include "scene/main/node.h" //only so casting works #include "script_language.h" #include <stdio.h> @@ -227,12 +228,12 @@ RID Resource::get_rid() const { void Resource::register_owner(Object *p_owner) { - owners.insert(p_owner->get_instance_ID()); + owners.insert(p_owner->get_instance_id()); } void Resource::unregister_owner(Object *p_owner) { - owners.erase(p_owner->get_instance_ID()); + owners.erase(p_owner->get_instance_id()); } void Resource::notify_change_to_owners() { diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index d19fe213f6..fdde08bb32 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -95,7 +95,7 @@ static Object *_ScriptDebuggerRemote_find = NULL; static void _ScriptDebuggerRemote_debug_func(Object *p_obj) { if (_ScriptDebuggerRemote_find == p_obj) { - _ScriptDebuggerRemote_found_id = p_obj->get_instance_ID(); + _ScriptDebuggerRemote_found_id = p_obj->get_instance_id(); } } @@ -109,7 +109,7 @@ static ObjectID safe_get_instance_id(const Variant &p_v) { REF r = p_v; if (r.is_valid()) { - return r->get_instance_ID(); + return r->get_instance_id(); } else { _ScriptDebuggerRemote_found_id = 0; @@ -572,7 +572,7 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) { ObjectID id2; Object *obj = var; if (obj) { - id2 = obj->get_instance_ID(); + id2 = obj->get_instance_id(); } else { id2 = 0; } diff --git a/core/script_language.cpp b/core/script_language.cpp index aeb1573840..bb99e0abae 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -280,8 +280,23 @@ ScriptDebugger::ScriptDebugger() { bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_value) { if (values.has(p_name)) { + Variant defval; + if (script->get_property_default_value(p_name, defval)) { + if (defval == p_value) { + values.erase(p_name); + return true; + } + } values[p_name] = p_value; return true; + } else { + Variant defval; + if (script->get_property_default_value(p_name, defval)) { + if (defval != p_value) { + values[p_name] = p_value; + } + return true; + } } return false; } @@ -291,12 +306,22 @@ bool PlaceHolderScriptInstance::get(const StringName &p_name, Variant &r_ret) co r_ret = values[p_name]; return true; } + + Variant defval; + if (script->get_property_default_value(p_name, defval)) { + r_ret = defval; + return true; + } return false; } void PlaceHolderScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + PropertyInfo pinfo = E->get(); + if (!values.has(pinfo.name)) { + pinfo.usage |= PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE; + } p_properties->push_back(E->get()); } } @@ -336,6 +361,14 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c if (!new_values.has(E->key())) to_remove.push_back(E->key()); + + Variant defval; + if (script->get_property_default_value(E->key(), defval)) { + //remove because it's the same as the default value + if (defval == E->get()) { + to_remove.push_back(E->key()); + } + } } while (to_remove.size()) { diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index b3ac9d274e..637fcd91d4 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -110,7 +110,7 @@ void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_A ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; - do_op.object = p_object->get_instance_ID(); + do_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); @@ -134,7 +134,7 @@ void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT return; Operation undo_op; - undo_op.object = p_object->get_instance_ID(); + undo_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); @@ -151,7 +151,7 @@ void UndoRedo::add_do_property(Object *p_object, const String &p_property, const ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; - do_op.object = p_object->get_instance_ID(); + do_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); @@ -170,7 +170,7 @@ void UndoRedo::add_undo_property(Object *p_object, const String &p_property, con return; Operation undo_op; - undo_op.object = p_object->get_instance_ID(); + undo_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); @@ -184,7 +184,7 @@ void UndoRedo::add_do_reference(Object *p_object) { ERR_FAIL_COND(action_level <= 0); ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; - do_op.object = p_object->get_instance_ID(); + do_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); @@ -201,7 +201,7 @@ void UndoRedo::add_undo_reference(Object *p_object) { return; Operation undo_op; - undo_op.object = p_object->get_instance_ID(); + undo_op.object = p_object->get_instance_id(); if (p_object->cast_to<Resource>()) undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); diff --git a/core/variant.cpp b/core/variant.cpp index 0807a33788..51c4b70bdc 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1600,7 +1600,7 @@ Variant::operator String() const { }; }; #endif - return "[" + _get_obj().obj->get_class() + ":" + itos(_get_obj().obj->get_instance_ID()) + "]"; + return "[" + _get_obj().obj->get_class() + ":" + itos(_get_obj().obj->get_instance_id()) + "]"; } else return "[Object:null]"; diff --git a/core/variant.h b/core/variant.h index 583a0d09a0..95782d9619 100644 --- a/core/variant.h +++ b/core/variant.h @@ -42,8 +42,8 @@ #include "io/ip_address.h" #include "math_2d.h" #include "matrix3.h" -#include "os/power.h" #include "node_path.h" +#include "os/power.h" #include "plane.h" #include "quat.h" #include "rect3.h" |