diff options
Diffstat (limited to 'core')
237 files changed, 1969 insertions, 2734 deletions
diff --git a/core/SCsub b/core/SCsub index 4c541d7269..c1e57f6840 100644 --- a/core/SCsub +++ b/core/SCsub @@ -18,7 +18,7 @@ gd_cpp = '#include "project_settings.h"\n' gd_cpp += gd_inc gd_cpp += "void ProjectSettings::register_global_defaults() {\n" + gd_call + "\n}\n" -f = open("global_defaults.gen.cpp", "wb") +f = open("global_defaults.gen.cpp", "w") f.write(gd_cpp) f.close() @@ -47,7 +47,7 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ): txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0" print("Invalid AES256 encryption key, not 64 bits hex: " + e) -f = open("script_encryption_key.gen.cpp", "wb") +f = open("script_encryption_key.gen.cpp", "w") f.write("#include \"project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n") f.close() diff --git a/core/allocators.h b/core/allocators.h index 3735a7746e..0b891b76a9 100644 --- a/core/allocators.h +++ b/core/allocators.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/array.cpp b/core/array.cpp index 21dab2ba90..c35bf5bf0c 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/array.h b/core/array.h index 589d52886f..777116ab56 100644 --- a/core/array.h +++ b/core/array.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 273ef78669..abe8b9b715 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -151,12 +151,12 @@ void _ResourceSaver::_bind_methods() { ClassDB::bind_method(D_METHOD("save", "path", "resource", "flags"), &_ResourceSaver::save, DEFVAL(0)); ClassDB::bind_method(D_METHOD("get_recognized_extensions", "type"), &_ResourceSaver::get_recognized_extensions); - BIND_CONSTANT(FLAG_RELATIVE_PATHS); - BIND_CONSTANT(FLAG_BUNDLE_RESOURCES); - BIND_CONSTANT(FLAG_CHANGE_PATH); - BIND_CONSTANT(FLAG_OMIT_EDITOR_PROPERTIES); - BIND_CONSTANT(FLAG_SAVE_BIG_ENDIAN); - BIND_CONSTANT(FLAG_COMPRESS); + BIND_ENUM_CONSTANT(FLAG_RELATIVE_PATHS); + BIND_ENUM_CONSTANT(FLAG_BUNDLE_RESOURCES); + BIND_ENUM_CONSTANT(FLAG_CHANGE_PATH); + BIND_ENUM_CONSTANT(FLAG_OMIT_EDITOR_PROPERTIES); + BIND_ENUM_CONSTANT(FLAG_SAVE_BIG_ENDIAN); + BIND_ENUM_CONSTANT(FLAG_COMPRESS); } _ResourceSaver::_ResourceSaver() { @@ -978,9 +978,9 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_screen_count"), &_OS::get_screen_count); ClassDB::bind_method(D_METHOD("get_current_screen"), &_OS::get_current_screen); ClassDB::bind_method(D_METHOD("set_current_screen", "screen"), &_OS::set_current_screen); - ClassDB::bind_method(D_METHOD("get_screen_position", "screen"), &_OS::get_screen_position, DEFVAL(0)); - ClassDB::bind_method(D_METHOD("get_screen_size", "screen"), &_OS::get_screen_size, DEFVAL(0)); - ClassDB::bind_method(D_METHOD("get_screen_dpi", "screen"), &_OS::get_screen_dpi, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("get_screen_position", "screen"), &_OS::get_screen_position, DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("get_screen_size", "screen"), &_OS::get_screen_size, DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("get_screen_dpi", "screen"), &_OS::get_screen_dpi, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("get_window_position"), &_OS::get_window_position); ClassDB::bind_method(D_METHOD("set_window_position", "position"), &_OS::set_window_position); ClassDB::bind_method(D_METHOD("get_window_size"), &_OS::get_window_size); @@ -1104,49 +1104,49 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_power_seconds_left"), &_OS::get_power_seconds_left); ClassDB::bind_method(D_METHOD("get_power_percent_left"), &_OS::get_power_percent_left); - BIND_CONSTANT(DAY_SUNDAY); - BIND_CONSTANT(DAY_MONDAY); - BIND_CONSTANT(DAY_TUESDAY); - BIND_CONSTANT(DAY_WEDNESDAY); - BIND_CONSTANT(DAY_THURSDAY); - BIND_CONSTANT(DAY_FRIDAY); - BIND_CONSTANT(DAY_SATURDAY); - - BIND_CONSTANT(MONTH_JANUARY); - BIND_CONSTANT(MONTH_FEBRUARY); - BIND_CONSTANT(MONTH_MARCH); - BIND_CONSTANT(MONTH_APRIL); - BIND_CONSTANT(MONTH_MAY); - BIND_CONSTANT(MONTH_JUNE); - BIND_CONSTANT(MONTH_JULY); - BIND_CONSTANT(MONTH_AUGUST); - BIND_CONSTANT(MONTH_SEPTEMBER); - BIND_CONSTANT(MONTH_OCTOBER); - BIND_CONSTANT(MONTH_NOVEMBER); - BIND_CONSTANT(MONTH_DECEMBER); - - BIND_CONSTANT(SCREEN_ORIENTATION_LANDSCAPE); - BIND_CONSTANT(SCREEN_ORIENTATION_PORTRAIT); - BIND_CONSTANT(SCREEN_ORIENTATION_REVERSE_LANDSCAPE); - BIND_CONSTANT(SCREEN_ORIENTATION_REVERSE_PORTRAIT); - BIND_CONSTANT(SCREEN_ORIENTATION_SENSOR_LANDSCAPE); - BIND_CONSTANT(SCREEN_ORIENTATION_SENSOR_PORTRAIT); - BIND_CONSTANT(SCREEN_ORIENTATION_SENSOR); - - BIND_CONSTANT(SYSTEM_DIR_DESKTOP); - BIND_CONSTANT(SYSTEM_DIR_DCIM); - BIND_CONSTANT(SYSTEM_DIR_DOCUMENTS); - BIND_CONSTANT(SYSTEM_DIR_DOWNLOADS); - BIND_CONSTANT(SYSTEM_DIR_MOVIES); - BIND_CONSTANT(SYSTEM_DIR_MUSIC); - BIND_CONSTANT(SYSTEM_DIR_PICTURES); - BIND_CONSTANT(SYSTEM_DIR_RINGTONES); - - BIND_CONSTANT(POWERSTATE_UNKNOWN); - BIND_CONSTANT(POWERSTATE_ON_BATTERY); - BIND_CONSTANT(POWERSTATE_NO_BATTERY); - BIND_CONSTANT(POWERSTATE_CHARGING); - BIND_CONSTANT(POWERSTATE_CHARGED); + BIND_ENUM_CONSTANT(DAY_SUNDAY); + BIND_ENUM_CONSTANT(DAY_MONDAY); + BIND_ENUM_CONSTANT(DAY_TUESDAY); + BIND_ENUM_CONSTANT(DAY_WEDNESDAY); + BIND_ENUM_CONSTANT(DAY_THURSDAY); + BIND_ENUM_CONSTANT(DAY_FRIDAY); + BIND_ENUM_CONSTANT(DAY_SATURDAY); + + BIND_ENUM_CONSTANT(MONTH_JANUARY); + BIND_ENUM_CONSTANT(MONTH_FEBRUARY); + BIND_ENUM_CONSTANT(MONTH_MARCH); + BIND_ENUM_CONSTANT(MONTH_APRIL); + BIND_ENUM_CONSTANT(MONTH_MAY); + BIND_ENUM_CONSTANT(MONTH_JUNE); + BIND_ENUM_CONSTANT(MONTH_JULY); + BIND_ENUM_CONSTANT(MONTH_AUGUST); + BIND_ENUM_CONSTANT(MONTH_SEPTEMBER); + BIND_ENUM_CONSTANT(MONTH_OCTOBER); + BIND_ENUM_CONSTANT(MONTH_NOVEMBER); + BIND_ENUM_CONSTANT(MONTH_DECEMBER); + + BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_LANDSCAPE); + BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_PORTRAIT); + BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_REVERSE_LANDSCAPE); + BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_REVERSE_PORTRAIT); + BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_SENSOR_LANDSCAPE); + BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_SENSOR_PORTRAIT); + BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_SENSOR); + + BIND_ENUM_CONSTANT(SYSTEM_DIR_DESKTOP); + BIND_ENUM_CONSTANT(SYSTEM_DIR_DCIM); + BIND_ENUM_CONSTANT(SYSTEM_DIR_DOCUMENTS); + BIND_ENUM_CONSTANT(SYSTEM_DIR_DOWNLOADS); + BIND_ENUM_CONSTANT(SYSTEM_DIR_MOVIES); + BIND_ENUM_CONSTANT(SYSTEM_DIR_MUSIC); + BIND_ENUM_CONSTANT(SYSTEM_DIR_PICTURES); + BIND_ENUM_CONSTANT(SYSTEM_DIR_RINGTONES); + + BIND_ENUM_CONSTANT(POWERSTATE_UNKNOWN); + BIND_ENUM_CONSTANT(POWERSTATE_ON_BATTERY); + BIND_ENUM_CONSTANT(POWERSTATE_NO_BATTERY); + BIND_ENUM_CONSTANT(POWERSTATE_CHARGING); + BIND_ENUM_CONSTANT(POWERSTATE_CHARGED); } _OS::_OS() { @@ -1406,11 +1406,10 @@ Error _File::open_encrypted_pass(const String &p_path, int p_mode_flags, const S Error _File::open_compressed(const String &p_path, int p_mode_flags, int p_compress_mode) { FileAccessCompressed *fac = memnew(FileAccessCompressed); - Error err = OK; fac->configure("GCPF", (Compression::Mode)p_compress_mode); - err = fac->_open(p_path, p_mode_flags); + Error err = fac->_open(p_path, p_mode_flags); if (err) { memdelete(fac); @@ -1772,15 +1771,15 @@ void _File::_bind_methods() { ClassDB::bind_method(D_METHOD("file_exists", "path"), &_File::file_exists); ClassDB::bind_method(D_METHOD("get_modified_time", "file"), &_File::get_modified_time); - BIND_CONSTANT(READ); - BIND_CONSTANT(WRITE); - BIND_CONSTANT(READ_WRITE); - BIND_CONSTANT(WRITE_READ); + BIND_ENUM_CONSTANT(READ); + BIND_ENUM_CONSTANT(WRITE); + BIND_ENUM_CONSTANT(READ_WRITE); + BIND_ENUM_CONSTANT(WRITE_READ); - BIND_CONSTANT(COMPRESSION_FASTLZ); - BIND_CONSTANT(COMPRESSION_DEFLATE); - BIND_CONSTANT(COMPRESSION_ZSTD); - BIND_CONSTANT(COMPRESSION_GZIP); + BIND_ENUM_CONSTANT(COMPRESSION_FASTLZ); + BIND_ENUM_CONSTANT(COMPRESSION_DEFLATE); + BIND_ENUM_CONSTANT(COMPRESSION_ZSTD); + BIND_ENUM_CONSTANT(COMPRESSION_GZIP); } _File::_File() { @@ -2285,9 +2284,9 @@ void _Thread::_bind_methods() { ClassDB::bind_method(D_METHOD("is_active"), &_Thread::is_active); ClassDB::bind_method(D_METHOD("wait_to_finish"), &_Thread::wait_to_finish); - BIND_CONSTANT(PRIORITY_LOW); - BIND_CONSTANT(PRIORITY_NORMAL); - BIND_CONSTANT(PRIORITY_HIGH); + BIND_ENUM_CONSTANT(PRIORITY_LOW); + BIND_ENUM_CONSTANT(PRIORITY_NORMAL); + BIND_ENUM_CONSTANT(PRIORITY_HIGH); } _Thread::_Thread() { @@ -2355,7 +2354,7 @@ Variant _ClassDB::instance(const StringName &p_class) const { if (!obj) return Variant(); - Reference *r = obj->cast_to<Reference>(); + Reference *r = Object::cast_to<Reference>(obj); if (r) { return REF(r); } else { @@ -2534,11 +2533,6 @@ float _Engine::get_frames_per_second() const { return Engine::get_singleton()->get_frames_per_second(); } -String _Engine::get_custom_level() const { - - return Engine::get_singleton()->get_custom_level(); -} - void _Engine::set_time_scale(float p_scale) { Engine::get_singleton()->set_time_scale(p_scale); } @@ -2568,6 +2562,16 @@ bool _Engine::is_in_fixed_frame() const { return Engine::get_singleton()->is_in_fixed_frame(); } +void _Engine::set_editor_hint(bool p_enabled) { + + Engine::get_singleton()->set_editor_hint(p_enabled); +} + +bool _Engine::is_editor_hint() const { + + return Engine::get_singleton()->is_editor_hint(); +} + void _Engine::_bind_methods() { ClassDB::bind_method(D_METHOD("set_iterations_per_second", "iterations_per_second"), &_Engine::set_iterations_per_second); @@ -2578,8 +2582,6 @@ void _Engine::_bind_methods() { ClassDB::bind_method(D_METHOD("set_time_scale", "time_scale"), &_Engine::set_time_scale); ClassDB::bind_method(D_METHOD("get_time_scale"), &_Engine::get_time_scale); - ClassDB::bind_method(D_METHOD("get_custom_level"), &_Engine::get_custom_level); - ClassDB::bind_method(D_METHOD("get_frames_drawn"), &_Engine::get_frames_drawn); ClassDB::bind_method(D_METHOD("get_frames_per_second"), &_Engine::get_frames_per_second); @@ -2588,6 +2590,9 @@ void _Engine::_bind_methods() { ClassDB::bind_method(D_METHOD("get_version_info"), &_Engine::get_version_info); ClassDB::bind_method(D_METHOD("is_in_fixed_frame"), &_Engine::is_in_fixed_frame); + + ClassDB::bind_method(D_METHOD("set_editor_hint", "enabled"), &_Engine::set_editor_hint); + ClassDB::bind_method(D_METHOD("is_editor_hint"), &_Engine::is_editor_hint); } _Engine *_Engine::singleton = NULL; diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 61c80aaba3..1a3782c471 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -85,6 +85,8 @@ public: _ResourceSaver(); }; +VARIANT_ENUM_CAST(_ResourceSaver::SaverFlags); + class MainLoop; class _OS : public Object { @@ -138,9 +140,9 @@ public: virtual int get_screen_count() const; virtual int get_current_screen() const; virtual void set_current_screen(int p_screen); - virtual Point2 get_screen_position(int p_screen = 0) const; - virtual Size2 get_screen_size(int p_screen = 0) const; - virtual int get_screen_dpi(int p_screen = 0) const; + virtual Point2 get_screen_position(int p_screen = -1) const; + virtual Size2 get_screen_size(int p_screen = -1) const; + virtual int get_screen_dpi(int p_screen = -1) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2 &p_position); virtual Size2 get_window_size() const; @@ -310,6 +312,8 @@ public: _OS(); }; +VARIANT_ENUM_CAST(_OS::Weekday); +VARIANT_ENUM_CAST(_OS::Month); VARIANT_ENUM_CAST(_OS::SystemDir); VARIANT_ENUM_CAST(_OS::ScreenOrientation); @@ -447,6 +451,9 @@ public: virtual ~_File(); }; +VARIANT_ENUM_CAST(_File::ModeFlags); +VARIANT_ENUM_CAST(_File::CompressionMode); + class _Directory : public Reference { GDCLASS(_Directory, Reference); @@ -578,6 +585,8 @@ public: ~_Thread(); }; +VARIANT_ENUM_CAST(_Thread::Priority); + class _ClassDB : public Object { GDCLASS(_ClassDB, Object) @@ -639,14 +648,15 @@ public: void set_time_scale(float p_scale); float get_time_scale(); - String get_custom_level() const; - MainLoop *get_main_loop() const; Dictionary get_version_info() const; bool is_in_fixed_frame() const; + void set_editor_hint(bool p_enabled); + bool is_editor_hint() const; + _Engine(); }; diff --git a/core/class_db.cpp b/core/class_db.cpp index 0503f7c6fc..1cb287a143 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -46,11 +46,6 @@ #ifdef DEBUG_METHODS_ENABLED -ParamDef::ParamDef(const Variant &p_variant) - : used(true), - val(p_variant) { -} - MethodDefinition D_METHOD(const char *p_name) { MethodDefinition md; @@ -538,11 +533,10 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b minfo.arguments.push_back(method->get_argument_info(i)); } - if (method->get_argument_type(-1) != Variant::NIL) { - minfo.return_val = method->get_argument_info(-1); - } - + minfo.return_val = method->get_return_info(); minfo.flags = method->get_hint_flags(); + minfo.default_arguments = method->get_default_arguments(); + p_methods->push_back(minfo); } @@ -583,7 +577,7 @@ MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) { return NULL; } -void ClassDB::bind_integer_constant(const StringName &p_class, const StringName &p_name, int p_constant) { +void ClassDB::bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int p_constant) { OBJTYPE_WLOCK; @@ -600,6 +594,24 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName type->constant_map[p_name] = p_constant; #ifdef DEBUG_METHODS_ENABLED + + String enum_name = p_enum; + if (enum_name != String()) { + if (enum_name.find(".") != -1) { + enum_name = enum_name.get_slicec('.', 1); + } + + List<StringName> *constants_list = type->enum_map.getptr(enum_name); + + if (constants_list) { + constants_list->push_back(p_name); + } else { + List<StringName> new_list; + new_list.push_back(p_name); + type->enum_map[enum_name] = new_list; + } + } + type->constant_order.push_back(p_name); #endif } @@ -655,6 +667,77 @@ int ClassDB::get_integer_constant(const StringName &p_class, const StringName &p return 0; } +#ifdef DEBUG_METHODS_ENABLED +StringName ClassDB::get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance) { + + OBJTYPE_RLOCK; + + ClassInfo *type = classes.getptr(p_class); + + while (type) { + + const StringName *k = NULL; + while ((k = type->enum_map.next(k))) { + + List<StringName> &constants_list = type->enum_map.get(*k); + const List<StringName>::Element *found = constants_list.find(p_name); + if (found) + return *k; + } + + if (p_no_inheritance) + break; + + type = type->inherits_ptr; + } + + return StringName(); +} + +void ClassDB::get_enum_list(const StringName &p_class, List<StringName> *p_enums, bool p_no_inheritance) { + + OBJTYPE_RLOCK; + + ClassInfo *type = classes.getptr(p_class); + + while (type) { + + const StringName *k = NULL; + while ((k = type->enum_map.next(k))) { + p_enums->push_back(*k); + } + + if (p_no_inheritance) + break; + + type = type->inherits_ptr; + } +} + +void ClassDB::get_enum_constants(const StringName &p_class, const StringName &p_enum, List<StringName> *p_constants, bool p_no_inheritance) { + + OBJTYPE_RLOCK; + + ClassInfo *type = classes.getptr(p_class); + + while (type) { + + const List<StringName> *constants = type->enum_map.getptr(p_enum); + + if (constants) { + for (const List<StringName>::Element *E = constants->front(); E; E = E->next()) { + p_constants->push_back(E->get()); + } + } + + if (p_no_inheritance) + break; + + type = type->inherits_ptr; + } +} +#endif + void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) { OBJTYPE_WLOCK; @@ -777,7 +860,7 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons MethodBind *mb_get = NULL; if (p_getter) { - MethodBind *mb_get = get_method(p_class, p_getter); + mb_get = get_method(p_class, p_getter); #ifdef DEBUG_METHODS_ENABLED if (!mb_get) { diff --git a/core/class_db.h b/core/class_db.h index 4287c5990f..f6b97748b0 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -38,29 +38,6 @@ @author Juan Linietsky <reduzio@gmail.com> */ -struct ParamHint { - - String name; - PropertyHint hint; - String hint_text; - Variant default_val; - - ParamHint(const String &p_name = "", PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "", const Variant &p_default_val = Variant()) - : name(p_name), - hint(p_hint), - hint_text(p_hint_text), - default_val(p_default_val) { - } -}; - -struct ParamDef { - bool used; - Variant val; - _FORCE_INLINE_ ParamDef() { used = false; } - ParamDef(const Variant &p_variant); -}; - -//#define DEFVAL( m_defval ) ParamDef(m_defval) #define DEFVAL(m_defval) (m_defval) //#define SIMPLE_METHODDEF @@ -138,6 +115,7 @@ public: HashMap<StringName, MethodInfo, StringNameHasher> signal_map; List<PropertyInfo> property_list; #ifdef DEBUG_METHODS_ENABLED + HashMap<StringName, List<StringName> > enum_map; List<StringName> constant_order; List<StringName> method_order; Set<StringName> methods_in_properties; @@ -180,27 +158,6 @@ public: static void _add_class() { _add_class2(T::get_class_static(), T::get_parent_class_static()); -#if 0 - GLOBAL_LOCK_FUNCTION; - - StringName name = T::get_class_static(); - - ERR_FAIL_COND(types.has(name)); - - types[name]=TypeInfo(); - TypeInfo &ti=types[name]; - ti.name=name; - ti.inherits=T::get_parent_class_static(); - - if (ti.inherits) { - - ERR_FAIL_COND( !types.has(ti.inherits) ); //it MUST be registered. - ti.inherits_ptr = &types[ti.inherits]; - - } else { - ti.inherits_ptr=NULL; - } -#endif } template <class T> @@ -251,102 +208,6 @@ public: static uint64_t get_api_hash(APIType p_api); -#if 0 - template<class N, class M> - static MethodBind* bind_method(N p_method_name, M p_method, - //default arguments - ParamDef d1=ParamDef(), - ParamDef d2=ParamDef(), - ParamDef d3=ParamDef(), - ParamDef d4=ParamDef(), - ParamDef d5=ParamDef() - ) { - - return bind_methodf(METHOD_FLAGS_DEFAULT,p_method_name, p_method, d1,d2,d3,d4,d5); - } - - - - template<class N, class M> - static MethodBind* bind_methodf(uint32_t p_flags, N p_method_name, M p_method, - - - //default arguments - const ParamDef &d1=ParamDef(), - const ParamDef &d2=ParamDef(), - const ParamDef &d3=ParamDef(), - const ParamDef &d4=ParamDef(), - const ParamDef &d5=ParamDef() - ) { - - GLOBAL_LOCK_FUNCTION; - - MethodDefinition method_name=p_method_name; - - MethodBind *bind = create_method_bind(p_method); - bind->set_name(method_name.name); - ERR_FAIL_COND_V(!bind,NULL); - - String instance_type=bind->get_instance_type(); - - TypeInfo *type=types.getptr(instance_type); - if (!type) { - memdelete(bind); - ERR_FAIL_COND_V(!type,NULL); - } - - if (type->method_map.has(method_name.name)) { - memdelete(bind); - // overloading not supported - ERR_EXPLAIN("Method already bound: "+instance_type+"::"+method_name.name); - ERR_FAIL_V(NULL); - } - bind->set_argument_names(method_name.args); - type->method_map[method_name.name]=bind; - - Vector<Variant> defvals; - -#define PARSE_DEFVAL(m_defval) \ - if (d##m_defval.used) \ - defvals.insert(0, d##m_defval.val); \ - else \ - goto set_defvals; - - - PARSE_DEFVAL(1); - PARSE_DEFVAL(2); - PARSE_DEFVAL(3); - PARSE_DEFVAL(4); - PARSE_DEFVAL(5); - set_defvals: - - bind->set_default_arguments(defvals); - bind->set_hint_flags(p_flags); - - return bind; -#undef PARSE_DEFVAL - } -#else - -#if 0 - template<class N, class M> - static MethodBind* bind_method(N p_method_name, M p_method, - //default arguments - const ParamDef &d1=ParamDef(), - const ParamDef &d2=ParamDef(), - const ParamDef &d3=ParamDef(), - const ParamDef &d4=ParamDef(), - const ParamDef &d5=ParamDef() - ) { - - MethodDefinition method_name=p_method_name; - - MethodBind *bind = create_method_bind(p_method); - - return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,method_name,d1,d2,d3,d4,d5); //use static function, much smaller binary usage - } -#endif - template <class N, class M> static MethodBind *bind_method(N p_method_name, M p_method) { @@ -409,26 +270,6 @@ public: return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 6); } -#if 0 - template<class N, class M> - static MethodBind* bind_methodf(uint32_t p_flags, N p_method_name, M p_method, - - const ParamDef& d1=ParamDef(), - const ParamDef& d2=ParamDef(), - const ParamDef& d3=ParamDef(), - const ParamDef& d4=ParamDef(), - const ParamDef& d5=ParamDef() - ) { - - MethodDefinition method_name=p_method_name; - - MethodBind *bind = create_method_bind(p_method); - - return bind_methodfi(p_flags,bind,method_name,d1,d2,d3,d4,d5); //use static function, much smaller binary usage - } -#endif - -#endif template <class M> static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>()) { @@ -456,7 +297,8 @@ public: } type->method_map[p_name] = bind; #ifdef DEBUG_METHODS_ENABLED - bind->set_return_type("Variant"); + // FIXME: <reduz> set_return_type is no longer in MethodBind, so I guess it should be moved to vararg method bind + //bind->set_return_type("Variant"); type->method_order.push_back(p_name); #endif @@ -488,9 +330,16 @@ public: static void add_virtual_method(const StringName &p_class, const MethodInfo &p_method, bool p_virtual = true); static void get_virtual_methods(const StringName &p_class, List<MethodInfo> *p_methods, bool p_no_inheritance = false); - static void bind_integer_constant(const StringName &p_class, const StringName &p_name, int p_constant); + static void bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int p_constant); static void get_integer_constant_list(const StringName &p_class, List<String> *p_constants, bool p_no_inheritance = false); static int get_integer_constant(const StringName &p_class, const StringName &p_name, bool *p_success = NULL); + +#ifdef DEBUG_METHODS_ENABLED + static StringName get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false); + static void get_enum_list(const StringName &p_class, List<StringName> *p_enums, bool p_no_inheritance = false); + static void get_enum_constants(const StringName &p_class, const StringName &p_enum, List<StringName> *p_constants, bool p_no_inheritance = false); +#endif + static StringName get_category(const StringName &p_node); static bool get_setter_and_type_for_property(const StringName &p_class, const StringName &p_prop, StringName &r_class, StringName &r_setter); @@ -509,8 +358,23 @@ public: static void cleanup(); }; +#ifdef DEBUG_METHODS_ENABLED + #define BIND_CONSTANT(m_constant) \ - ClassDB::bind_integer_constant(get_class_static(), #m_constant, m_constant); + ClassDB::bind_integer_constant(get_class_static(), StringName(), #m_constant, m_constant); + +#define BIND_ENUM_CONSTANT(m_constant) \ + ClassDB::bind_integer_constant(get_class_static(), __constant_get_enum_name(m_constant, #m_constant), #m_constant, m_constant); + +#else + +#define BIND_CONSTANT(m_constant) \ + ClassDB::bind_integer_constant(get_class_static(), StringName(), #m_constant, m_constant); + +#define BIND_ENUM_CONSTANT(m_constant) \ + ClassDB::bind_integer_constant(get_class_static(), StringName(), #m_constant, m_constant); + +#endif #ifdef TOOLS_ENABLED diff --git a/core/color.cpp b/core/color.cpp index 22a5504431..356e8c168c 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/color.h b/core/color.h index 9074a0e6d6..6df114f2f2 100644 --- a/core/color.h +++ b/core/color.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp index 823494ff67..8e2aa24c22 100644 --- a/core/command_queue_mt.cpp +++ b/core/command_queue_mt.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -55,6 +55,7 @@ CommandQueueMT::SyncSemaphore *CommandQueueMT::_alloc_sync_sem() { while (true) { + lock(); for (int i = 0; i < SYNC_SEMAPHORES; i++) { if (!sync_sems[i].in_use) { @@ -63,6 +64,7 @@ CommandQueueMT::SyncSemaphore *CommandQueueMT::_alloc_sync_sem() { break; } } + unlock(); if (idx == -1) { wait_for_flush(); diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index 2e0c478108..f99e16da15 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -911,12 +911,14 @@ public: template <class T, class M, class R> void push_and_ret(T *p_instance, M p_method, R *r_ret) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandRet0<T, M, R> *cmd = allocate_and_lock<CommandRet0<T, M, R> >(); cmd->instance = p_instance; cmd->method = p_method; cmd->ret = r_ret; - SyncSemaphore *ss = _alloc_sync_sem(); + cmd->sync = ss; unlock(); @@ -928,13 +930,15 @@ public: template <class T, class M, class P1, class R> void push_and_ret(T *p_instance, M p_method, P1 p1, R *r_ret) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandRet1<T, M, P1, R> *cmd = allocate_and_lock<CommandRet1<T, M, P1, R> >(); cmd->instance = p_instance; cmd->method = p_method; cmd->p1 = p1; cmd->ret = r_ret; - SyncSemaphore *ss = _alloc_sync_sem(); + cmd->sync = ss; unlock(); @@ -946,6 +950,8 @@ public: template <class T, class M, class P1, class P2, class R> void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, R *r_ret) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandRet2<T, M, P1, P2, R> *cmd = allocate_and_lock<CommandRet2<T, M, P1, P2, R> >(); cmd->instance = p_instance; @@ -953,7 +959,7 @@ public: cmd->p1 = p1; cmd->p2 = p2; cmd->ret = r_ret; - SyncSemaphore *ss = _alloc_sync_sem(); + cmd->sync = ss; unlock(); @@ -965,6 +971,8 @@ public: template <class T, class M, class P1, class P2, class P3, class R> void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, R *r_ret) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandRet3<T, M, P1, P2, P3, R> *cmd = allocate_and_lock<CommandRet3<T, M, P1, P2, P3, R> >(); cmd->instance = p_instance; @@ -973,7 +981,7 @@ public: cmd->p2 = p2; cmd->p3 = p3; cmd->ret = r_ret; - SyncSemaphore *ss = _alloc_sync_sem(); + cmd->sync = ss; unlock(); @@ -985,6 +993,8 @@ public: template <class T, class M, class P1, class P2, class P3, class P4, class R> void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, R *r_ret) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandRet4<T, M, P1, P2, P3, P4, R> *cmd = allocate_and_lock<CommandRet4<T, M, P1, P2, P3, P4, R> >(); cmd->instance = p_instance; @@ -994,7 +1004,7 @@ public: cmd->p3 = p3; cmd->p4 = p4; cmd->ret = r_ret; - SyncSemaphore *ss = _alloc_sync_sem(); + cmd->sync = ss; unlock(); @@ -1006,6 +1016,8 @@ public: template <class T, class M, class P1, class P2, class P3, class P4, class P5, class R> void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, R *r_ret) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandRet5<T, M, P1, P2, P3, P4, P5, R> *cmd = allocate_and_lock<CommandRet5<T, M, P1, P2, P3, P4, P5, R> >(); cmd->instance = p_instance; @@ -1016,7 +1028,7 @@ public: cmd->p4 = p4; cmd->p5 = p5; cmd->ret = r_ret; - SyncSemaphore *ss = _alloc_sync_sem(); + cmd->sync = ss; unlock(); @@ -1028,6 +1040,8 @@ public: template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class R> void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, R *r_ret) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandRet6<T, M, P1, P2, P3, P4, P5, P6, R> *cmd = allocate_and_lock<CommandRet6<T, M, P1, P2, P3, P4, P5, P6, R> >(); cmd->instance = p_instance; @@ -1039,7 +1053,7 @@ public: cmd->p5 = p5; cmd->p6 = p6; cmd->ret = r_ret; - SyncSemaphore *ss = _alloc_sync_sem(); + cmd->sync = ss; unlock(); @@ -1051,6 +1065,8 @@ public: template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class R> void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, R *r_ret) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandRet7<T, M, P1, P2, P3, P4, P5, P6, P7, R> *cmd = allocate_and_lock<CommandRet7<T, M, P1, P2, P3, P4, P5, P6, P7, R> >(); cmd->instance = p_instance; @@ -1063,7 +1079,7 @@ public: cmd->p6 = p6; cmd->p7 = p7; cmd->ret = r_ret; - SyncSemaphore *ss = _alloc_sync_sem(); + cmd->sync = ss; unlock(); @@ -1075,6 +1091,8 @@ public: template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R> void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, R *r_ret) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandRet8<T, M, P1, P2, P3, P4, P5, P6, P7, P8, R> *cmd = allocate_and_lock<CommandRet8<T, M, P1, P2, P3, P4, P5, P6, P7, P8, R> >(); cmd->instance = p_instance; @@ -1088,7 +1106,7 @@ public: cmd->p7 = p7; cmd->p8 = p8; cmd->ret = r_ret; - SyncSemaphore *ss = _alloc_sync_sem(); + cmd->sync = ss; unlock(); @@ -1100,12 +1118,13 @@ public: template <class T, class M> void push_and_sync(T *p_instance, M p_method) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandSync0<T, M> *cmd = allocate_and_lock<CommandSync0<T, M> >(); cmd->instance = p_instance; cmd->method = p_method; - SyncSemaphore *ss = _alloc_sync_sem(); cmd->sync = ss; unlock(); @@ -1117,13 +1136,14 @@ public: template <class T, class M, class P1> void push_and_sync(T *p_instance, M p_method, P1 p1) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandSync1<T, M, P1> *cmd = allocate_and_lock<CommandSync1<T, M, P1> >(); cmd->instance = p_instance; cmd->method = p_method; cmd->p1 = p1; - SyncSemaphore *ss = _alloc_sync_sem(); cmd->sync = ss; unlock(); @@ -1135,6 +1155,8 @@ public: template <class T, class M, class P1, class P2> void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandSync2<T, M, P1, P2> *cmd = allocate_and_lock<CommandSync2<T, M, P1, P2> >(); cmd->instance = p_instance; @@ -1142,7 +1164,6 @@ public: cmd->p1 = p1; cmd->p2 = p2; - SyncSemaphore *ss = _alloc_sync_sem(); cmd->sync = ss; unlock(); @@ -1154,6 +1175,8 @@ public: template <class T, class M, class P1, class P2, class P3> void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandSync3<T, M, P1, P2, P3> *cmd = allocate_and_lock<CommandSync3<T, M, P1, P2, P3> >(); cmd->instance = p_instance; @@ -1162,7 +1185,6 @@ public: cmd->p2 = p2; cmd->p3 = p3; - SyncSemaphore *ss = _alloc_sync_sem(); cmd->sync = ss; unlock(); @@ -1174,6 +1196,8 @@ public: template <class T, class M, class P1, class P2, class P3, class P4> void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandSync4<T, M, P1, P2, P3, P4> *cmd = allocate_and_lock<CommandSync4<T, M, P1, P2, P3, P4> >(); cmd->instance = p_instance; @@ -1183,7 +1207,6 @@ public: cmd->p3 = p3; cmd->p4 = p4; - SyncSemaphore *ss = _alloc_sync_sem(); cmd->sync = ss; unlock(); @@ -1195,6 +1218,8 @@ public: template <class T, class M, class P1, class P2, class P3, class P4, class P5> void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandSync5<T, M, P1, P2, P3, P4, P5> *cmd = allocate_and_lock<CommandSync5<T, M, P1, P2, P3, P4, P5> >(); cmd->instance = p_instance; @@ -1205,7 +1230,6 @@ public: cmd->p4 = p4; cmd->p5 = p5; - SyncSemaphore *ss = _alloc_sync_sem(); cmd->sync = ss; unlock(); @@ -1217,6 +1241,8 @@ public: template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6> void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandSync6<T, M, P1, P2, P3, P4, P5, P6> *cmd = allocate_and_lock<CommandSync6<T, M, P1, P2, P3, P4, P5, P6> >(); cmd->instance = p_instance; @@ -1228,7 +1254,6 @@ public: cmd->p5 = p5; cmd->p6 = p6; - SyncSemaphore *ss = _alloc_sync_sem(); cmd->sync = ss; unlock(); @@ -1240,6 +1265,8 @@ public: template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7> void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandSync7<T, M, P1, P2, P3, P4, P5, P6, P7> *cmd = allocate_and_lock<CommandSync7<T, M, P1, P2, P3, P4, P5, P6, P7> >(); cmd->instance = p_instance; @@ -1252,7 +1279,6 @@ public: cmd->p6 = p6; cmd->p7 = p7; - SyncSemaphore *ss = _alloc_sync_sem(); cmd->sync = ss; unlock(); @@ -1264,6 +1290,8 @@ public: template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8> void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { + SyncSemaphore *ss = _alloc_sync_sem(); + CommandSync8<T, M, P1, P2, P3, P4, P5, P6, P7, P8> *cmd = allocate_and_lock<CommandSync8<T, M, P1, P2, P3, P4, P5, P6, P7, P8> >(); cmd->instance = p_instance; @@ -1277,7 +1305,6 @@ public: cmd->p7 = p7; cmd->p8 = p8; - SyncSemaphore *ss = _alloc_sync_sem(); cmd->sync = ss; unlock(); diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index 172249c5d7..74565d2e32 100644 --- a/core/compressed_translation.cpp +++ b/core/compressed_translation.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/compressed_translation.h b/core/compressed_translation.h index c010491b3a..acccf95743 100644 --- a/core/compressed_translation.h +++ b/core/compressed_translation.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp index 2f5a684373..ef9346253f 100644 --- a/core/core_string_names.cpp +++ b/core/core_string_names.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/core_string_names.h b/core/core_string_names.h index 40f76aa9c0..2eb2b703ae 100644 --- a/core/core_string_names.h +++ b/core/core_string_names.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/dictionary.cpp b/core/dictionary.cpp index 1fe45aff94..bb2e892951 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -200,17 +200,6 @@ uint32_t Dictionary::hash() const { Array Dictionary::keys() const { -#if 0 - Array karr; - karr.resize(size()); - const Variant *K = NULL; - int idx = 0; - while ((K = next(K))) { - karr[idx++] = (*K); - } - return karr; -#else - Array varr; varr.resize(size()); if (_p->variant_map.empty()) @@ -228,7 +217,6 @@ Array Dictionary::keys() const { } return varr; -#endif } Array Dictionary::values() const { diff --git a/core/dictionary.h b/core/dictionary.h index 27caba916f..c8177d5648 100644 --- a/core/dictionary.h +++ b/core/dictionary.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/dvector.cpp b/core/dvector.cpp index 4bbe1aafd9..185cecd531 100644 --- a/core/dvector.cpp +++ b/core/dvector.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/dvector.h b/core/dvector.h index 66af42f7e2..1b81ceec5e 100644 --- a/core/dvector.h +++ b/core/dvector.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/engine.cpp b/core/engine.cpp index c16a2903d3..d73693dc12 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -121,4 +121,5 @@ Engine::Engine() { _in_fixed = false; _frame_ticks = 0; _frame_step = 0; + editor_hint = false; } diff --git a/core/engine.h b/core/engine.h index 16dfb77593..6f46ec8923 100644 --- a/core/engine.h +++ b/core/engine.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -39,7 +39,6 @@ class Engine { friend class Main; - String _custom_level; uint64_t frames_drawn; uint32_t _frame_delay; uint64_t _frame_ticks; @@ -51,9 +50,12 @@ class Engine { float _time_scale; bool _pixel_snap; uint64_t _fixed_frames; + uint64_t _idle_frames; bool _in_fixed; + bool editor_hint; + static Engine *singleton; public: @@ -67,8 +69,6 @@ public: virtual float get_frames_per_second() const { return _fps; } - String get_custom_level() const { return _custom_level; } - uint64_t get_frames_drawn(); uint64_t get_fixed_frames() const { return _fixed_frames; } @@ -85,6 +85,14 @@ public: _FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; } +#ifdef TOOLS_ENABLED + _FORCE_INLINE_ void set_editor_hint(bool p_enabled) { editor_hint = p_enabled; } + _FORCE_INLINE_ bool is_editor_hint() const { return editor_hint; } +#else + _FORCE_INLINE_ void set_editor_hint(bool p_enabled) {} + _FORCE_INLINE_ bool is_editor_hint() const { return false; } +#endif + Dictionary get_version_info() const; Engine(); diff --git a/core/error_list.h b/core/error_list.h index 14ef7bbc18..bc65ad0ee4 100644 --- a/core/error_list.h +++ b/core/error_list.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/error_macros.cpp b/core/error_macros.cpp index afbff6c52d..5919d38375 100644 --- a/core/error_macros.cpp +++ b/core/error_macros.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/error_macros.h b/core/error_macros.h index 6c803951a1..005b0e32a3 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/event_queue.cpp b/core/event_queue.cpp index c5257d5f6b..12f9942a07 100644 --- a/core/event_queue.cpp +++ b/core/event_queue.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/event_queue.h b/core/event_queue.h index a6c436909d..af1a760945 100644 --- a/core/event_queue.h +++ b/core/event_queue.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/func_ref.cpp b/core/func_ref.cpp index 5622a03665..d9a8f6bcdb 100644 --- a/core/func_ref.cpp +++ b/core/func_ref.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/func_ref.h b/core/func_ref.h index e60d5bd771..b9b1988ede 100644 --- a/core/func_ref.h +++ b/core/func_ref.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 9e745ecb98..224ee0e0aa 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -3,14 +3,14 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ +/* "Software") to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ @@ -36,504 +36,563 @@ struct _GlobalConstant { +#ifdef DEBUG_METHODS_ENABLED + StringName enum_name; +#endif const char *name; int value; + + _GlobalConstant() {} + +#ifdef DEBUG_METHODS_ENABLED + _GlobalConstant(const StringName &p_enum_name, const char *p_name, int p_value) + : enum_name(p_enum_name), + name(p_name), + value(p_value) { + } +#else + _GlobalConstant(const char *p_name, int p_value) + : name(p_name), + value(p_value) { + } +#endif }; +static Vector<_GlobalConstant> _global_constants; + +#ifdef DEBUG_METHODS_ENABLED + +#define BIND_GLOBAL_CONSTANT(m_constant) \ + _global_constants.push_back(_GlobalConstant(StringName(), #m_constant, m_constant)); + +#define BIND_GLOBAL_ENUM_CONSTANT(m_constant) \ + _global_constants.push_back(_GlobalConstant(__constant_get_enum_name(m_constant, #m_constant), #m_constant, m_constant)); + +#define BIND_GLOBAL_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \ + _global_constants.push_back(_GlobalConstant(__constant_get_enum_name(m_constant, #m_constant), m_custom_name, m_constant)); + +#else + #define BIND_GLOBAL_CONSTANT(m_constant) \ - { #m_constant, m_constant } + _global_constants.push_back(_GlobalConstant(#m_constant, m_constant)); + +#define BIND_GLOBAL_ENUM_CONSTANT(m_constant) \ + _global_constants.push_back(_GlobalConstant(#m_constant, m_constant)); + +#define BIND_GLOBAL_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \ + _global_constants.push_back(_GlobalConstant(m_custom_name, m_constant)); + +#endif + +VARIANT_ENUM_CAST(KeyList); +VARIANT_ENUM_CAST(KeyModifierMask); -static _GlobalConstant _global_constants[] = { +void register_global_constants() { //{ KEY_BACKSPACE, VK_BACK },// (0x08) // backspace - BIND_GLOBAL_CONSTANT(MARGIN_LEFT), - BIND_GLOBAL_CONSTANT(MARGIN_TOP), - BIND_GLOBAL_CONSTANT(MARGIN_RIGHT), - BIND_GLOBAL_CONSTANT(MARGIN_BOTTOM), - BIND_GLOBAL_CONSTANT(VERTICAL), - BIND_GLOBAL_CONSTANT(HORIZONTAL), - BIND_GLOBAL_CONSTANT(HALIGN_LEFT), - BIND_GLOBAL_CONSTANT(HALIGN_CENTER), - BIND_GLOBAL_CONSTANT(HALIGN_RIGHT), - BIND_GLOBAL_CONSTANT(VALIGN_TOP), - BIND_GLOBAL_CONSTANT(VALIGN_CENTER), - BIND_GLOBAL_CONSTANT(VALIGN_BOTTOM), + BIND_GLOBAL_ENUM_CONSTANT(MARGIN_LEFT); + BIND_GLOBAL_ENUM_CONSTANT(MARGIN_TOP); + BIND_GLOBAL_ENUM_CONSTANT(MARGIN_RIGHT); + BIND_GLOBAL_ENUM_CONSTANT(MARGIN_BOTTOM); + + BIND_GLOBAL_ENUM_CONSTANT(VERTICAL); + BIND_GLOBAL_ENUM_CONSTANT(HORIZONTAL); + + BIND_GLOBAL_ENUM_CONSTANT(HALIGN_LEFT); + BIND_GLOBAL_ENUM_CONSTANT(HALIGN_CENTER); + BIND_GLOBAL_ENUM_CONSTANT(HALIGN_RIGHT); + + BIND_GLOBAL_ENUM_CONSTANT(VALIGN_TOP); + BIND_GLOBAL_ENUM_CONSTANT(VALIGN_CENTER); + BIND_GLOBAL_ENUM_CONSTANT(VALIGN_BOTTOM); // hueg list of keys - BIND_GLOBAL_CONSTANT(SPKEY), - - BIND_GLOBAL_CONSTANT(KEY_ESCAPE), - BIND_GLOBAL_CONSTANT(KEY_TAB), - BIND_GLOBAL_CONSTANT(KEY_BACKTAB), - BIND_GLOBAL_CONSTANT(KEY_BACKSPACE), - 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), - BIND_GLOBAL_CONSTANT(KEY_PRINT), - BIND_GLOBAL_CONSTANT(KEY_SYSREQ), - BIND_GLOBAL_CONSTANT(KEY_CLEAR), - BIND_GLOBAL_CONSTANT(KEY_HOME), - BIND_GLOBAL_CONSTANT(KEY_END), - BIND_GLOBAL_CONSTANT(KEY_LEFT), - BIND_GLOBAL_CONSTANT(KEY_UP), - BIND_GLOBAL_CONSTANT(KEY_RIGHT), - BIND_GLOBAL_CONSTANT(KEY_DOWN), - BIND_GLOBAL_CONSTANT(KEY_PAGEUP), - BIND_GLOBAL_CONSTANT(KEY_PAGEDOWN), - BIND_GLOBAL_CONSTANT(KEY_SHIFT), - BIND_GLOBAL_CONSTANT(KEY_CONTROL), - BIND_GLOBAL_CONSTANT(KEY_META), - BIND_GLOBAL_CONSTANT(KEY_ALT), - BIND_GLOBAL_CONSTANT(KEY_CAPSLOCK), - BIND_GLOBAL_CONSTANT(KEY_NUMLOCK), - BIND_GLOBAL_CONSTANT(KEY_SCROLLLOCK), - BIND_GLOBAL_CONSTANT(KEY_F1), - BIND_GLOBAL_CONSTANT(KEY_F2), - BIND_GLOBAL_CONSTANT(KEY_F3), - BIND_GLOBAL_CONSTANT(KEY_F4), - BIND_GLOBAL_CONSTANT(KEY_F5), - BIND_GLOBAL_CONSTANT(KEY_F6), - BIND_GLOBAL_CONSTANT(KEY_F7), - BIND_GLOBAL_CONSTANT(KEY_F8), - BIND_GLOBAL_CONSTANT(KEY_F9), - BIND_GLOBAL_CONSTANT(KEY_F10), - BIND_GLOBAL_CONSTANT(KEY_F11), - BIND_GLOBAL_CONSTANT(KEY_F12), - BIND_GLOBAL_CONSTANT(KEY_F13), - BIND_GLOBAL_CONSTANT(KEY_F14), - BIND_GLOBAL_CONSTANT(KEY_F15), - BIND_GLOBAL_CONSTANT(KEY_F16), - BIND_GLOBAL_CONSTANT(KEY_KP_MULTIPLY), - BIND_GLOBAL_CONSTANT(KEY_KP_DIVIDE), - BIND_GLOBAL_CONSTANT(KEY_KP_SUBTRACT), - BIND_GLOBAL_CONSTANT(KEY_KP_PERIOD), - BIND_GLOBAL_CONSTANT(KEY_KP_ADD), - BIND_GLOBAL_CONSTANT(KEY_KP_0), - BIND_GLOBAL_CONSTANT(KEY_KP_1), - BIND_GLOBAL_CONSTANT(KEY_KP_2), - BIND_GLOBAL_CONSTANT(KEY_KP_3), - BIND_GLOBAL_CONSTANT(KEY_KP_4), - BIND_GLOBAL_CONSTANT(KEY_KP_5), - BIND_GLOBAL_CONSTANT(KEY_KP_6), - BIND_GLOBAL_CONSTANT(KEY_KP_7), - BIND_GLOBAL_CONSTANT(KEY_KP_8), - BIND_GLOBAL_CONSTANT(KEY_KP_9), - BIND_GLOBAL_CONSTANT(KEY_SUPER_L), - BIND_GLOBAL_CONSTANT(KEY_SUPER_R), - BIND_GLOBAL_CONSTANT(KEY_MENU), - BIND_GLOBAL_CONSTANT(KEY_HYPER_L), - BIND_GLOBAL_CONSTANT(KEY_HYPER_R), - BIND_GLOBAL_CONSTANT(KEY_HELP), - BIND_GLOBAL_CONSTANT(KEY_DIRECTION_L), - BIND_GLOBAL_CONSTANT(KEY_DIRECTION_R), - BIND_GLOBAL_CONSTANT(KEY_BACK), - BIND_GLOBAL_CONSTANT(KEY_FORWARD), - BIND_GLOBAL_CONSTANT(KEY_STOP), - BIND_GLOBAL_CONSTANT(KEY_REFRESH), - BIND_GLOBAL_CONSTANT(KEY_VOLUMEDOWN), - BIND_GLOBAL_CONSTANT(KEY_VOLUMEMUTE), - BIND_GLOBAL_CONSTANT(KEY_VOLUMEUP), - BIND_GLOBAL_CONSTANT(KEY_BASSBOOST), - BIND_GLOBAL_CONSTANT(KEY_BASSUP), - BIND_GLOBAL_CONSTANT(KEY_BASSDOWN), - BIND_GLOBAL_CONSTANT(KEY_TREBLEUP), - BIND_GLOBAL_CONSTANT(KEY_TREBLEDOWN), - BIND_GLOBAL_CONSTANT(KEY_MEDIAPLAY), - BIND_GLOBAL_CONSTANT(KEY_MEDIASTOP), - BIND_GLOBAL_CONSTANT(KEY_MEDIAPREVIOUS), - BIND_GLOBAL_CONSTANT(KEY_MEDIANEXT), - BIND_GLOBAL_CONSTANT(KEY_MEDIARECORD), - BIND_GLOBAL_CONSTANT(KEY_HOMEPAGE), - BIND_GLOBAL_CONSTANT(KEY_FAVORITES), - BIND_GLOBAL_CONSTANT(KEY_SEARCH), - BIND_GLOBAL_CONSTANT(KEY_STANDBY), - BIND_GLOBAL_CONSTANT(KEY_OPENURL), - BIND_GLOBAL_CONSTANT(KEY_LAUNCHMAIL), - BIND_GLOBAL_CONSTANT(KEY_LAUNCHMEDIA), - BIND_GLOBAL_CONSTANT(KEY_LAUNCH0), - BIND_GLOBAL_CONSTANT(KEY_LAUNCH1), - BIND_GLOBAL_CONSTANT(KEY_LAUNCH2), - BIND_GLOBAL_CONSTANT(KEY_LAUNCH3), - BIND_GLOBAL_CONSTANT(KEY_LAUNCH4), - BIND_GLOBAL_CONSTANT(KEY_LAUNCH5), - BIND_GLOBAL_CONSTANT(KEY_LAUNCH6), - BIND_GLOBAL_CONSTANT(KEY_LAUNCH7), - BIND_GLOBAL_CONSTANT(KEY_LAUNCH8), - BIND_GLOBAL_CONSTANT(KEY_LAUNCH9), - BIND_GLOBAL_CONSTANT(KEY_LAUNCHA), - BIND_GLOBAL_CONSTANT(KEY_LAUNCHB), - BIND_GLOBAL_CONSTANT(KEY_LAUNCHC), - BIND_GLOBAL_CONSTANT(KEY_LAUNCHD), - BIND_GLOBAL_CONSTANT(KEY_LAUNCHE), - BIND_GLOBAL_CONSTANT(KEY_LAUNCHF), - - BIND_GLOBAL_CONSTANT(KEY_UNKNOWN), - BIND_GLOBAL_CONSTANT(KEY_SPACE), - BIND_GLOBAL_CONSTANT(KEY_EXCLAM), - BIND_GLOBAL_CONSTANT(KEY_QUOTEDBL), - BIND_GLOBAL_CONSTANT(KEY_NUMBERSIGN), - BIND_GLOBAL_CONSTANT(KEY_DOLLAR), - BIND_GLOBAL_CONSTANT(KEY_PERCENT), - BIND_GLOBAL_CONSTANT(KEY_AMPERSAND), - BIND_GLOBAL_CONSTANT(KEY_APOSTROPHE), - BIND_GLOBAL_CONSTANT(KEY_PARENLEFT), - BIND_GLOBAL_CONSTANT(KEY_PARENRIGHT), - BIND_GLOBAL_CONSTANT(KEY_ASTERISK), - BIND_GLOBAL_CONSTANT(KEY_PLUS), - BIND_GLOBAL_CONSTANT(KEY_COMMA), - BIND_GLOBAL_CONSTANT(KEY_MINUS), - BIND_GLOBAL_CONSTANT(KEY_PERIOD), - BIND_GLOBAL_CONSTANT(KEY_SLASH), - BIND_GLOBAL_CONSTANT(KEY_0), - BIND_GLOBAL_CONSTANT(KEY_1), - BIND_GLOBAL_CONSTANT(KEY_2), - BIND_GLOBAL_CONSTANT(KEY_3), - BIND_GLOBAL_CONSTANT(KEY_4), - BIND_GLOBAL_CONSTANT(KEY_5), - BIND_GLOBAL_CONSTANT(KEY_6), - BIND_GLOBAL_CONSTANT(KEY_7), - BIND_GLOBAL_CONSTANT(KEY_8), - BIND_GLOBAL_CONSTANT(KEY_9), - BIND_GLOBAL_CONSTANT(KEY_COLON), - BIND_GLOBAL_CONSTANT(KEY_SEMICOLON), - BIND_GLOBAL_CONSTANT(KEY_LESS), - BIND_GLOBAL_CONSTANT(KEY_EQUAL), - BIND_GLOBAL_CONSTANT(KEY_GREATER), - BIND_GLOBAL_CONSTANT(KEY_QUESTION), - BIND_GLOBAL_CONSTANT(KEY_AT), - BIND_GLOBAL_CONSTANT(KEY_A), - BIND_GLOBAL_CONSTANT(KEY_B), - BIND_GLOBAL_CONSTANT(KEY_C), - BIND_GLOBAL_CONSTANT(KEY_D), - BIND_GLOBAL_CONSTANT(KEY_E), - BIND_GLOBAL_CONSTANT(KEY_F), - BIND_GLOBAL_CONSTANT(KEY_G), - BIND_GLOBAL_CONSTANT(KEY_H), - BIND_GLOBAL_CONSTANT(KEY_I), - BIND_GLOBAL_CONSTANT(KEY_J), - BIND_GLOBAL_CONSTANT(KEY_K), - BIND_GLOBAL_CONSTANT(KEY_L), - BIND_GLOBAL_CONSTANT(KEY_M), - BIND_GLOBAL_CONSTANT(KEY_N), - BIND_GLOBAL_CONSTANT(KEY_O), - BIND_GLOBAL_CONSTANT(KEY_P), - BIND_GLOBAL_CONSTANT(KEY_Q), - BIND_GLOBAL_CONSTANT(KEY_R), - BIND_GLOBAL_CONSTANT(KEY_S), - BIND_GLOBAL_CONSTANT(KEY_T), - BIND_GLOBAL_CONSTANT(KEY_U), - BIND_GLOBAL_CONSTANT(KEY_V), - BIND_GLOBAL_CONSTANT(KEY_W), - BIND_GLOBAL_CONSTANT(KEY_X), - BIND_GLOBAL_CONSTANT(KEY_Y), - BIND_GLOBAL_CONSTANT(KEY_Z), - BIND_GLOBAL_CONSTANT(KEY_BRACKETLEFT), - BIND_GLOBAL_CONSTANT(KEY_BACKSLASH), - BIND_GLOBAL_CONSTANT(KEY_BRACKETRIGHT), - BIND_GLOBAL_CONSTANT(KEY_ASCIICIRCUM), - BIND_GLOBAL_CONSTANT(KEY_UNDERSCORE), - BIND_GLOBAL_CONSTANT(KEY_QUOTELEFT), - BIND_GLOBAL_CONSTANT(KEY_BRACELEFT), - BIND_GLOBAL_CONSTANT(KEY_BAR), - BIND_GLOBAL_CONSTANT(KEY_BRACERIGHT), - BIND_GLOBAL_CONSTANT(KEY_ASCIITILDE), - BIND_GLOBAL_CONSTANT(KEY_NOBREAKSPACE), - BIND_GLOBAL_CONSTANT(KEY_EXCLAMDOWN), - BIND_GLOBAL_CONSTANT(KEY_CENT), - BIND_GLOBAL_CONSTANT(KEY_STERLING), - BIND_GLOBAL_CONSTANT(KEY_CURRENCY), - BIND_GLOBAL_CONSTANT(KEY_YEN), - BIND_GLOBAL_CONSTANT(KEY_BROKENBAR), - BIND_GLOBAL_CONSTANT(KEY_SECTION), - BIND_GLOBAL_CONSTANT(KEY_DIAERESIS), - BIND_GLOBAL_CONSTANT(KEY_COPYRIGHT), - BIND_GLOBAL_CONSTANT(KEY_ORDFEMININE), - BIND_GLOBAL_CONSTANT(KEY_GUILLEMOTLEFT), - BIND_GLOBAL_CONSTANT(KEY_NOTSIGN), - BIND_GLOBAL_CONSTANT(KEY_HYPHEN), - BIND_GLOBAL_CONSTANT(KEY_REGISTERED), - BIND_GLOBAL_CONSTANT(KEY_MACRON), - BIND_GLOBAL_CONSTANT(KEY_DEGREE), - BIND_GLOBAL_CONSTANT(KEY_PLUSMINUS), - BIND_GLOBAL_CONSTANT(KEY_TWOSUPERIOR), - BIND_GLOBAL_CONSTANT(KEY_THREESUPERIOR), - BIND_GLOBAL_CONSTANT(KEY_ACUTE), - BIND_GLOBAL_CONSTANT(KEY_MU), - BIND_GLOBAL_CONSTANT(KEY_PARAGRAPH), - BIND_GLOBAL_CONSTANT(KEY_PERIODCENTERED), - BIND_GLOBAL_CONSTANT(KEY_CEDILLA), - BIND_GLOBAL_CONSTANT(KEY_ONESUPERIOR), - BIND_GLOBAL_CONSTANT(KEY_MASCULINE), - BIND_GLOBAL_CONSTANT(KEY_GUILLEMOTRIGHT), - BIND_GLOBAL_CONSTANT(KEY_ONEQUARTER), - BIND_GLOBAL_CONSTANT(KEY_ONEHALF), - BIND_GLOBAL_CONSTANT(KEY_THREEQUARTERS), - BIND_GLOBAL_CONSTANT(KEY_QUESTIONDOWN), - BIND_GLOBAL_CONSTANT(KEY_AGRAVE), - BIND_GLOBAL_CONSTANT(KEY_AACUTE), - BIND_GLOBAL_CONSTANT(KEY_ACIRCUMFLEX), - BIND_GLOBAL_CONSTANT(KEY_ATILDE), - BIND_GLOBAL_CONSTANT(KEY_ADIAERESIS), - BIND_GLOBAL_CONSTANT(KEY_ARING), - BIND_GLOBAL_CONSTANT(KEY_AE), - BIND_GLOBAL_CONSTANT(KEY_CCEDILLA), - BIND_GLOBAL_CONSTANT(KEY_EGRAVE), - BIND_GLOBAL_CONSTANT(KEY_EACUTE), - BIND_GLOBAL_CONSTANT(KEY_ECIRCUMFLEX), - BIND_GLOBAL_CONSTANT(KEY_EDIAERESIS), - BIND_GLOBAL_CONSTANT(KEY_IGRAVE), - BIND_GLOBAL_CONSTANT(KEY_IACUTE), - BIND_GLOBAL_CONSTANT(KEY_ICIRCUMFLEX), - BIND_GLOBAL_CONSTANT(KEY_IDIAERESIS), - BIND_GLOBAL_CONSTANT(KEY_ETH), - BIND_GLOBAL_CONSTANT(KEY_NTILDE), - BIND_GLOBAL_CONSTANT(KEY_OGRAVE), - BIND_GLOBAL_CONSTANT(KEY_OACUTE), - BIND_GLOBAL_CONSTANT(KEY_OCIRCUMFLEX), - BIND_GLOBAL_CONSTANT(KEY_OTILDE), - BIND_GLOBAL_CONSTANT(KEY_ODIAERESIS), - BIND_GLOBAL_CONSTANT(KEY_MULTIPLY), - BIND_GLOBAL_CONSTANT(KEY_OOBLIQUE), - BIND_GLOBAL_CONSTANT(KEY_UGRAVE), - BIND_GLOBAL_CONSTANT(KEY_UACUTE), - BIND_GLOBAL_CONSTANT(KEY_UCIRCUMFLEX), - BIND_GLOBAL_CONSTANT(KEY_UDIAERESIS), - BIND_GLOBAL_CONSTANT(KEY_YACUTE), - BIND_GLOBAL_CONSTANT(KEY_THORN), - BIND_GLOBAL_CONSTANT(KEY_SSHARP), - - BIND_GLOBAL_CONSTANT(KEY_DIVISION), - BIND_GLOBAL_CONSTANT(KEY_YDIAERESIS), - - BIND_GLOBAL_CONSTANT(KEY_CODE_MASK), - BIND_GLOBAL_CONSTANT(KEY_MODIFIER_MASK), - - BIND_GLOBAL_CONSTANT(KEY_MASK_SHIFT), - BIND_GLOBAL_CONSTANT(KEY_MASK_ALT), - BIND_GLOBAL_CONSTANT(KEY_MASK_META), - BIND_GLOBAL_CONSTANT(KEY_MASK_CTRL), - BIND_GLOBAL_CONSTANT(KEY_MASK_CMD), - BIND_GLOBAL_CONSTANT(KEY_MASK_KPAD), - BIND_GLOBAL_CONSTANT(KEY_MASK_GROUP_SWITCH), + BIND_GLOBAL_CONSTANT(SPKEY); + + BIND_GLOBAL_ENUM_CONSTANT(KEY_ESCAPE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_TAB); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BACKTAB); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BACKSPACE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ENTER); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_ENTER); + BIND_GLOBAL_ENUM_CONSTANT(KEY_INSERT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_DELETE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PAUSE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PRINT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_SYSREQ); + BIND_GLOBAL_ENUM_CONSTANT(KEY_CLEAR); + BIND_GLOBAL_ENUM_CONSTANT(KEY_HOME); + BIND_GLOBAL_ENUM_CONSTANT(KEY_END); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LEFT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_UP); + BIND_GLOBAL_ENUM_CONSTANT(KEY_RIGHT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_DOWN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PAGEUP); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PAGEDOWN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_SHIFT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_CONTROL); + BIND_GLOBAL_ENUM_CONSTANT(KEY_META); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ALT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_CAPSLOCK); + BIND_GLOBAL_ENUM_CONSTANT(KEY_NUMLOCK); + BIND_GLOBAL_ENUM_CONSTANT(KEY_SCROLLLOCK); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F1); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F2); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F3); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F4); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F5); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F6); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F7); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F8); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F9); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F10); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F11); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F12); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F13); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F14); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F15); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F16); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_MULTIPLY); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_DIVIDE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_SUBTRACT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_PERIOD); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_ADD); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_0); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_1); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_2); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_3); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_4); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_5); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_6); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_7); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_8); + BIND_GLOBAL_ENUM_CONSTANT(KEY_KP_9); + BIND_GLOBAL_ENUM_CONSTANT(KEY_SUPER_L); + BIND_GLOBAL_ENUM_CONSTANT(KEY_SUPER_R); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MENU); + BIND_GLOBAL_ENUM_CONSTANT(KEY_HYPER_L); + BIND_GLOBAL_ENUM_CONSTANT(KEY_HYPER_R); + BIND_GLOBAL_ENUM_CONSTANT(KEY_HELP); + BIND_GLOBAL_ENUM_CONSTANT(KEY_DIRECTION_L); + BIND_GLOBAL_ENUM_CONSTANT(KEY_DIRECTION_R); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BACK); + BIND_GLOBAL_ENUM_CONSTANT(KEY_FORWARD); + BIND_GLOBAL_ENUM_CONSTANT(KEY_STOP); + BIND_GLOBAL_ENUM_CONSTANT(KEY_REFRESH); + BIND_GLOBAL_ENUM_CONSTANT(KEY_VOLUMEDOWN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_VOLUMEMUTE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_VOLUMEUP); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BASSBOOST); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BASSUP); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BASSDOWN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_TREBLEUP); + BIND_GLOBAL_ENUM_CONSTANT(KEY_TREBLEDOWN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MEDIAPLAY); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MEDIASTOP); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MEDIAPREVIOUS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MEDIANEXT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MEDIARECORD); + BIND_GLOBAL_ENUM_CONSTANT(KEY_HOMEPAGE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_FAVORITES); + BIND_GLOBAL_ENUM_CONSTANT(KEY_SEARCH); + BIND_GLOBAL_ENUM_CONSTANT(KEY_STANDBY); + BIND_GLOBAL_ENUM_CONSTANT(KEY_OPENURL); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCHMAIL); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCHMEDIA); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCH0); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCH1); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCH2); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCH3); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCH4); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCH5); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCH6); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCH7); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCH8); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCH9); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCHA); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCHB); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCHC); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCHD); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCHE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LAUNCHF); + + BIND_GLOBAL_ENUM_CONSTANT(KEY_UNKNOWN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_SPACE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_EXCLAM); + BIND_GLOBAL_ENUM_CONSTANT(KEY_QUOTEDBL); + BIND_GLOBAL_ENUM_CONSTANT(KEY_NUMBERSIGN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_DOLLAR); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PERCENT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_AMPERSAND); + BIND_GLOBAL_ENUM_CONSTANT(KEY_APOSTROPHE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PARENLEFT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PARENRIGHT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ASTERISK); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PLUS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_COMMA); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MINUS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PERIOD); + BIND_GLOBAL_ENUM_CONSTANT(KEY_SLASH); + BIND_GLOBAL_ENUM_CONSTANT(KEY_0); + BIND_GLOBAL_ENUM_CONSTANT(KEY_1); + BIND_GLOBAL_ENUM_CONSTANT(KEY_2); + BIND_GLOBAL_ENUM_CONSTANT(KEY_3); + BIND_GLOBAL_ENUM_CONSTANT(KEY_4); + BIND_GLOBAL_ENUM_CONSTANT(KEY_5); + BIND_GLOBAL_ENUM_CONSTANT(KEY_6); + BIND_GLOBAL_ENUM_CONSTANT(KEY_7); + BIND_GLOBAL_ENUM_CONSTANT(KEY_8); + BIND_GLOBAL_ENUM_CONSTANT(KEY_9); + BIND_GLOBAL_ENUM_CONSTANT(KEY_COLON); + BIND_GLOBAL_ENUM_CONSTANT(KEY_SEMICOLON); + BIND_GLOBAL_ENUM_CONSTANT(KEY_LESS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_EQUAL); + BIND_GLOBAL_ENUM_CONSTANT(KEY_GREATER); + BIND_GLOBAL_ENUM_CONSTANT(KEY_QUESTION); + BIND_GLOBAL_ENUM_CONSTANT(KEY_AT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_A); + BIND_GLOBAL_ENUM_CONSTANT(KEY_B); + BIND_GLOBAL_ENUM_CONSTANT(KEY_C); + BIND_GLOBAL_ENUM_CONSTANT(KEY_D); + BIND_GLOBAL_ENUM_CONSTANT(KEY_E); + BIND_GLOBAL_ENUM_CONSTANT(KEY_F); + BIND_GLOBAL_ENUM_CONSTANT(KEY_G); + BIND_GLOBAL_ENUM_CONSTANT(KEY_H); + BIND_GLOBAL_ENUM_CONSTANT(KEY_I); + BIND_GLOBAL_ENUM_CONSTANT(KEY_J); + BIND_GLOBAL_ENUM_CONSTANT(KEY_K); + BIND_GLOBAL_ENUM_CONSTANT(KEY_L); + BIND_GLOBAL_ENUM_CONSTANT(KEY_M); + BIND_GLOBAL_ENUM_CONSTANT(KEY_N); + BIND_GLOBAL_ENUM_CONSTANT(KEY_O); + BIND_GLOBAL_ENUM_CONSTANT(KEY_P); + BIND_GLOBAL_ENUM_CONSTANT(KEY_Q); + BIND_GLOBAL_ENUM_CONSTANT(KEY_R); + BIND_GLOBAL_ENUM_CONSTANT(KEY_S); + BIND_GLOBAL_ENUM_CONSTANT(KEY_T); + BIND_GLOBAL_ENUM_CONSTANT(KEY_U); + BIND_GLOBAL_ENUM_CONSTANT(KEY_V); + BIND_GLOBAL_ENUM_CONSTANT(KEY_W); + BIND_GLOBAL_ENUM_CONSTANT(KEY_X); + BIND_GLOBAL_ENUM_CONSTANT(KEY_Y); + BIND_GLOBAL_ENUM_CONSTANT(KEY_Z); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BRACKETLEFT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BACKSLASH); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BRACKETRIGHT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ASCIICIRCUM); + BIND_GLOBAL_ENUM_CONSTANT(KEY_UNDERSCORE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_QUOTELEFT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BRACELEFT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BAR); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BRACERIGHT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ASCIITILDE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_NOBREAKSPACE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_EXCLAMDOWN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_CENT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_STERLING); + BIND_GLOBAL_ENUM_CONSTANT(KEY_CURRENCY); + BIND_GLOBAL_ENUM_CONSTANT(KEY_YEN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_BROKENBAR); + BIND_GLOBAL_ENUM_CONSTANT(KEY_SECTION); + BIND_GLOBAL_ENUM_CONSTANT(KEY_DIAERESIS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_COPYRIGHT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ORDFEMININE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_GUILLEMOTLEFT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_NOTSIGN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_HYPHEN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_REGISTERED); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MACRON); + BIND_GLOBAL_ENUM_CONSTANT(KEY_DEGREE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PLUSMINUS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_TWOSUPERIOR); + BIND_GLOBAL_ENUM_CONSTANT(KEY_THREESUPERIOR); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ACUTE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MU); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PARAGRAPH); + BIND_GLOBAL_ENUM_CONSTANT(KEY_PERIODCENTERED); + BIND_GLOBAL_ENUM_CONSTANT(KEY_CEDILLA); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ONESUPERIOR); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MASCULINE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_GUILLEMOTRIGHT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ONEQUARTER); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ONEHALF); + BIND_GLOBAL_ENUM_CONSTANT(KEY_THREEQUARTERS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_QUESTIONDOWN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_AGRAVE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_AACUTE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ACIRCUMFLEX); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ATILDE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ADIAERESIS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ARING); + BIND_GLOBAL_ENUM_CONSTANT(KEY_AE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_CCEDILLA); + BIND_GLOBAL_ENUM_CONSTANT(KEY_EGRAVE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_EACUTE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ECIRCUMFLEX); + BIND_GLOBAL_ENUM_CONSTANT(KEY_EDIAERESIS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_IGRAVE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_IACUTE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ICIRCUMFLEX); + BIND_GLOBAL_ENUM_CONSTANT(KEY_IDIAERESIS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ETH); + BIND_GLOBAL_ENUM_CONSTANT(KEY_NTILDE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_OGRAVE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_OACUTE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_OCIRCUMFLEX); + BIND_GLOBAL_ENUM_CONSTANT(KEY_OTILDE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_ODIAERESIS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MULTIPLY); + BIND_GLOBAL_ENUM_CONSTANT(KEY_OOBLIQUE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_UGRAVE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_UACUTE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_UCIRCUMFLEX); + BIND_GLOBAL_ENUM_CONSTANT(KEY_UDIAERESIS); + BIND_GLOBAL_ENUM_CONSTANT(KEY_YACUTE); + BIND_GLOBAL_ENUM_CONSTANT(KEY_THORN); + BIND_GLOBAL_ENUM_CONSTANT(KEY_SSHARP); + + BIND_GLOBAL_ENUM_CONSTANT(KEY_DIVISION); + BIND_GLOBAL_ENUM_CONSTANT(KEY_YDIAERESIS); + + BIND_GLOBAL_ENUM_CONSTANT(KEY_CODE_MASK); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MODIFIER_MASK); + + BIND_GLOBAL_ENUM_CONSTANT(KEY_MASK_SHIFT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MASK_ALT); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MASK_META); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MASK_CTRL); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MASK_CMD); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MASK_KPAD); + BIND_GLOBAL_ENUM_CONSTANT(KEY_MASK_GROUP_SWITCH); // mouse - BIND_GLOBAL_CONSTANT(BUTTON_LEFT), - BIND_GLOBAL_CONSTANT(BUTTON_RIGHT), - BIND_GLOBAL_CONSTANT(BUTTON_MIDDLE), - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_UP), - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_DOWN), - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_LEFT), - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_RIGHT), - BIND_GLOBAL_CONSTANT(BUTTON_MASK_LEFT), - BIND_GLOBAL_CONSTANT(BUTTON_MASK_RIGHT), - BIND_GLOBAL_CONSTANT(BUTTON_MASK_MIDDLE), + BIND_GLOBAL_CONSTANT(BUTTON_LEFT); + BIND_GLOBAL_CONSTANT(BUTTON_RIGHT); + BIND_GLOBAL_CONSTANT(BUTTON_MIDDLE); + BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_UP); + BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_DOWN); + BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_LEFT); + BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_RIGHT); + BIND_GLOBAL_CONSTANT(BUTTON_MASK_LEFT); + BIND_GLOBAL_CONSTANT(BUTTON_MASK_RIGHT); + BIND_GLOBAL_CONSTANT(BUTTON_MASK_MIDDLE); //joypads - BIND_GLOBAL_CONSTANT(JOY_BUTTON_0), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_1), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_2), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_3), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_4), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_5), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_6), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_7), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_8), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_9), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_10), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_11), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_12), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_13), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_14), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_15), - BIND_GLOBAL_CONSTANT(JOY_BUTTON_MAX), - - BIND_GLOBAL_CONSTANT(JOY_SONY_CIRCLE), - BIND_GLOBAL_CONSTANT(JOY_SONY_X), - BIND_GLOBAL_CONSTANT(JOY_SONY_SQUARE), - BIND_GLOBAL_CONSTANT(JOY_SONY_TRIANGLE), - - BIND_GLOBAL_CONSTANT(JOY_XBOX_B), - BIND_GLOBAL_CONSTANT(JOY_XBOX_A), - BIND_GLOBAL_CONSTANT(JOY_XBOX_X), - BIND_GLOBAL_CONSTANT(JOY_XBOX_Y), - - BIND_GLOBAL_CONSTANT(JOY_DS_A), - BIND_GLOBAL_CONSTANT(JOY_DS_B), - BIND_GLOBAL_CONSTANT(JOY_DS_X), - BIND_GLOBAL_CONSTANT(JOY_DS_Y), - - BIND_GLOBAL_CONSTANT(JOY_SELECT), - BIND_GLOBAL_CONSTANT(JOY_START), - BIND_GLOBAL_CONSTANT(JOY_DPAD_UP), - BIND_GLOBAL_CONSTANT(JOY_DPAD_DOWN), - BIND_GLOBAL_CONSTANT(JOY_DPAD_LEFT), - BIND_GLOBAL_CONSTANT(JOY_DPAD_RIGHT), - BIND_GLOBAL_CONSTANT(JOY_L), - BIND_GLOBAL_CONSTANT(JOY_L2), - BIND_GLOBAL_CONSTANT(JOY_L3), - BIND_GLOBAL_CONSTANT(JOY_R), - BIND_GLOBAL_CONSTANT(JOY_R2), - BIND_GLOBAL_CONSTANT(JOY_R3), - - BIND_GLOBAL_CONSTANT(JOY_AXIS_0), - BIND_GLOBAL_CONSTANT(JOY_AXIS_1), - BIND_GLOBAL_CONSTANT(JOY_AXIS_2), - BIND_GLOBAL_CONSTANT(JOY_AXIS_3), - BIND_GLOBAL_CONSTANT(JOY_AXIS_4), - BIND_GLOBAL_CONSTANT(JOY_AXIS_5), - BIND_GLOBAL_CONSTANT(JOY_AXIS_6), - BIND_GLOBAL_CONSTANT(JOY_AXIS_7), - BIND_GLOBAL_CONSTANT(JOY_AXIS_MAX), - - BIND_GLOBAL_CONSTANT(JOY_ANALOG_LX), - BIND_GLOBAL_CONSTANT(JOY_ANALOG_LY), - - BIND_GLOBAL_CONSTANT(JOY_ANALOG_RX), - BIND_GLOBAL_CONSTANT(JOY_ANALOG_RY), - - BIND_GLOBAL_CONSTANT(JOY_ANALOG_L2), - BIND_GLOBAL_CONSTANT(JOY_ANALOG_R2), + BIND_GLOBAL_CONSTANT(JOY_BUTTON_0); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_1); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_2); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_3); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_4); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_5); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_6); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_7); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_8); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_9); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_10); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_11); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_12); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_13); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_14); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_15); + BIND_GLOBAL_CONSTANT(JOY_BUTTON_MAX); + + BIND_GLOBAL_CONSTANT(JOY_SONY_CIRCLE); + BIND_GLOBAL_CONSTANT(JOY_SONY_X); + BIND_GLOBAL_CONSTANT(JOY_SONY_SQUARE); + BIND_GLOBAL_CONSTANT(JOY_SONY_TRIANGLE); + + BIND_GLOBAL_CONSTANT(JOY_XBOX_B); + BIND_GLOBAL_CONSTANT(JOY_XBOX_A); + BIND_GLOBAL_CONSTANT(JOY_XBOX_X); + BIND_GLOBAL_CONSTANT(JOY_XBOX_Y); + + BIND_GLOBAL_CONSTANT(JOY_DS_A); + BIND_GLOBAL_CONSTANT(JOY_DS_B); + BIND_GLOBAL_CONSTANT(JOY_DS_X); + BIND_GLOBAL_CONSTANT(JOY_DS_Y); + + BIND_GLOBAL_CONSTANT(JOY_SELECT); + BIND_GLOBAL_CONSTANT(JOY_START); + BIND_GLOBAL_CONSTANT(JOY_DPAD_UP); + BIND_GLOBAL_CONSTANT(JOY_DPAD_DOWN); + BIND_GLOBAL_CONSTANT(JOY_DPAD_LEFT); + BIND_GLOBAL_CONSTANT(JOY_DPAD_RIGHT); + BIND_GLOBAL_CONSTANT(JOY_L); + BIND_GLOBAL_CONSTANT(JOY_L2); + BIND_GLOBAL_CONSTANT(JOY_L3); + BIND_GLOBAL_CONSTANT(JOY_R); + BIND_GLOBAL_CONSTANT(JOY_R2); + BIND_GLOBAL_CONSTANT(JOY_R3); + + BIND_GLOBAL_CONSTANT(JOY_AXIS_0); + BIND_GLOBAL_CONSTANT(JOY_AXIS_1); + BIND_GLOBAL_CONSTANT(JOY_AXIS_2); + BIND_GLOBAL_CONSTANT(JOY_AXIS_3); + BIND_GLOBAL_CONSTANT(JOY_AXIS_4); + BIND_GLOBAL_CONSTANT(JOY_AXIS_5); + BIND_GLOBAL_CONSTANT(JOY_AXIS_6); + BIND_GLOBAL_CONSTANT(JOY_AXIS_7); + BIND_GLOBAL_CONSTANT(JOY_AXIS_MAX); + + BIND_GLOBAL_CONSTANT(JOY_ANALOG_LX); + BIND_GLOBAL_CONSTANT(JOY_ANALOG_LY); + + BIND_GLOBAL_CONSTANT(JOY_ANALOG_RX); + BIND_GLOBAL_CONSTANT(JOY_ANALOG_RY); + + BIND_GLOBAL_CONSTANT(JOY_ANALOG_L2); + BIND_GLOBAL_CONSTANT(JOY_ANALOG_R2); // error list - BIND_GLOBAL_CONSTANT(OK), - BIND_GLOBAL_CONSTANT(FAILED), ///< Generic fail error - BIND_GLOBAL_CONSTANT(ERR_UNAVAILABLE), ///< What is requested is unsupported/unavailable - BIND_GLOBAL_CONSTANT(ERR_UNCONFIGURED), ///< The object being used hasn't been properly set up yet - BIND_GLOBAL_CONSTANT(ERR_UNAUTHORIZED), ///< Missing credentials for requested resource - BIND_GLOBAL_CONSTANT(ERR_PARAMETER_RANGE_ERROR), ///< Parameter given out of range - BIND_GLOBAL_CONSTANT(ERR_OUT_OF_MEMORY), ///< Out of memory - BIND_GLOBAL_CONSTANT(ERR_FILE_NOT_FOUND), - BIND_GLOBAL_CONSTANT(ERR_FILE_BAD_DRIVE), - BIND_GLOBAL_CONSTANT(ERR_FILE_BAD_PATH), - BIND_GLOBAL_CONSTANT(ERR_FILE_NO_PERMISSION), - BIND_GLOBAL_CONSTANT(ERR_FILE_ALREADY_IN_USE), - BIND_GLOBAL_CONSTANT(ERR_FILE_CANT_OPEN), - BIND_GLOBAL_CONSTANT(ERR_FILE_CANT_WRITE), - BIND_GLOBAL_CONSTANT(ERR_FILE_CANT_READ), - BIND_GLOBAL_CONSTANT(ERR_FILE_UNRECOGNIZED), - BIND_GLOBAL_CONSTANT(ERR_FILE_CORRUPT), - BIND_GLOBAL_CONSTANT(ERR_FILE_MISSING_DEPENDENCIES), - BIND_GLOBAL_CONSTANT(ERR_FILE_EOF), - BIND_GLOBAL_CONSTANT(ERR_CANT_OPEN), ///< Can't open a resource/socket/file - BIND_GLOBAL_CONSTANT(ERR_CANT_CREATE), - BIND_GLOBAL_CONSTANT(ERR_PARSE_ERROR), - BIND_GLOBAL_CONSTANT(ERR_QUERY_FAILED), - BIND_GLOBAL_CONSTANT(ERR_ALREADY_IN_USE), - BIND_GLOBAL_CONSTANT(ERR_LOCKED), ///< resource is locked - BIND_GLOBAL_CONSTANT(ERR_TIMEOUT), - BIND_GLOBAL_CONSTANT(ERR_CANT_AQUIRE_RESOURCE), - BIND_GLOBAL_CONSTANT(ERR_INVALID_DATA), ///< Data passed is invalid - BIND_GLOBAL_CONSTANT(ERR_INVALID_PARAMETER), ///< Parameter passed is invalid - BIND_GLOBAL_CONSTANT(ERR_ALREADY_EXISTS), ///< When adding ), item already exists - BIND_GLOBAL_CONSTANT(ERR_DOES_NOT_EXIST), ///< When retrieving/erasing ), it item does not exist - BIND_GLOBAL_CONSTANT(ERR_DATABASE_CANT_READ), ///< database is full - BIND_GLOBAL_CONSTANT(ERR_DATABASE_CANT_WRITE), ///< database is full - BIND_GLOBAL_CONSTANT(ERR_COMPILATION_FAILED), - BIND_GLOBAL_CONSTANT(ERR_METHOD_NOT_FOUND), - BIND_GLOBAL_CONSTANT(ERR_LINK_FAILED), - BIND_GLOBAL_CONSTANT(ERR_SCRIPT_FAILED), - BIND_GLOBAL_CONSTANT(ERR_CYCLIC_LINK), - BIND_GLOBAL_CONSTANT(ERR_BUSY), - BIND_GLOBAL_CONSTANT(ERR_HELP), ///< user requested help!! - BIND_GLOBAL_CONSTANT(ERR_BUG), ///< a bug in the software certainly happened ), due to a double check failing or unexpected behavior. - BIND_GLOBAL_CONSTANT(ERR_WTF), - - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_NONE), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_RANGE), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_EXP_RANGE), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_ENUM), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_EXP_EASING), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_LENGTH), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_KEY_ACCEL), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_FLAGS), - - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_LAYERS_2D_RENDER), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_LAYERS_2D_PHYSICS), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_LAYERS_3D_RENDER), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_LAYERS_3D_PHYSICS), - - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_FILE), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_DIR), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_GLOBAL_FILE), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_GLOBAL_DIR), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_RESOURCE_TYPE), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_MULTILINE_TEXT), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_COLOR_NO_ALPHA), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_IMAGE_COMPRESS_LOSSY), - BIND_GLOBAL_CONSTANT(PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS), - - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_STORAGE), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_EDITOR), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_NETWORK), - - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_EDITOR_HELPER), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_CHECKABLE), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_CHECKED), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_INTERNATIONALIZED), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_GROUP), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_CATEGORY), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_STORE_IF_NONZERO), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_STORE_IF_NONONE), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_NO_INSTANCE_STATE), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_RESTART_IF_CHANGED), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_SCRIPT_VARIABLE), - - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_DEFAULT), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_DEFAULT_INTL), - BIND_GLOBAL_CONSTANT(PROPERTY_USAGE_NOEDITOR), - - BIND_GLOBAL_CONSTANT(METHOD_FLAG_NORMAL), - BIND_GLOBAL_CONSTANT(METHOD_FLAG_EDITOR), - BIND_GLOBAL_CONSTANT(METHOD_FLAG_NOSCRIPT), - BIND_GLOBAL_CONSTANT(METHOD_FLAG_CONST), - BIND_GLOBAL_CONSTANT(METHOD_FLAG_REVERSE), - BIND_GLOBAL_CONSTANT(METHOD_FLAG_VIRTUAL), - BIND_GLOBAL_CONSTANT(METHOD_FLAG_FROM_SCRIPT), - BIND_GLOBAL_CONSTANT(METHOD_FLAGS_DEFAULT), - - { "TYPE_NIL", Variant::NIL }, - { "TYPE_BOOL", Variant::BOOL }, - { "TYPE_INT", Variant::INT }, - { "TYPE_REAL", Variant::REAL }, - { "TYPE_STRING", Variant::STRING }, - { "TYPE_VECTOR2", Variant::VECTOR2 }, // 5 - { "TYPE_RECT2", Variant::RECT2 }, - { "TYPE_VECTOR3", Variant::VECTOR3 }, - { "TYPE_TRANSFORM2D", Variant::TRANSFORM2D }, - { "TYPE_PLANE", Variant::PLANE }, - { "TYPE_QUAT", Variant::QUAT }, // 10 - { "TYPE_RECT3", Variant::RECT3 }, - { "TYPE_BASIS", Variant::BASIS }, - { "TYPE_TRANSFORM", Variant::TRANSFORM }, - { "TYPE_COLOR", Variant::COLOR }, - { "TYPE_NODE_PATH", Variant::NODE_PATH }, // 15 - { "TYPE_RID", Variant::_RID }, - { "TYPE_OBJECT", Variant::OBJECT }, - { "TYPE_DICTIONARY", Variant::DICTIONARY }, // 20 - { "TYPE_ARRAY", Variant::ARRAY }, - { "TYPE_RAW_ARRAY", Variant::POOL_BYTE_ARRAY }, - { "TYPE_INT_ARRAY", Variant::POOL_INT_ARRAY }, - { "TYPE_REAL_ARRAY", Variant::POOL_REAL_ARRAY }, - { "TYPE_STRING_ARRAY", Variant::POOL_STRING_ARRAY }, - { "TYPE_VECTOR2_ARRAY", Variant::POOL_VECTOR2_ARRAY }, // 25 - { "TYPE_VECTOR3_ARRAY", Variant::POOL_VECTOR3_ARRAY }, - { "TYPE_COLOR_ARRAY", Variant::POOL_COLOR_ARRAY }, - { "TYPE_MAX", Variant::VARIANT_MAX }, - { NULL, 0 } + BIND_GLOBAL_ENUM_CONSTANT(OK); + BIND_GLOBAL_ENUM_CONSTANT(FAILED); ///< Generic fail error + BIND_GLOBAL_ENUM_CONSTANT(ERR_UNAVAILABLE); ///< What is requested is unsupported/unavailable + BIND_GLOBAL_ENUM_CONSTANT(ERR_UNCONFIGURED); ///< The object being used hasn't been properly set up yet + BIND_GLOBAL_ENUM_CONSTANT(ERR_UNAUTHORIZED); ///< Missing credentials for requested resource + BIND_GLOBAL_ENUM_CONSTANT(ERR_PARAMETER_RANGE_ERROR); ///< Parameter given out of range + BIND_GLOBAL_ENUM_CONSTANT(ERR_OUT_OF_MEMORY); ///< Out of memory + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_NOT_FOUND); + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_BAD_DRIVE); + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_BAD_PATH); + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_NO_PERMISSION); + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_ALREADY_IN_USE); + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CANT_OPEN); + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CANT_WRITE); + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CANT_READ); + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_UNRECOGNIZED); + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_CORRUPT); + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_MISSING_DEPENDENCIES); + BIND_GLOBAL_ENUM_CONSTANT(ERR_FILE_EOF); + BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_OPEN); ///< Can't open a resource/socket/file + BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_CREATE); + BIND_GLOBAL_ENUM_CONSTANT(ERR_PARSE_ERROR); + BIND_GLOBAL_ENUM_CONSTANT(ERR_QUERY_FAILED); + BIND_GLOBAL_ENUM_CONSTANT(ERR_ALREADY_IN_USE); + BIND_GLOBAL_ENUM_CONSTANT(ERR_LOCKED); ///< resource is locked + BIND_GLOBAL_ENUM_CONSTANT(ERR_TIMEOUT); + BIND_GLOBAL_ENUM_CONSTANT(ERR_CANT_AQUIRE_RESOURCE); + BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_DATA); ///< Data passed is invalid + BIND_GLOBAL_ENUM_CONSTANT(ERR_INVALID_PARAMETER); ///< Parameter passed is invalid + BIND_GLOBAL_ENUM_CONSTANT(ERR_ALREADY_EXISTS); ///< When adding ), item already exists + BIND_GLOBAL_ENUM_CONSTANT(ERR_DOES_NOT_EXIST); ///< When retrieving/erasing ), it item does not exist + BIND_GLOBAL_ENUM_CONSTANT(ERR_DATABASE_CANT_READ); ///< database is full + BIND_GLOBAL_ENUM_CONSTANT(ERR_DATABASE_CANT_WRITE); ///< database is full + BIND_GLOBAL_ENUM_CONSTANT(ERR_COMPILATION_FAILED); + BIND_GLOBAL_ENUM_CONSTANT(ERR_METHOD_NOT_FOUND); + BIND_GLOBAL_ENUM_CONSTANT(ERR_LINK_FAILED); + BIND_GLOBAL_ENUM_CONSTANT(ERR_SCRIPT_FAILED); + BIND_GLOBAL_ENUM_CONSTANT(ERR_CYCLIC_LINK); + BIND_GLOBAL_ENUM_CONSTANT(ERR_BUSY); + BIND_GLOBAL_ENUM_CONSTANT(ERR_HELP); ///< user requested help!! + BIND_GLOBAL_ENUM_CONSTANT(ERR_BUG); ///< a bug in the software certainly happened ), due to a double check failing or unexpected behavior. + BIND_GLOBAL_ENUM_CONSTANT(ERR_WTF); + + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_NONE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_RANGE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_EXP_RANGE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_ENUM); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_EXP_EASING); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_LENGTH); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_KEY_ACCEL); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_FLAGS); + + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_LAYERS_2D_RENDER); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_LAYERS_2D_PHYSICS); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_LAYERS_3D_RENDER); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_LAYERS_3D_PHYSICS); + + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_FILE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_DIR); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_GLOBAL_FILE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_GLOBAL_DIR); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_RESOURCE_TYPE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_MULTILINE_TEXT); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_COLOR_NO_ALPHA); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_IMAGE_COMPRESS_LOSSY); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS); + + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_STORAGE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_EDITOR); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_NETWORK); + + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_EDITOR_HELPER); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_CHECKABLE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_CHECKED); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_INTERNATIONALIZED); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_GROUP); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_CATEGORY); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_STORE_IF_NONZERO); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_STORE_IF_NONONE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_NO_INSTANCE_STATE); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_RESTART_IF_CHANGED); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_SCRIPT_VARIABLE); + + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_DEFAULT); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_DEFAULT_INTL); + BIND_GLOBAL_ENUM_CONSTANT(PROPERTY_USAGE_NOEDITOR); + + BIND_GLOBAL_ENUM_CONSTANT(METHOD_FLAG_NORMAL); + BIND_GLOBAL_ENUM_CONSTANT(METHOD_FLAG_EDITOR); + BIND_GLOBAL_ENUM_CONSTANT(METHOD_FLAG_NOSCRIPT); + BIND_GLOBAL_ENUM_CONSTANT(METHOD_FLAG_CONST); + BIND_GLOBAL_ENUM_CONSTANT(METHOD_FLAG_REVERSE); + BIND_GLOBAL_ENUM_CONSTANT(METHOD_FLAG_VIRTUAL); + BIND_GLOBAL_ENUM_CONSTANT(METHOD_FLAG_FROM_SCRIPT); + BIND_GLOBAL_ENUM_CONSTANT(METHOD_FLAGS_DEFAULT); + + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_NIL", Variant::NIL); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BOOL", Variant::BOOL); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT", Variant::INT); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_REAL", Variant::REAL); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING", Variant::STRING); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2", Variant::VECTOR2); // 5 + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RECT2", Variant::RECT2); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3", Variant::VECTOR3); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM2D", Variant::TRANSFORM2D); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_PLANE", Variant::PLANE); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_QUAT", Variant::QUAT); // 10 + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RECT3", Variant::RECT3); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BASIS", Variant::BASIS); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM", Variant::TRANSFORM); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR", Variant::COLOR); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_NODE_PATH", Variant::NODE_PATH); // 15 + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RID", Variant::_RID); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_OBJECT", Variant::OBJECT); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_DICTIONARY", Variant::DICTIONARY); // 20 + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_ARRAY", Variant::ARRAY); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RAW_ARRAY", Variant::POOL_BYTE_ARRAY); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_INT_ARRAY", Variant::POOL_INT_ARRAY); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_REAL_ARRAY", Variant::POOL_REAL_ARRAY); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_STRING_ARRAY", Variant::POOL_STRING_ARRAY); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR2_ARRAY", Variant::POOL_VECTOR2_ARRAY); // 25 + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_VECTOR3_ARRAY", Variant::POOL_VECTOR3_ARRAY); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR_ARRAY", Variant::POOL_COLOR_ARRAY); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_MAX", Variant::VARIANT_MAX); +} -}; +void unregister_global_constants() { + + _global_constants.clear(); +} int GlobalConstants::get_global_constant_count() { - int i = 0; - while (_global_constants[i].name) - i++; - return i; + return _global_constants.size(); +} + +#ifdef DEBUG_METHODS_ENABLED +StringName GlobalConstants::get_global_constant_enum(int p_idx) { + + return _global_constants[p_idx].enum_name; +} +#else +StringName GlobalConstants::get_global_constant_enum(int p_idx) { + + return StringName(); } +#endif const char *GlobalConstants::get_global_constant_name(int p_idx) { diff --git a/core/global_constants.h b/core/global_constants.h index f298fc31c7..350018e336 100644 --- a/core/global_constants.h +++ b/core/global_constants.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -30,9 +30,12 @@ #ifndef GLOBAL_CONSTANTS_H #define GLOBAL_CONSTANTS_H +#include "string_db.h" + class GlobalConstants { public: static int get_global_constant_count(); + static StringName get_global_constant_enum(int p_idx); static const char *get_global_constant_name(int p_idx); static int get_global_constant_value(int p_idx); }; diff --git a/core/hash_map.h b/core/hash_map.h index 2d7249e2fc..b22c6378b0 100644 --- a/core/hash_map.h +++ b/core/hash_map.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/hashfuncs.h b/core/hashfuncs.h index 8392984565..56d40f1dd7 100644 --- a/core/hashfuncs.h +++ b/core/hashfuncs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/helper/math_fieldwise.cpp b/core/helper/math_fieldwise.cpp index 5545c2d642..2ce2a70866 100644 --- a/core/helper/math_fieldwise.cpp +++ b/core/helper/math_fieldwise.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/helper/math_fieldwise.h b/core/helper/math_fieldwise.h index 58489fd3bb..4671703f41 100644 --- a/core/helper/math_fieldwise.h +++ b/core/helper/math_fieldwise.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/helper/value_evaluator.h b/core/helper/value_evaluator.h index e32697ca95..bb234de989 100644 --- a/core/helper/value_evaluator.h +++ b/core/helper/value_evaluator.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/image.cpp b/core/image.cpp index 2db9cb1571..bb1ce2cee3 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -343,6 +343,11 @@ int Image::get_height() const { return height; } +Vector2 Image::get_size() const { + + return Vector2(width, height); +} + bool Image::has_mipmaps() const { return mipmaps; @@ -676,8 +681,8 @@ void Image::resize_to_po2(bool p_square) { ERR_FAIL(); } - int w = nearest_power_of_2(width); - int h = nearest_power_of_2(height); + int w = next_power_of_2(width); + int h = next_power_of_2(height); if (w == width && h == height) { @@ -1060,7 +1065,7 @@ Error Image::generate_mipmaps() { PoolVector<uint8_t>::Write wp = data.write(); - if (nearest_power_of_2(width) == uint32_t(width) && nearest_power_of_2(height) == uint32_t(height)) { + if (next_power_of_2(width) == uint32_t(width) && next_power_of_2(height) == uint32_t(height)) { //use fast code for powers of 2 int prev_ofs = 0; int prev_h = height; @@ -2215,6 +2220,7 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("get_width"), &Image::get_width); ClassDB::bind_method(D_METHOD("get_height"), &Image::get_height); + ClassDB::bind_method(D_METHOD("get_size"), &Image::get_size); ClassDB::bind_method(D_METHOD("has_mipmaps"), &Image::has_mipmaps); ClassDB::bind_method(D_METHOD("get_format"), &Image::get_format); ClassDB::bind_method(D_METHOD("get_data"), &Image::get_data); @@ -2275,62 +2281,62 @@ void Image::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "_set_data", "_get_data"); - BIND_CONSTANT(FORMAT_L8); //luminance - BIND_CONSTANT(FORMAT_LA8); //luminance-alpha - BIND_CONSTANT(FORMAT_R8); - BIND_CONSTANT(FORMAT_RG8); - BIND_CONSTANT(FORMAT_RGB8); - BIND_CONSTANT(FORMAT_RGBA8); - BIND_CONSTANT(FORMAT_RGBA4444); - BIND_CONSTANT(FORMAT_RGBA5551); - BIND_CONSTANT(FORMAT_RF); //float - BIND_CONSTANT(FORMAT_RGF); - BIND_CONSTANT(FORMAT_RGBF); - BIND_CONSTANT(FORMAT_RGBAF); - BIND_CONSTANT(FORMAT_RH); //half float - BIND_CONSTANT(FORMAT_RGH); - BIND_CONSTANT(FORMAT_RGBH); - BIND_CONSTANT(FORMAT_RGBAH); - BIND_CONSTANT(FORMAT_RGBE9995); - BIND_CONSTANT(FORMAT_DXT1); //s3tc bc1 - BIND_CONSTANT(FORMAT_DXT3); //bc2 - BIND_CONSTANT(FORMAT_DXT5); //bc3 - BIND_CONSTANT(FORMAT_RGTC_R); - BIND_CONSTANT(FORMAT_RGTC_RG); - BIND_CONSTANT(FORMAT_BPTC_RGBA); //btpc bc6h - BIND_CONSTANT(FORMAT_BPTC_RGBF); //float / - BIND_CONSTANT(FORMAT_BPTC_RGBFU); //unsigned float - BIND_CONSTANT(FORMAT_PVRTC2); //pvrtc - BIND_CONSTANT(FORMAT_PVRTC2A); - BIND_CONSTANT(FORMAT_PVRTC4); - BIND_CONSTANT(FORMAT_PVRTC4A); - BIND_CONSTANT(FORMAT_ETC); //etc1 - BIND_CONSTANT(FORMAT_ETC2_R11); //etc2 - BIND_CONSTANT(FORMAT_ETC2_R11S); //signed ); NOT srgb. - BIND_CONSTANT(FORMAT_ETC2_RG11); - BIND_CONSTANT(FORMAT_ETC2_RG11S); - BIND_CONSTANT(FORMAT_ETC2_RGB8); - BIND_CONSTANT(FORMAT_ETC2_RGBA8); - BIND_CONSTANT(FORMAT_ETC2_RGB8A1); - BIND_CONSTANT(FORMAT_MAX); - - BIND_CONSTANT(INTERPOLATE_NEAREST); - BIND_CONSTANT(INTERPOLATE_BILINEAR); - BIND_CONSTANT(INTERPOLATE_CUBIC); - - BIND_CONSTANT(ALPHA_NONE); - BIND_CONSTANT(ALPHA_BIT); - BIND_CONSTANT(ALPHA_BLEND); - - BIND_CONSTANT(COMPRESS_S3TC); - BIND_CONSTANT(COMPRESS_PVRTC2); - BIND_CONSTANT(COMPRESS_PVRTC4); - BIND_CONSTANT(COMPRESS_ETC); - BIND_CONSTANT(COMPRESS_ETC2); - - BIND_CONSTANT(COMPRESS_SOURCE_GENERIC); - BIND_CONSTANT(COMPRESS_SOURCE_SRGB); - BIND_CONSTANT(COMPRESS_SOURCE_NORMAL); + BIND_ENUM_CONSTANT(FORMAT_L8); //luminance + BIND_ENUM_CONSTANT(FORMAT_LA8); //luminance-alpha + BIND_ENUM_CONSTANT(FORMAT_R8); + BIND_ENUM_CONSTANT(FORMAT_RG8); + BIND_ENUM_CONSTANT(FORMAT_RGB8); + BIND_ENUM_CONSTANT(FORMAT_RGBA8); + BIND_ENUM_CONSTANT(FORMAT_RGBA4444); + BIND_ENUM_CONSTANT(FORMAT_RGBA5551); + BIND_ENUM_CONSTANT(FORMAT_RF); //float + BIND_ENUM_CONSTANT(FORMAT_RGF); + BIND_ENUM_CONSTANT(FORMAT_RGBF); + BIND_ENUM_CONSTANT(FORMAT_RGBAF); + BIND_ENUM_CONSTANT(FORMAT_RH); //half float + BIND_ENUM_CONSTANT(FORMAT_RGH); + BIND_ENUM_CONSTANT(FORMAT_RGBH); + BIND_ENUM_CONSTANT(FORMAT_RGBAH); + BIND_ENUM_CONSTANT(FORMAT_RGBE9995); + BIND_ENUM_CONSTANT(FORMAT_DXT1); //s3tc bc1 + BIND_ENUM_CONSTANT(FORMAT_DXT3); //bc2 + BIND_ENUM_CONSTANT(FORMAT_DXT5); //bc3 + BIND_ENUM_CONSTANT(FORMAT_RGTC_R); + BIND_ENUM_CONSTANT(FORMAT_RGTC_RG); + BIND_ENUM_CONSTANT(FORMAT_BPTC_RGBA); //btpc bc6h + BIND_ENUM_CONSTANT(FORMAT_BPTC_RGBF); //float / + BIND_ENUM_CONSTANT(FORMAT_BPTC_RGBFU); //unsigned float + BIND_ENUM_CONSTANT(FORMAT_PVRTC2); //pvrtc + BIND_ENUM_CONSTANT(FORMAT_PVRTC2A); + BIND_ENUM_CONSTANT(FORMAT_PVRTC4); + BIND_ENUM_CONSTANT(FORMAT_PVRTC4A); + BIND_ENUM_CONSTANT(FORMAT_ETC); //etc1 + BIND_ENUM_CONSTANT(FORMAT_ETC2_R11); //etc2 + BIND_ENUM_CONSTANT(FORMAT_ETC2_R11S); //signed ); NOT srgb. + BIND_ENUM_CONSTANT(FORMAT_ETC2_RG11); + BIND_ENUM_CONSTANT(FORMAT_ETC2_RG11S); + BIND_ENUM_CONSTANT(FORMAT_ETC2_RGB8); + BIND_ENUM_CONSTANT(FORMAT_ETC2_RGBA8); + BIND_ENUM_CONSTANT(FORMAT_ETC2_RGB8A1); + BIND_ENUM_CONSTANT(FORMAT_MAX); + + BIND_ENUM_CONSTANT(INTERPOLATE_NEAREST); + BIND_ENUM_CONSTANT(INTERPOLATE_BILINEAR); + BIND_ENUM_CONSTANT(INTERPOLATE_CUBIC); + + BIND_ENUM_CONSTANT(ALPHA_NONE); + BIND_ENUM_CONSTANT(ALPHA_BIT); + BIND_ENUM_CONSTANT(ALPHA_BLEND); + + BIND_ENUM_CONSTANT(COMPRESS_S3TC); + BIND_ENUM_CONSTANT(COMPRESS_PVRTC2); + BIND_ENUM_CONSTANT(COMPRESS_PVRTC4); + BIND_ENUM_CONSTANT(COMPRESS_ETC); + BIND_ENUM_CONSTANT(COMPRESS_ETC2); + + BIND_ENUM_CONSTANT(COMPRESS_SOURCE_GENERIC); + BIND_ENUM_CONSTANT(COMPRESS_SOURCE_SRGB); + BIND_ENUM_CONSTANT(COMPRESS_SOURCE_NORMAL); } void Image::set_compress_bc_func(void (*p_compress_func)(Image *, CompressSource)) { diff --git a/core/image.h b/core/image.h index 7acc4744e9..27df65a898 100644 --- a/core/image.h +++ b/core/image.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -177,6 +177,7 @@ private: public: int get_width() const; ///< Get image width int get_height() const; ///< Get image height + Vector2 get_size() const; bool has_mipmaps() const; int get_mipmap_count() const; diff --git a/core/input_map.cpp b/core/input_map.cpp index 8435882325..82a2eaddae 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/input_map.h b/core/input_map.h index ba93e61f5f..18e6b04d4e 100644 --- a/core/input_map.h +++ b/core/input_map.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/int_types.h b/core/int_types.h index 973e0c749d..e9bcc88ee8 100644 --- a/core/int_types.h +++ b/core/int_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/compression.cpp b/core/io/compression.cpp index 139383710c..44fa65e11d 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/compression.h b/core/io/compression.h index 5eb7806d7b..22d8109d4f 100644 --- a/core/io/compression.h +++ b/core/io/compression.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index edd090adf2..daa6b01d6e 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/config_file.h b/core/io/config_file.h index 75a3a519a6..8ed8a069e4 100644 --- a/core/io/config_file.h +++ b/core/io/config_file.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_buffered.cpp b/core/io/file_access_buffered.cpp index 126ec7575e..859f2e3f8c 100644 --- a/core/io/file_access_buffered.cpp +++ b/core/io/file_access_buffered.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_buffered.h b/core/io/file_access_buffered.h index 0ad2d0e929..d3137058fb 100644 --- a/core/io/file_access_buffered.h +++ b/core/io/file_access_buffered.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h index 362589adf1..9e41834561 100644 --- a/core/io/file_access_buffered_fa.h +++ b/core/io/file_access_buffered_fa.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp index 4e802579c6..70430ca5d3 100644 --- a/core/io/file_access_compressed.cpp +++ b/core/io/file_access_compressed.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -43,16 +43,16 @@ void FileAccessCompressed::configure(const String &p_magic, Compression::Mode p_ block_size = p_block_size; } -#define WRITE_FIT(m_bytes) \ - { \ - if (write_pos + (m_bytes) > write_max) { \ - write_max = write_pos + (m_bytes); \ - } \ - if (write_max > write_buffer_size) { \ - write_buffer_size = nearest_power_of_2(write_max); \ - buffer.resize(write_buffer_size); \ - write_ptr = buffer.ptr(); \ - } \ +#define WRITE_FIT(m_bytes) \ + { \ + if (write_pos + (m_bytes) > write_max) { \ + write_max = write_pos + (m_bytes); \ + } \ + if (write_max > write_buffer_size) { \ + write_buffer_size = next_power_of_2(write_max); \ + buffer.resize(write_buffer_size); \ + write_ptr = buffer.ptr(); \ + } \ } Error FileAccessCompressed::open_after_magic(FileAccess *p_base) { @@ -368,7 +368,6 @@ FileAccessCompressed::FileAccessCompressed() { f = NULL; magic = "GCMP"; - block_size = 16384; cmode = Compression::MODE_ZSTD; writing = false; write_ptr = 0; diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h index 340c298a0f..2fe1428752 100644 --- a/core/io/file_access_compressed.h +++ b/core/io/file_access_compressed.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index f2b33a01bb..cf82d04ac5 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h index 2bd3c52661..3df2806a7a 100644 --- a/core/io/file_access_encrypted.h +++ b/core/io/file_access_encrypted.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 8e719568e5..5b186b7798 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h index ea858c547e..7feb16461b 100644 --- a/core/io/file_access_memory.h +++ b/core/io/file_access_memory.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index aa67479d7e..be31076557 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index 1e85756122..d6010cdbac 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index c3bcfc840b..e36ff28220 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 25473131d6..758e9afa8e 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index d748d5c773..8c99ef2983 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index c9cc2dac79..2a8ec3fca5 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 4d5b88cfa1..dd56db9bf9 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -650,84 +650,84 @@ void HTTPClient::_bind_methods() { ClassDB::bind_method(D_METHOD("query_string_from_dict", "fields"), &HTTPClient::query_string_from_dict); - BIND_CONSTANT(METHOD_GET); - BIND_CONSTANT(METHOD_HEAD); - BIND_CONSTANT(METHOD_POST); - BIND_CONSTANT(METHOD_PUT); - BIND_CONSTANT(METHOD_DELETE); - BIND_CONSTANT(METHOD_OPTIONS); - BIND_CONSTANT(METHOD_TRACE); - BIND_CONSTANT(METHOD_CONNECT); - BIND_CONSTANT(METHOD_MAX); - - BIND_CONSTANT(STATUS_DISCONNECTED); - BIND_CONSTANT(STATUS_RESOLVING); //resolving hostname (if passed a hostname) - BIND_CONSTANT(STATUS_CANT_RESOLVE); - BIND_CONSTANT(STATUS_CONNECTING); //connecting to ip - BIND_CONSTANT(STATUS_CANT_CONNECT); - BIND_CONSTANT(STATUS_CONNECTED); //connected ); requests only accepted here - BIND_CONSTANT(STATUS_REQUESTING); // request in progress - BIND_CONSTANT(STATUS_BODY); // request resulted in body ); which must be read - BIND_CONSTANT(STATUS_CONNECTION_ERROR); - BIND_CONSTANT(STATUS_SSL_HANDSHAKE_ERROR); - - BIND_CONSTANT(RESPONSE_CONTINUE); - BIND_CONSTANT(RESPONSE_SWITCHING_PROTOCOLS); - BIND_CONSTANT(RESPONSE_PROCESSING); + BIND_ENUM_CONSTANT(METHOD_GET); + BIND_ENUM_CONSTANT(METHOD_HEAD); + BIND_ENUM_CONSTANT(METHOD_POST); + BIND_ENUM_CONSTANT(METHOD_PUT); + BIND_ENUM_CONSTANT(METHOD_DELETE); + BIND_ENUM_CONSTANT(METHOD_OPTIONS); + BIND_ENUM_CONSTANT(METHOD_TRACE); + BIND_ENUM_CONSTANT(METHOD_CONNECT); + BIND_ENUM_CONSTANT(METHOD_MAX); + + BIND_ENUM_CONSTANT(STATUS_DISCONNECTED); + BIND_ENUM_CONSTANT(STATUS_RESOLVING); //resolving hostname (if passed a hostname) + BIND_ENUM_CONSTANT(STATUS_CANT_RESOLVE); + BIND_ENUM_CONSTANT(STATUS_CONNECTING); //connecting to ip + BIND_ENUM_CONSTANT(STATUS_CANT_CONNECT); + BIND_ENUM_CONSTANT(STATUS_CONNECTED); //connected ); requests only accepted here + BIND_ENUM_CONSTANT(STATUS_REQUESTING); // request in progress + BIND_ENUM_CONSTANT(STATUS_BODY); // request resulted in body ); which must be read + BIND_ENUM_CONSTANT(STATUS_CONNECTION_ERROR); + BIND_ENUM_CONSTANT(STATUS_SSL_HANDSHAKE_ERROR); + + BIND_ENUM_CONSTANT(RESPONSE_CONTINUE); + BIND_ENUM_CONSTANT(RESPONSE_SWITCHING_PROTOCOLS); + BIND_ENUM_CONSTANT(RESPONSE_PROCESSING); // 2xx successful - BIND_CONSTANT(RESPONSE_OK); - BIND_CONSTANT(RESPONSE_CREATED); - BIND_CONSTANT(RESPONSE_ACCEPTED); - BIND_CONSTANT(RESPONSE_NON_AUTHORITATIVE_INFORMATION); - BIND_CONSTANT(RESPONSE_NO_CONTENT); - BIND_CONSTANT(RESPONSE_RESET_CONTENT); - BIND_CONSTANT(RESPONSE_PARTIAL_CONTENT); - BIND_CONSTANT(RESPONSE_MULTI_STATUS); - BIND_CONSTANT(RESPONSE_IM_USED); + BIND_ENUM_CONSTANT(RESPONSE_OK); + BIND_ENUM_CONSTANT(RESPONSE_CREATED); + BIND_ENUM_CONSTANT(RESPONSE_ACCEPTED); + BIND_ENUM_CONSTANT(RESPONSE_NON_AUTHORITATIVE_INFORMATION); + BIND_ENUM_CONSTANT(RESPONSE_NO_CONTENT); + BIND_ENUM_CONSTANT(RESPONSE_RESET_CONTENT); + BIND_ENUM_CONSTANT(RESPONSE_PARTIAL_CONTENT); + BIND_ENUM_CONSTANT(RESPONSE_MULTI_STATUS); + BIND_ENUM_CONSTANT(RESPONSE_IM_USED); // 3xx redirection - BIND_CONSTANT(RESPONSE_MULTIPLE_CHOICES); - BIND_CONSTANT(RESPONSE_MOVED_PERMANENTLY); - BIND_CONSTANT(RESPONSE_FOUND); - BIND_CONSTANT(RESPONSE_SEE_OTHER); - BIND_CONSTANT(RESPONSE_NOT_MODIFIED); - BIND_CONSTANT(RESPONSE_USE_PROXY); - BIND_CONSTANT(RESPONSE_TEMPORARY_REDIRECT); + BIND_ENUM_CONSTANT(RESPONSE_MULTIPLE_CHOICES); + BIND_ENUM_CONSTANT(RESPONSE_MOVED_PERMANENTLY); + BIND_ENUM_CONSTANT(RESPONSE_FOUND); + BIND_ENUM_CONSTANT(RESPONSE_SEE_OTHER); + BIND_ENUM_CONSTANT(RESPONSE_NOT_MODIFIED); + BIND_ENUM_CONSTANT(RESPONSE_USE_PROXY); + BIND_ENUM_CONSTANT(RESPONSE_TEMPORARY_REDIRECT); // 4xx client error - BIND_CONSTANT(RESPONSE_BAD_REQUEST); - BIND_CONSTANT(RESPONSE_UNAUTHORIZED); - BIND_CONSTANT(RESPONSE_PAYMENT_REQUIRED); - BIND_CONSTANT(RESPONSE_FORBIDDEN); - BIND_CONSTANT(RESPONSE_NOT_FOUND); - BIND_CONSTANT(RESPONSE_METHOD_NOT_ALLOWED); - BIND_CONSTANT(RESPONSE_NOT_ACCEPTABLE); - BIND_CONSTANT(RESPONSE_PROXY_AUTHENTICATION_REQUIRED); - BIND_CONSTANT(RESPONSE_REQUEST_TIMEOUT); - BIND_CONSTANT(RESPONSE_CONFLICT); - BIND_CONSTANT(RESPONSE_GONE); - BIND_CONSTANT(RESPONSE_LENGTH_REQUIRED); - BIND_CONSTANT(RESPONSE_PRECONDITION_FAILED); - BIND_CONSTANT(RESPONSE_REQUEST_ENTITY_TOO_LARGE); - BIND_CONSTANT(RESPONSE_REQUEST_URI_TOO_LONG); - BIND_CONSTANT(RESPONSE_UNSUPPORTED_MEDIA_TYPE); - BIND_CONSTANT(RESPONSE_REQUESTED_RANGE_NOT_SATISFIABLE); - BIND_CONSTANT(RESPONSE_EXPECTATION_FAILED); - BIND_CONSTANT(RESPONSE_UNPROCESSABLE_ENTITY); - BIND_CONSTANT(RESPONSE_LOCKED); - BIND_CONSTANT(RESPONSE_FAILED_DEPENDENCY); - BIND_CONSTANT(RESPONSE_UPGRADE_REQUIRED); + BIND_ENUM_CONSTANT(RESPONSE_BAD_REQUEST); + BIND_ENUM_CONSTANT(RESPONSE_UNAUTHORIZED); + BIND_ENUM_CONSTANT(RESPONSE_PAYMENT_REQUIRED); + BIND_ENUM_CONSTANT(RESPONSE_FORBIDDEN); + BIND_ENUM_CONSTANT(RESPONSE_NOT_FOUND); + BIND_ENUM_CONSTANT(RESPONSE_METHOD_NOT_ALLOWED); + BIND_ENUM_CONSTANT(RESPONSE_NOT_ACCEPTABLE); + BIND_ENUM_CONSTANT(RESPONSE_PROXY_AUTHENTICATION_REQUIRED); + BIND_ENUM_CONSTANT(RESPONSE_REQUEST_TIMEOUT); + BIND_ENUM_CONSTANT(RESPONSE_CONFLICT); + BIND_ENUM_CONSTANT(RESPONSE_GONE); + BIND_ENUM_CONSTANT(RESPONSE_LENGTH_REQUIRED); + BIND_ENUM_CONSTANT(RESPONSE_PRECONDITION_FAILED); + BIND_ENUM_CONSTANT(RESPONSE_REQUEST_ENTITY_TOO_LARGE); + BIND_ENUM_CONSTANT(RESPONSE_REQUEST_URI_TOO_LONG); + BIND_ENUM_CONSTANT(RESPONSE_UNSUPPORTED_MEDIA_TYPE); + BIND_ENUM_CONSTANT(RESPONSE_REQUESTED_RANGE_NOT_SATISFIABLE); + BIND_ENUM_CONSTANT(RESPONSE_EXPECTATION_FAILED); + BIND_ENUM_CONSTANT(RESPONSE_UNPROCESSABLE_ENTITY); + BIND_ENUM_CONSTANT(RESPONSE_LOCKED); + BIND_ENUM_CONSTANT(RESPONSE_FAILED_DEPENDENCY); + BIND_ENUM_CONSTANT(RESPONSE_UPGRADE_REQUIRED); // 5xx server error - BIND_CONSTANT(RESPONSE_INTERNAL_SERVER_ERROR); - BIND_CONSTANT(RESPONSE_NOT_IMPLEMENTED); - BIND_CONSTANT(RESPONSE_BAD_GATEWAY); - BIND_CONSTANT(RESPONSE_SERVICE_UNAVAILABLE); - BIND_CONSTANT(RESPONSE_GATEWAY_TIMEOUT); - BIND_CONSTANT(RESPONSE_HTTP_VERSION_NOT_SUPPORTED); - BIND_CONSTANT(RESPONSE_INSUFFICIENT_STORAGE); - BIND_CONSTANT(RESPONSE_NOT_EXTENDED); + BIND_ENUM_CONSTANT(RESPONSE_INTERNAL_SERVER_ERROR); + BIND_ENUM_CONSTANT(RESPONSE_NOT_IMPLEMENTED); + BIND_ENUM_CONSTANT(RESPONSE_BAD_GATEWAY); + BIND_ENUM_CONSTANT(RESPONSE_SERVICE_UNAVAILABLE); + BIND_ENUM_CONSTANT(RESPONSE_GATEWAY_TIMEOUT); + BIND_ENUM_CONSTANT(RESPONSE_HTTP_VERSION_NOT_SUPPORTED); + BIND_ENUM_CONSTANT(RESPONSE_INSUFFICIENT_STORAGE); + BIND_ENUM_CONSTANT(RESPONSE_NOT_EXTENDED); } void HTTPClient::set_read_chunk_size(int p_size) { diff --git a/core/io/http_client.h b/core/io/http_client.h index 3cee1e0c6b..023370ae81 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -197,6 +197,7 @@ public: ~HTTPClient(); }; +VARIANT_ENUM_CAST(HTTPClient::ResponseCode) VARIANT_ENUM_CAST(HTTPClient::Method); VARIANT_ENUM_CAST(HTTPClient::Status); diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index 23719940be..637b95ccf8 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -43,7 +43,7 @@ bool ImageFormatLoader::recognize(const String &p_extension) const { return false; } -Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom, bool p_force_linear) { +Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom, bool p_force_linear, float p_scale) { ERR_FAIL_COND_V(p_image.is_null(), ERR_INVALID_PARAMETER); FileAccess *f = p_custom; @@ -62,7 +62,7 @@ Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_c if (!loader[i]->recognize(extension)) continue; - Error err = loader[i]->load_image(p_image, f, p_force_linear); + Error err = loader[i]->load_image(p_image, f, p_force_linear, p_scale); if (err != ERR_FILE_UNRECOGNIZED) { diff --git a/core/io/image_loader.h b/core/io/image_loader.h index e528d1423b..17a89603fa 100644 --- a/core/io/image_loader.h +++ b/core/io/image_loader.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -56,7 +56,7 @@ class ImageFormatLoader { friend class ImageLoader; protected: - virtual Error load_image(Ref<Image> p_image, FileAccess *p_fileaccess, bool p_force_linear) = 0; + virtual Error load_image(Ref<Image> p_image, FileAccess *p_fileaccess, bool p_force_linear, float p_scale) = 0; virtual void get_recognized_extensions(List<String> *p_extensions) const = 0; bool recognize(const String &p_extension) const; @@ -75,7 +75,7 @@ class ImageLoader { protected: public: - static Error load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom = NULL, bool p_force_linear = false); + static Error load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom = NULL, bool p_force_linear = false, float p_scale = 1.0); static void get_recognized_extensions(List<String> *p_extensions); static bool recognize(const String &p_extension); diff --git a/core/io/ip.cpp b/core/io/ip.cpp index c869bdad9b..60a44b2128 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -242,18 +242,18 @@ void IP::_bind_methods() { ClassDB::bind_method(D_METHOD("get_local_addresses"), &IP::_get_local_addresses); ClassDB::bind_method(D_METHOD("clear_cache", "hostname"), &IP::clear_cache, DEFVAL("")); - BIND_CONSTANT(RESOLVER_STATUS_NONE); - BIND_CONSTANT(RESOLVER_STATUS_WAITING); - BIND_CONSTANT(RESOLVER_STATUS_DONE); - BIND_CONSTANT(RESOLVER_STATUS_ERROR); + BIND_ENUM_CONSTANT(RESOLVER_STATUS_NONE); + BIND_ENUM_CONSTANT(RESOLVER_STATUS_WAITING); + BIND_ENUM_CONSTANT(RESOLVER_STATUS_DONE); + BIND_ENUM_CONSTANT(RESOLVER_STATUS_ERROR); BIND_CONSTANT(RESOLVER_MAX_QUERIES); BIND_CONSTANT(RESOLVER_INVALID_ID); - BIND_CONSTANT(TYPE_NONE); - BIND_CONSTANT(TYPE_IPV4); - BIND_CONSTANT(TYPE_IPV6); - BIND_CONSTANT(TYPE_ANY); + BIND_ENUM_CONSTANT(TYPE_NONE); + BIND_ENUM_CONSTANT(TYPE_IPV4); + BIND_ENUM_CONSTANT(TYPE_IPV6); + BIND_ENUM_CONSTANT(TYPE_ANY); } IP *IP::singleton = NULL; diff --git a/core/io/ip.h b/core/io/ip.h index 66a4a48da2..04c6811792 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/ip_address.cpp b/core/io/ip_address.cpp index ea3041945c..da74f6c116 100644 --- a/core/io/ip_address.cpp +++ b/core/io/ip_address.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/ip_address.h b/core/io/ip_address.h index da16622a9b..205efd9a0e 100644 --- a/core/io/ip_address.h +++ b/core/io/ip_address.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/json.cpp b/core/io/json.cpp index d537061c5b..2e9170bc34 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/json.h b/core/io/json.h index 75df15a077..893a88e264 100644 --- a/core/io/json.h +++ b/core/io/json.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 8eb40b61d7..af7db904e9 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -33,8 +33,28 @@ #include "reference.h" #include <stdio.h> +void EncodedObjectAsID::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_object_id", "id"), &EncodedObjectAsID::set_object_id); + ClassDB::bind_method(D_METHOD("get_object_id"), &EncodedObjectAsID::get_object_id); +} + +void EncodedObjectAsID::set_object_id(ObjectID p_id) { + id = p_id; +} + +ObjectID EncodedObjectAsID::get_object_id() const { + + return id; +} + +EncodedObjectAsID::EncodedObjectAsID() { + + id = 0; +} + #define ENCODE_MASK 0xFF #define ENCODE_FLAG_64 1 << 16 +#define ENCODE_FLAG_OBJECT_AS_ID 1 << 16 static Error _decode_string(const uint8_t *&buf, int &len, int *r_len, String &r_string) { ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); @@ -381,56 +401,74 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int } break; case Variant::OBJECT: { - ERR_FAIL_COND_V(!p_allow_objects, ERR_UNAUTHORIZED); - - String str; - Error err = _decode_string(buf, len, r_len, str); - if (err) - return err; + if (type & ENCODE_FLAG_OBJECT_AS_ID) { + //this _is_ allowed + ObjectID val = decode_uint64(buf); + if (r_len) + (*r_len) += 8; - if (str == String()) { - r_variant = (Object *)NULL; - } else { + if (val == 0) { + r_variant = (Object *)NULL; + } else { + Ref<EncodedObjectAsID> obj_as_id; + obj_as_id.instance(); + obj_as_id->set_object_id(val); - Object *obj = ClassDB::instance(str); + r_variant = obj_as_id; + } - ERR_FAIL_COND_V(!obj, ERR_UNAVAILABLE); - ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); + } else { + ERR_FAIL_COND_V(!p_allow_objects, ERR_UNAUTHORIZED); - int32_t count = decode_uint32(buf); - buf += 4; - len -= 4; - if (r_len) { - (*r_len) += 4; - } + String str; + Error err = _decode_string(buf, len, r_len, str); + if (err) + return err; - for (int i = 0; i < count; i++) { + if (str == String()) { + r_variant = (Object *)NULL; + } else { - str = String(); - err = _decode_string(buf, len, r_len, str); - if (err) - return err; + Object *obj = ClassDB::instance(str); - Variant value; - int used; - err = decode_variant(value, buf, len, &used, p_allow_objects); - if (err) - return err; + ERR_FAIL_COND_V(!obj, ERR_UNAVAILABLE); + ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); - buf += used; - len -= used; + int32_t count = decode_uint32(buf); + buf += 4; + len -= 4; if (r_len) { - (*r_len) += used; + (*r_len) += 4; } - obj->set(str, value); - } + for (int i = 0; i < count; i++) { - if (obj->cast_to<Reference>()) { - REF ref = REF(obj->cast_to<Reference>()); - r_variant = ref; - } else { - r_variant = obj; + str = String(); + err = _decode_string(buf, len, r_len, str); + if (err) + return err; + + Variant value; + int used; + err = decode_variant(value, buf, len, &used, p_allow_objects); + if (err) + return err; + + buf += used; + len -= used; + if (r_len) { + (*r_len) += used; + } + + obj->set(str, value); + } + + if (Object::cast_to<Reference>(obj)) { + REF ref = REF(Object::cast_to<Reference>(obj)); + r_variant = ref; + } else { + r_variant = obj; + } } } @@ -769,14 +807,19 @@ static void _encode_string(const String &p_string, uint8_t *&buf, int &r_len) { encode_uint32(utf8.length(), buf); buf += 4; copymem(buf, utf8.get_data(), utf8.length()); + buf += utf8.length(); } r_len += 4 + utf8.length(); - while (r_len % 4) + while (r_len % 4) { r_len++; //pad + if (buf) { + buf++; + } + } } -Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) { +Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_object_as_id) { uint8_t *buf = r_buffer; @@ -800,6 +843,11 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) { flags |= ENCODE_FLAG_64; //always encode real as double } } break; + case Variant::OBJECT: { + if (p_object_as_id) { + flags |= ENCODE_FLAG_OBJECT_AS_ID; + } + } break; } if (buf) { @@ -1071,49 +1119,66 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) { } break; case Variant::OBJECT: { - Object *obj = p_variant; - if (!obj) { + if (p_object_as_id) { + if (buf) { - encode_uint32(0, buf); - buf += 4; - r_len += 4; + + Object *obj = p_variant; + ObjectID id = 0; + if (obj && ObjectDB::instance_validate(obj)) { + id = obj->get_instance_id(); + } + + encode_uint64(id, buf); } + + r_len += 8; + } else { - _encode_string(obj->get_class(), buf, r_len); + Object *obj = p_variant; + if (!obj) { + if (buf) { + encode_uint32(0, buf); + buf += 4; + r_len += 4; + } + } else { + _encode_string(obj->get_class(), buf, r_len); - List<PropertyInfo> props; - obj->get_property_list(&props); + List<PropertyInfo> props; + obj->get_property_list(&props); - int pc = 0; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { + int pc = 0; + for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) - continue; - pc++; - } + if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) + continue; + pc++; + } - if (buf) { - encode_uint32(pc, buf); - buf += 4; - } + if (buf) { + encode_uint32(pc, buf); + buf += 4; + } - r_len += 4; + r_len += 4; - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { + for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) - continue; + if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) + continue; - _encode_string(E->get().name, buf, r_len); + _encode_string(E->get().name, buf, r_len); - int len; - Error err = encode_variant(obj->get(E->get().name), buf, len); - if (err) - return err; - ERR_FAIL_COND_V(len % 4, ERR_BUG); - r_len += len; - if (buf) - buf += len; + int len; + Error err = encode_variant(obj->get(E->get().name), buf, len, p_object_as_id); + if (err) + return err; + ERR_FAIL_COND_V(len % 4, ERR_BUG); + r_len += len; + if (buf) + buf += len; + } } } @@ -1147,12 +1212,12 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) { r_len++; //pad */ int len; - encode_variant(E->get(), buf, len); + encode_variant(E->get(), buf, len, p_object_as_id); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) buf += len; - encode_variant(d[E->get()], buf, len); + encode_variant(d[E->get()], buf, len, p_object_as_id); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) @@ -1174,7 +1239,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) { for (int i = 0; i < v.size(); i++) { int len; - encode_variant(v.get(i), buf, len); + encode_variant(v.get(i), buf, len, p_object_as_id); ERR_FAIL_COND_V(len % 4, ERR_BUG); r_len += len; if (buf) diff --git a/core/io/marshalls.h b/core/io/marshalls.h index a6cc72b691..5541e52a89 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -32,8 +32,8 @@ #include "typedefs.h" +#include "reference.h" #include "variant.h" - /** * Miscellaneous helpers for marshalling data types, and encoding * in an endian independent way @@ -183,7 +183,22 @@ static inline double decode_double(const uint8_t *p_arr) { return md.d; } -Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects=true); -Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len); +class EncodedObjectAsID : public Reference { + GDCLASS(EncodedObjectAsID, Reference); + + ObjectID id; + +protected: + static void _bind_methods(); + +public: + void set_object_id(ObjectID p_id); + ObjectID get_object_id() const; + + EncodedObjectAsID(); +}; + +Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects = true); +Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_object_as_id = false); #endif diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp index 105b8dce44..dea6fab350 100644 --- a/core/io/networked_multiplayer_peer.cpp +++ b/core/io/networked_multiplayer_peer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -44,13 +44,13 @@ void NetworkedMultiplayerPeer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_refuse_new_connections", "enable"), &NetworkedMultiplayerPeer::set_refuse_new_connections); ClassDB::bind_method(D_METHOD("is_refusing_new_connections"), &NetworkedMultiplayerPeer::is_refusing_new_connections); - BIND_CONSTANT(TRANSFER_MODE_UNRELIABLE); - BIND_CONSTANT(TRANSFER_MODE_UNRELIABLE_ORDERED); - BIND_CONSTANT(TRANSFER_MODE_RELIABLE); + BIND_ENUM_CONSTANT(TRANSFER_MODE_UNRELIABLE); + BIND_ENUM_CONSTANT(TRANSFER_MODE_UNRELIABLE_ORDERED); + BIND_ENUM_CONSTANT(TRANSFER_MODE_RELIABLE); - BIND_CONSTANT(CONNECTION_DISCONNECTED); - BIND_CONSTANT(CONNECTION_CONNECTING); - BIND_CONSTANT(CONNECTION_CONNECTED); + BIND_ENUM_CONSTANT(CONNECTION_DISCONNECTED); + BIND_ENUM_CONSTANT(CONNECTION_CONNECTING); + BIND_ENUM_CONSTANT(CONNECTION_CONNECTED); BIND_CONSTANT(TARGET_PEER_BROADCAST); BIND_CONSTANT(TARGET_PEER_SERVER); diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h index bd951912f9..efaea46b84 100644 --- a/core/io/networked_multiplayer_peer.h +++ b/core/io/networked_multiplayer_peer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index f62ffd7183..16c73c26e7 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -92,7 +92,7 @@ Error PacketPeer::get_var(Variant &r_variant) const { Error PacketPeer::put_var(const Variant &p_packet) { int len; - Error err = encode_variant(p_packet, NULL, len); // compute len first + Error err = encode_variant(p_packet, NULL, len, !allow_object_decoding); // compute len first if (err) return err; @@ -101,7 +101,7 @@ Error PacketPeer::put_var(const Variant &p_packet) { uint8_t *buf = (uint8_t *)alloca(len); ERR_FAIL_COND_V(!buf, ERR_OUT_OF_MEMORY); - err = encode_variant(p_packet, buf, len); + err = encode_variant(p_packet, buf, len, !allow_object_decoding); ERR_FAIL_COND_V(err, err); return put_packet(buf, len); @@ -155,6 +155,8 @@ void PacketPeerStream::_bind_methods() { ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::_set_stream_peer); ClassDB::bind_method(D_METHOD("set_input_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_input_buffer_max_size); ClassDB::bind_method(D_METHOD("set_output_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_output_buffer_max_size); + ClassDB::bind_method(D_METHOD("get_input_buffer_max_size"), &PacketPeerStream::get_input_buffer_max_size); + ClassDB::bind_method(D_METHOD("get_output_buffer_max_size"), &PacketPeerStream::get_output_buffer_max_size); } Error PacketPeerStream::_poll_buffer() const { @@ -265,12 +267,22 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) { ERR_EXPLAIN("Buffer in use, resizing would cause loss of data"); ERR_FAIL_COND(ring_buffer.data_left()); ring_buffer.resize(nearest_shift(p_max_size + 4)); - input_buffer.resize(nearest_power_of_2(p_max_size + 4)); + input_buffer.resize(next_power_of_2(p_max_size + 4)); +} + +int PacketPeerStream::get_input_buffer_max_size() const { + + return input_buffer.size() - 4; } void PacketPeerStream::set_output_buffer_max_size(int p_max_size) { - output_buffer.resize(nearest_power_of_2(p_max_size + 4)); + output_buffer.resize(next_power_of_2(p_max_size + 4)); +} + +int PacketPeerStream::get_output_buffer_max_size() const { + + return output_buffer.size() - 4; } PacketPeerStream::PacketPeerStream() { diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h index 3bd6876aa7..b08d44ad8a 100644 --- a/core/io/packet_peer.h +++ b/core/io/packet_peer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -98,7 +98,9 @@ public: void set_stream_peer(const Ref<StreamPeer> &p_peer); void set_input_buffer_max_size(int p_max_size); + int get_input_buffer_max_size() const; void set_output_buffer_max_size(int p_max_size); + int get_output_buffer_max_size() const; PacketPeerStream(); }; diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp index d1729819a8..2773d2a5a3 100644 --- a/core/io/packet_peer_udp.cpp +++ b/core/io/packet_peer_udp.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h index 007b810b67..5a2b54774f 100644 --- a/core/io/packet_peer_udp.h +++ b/core/io/packet_peer_udp.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index 28382ab419..f1f5b6f538 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/pck_packer.h b/core/io/pck_packer.h index ddfa093a6b..c0a6acd859 100644 --- a/core/io/pck_packer.h +++ b/core/io/pck_packer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index fd8928b8a0..965d11e414 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,12 +28,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resource_format_binary.h" -#include "image.h" -#include "io/file_access_compressed.h" -#include "io/marshalls.h" -#include "os/dir_access.h" -#include "project_settings.h" -#include "version.h" + +#include "core/image.h" +#include "core/io/file_access_compressed.h" +#include "core/io/marshalls.h" +#include "core/os/dir_access.h" +#include "core/project_settings.h" +#include "core/version.h" + //#define print_bl(m_what) print_line(m_what) #define print_bl(m_what) @@ -713,7 +715,7 @@ Error ResourceInteractiveLoaderBinary::poll() { } ERR_FAIL_COND_V(!obj, ERR_FILE_CORRUPT); - Resource *r = obj->cast_to<Resource>(); + Resource *r = Object::cast_to<Resource>(obj); if (!r) { error = ERR_FILE_CORRUPT; memdelete(obj); //bye @@ -1715,54 +1717,6 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant default: {} } } -#if 0 -Error ResourceFormatSaverBinary::_save_obj(const Object *p_object,SavedObject *so) { - - //use classic way - List<PropertyInfo> property_list; - p_object->get_property_list( &property_list ); - - for(List<PropertyInfo>::Element *E=property_list.front();E;E=E->next()) { - - if (skip_editor && E->get().name.begins_with("__editor")) - continue; - if (E->get().usage&PROPERTY_USAGE_STORAGE || (bundle_resources && E->get().usage&PROPERTY_USAGE_BUNDLE)) { - - SavedObject::SavedProperty sp; - sp.name_idx=get_string_index(E->get().name); - sp.value = p_object->get(E->get().name); - _find_resources(sp.value); - so->properties.push_back(sp); - } - } - - return OK; - -} - - - -Error ResourceFormatSaverBinary::save(const Object *p_object,const Variant &p_meta) { - - ERR_FAIL_COND_V(!f,ERR_UNCONFIGURED); - ERR_EXPLAIN("write_object should supply either an object, a meta, or both"); - ERR_FAIL_COND_V(!p_object && p_meta.get_type()==Variant::NIL, ERR_INVALID_PARAMETER); - - SavedObject *so = memnew( SavedObject ); - - if (p_object) - so->type=p_object->get_type(); - - _find_resources(p_meta); - so->meta=p_meta; - Error err = _save_obj(p_object,so); - ERR_FAIL_COND_V( err, ERR_INVALID_DATA ); - - saved_objects.push_back(so); - - return OK; -} -#endif void ResourceFormatSaverBinaryInstance::save_unicode_string(const String &p_string) { @@ -1798,7 +1752,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p } ERR_FAIL_COND_V(err, err); - FileAccessRef _fref(f); relative_paths = p_flags & ResourceSaver::FLAG_RELATIVE_PATHS; skip_editor = p_flags & ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES; @@ -1810,7 +1763,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p takeover_paths = false; local_path = p_path.get_base_dir(); - //bin_meta_idx = get_string_index("__bin_meta__"); //is often used, so create _find_resources(p_resource, true); @@ -1836,7 +1788,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p return ERR_CANT_CREATE; } - //f->store_32(saved_resources.size()+external_resources.size()); // load steps -not needed save_unicode_string(p_resource->get_class()); uint64_t md_at = f->get_pos(); f->store_64(0); //offset to impoty metadata @@ -1875,7 +1826,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p f->store_32(strings.size()); //string table size for (int i = 0; i < strings.size(); i++) { - //print_bl("saving string: "+strings[i]); save_unicode_string(strings[i]); } @@ -1944,9 +1894,8 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p } Vector<uint64_t> ofs_table; - //int saved_idx=0; - //now actually save the resources + //now actually save the resources for (List<ResourceData>::Element *E = resources.front(); E; E = E->next()) { ResourceData &rd = E->get(); diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 1c66344e3e..1bd0d333c6 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp index 7033dbe5fb..69ff791a3a 100644 --- a/core/io/resource_import.cpp +++ b/core/io/resource_import.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -32,13 +32,17 @@ #include "os/os.h" #include "variant_parser.h" -Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndType &r_path_and_type) const { +Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid) const { Error err; FileAccess *f = FileAccess::open(p_path + ".import", FileAccess::READ, &err); - if (!f) + if (!f) { + if (r_valid) { + *r_valid = false; + } return err; + } VariantParser::StreamFile stream; stream.f = f; @@ -47,6 +51,10 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy Variant value; VariantParser::Tag next_tag; + if (r_valid) { + *r_valid = true; + } + int lines = 0; String error_text; bool path_found = false; //first match must have priority @@ -79,6 +87,10 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy path_found = true; //first match must have priority } else if (assign == "type") { r_path_and_type.type = value; + } else if (assign == "valid") { + if (r_valid) { + *r_valid = value; + } } } else if (next_tag.name != "remap") { @@ -245,6 +257,14 @@ void ResourceFormatImporter::get_internal_resource_path_list(const String &p_pat memdelete(f); } +bool ResourceFormatImporter::is_import_valid(const String &p_path) const { + + bool valid = true; + PathAndType pat; + _get_path_and_type(p_path, pat, &valid); + return valid; +} + String ResourceFormatImporter::get_resource_type(const String &p_path) const { PathAndType pat; diff --git a/core/io/resource_import.h b/core/io/resource_import.h index 67fd870178..b10255fbab 100644 --- a/core/io/resource_import.h +++ b/core/io/resource_import.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -40,7 +40,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { String type; }; - Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type) const; + Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid = NULL) const; static ResourceFormatImporter *singleton; @@ -54,6 +54,7 @@ public: virtual bool recognize_path(const String &p_path, const String &p_for_type = String()) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; + virtual bool is_import_valid(const String &p_path) const; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual bool can_be_imported(const String &p_path) const; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 5347cd6ee1..30ae9f5681 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -296,6 +296,31 @@ void ResourceLoader::add_resource_format_loader(ResourceFormatLoader *p_format_l } } +bool ResourceLoader::is_import_valid(const String &p_path) { + + String path = _path_remap(p_path); + + String local_path; + if (path.is_rel_path()) + local_path = "res://" + path; + else + local_path = ProjectSettings::get_singleton()->localize_path(path); + + for (int i = 0; i < loader_count; i++) { + + if (!loader[i]->recognize_path(local_path)) + continue; + /* + if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) + continue; + */ + + return loader[i]->is_import_valid(p_path); + } + + return false; //not found +} + void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) { String path = _path_remap(p_path); diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index e6687800d7..91f0c939bf 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -66,6 +66,7 @@ public: virtual String get_resource_type(const String &p_path) const = 0; virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); virtual Error rename_dependencies(const String &p_path, const Map<String, String> &p_map) { return OK; } + virtual bool is_import_valid(const String &p_path) const { return true; } virtual ~ResourceFormatLoader() {} }; @@ -104,6 +105,7 @@ public: static String get_resource_type(const String &p_path); static void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false); static Error rename_dependencies(const String &p_path, const Map<String, String> &p_map); + static bool is_import_valid(const String &p_path); static void set_timestamp_on_load(bool p_timestamp) { timestamp_on_load = p_timestamp; } diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 314259b2e9..e6187c9e3c 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h index f7fbcc1fb8..3fdd00133a 100644 --- a/core/io/resource_saver.h +++ b/core/io/resource_saver.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index 7042700d92..1006158003 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h index d0748a8c9e..1ee997c123 100644 --- a/core/io/stream_peer.h +++ b/core/io/stream_peer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp index ef3c264375..d1fe214343 100644 --- a/core/io/stream_peer_ssl.cpp +++ b/core/io/stream_peer_ssl.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -55,10 +55,11 @@ void StreamPeerSSL::_bind_methods() { ClassDB::bind_method(D_METHOD("connect_to_stream", "stream", "validate_certs", "for_hostname"), &StreamPeerSSL::connect_to_stream, DEFVAL(false), DEFVAL(String())); ClassDB::bind_method(D_METHOD("get_status"), &StreamPeerSSL::get_status); ClassDB::bind_method(D_METHOD("disconnect_from_stream"), &StreamPeerSSL::disconnect_from_stream); - BIND_CONSTANT(STATUS_DISCONNECTED); - BIND_CONSTANT(STATUS_CONNECTED); - BIND_CONSTANT(STATUS_ERROR_NO_CERTIFICATE); - BIND_CONSTANT(STATUS_ERROR_HOSTNAME_MISMATCH); + + BIND_ENUM_CONSTANT(STATUS_DISCONNECTED); + BIND_ENUM_CONSTANT(STATUS_CONNECTED); + BIND_ENUM_CONSTANT(STATUS_ERROR_NO_CERTIFICATE); + BIND_ENUM_CONSTANT(STATUS_ERROR_HOSTNAME_MISMATCH); } StreamPeerSSL::StreamPeerSSL() { diff --git a/core/io/stream_peer_ssl.h b/core/io/stream_peer_ssl.h index a81ae24e4a..bcbbeb0d48 100644 --- a/core/io/stream_peer_ssl.h +++ b/core/io/stream_peer_ssl.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp index 5c859ea7c0..0e047a8f32 100644 --- a/core/io/stream_peer_tcp.cpp +++ b/core/io/stream_peer_tcp.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -55,10 +55,10 @@ void StreamPeerTCP::_bind_methods() { ClassDB::bind_method(D_METHOD("get_connected_port"), &StreamPeerTCP::get_connected_port); ClassDB::bind_method(D_METHOD("disconnect_from_host"), &StreamPeerTCP::disconnect_from_host); - BIND_CONSTANT(STATUS_NONE); - BIND_CONSTANT(STATUS_CONNECTING); - BIND_CONSTANT(STATUS_CONNECTED); - BIND_CONSTANT(STATUS_ERROR); + BIND_ENUM_CONSTANT(STATUS_NONE); + BIND_ENUM_CONSTANT(STATUS_CONNECTING); + BIND_ENUM_CONSTANT(STATUS_CONNECTED); + BIND_ENUM_CONSTANT(STATUS_ERROR); } Ref<StreamPeerTCP> StreamPeerTCP::create_ref() { diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index 53c21a93fd..45c93c2d36 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp index 29a80ecc19..a4364fa17c 100644 --- a/core/io/tcp_server.cpp +++ b/core/io/tcp_server.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h index b4ff3246ad..a7276401e4 100644 --- a/core/io/tcp_server.h +++ b/core/io/tcp_server.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index 1a670b0ab0..353eabea45 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/translation_loader_po.h b/core/io/translation_loader_po.h index a731e4e0d6..a14238f1df 100644 --- a/core/io/translation_loader_po.h +++ b/core/io/translation_loader_po.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index e5f4433b8f..62110bfe24 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -373,13 +373,13 @@ void XMLParser::_bind_methods() { ClassDB::bind_method(D_METHOD("open", "file"), &XMLParser::open); ClassDB::bind_method(D_METHOD("open_buffer", "buffer"), &XMLParser::open_buffer); - BIND_CONSTANT(NODE_NONE); - BIND_CONSTANT(NODE_ELEMENT); - BIND_CONSTANT(NODE_ELEMENT_END); - BIND_CONSTANT(NODE_TEXT); - BIND_CONSTANT(NODE_COMMENT); - BIND_CONSTANT(NODE_CDATA); - BIND_CONSTANT(NODE_UNKNOWN); + BIND_ENUM_CONSTANT(NODE_NONE); + BIND_ENUM_CONSTANT(NODE_ELEMENT); + BIND_ENUM_CONSTANT(NODE_ELEMENT_END); + BIND_ENUM_CONSTANT(NODE_TEXT); + BIND_ENUM_CONSTANT(NODE_COMMENT); + BIND_ENUM_CONSTANT(NODE_CDATA); + BIND_ENUM_CONSTANT(NODE_UNKNOWN); }; Error XMLParser::read() { diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h index 297211ecc6..28c57b567f 100644 --- a/core/io/xml_parser.h +++ b/core/io/xml_parser.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/zip_io.h b/core/io/zip_io.h index 88e680c0e0..8cf971ee08 100644 --- a/core/io/zip_io.h +++ b/core/io/zip_io.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/list.h b/core/list.h index df69b1dc40..0cad6038ff 100644 --- a/core/list.h +++ b/core/list.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/make_binders.py b/core/make_binders.py index a5cdb78443..6468c029f0 100644 --- a/core/make_binders.py +++ b/core/make_binders.py @@ -16,12 +16,11 @@ public: $ return Variant::NIL; } - virtual StringName _gen_argument_type_name(int p_arg) const { return _gen_argument_type_hint(p_arg); } - StringName _gen_argument_type_hint(int p_argument) const { - $ifret if (p_argument==-1) return GetTypeInfo<R>::get_class_name();$ - $arg if (p_argument==(@-1)) return GetTypeInfo<P@>::get_class_name(); + virtual PropertyInfo _gen_argument_type_info(int p_argument) const { + $ifret if (p_argument==-1) return GetTypeInfo<R>::get_class_info();$ + $arg if (p_argument==(@-1)) return GetTypeInfo<P@>::get_class_info(); $ - return StringName(); + return PropertyInfo(); } #endif virtual String get_instance_class() const { @@ -30,7 +29,7 @@ public: virtual Variant call(Object* p_object,const Variant** p_args,int p_arg_count, Variant::CallError& r_error) { - T *instance=p_object->cast_to<T>(); + T *instance=Object::cast_to<T>(p_object); r_error.error=Variant::CallError::CALL_OK; #ifdef DEBUG_METHODS_ENABLED @@ -58,7 +57,7 @@ public: #ifdef PTRCALL_ENABLED virtual void ptrcall(Object*p_object,const void** p_args,void *r_ret) { - T *instance=p_object->cast_to<T>(); + T *instance=Object::cast_to<T>(p_object); $ifret PtrToArg<R>::encode( $ (instance->*method)($arg, PtrToArg<P@>::convert(p_args[@-1])$) $ifret ,r_ret)$ ; } #endif @@ -104,14 +103,13 @@ public: return Variant::NIL; } - virtual StringName _gen_argument_type_name(int p_arg) const { return _gen_argument_type_hint(p_arg); } - - StringName _gen_argument_type_hint(int p_argument) const { - $ifret if (p_argument==-1) return GetTypeInfo<R>::get_class_name();$ - $arg if (p_argument==(@-1)) return GetTypeInfo<P@>::get_class_name(); + virtual PropertyInfo _gen_argument_type_info(int p_argument) const { + $ifret if (p_argument==-1) return GetTypeInfo<R>::get_class_info();$ + $arg if (p_argument==(@-1)) return GetTypeInfo<P@>::get_class_info(); $ - return StringName(); + return PropertyInfo(); } + #endif virtual String get_instance_class() const { return type_name; diff --git a/core/map.h b/core/map.h index ef0f75fc9b..75a38a3440 100644 --- a/core/map.h +++ b/core/map.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 04e4383f03..21516ac768 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/a_star.h b/core/math/a_star.h index ebf1407c17..d2d2166719 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/audio_frame.cpp b/core/math/audio_frame.cpp index 30a50c8add..555d3536df 100644 --- a/core/math/audio_frame.cpp +++ b/core/math/audio_frame.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h index d54f622197..cfc7331767 100644 --- a/core/math/audio_frame.h +++ b/core/math/audio_frame.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp index e22bc2b05e..be950568cf 100644 --- a/core/math/bsp_tree.cpp +++ b/core/math/bsp_tree.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h index 8296e57943..2e762ba4de 100644 --- a/core/math/bsp_tree.h +++ b/core/math/bsp_tree.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index a1666ccd8b..0512cdd798 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -180,19 +180,7 @@ void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear } void CameraMatrix::set_frustum(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_near, real_t p_far) { -#if 0 - ///@TODO, give a check to this. I'm not sure if it's working. - set_identity(); - matrix[0][0]=(2*p_near) / (p_right-p_left); - matrix[0][2]=(p_right+p_left) / (p_right-p_left); - matrix[1][1]=(2*p_near) / (p_top-p_bottom); - matrix[1][2]=(p_top+p_bottom) / (p_top-p_bottom); - matrix[2][2]=-(p_far+p_near) / ( p_far-p_near); - matrix[2][3]=-(2*p_far*p_near) / (p_far-p_near); - matrix[3][2]=-1; - matrix[3][3]=0; -#else real_t *te = &matrix[0][0]; real_t x = 2 * p_near / (p_right - p_left); real_t y = 2 * p_near / (p_top - p_bottom); @@ -218,8 +206,6 @@ void CameraMatrix::set_frustum(real_t p_left, real_t p_right, real_t p_bottom, r te[13] = 0; te[14] = d; te[15] = 0; - -#endif } real_t CameraMatrix::get_z_far() const { diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index 4be8ffab8c..175d0cdb1b 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/face3.cpp b/core/math/face3.cpp index 0e292500bf..748faad28f 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/face3.h b/core/math/face3.h index 3d02ae4014..8e4a25fb7a 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index 2bea514d37..7c8fb6f17d 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1076,8 +1076,8 @@ void Geometry::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_resu for (int i = 0; i < results.size(); i++) { - real_t h = nearest_power_of_2(results[i].max_h); - real_t w = nearest_power_of_2(results[i].max_w); + real_t h = next_power_of_2(results[i].max_h); + real_t w = next_power_of_2(results[i].max_w); real_t aspect = h > w ? h / w : w / h; if (aspect < best_aspect) { best = i; diff --git a/core/math/geometry.h b/core/math/geometry.h index 909d8164c3..cd069bd7a3 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -105,7 +105,7 @@ public: } static void get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2, Vector3 &c1, Vector3 &c2) { -#if 1 + //do the function 'd' as defined by pb. I think is is dot product of some sort #define d_of(m, n, o, p) ((m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z)) @@ -120,33 +120,6 @@ public: if (mub > 1) mub = 1; c1 = p1.linear_interpolate(p2, mua); c2 = q1.linear_interpolate(q2, mub); -#else - //this is broken do not use - Vector3 u = p2 - p1; - Vector3 v = q2 - q1; - Vector3 w = p1 - q1; - float a = u.dot(u); - float b = u.dot(v); - float c = v.dot(v); // always >= 0 - float d = u.dot(w); - float e = v.dot(w); - float D = a * c - b * b; // always >= 0 - float sc, tc; - - // compute the line parameters of the two closest points - if (D < CMP_EPSILON) { // the lines are almost parallel - sc = 0.0; - tc = (b > c ? d / b : e / c); // use the largest denominator - } else { - sc = (b * e - c * d) / D; - tc = (a * e - b * d) / D; - } - - c1 = w + sc * u; - c2 = w + tc * v; -// get the difference of the two closest points -//Vector dP = w + (sc * u) - (tc * v); // = L1(sc) - L2(tc) -#endif } static real_t get_closest_distance_between_segments(const Vector3 &p_from_a, const Vector3 &p_to_a, const Vector3 &p_from_b, const Vector3 &p_to_b) { diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index 956cfe5258..c77fe96ff2 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -205,33 +205,6 @@ Vector2 Vector2::clamped(real_t p_len) const { return v; } -Vector2 Vector2::cubic_interpolate_soft(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const { -#if 0 - k[0] = ((*this) (vi[0] + 1, vi[1], vi[2])) - ((*this) (vi[0], - vi[1],vi[2])); //fk = a0 - k[1] = (((*this) (vi[0] + 1, vi[1], vi[2])) - ((*this) ((int) (v(0) - - 1), vi[1],vi[2])))*0.5; //dk = a1 - k[2] = (((*this) ((int) (v(0) + 2), vi[1], vi[2])) - ((*this) (vi[0], - vi[1],vi[2])))*0.5; //dk+1 - k[3] = k[0]*3 - k[1]*2 - k[2];//a2 - k[4] = k[1] + k[2] - k[0]*2;//a3 - - //ip = a3(t-tk)³ + a2(t-tk)² + a1(t-tk) + a0 - // - //a3 = dk + dk+1 - Dk - //a2 = 3Dk - 2dk - dk+1 - //a1 = dk - //a0 = fk - // - //dk = (fk+1 - fk-1)*0.5 - //Dk = (fk+1 - fk) - - real_t dk = -#endif - - return Vector2(); -} - Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const { Vector2 p0 = p_pre_a; diff --git a/core/math/math_2d.h b/core/math/math_2d.h index 6fea6c8adb..d215df8a43 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -113,7 +113,6 @@ struct Vector2 { _FORCE_INLINE_ static Vector2 linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t); _FORCE_INLINE_ Vector2 linear_interpolate(const Vector2 &p_b, real_t p_t) const; Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const; - Vector2 cubic_interpolate_soft(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const; Vector2 slide(const Vector2 &p_normal) const; Vector2 bounce(const Vector2 &p_normal) const; diff --git a/core/math/math_defs.h b/core/math/math_defs.h index 3d9eb63e11..904cbc1abc 100644 --- a/core/math/math_defs.h +++ b/core/math/math_defs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp index 9f5a9c193a..6fb688f16b 100644 --- a/core/math/math_funcs.cpp +++ b/core/math/math_funcs.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,16 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "math_funcs.h" + #include "core/os/os.h" pcg32_random_t Math::default_pcg = { 12047754176567800795ULL, PCG_DEFAULT_INC_64 }; #define PHI 0x9e3779b9 -#if 0 -static uint32_t Q[4096]; -#endif - // TODO: we should eventually expose pcg.inc too uint32_t Math::rand_from_seed(uint64_t *seed) { pcg32_random_t pcg = { *seed, PCG_DEFAULT_INC_64 }; diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 45509a0808..9651e37f3e 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -153,8 +153,14 @@ public: static _ALWAYS_INLINE_ double rad2deg(double p_y) { return p_y * 180.0 / Math_PI; } static _ALWAYS_INLINE_ float rad2deg(float p_y) { return p_y * 180.0 / Math_PI; } - static _ALWAYS_INLINE_ double lerp(double a, double b, double c) { return a + (b - a) * c; } - static _ALWAYS_INLINE_ float lerp(float a, float b, float c) { return a + (b - a) * c; } + static _ALWAYS_INLINE_ double lerp(double p_from, double p_to, double p_weight) { return p_from + (p_to - p_from) * p_weight; } + static _ALWAYS_INLINE_ float lerp(float p_from, float p_to, float p_weight) { return p_from + (p_to - p_from) * p_weight; } + + static _ALWAYS_INLINE_ double inverse_lerp(double p_from, double p_to, double p_value) { return (p_value - p_from) / (p_to - p_from); } + static _ALWAYS_INLINE_ float inverse_lerp(float p_from, float p_to, float p_value) { return (p_value - p_from) / (p_to - p_from); } + + static _ALWAYS_INLINE_ double range_lerp(double p_value, double p_istart, double p_istop, double p_ostart, double p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); } + static _ALWAYS_INLINE_ float range_lerp(float p_value, float p_istart, float p_istop, float p_ostart, float p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); } static _ALWAYS_INLINE_ double linear2db(double p_linear) { return Math::log(p_linear) * 8.6858896380650365530225783783321; } static _ALWAYS_INLINE_ float linear2db(float p_linear) { return Math::log(p_linear) * 8.6858896380650365530225783783321; } diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index f2f6ff93cf..57555bbb2a 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -254,17 +254,6 @@ Vector3 Basis::get_scale() const { Vector3(elements[0][2], elements[1][2], elements[2][2]).length()); } -// Sets scaling while preserving rotation. -// This requires some care when working with matrices with negative determinant, -// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation. -// For details, see the explanation in get_scale. -void Basis::set_scale(const Vector3 &p_scale) { - Vector3 e = get_euler(); - Basis(); // reset to identity - scale(p_scale); - rotate(e); -} - // Multiplies the matrix from left by the rotation matrix: M -> R.M // Note that this does *not* rotate the matrix itself. // @@ -316,28 +305,6 @@ void Basis::get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const { m.get_axis_angle(p_axis, p_angle); } -// Sets rotation while preserving scaling. -// This requires some care when working with matrices with negative determinant, -// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation. -// For details, see the explanation in get_scale. -void Basis::set_rotation_euler(const Vector3 &p_euler) { - Vector3 s = get_scale(); - Basis(); // reset to identity - scale(s); - rotate(p_euler); -} - -// Sets rotation while preserving scaling. -// This requires some care when working with matrices with negative determinant, -// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation. -// For details, see the explanation in get_scale. -void Basis::set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle) { - Vector3 s = get_scale(); - Basis(); // reset to identity - scale(s); - rotate(p_axis, p_angle); -} - // get_euler_xyz returns a vector containing the Euler angles in the format // (a1,a2,a3), where a3 is the angle of the first rotation, and a1 is the last // (following the convention they are commonly defined in the literature). @@ -365,14 +332,10 @@ Vector3 Basis::get_euler_xyz() const { if (euler.y < Math_PI * 0.5) { if (euler.y > -Math_PI * 0.5) { //if rotation is Y-only, return a proper -pi,pi range like in x or z for the same case. - if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[0][0] < 0.0) { + if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[1][2] == 0 && elements[2][1] == 0 && elements[1][1] == 1) { euler.x = 0; + euler.y = atan2(elements[0][2], elements[0][0]); euler.z = 0; - - if (euler.y > 0.0) - euler.y = Math_PI - euler.y; - else - euler.y = -(Math_PI + euler.y); } else { euler.x = Math::atan2(-elements[1][2], elements[2][2]); euler.z = Math::atan2(-elements[0][1], elements[0][0]); @@ -436,15 +399,10 @@ Vector3 Basis::get_euler_yxz() const { if (m12 < 1) { if (m12 > -1) { - if (elements[1][0] == 0 && elements[0][1] == 0 && elements[2][2] < 0) { // use pure x rotation - real_t x = asin(-m12); + if (elements[1][0] == 0 && elements[0][1] == 0 && elements[0][2] == 0 && elements[2][0] == 0 && elements[0][0] == 1) { // use pure x rotation + euler.x = atan2(-m12, elements[1][1]); euler.y = 0; euler.z = 0; - - if (x > 0.0) - euler.x = Math_PI - x; - else - euler.x = -(Math_PI + x); } else { euler.x = asin(-m12); euler.y = atan2(elements[0][2], elements[2][2]); diff --git a/core/math/matrix3.h b/core/math/matrix3.h index 74e6564578..be8de2e1c4 100644 --- a/core/math/matrix3.h +++ b/core/math/matrix3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -81,9 +81,6 @@ public: Vector3 get_rotation() const; void get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const; - void set_rotation_euler(const Vector3 &p_euler); - void set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle); - Vector3 get_euler_xyz() const; void set_euler_xyz(const Vector3 &p_euler); Vector3 get_euler_yxz() const; @@ -99,7 +96,6 @@ public: Basis scaled(const Vector3 &p_scale) const; Vector3 get_scale() const; - void set_scale(const Vector3 &p_scale); // transposed dot products _FORCE_INLINE_ real_t tdotx(const Vector3 &v) const { diff --git a/core/math/octree.h b/core/math/octree.h index 2e37056030..95a67943fd 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -851,28 +851,6 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) { ERR_FAIL_COND(!E); Element &e = E->get(); -#if 0 - - pass++; - if (!e.aabb.has_no_surface()) { - _remove_element(&e); - } - - e.aabb=p_aabb; - - if (!e.aabb.has_no_surface()) { - _ensure_valid_root(p_aabb); - - _insert_element(&e,root); - if (use_pairs) - _element_check_pairs(&e); - - } - - _optimize(); - -#else - bool old_has_surf = !e.aabb.has_no_surface(); bool new_has_surf = !p_aabb.has_no_surface(); @@ -979,7 +957,6 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) { } _optimize(); -#endif } template <class T, bool use_pairs, class AL> diff --git a/core/math/plane.cpp b/core/math/plane.cpp index 17928d07c3..08395ed07b 100644 --- a/core/math/plane.cpp +++ b/core/math/plane.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/plane.h b/core/math/plane.h index 73d584e553..559a735817 100644 --- a/core/math/plane.h +++ b/core/math/plane.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/quat.cpp b/core/math/quat.cpp index 5984cdf657..cebc5b9522 100644 --- a/core/math/quat.cpp +++ b/core/math/quat.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -139,48 +139,6 @@ Quat Quat::inverse() const { Quat Quat::slerp(const Quat &q, const real_t &t) const { -#if 0 - - - Quat dst=q; - Quat src=*this; - - src.normalize(); - dst.normalize(); - - real_t cosine = dst.dot(src); - - if (cosine < 0 && true) { - cosine = -cosine; - dst = -dst; - } else { - dst = dst; - } - - if (Math::abs(cosine) < 1 - CMP_EPSILON) { - // Standard case (slerp) - real_t sine = Math::sqrt(1 - cosine*cosine); - real_t angle = Math::atan2(sine, cosine); - real_t inv_sine = 1.0 / sine; - real_t coeff_0 = Math::sin((1.0 - t) * angle) * inv_sine; - real_t coeff_1 = Math::sin(t * angle) * inv_sine; - Quat ret= src * coeff_0 + dst * coeff_1; - - return ret; - } else { - // There are two situations: - // 1. "rkP" and "q" are very close (cosine ~= +1), so we can do a linear - // interpolation safely. - // 2. "rkP" and "q" are almost invedste of each other (cosine ~= -1), there - // are an infinite number of possibilities interpolation. but we haven't - // have method to fix this case, so just use linear interpolation here. - Quat ret = src * (1.0 - t) + dst *t; - // taking the complement requires renormalisation - ret.normalize(); - return ret; - } -#else - Quat to1; real_t omega, cosom, sinom, scale0, scale1; @@ -221,7 +179,6 @@ Quat Quat::slerp(const Quat &q, const real_t &t) const { scale0 * y + scale1 * to1.y, scale0 * z + scale1 * to1.z, scale0 * w + scale1 * to1.w); -#endif } Quat Quat::slerpni(const Quat &q, const real_t &t) const { @@ -241,53 +198,6 @@ Quat Quat::slerpni(const Quat &q, const real_t &t) const { invFactor * from.y + newFactor * q.y, invFactor * from.z + newFactor * q.z, invFactor * from.w + newFactor * q.w); - -#if 0 - real_t to1[4]; - real_t omega, cosom, sinom, scale0, scale1; - - - // calc cosine - cosom = x * q.x + y * q.y + z * q.z - + w * q.w; - - - // adjust signs (if necessary) - if ( cosom <0.0 && false) { - cosom = -cosom;to1[0] = - q.x; - to1[1] = - q.y; - to1[2] = - q.z; - to1[3] = - q.w; - } else { - to1[0] = q.x; - to1[1] = q.y; - to1[2] = q.z; - to1[3] = q.w; - } - - - // calculate coefficients - - if ( (1.0 - cosom) > CMP_EPSILON ) { - // standard case (slerp) - omega = Math::acos(cosom); - sinom = Math::sin(omega); - scale0 = Math::sin((1.0 - t) * omega) / sinom; - scale1 = Math::sin(t * omega) / sinom; - } else { - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - scale0 = 1.0 - t; - scale1 = t; - } - // calculate final values - return Quat( - scale0 * x + scale1 * to1[0], - scale0 * y + scale1 * to1[1], - scale0 * z + scale1 * to1[2], - scale0 * w + scale1 * to1[3] - ); -#endif } Quat Quat::cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const { diff --git a/core/math/quat.h b/core/math/quat.h index 0e378eb4e4..9668f8c7a3 100644 --- a/core/math/quat.h +++ b/core/math/quat.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 54b97ac38c..e9a383df40 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h index 49600649e3..47ed22615b 100644 --- a/core/math/quick_hull.h +++ b/core/math/quick_hull.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/rect3.cpp b/core/math/rect3.cpp index 973607f565..6f01000f61 100644 --- a/core/math/rect3.cpp +++ b/core/math/rect3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/rect3.h b/core/math/rect3.h index 7c971f5ac7..c3a2f5fbfb 100644 --- a/core/math/rect3.h +++ b/core/math/rect3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -47,12 +47,12 @@ public: real_t get_area() const; /// get area _FORCE_INLINE_ bool has_no_area() const { - return (size.x <= CMP_EPSILON || size.y <= CMP_EPSILON || size.z <= CMP_EPSILON); + return (size.x <= 0 || size.y <= 0 || size.z <= 0); } _FORCE_INLINE_ bool has_no_surface() const { - return (size.x <= CMP_EPSILON && size.y <= CMP_EPSILON && size.z <= CMP_EPSILON); + return (size.x <= 0 && size.y <= 0 && size.z <= 0); } const Vector3 &get_position() const { return position; } @@ -189,8 +189,6 @@ Vector3 Rect3::get_endpoint(int p_point) const { bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const { -#if 1 - Vector3 half_extents = size * 0.5; Vector3 ofs = position + half_extents; @@ -206,42 +204,6 @@ bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) co } return true; -#else - //cache all points to check against! - // #warning should be easy to optimize, just use the same as when taking the support and use only that point - Vector3 points[8] = { - Vector3(position.x, position.y, position.z), - Vector3(position.x, position.y, position.z + size.z), - Vector3(position.x, position.y + size.y, position.z), - Vector3(position.x, position.y + size.y, position.z + size.z), - Vector3(position.x + size.x, position.y, position.z), - Vector3(position.x + size.x, position.y, position.z + size.z), - Vector3(position.x + size.x, position.y + size.y, position.z), - Vector3(position.x + size.x, position.y + size.y, position.z + size.z), - }; - - for (int i = 0; i < p_plane_count; i++) { //for each plane - - const Plane &plane = p_planes[i]; - bool all_points_over = true; - //test if it has all points over! - - for (int j = 0; j < 8; j++) { - - if (!plane.is_point_over(points[j])) { - - all_points_over = false; - break; - } - } - - if (all_points_over) { - - return false; - } - } - return true; -#endif } bool Rect3::has_point(const Vector3 &p_point) const { diff --git a/core/math/transform.cpp b/core/math/transform.cpp index 3a86fbfc6c..60df69a509 100644 --- a/core/math/transform.cpp +++ b/core/math/transform.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/transform.h b/core/math/transform.h index 48467f2ed7..566bf482a9 100644 --- a/core/math/transform.h +++ b/core/math/transform.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -154,8 +154,7 @@ _FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const { } _FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const { -/* define vertices */ -#if 1 + /* define vertices */ Vector3 x = basis.get_axis(0) * p_aabb.size.x; Vector3 y = basis.get_axis(1) * p_aabb.size.y; Vector3 z = basis.get_axis(2) * p_aabb.size.z; @@ -171,31 +170,8 @@ _FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const { new_aabb.expand_to(pos + y + z); new_aabb.expand_to(pos + x + y + z); return new_aabb; -#else - - Vector3 vertices[8] = { - Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z), - Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z), - Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z), - Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z), - Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z), - Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z), - Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z), - Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z) - }; - - AABB ret; - - ret.pos = xform(vertices[0]); - - for (int i = 1; i < 8; i++) { - - ret.expand_to(xform(vertices[i])); - } - - return ret; -#endif } + _FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const { /* define vertices */ @@ -222,4 +198,4 @@ _FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const { return ret; } -#endif +#endif // TRANSFORM_H diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index 1df3c8c298..614104f698 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h index 166f10c577..2bf67fffcb 100644 --- a/core/math/triangle_mesh.h +++ b/core/math/triangle_mesh.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/triangulate.cpp b/core/math/triangulate.cpp index 4a5d0a078e..b20f2e06d5 100644 --- a/core/math/triangulate.cpp +++ b/core/math/triangulate.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/triangulate.h b/core/math/triangulate.h index 3f0ad00033..21e148249e 100644 --- a/core/math/triangulate.h +++ b/core/math/triangulate.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index efffacb36e..144234f4d1 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -125,51 +125,6 @@ Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, c return out; } -#if 0 -Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,real_t p_t) const { - - Vector3 p0=p_pre_a; - Vector3 p1=*this; - Vector3 p2=p_b; - Vector3 p3=p_post_b; - - if (true) { - - real_t ab = p0.distance_to(p1); - real_t bc = p1.distance_to(p2); - real_t cd = p2.distance_to(p3); - - //if (ab>bc) { - if (ab>0) - p0 = p1+(p0-p1)*(bc/ab); - //} - - //if (cd>bc) { - if (cd>0) - p3 = p2+(p3-p2)*(bc/cd); - //} - } - - real_t t = p_t; - real_t t2 = t * t; - real_t t3 = t2 * t; - - Vector3 out; - out.x = 0.5 * ( ( 2.0 * p1.x ) + - ( -p0.x + p2.x ) * t + - ( 2.0 * p0.x - 5.0 * p1.x + 4 * p2.x - p3.x ) * t2 + - ( -p0.x + 3.0 * p1.x - 3.0 * p2.x + p3.x ) * t3 ); - out.y = 0.5 * ( ( 2.0 * p1.y ) + - ( -p0.y + p2.y ) * t + - ( 2.0 * p0.y - 5.0 * p1.y + 4 * p2.y - p3.y ) * t2 + - ( -p0.y + 3.0 * p1.y - 3.0 * p2.y + p3.y ) * t3 ); - out.z = 0.5 * ( ( 2.0 * p1.z ) + - ( -p0.z + p2.z ) * t + - ( 2.0 * p0.z - 5.0 * p1.z + 4 * p2.z - p3.z ) * t2 + - ( -p0.z + 3.0 * p1.z - 3.0 * p2.z + p3.z ) * t3 ); - return out; -} -#endif Vector3::operator String() const { return (rtos(x) + ", " + rtos(y) + ", " + rtos(z)); diff --git a/core/math/vector3.h b/core/math/vector3.h index c58a86fbdb..74c822fcd7 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 564069d8bb..040fb69805 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -240,47 +240,6 @@ void MessageQueue::statistics() { } } -bool MessageQueue::print() { -#if 0 - uint32_t read_pos=0; - while (read_pos < buffer_end ) { - Message *message = (Message*)&buffer[ read_pos ]; - - Object *target = ObjectDB::get_instance(message->instance_ID); - String cname; - String cfunc; - - if (target==NULL) { - //object was deleted - //WARN_PRINT("Object was deleted while awaiting a callback") - //should it print a warning? - } else if (message->notification>=0) { - - // messages don't expect a return value - cfunc="notification # "+itos(message->notification); - cname=target->get_type(); - - } else if (!message->target.empty()) { - - cfunc="property: "+message->target; - cname=target->get_type(); - - - } else if (message->target) { - - cfunc=String(message->target)+"()"; - cname=target->get_type(); - } - - - read_pos+=sizeof(Message); - if (message->type!=TYPE_NOTIFICATION) - read_pos+=sizeof(Variant)*message->args; - } -#endif - return false; -} - int MessageQueue::get_max_buffer_usage() const { return buffer_max_used; diff --git a/core/message_queue.h b/core/message_queue.h index 843ab17d94..193d2b6907 100644 --- a/core/message_queue.h +++ b/core/message_queue.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -33,6 +33,7 @@ #include "object.h" #include "os/mutex.h" #include "os/thread_safe.h" + class MessageQueue { _THREAD_SAFE_CLASS_ @@ -85,7 +86,6 @@ public: Error push_notification(Object *p_object, int p_notification); Error push_set(Object *p_object, const StringName &p_prop, const Variant &p_value); - bool print(); void statistics(); void flush(); diff --git a/core/method_bind.cpp b/core/method_bind.cpp index 6792b62703..8cace0bbaa 100644 --- a/core/method_bind.cpp +++ b/core/method_bind.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -36,31 +36,16 @@ #ifdef DEBUG_METHODS_ENABLED PropertyInfo MethodBind::get_argument_info(int p_argument) const { - if (p_argument >= 0) { + ERR_FAIL_INDEX_V(p_argument, get_argument_count(), PropertyInfo()); - String name = p_argument < arg_names.size() ? String(arg_names[p_argument]) : String("arg" + itos(p_argument)); - PropertyInfo pi(get_argument_type(p_argument), name); - - if (!is_vararg() && pi.type == Variant::OBJECT) { - StringName type_hint = arg_type_hints[p_argument]; - - if (type_hint != StringName()) { - pi.hint = PROPERTY_HINT_RESOURCE_TYPE; - pi.hint_string = type_hint.operator String(); - } - } - return pi; + PropertyInfo info = _gen_argument_type_info(p_argument); + info.name = p_argument < arg_names.size() ? String(arg_names[p_argument]) : String("arg" + itos(p_argument)); + return info; +} - } else { +PropertyInfo MethodBind::get_return_info() const { - Variant::Type at = get_argument_type(-1); - if (at == Variant::OBJECT && ret_type) - return PropertyInfo(at, "ret", PROPERTY_HINT_RESOURCE_TYPE, ret_type); - else - return PropertyInfo(at, "ret"); - } - - return PropertyInfo(); + return _gen_argument_type_info(-1); } #endif @@ -91,16 +76,6 @@ Vector<StringName> MethodBind::get_argument_names() const { return arg_names; } -void MethodBind::set_argument_type_hints(const Vector<StringName> &p_type_hints) { - - arg_type_hints = p_type_hints; -} - -Vector<StringName> MethodBind::get_argument_type_hints() const { - - return arg_type_hints; -} - #endif void MethodBind::set_default_arguments(const Vector<Variant> &p_defargs) { @@ -114,18 +89,13 @@ void MethodBind::_generate_argument_types(int p_count) { set_argument_count(p_count); Variant::Type *argt = memnew_arr(Variant::Type, p_count + 1); - - arg_type_hints.resize(p_count); - argt[0] = _gen_argument_type(-1); // return type - set_return_type(_gen_argument_type_hint(-1)); for (int i = 0; i < p_count; i++) { argt[i + 1] = _gen_argument_type(i); - arg_type_hints[i] = _gen_argument_type_hint(i); } - set_argument_types(argt); + argument_types = argt; } #endif diff --git a/core/method_bind.h b/core/method_bind.h index 9bf0323733..75f09b2cd9 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -124,6 +124,9 @@ struct VariantCaster<const T &> { #endif +// Object enum casts must go here +VARIANT_ENUM_CAST(Object::ConnectFlags); + #define CHECK_ARG(m_arg) \ if ((m_arg - 1) < p_arg_count) { \ Variant::Type argtype = get_argument_type(m_arg - 1); \ @@ -148,14 +151,35 @@ struct VariantCaster<const T &> { VARIANT_ENUM_CAST(Vector3::Axis); VARIANT_ENUM_CAST(Error); -VARIANT_ENUM_CAST(wchar_t); VARIANT_ENUM_CAST(Margin); VARIANT_ENUM_CAST(Corner); VARIANT_ENUM_CAST(Orientation); VARIANT_ENUM_CAST(HAlign); +VARIANT_ENUM_CAST(VAlign); +VARIANT_ENUM_CAST(PropertyHint); +VARIANT_ENUM_CAST(PropertyUsageFlags); +VARIANT_ENUM_CAST(MethodFlags); VARIANT_ENUM_CAST(Variant::Type); VARIANT_ENUM_CAST(Variant::Operator); +template <> +struct VariantCaster<wchar_t> { + static _FORCE_INLINE_ wchar_t cast(const Variant &p_variant) { + return (wchar_t)p_variant.operator int(); + } +}; +#ifdef PTRCALL_ENABLED +template <> +struct PtrToArg<wchar_t> { + _FORCE_INLINE_ static wchar_t convert(const void *p_ptr) { + return wchar_t(*reinterpret_cast<const int *>(p_ptr)); + } + _FORCE_INLINE_ static void encode(wchar_t p_val, const void *p_ptr) { + *(int *)p_ptr = p_val; + } +}; +#endif + class MethodBind { int method_id; @@ -164,23 +188,22 @@ class MethodBind { Vector<Variant> default_arguments; int default_argument_count; int argument_count; -#ifdef DEBUG_METHODS_ENABLED - Vector<StringName> arg_names; - Vector<StringName> arg_type_hints; - Variant::Type *argument_types; - StringName ret_type; -#endif + bool _const; bool _returns; protected: +#ifdef DEBUG_METHODS_ENABLED + Variant::Type *argument_types; + Vector<StringName> arg_names; +#endif void _set_const(bool p_const); void _set_returns(bool p_returns); #ifdef DEBUG_METHODS_ENABLED virtual Variant::Type _gen_argument_type(int p_arg) const = 0; - virtual StringName _gen_argument_type_hint(int p_arg) const = 0; + virtual PropertyInfo _gen_argument_type_info(int p_arg) const = 0; void _generate_argument_types(int p_count); - void set_argument_types(Variant::Type *p_types) { argument_types = p_types; } + #endif void set_argument_count(int p_count) { argument_count = p_count; } @@ -210,9 +233,6 @@ public: #ifdef DEBUG_METHODS_ENABLED - _FORCE_INLINE_ void set_return_type(const StringName &p_type) { ret_type = p_type; } - _FORCE_INLINE_ StringName get_return_type() const { return ret_type; } - _FORCE_INLINE_ Variant::Type get_argument_type(int p_argument) const { ERR_FAIL_COND_V(p_argument < -1 || p_argument > argument_count, Variant::NIL); @@ -220,12 +240,11 @@ public: } PropertyInfo get_argument_info(int p_argument) const; + PropertyInfo get_return_info() const; - void set_argument_names(const Vector<StringName> &p_names); + void set_argument_names(const Vector<StringName> &p_names); //set by class, db, cant be inferred otherwise Vector<StringName> get_argument_names() const; - void set_argument_type_hints(const Vector<StringName> &p_type_hints); - Vector<StringName> get_argument_type_hints() const; #endif void set_hint_flags(uint32_t p_hint) { hint_flags = p_hint; } uint32_t get_hint_flags() const { return hint_flags | (is_const() ? METHOD_FLAG_CONST : 0) | (is_vararg() ? METHOD_FLAG_VARARG : 0); } @@ -233,28 +252,6 @@ public: _FORCE_INLINE_ int get_argument_count() const { return argument_count; }; -#if 0 - _FORCE_INLINE_ Variant call_safe(const Variant** p_args,int p_arg_count, Variant::CallError& r_error) { - - r_error.error=Variant::CallError::CALL_OK; - check_call( p_args, &errorarg ); - if (!err) - return call(p_object, VARIANT_ARG_PASS ); - - VARIANT_ARGPTRS - String errstr; - String methodname = get_instance_type()+"::"+name; - if (err==CALL_ERROR_ARGUMENT_TYPE) { - errstr="Invalid Argument to call: '"+methodname+"'. Cannot convert argument "+itos(errorarg+1)+" from "+Variant::get_type_name(get_argument_type(errorarg))+" to "+Variant::get_type_name(argptr[errorarg]->get_type())+"."; - } - if (err==CALL_ERROR_EXTRA_ARGUMENT) { - errstr="Invalid call. Member function '"+methodname+"' takes "+itos(get_argument_count())+" argument, but argument "+itos(errorarg+1)+" was received."; - } - - ERR_PRINT(errstr.ascii().get_data()); - return Variant(); - } -#endif virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Variant::CallError &r_error) = 0; #ifdef PTRCALL_ENABLED @@ -281,18 +278,36 @@ public: protected: NativeCall call_method; +#ifdef DEBUG_METHODS_ENABLED + + MethodInfo arguments; +#endif public: - virtual Variant::Type _gen_argument_type(int p_arg) const { +#ifdef DEBUG_METHODS_ENABLED - return Variant::NIL; + virtual PropertyInfo _gen_argument_type_info(int p_arg) const { + + if (p_arg < 0) { + return arguments.return_val; + } else if (p_arg < arguments.arguments.size()) { + return arguments.arguments[p_arg]; + } else { + return PropertyInfo(Variant::NIL, "arg_" + itos(p_arg), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT); + } + } + + virtual Variant::Type _gen_argument_type(int p_arg) const { + return _gen_argument_type_info(p_arg).type; } - virtual StringName _gen_argument_type_hint(int p_arg) const { +#else - return "Variant"; + virtual Variant::Type _gen_argument_type(int p_arg) const { + return Variant::NIL; } +#endif virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Variant::CallError &r_error) { T *instance = static_cast<T *>(p_object); @@ -317,7 +332,9 @@ public: set_argument_names(names); } - set_argument_types(at); + argument_types = at; + arguments = p_info; + arguments.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; #endif } diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h index d8755fd98b..2875eb912f 100644 --- a/core/method_ptrcall.h +++ b/core/method_ptrcall.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/node_path.cpp b/core/node_path.cpp index ad2eae859d..15f950f605 100644 --- a/core/node_path.cpp +++ b/core/node_path.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/node_path.h b/core/node_path.h index 31446ab9b4..eb5b9eb6cf 100644 --- a/core/node_path.h +++ b/core/node_path.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/object.cpp b/core/object.cpp index 62b2b5d545..23e32a214a 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -65,6 +65,7 @@ PropertyInfo::operator Dictionary() const { Dictionary d; d["name"] = name; + d["class_name"] = class_name; d["type"] = type; d["hint"] = hint; d["hint_string"] = hint_string; @@ -82,6 +83,9 @@ PropertyInfo PropertyInfo::from_dict(const Dictionary &p_dict) { if (p_dict.has("name")) pi.name = p_dict["name"]; + if (p_dict.has("class_name")) + pi.class_name = p_dict["class_name"]; + if (p_dict.has("hint")) pi.hint = PropertyHint(int(p_dict["hint"])); @@ -270,6 +274,63 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn arguments.push_back(p_param5); } +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; +} + +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; + arguments.push_back(p_param1); +} + +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; + arguments.push_back(p_param1); + arguments.push_back(p_param2); +} + +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; + arguments.push_back(p_param1); + arguments.push_back(p_param2); + arguments.push_back(p_param3); +} + +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; + arguments.push_back(p_param1); + arguments.push_back(p_param2); + arguments.push_back(p_param3); + arguments.push_back(p_param4); +} + +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) + : name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { + return_val = p_ret; + arguments.push_back(p_param1); + arguments.push_back(p_param2); + arguments.push_back(p_param3); + arguments.push_back(p_param4); + arguments.push_back(p_param5); +} + Object::Connection::operator Variant() const { Dictionary d; @@ -338,35 +399,6 @@ void Object::get_valid_parents_static(List<String> *p_parents) { } void Object::_get_valid_parents_static(List<String> *p_parents) { } -#if 0 -//old style set, deprecated - -void Object::set(const String& p_name, const Variant& p_value) { - - _setv(p_name,p_value); - - /* - if (!_use_builtin_script()) - return; - */ - - bool success; - ClassDB::set_property(this,p_name,p_value,success); - if (success) { - return; - } - - if (p_name=="__meta__") { - metadata=p_value; - } else if (p_name=="script") { - set_script(p_value); - } else if (script_instance) { - script_instance->set(p_name,p_value); - } - - -} -#endif void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid) { @@ -485,34 +517,6 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const { } } -#if 0 -//old style get, deprecated -Variant Object::get(const String& p_name) const { - - Variant ret=_getv(p_name); - if (ret.get_type()!=Variant::NIL) - return ret; - - bool success; - ClassDB::get_property(const_cast<Object*>(this),p_name,ret,success); - if (success) { - return ret; - } - - if (p_name=="__meta__") - return metadata; - else if (p_name=="script") - return script; - - if (script_instance) { - return script_instance->get(p_name); - } - - return Variant(); - -} -#endif - void Object::get_property_list(List<PropertyInfo> *p_list, bool p_reversed) const { if (script_instance && p_reversed) { @@ -592,22 +596,6 @@ Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Vari return Variant(); } -#if 0 -Variant Object::_call_bind(const StringName& p_name, const Variant& p_arg1, const Variant& p_arg2, const Variant& p_arg3, const Variant& p_arg4) { - - ERR_FAIL_COND_V(p_argcount<1,Variant()); - - return call(p_name, p_arg1, p_arg2, p_arg3, p_arg4); -}; - - - - -void Object::_call_deferred_bind(const StringName& p_name, const Variant& p_arg1, const Variant& p_arg2, const Variant& p_arg3, const Variant& p_arg4) { - - call_deferred(p_name, p_arg1, p_arg2, p_arg3, p_arg4); -}; -#endif #ifdef DEBUG_ENABLED static bool _test_call_error(const StringName &p_func, const Variant::CallError &error) { @@ -650,7 +638,7 @@ void Object::call_multilevel(const StringName &p_method, const Variant **p_args, if (p_method == CoreStringNames::get_singleton()->_free) { #ifdef DEBUG_ENABLED - if (cast_to<Reference>()) { + if (Object::cast_to<Reference>(this)) { ERR_EXPLAIN("Can't 'free' a reference."); ERR_FAIL(); return; @@ -760,54 +748,6 @@ Variant Object::callv(const StringName &p_method, const Array &p_args) { } Variant Object::call(const StringName &p_name, VARIANT_ARG_DECLARE) { -#if 0 - if (p_name==CoreStringNames::get_singleton()->_free) { -#ifdef DEBUG_ENABLED - if (cast_to<Reference>()) { - ERR_EXPLAIN("Can't 'free' a reference."); - ERR_FAIL_V(Variant()); - } -#endif - //must be here, must be before everything, - memdelete(this); - return Variant(); - } - - VARIANT_ARGPTRS; - - int argc=0; - for(int i=0;i<VARIANT_ARG_MAX;i++) { - if (argptr[i]->get_type()==Variant::NIL) - break; - argc++; - } - - Variant::CallError error; - - Variant ret; - - if (script_instance) { - ret = script_instance->call(p_name,argptr,argc,error); - if (_test_call_error(p_name,error)) - return ret; - } - - MethodBind *method=ClassDB::get_method(get_type_name(),p_name); - - if (method) { - - - Variant ret = method->call(this,argptr,argc,error); - if (_test_call_error(p_name,error)) - return ret; - - return ret; - } else { - - } - - return Variant(); -#else VARIANT_ARGPTRS; @@ -822,52 +762,9 @@ Variant Object::call(const StringName &p_name, VARIANT_ARG_DECLARE) { Variant ret = call(p_name, argptr, argc, error); return ret; - -#endif } void Object::call_multilevel(const StringName &p_name, VARIANT_ARG_DECLARE) { -#if 0 - if (p_name==CoreStringNames::get_singleton()->_free) { -#ifdef DEBUG_ENABLED - if (cast_to<Reference>()) { - ERR_EXPLAIN("Can't 'free' a reference."); - ERR_FAIL(); - return; - } -#endif - //must be here, must be before everything, - memdelete(this); - return; - } - - VARIANT_ARGPTRS; - - int argc=0; - for(int i=0;i<VARIANT_ARG_MAX;i++) { - if (argptr[i]->get_type()==Variant::NIL) - break; - argc++; - } - - Variant::CallError error; - - if (script_instance) { - script_instance->call(p_name,argptr,argc,error); - _test_call_error(p_name,error); - - } - - MethodBind *method=ClassDB::get_method(get_type_name(),p_name); - - if (method) { - - method->call(this,argptr,argc,error); - _test_call_error(p_name,error); - - } - -#else VARIANT_ARGPTRS; @@ -880,8 +777,6 @@ void Object::call_multilevel(const StringName &p_name, VARIANT_ARG_DECLARE) { //Variant::CallError error; call_multilevel(p_name, argptr, argc); - -#endif } Variant Object::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { @@ -896,7 +791,7 @@ Variant Object::call(const StringName &p_method, const Variant **p_args, int p_a r_error.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; return Variant(); } - if (cast_to<Reference>()) { + if (Object::cast_to<Reference>(this)) { r_error.argument = 0; r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; ERR_EXPLAIN("Can't 'free' a reference."); @@ -1126,22 +1021,6 @@ struct _ObjectSignalDisconnectData { StringName method; }; -#if 0 -void Object::_emit_signal(const StringName& p_name,const Array& p_pargs){ - - Variant args[VARIANT_ARG_MAX]; - - int count = p_pargs.size(); - - for(int i=0;i<count;i++) { - args[i]=p_pargs[i]; - } - - emit_signal(p_name,VARIANT_ARGS_FROM_ARRAY(args)); -} - -#endif - Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Variant::CallError &r_error) { r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; @@ -1310,21 +1189,7 @@ void Object::_add_user_signal(const String &p_name, const Array &p_args) { add_user_signal(mi); } -#if 0 -void Object::_emit_signal(const StringName& p_name,const Array& p_pargs){ - - Variant args[VARIANT_ARG_MAX]; - - int count = p_pargs.size(); - - for(int i=0;i<count;i++) { - args[i]=p_pargs[i]; - } - - emit_signal(p_name,VARIANT_ARGS_FROM_ARRAY(args)); -} -#endif Array Object::_get_signal_list() const { List<MethodInfo> signal_list; @@ -1338,6 +1203,7 @@ Array Object::_get_signal_list() const { return ret; } + Array Object::_get_signal_connection_list(const String &p_signal) const { List<Connection> conns; @@ -1468,7 +1334,7 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str 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_EXPLAIN("Signal '" + p_signal + "' is already connected to given method '" + p_to_method + "' in that object."); ERR_FAIL_COND_V(s->slot_map.has(target), ERR_INVALID_PARAMETER); } @@ -1560,7 +1426,7 @@ void Object::initialize_class() { initialized = true; } -StringName Object::XL_MESSAGE(const StringName &p_message) const { +StringName Object::tr(const StringName &p_message) const { if (!_can_translate || !TranslationServer::get_singleton()) return p_message; @@ -1568,11 +1434,6 @@ StringName Object::XL_MESSAGE(const StringName &p_message) const { return TranslationServer::get_singleton()->translate(p_message); } -StringName Object::tr(const StringName &p_message) const { - - return XL_MESSAGE(p_message); -} - void Object::_clear_internal_resource_paths(const Variant &p_var) { switch (p_var.get_type()) { @@ -1712,11 +1573,10 @@ void Object::_bind_methods() { ClassDB::bind_method(D_METHOD("set_block_signals", "enable"), &Object::set_block_signals); ClassDB::bind_method(D_METHOD("is_blocking_signals"), &Object::is_blocking_signals); - ClassDB::bind_method(D_METHOD("set_message_translation", "enable"), &Object::set_message_translation); - ClassDB::bind_method(D_METHOD("can_translate_messages"), &Object::can_translate_messages); ClassDB::bind_method(D_METHOD("property_list_changed_notify"), &Object::property_list_changed_notify); - ClassDB::bind_method(D_METHOD("XL_MESSAGE", "message"), &Object::XL_MESSAGE); + ClassDB::bind_method(D_METHOD("set_message_translation", "enable"), &Object::set_message_translation); + ClassDB::bind_method(D_METHOD("can_translate_messages"), &Object::can_translate_messages); ClassDB::bind_method(D_METHOD("tr", "message"), &Object::tr); ClassDB::bind_method(D_METHOD("is_queued_for_deletion"), &Object::is_queued_for_deletion); @@ -1726,7 +1586,7 @@ void Object::_bind_methods() { ADD_SIGNAL(MethodInfo("script_changed")); BIND_VMETHOD(MethodInfo("_notification", PropertyInfo(Variant::INT, "what"))); - BIND_VMETHOD(MethodInfo("_set:bool", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "_set", PropertyInfo(Variant::STRING, "property"), PropertyInfo(Variant::NIL, "value"))); #ifdef TOOLS_ENABLED MethodInfo miget("_get", PropertyInfo(Variant::STRING, "property")); miget.return_val.name = "Variant"; @@ -1743,9 +1603,9 @@ void Object::_bind_methods() { BIND_CONSTANT(NOTIFICATION_POSTINITIALIZE); BIND_CONSTANT(NOTIFICATION_PREDELETE); - BIND_CONSTANT(CONNECT_DEFERRED); - BIND_CONSTANT(CONNECT_PERSIST); - BIND_CONSTANT(CONNECT_ONESHOT); + BIND_ENUM_CONSTANT(CONNECT_DEFERRED); + BIND_ENUM_CONSTANT(CONNECT_PERSIST); + BIND_ENUM_CONSTANT(CONNECT_ONESHOT); } void Object::call_deferred(const StringName &p_method, VARIANT_ARG_DECLARE) { diff --git a/core/object.h b/core/object.h index 4648d9d90e..6e1ed4308e 100644 --- a/core/object.h +++ b/core/object.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -83,6 +83,7 @@ enum PropertyHint { PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base + PROPERTY_HINT_OBJECT_TOO_BIG, ///< object is too big to send PROPERTY_HINT_MAX, }; @@ -106,6 +107,8 @@ enum PropertyUsageFlags { PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768, PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536, PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE = 1 << 17, + PROPERTY_USAGE_CLASS_IS_ENUM = 1 << 18, + PROPERTY_USAGE_NIL_IS_VARIANT = 1 << 19, 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, @@ -125,6 +128,7 @@ struct PropertyInfo { Variant::Type type; String name; + StringName class_name; //for classes PropertyHint hint; String hint_string; uint32_t usage; @@ -144,13 +148,27 @@ struct PropertyInfo { hint(PROPERTY_HINT_NONE), usage(PROPERTY_USAGE_DEFAULT) { } - PropertyInfo(Variant::Type p_type, const String p_name, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", uint32_t p_usage = PROPERTY_USAGE_DEFAULT) + PropertyInfo(Variant::Type p_type, const String p_name, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", uint32_t p_usage = PROPERTY_USAGE_DEFAULT, const StringName &p_class_name = StringName()) : type(p_type), name(p_name), hint(p_hint), hint_string(p_hint_string), usage(p_usage) { + + if (hint == PROPERTY_HINT_RESOURCE_TYPE) { + class_name = hint_string; + } else { + class_name = p_class_name; + } } + PropertyInfo(const StringName &p_class_name) + : type(Variant::OBJECT), + hint(PROPERTY_HINT_NONE), + usage(PROPERTY_USAGE_DEFAULT) { + + class_name = p_class_name; + } + bool operator<(const PropertyInfo &p_info) const { return name < p_info.name; } @@ -167,6 +185,7 @@ struct MethodInfo { uint32_t flags; int id; + inline bool operator==(const MethodInfo &p_method) const { return id == p_method.id; } inline bool operator<(const MethodInfo &p_method) const { return id == p_method.id ? (name < p_method.name) : (id < p_method.id); } operator Dictionary() const; @@ -186,6 +205,12 @@ struct MethodInfo { MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3); MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4); MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5); + MethodInfo(const PropertyInfo &p_ret, const String &p_name); + MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1); + MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2); + MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3); + MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4); + MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5); }; // old cast_to @@ -540,46 +565,46 @@ public: void add_change_receptor(Object *p_receptor); void remove_change_receptor(Object *p_receptor); -// TODO: ensure 'this' is never NULL since it's UB, but by now, avoid warning flood -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wundefined-bool-conversion" -#endif - template <class T> - T *cast_to() { - + static T *cast_to(Object *p_object) { +#ifdef DEBUG_ENABLED + // TODO there are some legitimate reasons to pass NULL as p_object. + // we need to figure out how to deal with that in debug mode. + // This code will return NULL for a NULL input in release mode also. + ERR_FAIL_COND_V(p_object == NULL, NULL); +#endif #ifndef NO_SAFE_CAST - return SAFE_CAST<T *>(this); + return dynamic_cast<T *>(p_object); #else - if (!this) + if (!p_object) return NULL; - if (is_class_ptr(T::get_class_ptr_static())) - return static_cast<T *>(this); + if (p_object->is_class_ptr(T::get_class_ptr_static())) + return static_cast<T *>(p_object); else return NULL; #endif } template <class T> - const T *cast_to() const { - + static const T *cast_to(const Object *p_object) { +#ifdef DEBUG_ENABLED + // TODO there are some legitimate reasons to pass NULL as p_object. + // we need to figure out how to deal with that in debug mode. + // This code will return NULL for a NULL input in release mode also. + ERR_FAIL_COND_V(p_object == NULL, NULL); +#endif #ifndef NO_SAFE_CAST - return SAFE_CAST<const T *>(this); + return dynamic_cast<const T *>(p_object); #else - if (!this) + if (!p_object) return NULL; - if (is_class_ptr(T::get_class_ptr_static())) - return static_cast<const T *>(this); + if (p_object->is_class_ptr(T::get_class_ptr_static())) + return static_cast<const T *>(p_object); else return NULL; #endif } -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - enum { NOTIFICATION_POSTINITIALIZE = 0, @@ -678,8 +703,7 @@ public: virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; - StringName XL_MESSAGE(const StringName &p_message) const; //translate message (internationalization) - StringName tr(const StringName &p_message) const; //translate message (alternative) + StringName tr(const StringName &p_message) const; // translate message (internationalization) bool _is_queued_for_deletion; // set to true by SceneTree::queue_delete() bool is_queued_for_deletion() const; diff --git a/core/os/copymem.h b/core/os/copymem.h index 3ad2403f9c..789dce76e7 100644 --- a/core/os/copymem.h +++ b/core/os/copymem.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 391ae78c85..f24d6d16ca 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/dir_access.h b/core/os/dir_access.h index 4bee229555..6ad8b4c49b 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 9d1fefc925..b969b58bfb 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/file_access.h b/core/os/file_access.h index beed7551fb..8393f0530b 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/input.cpp b/core/os/input.cpp index c7b32b939a..65752662d7 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -86,10 +86,10 @@ void Input::_bind_methods() { ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image", "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); - BIND_CONSTANT(MOUSE_MODE_CAPTURED); - BIND_CONSTANT(MOUSE_MODE_CONFINED); + BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE); + BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN); + BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED); + BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED); ADD_SIGNAL(MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "connected"))); } diff --git a/core/os/input.h b/core/os/input.h index 6759c624e3..f98b97e647 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index cb38eb67b6..88037859aa 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,11 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "input_event.h" + #include "input_map.h" #include "os/keyboard.h" -/** - * - */ void InputEvent::set_id(uint32_t p_id) { id = p_id; @@ -99,25 +97,6 @@ bool InputEvent::is_action_type() const { return false; } -#if 0 -if (String(p_method) == "is_action" && p_argidx == 0) { - - List<PropertyInfo> pinfo; - ProjectSettings::get_singleton()->get_property_list(&pinfo); - - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - - if (!pi.name.begins_with("input/")) - continue; - - String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); - result.insert("\"" + name + "\""); - } - -} else -#endif - void InputEvent::_bind_methods() { ClassDB::bind_method(D_METHOD("set_id", "id"), &InputEvent::set_id); @@ -483,6 +462,38 @@ bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event) const { return mb->button_index == button_index; } +String InputEventMouseButton::as_text() const { + + String button_index_string = ""; + switch (get_button_index()) { + case BUTTON_LEFT: + button_index_string = "BUTTON_LEFT"; + break; + case BUTTON_RIGHT: + button_index_string = "BUTTON_RIGHT"; + break; + case BUTTON_MIDDLE: + button_index_string = "BUTTON_MIDDLE"; + break; + case BUTTON_WHEEL_UP: + button_index_string = "BUTTON_WHEEL_UP"; + break; + case BUTTON_WHEEL_DOWN: + button_index_string = "BUTTON_WHEEL_DOWN"; + break; + case BUTTON_WHEEL_LEFT: + button_index_string = "BUTTON_WHEEL_LEFT"; + break; + case BUTTON_WHEEL_RIGHT: + button_index_string = "BUTTON_WHEEL_RIGHT"; + break; + default: + button_index_string = itos(get_button_index()); + break; + } + return "InputEventMouseButton : button_index=" + button_index_string + ", pressed=" + (pressed ? "true" : "false") + ", position=(" + String(get_position()) + "), button_mask=" + itos(get_button_mask()) + ", doubleclick=" + (doubleclick ? "true" : "false"); +} + void InputEventMouseButton::_bind_methods() { ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMouseButton::set_factor); @@ -559,6 +570,26 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co return mm; } +String InputEventMouseMotion::as_text() const { + + String button_mask_string = ""; + switch (get_button_mask()) { + case BUTTON_MASK_LEFT: + button_mask_string = "BUTTON_MASK_LEFT"; + break; + case BUTTON_MASK_MIDDLE: + button_mask_string = "BUTTON_MASK_MIDDLE"; + break; + case BUTTON_MASK_RIGHT: + button_mask_string = "BUTTON_MASK_RIGHT"; + break; + default: + button_mask_string = itos(get_button_mask()); + break; + } + return "InputEventMouseMotion : button_mask=" + button_mask_string + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + ")"; +} + void InputEventMouseMotion::_bind_methods() { ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventMouseMotion::set_relative); @@ -609,6 +640,11 @@ bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event) const return (axis == jm->axis && (axis_value < 0) == (jm->axis_value < 0)); } +String InputEventJoypadMotion::as_text() const { + + return "InputEventJoypadMotion : axis=" + itos(axis) + ", axis_value=" + String(Variant(axis_value)); +} + void InputEventJoypadMotion::_bind_methods() { ClassDB::bind_method(D_METHOD("set_axis", "axis"), &InputEventJoypadMotion::set_axis); @@ -665,6 +701,11 @@ bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event) const return button_index == jb->button_index; } +String InputEventJoypadButton::as_text() const { + + return "InputEventJoypadButton : button_index=" + itos(button_index) + ", pressed=" + (pressed ? "true" : "false") + ", pressure=" + String(Variant(pressure)); +} + void InputEventJoypadButton::_bind_methods() { ClassDB::bind_method(D_METHOD("set_button_index", "button_index"), &InputEventJoypadButton::set_button_index); @@ -730,6 +771,11 @@ Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, co return st; } +String InputEventScreenTouch::as_text() const { + + return "InputEventScreenTouch : index=" + itos(index) + ", pressed=" + (pressed ? "true" : "false") + ", position=(" + String(get_position()) + ")"; +} + void InputEventScreenTouch::_bind_methods() { ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenTouch::set_index); @@ -808,6 +854,11 @@ Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, con return sd; } +String InputEventScreenDrag::as_text() const { + + return "InputEventScreenDrag : index=" + itos(index) + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + ")"; +} + void InputEventScreenDrag::_bind_methods() { ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenDrag::set_index); @@ -857,6 +908,11 @@ bool InputEventAction::is_action(const StringName &p_action) const { return action == p_action; } +String InputEventAction::as_text() const { + + return "InputEventAction : action=" + action + ", pressed=(" + (pressed ? "true" : "false"); +} + void InputEventAction::_bind_methods() { ClassDB::bind_method(D_METHOD("set_action", "action"), &InputEventAction::set_action); diff --git a/core/os/input_event.h b/core/os/input_event.h index d1fd7cc90f..5dc0f91d5f 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -307,6 +307,7 @@ public: virtual bool action_match(const Ref<InputEvent> &p_event) const; virtual bool is_action_type() const { return true; } + virtual String as_text() const; InputEventMouseButton(); }; @@ -328,6 +329,7 @@ public: Vector2 get_speed() const; virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const; + virtual String as_text() const; InputEventMouseMotion(); }; @@ -352,6 +354,7 @@ public: virtual bool action_match(const Ref<InputEvent> &p_event) const; virtual bool is_action_type() const { return true; } + virtual String as_text() const; InputEventJoypadMotion(); }; @@ -378,6 +381,7 @@ public: virtual bool action_match(const Ref<InputEvent> &p_event) const; virtual bool is_action_type() const { return true; } + virtual String as_text() const; InputEventJoypadButton(); }; @@ -402,6 +406,7 @@ public: virtual bool is_pressed() const; virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const; + virtual String as_text() const; InputEventScreenTouch(); }; @@ -431,6 +436,7 @@ public: Vector2 get_speed() const; virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const; + virtual String as_text() const; InputEventScreenDrag(); }; @@ -455,6 +461,7 @@ public: virtual bool is_action(const StringName &p_action) const; virtual bool is_action_type() const { return true; } + virtual String as_text() const; InputEventAction(); }; diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index 9b3e376ea6..30e7d5e791 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/keyboard.h b/core/os/keyboard.h index 1ef26de183..509ff23a93 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index 248f5537c6..b146d370f1 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -54,6 +54,8 @@ void MainLoop::_bind_methods() { BIND_CONSTANT(NOTIFICATION_WM_QUIT_REQUEST); BIND_CONSTANT(NOTIFICATION_WM_UNFOCUS_REQUEST); BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING); + BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED); + BIND_CONSTANT(NOTIFICATION_WM_ABOUT); }; void MainLoop::set_init_script(const Ref<Script> &p_init_script) { diff --git a/core/os/main_loop.h b/core/os/main_loop.h index 23b352468e..fd76d8454f 100644 --- a/core/os/main_loop.h +++ b/core/os/main_loop.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -56,7 +56,11 @@ public: NOTIFICATION_WM_GO_BACK_REQUEST = 7, NOTIFICATION_WM_UNFOCUS_REQUEST = 8, NOTIFICATION_OS_MEMORY_WARNING = 9, - NOTIFICATION_TRANSLATION_CHANGED = 10, + // Note: NOTIFICATION_TRANSLATION_CHANGED and NOTIFICATION_WM_ABOUT used to have id=10 and id=11 but these + // conflict with NOTIFICATION_ENTER_TREE (id=10) and NOTIFICATION_EXIT_TREE (id=11), so id=90 and id=91 + // fixes this issue. + NOTIFICATION_TRANSLATION_CHANGED = 90, + NOTIFICATION_WM_ABOUT = 91, }; virtual void input_event(const Ref<InputEvent> &p_event); diff --git a/core/os/memory.cpp b/core/os/memory.cpp index acc960acd9..74d5cbbea1 100644 --- a/core/os/memory.cpp +++ b/core/os/memory.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/memory.h b/core/os/memory.h index e1d7138ad5..f8b3da579b 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/mutex.cpp b/core/os/mutex.cpp index 134d313bdf..d3edc2c423 100644 --- a/core/os/mutex.cpp +++ b/core/os/mutex.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/mutex.h b/core/os/mutex.h index 80a30b0b26..9e353df33d 100644 --- a/core/os/mutex.h +++ b/core/os/mutex.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/os.cpp b/core/os/os.cpp index 3a06a3fa8f..1292b7eeed 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -171,7 +171,7 @@ static FileAccess *_OSPRF = NULL; static void _OS_printres(Object *p_obj) { - Resource *res = p_obj->cast_to<Resource>(); + Resource *res = Object::cast_to<Resource>(p_obj); if (!res) return; diff --git a/core/os/os.h b/core/os/os.h index 4d64e4a9f0..258708eea2 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -164,9 +164,9 @@ public: virtual int get_screen_count() const { return 1; } virtual int get_current_screen() const { return 0; } virtual void set_current_screen(int p_screen) {} - virtual Point2 get_screen_position(int p_screen = 0) const { return Point2(); } - virtual Size2 get_screen_size(int p_screen = 0) const { return get_window_size(); } - virtual int get_screen_dpi(int p_screen = 0) const { return 72; } + virtual Point2 get_screen_position(int p_screen = -1) const { return Point2(); } + virtual Size2 get_screen_size(int p_screen = -1) const { return get_window_size(); } + virtual int get_screen_dpi(int p_screen = -1) const { return 72; } virtual Point2 get_window_position() const { return Vector2(); } virtual void set_window_position(const Point2 &p_position) {} virtual Size2 get_window_size() const = 0; diff --git a/core/os/power.h b/core/os/power.h index dbf4c75c59..59a091012e 100644 --- a/core/os/power.h +++ b/core/os/power.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/rw_lock.cpp b/core/os/rw_lock.cpp index 0427374de4..d0ad249afa 100644 --- a/core/os/rw_lock.cpp +++ b/core/os/rw_lock.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h index 253bd260ee..c13eb8147c 100644 --- a/core/os/rw_lock.h +++ b/core/os/rw_lock.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/semaphore.cpp b/core/os/semaphore.cpp index ce75186001..ea0a02ae22 100644 --- a/core/os/semaphore.cpp +++ b/core/os/semaphore.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/semaphore.h b/core/os/semaphore.h index f2be966979..c169e0212e 100644 --- a/core/os/semaphore.h +++ b/core/os/semaphore.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/shell.cpp b/core/os/shell.cpp index 9bf2d4466d..07e4924c38 100644 --- a/core/os/shell.cpp +++ b/core/os/shell.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/shell.h b/core/os/shell.h index 33044ee10e..7cb95dd5c8 100644 --- a/core/os/shell.h +++ b/core/os/shell.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread.cpp b/core/os/thread.cpp index bd565334c3..af8ae847dc 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread.h b/core/os/thread.h index 1103f67ff2..697494708e 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread_dummy.cpp b/core/os/thread_dummy.cpp index 88c111297d..39b5bdd9b8 100644 --- a/core/os/thread_dummy.cpp +++ b/core/os/thread_dummy.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread_dummy.h b/core/os/thread_dummy.h index 64941a71f8..56e7061eee 100644 --- a/core/os/thread_dummy.h +++ b/core/os/thread_dummy.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread_safe.cpp b/core/os/thread_safe.cpp index 486e072985..a49d412254 100644 --- a/core/os/thread_safe.cpp +++ b/core/os/thread_safe.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread_safe.h b/core/os/thread_safe.h index 0cecf33cc2..f9a1d0f62b 100644 --- a/core/os/thread_safe.h +++ b/core/os/thread_safe.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index eb4aeb758a..4040680c6d 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/packed_data_container.h b/core/packed_data_container.h index bab994fc94..e6a674d7ce 100644 --- a/core/packed_data_container.h +++ b/core/packed_data_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/pair.h b/core/pair.h index d517339ddf..f780c79c81 100644 --- a/core/pair.h +++ b/core/pair.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/path_remap.cpp b/core/path_remap.cpp index c5961213e8..d8fa2748bc 100644 --- a/core/path_remap.cpp +++ b/core/path_remap.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/path_remap.h b/core/path_remap.h index 95249c6334..04da4c1510 100644 --- a/core/path_remap.h +++ b/core/path_remap.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp index d563925f3b..c122d21545 100644 --- a/core/pool_allocator.cpp +++ b/core/pool_allocator.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/pool_allocator.h b/core/pool_allocator.h index f62e410e66..12de4d58e8 100644 --- a/core/pool_allocator.h +++ b/core/pool_allocator.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/print_string.cpp b/core/print_string.cpp index 4a4c8093ca..92a04cbf0b 100644 --- a/core/print_string.cpp +++ b/core/print_string.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/print_string.h b/core/print_string.h index c4cd610856..9f8420c31a 100644 --- a/core/print_string.h +++ b/core/print_string.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 4a1b35ea4a..ce1d7918db 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -733,46 +733,6 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust } return OK; - -#if 0 - Error err = file->open(dst_file,FileAccess::WRITE); - if (err) { - memdelete(file); - ERR_EXPLAIN("Couldn't save project.godot"); - ERR_FAIL_COND_V(err,err) - } - - - for(Map<String,List<String> >::Element *E=props.front();E;E=E->next()) { - - if (E!=props.front()) - file->store_string("\n"); - - if (E->key()!="") - file->store_string("["+E->key()+"]\n\n"); - for(List<String>::Element *F=E->get().front();F;F=F->next()) { - - String key = F->get(); - if (E->key()!="") - key=E->key()+"/"+key; - Variant value; - - if (p_custom.has(key)) - value=p_custom[key]; - else - value = get(key); - - file->store_string(F->get()+"="+_encode_variant(value)+"\n"); - - } - } - - file->close(); - memdelete(file); - - - return OK; -#endif } Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) { diff --git a/core/project_settings.h b/core/project_settings.h index cee3b3b5f3..5c8907c74e 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/ref_ptr.cpp b/core/ref_ptr.cpp index c2128fd45d..4a27b523fb 100644 --- a/core/ref_ptr.cpp +++ b/core/ref_ptr.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -69,7 +69,7 @@ RID RefPtr::get_rid() const { Ref<Reference> *ref = reinterpret_cast<Ref<Reference> *>(&data[0]); if (ref->is_null()) return RID(); - Resource *res = (*ref)->cast_to<Resource>(); + Resource *res = Object::cast_to<Resource>(ref->ptr()); if (res) return res->get_rid(); return RID(); diff --git a/core/ref_ptr.h b/core/ref_ptr.h index b76bbab7fa..bb98f0507a 100644 --- a/core/ref_ptr.h +++ b/core/ref_ptr.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/reference.cpp b/core/reference.cpp index e9629ee7c0..bb70628cbe 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -98,7 +98,7 @@ Variant WeakRef::get_ref() const { Object *obj = ObjectDB::get_instance(ref); if (!obj) return Variant(); - Reference *r = obj->cast_to<Reference>(); + Reference *r = cast_to<Reference>(obj); if (r) { return REF(r); @@ -124,44 +124,3 @@ void WeakRef::_bind_methods() { ClassDB::bind_method(D_METHOD("get_ref"), &WeakRef::get_ref); } -#if 0 - -Reference * RefBase::get_reference_from_ref(const RefBase &p_base) { - - return p_base.get_reference(); -} -void RefBase::ref_inc(Reference *p_reference) { - - p_reference->refcount.ref(); -} -bool RefBase::ref_dec(Reference *p_reference) { - - bool ref = p_reference->refcount.unref(); - return ref; -} - -Reference *RefBase::first_ref(Reference *p_reference) { - - if (p_reference->refcount.ref()) { - - // this may fail in the scenario of two threads assigning the pointer for the FIRST TIME - // at the same time, which is never likely to happen (would be crazy to do) - // so don't do it. - - if (p_reference->refcount_init.get()>0) { - p_reference->refcount_init.unref(); - p_reference->refcount.unref(); // first referencing is already 1, so compensate for the ref above - } - - return p_reference; - } else { - - return 0; - } - -} -char * RefBase::get_refptr_data(const RefPtr &p_refptr) const { - - return p_refptr.data; -} -#endif diff --git a/core/reference.h b/core/reference.h index 7f48f8323e..5fe8296314 100644 --- a/core/reference.h +++ b/core/reference.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -59,21 +59,6 @@ public: ~Reference(); }; -#if 0 -class RefBase { -protected: - void ref_inc(Reference *p_reference); - bool ref_dec(Reference *p_reference); - Reference *first_ref(Reference *p_reference); - Reference * get_reference_from_ref(const RefBase &p_base); - virtual Reference * get_reference() const=0; - char * get_refptr_data(const RefPtr &p_refptr) const; -public: - - virtual ~RefBase() {} -}; -#endif - template <class T> class Ref { @@ -151,20 +136,10 @@ public: return refptr; }; -#if 0 - // go to RefPtr - operator RefPtr() const { - - return get_ref_ptr(); - } -#endif - -#if 1 operator Variant() const { return Variant(get_ref_ptr()); } -#endif void operator=(const Ref &p_from) { @@ -180,7 +155,7 @@ public: return; } Ref r; - r.reference = refb->cast_to<T>(); + r.reference = Object::cast_to<T>(refb); ref(r); r.reference = NULL; } @@ -194,7 +169,7 @@ public: return; } Ref r; - r.reference = refb->cast_to<T>(); + r.reference = Object::cast_to<T>(refb); ref(r); r.reference = NULL; } @@ -209,7 +184,7 @@ public: return; } Ref r; - r.reference = refb->cast_to<T>(); + r.reference = Object::cast_to<T>(refb); ref(r); r.reference = NULL; } @@ -230,7 +205,7 @@ public: return; } Ref r; - r.reference = refb->cast_to<T>(); + r.reference = Object::cast_to<T>(refb); ref(r); r.reference = NULL; } @@ -254,7 +229,7 @@ public: return; } Ref r; - r.reference = refb->cast_to<T>(); + r.reference = Object::cast_to<T>(refb); ref(r); r.reference = NULL; } @@ -269,7 +244,7 @@ public: return; } Ref r; - r.reference = refb->cast_to<T>(); + r.reference = Object::cast_to<T>(refb); ref(r); r.reference = NULL; } @@ -374,12 +349,16 @@ struct PtrToArg<const RefPtr &> { } }; +#endif // PTRCALL_ENABLED + +#ifdef DEBUG_METHODS_ENABLED + template <class T> struct GetTypeInfo<Ref<T> > { enum { VARIANT_TYPE = Variant::OBJECT }; - static inline StringName get_class_name() { - return T::get_class_static(); + static inline PropertyInfo get_class_info() { + return PropertyInfo(Variant::OBJECT, String(), PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static()); } }; @@ -387,10 +366,11 @@ template <class T> struct GetTypeInfo<const Ref<T> &> { enum { VARIANT_TYPE = Variant::OBJECT }; - static inline StringName get_class_name() { - return T::get_class_static(); + static inline PropertyInfo get_class_info() { + return PropertyInfo(Variant::OBJECT, String(), PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static()); } }; -#endif +#endif // DEBUG_METHODS_ENABLED + #endif // REFERENCE_H diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 43f781af55..27c31127a4 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -39,6 +39,7 @@ #include "input_map.h" #include "io/config_file.h" #include "io/http_client.h" +#include "io/marshalls.h" #include "io/packet_peer.h" #include "io/packet_peer_udp.h" #include "io/pck_packer.h" @@ -56,7 +57,6 @@ #include "project_settings.h" #include "translation.h" #include "undo_redo.h" - static ResourceFormatSaverBinary *resource_saver_binary = NULL; static ResourceFormatLoaderBinary *resource_loader_binary = NULL; static ResourceFormatImporter *resource_format_importer = NULL; @@ -75,6 +75,8 @@ static _Geometry *_geometry = NULL; extern Mutex *_global_mutex; +extern void register_global_constants(); +extern void unregister_global_constants(); extern void register_variant_methods(); extern void unregister_variant_methods(); @@ -88,6 +90,7 @@ void register_core_types() { StringName::setup(); + register_global_constants(); register_variant_methods(); CoreStringNames::create(); @@ -157,6 +160,7 @@ void register_core_types() { ClassDB::register_class<PackedDataContainer>(); ClassDB::register_virtual_class<PackedDataContainerRef>(); ClassDB::register_class<AStar>(); + ClassDB::register_class<EncodedObjectAsID>(); ip = IP::create(); @@ -217,6 +221,7 @@ void unregister_core_types() { ObjectDB::cleanup(); unregister_variant_methods(); + unregister_global_constants(); ClassDB::cleanup(); ResourceCache::clear(); diff --git a/core/register_core_types.h b/core/register_core_types.h index 794c45dff0..cf84d70930 100644 --- a/core/register_core_types.h +++ b/core/register_core_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/resource.cpp b/core/resource.cpp index a0b0fd24e1..37d42226b4 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/resource.h b/core/resource.h index bbf233d53e..7dc3b67291 100644 --- a/core/resource.h +++ b/core/resource.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/rid.cpp b/core/rid.cpp index ca1d2be421..cb16715936 100644 --- a/core/rid.cpp +++ b/core/rid.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/rid.h b/core/rid.h index a93d7d912e..276375167e 100644 --- a/core/rid.h +++ b/core/rid.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/ring_buffer.h b/core/ring_buffer.h index 8b32bb5e10..6c882f1ef9 100644 --- a/core/ring_buffer.h +++ b/core/ring_buffer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/safe_refcount.cpp b/core/safe_refcount.cpp index 971e9ad1d5..c330a983a7 100644 --- a/core/safe_refcount.cpp +++ b/core/safe_refcount.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/safe_refcount.h b/core/safe_refcount.h index ed0620c777..802d84cccc 100644 --- a/core/safe_refcount.h +++ b/core/safe_refcount.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/script_debugger_local.cpp b/core/script_debugger_local.cpp index d2ccf495ae..c2632da38b 100644 --- a/core/script_debugger_local.cpp +++ b/core/script_debugger_local.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/script_debugger_local.h b/core/script_debugger_local.h index d32edb503b..097c7c41f3 100644 --- a/core/script_debugger_local.h +++ b/core/script_debugger_local.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 44e86bca6a..8875732b8e 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -30,10 +30,10 @@ #include "script_debugger_remote.h" #include "io/ip.h" +#include "io/marshalls.h" #include "os/input.h" #include "os/os.h" #include "project_settings.h" - void ScriptDebuggerRemote::_send_video_memory() { List<ResourceUsage> usage; @@ -120,6 +120,18 @@ static ObjectID safe_get_instance_id(const Variant &p_v) { } } +void ScriptDebuggerRemote::_put_variable(const String &p_name, const Variant &p_variable) { + + packet_peer_stream->put_var(p_name); + int len = 0; + Error err = encode_variant(p_variable, NULL, len); + if (len > packet_peer_stream->get_output_buffer_max_size()) { //limit to max size + packet_peer_stream->put_var(Variant()); + } else { + packet_peer_stream->put_var(p_variable); + } +} + void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) { //this function is called when there is a debugger break (bug on script) @@ -130,8 +142,6 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) ERR_FAIL(); } - OS::get_singleton()->enable_for_stealing_focus(ProjectSettings::get_singleton()->get("editor_pid")); - packet_peer_stream->put_var("debug_enter"); packet_peer_stream->put_var(2); packet_peer_stream->put_var(p_can_continue); @@ -210,14 +220,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) while (E) { - if (F->get().get_type() == Variant::OBJECT) { - packet_peer_stream->put_var("*" + E->get()); - String pretty_print = F->get().operator String(); - packet_peer_stream->put_var(pretty_print.ascii().get_data()); - } else { - packet_peer_stream->put_var(E->get()); - packet_peer_stream->put_var(F->get()); - } + _put_variable(E->get(), F->get()); E = E->next(); F = F->next(); @@ -231,15 +234,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) List<Variant>::Element *F = local_vals.front(); while (E) { - - if (F->get().get_type() == Variant::OBJECT) { - packet_peer_stream->put_var("*" + E->get()); - String pretty_print = F->get().operator String(); - packet_peer_stream->put_var(pretty_print.ascii().get_data()); - } else { - packet_peer_stream->put_var(E->get()); - packet_peer_stream->put_var(F->get()); - } + _put_variable(E->get(), F->get()); E = E->next(); F = F->next(); @@ -566,30 +561,19 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) { } Variant var = obj->get(E->get().name); + packet_peer_stream->put_var(E->get().type); + //only send information that can be sent.. - if (E->get().type == Variant::OBJECT || var.get_type() == Variant::OBJECT) { - - ObjectID id2; - Object *obj = var; - if (obj) { - id2 = obj->get_instance_id(); - } else { - id2 = 0; - } + int len = 0; //test how big is this to encode + encode_variant(var, NULL, len); - packet_peer_stream->put_var(Variant::INT); //hint string - packet_peer_stream->put_var(PROPERTY_HINT_OBJECT_ID); //hint - packet_peer_stream->put_var(E->get().hint_string); //hint string - packet_peer_stream->put_var(id2); //value + if (len > packet_peer_stream->get_output_buffer_max_size()) { //limit to max size + packet_peer_stream->put_var(PROPERTY_HINT_OBJECT_TOO_BIG); + packet_peer_stream->put_var(""); + packet_peer_stream->put_var(Variant()); } else { - packet_peer_stream->put_var(E->get().type); packet_peer_stream->put_var(E->get().hint); packet_peer_stream->put_var(E->get().hint_string); - //only send information that can be sent.. - - if (var.get_type() >= Variant::DICTIONARY) { - var = Array(); //send none for now, may be to big - } packet_peer_stream->put_var(var); } } diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index 924e3774a2..b1ef88b812 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -126,6 +126,8 @@ class ScriptDebuggerRemote : public ScriptDebugger { Vector<FrameData> profile_frame_data; + void _put_variable(const String &p_name, const Variant &p_variable); + public: struct ResourceUsage { diff --git a/core/script_language.cpp b/core/script_language.cpp index 4664049145..f2be15897e 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -54,6 +54,12 @@ void Script::_bind_methods() { ClassDB::bind_method(D_METHOD("get_source_code"), &Script::get_source_code); ClassDB::bind_method(D_METHOD("set_source_code", "source"), &Script::set_source_code); ClassDB::bind_method(D_METHOD("reload", "keep_state"), &Script::reload, DEFVAL(false)); + + ClassDB::bind_method(D_METHOD("has_method", "method_name"), &Script::has_method); + ClassDB::bind_method(D_METHOD("has_script_signal", "signal_name"), &Script::has_script_signal); + + ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool); + ClassDB::bind_method(D_METHOD("get_node_type"), &Script::get_node_type); } void ScriptServer::set_scripting_enabled(bool p_enabled) { diff --git a/core/script_language.h b/core/script_language.h index 7aba3ec0f1..342d8c8072 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -207,7 +207,7 @@ public: virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const = 0; virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; } - virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint) { return ERR_UNAVAILABLE; } + virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_force, String &r_call_hint) { return ERR_UNAVAILABLE; } struct LookupResult { enum Type { diff --git a/core/self_list.h b/core/self_list.h index e229d5bf8e..053ab40162 100644 --- a/core/self_list.h +++ b/core/self_list.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/set.h b/core/set.h index 6e6f07508c..317e180869 100644 --- a/core/set.h +++ b/core/set.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/simple_type.h b/core/simple_type.h index 6003bd393f..96e79966e0 100644 --- a/core/simple_type.h +++ b/core/simple_type.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -33,95 +33,21 @@ /* Batch of specializations to obtain the actual simple type */ template <class T> -struct GetSimpleType { - - T type; -}; - -template <class T> struct GetSimpleTypeT { typedef T type_t; }; template <class T> -struct GetSimpleType<T &> { - - T type; -}; - -template <class T> struct GetSimpleTypeT<T &> { typedef T type_t; }; template <class T> -struct GetSimpleType<T const> { - - T type; - _FORCE_INLINE_ GetSimpleType() {} -}; - -template <class T> struct GetSimpleTypeT<T const> { typedef T type_t; }; -template <class T> -struct GetSimpleType<const T &> { - - T type; - _FORCE_INLINE_ GetSimpleType() {} -}; - -template <class T> -struct GetSimpleType<T *> { - - T *type; - _FORCE_INLINE_ GetSimpleType() { type = NULL; } -}; - -template <class T> -struct GetSimpleType<const T *> { - - T *type; - _FORCE_INLINE_ GetSimpleType() { type = NULL; } -}; - -#define SIMPLE_NUMERIC_TYPE(m_type) \ - template <> \ - struct GetSimpleType<m_type> { \ - m_type type; \ - _FORCE_INLINE_ GetSimpleType() { type = (m_type)0; } \ - }; \ - template <> \ - struct GetSimpleType<m_type const> { \ - m_type type; \ - _FORCE_INLINE_ GetSimpleType() { type = (m_type)0; } \ - }; \ - template <> \ - struct GetSimpleType<m_type &> { \ - m_type type; \ - _FORCE_INLINE_ GetSimpleType() { type = (m_type)0; } \ - }; \ - template <> \ - struct GetSimpleType<const m_type &> { \ - m_type type; \ - _FORCE_INLINE_ GetSimpleType() { type = (m_type)0; } \ - }; - -SIMPLE_NUMERIC_TYPE(bool); -SIMPLE_NUMERIC_TYPE(uint8_t); -SIMPLE_NUMERIC_TYPE(int8_t); -SIMPLE_NUMERIC_TYPE(uint16_t); -SIMPLE_NUMERIC_TYPE(int16_t); -SIMPLE_NUMERIC_TYPE(uint32_t); -SIMPLE_NUMERIC_TYPE(int32_t); -SIMPLE_NUMERIC_TYPE(int64_t); -SIMPLE_NUMERIC_TYPE(uint64_t); -SIMPLE_NUMERIC_TYPE(float); -SIMPLE_NUMERIC_TYPE(double); - #endif diff --git a/core/sort.h b/core/sort.h index 06c427f61e..a5e23f53df 100644 --- a/core/sort.h +++ b/core/sort.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/string_db.cpp b/core/string_db.cpp index c61fbba9b5..ef38491a6b 100644 --- a/core/string_db.cpp +++ b/core/string_db.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/string_db.h b/core/string_db.h index 18af9fb3a7..2bef29fab8 100644 --- a/core/string_db.h +++ b/core/string_db.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/translation.cpp b/core/translation.cpp index c38d5d8b4d..f1f9c72b85 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/translation.h b/core/translation.h index 8630b8a478..cf59583ad6 100644 --- a/core/translation.h +++ b/core/translation.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/type_info.h b/core/type_info.h index 10912fd074..da6047450c 100644 --- a/core/type_info.h +++ b/core/type_info.h @@ -1,6 +1,8 @@ #ifndef GET_TYPE_INFO_H #define GET_TYPE_INFO_H +#ifdef DEBUG_METHODS_ENABLED + template <bool C, typename T = void> struct EnableIf { @@ -39,9 +41,9 @@ template <class T, typename = void> struct GetTypeInfo { enum { VARIANT_TYPE = Variant::NIL }; - static inline StringName get_class_name() { - ERR_PRINT("Fallback type info. Bug!"); - return ""; // Not "Nil", this is an error + static inline PropertyInfo get_class_info() { + ERR_PRINT("GetTypeInfo fallback. Bug!"); + return PropertyInfo(); // Not "Nil", this is an error } }; @@ -49,15 +51,15 @@ struct GetTypeInfo { template <> \ struct GetTypeInfo<m_type> { \ enum { VARIANT_TYPE = m_var_type }; \ - static inline StringName get_class_name() { \ - return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \ } \ }; \ template <> \ struct GetTypeInfo<const m_type &> { \ enum { VARIANT_TYPE = m_var_type }; \ - static inline StringName get_class_name() { \ - return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \ } \ }; @@ -70,6 +72,7 @@ MAKE_TYPE_INFO(uint32_t, Variant::INT) MAKE_TYPE_INFO(int32_t, Variant::INT) MAKE_TYPE_INFO(int64_t, Variant::INT) MAKE_TYPE_INFO(uint64_t, Variant::INT) +MAKE_TYPE_INFO(wchar_t, Variant::INT) MAKE_TYPE_INFO(float, Variant::REAL) MAKE_TYPE_INFO(double, Variant::REAL) @@ -102,38 +105,52 @@ MAKE_TYPE_INFO(IP_Address, Variant::STRING) class BSP_Tree; MAKE_TYPE_INFO(BSP_Tree, Variant::DICTIONARY) -#define MAKE_TYPE_INFO_WITH_NAME(m_type, m_var_type, m_class_name) \ - template <> \ - struct GetTypeInfo<m_type> { \ - enum { VARIANT_TYPE = m_var_type }; \ - static inline StringName get_class_name() { \ - return m_class_name; \ - } \ - }; \ - template <> \ - struct GetTypeInfo<const m_type &> { \ - enum { VARIANT_TYPE = m_var_type }; \ - static inline StringName get_class_name() { \ - return m_class_name; \ - } \ - }; +//for RefPtr +template <> +struct GetTypeInfo<RefPtr> { + enum { VARIANT_TYPE = Variant::OBJECT }; + static inline PropertyInfo get_class_info() { + return PropertyInfo(Variant::OBJECT, String(), PROPERTY_HINT_RESOURCE_TYPE, "Reference"); + } +}; +template <> +struct GetTypeInfo<const RefPtr &> { + enum { VARIANT_TYPE = Variant::OBJECT }; + static inline PropertyInfo get_class_info() { + return PropertyInfo(Variant::OBJECT, String(), PROPERTY_HINT_RESOURCE_TYPE, "Reference"); + } +}; -MAKE_TYPE_INFO_WITH_NAME(RefPtr, Variant::OBJECT, "Reference") -MAKE_TYPE_INFO_WITH_NAME(Variant, Variant::NIL, "Variant") +//for variant +template <> +struct GetTypeInfo<Variant> { + enum { VARIANT_TYPE = Variant::NIL }; + static inline PropertyInfo get_class_info() { + return PropertyInfo(Variant::NIL, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT); + } +}; + +template <> +struct GetTypeInfo<const Variant &> { + enum { VARIANT_TYPE = Variant::NIL }; + static inline PropertyInfo get_class_info() { + return PropertyInfo(Variant::NIL, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT); + } +}; #define MAKE_TEMPLATE_TYPE_INFO(m_template, m_type, m_var_type) \ template <> \ struct GetTypeInfo<m_template<m_type> > { \ enum { VARIANT_TYPE = m_var_type }; \ - static inline StringName get_class_name() { \ - return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \ } \ }; \ template <> \ struct GetTypeInfo<const m_template<m_type> &> { \ enum { VARIANT_TYPE = m_var_type }; \ - static inline StringName get_class_name() { \ - return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo((Variant::Type)VARIANT_TYPE, String()); \ } \ }; @@ -152,42 +169,12 @@ MAKE_TEMPLATE_TYPE_INFO(Vector, Plane, Variant::ARRAY) MAKE_TEMPLATE_TYPE_INFO(PoolVector, Plane, Variant::ARRAY) MAKE_TEMPLATE_TYPE_INFO(PoolVector, Face3, Variant::POOL_VECTOR3_ARRAY) -#define MAKE_ENUM_TYPE_INFO(m_enum) \ - template <> \ - struct GetTypeInfo<m_enum> { \ - enum { VARIANT_TYPE = Variant::INT }; \ - static inline StringName get_class_name() { \ - return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \ - } \ - }; \ - template <> \ - struct GetTypeInfo<m_enum const> { \ - enum { VARIANT_TYPE = Variant::INT }; \ - static inline StringName get_class_name() { \ - return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \ - } \ - }; \ - template <> \ - struct GetTypeInfo<m_enum &> { \ - enum { VARIANT_TYPE = Variant::INT }; \ - static inline StringName get_class_name() { \ - return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \ - } \ - }; \ - template <> \ - struct GetTypeInfo<const m_enum &> { \ - enum { VARIANT_TYPE = Variant::INT }; \ - static inline StringName get_class_name() { \ - return Variant::get_type_name((Variant::Type)VARIANT_TYPE); \ - } \ - }; - template <typename T> struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::value>::type> { enum { VARIANT_TYPE = Variant::OBJECT }; - static inline StringName get_class_name() { - return T::get_class_static(); + static inline PropertyInfo get_class_info() { + return PropertyInfo(StringName(T::get_class_static())); } }; @@ -195,9 +182,43 @@ template <typename T> struct GetTypeInfo<const T *, typename EnableIf<TypeInherits<Object, T>::value>::type> { enum { VARIANT_TYPE = Variant::OBJECT }; - static inline StringName get_class_name() { - return T::get_class_static(); + static inline PropertyInfo get_class_info() { + return PropertyInfo(StringName(T::get_class_static())); } }; +#define TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, m_impl) \ + template <> \ + struct GetTypeInfo<m_impl> { \ + enum { VARIANT_TYPE = Variant::INT }; \ + static inline PropertyInfo get_class_info() { \ + return PropertyInfo(Variant::INT, String(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_CLASS_IS_ENUM, String(#m_enum).replace("::", ".")); \ + } \ + }; + +#define MAKE_ENUM_TYPE_INFO(m_enum) \ + TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, m_enum) \ + TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, m_enum const) \ + TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, m_enum &) \ + TEMPL_MAKE_ENUM_TYPE_INFO(m_enum, const m_enum &) + +template <typename T> +inline StringName __constant_get_enum_name(T param, const String &p_constant) { + if (GetTypeInfo<T>::VARIANT_TYPE == Variant::NIL) + ERR_PRINTS("Missing VARIANT_ENUM_CAST for constant's enum: " + p_constant); + return GetTypeInfo<T>::get_class_info().class_name; +} + +#define CLASS_INFO(m_type) \ + (GetTypeInfo<m_type *>::VARIANT_TYPE != Variant::NIL ? \ + GetTypeInfo<m_type *>::get_class_info() : \ + GetTypeInfo<m_type>::get_class_info()) + +#else + +#define MAKE_ENUM_TYPE_INFO(m_enum) +#define CLASS_INFO(m_type) + +#endif // DEBUG_METHODS_ENABLED + #endif // GET_TYPE_INFO_H diff --git a/core/typedefs.h b/core/typedefs.h index 40d9ea37b5..565e28020b 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -162,9 +162,9 @@ inline void __swap_tmpl(T &x, T &y) { #define _add_overflow __builtin_add_overflow #endif -/** Function to find the nearest (bigger) power of 2 to an integer */ +/** Function to find the next power of 2 to an integer */ -static _FORCE_INLINE_ unsigned int nearest_power_of_2(unsigned int x) { +static _FORCE_INLINE_ unsigned int next_power_of_2(unsigned int x) { --x; x |= x >> 1; @@ -176,6 +176,23 @@ static _FORCE_INLINE_ unsigned int nearest_power_of_2(unsigned int x) { return ++x; } +static _FORCE_INLINE_ unsigned int previous_power_of_2(unsigned int x) { + + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + return x - (x >> 1); +} + +static _FORCE_INLINE_ unsigned int closest_power_of_2(unsigned int x) { + + unsigned int nx = next_power_of_2(x); + unsigned int px = previous_power_of_2(x); + return (nx - x) > (x - px) ? px : nx; +} + // We need this definition inside the function below. static inline int get_shift_from_power_of_2(unsigned int p_pixel); diff --git a/core/ucaps.h b/core/ucaps.h index cd4a581a49..f6c42f37d6 100644 --- a/core/ucaps.h +++ b/core/ucaps.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 19b9f161b7..4760047959 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -111,8 +111,8 @@ void UndoRedo::add_do_method(Object *p_object, const String &p_method, VARIANT_A ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; do_op.object = p_object->get_instance_id(); - if (p_object->cast_to<Resource>()) - do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); + if (Object::cast_to<Resource>(p_object)) + do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object)); do_op.type = Operation::TYPE_METHOD; do_op.name = p_method; @@ -135,8 +135,8 @@ void UndoRedo::add_undo_method(Object *p_object, const String &p_method, VARIANT Operation undo_op; undo_op.object = p_object->get_instance_id(); - if (p_object->cast_to<Resource>()) - undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); + if (Object::cast_to<Resource>(p_object)) + undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object)); undo_op.type = Operation::TYPE_METHOD; undo_op.name = p_method; @@ -152,8 +152,8 @@ void UndoRedo::add_do_property(Object *p_object, const String &p_property, const ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; do_op.object = p_object->get_instance_id(); - if (p_object->cast_to<Resource>()) - do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); + if (Object::cast_to<Resource>(p_object)) + do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object)); do_op.type = Operation::TYPE_PROPERTY; do_op.name = p_property; @@ -171,8 +171,8 @@ void UndoRedo::add_undo_property(Object *p_object, const String &p_property, con Operation undo_op; undo_op.object = p_object->get_instance_id(); - if (p_object->cast_to<Resource>()) - undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); + if (Object::cast_to<Resource>(p_object)) + undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object)); undo_op.type = Operation::TYPE_PROPERTY; undo_op.name = p_property; @@ -185,8 +185,8 @@ void UndoRedo::add_do_reference(Object *p_object) { ERR_FAIL_COND((current_action + 1) >= actions.size()); Operation do_op; do_op.object = p_object->get_instance_id(); - if (p_object->cast_to<Resource>()) - do_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); + if (Object::cast_to<Resource>(p_object)) + do_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object)); do_op.type = Operation::TYPE_REFERENCE; actions[current_action + 1].do_ops.push_back(do_op); @@ -202,8 +202,8 @@ void UndoRedo::add_undo_reference(Object *p_object) { Operation undo_op; undo_op.object = p_object->get_instance_id(); - if (p_object->cast_to<Resource>()) - undo_op.resref = Ref<Resource>(p_object->cast_to<Resource>()); + if (Object::cast_to<Resource>(p_object)) + undo_op.resref = Ref<Resource>(Object::cast_to<Resource>(p_object)); undo_op.type = Operation::TYPE_REFERENCE; actions[current_action + 1].undo_ops.push_back(undo_op); @@ -270,7 +270,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) { obj->call(op.name, VARIANT_ARGS_FROM_ARRAY(op.args)); #ifdef TOOLS_ENABLED - Resource *res = obj->cast_to<Resource>(); + Resource *res = Object::cast_to<Resource>(obj); if (res) res->set_edited(true); @@ -284,7 +284,7 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) { obj->set(op.name, op.args[0]); #ifdef TOOLS_ENABLED - Resource *res = obj->cast_to<Resource>(); + Resource *res = Object::cast_to<Resource>(obj); if (res) res->set_edited(true); #endif @@ -504,7 +504,7 @@ void UndoRedo::_bind_methods() { ClassDB::bind_method(D_METHOD("get_current_action_name"), &UndoRedo::get_current_action_name); ClassDB::bind_method(D_METHOD("get_version"), &UndoRedo::get_version); - BIND_CONSTANT(MERGE_DISABLE); - BIND_CONSTANT(MERGE_ENDS); - BIND_CONSTANT(MERGE_ALL); + BIND_ENUM_CONSTANT(MERGE_DISABLE); + BIND_ENUM_CONSTANT(MERGE_ENDS); + BIND_ENUM_CONSTANT(MERGE_ALL); } diff --git a/core/undo_redo.h b/core/undo_redo.h index 5b79f957da..84133c4eea 100644 --- a/core/undo_redo.h +++ b/core/undo_redo.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/ustring.cpp b/core/ustring.cpp index 0521966943..ee07c7b11b 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1252,66 +1252,7 @@ String String::utf8(const char *p_utf8, int p_len) { return ret; }; -#if 0 -_FORCE_INLINE static int parse_utf8_char(const char *p_utf8,unsigned int *p_ucs4,int p_left) { //return len - - - int len=0; - -/* Determine the number of characters in sequence */ - if ((*p_utf8 & 0x80)==0) - len=1; - else if ((*p_utf8 & 0xE0)==0xC0) - len=2; - else if ((*p_utf8 & 0xF0)==0xE0) - len=3; - else if ((*p_utf8 & 0xF8)==0xF0) - len=4; - else if ((*p_utf8 & 0xFC)==0xF8) - len=5; - else if ((*p_utf8 & 0xFE)==0xFC) - len=6; - else - return -1; //invalid UTF8 - - if (len>p_left) - return -1; //not enough space - - if (len==2 && (*p_utf8&0x1E)==0) { - //printf("overlong rejected\n"); - return -1; //reject overlong - } - - /* Convert the first character */ - - unsigned int unichar=0; - - if (len == 1) - unichar=*p_utf8; - else { - - unichar=(0xFF >> (len +1)) & *p_utf8; - for (int i=1;i<len;i++) { - - if ((p_utf8[i] & 0xC0) != 0x80) { - //printf("invalid utf8\n"); - return -1; //invalid utf8 - } - if (unichar==0 && i==2 && ((p_utf8[i] & 0x7F) >> (7 - len)) == 0) { - //printf("no overlong\n"); - return -1; //no overlong - } - unichar = (unichar << 6) | (p_utf8[i] & 0x3F); - } - } - - *p_ucs4=unichar; - - return len; - -} -#endif bool String::parse_utf8(const char *p_utf8, int p_len) { #define _UNICERROR(m_err) print_line("unicode error: " + String(m_err)); @@ -1998,94 +1939,6 @@ double String::to_double(const char *p_str) { #else return built_in_strtod<char>(p_str); #endif -#if 0 -#if 0 - - - return atof(p_str); -#else - if (!p_str[0]) - return 0; -///@todo make more exact so saving and loading does not lose precision - - double integer=0; - double decimal=0; - double decimal_mult=0.1; - double sign=1.0; - double exp=0; - double exp_sign=1.0; - int reading=READING_SIGN; - - const char *str=p_str; - - while(*str && reading!=READING_DONE) { - - CharType c=*(str++); - switch(reading) { - case READING_SIGN: { - if (c>='0' && c<='9') - reading=READING_INT; - // let it fallthrough - else if (c=='-') { - sign=-1.0; - reading=READING_INT; - break; - } else if (c=='.') { - reading=READING_DEC; - break; - } else { - break; - } - } - case READING_INT: { - - if (c>='0' && c<='9') { - - integer*=10; - integer+=c-'0'; - } else if (c=='.') { - reading=READING_DEC; - } else if (c=='e') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_DEC: { - - if (c>='0' && c<='9') { - - decimal+=(c-'0')*decimal_mult; - decimal_mult*=0.1; - } else if (c=='e') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_EXP: { - - if (c>='0' && c<='9') { - - exp*=10.0; - exp+=(c-'0'); - } else if (c=='-' && exp==0) { - exp_sign=-1.0; - } else if (exp_sign>=0 && c=='+') { - //redundant... - exp_sign=1.0; - } else { - reading=READING_DONE; - } - } break; - } - } - - return sign*(integer+decimal)*Math::pow(10,exp_sign*exp); -#endif -#endif } float String::to_float() const { @@ -2096,100 +1949,6 @@ float String::to_float() const { double String::to_double(const CharType *p_str, const CharType **r_end) { return built_in_strtod<CharType>(p_str, (CharType **)r_end); -#if 0 -#if 0 - //ndef NO_USE_STDLIB - return wcstod(p_str,p_len<0?NULL:p_str+p_len); -#else - if (p_len==0 || !p_str[0]) - return 0; -///@todo make more exact so saving and loading does not lose precision - - double integer=0; - double decimal=0; - double decimal_mult=0.1; - double sign=1.0; - double exp=0; - double exp_sign=1.0; - int reading=READING_SIGN; - - const CharType *str=p_str; - const CharType *limit=&p_str[p_len]; - - while(reading!=READING_DONE && str!=limit) { - - CharType c=*(str++); - switch(reading) { - case READING_SIGN: { - if (c>='0' && c<='9') - reading=READING_INT; - // let it fallthrough - else if (c=='-') { - sign=-1.0; - reading=READING_INT; - break; - } else if (c=='.') { - reading=READING_DEC; - break; - } else if (c==0) { - reading=READING_DONE; - break; - } else { - break; - } - } - case READING_INT: { - - if (c>='0' && c<='9') { - - integer*=10; - integer+=c-'0'; - } else if (c=='.') { - reading=READING_DEC; - } else if (c=='e' || c=='E') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_DEC: { - - if (c>='0' && c<='9') { - - decimal+=(c-'0')*decimal_mult; - decimal_mult*=0.1; - } else if (c=='e' || c=='E') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_EXP: { - - if (c>='0' && c<='9') { - - exp*=10.0; - exp+=(c-'0'); - } else if (c=='-' && exp==0) { - exp_sign=-1.0; - } else if (exp_sign>=0 && c=='+') { - //redundant... - exp_sign=1.0; - } else { - reading=READING_DONE; - } - } break; - } - } - - if (r_end) - *r_end=str-1; - - return sign*(integer+decimal)*Math::pow(10,exp_sign*exp); -#endif -#endif } int64_t String::to_int(const CharType *p_str, int p_len) { @@ -2252,98 +2011,6 @@ double String::to_double() const { #else return built_in_strtod<CharType>(c_str()); #endif -#if 0 -#ifndef NO_USE_STDLIB - - return atof(utf8().get_data()); -#else - - double integer=0; - double decimal=0; - double decimal_mult=0.1; - double sign=1.0; - double exp=0; - double exp_sign=1.0; - int reading=READING_SIGN; - - const CharType *str=&operator[](0); - - while(*str && reading!=READING_DONE) { - - CharType c=*(str++); - switch(reading) { - case READING_SIGN: { - if (c>='0' && c<='9') - reading=READING_INT; - // let it fallthrough - else if (c=='-') { - sign=-1.0; - reading=READING_INT; - break; - } else if (c=='.') { - reading=READING_DEC; - break; - } else { - break; - } - } - case READING_INT: { - - if (c>='0' && c<='9') { - - integer*=10; - integer+=c-'0'; - } else if (c=='.') { - reading=READING_DEC; - } else if (c=='e') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_DEC: { - - if (c>='0' && c<='9') { - - decimal+=(c-'0')*decimal_mult; - decimal_mult*=0.1; - } else if (c=='e') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_EXP: { - - if (c>='0' && c<='9') { - - exp*=10.0; - exp+=(c-'0'); - } else if (c=='-' && exp==0) { - exp_sign=-1.0; - } else if (exp_sign>=0 && c=='+') { - //redundant... - exp_sign=1.0; - } else { - reading=READING_DONE; - } - } break; - } - } - - return sign*(integer+decimal)*Math::pow(10,exp_sign*exp); -#endif -#if 0 - - - double ret=sign*(integer+decimal)*Math::pow(10,exp_sign*exp); - - print_line(*this +" == "+rtos(ret)); - return ret; -#endif -#endif } bool operator==(const char *p_chr, const String &p_str) { diff --git a/core/ustring.h b/core/ustring.h index 1c61e12e85..ab4e325f2c 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/variant.cpp b/core/variant.cpp index 51c4b70bdc..74f6b6a711 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1764,14 +1764,14 @@ Variant::operator Object *() const { Variant::operator Node *() const { if (type == OBJECT) - return _get_obj().obj ? _get_obj().obj->cast_to<Node>() : NULL; + return Object::cast_to<Node>(_get_obj().obj); else return NULL; } Variant::operator Control *() const { if (type == OBJECT) - return _get_obj().obj ? _get_obj().obj->cast_to<Control>() : NULL; + return Object::cast_to<Control>(_get_obj().obj); else return NULL; } diff --git a/core/variant.h b/core/variant.h index 40de1a9bce..c44608ebfa 100644 --- a/core/variant.h +++ b/core/variant.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/variant_call.cpp b/core/variant_call.cpp index aabc2546bc..ad15f8f5cb 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -729,9 +729,6 @@ struct _VariantCall { VCALL_PTR1R(Basis, scaled); VCALL_PTR0R(Basis, get_scale); VCALL_PTR0R(Basis, get_euler); - VCALL_PTR1(Basis, set_scale); - VCALL_PTR1(Basis, set_rotation_euler); - VCALL_PTR2(Basis, set_rotation_axis_angle); VCALL_PTR1R(Basis, tdotx); VCALL_PTR1R(Basis, tdoty); VCALL_PTR1R(Basis, tdotz); @@ -747,6 +744,7 @@ struct _VariantCall { VCALL_PTR1R(Transform, translated); VCALL_PTR0R(Transform, orthonormalized); VCALL_PTR2R(Transform, looking_at); + VCALL_PTR2R(Transform, interpolate_with); static void _call_Transform_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) { @@ -1691,7 +1689,7 @@ void register_variant_methods() { ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, xform_inv, NIL, "v", varray()); ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, basis_xform, NIL, "v", varray()); ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, basis_xform_inv, NIL, "v", varray()); - ADDFUNC2(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "m", REAL, "c", varray()); + ADDFUNC2(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", REAL, "weight", varray()); ADDFUNC0(BASIS, BASIS, Basis, inverse, varray()); ADDFUNC0(BASIS, BASIS, Basis, transposed, varray()); @@ -1699,9 +1697,6 @@ void register_variant_methods() { ADDFUNC0(BASIS, REAL, Basis, determinant, varray()); ADDFUNC2(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", REAL, "phi", varray()); ADDFUNC1(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray()); - ADDFUNC1(BASIS, NIL, Basis, set_scale, VECTOR3, "scale", varray()); - ADDFUNC1(BASIS, NIL, Basis, set_rotation_euler, VECTOR3, "euler", varray()); - ADDFUNC2(BASIS, NIL, Basis, set_rotation_axis_angle, VECTOR3, "axis", REAL, "angle", varray()); ADDFUNC0(BASIS, VECTOR3, Basis, get_scale, varray()); ADDFUNC0(BASIS, VECTOR3, Basis, get_euler, varray()); ADDFUNC1(BASIS, REAL, Basis, tdotx, VECTOR3, "with", varray()); @@ -1718,6 +1713,7 @@ void register_variant_methods() { ADDFUNC1(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray()); ADDFUNC1(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "ofs", varray()); ADDFUNC2(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray()); + ADDFUNC2(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", REAL, "weight", varray()); ADDFUNC1(TRANSFORM, NIL, Transform, xform, NIL, "v", varray()); ADDFUNC1(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray()); diff --git a/core/variant_construct_string.cpp b/core/variant_construct_string.cpp index fa8a393d08..ccbb70d689 100644 --- a/core/variant_construct_string.cpp +++ b/core/variant_construct_string.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 5fda6b1473..b6e114b853 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 398f20caf3..65c7b7cfec 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -326,6 +326,7 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri is_float = true; } else if (c == 'e') { reading = READING_EXP; + is_float = true; } else { reading = READING_DONE; } @@ -337,7 +338,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri } else if (c == 'e') { reading = READING_EXP; - } else { reading = READING_DONE; } @@ -349,8 +349,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri exp_beg = true; } else if ((c == '-' || c == '+') && !exp_sign && !exp_beg) { - if (c == '-') - is_float = true; exp_sign = true; } else { @@ -744,7 +742,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, return err; if (token.type == TK_PARENTHESIS_CLOSE) { - Reference *reference = obj->cast_to<Reference>(); + Reference *reference = Object::cast_to<Reference>(obj); if (reference) { value = REF(reference); } else { diff --git a/core/variant_parser.h b/core/variant_parser.h index acbe0e967f..524891cdfd 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/vector.h b/core/vector.h index 9f523c567c..03eaf65099 100644 --- a/core/vector.h +++ b/core/vector.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -71,7 +71,7 @@ class Vector { _FORCE_INLINE_ size_t _get_alloc_size(size_t p_elements) const { //return nearest_power_of_2_templated(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int)); - return nearest_power_of_2(p_elements * sizeof(T)); + return next_power_of_2(p_elements * sizeof(T)); } _FORCE_INLINE_ bool _get_alloc_size_checked(size_t p_elements, size_t *out) const { @@ -79,7 +79,7 @@ class Vector { size_t o; size_t p; if (_mul_overflow(p_elements, sizeof(T), &o)) return false; - *out = nearest_power_of_2(o); + *out = next_power_of_2(o); if (_add_overflow(o, static_cast<size_t>(32), &p)) return false; //no longer allocated here return true; #else diff --git a/core/version.h b/core/version.h index 43f6f1bbf9..436f30ef01 100644 --- a/core/version.h +++ b/core/version.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/vmap.h b/core/vmap.h index 66f935f58d..f0977341ec 100644 --- a/core/vmap.h +++ b/core/vmap.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/vset.h b/core/vset.h index 73062e064c..7b12ae0b25 100644 --- a/core/vset.h +++ b/core/vset.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ |