diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/project_settings.cpp | 15 | ||||
-rw-r--r-- | core/project_settings.h | 2 | ||||
-rw-r--r-- | core/undo_redo.cpp | 19 | ||||
-rw-r--r-- | core/vector.h | 56 |
4 files changed, 57 insertions, 35 deletions
diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 407bb78375..031ac06063 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -307,7 +307,7 @@ void ProjectSettings::_convert_to_last_version() { * If a project file is found, load it or fail. * If nothing was found, error out. */ -Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bool p_upwards) { +Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, bool p_upwards) { // If looking for files in a network client, use it directly @@ -450,6 +450,18 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bo return OK; } +Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bool p_upwards) { + Error err = _setup(p_path, p_main_pack, p_upwards); + if (err == OK) { + String custom_settings = GLOBAL_DEF("application/config/project_settings_override", ""); + if (custom_settings != "") { + _load_settings_text(custom_settings); + } + } + + return err; +} + bool ProjectSettings::has_setting(String p_var) const { _THREAD_SAFE_METHOD_ @@ -995,6 +1007,7 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("application/run/disable_stderr", false); GLOBAL_DEF("application/config/use_custom_user_dir", false); GLOBAL_DEF("application/config/custom_user_dir_name", ""); + GLOBAL_DEF("application/config/project_settings_override", ""); action = Dictionary(); action["deadzone"] = Variant(0.5f); diff --git a/core/project_settings.h b/core/project_settings.h index 611355f2ef..f150e4499b 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -112,6 +112,8 @@ protected: void _add_property_info_bind(const Dictionary &p_info); + Error _setup(const String &p_path, const String &p_main_pack, bool p_upwards = false); + protected: static void _bind_methods(); diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 3d41c374ea..f2f521c196 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -268,7 +268,24 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) { case Operation::TYPE_METHOD: { - obj->call(op.name, VARIANT_ARGS_FROM_ARRAY(op.args)); + Vector<const Variant *> argptrs; + argptrs.resize(VARIANT_ARG_MAX); + int argc = 0; + + for (int i = 0; i < VARIANT_ARG_MAX; i++) { + if (op.args[i].get_type() == Variant::NIL) { + break; + } + argptrs.write[i] = &op.args[i]; + argc++; + } + argptrs.resize(argc); + + Variant::CallError ce; + obj->call(op.name, (const Variant **)argptrs.ptr(), argc, ce); + if (ce.error != Variant::CallError::CALL_OK) { + ERR_PRINTS("Error calling method from signal '" + String(op.name) + "': " + Variant::get_call_error_text(obj, op.name, (const Variant **)argptrs.ptr(), argc, ce)); + } #ifdef TOOLS_ENABLED Resource *res = Object::cast_to<Resource>(obj); if (res) diff --git a/core/vector.h b/core/vector.h index 38a1082407..2fb6f6c1c4 100644 --- a/core/vector.h +++ b/core/vector.h @@ -44,17 +44,11 @@ template <class T> class VectorWriteProxy { - friend class Vector<T>; - CowData<T> *_parent; - - _FORCE_INLINE_ VectorWriteProxy(CowData<T> *parent) : - _parent(parent){}; - public: _FORCE_INLINE_ T &operator[](int p_index) { - CRASH_BAD_INDEX(p_index, _parent->size()); + CRASH_BAD_INDEX(p_index, ((Vector<T> *)(this))->_cowdata.size()); - return _parent->ptrw()[p_index]; + return ((Vector<T> *)(this))->_cowdata.ptrw()[p_index]; } }; @@ -62,39 +56,41 @@ template <class T> class Vector { friend class VectorWriteProxy<T>; - CowData<T> *_cowdata; - public: VectorWriteProxy<T> write; +private: + CowData<T> _cowdata; + +public: bool push_back(const T &p_elem); - void remove(int p_index) { _cowdata->remove(p_index); } + void remove(int p_index) { _cowdata.remove(p_index); } void erase(const T &p_val) { int idx = find(p_val); if (idx >= 0) remove(idx); }; void invert(); - _FORCE_INLINE_ T *ptrw() { return _cowdata->ptrw(); } - _FORCE_INLINE_ const T *ptr() const { return _cowdata->ptr(); } + _FORCE_INLINE_ T *ptrw() { return _cowdata.ptrw(); } + _FORCE_INLINE_ const T *ptr() const { return _cowdata.ptr(); } _FORCE_INLINE_ void clear() { resize(0); } - _FORCE_INLINE_ bool empty() const { return _cowdata->empty(); } + _FORCE_INLINE_ bool empty() const { return _cowdata.empty(); } - _FORCE_INLINE_ T get(int p_index) { return _cowdata->get(p_index); } - _FORCE_INLINE_ const T get(int p_index) const { return _cowdata->get(p_index); } - _FORCE_INLINE_ void set(int p_index, const T &p_elem) { _cowdata->set(p_index, p_elem); } - _FORCE_INLINE_ int size() const { return _cowdata->size(); } - Error resize(int p_size) { return _cowdata->resize(p_size); } - _FORCE_INLINE_ const T &operator[](int p_index) const { return _cowdata->get(p_index); } - Error insert(int p_pos, const T &p_val) { return _cowdata->insert(p_pos, p_val); } + _FORCE_INLINE_ T get(int p_index) { return _cowdata.get(p_index); } + _FORCE_INLINE_ const T get(int p_index) const { return _cowdata.get(p_index); } + _FORCE_INLINE_ void set(int p_index, const T &p_elem) { _cowdata.set(p_index, p_elem); } + _FORCE_INLINE_ int size() const { return _cowdata.size(); } + Error resize(int p_size) { return _cowdata.resize(p_size); } + _FORCE_INLINE_ const T &operator[](int p_index) const { return _cowdata.get(p_index); } + Error insert(int p_pos, const T &p_val) { return _cowdata.insert(p_pos, p_val); } void append_array(const Vector<T> &p_other); template <class C> void sort_custom() { - int len = _cowdata->size(); + int len = _cowdata.size(); if (len == 0) return; @@ -110,7 +106,7 @@ public: void ordered_insert(const T &p_val) { int i; - for (i = 0; i < _cowdata->size(); i++) { + for (i = 0; i < _cowdata.size(); i++) { if (p_val < operator[](i)) { break; @@ -135,20 +131,14 @@ public: return ret; } - _FORCE_INLINE_ Vector() : - _cowdata(new CowData<T>()), - write(VectorWriteProxy<T>(_cowdata)) {} - _FORCE_INLINE_ Vector(const Vector &p_from) : - _cowdata(new CowData<T>()), - write(VectorWriteProxy<T>(_cowdata)) { _cowdata->_ref(p_from._cowdata); } + _FORCE_INLINE_ Vector() {} + _FORCE_INLINE_ Vector(const Vector &p_from) { _cowdata._ref(p_from._cowdata); } inline Vector &operator=(const Vector &p_from) { - _cowdata->_ref(p_from._cowdata); + _cowdata._ref(p_from._cowdata); return *this; } - _FORCE_INLINE_ ~Vector() { - delete _cowdata; - } + _FORCE_INLINE_ ~Vector() {} }; template <class T> |