diff options
Diffstat (limited to 'core')
231 files changed, 1450 insertions, 1125 deletions
diff --git a/core/allocators.h b/core/allocators.h index 16e516e87b..4a5fd7a119 100644 --- a/core/allocators.h +++ b/core/allocators.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/array.cpp b/core/array.cpp index 41af460d83..fef0fcbb40 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/array.h b/core/array.h index c29b4355ca..ecb91b69dc 100644 --- a/core/array.h +++ b/core/array.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/balloon_allocator.h b/core/balloon_allocator.h index 177c744669..eb6632bb37 100644 --- a/core/balloon_allocator.h +++ b/core/balloon_allocator.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 438db5d518..f951237971 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -62,8 +62,8 @@ void _ResourceLoader::_bind_methods() { ObjectTypeDB::bind_method(_MD("load:Resource","path","type_hint", "p_no_cache"),&_ResourceLoader::load,DEFVAL(""), DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_recognized_extensions_for_type","type"),&_ResourceLoader::get_recognized_extensions_for_type); ObjectTypeDB::bind_method(_MD("set_abort_on_missing_resources","abort"),&_ResourceLoader::set_abort_on_missing_resources); - ObjectTypeDB::bind_method(_MD("get_dependencies"),&_ResourceLoader::get_dependencies); - ObjectTypeDB::bind_method(_MD("has"),&_ResourceLoader::has); + ObjectTypeDB::bind_method(_MD("get_dependencies","path"),&_ResourceLoader::get_dependencies); + ObjectTypeDB::bind_method(_MD("has","path"),&_ResourceLoader::has); } _ResourceLoader::_ResourceLoader() { @@ -96,7 +96,7 @@ _ResourceSaver *_ResourceSaver::singleton=NULL; void _ResourceSaver::_bind_methods() { - ObjectTypeDB::bind_method(_MD("save","path","resource:Resource"),&_ResourceSaver::save, DEFVAL(0)); + ObjectTypeDB::bind_method(_MD("save","path","resource:Resource","flags"),&_ResourceSaver::save,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_recognized_extensions","type"),&_ResourceSaver::get_recognized_extensions); BIND_CONSTANT(FLAG_RELATIVE_PATHS); @@ -494,8 +494,8 @@ uint64_t _OS::get_unix_time() const { return OS::get_singleton()->get_unix_time(); }; -uint64_t _OS::get_system_time_msec() const { - return OS::get_singleton()->get_system_time_msec(); +uint64_t _OS::get_system_time_secs() const { + return OS::get_singleton()->get_system_time_secs(); } void _OS::delay_usec(uint32_t p_usec) const { @@ -810,9 +810,9 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_time","utc"),&_OS::get_time,DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_time_zone_info"),&_OS::get_time_zone_info); ObjectTypeDB::bind_method(_MD("get_unix_time"),&_OS::get_unix_time); - ObjectTypeDB::bind_method(_MD("get_system_time_msec"), &_OS::get_system_time_msec); + ObjectTypeDB::bind_method(_MD("get_system_time_secs"), &_OS::get_system_time_secs); - ObjectTypeDB::bind_method(_MD("set_icon"),&_OS::set_icon); + ObjectTypeDB::bind_method(_MD("set_icon","icon"),&_OS::set_icon); ObjectTypeDB::bind_method(_MD("delay_usec","usec"),&_OS::delay_usec); ObjectTypeDB::bind_method(_MD("delay_msec","msec"),&_OS::delay_msec); @@ -851,9 +851,9 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_frames_per_second"),&_OS::get_frames_per_second); ObjectTypeDB::bind_method(_MD("print_all_textures_by_size"),&_OS::print_all_textures_by_size); - ObjectTypeDB::bind_method(_MD("print_resources_by_type"),&_OS::print_resources_by_type); + ObjectTypeDB::bind_method(_MD("print_resources_by_type","types"),&_OS::print_resources_by_type); - ObjectTypeDB::bind_method(_MD("native_video_play"),&_OS::native_video_play); + ObjectTypeDB::bind_method(_MD("native_video_play","path","volume","audio_track","subtitle_track"),&_OS::native_video_play); ObjectTypeDB::bind_method(_MD("native_video_is_playing"),&_OS::native_video_is_playing); ObjectTypeDB::bind_method(_MD("native_video_stop"),&_OS::native_video_stop); ObjectTypeDB::bind_method(_MD("native_video_pause"),&_OS::native_video_pause); @@ -1509,6 +1509,7 @@ void _File::_bind_methods() { BIND_CONSTANT( READ ); BIND_CONSTANT( WRITE ); BIND_CONSTANT( READ_WRITE ); + BIND_CONSTANT( WRITE_READ ); } _File::_File(){ diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 172f33dac5..62572d7761 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -208,7 +208,7 @@ public: Dictionary get_time(bool utc) const; Dictionary get_time_zone_info() const; uint64_t get_unix_time() const; - uint64_t get_system_time_msec() const; + uint64_t get_system_time_secs() const; int get_static_memory_usage() const; int get_static_memory_peak_usage() const; @@ -329,6 +329,7 @@ public: READ=1, WRITE=2, READ_WRITE=3, + WRITE_READ=7, }; Error open_encrypted(const String& p_path, int p_mode_flags,const Vector<uint8_t>& p_key); diff --git a/core/color.cpp b/core/color.cpp index 32f3df6d4b..c53de360bc 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/color.h b/core/color.h index d5d5a4ea09..d0a1e8835c 100644 --- a/core/color.h +++ b/core/color.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp index f28617b33c..a2507b1378 100644 --- a/core/command_queue_mt.cpp +++ b/core/command_queue_mt.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index 113199869b..4fd33e3a55 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -983,7 +983,7 @@ public: void flush_all() { - ERR_FAIL_COND(sync); + //ERR_FAIL_COND(sync); lock(); while (true) { bool exit = !flush_one(); diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index 45fd4b5080..b104b8062a 100644 --- a/core/compressed_translation.cpp +++ b/core/compressed_translation.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -410,15 +410,15 @@ bool PHashTranslation::_set(const StringName& p_name, const Variant& p_value) { String name = p_name.operator String(); if (name=="hash_table") { hash_table=p_value; - print_line("translation: loaded hash table of size: "+itos(hash_table.size())); + //print_line("translation: loaded hash table of size: "+itos(hash_table.size())); } else if (name=="bucket_table") { bucket_table=p_value; - print_line("translation: loaded bucket table of size: "+itos(bucket_table.size())); + //print_line("translation: loaded bucket table of size: "+itos(bucket_table.size())); } else if (name=="strings") { strings=p_value; - print_line("translation: loaded string table of size: "+itos(strings.size())); + //print_line("translation: loaded string table of size: "+itos(strings.size())); } else if (name=="load_from") { - print_line("generating"); + //print_line("generating"); generate(p_value); } else return false; diff --git a/core/compressed_translation.h b/core/compressed_translation.h index c41e2afb53..a1406ce1b2 100644 --- a/core/compressed_translation.h +++ b/core/compressed_translation.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp index d0cd19768f..8605b9131b 100644 --- a/core/core_string_names.cpp +++ b/core/core_string_names.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/core_string_names.h b/core/core_string_names.h index 8bda1f3f79..ef9e846c47 100644 --- a/core/core_string_names.h +++ b/core/core_string_names.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/dictionary.cpp b/core/dictionary.cpp index c544573629..a013c21b29 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/dictionary.h b/core/dictionary.h index 8cbabfc65d..145e7e5c84 100644 --- a/core/dictionary.h +++ b/core/dictionary.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/dvector.cpp b/core/dvector.cpp index 60aa2e079f..fa06399139 100644 --- a/core/dvector.cpp +++ b/core/dvector.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/dvector.h b/core/dvector.h index 2c75bbf9eb..17431b33a6 100644 --- a/core/dvector.h +++ b/core/dvector.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/error_list.h b/core/error_list.h index 92c417154c..cb531f527f 100644 --- a/core/error_list.h +++ b/core/error_list.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/error_macros.cpp b/core/error_macros.cpp index 53bce56626..03e5ba37da 100644 --- a/core/error_macros.cpp +++ b/core/error_macros.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/error_macros.h b/core/error_macros.h index cc88686301..cafbf0c16e 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/event_queue.cpp b/core/event_queue.cpp index 1afd686f86..088e80b266 100644 --- a/core/event_queue.cpp +++ b/core/event_queue.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/event_queue.h b/core/event_queue.h index 51ed7373eb..af0a4df2b8 100644 --- a/core/event_queue.h +++ b/core/event_queue.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/fpstr.cpp b/core/fpstr.cpp index 20b527d88b..76046d0b99 100644 --- a/core/fpstr.cpp +++ b/core/fpstr.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/fpstr.h b/core/fpstr.h index c8ff80806e..d3d02733b3 100644 --- a/core/fpstr.h +++ b/core/fpstr.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 9fb45c672a..92e50a8b96 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -402,6 +402,9 @@ static _GlobalConstant _global_constants[]={ BIND_GLOBAL_CONSTANT( JOY_ANALOG_2_X ), BIND_GLOBAL_CONSTANT( JOY_ANALOG_2_Y ), + BIND_GLOBAL_CONSTANT( JOY_ANALOG_L2 ), + BIND_GLOBAL_CONSTANT( JOY_ANALOG_R2 ), + // error list diff --git a/core/global_constants.h b/core/global_constants.h index 77cd3724c6..f7f6677482 100644 --- a/core/global_constants.h +++ b/core/global_constants.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/globals.cpp b/core/globals.cpp index eed37c2308..1e60854f28 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -137,7 +137,7 @@ bool Globals::_set(const StringName& p_name, const Variant& p_value) { props[p_name].order=last_order++; } } else { - props[p_name]=VariantContainer(p_value,last_order++ + registering_order?0:NO_ORDER_BASE); + props[p_name]=VariantContainer(p_value,last_order++ + (registering_order?0:NO_ORDER_BASE)); } } @@ -304,6 +304,7 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) { return OK; } + if (OS::get_singleton()->get_resource_dir()!="") { //OS will call Globals->get_resource_path which will be empty if not overriden! //if the OS would rather use somewhere else, then it will not be empty. @@ -637,7 +638,9 @@ static Variant _decode_variant(const String& p_string) { InputEvent ie; ie.type=InputEvent::JOYSTICK_MOTION; ie.device=params[0].to_int(); - ie.joy_motion.axis=params[1].to_int(); + int axis = params[1].to_int();; + ie.joy_motion.axis=axis>>1; + ie.joy_motion.axis_value=axis&1?1:-1; return ie; } @@ -1028,7 +1031,7 @@ static String _encode_variant(const Variant& p_variant) { } break; case InputEvent::JOYSTICK_MOTION: { - return "jaxis("+itos(ev.device)+", "+itos(ev.joy_motion.axis)+")"; + return "jaxis("+itos(ev.device)+", "+itos(ev.joy_motion.axis * 2 + (ev.joy_motion.axis_value<0?0:1))+")"; } break; default: { @@ -1390,11 +1393,11 @@ void Globals::_bind_methods() { ObjectTypeDB::bind_method(_MD("localize_path","path"),&Globals::localize_path); ObjectTypeDB::bind_method(_MD("globalize_path","path"),&Globals::globalize_path); ObjectTypeDB::bind_method(_MD("save"),&Globals::save); - ObjectTypeDB::bind_method(_MD("has_singleton"),&Globals::has_singleton); - ObjectTypeDB::bind_method(_MD("get_singleton"),&Globals::get_singleton_object); - ObjectTypeDB::bind_method(_MD("load_resource_pack"),&Globals::_load_resource_pack); + ObjectTypeDB::bind_method(_MD("has_singleton","name"),&Globals::has_singleton); + ObjectTypeDB::bind_method(_MD("get_singleton","name"),&Globals::get_singleton_object); + ObjectTypeDB::bind_method(_MD("load_resource_pack","pack"),&Globals::_load_resource_pack); - ObjectTypeDB::bind_method(_MD("save_custom"),&Globals::_save_custom_bnd); + ObjectTypeDB::bind_method(_MD("save_custom","file"),&Globals::_save_custom_bnd); } diff --git a/core/globals.h b/core/globals.h index bfa400988f..8951f5fbd2 100644 --- a/core/globals.h +++ b/core/globals.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/hash_map.h b/core/hash_map.h index eea6d1a153..33eb25652c 100644 --- a/core/hash_map.h +++ b/core/hash_map.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/hashfuncs.h b/core/hashfuncs.h index b12950f160..c2ed5bd679 100644 --- a/core/hashfuncs.h +++ b/core/hashfuncs.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/image.cpp b/core/image.cpp index eadb7ecc8b..798fc41f40 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/image.h b/core/image.h index a155823af7..aea5dc6438 100644 --- a/core/image.h +++ b/core/image.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/image_quantize.cpp b/core/image_quantize.cpp index a14e0ab72e..b8d4658fda 100644 --- a/core/image_quantize.cpp +++ b/core/image_quantize.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/input_map.cpp b/core/input_map.cpp index 24151c59c9..d4560a1e1b 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -204,6 +204,64 @@ bool InputMap::event_is_action(const InputEvent& p_event, const StringName& p_ac return _find_event(E->get().inputs,p_event)!=NULL; } +bool InputMap::event_is_joy_motion_action_pressed(const InputEvent& p_event) const { + + ERR_FAIL_COND_V(p_event.type!=InputEvent::JOYSTICK_MOTION,false); + bool pressed=false; + + //this could be optimized by having a separate list of joymotions? + + for (Map<StringName, Action>::Element *A=input_map.front();A;A=A->next()) { + + for (List<InputEvent>::Element *E=A->get().inputs.front();E;E=E->next()) { + + const InputEvent& e=E->get(); + if(e.type!=p_event.type) + continue; + if (e.type!=InputEvent::KEY && e.device!=p_event.device) + continue; + + switch(p_event.type) { + + case InputEvent::KEY: { + + if (e.key.scancode==p_event.key.scancode && e.key.mod == p_event.key.mod) + return e.key.pressed; + + } break; + case InputEvent::JOYSTICK_BUTTON: { + + if (e.joy_button.button_index==p_event.joy_button.button_index) { + return e.joy_button.pressed; + } + + } break; + case InputEvent::MOUSE_BUTTON: { + + if (e.mouse_button.button_index==p_event.mouse_button.button_index) { + return e.mouse_button.pressed; + } + + } break; + case InputEvent::JOYSTICK_MOTION: { + + if (e.joy_motion.axis==p_event.joy_motion.axis) { + if ( + (e.joy_motion.axis_value * p_event.joy_motion.axis_value >0) && //same axis + ABS(e.joy_motion.axis_value)>0.5 && ABS(p_event.joy_motion.axis_value)>0.5 ) + pressed=true; + } + + } break; + } + + } + } + + return pressed; + +} + void InputMap::load_from_globals() { input_map.clear();; diff --git a/core/input_map.h b/core/input_map.h index c5b21b1457..5cd1e41922 100644 --- a/core/input_map.h +++ b/core/input_map.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -68,6 +68,7 @@ public: const List<InputEvent> *get_action_list(const StringName& p_action); bool event_is_action(const InputEvent& p_event, const StringName& p_action) const; + bool event_is_joy_motion_action_pressed(const InputEvent& p_event) const; void load_from_globals(); diff --git a/core/int_types.h b/core/int_types.h index 231196b808..7d7c4b16b0 100644 --- a/core/int_types.h +++ b/core/int_types.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/compression.cpp b/core/io/compression.cpp index 729b7bec52..a17e358cbb 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/compression.h b/core/io/compression.h index 106a3f0201..07a293c940 100644 --- a/core/io/compression.h +++ b/core/io/compression.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index 75388f514a..fd20ec9404 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -29,6 +29,7 @@ #include "config_file.h" #include "os/keyboard.h" #include "os/file_access.h" +#include "variant_parser.h" StringArray ConfigFile::_get_sections() const { @@ -83,10 +84,10 @@ void ConfigFile::set_value(const String& p_section, const String& p_key, const V } } -Variant ConfigFile::get_value(const String& p_section, const String& p_key) const{ +Variant ConfigFile::get_value(const String& p_section, const String& p_key, Variant p_default) const { - ERR_FAIL_COND_V(!values.has(p_section),Variant()); - ERR_FAIL_COND_V(!values[p_section].has(p_key),Variant()); + ERR_FAIL_COND_V(!values.has(p_section),p_default); + ERR_FAIL_COND_V(!values[p_section].has(p_key),p_default); return values[p_section][p_key]; } @@ -118,151 +119,6 @@ void ConfigFile::get_section_keys(const String& p_section,List<String> *r_keys) } -static String _encode_variant(const Variant& p_variant) { - - switch(p_variant.get_type()) { - - case Variant::BOOL: { - bool val = p_variant; - return (val?"true":"false"); - } break; - case Variant::INT: { - int val = p_variant; - return itos(val); - } break; - case Variant::REAL: { - float val = p_variant; - return rtos(val)+(val==int(val)?".0":""); - } break; - case Variant::STRING: { - String val = p_variant; - return "\""+val.xml_escape()+"\""; - } break; - case Variant::COLOR: { - - Color val = p_variant; - return "#"+val.to_html(); - } break; - case Variant::STRING_ARRAY: - case Variant::INT_ARRAY: - case Variant::REAL_ARRAY: - case Variant::ARRAY: { - Array arr = p_variant; - String str="["; - for(int i=0;i<arr.size();i++) { - - if (i>0) - str+=", "; - str+=_encode_variant(arr[i]); - } - str+="]"; - return str; - } break; - case Variant::DICTIONARY: { - Dictionary d = p_variant; - String str="{"; - List<Variant> keys; - d.get_key_list(&keys); - for(List<Variant>::Element *E=keys.front();E;E=E->next()) { - - if (E!=keys.front()) - str+=", "; - str+=_encode_variant(E->get()); - str+=":"; - str+=_encode_variant(d[E->get()]); - - } - str+="}"; - return str; - } break; - case Variant::IMAGE: { - String str="img("; - - Image img=p_variant; - if (!img.empty()) { - - String format; - switch(img.get_format()) { - - case Image::FORMAT_GRAYSCALE: format="grayscale"; break; - case Image::FORMAT_INTENSITY: format="intensity"; break; - case Image::FORMAT_GRAYSCALE_ALPHA: format="grayscale_alpha"; break; - case Image::FORMAT_RGB: format="rgb"; break; - case Image::FORMAT_RGBA: format="rgba"; break; - case Image::FORMAT_INDEXED : format="indexed"; break; - case Image::FORMAT_INDEXED_ALPHA: format="indexed_alpha"; break; - case Image::FORMAT_BC1: format="bc1"; break; - case Image::FORMAT_BC2: format="bc2"; break; - case Image::FORMAT_BC3: format="bc3"; break; - case Image::FORMAT_BC4: format="bc4"; break; - case Image::FORMAT_BC5: format="bc5"; break; - case Image::FORMAT_CUSTOM: format="custom custom_size="+itos(img.get_data().size())+""; break; - default: {} - } - - str+=format+", "; - str+=itos(img.get_mipmaps())+", "; - str+=itos(img.get_width())+", "; - str+=itos(img.get_height())+", "; - DVector<uint8_t> data = img.get_data(); - int ds=data.size(); - DVector<uint8_t>::Read r = data.read(); - for(int i=0;i<ds;i++) { - uint8_t byte = r[i]; - const char hex[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; - char bstr[3]={ hex[byte>>4], hex[byte&0xF], 0}; - str+=bstr; - } - } - str+=")"; - return str; - } break; - case Variant::INPUT_EVENT: { - - InputEvent ev = p_variant; - - switch(ev.type) { - - case InputEvent::KEY: { - - String mods; - if (ev.key.mod.control) - mods+="C"; - if (ev.key.mod.shift) - mods+="S"; - if (ev.key.mod.alt) - mods+="A"; - if (ev.key.mod.meta) - mods+="M"; - if (mods!="") - mods=", "+mods; - - return "key("+keycode_get_string(ev.key.scancode)+mods+")"; - } break; - case InputEvent::MOUSE_BUTTON: { - - return "mbutton("+itos(ev.device)+", "+itos(ev.mouse_button.button_index)+")"; - } break; - case InputEvent::JOYSTICK_BUTTON: { - - return "jbutton("+itos(ev.device)+", "+itos(ev.joy_button.button_index)+")"; - } break; - case InputEvent::JOYSTICK_MOTION: { - - return "jaxis("+itos(ev.device)+", "+itos(ev.joy_motion.axis)+")"; - } break; - default: { - - return "nil"; - } break; - - } - } break; - default: {} - } - - return "nil"; //don't know wha to do with this -} Error ConfigFile::save(const String& p_path){ @@ -271,6 +127,8 @@ Error ConfigFile::save(const String& p_path){ FileAccess *file = FileAccess::open(p_path,FileAccess::WRITE,&err); if (err) { + if (file) + memdelete(file); return err; } @@ -283,7 +141,9 @@ Error ConfigFile::save(const String& p_path){ for(Map<String, Variant>::Element *F=E->get().front();F;F=F->next()) { - file->store_string(F->key()+"="+_encode_variant(F->get())+"\n"); + String vstr; + VariantWriter::write_to_string(F->get(),vstr); + file->store_string(F->key()+"="+vstr+"\n"); } } @@ -292,432 +152,49 @@ Error ConfigFile::save(const String& p_path){ return OK; } -static Vector<String> _decode_params(const String& p_string) { - - int begin=p_string.find("("); - ERR_FAIL_COND_V(begin==-1,Vector<String>()); - begin++; - int end=p_string.find(")"); - ERR_FAIL_COND_V(end<begin,Vector<String>()); - return p_string.substr(begin,end-begin).split(","); -} - -static String _get_chunk(const String& str,int &pos, int close_pos) { - - - enum { - MIN_COMMA, - MIN_COLON, - MIN_CLOSE, - MIN_QUOTE, - MIN_PARENTHESIS, - MIN_CURLY_OPEN, - MIN_OPEN - }; - - int min_pos=close_pos; - int min_what=MIN_CLOSE; - -#define TEST_MIN(m_how,m_what) \ -{\ -int res = str.find(m_how,pos);\ -if (res!=-1 && res < min_pos) {\ - min_pos=res;\ - min_what=m_what;\ -}\ -}\ - - - TEST_MIN(",",MIN_COMMA); - TEST_MIN("[",MIN_OPEN); - TEST_MIN("{",MIN_CURLY_OPEN); - TEST_MIN("(",MIN_PARENTHESIS); - TEST_MIN("\"",MIN_QUOTE); - - int end=min_pos; - - - switch(min_what) { - - case MIN_COMMA: { - } break; - case MIN_CLOSE: { - //end because it's done - } break; - case MIN_QUOTE: { - end=str.find("\"",min_pos+1)+1; - ERR_FAIL_COND_V(end==-1,Variant()); - - } break; - case MIN_PARENTHESIS: { - - end=str.find(")",min_pos+1)+1; - ERR_FAIL_COND_V(end==-1,Variant()); - - } break; - case MIN_OPEN: { - int level=1; - end++; - while(end<close_pos) { - - if (str[end]=='[') - level++; - if (str[end]==']') { - level--; - if (level==0) - break; - } - end++; - } - ERR_FAIL_COND_V(level!=0,Variant()); - end++; - } break; - case MIN_CURLY_OPEN: { - int level=1; - end++; - while(end<close_pos) { - - if (str[end]=='{') - level++; - if (str[end]=='}') { - level--; - if (level==0) - break; - } - end++; - } - ERR_FAIL_COND_V(level!=0,Variant()); - end++; - } break; - - } - - String ret = str.substr(pos,end-pos); - - pos=end; - while(pos<close_pos) { - if (str[pos]!=',' && str[pos]!=' ' && str[pos]!=':') - break; - pos++; - } - - return ret; - -} - - -static Variant _decode_variant(const String& p_string) { - - - String str = p_string.strip_edges(); - - if (str.nocasecmp_to("true")==0) - return Variant(true); - if (str.nocasecmp_to("false")==0) - return Variant(false); - if (str.nocasecmp_to("nil")==0) - return Variant(); - if (str.is_valid_float()) { - if (str.find(".")==-1) - return str.to_int(); - else - return str.to_double(); - - } - if (str.begins_with("#")) { //string - return Color::html(str); - } - if (str.begins_with("\"")) { //string - int end = str.find_last("\""); - ERR_FAIL_COND_V(end==0,Variant()); - return str.substr(1,end-1).xml_unescape(); - - } - - if (str.begins_with("[")) { //array - - int close_pos = str.find_last("]"); - ERR_FAIL_COND_V(close_pos==-1,Variant()); - Array array; - - int pos=1; - - while(pos<close_pos) { - - String s = _get_chunk(str,pos,close_pos); - array.push_back(_decode_variant(s)); - } - return array; - - } - - if (str.begins_with("{")) { //array - - int close_pos = str.find_last("}"); - ERR_FAIL_COND_V(close_pos==-1,Variant()); - Dictionary d; - - int pos=1; - - while(pos<close_pos) { - - String key = _get_chunk(str,pos,close_pos); - String data = _get_chunk(str,pos,close_pos); - d[_decode_variant(key)]=_decode_variant(data); - } - return d; - - } - if (str.begins_with("key")) { - Vector<String> params = _decode_params(p_string); - ERR_FAIL_COND_V(params.size()!=1 && params.size()!=2,Variant()); - int scode=0; - - if (params[0].is_numeric()) { - scode=params[0].to_int(); - if (scode < 10) { - scode=KEY_0+scode; - } - } else - scode=find_keycode(params[0]); - - InputEvent ie; - ie.type=InputEvent::KEY; - ie.key.scancode=scode; - - if (params.size()==2) { - String mods=params[1]; - if (mods.findn("C")!=-1) - ie.key.mod.control=true; - if (mods.findn("A")!=-1) - ie.key.mod.alt=true; - if (mods.findn("S")!=-1) - ie.key.mod.shift=true; - if (mods.findn("M")!=-1) - ie.key.mod.meta=true; - } - return ie; - - } - - if (str.begins_with("mbutton")) { - Vector<String> params = _decode_params(p_string); - ERR_FAIL_COND_V(params.size()!=2,Variant()); - - InputEvent ie; - ie.type=InputEvent::MOUSE_BUTTON; - ie.device=params[0].to_int(); - ie.mouse_button.button_index=params[1].to_int(); - - return ie; - } - - if (str.begins_with("jbutton")) { - Vector<String> params = _decode_params(p_string); - ERR_FAIL_COND_V(params.size()!=2,Variant()); - - InputEvent ie; - ie.type=InputEvent::JOYSTICK_BUTTON; - ie.device=params[0].to_int(); - ie.joy_button.button_index=params[1].to_int(); - - return ie; - } - - if (str.begins_with("jaxis")) { - Vector<String> params = _decode_params(p_string); - ERR_FAIL_COND_V(params.size()!=2,Variant()); - - InputEvent ie; - ie.type=InputEvent::JOYSTICK_MOTION; - ie.device=params[0].to_int(); - ie.joy_motion.axis=params[1].to_int(); - - return ie; - } - if (str.begins_with("img")) { - Vector<String> params = _decode_params(p_string); - if (params.size()==0) { - return Image(); - } - - ERR_FAIL_COND_V(params.size()!=5,Image()); - - String format=params[0].strip_edges(); - - Image::Format imgformat; - - if (format=="grayscale") { - imgformat=Image::FORMAT_GRAYSCALE; - } else if (format=="intensity") { - imgformat=Image::FORMAT_INTENSITY; - } else if (format=="grayscale_alpha") { - imgformat=Image::FORMAT_GRAYSCALE_ALPHA; - } else if (format=="rgb") { - imgformat=Image::FORMAT_RGB; - } else if (format=="rgba") { - imgformat=Image::FORMAT_RGBA; - } else if (format=="indexed") { - imgformat=Image::FORMAT_INDEXED; - } else if (format=="indexed_alpha") { - imgformat=Image::FORMAT_INDEXED_ALPHA; - } else if (format=="bc1") { - imgformat=Image::FORMAT_BC1; - } else if (format=="bc2") { - imgformat=Image::FORMAT_BC2; - } else if (format=="bc3") { - imgformat=Image::FORMAT_BC3; - } else if (format=="bc4") { - imgformat=Image::FORMAT_BC4; - } else if (format=="bc5") { - imgformat=Image::FORMAT_BC5; - } else if (format=="custom") { - imgformat=Image::FORMAT_CUSTOM; - } else { - - ERR_FAIL_V( Image() ); - } - - int mipmaps=params[1].to_int(); - int w=params[2].to_int(); - int h=params[3].to_int(); - - if (w == 0 && h == 0) { - //r_v = Image(w, h, imgformat); - return Image(); - }; - - - String data=params[4]; - int datasize=data.length()/2; - DVector<uint8_t> pixels; - pixels.resize(datasize); - DVector<uint8_t>::Write wb = pixels.write(); - const CharType *cptr=data.c_str(); - - int idx=0; - uint8_t byte; - while( idx<datasize*2) { - - CharType c=*(cptr++); - - ERR_FAIL_COND_V(c=='<',ERR_FILE_CORRUPT); - - if ( (c>='0' && c<='9') || (c>='A' && c<='F') || (c>='a' && c<='f') ) { - - if (idx&1) { - - byte|=HEX2CHR(c); - wb[idx>>1]=byte; - } else { - - byte=HEX2CHR(c)<<4; - } - - idx++; - } - - } - - wb = DVector<uint8_t>::Write(); - - return Image(w,h,mipmaps,imgformat,pixels); - } - - if (str.find(",")!=-1) { //vector2 or vector3 - Vector<float> farr = str.split_floats(",",true); - if (farr.size()==2) { - return Point2(farr[0],farr[1]); - } - if (farr.size()==3) { - return Vector3(farr[0],farr[1],farr[2]); - } - ERR_FAIL_V(Variant()); - } - - - return Variant(); -} Error ConfigFile::load(const String& p_path) { Error err; FileAccess *f= FileAccess::open(p_path,FileAccess::READ,&err); - if (err!=OK) { - - return err; - } - - - String line; - String section; - String subpath; - - int line_count = 0; - - while(!f->eof_reached()) { - - String line = f->get_line().strip_edges(); - line_count++; - - if (line=="") - continue; - - // find comments - - { + if (!f) + return ERR_CANT_OPEN; - int pos=0; - while (true) { - int ret = line.find(";",pos); - if (ret==-1) - break; + VariantParser::StreamFile stream; + stream.f=f; - int qc=0; - for(int i=0;i<ret;i++) { + String assign; + Variant value; + VariantParser::Tag next_tag; - if (line[i]=='"') - qc++; - } + int lines=0; + String error_text; - if ( !(qc&1) ) { - //not inside string, real comment - line=line.substr(0,ret); - break; - - } + String section; - pos=ret+1; + while(true) { + assign=Variant(); + next_tag.fields.clear(); + next_tag.name=String(); - } + err = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,NULL,true); + if (err==ERR_FILE_EOF) { + memdelete(f); + return OK; + } + else if (err!=OK) { + ERR_PRINTS("ConfgFile::load - "+p_path+":"+itos(lines)+" error: "+error_text); + memdelete(f); + return err; } - if (line.begins_with("[")) { - - int end = line.find_last("]"); - ERR_CONTINUE(end!=line.length()-1); - - section=line.substr(1,line.length()-2); - - } else if (line.find("=")!=-1) { - - - int eqpos = line.find("="); - String var=line.substr(0,eqpos).strip_edges(); - String value=line.substr(eqpos+1,line.length()).strip_edges(); - - Variant val = _decode_variant(value); - - set_value(section,var,val); - - } else { - - if (line.length() > 0) { - ERR_PRINT(String("Syntax error on line "+itos(line_count)+" of file "+p_path).ascii().get_data()); - }; - }; + if (assign!=String()) { + set_value(section,assign,value); + } else if (next_tag.name!=String()) { + section=next_tag.name; + } } memdelete(f); @@ -730,13 +207,13 @@ Error ConfigFile::load(const String& p_path) { void ConfigFile::_bind_methods(){ ObjectTypeDB::bind_method(_MD("set_value","section","key","value"),&ConfigFile::set_value); - ObjectTypeDB::bind_method(_MD("get_value","section","key"),&ConfigFile::get_value); + ObjectTypeDB::bind_method(_MD("get_value","section","key","default"),&ConfigFile::get_value,DEFVAL(Variant())); ObjectTypeDB::bind_method(_MD("has_section","section"),&ConfigFile::has_section); ObjectTypeDB::bind_method(_MD("has_section_key","section","key"),&ConfigFile::has_section_key); ObjectTypeDB::bind_method(_MD("get_sections"),&ConfigFile::_get_sections); - ObjectTypeDB::bind_method(_MD("get_section_keys"),&ConfigFile::_get_section_keys); + ObjectTypeDB::bind_method(_MD("get_section_keys","section"),&ConfigFile::_get_section_keys); ObjectTypeDB::bind_method(_MD("load:Error","path"),&ConfigFile::load); ObjectTypeDB::bind_method(_MD("save:Error","path"),&ConfigFile::save); diff --git a/core/io/config_file.h b/core/io/config_file.h index 608f143fb1..4708fefeaa 100644 --- a/core/io/config_file.h +++ b/core/io/config_file.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -46,7 +46,7 @@ protected: public: void set_value(const String& p_section, const String& p_key, const Variant& p_value); - Variant get_value(const String& p_section, const String& p_key) const; + Variant get_value(const String& p_section, const String& p_key, Variant p_default=Variant()) const; bool has_section(const String& p_section) const; bool has_section_key(const String& p_section,const String& p_key) const; diff --git a/core/io/file_access_buffered.cpp b/core/io/file_access_buffered.cpp index ab17cb8118..b38fda3686 100644 --- a/core/io/file_access_buffered.cpp +++ b/core/io/file_access_buffered.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_buffered.h b/core/io/file_access_buffered.h index e6de203cda..9d405e15f7 100644 --- a/core/io/file_access_buffered.h +++ b/core/io/file_access_buffered.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h index d36c4843e4..afa79db06f 100644 --- a/core/io/file_access_buffered_fa.h +++ b/core/io/file_access_buffered_fa.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp index 1d06dc8c4b..2547d2d065 100644 --- a/core/io/file_access_compressed.cpp +++ b/core/io/file_access_compressed.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h index 69a03fa14f..f9e7cd98bd 100644 --- a/core/io/file_access_compressed.h +++ b/core/io/file_access_compressed.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 83da55fc61..2cc52a9e2d 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h index 8c58a8a8ce..287f3dfe04 100644 --- a/core/io/file_access_memory.h +++ b/core/io/file_access_memory.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index 850e055129..10667a4187 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index 2190cdb0ea..0073209ab8 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 339a6d0528..5c8c741f28 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 5bf5ad012c..f5dae6d51d 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index ab2eb3b3f2..41f43bf54d 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index 88272e6cfc..0a927b72f2 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 58092efd4b..19a7286dcf 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -248,7 +248,7 @@ Error HTTPClient::poll(){ status=STATUS_SSL_HANDSHAKE_ERROR; return ERR_CANT_CONNECT; } - print_line("SSL! TURNED ON!"); + //print_line("SSL! TURNED ON!"); connection=ssl; } status=STATUS_CONNECTED; @@ -295,7 +295,7 @@ Error HTTPClient::poll(){ response_str.push_back(0); String response; response.parse_utf8((const char*)response_str.ptr()); - print_line("END OF RESPONSE? :\n"+response+"\n------"); + //print_line("END OF RESPONSE? :\n"+response+"\n------"); Vector<String> responses = response.split("\n"); body_size=0; chunked=false; @@ -307,16 +307,17 @@ Error HTTPClient::poll(){ for(int i=0;i<responses.size();i++) { String s = responses[i].strip_edges(); + s = s.to_lower(); if (s.length()==0) continue; - if (s.begins_with("Content-Length:")) { + if (s.begins_with("content-length:")) { body_size = s.substr(s.find(":")+1,s.length()).strip_edges().to_int(); body_left=body_size; } - if (s.begins_with("Transfer-Encoding:")) { + if (s.begins_with("transfer-encoding:")) { String encoding = s.substr(s.find(":")+1,s.length()).strip_edges(); - print_line("TRANSFER ENCODING: "+encoding); + //print_line("TRANSFER ENCODING: "+encoding); if (encoding=="chunked") { chunked=true; } diff --git a/core/io/http_client.h b/core/io/http_client.h index b103dc43fc..e138681396 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index 2db6e00f0a..aa641f00b4 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/image_loader.h b/core/io/image_loader.h index ff972696ea..3cc6c6cf43 100644 --- a/core/io/image_loader.h +++ b/core/io/image_loader.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 523f9f472b..b8bd00c2fb 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/ip.h b/core/io/ip.h index 6f50a190e6..38c86e7ba3 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/ip_address.cpp b/core/io/ip_address.cpp index ed5a45c9ef..7a51bce7c6 100644 --- a/core/io/ip_address.cpp +++ b/core/io/ip_address.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/ip_address.h b/core/io/ip_address.h index e55f45a2d7..1292311729 100644 --- a/core/io/ip_address.h +++ b/core/io/ip_address.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/json.cpp b/core/io/json.cpp index 22c99d0465..f9a8638d06 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -86,7 +86,7 @@ String JSON::_print_var(const Variant& p_var) { s+="}"; return s; }; - default: return "\""+String(p_var).c_escape()+"\""; + default: return "\""+String(p_var).json_escape()+"\""; } @@ -288,7 +288,7 @@ Error JSON::_parse_value(Variant &value,Token& token,const CharType *p_str,int & if (token.type==TK_CURLY_BRACKET_OPEN) { - Dictionary d; + Dictionary d(true); Error err = _parse_object(d,p_str,index,p_len,line,r_err_str); if (err) return err; @@ -296,7 +296,7 @@ Error JSON::_parse_value(Variant &value,Token& token,const CharType *p_str,int & return OK; } else if (token.type==TK_BRACKET_OPEN) { - Array a; + Array a(true); Error err = _parse_array(a,p_str,index,p_len,line,r_err_str); if (err) return err; diff --git a/core/io/json.h b/core/io/json.h index 78b6303451..a2803269cb 100644 --- a/core/io/json.h +++ b/core/io/json.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 62ccd81489..4dccf21d2d 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/marshalls.h b/core/io/marshalls.h index df673debf5..7a5b16e8af 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index fc9e51f000..6cb3daa7ac 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h index 76d1eb22b5..b29fc22af0 100644 --- a/core/io/packet_peer.h +++ b/core/io/packet_peer.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 9a3a191b3b..c008c3f9a4 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -725,7 +725,8 @@ Error ResourceInteractiveLoaderBinary::poll(){ } } else { - path=res_path; + if (!ResourceCache::has(res_path)) + path=res_path; } uint64_t offset = internal_resources[s].offset; diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 8bf20bc574..b8be3080b8 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 48917a19ea..8c8d79948a 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -1570,7 +1570,9 @@ Error ResourceInteractiveLoaderXML::poll() { if (main) { f->close(); resource=res; - resource->set_path(res_path); + if (!ResourceCache::has(res_path)) { + resource->set_path(res_path); + } error=ERR_FILE_EOF; return error; diff --git a/core/io/resource_format_xml.h b/core/io/resource_format_xml.h index 77987c6a5b..94c81a4111 100644 --- a/core/io/resource_format_xml.h +++ b/core/io/resource_format_xml.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 3862790b02..67208b5960 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 00a05dcb43..fe58303066 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index fdb9a53f0d..51020a0285 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h index 8382b65290..7bc96c1087 100644 --- a/core/io/resource_saver.h +++ b/core/io/resource_saver.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index 1b39286bf7..2a9dff86f8 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h index 2bb8f731b2..970e6695a5 100644 --- a/core/io/stream_peer.h +++ b/core/io/stream_peer.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp index c2343790ea..fbb0c69cb7 100644 --- a/core/io/stream_peer_tcp.cpp +++ b/core/io/stream_peer_tcp.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index 0e37303516..4c58e7e149 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp index 803df87086..274d20a48a 100644 --- a/core/io/tcp_server.cpp +++ b/core/io/tcp_server.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h index b59f3293d7..512a7e640a 100644 --- a/core/io/tcp_server.h +++ b/core/io/tcp_server.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index 020d168208..fe101a8676 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/translation_loader_po.h b/core/io/translation_loader_po.h index e07ae15e28..a569674d80 100644 --- a/core/io/translation_loader_po.h +++ b/core/io/translation_loader_po.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index 1ff458f325..e6a90412c1 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -385,15 +385,15 @@ void XMLParser::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_node_data"),&XMLParser::get_node_data); ObjectTypeDB::bind_method(_MD("get_node_offset"),&XMLParser::get_node_offset); ObjectTypeDB::bind_method(_MD("get_attribute_count"),&XMLParser::get_attribute_count); - ObjectTypeDB::bind_method(_MD("get_attribute_name"),&XMLParser::get_attribute_name); - ObjectTypeDB::bind_method(_MD("get_attribute_value"),(String (XMLParser::*)(int) const) &XMLParser::get_attribute_value); - ObjectTypeDB::bind_method(_MD("has_attribute"),&XMLParser::has_attribute); - ObjectTypeDB::bind_method(_MD("get_named_attribute_value"), (String (XMLParser::*)(const String&) const) &XMLParser::get_attribute_value); - ObjectTypeDB::bind_method(_MD("get_named_attribute_value_safe"), &XMLParser::get_attribute_value_safe); + ObjectTypeDB::bind_method(_MD("get_attribute_name","idx"),&XMLParser::get_attribute_name); + ObjectTypeDB::bind_method(_MD("get_attribute_value","idx"),(String (XMLParser::*)(int) const) &XMLParser::get_attribute_value); + ObjectTypeDB::bind_method(_MD("has_attribute","name"),&XMLParser::has_attribute); + ObjectTypeDB::bind_method(_MD("get_named_attribute_value","name"), (String (XMLParser::*)(const String&) const) &XMLParser::get_attribute_value); + ObjectTypeDB::bind_method(_MD("get_named_attribute_value_safe","name"), &XMLParser::get_attribute_value_safe); ObjectTypeDB::bind_method(_MD("is_empty"),&XMLParser::is_empty); ObjectTypeDB::bind_method(_MD("get_current_line"),&XMLParser::get_current_line); ObjectTypeDB::bind_method(_MD("skip_section"),&XMLParser::skip_section); - ObjectTypeDB::bind_method(_MD("seek"),&XMLParser::seek); + ObjectTypeDB::bind_method(_MD("seek","pos"),&XMLParser::seek); ObjectTypeDB::bind_method(_MD("open","file"),&XMLParser::open); ObjectTypeDB::bind_method(_MD("open_buffer","buffer"),&XMLParser::open_buffer); diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h index 418a8efa70..e0ec3ec770 100644 --- a/core/io/xml_parser.h +++ b/core/io/xml_parser.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/io/zip_io.h b/core/io/zip_io.h index dd3c371a4a..355003d947 100644 --- a/core/io/zip_io.h +++ b/core/io/zip_io.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/list.h b/core/list.h index 018abca940..fbeb653da4 100644 --- a/core/list.h +++ b/core/list.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/map.h b/core/map.h index e45c833bcb..35dc73df48 100644 --- a/core/map.h +++ b/core/map.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/aabb.cpp b/core/math/aabb.cpp index 435df66aab..6d8a5a72f0 100644 --- a/core/math/aabb.cpp +++ b/core/math/aabb.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/aabb.h b/core/math/aabb.h index 4781e5c263..7c9c3081ac 100644 --- a/core/math/aabb.h +++ b/core/math/aabb.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/bezier_curve.cpp b/core/math/bezier_curve.cpp index c9467a77e4..37cf16504c 100644 --- a/core/math/bezier_curve.cpp +++ b/core/math/bezier_curve.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/bezier_curve.h b/core/math/bezier_curve.h index de14d68987..25df9dfda8 100644 --- a/core/math/bezier_curve.h +++ b/core/math/bezier_curve.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp index d71b7551d9..0c07b733f0 100644 --- a/core/math/bsp_tree.cpp +++ b/core/math/bsp_tree.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h index b980d9590b..a7145f9ff1 100644 --- a/core/math/bsp_tree.h +++ b/core/math/bsp_tree.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index f1afa33a4b..61c8b78e0a 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index 52b84f4870..27500a545e 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/face3.cpp b/core/math/face3.cpp index 354372df74..e1af91f28e 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/face3.h b/core/math/face3.h index eccbc78122..c36fdd1332 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index 14adde74e7..2905d26fe5 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/geometry.h b/core/math/geometry.h index 8214895676..8370990d6e 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index ce03f089e5..a485125cb4 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -187,7 +187,6 @@ Vector2 Vector2::snapped(const Vector2& p_by) const { Vector2 Vector2::clamped(real_t p_len) const { - return *this; real_t l = length(); Vector2 v = *this; if (l>0 && p_len<l) { diff --git a/core/math/math_2d.h b/core/math/math_2d.h index 3d40e24091..1171364671 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/math_defs.cpp b/core/math/math_defs.cpp index 51aaa6800e..70963bd71d 100644 --- a/core/math/math_defs.cpp +++ b/core/math/math_defs.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/math_defs.h b/core/math/math_defs.h index 7cb6c7f499..eb85039ca3 100644 --- a/core/math/math_defs.h +++ b/core/math/math_defs.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp index 3c94ac5bc7..20d9db3375 100644 --- a/core/math/math_funcs.cpp +++ b/core/math/math_funcs.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -207,9 +207,15 @@ double Math::ceil(double p_x) { int Math::decimals(double p_step) { int max=4; + double llimit = Math::pow(0.1,max); + double ulimit = 1.0-llimit; int i=0; - while( (p_step - Math::floor(p_step)) != 0.0 && max) { - + while( max) { + + float d = absf(p_step) - Math::floor(absf(p_step)); + + if (d<llimit || d>ulimit) + break; p_step*=10.0; max--; i++; diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index ec089ebc8b..62890b0371 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index 10f1461fdc..f51da80a83 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/matrix3.h b/core/math/matrix3.h index 98feb2dbbd..291934b8eb 100644 --- a/core/math/matrix3.h +++ b/core/math/matrix3.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/octree.h b/core/math/octree.h index 84de388178..b51c4bcba7 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/plane.cpp b/core/math/plane.cpp index f9395a002a..d17ce01bec 100644 --- a/core/math/plane.cpp +++ b/core/math/plane.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/plane.h b/core/math/plane.h index 604b880266..d20e63dc47 100644 --- a/core/math/plane.h +++ b/core/math/plane.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/quat.cpp b/core/math/quat.cpp index e0c4b0793c..ebc5ec4e65 100644 --- a/core/math/quat.cpp +++ b/core/math/quat.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/quat.h b/core/math/quat.h index f161e35074..738b6946c7 100644 --- a/core/math/quat.h +++ b/core/math/quat.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 80ae0f04e1..956824d3d0 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h index cb486a0b6f..8c009b907d 100644 --- a/core/math/quick_hull.h +++ b/core/math/quick_hull.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/transform.cpp b/core/math/transform.cpp index a6f4f626cc..8371f7e34b 100644 --- a/core/math/transform.cpp +++ b/core/math/transform.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/transform.h b/core/math/transform.h index a992843d70..bd1247084d 100644 --- a/core/math/transform.h +++ b/core/math/transform.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index 70cb639fc2..adb9861092 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h index 87d8ce8e6c..b5e8f79cde 100644 --- a/core/math/triangle_mesh.h +++ b/core/math/triangle_mesh.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/triangulate.cpp b/core/math/triangulate.cpp index b13e13c47d..27b7c86675 100644 --- a/core/math/triangulate.cpp +++ b/core/math/triangulate.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/triangulate.h b/core/math/triangulate.h index 927b7efb8d..7dcc91b2fd 100644 --- a/core/math/triangulate.h +++ b/core/math/triangulate.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index a3877eb9ff..8afd73f482 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/math/vector3.h b/core/math/vector3.h index 8a3cca8f33..528c4d37b3 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 489939ee65..c69021f4f0 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -28,7 +28,7 @@ /*************************************************************************/ #include "message_queue.h" #include "globals.h" - +#include "script_language.h" MessageQueue *MessageQueue::singleton=NULL; MessageQueue *MessageQueue::get_singleton() { @@ -36,26 +36,11 @@ MessageQueue *MessageQueue::get_singleton() { return singleton; } -Error MessageQueue::push_call(ObjectID p_id, const StringName& p_method, VARIANT_ARG_DECLARE) { +Error MessageQueue::push_call(ObjectID p_id,const StringName& p_method,const Variant** p_args,int p_argcount,bool p_show_error) { _THREAD_SAFE_METHOD_ - uint8_t room_needed=sizeof(Message); - int args=0; - if (p_arg5.get_type()!=Variant::NIL) - args=5; - else if (p_arg4.get_type()!=Variant::NIL) - args=4; - else if (p_arg3.get_type()!=Variant::NIL) - args=3; - else if (p_arg2.get_type()!=Variant::NIL) - args=2; - else if (p_arg1.get_type()!=Variant::NIL) - args=1; - else - args=0; - - room_needed+=sizeof(Variant)*args; + int room_needed=sizeof(Message)+sizeof(Variant)*p_argcount; if ((buffer_end+room_needed) >= buffer_size) { String type; @@ -65,53 +50,43 @@ Error MessageQueue::push_call(ObjectID p_id, const StringName& p_method, VARIANT statistics(); } + ERR_FAIL_COND_V( (buffer_end+room_needed) >= buffer_size , ERR_OUT_OF_MEMORY ); Message * msg = memnew_placement( &buffer[ buffer_end ], Message ); - msg->args=args; + msg->args=p_argcount; msg->instance_ID=p_id; msg->target=p_method; msg->type=TYPE_CALL; - buffer_end+=sizeof(Message); + if (p_show_error) + msg->type|=FLAG_SHOW_ERROR; + buffer_end+=sizeof(Message); - if (args>=1) { + for(int i=0;i<p_argcount;i++) { Variant * v = memnew_placement( &buffer[ buffer_end ], Variant ); buffer_end+=sizeof(Variant); - *v=p_arg1; - } - - if (args>=2) { + *v=*p_args[i]; - Variant * v = memnew_placement( &buffer[ buffer_end ], Variant ); - buffer_end+=sizeof(Variant); - *v=p_arg2; } - if (args>=3) { + return OK; +} - Variant * v = memnew_placement( &buffer[ buffer_end ], Variant ); - buffer_end+=sizeof(Variant); - *v=p_arg3; +Error MessageQueue::push_call(ObjectID p_id, const StringName& p_method, VARIANT_ARG_DECLARE) { - } + VARIANT_ARGPTRS; - if (args>=4) { + int argc=0; - Variant * v = memnew_placement( &buffer[ buffer_end ], Variant ); - buffer_end+=sizeof(Variant); - *v=p_arg4; + for(int i=0;i<VARIANT_ARG_MAX;i++) { + if (argptr[i]->get_type()==Variant::NIL) + break; + argc++; } - if (args>=5) { + return push_call(p_id,p_method,argptr,argc,false); - Variant * v = memnew_placement( &buffer[ buffer_end ], Variant ); - buffer_end+=sizeof(Variant); - *v=p_arg5; - } - - - return OK; } Error MessageQueue::push_set(ObjectID p_id, const StringName& p_prop, const Variant& p_value) { @@ -212,7 +187,7 @@ void MessageQueue::statistics() { if (target!=NULL) { - switch(message->type) { + switch(message->type&FLAG_MASK) { case TYPE_CALL: { @@ -251,7 +226,7 @@ void MessageQueue::statistics() { read_pos+=sizeof(Message); - if (message->type!=TYPE_NOTIFICATION) + if ((message->type&FLAG_MASK)!=TYPE_NOTIFICATION) read_pos+=sizeof(Variant)*message->args; } @@ -322,6 +297,26 @@ int MessageQueue::get_max_buffer_usage() const { return buffer_max_used; } + +void MessageQueue::_call_function(Object* p_target, const StringName& p_func, const Variant *p_args, int p_argcount,bool p_show_error) { + + const Variant **argptrs=NULL; + if (p_argcount) { + argptrs = (const Variant**)alloca(sizeof(Variant*)*p_argcount); + for(int i=0;i<p_argcount;i++) { + argptrs[i]=&p_args[i]; + } + } + + Variant::CallError ce; + p_target->call(p_func,argptrs,p_argcount,ce); + if (p_show_error && ce.error!=Variant::CallError::CALL_OK) { + + ERR_PRINTS("Error calling deferred method: "+Variant::get_call_error_text(p_target,p_func,argptrs,p_argcount,ce)); + + } +} + void MessageQueue::flush() { @@ -347,7 +342,7 @@ void MessageQueue::flush() { if (target!=NULL) { - switch(message->type) { + switch(message->type&FLAG_MASK) { case TYPE_CALL: { Variant *args= (Variant*)(message+1); @@ -355,12 +350,7 @@ void MessageQueue::flush() { // messages don't expect a return value - target->call( message->target, - (message->args>=1) ? args[0] : Variant(), - (message->args>=2) ? args[1] : Variant(), - (message->args>=3) ? args[2] : Variant(), - (message->args>=4) ? args[3] : Variant(), - (message->args>=5) ? args[4] : Variant() ); + _call_function(target,message->target,args,message->args,message->type&FLAG_SHOW_ERROR); for(int i=0;i<message->args;i++) { args[i].~Variant(); @@ -386,7 +376,7 @@ void MessageQueue::flush() { } uint32_t advance = sizeof(Message); - if (message->type!=TYPE_NOTIFICATION) + if ((message->type&FLAG_MASK)!=TYPE_NOTIFICATION) advance+=sizeof(Variant)*message->args; message->~Message(); @@ -423,14 +413,14 @@ MessageQueue::~MessageQueue() { Message *message = (Message*)&buffer[ read_pos ]; Variant *args= (Variant*)(message+1); int argc = message->args; - if (message->type!=TYPE_NOTIFICATION) { + if ((message->type&FLAG_MASK)!=TYPE_NOTIFICATION) { for (int i=0;i<argc;i++) args[i].~Variant(); } message->~Message(); read_pos+=sizeof(Message); - if (message->type!=TYPE_NOTIFICATION) + if ((message->type&FLAG_MASK)!=TYPE_NOTIFICATION) read_pos+=sizeof(Variant)*message->args; } diff --git a/core/message_queue.h b/core/message_queue.h index 5cee21847b..6a3ec79732 100644 --- a/core/message_queue.h +++ b/core/message_queue.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -46,7 +46,10 @@ class MessageQueue { enum { TYPE_CALL, TYPE_NOTIFICATION, - TYPE_SET + TYPE_SET, + FLAG_SHOW_ERROR=1<<14, + FLAG_MASK=FLAG_SHOW_ERROR-1 + }; struct Message { @@ -65,12 +68,14 @@ class MessageQueue { uint32_t buffer_max_used; uint32_t buffer_size; + void _call_function(Object* p_target,const StringName& p_func,const Variant *p_args,int p_argcount,bool p_show_error); static MessageQueue *singleton; public: static MessageQueue *get_singleton(); + Error push_call(ObjectID p_id,const StringName& p_method,const Variant** p_args,int p_argcount,bool p_show_error=false); Error push_call(ObjectID p_id, const StringName& p_method, VARIANT_ARG_LIST); Error push_notification(ObjectID p_id, int p_notification); Error push_set(ObjectID p_id, const StringName& p_prop, const Variant& p_value); diff --git a/core/method_bind.cpp b/core/method_bind.cpp index ce57380434..b41fa33887 100644 --- a/core/method_bind.cpp +++ b/core/method_bind.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/method_bind.h b/core/method_bind.h index 85c1084f80..4c2598e50c 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/multi_bucket_array.h b/core/multi_bucket_array.h index d85c9de583..98033e40f6 100644 --- a/core/multi_bucket_array.h +++ b/core/multi_bucket_array.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/object.cpp b/core/object.cpp index 9fdd11eb2e..c92fc35b24 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -512,17 +512,10 @@ Variant Object::_call_deferred_bind(const Variant** p_args, int p_argcount, Vari r_error.error=Variant::CallError::CALL_OK; - StringName signal = *p_args[0]; - - Variant v[VARIANT_ARG_MAX]; - - - for(int i=0;i<MIN(5,p_argcount-1);i++) { + StringName method = *p_args[0]; - v[i]=*p_args[i+1]; - } + MessageQueue::get_singleton()->push_call(get_instance_ID(),method,&p_args[1],p_argcount-1); - call_deferred(signal,v[0],v[1],v[2],v[3],v[4]); return Variant(); } @@ -839,6 +832,8 @@ void Object::call_multilevel(const StringName& p_name, VARIANT_ARG_DECLARE) { Variant Object::call(const StringName& p_method,const Variant** p_args,int p_argcount,Variant::CallError &r_error) { + r_error.error=Variant::CallError::CALL_OK; + if (p_method==CoreStringNames::get_singleton()->_free) { //free must be here, before anything, always ready #ifdef DEBUG_ENABLED @@ -1011,6 +1006,27 @@ Array Object::_get_property_list_bind() const { return convert_property_list(&lpi); } + +static Dictionary _get_dict_from_method(const MethodInfo &mi) { + + Dictionary d; + d["name"]=mi.name; + d["args"]=convert_property_list(&mi.arguments); + Array da; + for(int i=0;i<mi.default_arguments.size();i++) + da.push_back(mi.default_arguments[i]); + d["default_args"]=da; + d["flags"]=mi.flags; + d["id"]=mi.id; + Dictionary r; + r["type"]=mi.return_val.type; + r["hint"]=mi.return_val.hint; + r["hint_string"]=mi.return_val.hint_string; + d["return_type"]=r; + return d; + +} + Array Object::_get_method_list_bind() const { List<MethodInfo> ml; @@ -1019,20 +1035,7 @@ Array Object::_get_method_list_bind() const { for(List<MethodInfo>::Element *E=ml.front();E;E=E->next()) { - Dictionary d; - d["name"]=E->get().name; - d["args"]=convert_property_list(&E->get().arguments); - Array da; - for(int i=0;i<E->get().default_arguments.size();i++) - da.push_back(E->get().default_arguments[i]); - d["default_args"]=da; - d["flags"]=E->get().flags; - d["id"]=E->get().id; - Dictionary r; - r["type"]=E->get().return_val.type; - r["hint"]=E->get().return_val.hint; - r["hint_string"]=E->get().return_val.hint_string; - d["return_type"]=r; + Dictionary d = _get_dict_from_method(E->get()); //va.push_back(d); ret.push_back(d); } @@ -1122,21 +1125,22 @@ Variant Object::_emit_signal(const Variant** p_args, int p_argcount, Variant::Ca StringName signal = *p_args[0]; - Variant v[VARIANT_ARG_MAX]; - - for(int i=0;i<MIN(5,p_argcount-1);i++) { + const Variant**args=NULL; - v[i]=*p_args[i+1]; + int argc=p_argcount-1; + if (argc) { + args=&p_args[1]; } - emit_signal(signal,v[0],v[1],v[2],v[3],v[4]); + emit_signal(signal,args,argc); + return Variant(); -} +} -void Object::emit_signal(const StringName& p_name,VARIANT_ARG_DECLARE) { +void Object::emit_signal(const StringName& p_name,const Variant** p_args,int p_argcount) { if (_block_signals) return; //no emit, signals blocked @@ -1159,10 +1163,12 @@ void Object::emit_signal(const StringName& p_name,VARIANT_ARG_DECLARE) { OBJ_DEBUG_LOCK + Vector<const Variant*> bind_mem; + + for(int i=0;i<ssize;i++) { const Connection &c = slot_map.getv(i).conn; - VARIANT_ARGPTRS Object *target; #ifdef DEBUG_ENABLED @@ -1173,21 +1179,37 @@ void Object::emit_signal(const StringName& p_name,VARIANT_ARG_DECLARE) { #endif - int bind_count=c.binds.size(); - int bind=0; + const Variant **args=p_args; + int argc=p_argcount; - for(int i=0;bind < bind_count && i<VARIANT_ARG_MAX;i++) { + if (c.binds.size()) { + //handle binds + bind_mem.resize(p_argcount+c.binds.size()); - if (argptr[i]->get_type()==Variant::NIL) { - argptr[i]=&c.binds[bind]; - bind++; + for(int j=0;j<p_argcount;j++) { + bind_mem[j]=p_args[j]; + } + for(int j=0;j<c.binds.size();j++) { + bind_mem[p_argcount+j]=&c.binds[j]; } + + args=bind_mem.ptr(); + argc=bind_mem.size(); } if (c.flags&CONNECT_DEFERRED) { - MessageQueue::get_singleton()->push_call(target->get_instance_ID(),c.method,VARIANT_ARGPTRS_PASS); + MessageQueue::get_singleton()->push_call(target->get_instance_ID(),c.method,args,argc,true); } else { - target->call( c.method, VARIANT_ARGPTRS_PASS ); + Variant::CallError ce; + target->call( c.method, args, argc,ce ); + if (ce.error!=Variant::CallError::CALL_OK) { + + if (ce.error==Variant::CallError::CALL_ERROR_INVALID_METHOD && !ObjectTypeDB::type_exists( target->get_type_name() ) ) { + //most likely object is not initialized yet, do not throw error. + } else { + ERR_PRINTS("Error calling method from signal '"+String(p_name)+"': "+Variant::get_call_error_text(target,c.method,args,argc,ce)); + } + } } if (c.flags&CONNECT_ONESHOT) { @@ -1200,57 +1222,29 @@ void Object::emit_signal(const StringName& p_name,VARIANT_ARG_DECLARE) { } -#if 0 - - //old (deprecated and dangerous code) - s->lock++; - for( Map<Signal::Target,Signal::Slot>::Element *E = s->slot_map.front();E;E=E->next() ) { - - const Signal::Target& t = E->key(); - const Signal::Slot& s = E->get(); - const Connection &c = s.cE->get(); - VARIANT_ARGPTRS + while (!disconnect_data.empty()) { - int bind_count=c.binds.size(); - int bind=0; + const _ObjectSignalDisconnectData &dd = disconnect_data.front()->get(); + disconnect(dd.signal,dd.target,dd.method); + disconnect_data.pop_front(); + } - for(int i=0;bind < bind_count && i<VARIANT_ARG_MAX;i++) { +} - if (argptr[i]->get_type()==Variant::NIL) { - argptr[i]=&c.binds[bind]; - bind++; - } - } +void Object::emit_signal(const StringName& p_name,VARIANT_ARG_DECLARE) { - if (c.flags&CONNECT_DEFERRED) { - MessageQueue::get_singleton()->push_call(t._id,t.method,VARIANT_ARGPTRS_PASS); - } else { - Object *obj = ObjectDB::get_instance(t._id); - ERR_CONTINUE(!obj); //yeah this should always be here - obj->call( t.method, VARIANT_ARGPTRS_PASS ); - } + VARIANT_ARGPTRS; - if (c.flags&CONNECT_ONESHOT) { - _ObjectSignalDisconnectData dd; - dd.signal=p_name; - dd.target=ObjectDB::get_instance(t._id); - dd.method=t.method; - disconnect_data.push_back(dd); - } + int argc=0; + for(int i=0;i<VARIANT_ARG_MAX;i++) { + if (argptr[i]->get_type()==Variant::NIL) + break; + argc++; } - - - s->lock--; -#endif - while (!disconnect_data.empty()) { - - const _ObjectSignalDisconnectData &dd = disconnect_data.front()->get(); - disconnect(dd.signal,dd.target,dd.method); - disconnect_data.pop_front(); - } + emit_signal(p_name,argptr,argc); } @@ -1299,11 +1293,39 @@ void Object::_emit_signal(const StringName& p_name,const Array& p_pargs){ #endif Array Object::_get_signal_list() const{ - return Array(); + List<MethodInfo> signal_list; + get_signal_list(&signal_list); + + Array ret; + for (List<MethodInfo>::Element *E=signal_list.front();E;E=E->next()) { + + ret.push_back(_get_dict_from_method(E->get())); + } + + return ret; } Array Object::_get_signal_connection_list(const String& p_signal) const{ - return Array(); + List<Connection> conns; + get_all_signal_connections(&conns); + + Array ret; + + for (List<Connection>::Element *E=conns.front();E;E=E->next()) { + + Connection &c=E->get(); + Dictionary rc; + rc["signal"]=c.signal; + rc["method"]=c.method; + rc["source"]=c.source; + rc["target"]=c.target; + rc["binds"]=c.binds; + rc["flags"]=c.flags; + ret.push_back(rc); + } + + return ret; + } @@ -1550,7 +1572,7 @@ void Object::_bind_methods() { ObjectTypeDB::bind_method(_MD("get","property"),&Object::_get_bind); ObjectTypeDB::bind_method(_MD("get_property_list"),&Object::_get_property_list_bind); ObjectTypeDB::bind_method(_MD("get_method_list"),&Object::_get_method_list_bind); - ObjectTypeDB::bind_method(_MD("notification","what"),&Object::notification,DEFVAL(false)); + ObjectTypeDB::bind_method(_MD("notification","what","reversed"),&Object::notification,DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_instance_ID"),&Object::get_instance_ID); ObjectTypeDB::bind_method(_MD("set_script","script:Script"),&Object::set_script); @@ -1615,9 +1637,10 @@ void Object::_bind_methods() { ObjectTypeDB::bind_method(_MD("callv:Variant","method","arg_array"),&Object::callv); - ObjectTypeDB::bind_method(_MD("has_method"),&Object::has_method); + ObjectTypeDB::bind_method(_MD("has_method","method"),&Object::has_method); ObjectTypeDB::bind_method(_MD("get_signal_list"),&Object::_get_signal_list); + ObjectTypeDB::bind_method(_MD("get_signal_connection_list","signal"),&Object::_get_signal_connection_list); ObjectTypeDB::bind_method(_MD("connect","signal","target:Object","method","binds","flags"),&Object::connect,DEFVAL(Array()),DEFVAL(0)); ObjectTypeDB::bind_method(_MD("disconnect","signal","target:Object","method"),&Object::disconnect); diff --git a/core/object.h b/core/object.h index 5b6361796f..dcebf9b2a2 100644 --- a/core/object.h +++ b/core/object.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -593,6 +593,7 @@ public: void add_user_signal(const MethodInfo& p_signal); void emit_signal(const StringName& p_name,VARIANT_ARG_LIST); + void emit_signal(const StringName& p_name, const Variant** p_args, int p_argcount); void get_signal_list(List<MethodInfo> *p_signals ) const; void get_signal_connection_list(const StringName& p_signal,List<Connection> *p_connections) const; void get_all_signal_connections(List<Connection> *p_connections) const; diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp index f8ba0a9b15..dd9304f1f9 100644 --- a/core/object_type_db.cpp +++ b/core/object_type_db.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/object_type_db.h b/core/object_type_db.h index 319e3ec02c..f6caf14be5 100644 --- a/core/object_type_db.h +++ b/core/object_type_db.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/copymem.cpp b/core/os/copymem.cpp index 54baf1e232..234ca50b45 100644 --- a/core/os/copymem.cpp +++ b/core/os/copymem.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/copymem.h b/core/os/copymem.h index a5d640edbf..d7fc46aae4 100644 --- a/core/os/copymem.h +++ b/core/os/copymem.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index d0baae5872..32d66a7408 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/dir_access.h b/core/os/dir_access.h index 8bacc96c60..e97a065998 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index ef7efd27e1..d82d0b63c5 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/file_access.h b/core/os/file_access.h index 8e34013796..51cf839117 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -78,6 +78,7 @@ public: READ=1, WRITE=2, READ_WRITE=3, + WRITE_READ=7, }; virtual void close()=0; ///< close a file diff --git a/core/os/input.cpp b/core/os/input.cpp index 15872d02fd..6e1e618d9a 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -53,8 +53,12 @@ void Input::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_mouse_button_pressed","button"),&Input::is_mouse_button_pressed); ObjectTypeDB::bind_method(_MD("is_joy_button_pressed","device","button"),&Input::is_joy_button_pressed); ObjectTypeDB::bind_method(_MD("is_action_pressed","action"),&Input::is_action_pressed); + ObjectTypeDB::bind_method(_MD("add_joy_mapping","mapping", "update_existing"),&Input::add_joy_mapping, DEFVAL(false)); + ObjectTypeDB::bind_method(_MD("remove_joy_mapping","guid"),&Input::remove_joy_mapping); + ObjectTypeDB::bind_method(_MD("is_joy_known","device"),&Input::is_joy_known); ObjectTypeDB::bind_method(_MD("get_joy_axis","device","axis"),&Input::get_joy_axis); ObjectTypeDB::bind_method(_MD("get_joy_name","device"),&Input::get_joy_name); + ObjectTypeDB::bind_method(_MD("get_joy_guid","device"),&Input::get_joy_guid); ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer); //ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos); - this is not the function you want ObjectTypeDB::bind_method(_MD("get_mouse_speed"),&Input::get_mouse_speed); @@ -62,8 +66,8 @@ void Input::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_mouse_mode","mode"),&Input::set_mouse_mode); ObjectTypeDB::bind_method(_MD("get_mouse_mode"),&Input::get_mouse_mode); ObjectTypeDB::bind_method(_MD("warp_mouse_pos","to"),&Input::warp_mouse_pos); - ObjectTypeDB::bind_method(_MD("action_press"),&Input::action_press); - ObjectTypeDB::bind_method(_MD("action_release"),&Input::action_release); + ObjectTypeDB::bind_method(_MD("action_press","action"),&Input::action_press); + ObjectTypeDB::bind_method(_MD("action_release","action"),&Input::action_release); ObjectTypeDB::bind_method(_MD("set_custom_mouse_cursor","image:Texture","hotspot"),&Input::set_custom_mouse_cursor,DEFVAL(Vector2())); BIND_CONSTANT( MOUSE_MODE_VISIBLE ); diff --git a/core/os/input.h b/core/os/input.h index d81ebf4ec3..2dd4496f26 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -63,7 +63,10 @@ public: virtual float get_joy_axis(int p_device,int p_axis)=0; virtual String get_joy_name(int p_idx)=0; virtual void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid)=0; - + virtual void add_joy_mapping(String p_mapping, bool p_update_existing=false)=0; + virtual void remove_joy_mapping(String p_guid)=0; + virtual bool is_joy_known(int p_device)=0; + virtual String get_joy_guid(int p_device) const=0; virtual Point2 get_mouse_pos() const=0; virtual Point2 get_mouse_speed() const=0; diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index 2bd62927b0..2f39567a7e 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -156,6 +156,7 @@ bool InputEvent::is_pressed() const { case MOUSE_BUTTON: return mouse_button.pressed; case JOYSTICK_BUTTON: return joy_button.pressed; case SCREEN_TOUCH: return screen_touch.pressed; + case JOYSTICK_MOTION: return InputMap::get_singleton()->event_is_joy_motion_action_pressed(*this); case ACTION: return action.pressed; default: {} } diff --git a/core/os/input_event.h b/core/os/input_event.h index 4bb122ebc1..b601adc875 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -143,6 +143,9 @@ enum { JOY_ANALOG_2_X = JOY_AXIS_4, JOY_ANALOG_2_Y = JOY_AXIS_5, + + JOY_ANALOG_L2 = JOY_AXIS_6, + JOY_ANALOG_R2 = JOY_AXIS_7, }; diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index 10e64c3961..633aa06a9a 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/keyboard.h b/core/os/keyboard.h index eaf656dd4d..69e74d1252 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index c37c281fb9..310bbaa3b8 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/main_loop.h b/core/os/main_loop.h index c5d58120c5..059624dbe4 100644 --- a/core/os/main_loop.h +++ b/core/os/main_loop.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/memory.cpp b/core/os/memory.cpp index 1d9ac4e302..f7f8fef2b7 100644 --- a/core/os/memory.cpp +++ b/core/os/memory.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/memory.h b/core/os/memory.h index 0a35c93fdb..98b973bc06 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/memory_pool_dynamic.cpp b/core/os/memory_pool_dynamic.cpp index d1c41aff84..6be8d0a36d 100644 --- a/core/os/memory_pool_dynamic.cpp +++ b/core/os/memory_pool_dynamic.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/memory_pool_dynamic.h b/core/os/memory_pool_dynamic.h index 00999ee24d..82149bcf5d 100644 --- a/core/os/memory_pool_dynamic.h +++ b/core/os/memory_pool_dynamic.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/memory_pool_dynamic_prealloc.cpp b/core/os/memory_pool_dynamic_prealloc.cpp index c7c25f32d1..f76c2a12b4 100644 --- a/core/os/memory_pool_dynamic_prealloc.cpp +++ b/core/os/memory_pool_dynamic_prealloc.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/memory_pool_dynamic_prealloc.h b/core/os/memory_pool_dynamic_prealloc.h index 3523079bac..d2256c0c98 100644 --- a/core/os/memory_pool_dynamic_prealloc.h +++ b/core/os/memory_pool_dynamic_prealloc.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/memory_pool_dynamic_static.cpp b/core/os/memory_pool_dynamic_static.cpp index 029ef450cd..894066708e 100644 --- a/core/os/memory_pool_dynamic_static.cpp +++ b/core/os/memory_pool_dynamic_static.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/memory_pool_dynamic_static.h b/core/os/memory_pool_dynamic_static.h index a870f3070c..6177c78de7 100644 --- a/core/os/memory_pool_dynamic_static.h +++ b/core/os/memory_pool_dynamic_static.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/memory_pool_static.cpp b/core/os/memory_pool_static.cpp index d3617eac73..321f4d989e 100644 --- a/core/os/memory_pool_static.cpp +++ b/core/os/memory_pool_static.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/memory_pool_static.h b/core/os/memory_pool_static.h index 40bd1aaf0e..2e11b7ded4 100644 --- a/core/os/memory_pool_static.h +++ b/core/os/memory_pool_static.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/mutex.cpp b/core/os/mutex.cpp index be984c080b..9b379009b9 100644 --- a/core/os/mutex.cpp +++ b/core/os/mutex.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/mutex.h b/core/os/mutex.h index ac6d36d635..f16375aa26 100644 --- a/core/os/mutex.h +++ b/core/os/mutex.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/os.cpp b/core/os/os.cpp index 8caf95e4d1..be447d511e 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -50,7 +50,7 @@ uint64_t OS::get_unix_time() const { return 0; }; -uint64_t OS::get_system_time_msec() const { +uint64_t OS::get_system_time_secs() const { return 0; } void OS::debug_break() { @@ -507,6 +507,13 @@ float OS::get_time_scale() const { return _time_scale; } +bool OS::is_joy_known(int p_device) { + return true; +} + +String OS::get_joy_guid(int p_device) const { + return "Default Joystick"; +} OS::OS() { last_error=NULL; diff --git a/core/os/os.h b/core/os/os.h index ab1a07276c..83ea2c2101 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -256,7 +256,7 @@ public: virtual Time get_time(bool local=false) const=0; virtual TimeZoneInfo get_time_zone_info() const=0; virtual uint64_t get_unix_time() const; - virtual uint64_t get_system_time_msec() const; + virtual uint64_t get_system_time_secs() const; virtual void delay_usec(uint32_t p_usec) const=0; virtual uint64_t get_ticks_usec() const=0; @@ -397,6 +397,9 @@ public: _FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; } + virtual bool is_joy_known(int p_device); + virtual String get_joy_guid(int p_device)const; + OS(); virtual ~OS(); diff --git a/core/os/pc_joystick_map.h b/core/os/pc_joystick_map.h index 111dc9b3a8..df123c5c1b 100644 --- a/core/os/pc_joystick_map.h +++ b/core/os/pc_joystick_map.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/semaphore.cpp b/core/os/semaphore.cpp index 8cb431d2cc..5fa2d339dc 100644 --- a/core/os/semaphore.cpp +++ b/core/os/semaphore.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/semaphore.h b/core/os/semaphore.h index e8ad9d3c3a..b65542ce35 100644 --- a/core/os/semaphore.h +++ b/core/os/semaphore.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/shell.cpp b/core/os/shell.cpp index 3746dc6804..8737d97fa0 100644 --- a/core/os/shell.cpp +++ b/core/os/shell.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/shell.h b/core/os/shell.h index 7ef5abbdef..805dd70301 100644 --- a/core/os/shell.h +++ b/core/os/shell.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/thread.cpp b/core/os/thread.cpp index 53db62c176..7fb1e969d4 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/thread.h b/core/os/thread.h index e3d00b0397..5711561809 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/thread_dummy.cpp b/core/os/thread_dummy.cpp index 4e139f6379..30a0e2696c 100644 --- a/core/os/thread_dummy.cpp +++ b/core/os/thread_dummy.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/thread_dummy.h b/core/os/thread_dummy.h index a83e42ff98..800eef9ef9 100644 --- a/core/os/thread_dummy.h +++ b/core/os/thread_dummy.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/thread_safe.cpp b/core/os/thread_safe.cpp index 9a20db6a9d..f252190504 100644 --- a/core/os/thread_safe.cpp +++ b/core/os/thread_safe.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/os/thread_safe.h b/core/os/thread_safe.h index 62d2181279..793dd88543 100644 --- a/core/os/thread_safe.h +++ b/core/os/thread_safe.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index fa17e93aa8..dd736502a3 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/packed_data_container.h b/core/packed_data_container.h index f4152bbb4d..9183dcb90e 100644 --- a/core/packed_data_container.h +++ b/core/packed_data_container.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/pair.cpp b/core/pair.cpp index 17076bb379..14bb2d7775 100644 --- a/core/pair.cpp +++ b/core/pair.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/pair.h b/core/pair.h index 83fc837fff..9bffc37f49 100644 --- a/core/pair.h +++ b/core/pair.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/path_db.cpp b/core/path_db.cpp index c6ea25d966..d3521fcb23 100644 --- a/core/path_db.cpp +++ b/core/path_db.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/path_db.h b/core/path_db.h index de84216006..9c9be65d28 100644 --- a/core/path_db.h +++ b/core/path_db.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/path_remap.cpp b/core/path_remap.cpp index 2ef39470a0..d4cb883f41 100644 --- a/core/path_remap.cpp +++ b/core/path_remap.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/path_remap.h b/core/path_remap.h index cb2a045668..66ebe7987b 100644 --- a/core/path_remap.h +++ b/core/path_remap.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp index d7dca45836..23be650fda 100644 --- a/core/pool_allocator.cpp +++ b/core/pool_allocator.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/pool_allocator.h b/core/pool_allocator.h index 4b0f931eb3..2c5920149b 100644 --- a/core/pool_allocator.h +++ b/core/pool_allocator.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/print_string.cpp b/core/print_string.cpp index 42e018f303..e364388b7b 100644 --- a/core/print_string.cpp +++ b/core/print_string.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -66,7 +66,7 @@ void remove_print_handler(PrintHandlerList *p_handler) { l=l->next; } - OS::get_singleton()->print("print hanlder list is %p\n",print_handler_list); + OS::get_singleton()->print("print handler list is %p\n",print_handler_list); ERR_FAIL_COND(l==NULL); _global_unlock(); diff --git a/core/print_string.h b/core/print_string.h index 4ea389b3a1..0aa5b4c8e9 100644 --- a/core/print_string.h +++ b/core/print_string.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/ref_ptr.cpp b/core/ref_ptr.cpp index ddb8054e3b..dee2b9a164 100644 --- a/core/ref_ptr.cpp +++ b/core/ref_ptr.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/ref_ptr.h b/core/ref_ptr.h index d1ee6a3a7d..68788b73cd 100644 --- a/core/ref_ptr.h +++ b/core/ref_ptr.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/reference.cpp b/core/reference.cpp index 509e132b5a..90bafd0a9c 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/reference.h b/core/reference.h index 65f31f78f3..8bfbf19ab6 100644 --- a/core/reference.h +++ b/core/reference.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 8754946bb1..d977ea3e18 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -101,10 +101,12 @@ void register_core_types() { resource_loader_binary = memnew( ResourceFormatLoaderBinary ); ResourceLoader::add_resource_format_loader(resource_loader_binary); +#ifdef XML_ENABLED resource_saver_xml = memnew( ResourceFormatSaverXML ); ResourceSaver::add_resource_format_saver(resource_saver_xml); resource_loader_xml = memnew( ResourceFormatLoaderXML ); ResourceLoader::add_resource_format_loader(resource_loader_xml); +#endif ObjectTypeDB::register_type<Object>(); diff --git a/core/register_core_types.h b/core/register_core_types.h index a84849c969..239d67f1ec 100644 --- a/core/register_core_types.h +++ b/core/register_core_types.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/res_ptr.cpp b/core/res_ptr.cpp index fcff285e8f..11312b8021 100644 --- a/core/res_ptr.cpp +++ b/core/res_ptr.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/res_ptr.h b/core/res_ptr.h index 21f7fb6a2c..e1dc66b290 100644 --- a/core/res_ptr.h +++ b/core/res_ptr.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/resource.cpp b/core/resource.cpp index 6967599f96..e0706cf541 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -278,7 +278,7 @@ void Resource::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_import_metadata","metadata"),&Resource::set_import_metadata); ObjectTypeDB::bind_method(_MD("get_import_metadata"),&Resource::get_import_metadata); - ObjectTypeDB::bind_method(_MD("duplicate"),&Resource::duplicate,DEFVAL(false)); + ObjectTypeDB::bind_method(_MD("duplicate","subresources"),&Resource::duplicate,DEFVAL(false)); ADD_SIGNAL( MethodInfo("changed") ); ADD_PROPERTY( PropertyInfo(Variant::STRING,"resource/path",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR ), _SCS("set_path"),_SCS("get_path")); ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"resource/name"), _SCS("set_name"),_SCS("get_name")); diff --git a/core/resource.h b/core/resource.h index cd28a51755..f0c86631cc 100644 --- a/core/resource.h +++ b/core/resource.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/rid.cpp b/core/rid.cpp index 0870e6ab2d..219c2f0e69 100644 --- a/core/rid.cpp +++ b/core/rid.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/rid.h b/core/rid.h index e6582757ee..85ae1b15d3 100644 --- a/core/rid.h +++ b/core/rid.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/ring_buffer.h b/core/ring_buffer.h index 5cbd261ec8..4658ec5e51 100644 --- a/core/ring_buffer.h +++ b/core/ring_buffer.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/safe_refcount.cpp b/core/safe_refcount.cpp index afe2a4eb33..7718e466f2 100644 --- a/core/safe_refcount.cpp +++ b/core/safe_refcount.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/safe_refcount.h b/core/safe_refcount.h index 481b9fa7e9..e5dc854c23 100644 --- a/core/safe_refcount.h +++ b/core/safe_refcount.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/script_debugger_debugger.cpp b/core/script_debugger_debugger.cpp index 5c592a130c..71ad33f5ed 100644 --- a/core/script_debugger_debugger.cpp +++ b/core/script_debugger_debugger.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/script_debugger_local.cpp b/core/script_debugger_local.cpp index 649bbe89f0..3e442f7f59 100644 --- a/core/script_debugger_local.cpp +++ b/core/script_debugger_local.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/script_debugger_local.h b/core/script_debugger_local.h index 45ff1d4466..4abacfc519 100644 --- a/core/script_debugger_local.h +++ b/core/script_debugger_local.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index d72c9f7532..b56ff4c0e1 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -30,7 +30,7 @@ #include "os/os.h" #include "io/ip.h" #include "globals.h" - +#include "os/input.h" void ScriptDebuggerRemote::_send_video_memory() { List<ResourceUsage> usage; @@ -135,6 +135,10 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) { packet_peer_stream->put_var(p_can_continue); packet_peer_stream->put_var(p_script->debug_get_error()); + Input::MouseMode mouse_mode=Input::get_singleton()->get_mouse_mode(); + if (mouse_mode!=Input::MOUSE_MODE_VISIBLE) + Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE); + while(true) { @@ -296,6 +300,9 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) { packet_peer_stream->put_var("debug_exit"); packet_peer_stream->put_var(0); + if (mouse_mode!=Input::MOUSE_MODE_VISIBLE) + Input::get_singleton()->set_mouse_mode(mouse_mode); + } diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index 973fa23212..f18e212236 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/script_language.cpp b/core/script_language.cpp index b7a0f579f4..2ce3844ba3 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/script_language.h b/core/script_language.h index 9660f141c7..3138c88e8e 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -98,6 +98,7 @@ public: virtual bool has_script_signal(const StringName& p_signal) const=0; virtual void get_script_signal_list(List<MethodInfo> *r_signals) const=0; + virtual bool get_property_default_value(const StringName& p_property,Variant& r_value) const=0; virtual void update_exports() {} //editor tool @@ -165,6 +166,7 @@ public: virtual String make_function(const String& p_class,const String& p_name,const StringArray& p_args) const=0; 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 void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const=0; + virtual void add_global_constant(const StringName& p_variable,const Variant& p_value)=0; /* DEBUGGER FUNCTIONS */ diff --git a/core/self_list.h b/core/self_list.h index b414baaba6..bfdcfbfbc2 100644 --- a/core/self_list.h +++ b/core/self_list.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/set.h b/core/set.h index 91c4e3f9c4..808ffe5b36 100644 --- a/core/set.h +++ b/core/set.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/simple_type.h b/core/simple_type.h index 84e08bf0b4..1cc597146e 100644 --- a/core/simple_type.h +++ b/core/simple_type.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/sort.h b/core/sort.h index 65664d0ed8..bd61921c8a 100644 --- a/core/sort.h +++ b/core/sort.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/string_db.cpp b/core/string_db.cpp index b48d9f37d4..0e953cc326 100644 --- a/core/string_db.cpp +++ b/core/string_db.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/string_db.h b/core/string_db.h index 3b3249bf5e..f6c6ecefec 100644 --- a/core/string_db.h +++ b/core/string_db.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/translation.cpp b/core/translation.cpp index 8247cd1201..e4dad8d8de 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -626,7 +626,7 @@ bool TranslationServer::_load_translations(const String& p_from) { for(int i=0;i<tcount;i++) { - print_line( "Loading translation from " + r[i] ); + //print_line( "Loading translation from " + r[i] ); Ref<Translation> tr = ResourceLoader::load(r[i]); if (tr.is_valid()) add_translation(tr); @@ -670,10 +670,10 @@ void TranslationServer::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_locale","locale"),&TranslationServer::set_locale); ObjectTypeDB::bind_method(_MD("get_locale"),&TranslationServer::get_locale); - ObjectTypeDB::bind_method(_MD("translate"),&TranslationServer::translate); + ObjectTypeDB::bind_method(_MD("translate","message"),&TranslationServer::translate); - ObjectTypeDB::bind_method(_MD("add_translation"),&TranslationServer::add_translation); - ObjectTypeDB::bind_method(_MD("remove_translation"),&TranslationServer::remove_translation); + ObjectTypeDB::bind_method(_MD("add_translation","translation:Translation"),&TranslationServer::add_translation); + ObjectTypeDB::bind_method(_MD("remove_translation","translation:Translation"),&TranslationServer::remove_translation); ObjectTypeDB::bind_method(_MD("clear"),&TranslationServer::clear); diff --git a/core/translation.h b/core/translation.h index 54118cd3b5..5be6b8913a 100644 --- a/core/translation.h +++ b/core/translation.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/typedefs.h b/core/typedefs.h index 460b2e2110..1ca7a4f66d 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index ece9a02e24..ecbda1d3fd 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/undo_redo.h b/core/undo_redo.h index 141a413c2a..7f63ba9ed6 100644 --- a/core/undo_redo.h +++ b/core/undo_redo.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/ustring.cpp b/core/ustring.cpp index bf2494e9b5..ee750c39e5 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -1636,12 +1636,16 @@ int64_t String::to_int64() const { return integer*sign; } -int String::to_int(const char* p_str) { +int String::to_int(const char* p_str,int p_len) { int to=0; - while(p_str[to]!=0 && p_str[to]!='.') - to++; + if (p_len>=0) + to=p_len; + else { + while(p_str[to]!=0 && p_str[to]!='.') + to++; + } int integer=0; @@ -3154,6 +3158,21 @@ String String::c_escape() const { return escaped; } +String String::json_escape() const { + + String escaped=*this; + escaped=escaped.replace("\\","\\\\"); + escaped=escaped.replace("\b","\\b"); + escaped=escaped.replace("\f","\\f"); + escaped=escaped.replace("\n","\\n"); + escaped=escaped.replace("\r","\\r"); + escaped=escaped.replace("\t","\\t"); + escaped=escaped.replace("\v","\\v"); + escaped=escaped.replace("\"","\\\""); + + return escaped; +} + String String::xml_escape(bool p_escape_quotes) const { String str=*this; diff --git a/core/ustring.h b/core/ustring.h index 2f3c4bff4d..9276afa0f7 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -144,7 +144,7 @@ public: int to_int() const; int64_t to_int64() const; - static int to_int(const char* p_str); + static int to_int(const char* p_str, int p_len=-1); static double to_double(const char* p_str); static double to_double(const CharType* p_str, const CharType **r_end=NULL); static int64_t to_int(const CharType* p_str,int p_len=-1); @@ -211,6 +211,7 @@ public: String http_unescape() const; String c_escape() const; String c_unescape() const; + String json_escape() const; String world_wrap(int p_chars_per_line) const; String percent_encode() const; diff --git a/core/variant.cpp b/core/variant.cpp index c6a55b10e6..3bd8d80528 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -33,7 +33,7 @@ #include "scene/gui/control.h" #include "io/marshalls.h" #include "core_string_names.h" - +#include "variant_parser.h" String Variant::get_type_name(Variant::Type p_type) { @@ -706,6 +706,17 @@ bool Variant::operator==(const Variant& p_variant) const { } +bool Variant::operator!=(const Variant& p_variant) const { + + if (type!=p_variant.type) //evaluation of operator== needs to be more strict + return true; + bool v; + Variant r; + evaluate(OP_NOT_EQUAL,*this,p_variant,r,v); + return r; + +} + bool Variant::operator<(const Variant& p_variant) const { if (type!=p_variant.type) //if types differ, then order by type first return type<p_variant.type; @@ -2973,132 +2984,40 @@ void Variant::construct_from_string(const String& p_string,Variant& r_value,Obje } -String Variant::get_construct_string(ObjectDeConstruct p_obj_deconstruct,void *p_deconstruct_ud) const { - - switch( type ) { - - case NIL: return "null"; - case BOOL: return _data._bool ? "true" : "false"; - case INT: return String::num(_data._int); - case REAL: return String::num(_data._real); - case STRING: return "\""+reinterpret_cast<const String*>(_data._mem)->c_escape()+"\""; - case VECTOR2: return "Vector2("+operator Vector2()+")"; - case RECT2: return "Rect2("+operator Rect2()+")"; - case MATRIX32: return "Matrix32("+operator Matrix32()+")"; - case VECTOR3: return "Vector3("+operator Vector3()+")"; - case PLANE: return "Plane("+operator Plane()+")"; - //case QUAT: - case _AABB: return "AABB("+operator AABB()+")"; - case QUAT: return "Quat("+operator Quat()+")"; - case MATRIX3: return "Matrix3("+operator Matrix3()+")"; - case TRANSFORM: return "Transform("+operator Transform()+")"; - case NODE_PATH: return "@\""+String(operator NodePath()).c_escape()+"\""; - case INPUT_EVENT: return "InputEvent()"; - case COLOR: return "Color("+String::num( operator Color().r)+","+String::num( operator Color().g)+","+String::num( operator Color().b)+","+String::num( operator Color().a)+")" ; - case DICTIONARY: { - - const Dictionary &d =*reinterpret_cast<const Dictionary*>(_data._mem); - //const String *K=NULL; - String str="{"; - List<Variant> keys; - d.get_key_list(&keys); - - Vector<_VariantStrPair> pairs; - - for(List<Variant>::Element *E=keys.front();E;E=E->next()) { - - _VariantStrPair sp; - sp.key=E->get().get_construct_string(p_obj_deconstruct,p_deconstruct_ud); - sp.value=d[E->get()].get_construct_string(p_obj_deconstruct,p_deconstruct_ud); - pairs.push_back(sp); - } +String Variant::get_construct_string() const { - pairs.sort(); + String vars; + VariantWriter::write_to_string(*this,vars); - for(int i=0;i<pairs.size();i++) { - if (i>0) - str+=", "; - str+="("+pairs[i].key+":"+pairs[i].value+")"; - } - str+="}"; + return vars; - return str; - } break; - case VECTOR3_ARRAY: { - - DVector<Vector3> vec = operator DVector<Vector3>(); - String str="Vector3Array(["; - for(int i=0;i<vec.size();i++) { - - if (i>0) - str+=", "; - str+=Variant( vec[i] ).get_construct_string(); - } - return str+"])"; - } break; - case STRING_ARRAY: { +} - DVector<String> vec = operator DVector<String>(); - String str="StringArray(["; - for(int i=0;i<vec.size();i++) { +String Variant::get_call_error_text(Object* p_base, const StringName& p_method,const Variant** p_argptrs,int p_argcount,const Variant::CallError &ce) { - if (i>0) - str+=", "; - str=str+=Variant( vec[i] ).get_construct_string(); - } - return str+"])"; - } break; - case INT_ARRAY: { - DVector<int> vec = operator DVector<int>(); - String str="IntArray(["; - for(int i=0;i<vec.size();i++) { + String err_text; - if (i>0) - str+=", "; - str=str+itos(vec[i]); - } - return str+"])"; - } break; - case REAL_ARRAY: { - - DVector<real_t> vec = operator DVector<real_t>(); - String str="FloatArray(["; - for(int i=0;i<vec.size();i++) { - - if (i>0) - str+=", "; - str=str+rtos(vec[i]); - } - return str+"])"; - } break; - case ARRAY: { - - Array arr = operator Array(); - String str="["; - for (int i=0; i<arr.size(); i++) { - if (i) - str+=", "; - str += arr[i].get_construct_string(p_obj_deconstruct,p_deconstruct_ud); - }; - return str+"]"; - - } break; - case OBJECT: { + if (ce.error==Variant::CallError::CALL_ERROR_INVALID_ARGUMENT) { + int errorarg=ce.argument; + err_text="Cannot convert argument "+itos(errorarg+1)+" from "+Variant::get_type_name(p_argptrs[errorarg]->get_type())+" to "+Variant::get_type_name(ce.expected)+"."; + } else if (ce.error==Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) { + err_text="Expected "+itos(ce.argument)+" arguments."; + } else if (ce.error==Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) { + err_text="Expected "+itos(ce.argument)+" arguments."; + } else if (ce.error==Variant::CallError::CALL_ERROR_INVALID_METHOD) { + err_text="Method not found."; + } else if (ce.error==Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL) { + err_text="Instance is null"; + } else if (ce.error==Variant::CallError::CALL_OK){ + return "Call OK"; + } - if (_get_obj().obj) { - if (p_obj_deconstruct) { - return "Object(\""+p_obj_deconstruct(Variant(*this),p_deconstruct_ud).c_escape()+")"; - } else { - return _get_obj().obj->get_type()+".new()"; - } - } else - return "null"; + String class_name = p_base->get_type(); + Ref<Script> script = p_base->get_script(); + if (script.is_valid() && script->get_path().is_resource_file()) { - } break; - default: { - return "["+get_type_name(type)+"]"; - } + class_name+="("+script->get_path().get_file()+")"; } - + return "'"+class_name+"::"+String(p_method)+"': "+err_text; } diff --git a/core/variant.h b/core/variant.h index e75a2b1c92..b58c781bdd 100644 --- a/core/variant.h +++ b/core/variant.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -390,6 +390,9 @@ public: Variant call(const StringName& p_method,const Variant** p_args,int p_argcount,CallError &r_error); Variant call(const StringName& p_method,const Variant& p_arg1=Variant(),const Variant& p_arg2=Variant(),const Variant& p_arg3=Variant(),const Variant& p_arg4=Variant(),const Variant& p_arg5=Variant()); + + static String get_call_error_text(Object* p_base, const StringName& p_method,const Variant** p_argptrs,int p_argcount,const Variant::CallError &ce); + static Variant construct(const Variant::Type,const Variant** p_args,int p_argcount,CallError &r_error,bool p_strict=true); void get_method_list(List<MethodInfo> *p_list) const; @@ -411,6 +414,7 @@ public: //argsVariant call() bool operator==(const Variant& p_variant) const; + bool operator!=(const Variant& p_variant) const; bool operator<(const Variant& p_variant) const; uint32_t hash() const; @@ -425,7 +429,7 @@ public: typedef String (*ObjectDeConstruct)(const Variant& p_object,void *ud); typedef void (*ObjectConstruct)(const String& p_text,void *ud,Variant& r_value); - String get_construct_string(ObjectDeConstruct p_obj_deconstruct=NULL,void *p_deconstruct_ud=NULL) const; + String get_construct_string() const; static void construct_from_string(const String& p_string,Variant& r_value,ObjectConstruct p_obj_construct=NULL,void *p_construct_ud=NULL); void operator=(const Variant& p_variant); // only this is enough for all the other types diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 2ac876c8f4..90f868c866 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -272,6 +272,9 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM0R(String,get_file); VCALL_LOCALMEM0R(String,xml_escape); VCALL_LOCALMEM0R(String,xml_unescape); + VCALL_LOCALMEM0R(String,c_escape); + VCALL_LOCALMEM0R(String,c_unescape); + VCALL_LOCALMEM0R(String,json_escape); VCALL_LOCALMEM0R(String,percent_encode); VCALL_LOCALMEM0R(String,percent_decode); VCALL_LOCALMEM0R(String,is_valid_identifier); @@ -1286,6 +1289,9 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(STRING,STRING,String,get_file,varray()); ADDFUNC0(STRING,STRING,String,xml_escape,varray()); ADDFUNC0(STRING,STRING,String,xml_unescape,varray()); + ADDFUNC0(STRING,STRING,String,c_escape,varray()); + ADDFUNC0(STRING,STRING,String,c_unescape,varray()); + ADDFUNC0(STRING,STRING,String,json_escape,varray()); ADDFUNC0(STRING,STRING,String,percent_encode,varray()); ADDFUNC0(STRING,STRING,String,percent_decode,varray()); ADDFUNC0(STRING,BOOL,String,is_valid_identifier,varray()); diff --git a/core/variant_call_bind.h b/core/variant_call_bind.h index 613669203d..54954540b0 100644 --- a/core/variant_call_bind.h +++ b/core/variant_call_bind.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/variant_op.cpp b/core/variant_op.cpp index e33b79e63c..204a00e1d5 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -1003,7 +1003,7 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) return; } - *str = str->substr(0,idx-1)+chr+str->substr(idx+1,str->length()); + *str = str->substr(0,idx)+chr+str->substr(idx+1,str->length()); valid=true; return; @@ -1352,6 +1352,22 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) valid=true; v->set_hsv(v->get_h(),v->get_s(),p_value); return; + } else if (*str=="r8" ) { + valid=true; + v->g=float(p_value)/255.0; + return; + } else if (*str=="g8" ) { + valid=true; + v->g=float(p_value)/255.0; + return; + } else if (*str=="b8" ) { + valid=true; + v->b=float(p_value)/255.0; + return; + } else if (*str=="a8" ) {\ + valid=true; + v->a=float(p_value)/255.0; + return; } } else if (p_index.get_type()==Variant::INT) { @@ -2195,6 +2211,18 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const { } else if (*str=="v" ) { valid=true; return v->get_v(); + } else if (*str=="r8") { + valid=true; + return v->r*255.0; + } else if (*str=="g8" ) { + valid=true; + return v->g*255.0; + } else if (*str=="b8" ) { + valid=true; + return v->b*255.0; + } else if (*str=="a8" ) { + valid=true; + return v->a*255.0; } } else if (p_index.get_type()==Variant::INT) { @@ -2866,6 +2894,10 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back( PropertyInfo(Variant::REAL,"h")); p_list->push_back( PropertyInfo(Variant::REAL,"s")); p_list->push_back( PropertyInfo(Variant::REAL,"v")); + p_list->push_back( PropertyInfo(Variant::INT,"r8")); + p_list->push_back( PropertyInfo(Variant::INT,"g8")); + p_list->push_back( PropertyInfo(Variant::INT,"b8")); + p_list->push_back( PropertyInfo(Variant::INT,"a8")); } break; case IMAGE: { } break; diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 239b129388..3efa87de80 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -19,6 +19,20 @@ bool VariantParser::StreamFile::is_eof() const { } +CharType VariantParser::StreamString::get_char() { + + if (pos>=s.length()) + return 0; + else + return s[pos++]; +} + +bool VariantParser::StreamString::is_utf8() const { + return false; +} +bool VariantParser::StreamString::is_eof() const { + return pos>s.length(); +} ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -35,8 +49,10 @@ const char * VariantParser::tk_name[TK_MAX] = { "identifier", "string", "number", + "color", "':'", "','", + "'.'", "'='", "EOF", "ERROR" @@ -106,16 +122,58 @@ Error VariantParser::get_token(Stream *p_stream, Token& r_token, int &line, Stri r_token.type=TK_COLON; return OK; }; + case ';': { + + while(true) { + CharType ch=p_stream->get_char(); + if (p_stream->is_eof()) { + r_token.type=TK_EOF; + return OK; + } + if (ch=='\n') + break; + } + + break; + }; case ',': { r_token.type=TK_COMMA; return OK; }; + case '.': { + + r_token.type=TK_PERIOD; + return OK; + }; case '=': { r_token.type=TK_EQUAL; return OK; }; + case '#': { + + + String color_str="#"; + while(true) { + CharType ch=p_stream->get_char(); + if (p_stream->is_eof()) { + r_token.type=TK_EOF; + return OK; + } else if ( (ch>='0' && ch<='9') || (ch>='a' && ch<='f') || (ch>='A' && ch<='F') ) { + color_str+=String::chr(ch); + + } else { + p_stream->saved=ch; + break; + } + } + + r_token.value=Color::html(color_str); + r_token.type=TK_COLOR; + return OK; + + }; case '"': { @@ -336,6 +394,42 @@ Error VariantParser::get_token(Stream *p_stream, Token& r_token, int &line, Stri return ERR_PARSE_ERROR; } +Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String>& strings, int &line, String &r_err_str) { + + Token token; + get_token(p_stream,token,line,r_err_str); + if (token.type!=TK_PARENTHESIS_OPEN) { + r_err_str="Expected '(' in old-style engine.cfg construct"; + return ERR_PARSE_ERROR; + } + + + String accum; + + while(true) { + + CharType c=p_stream->get_char(); + + if (p_stream->is_eof()) { + r_err_str="Unexpected EOF while parsing old-style engine.cfg construct"; + return ERR_PARSE_ERROR; + } + + if (c==',') { + strings.push_back(accum.strip_edges()); + accum=String(); + } else if (c==')') { + strings.push_back(accum.strip_edges()); + return OK; + } else if (c=='\n') { + line++; + } + + } + + return OK; +} + template<class T> Error VariantParser::_parse_construct(Stream *p_stream,Vector<T>& r_construct,int &line,String &r_err_str) { @@ -354,7 +448,7 @@ Error VariantParser::_parse_construct(Stream *p_stream,Vector<T>& r_construct,in if (!first) { get_token(p_stream,token,line,r_err_str); if (token.type==TK_COMMA) { - //do none + //do none } else if (token.type==TK_PARENTHESIS_CLOSE) { break; } else { @@ -364,7 +458,10 @@ Error VariantParser::_parse_construct(Stream *p_stream,Vector<T>& r_construct,in } } get_token(p_stream,token,line,r_err_str); - if (token.type!=TK_NUMBER) { + + if (first && token.type==TK_PARENTHESIS_CLOSE) { + break; + } else if (token.type!=TK_NUMBER) { r_err_str="Expected float in constructor"; return ERR_PARSE_ERROR; } @@ -984,8 +1081,24 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in ie.joy_motion.axis = token.value; get_token(p_stream,token,line,r_err_str); + + if (token.type!=TK_COMMA) { + r_err_str="Expected ',' after axis index"; + return ERR_PARSE_ERROR; + } + + get_token(p_stream,token,line,r_err_str); + if (token.type!=TK_NUMBER) { + r_err_str="Expected axis sign"; + return ERR_PARSE_ERROR; + } + + ie.joy_motion.axis_value = token.value; + + get_token(p_stream,token,line,r_err_str); + if (token.type!=TK_PARENTHESIS_CLOSE) { - r_err_str="Expected ')'"; + r_err_str="Expected ')' for jaxis"; return ERR_PARSE_ERROR; } @@ -1079,7 +1192,7 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in get_token(p_stream,token,line,r_err_str); if (token.type==TK_COMMA) { //do none - } else if (token.type!=TK_PARENTHESIS_CLOSE) { + } else if (token.type==TK_PARENTHESIS_CLOSE) { break; } else { r_err_str="Expected ',' or ')'"; @@ -1088,11 +1201,13 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in } } get_token(p_stream,token,line,r_err_str); + if (token.type!=TK_STRING) { - r_err_str="Expected string"; + r_err_str="Expected string"; return ERR_PARSE_ERROR; } + first=false; cs.push_back(token.value); } @@ -1174,6 +1289,112 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in value=arr; return OK; + } else if (id=="key") { // compatibility with engine.cfg + + Vector<String> params; + Error err = _parse_enginecfg(p_stream,params,line,r_err_str); + if (err) + return err; + ERR_FAIL_COND_V(params.size()!=1 && params.size()!=2,ERR_PARSE_ERROR); + + int scode=0; + + if (params[0].is_numeric()) { + scode=params[0].to_int(); + if (scode < 10) { + scode=KEY_0+scode; + } + } else + scode=find_keycode(params[0]); + + InputEvent ie; + ie.type=InputEvent::KEY; + ie.key.scancode=scode; + + if (params.size()==2) { + String mods=params[1]; + if (mods.findn("C")!=-1) + ie.key.mod.control=true; + if (mods.findn("A")!=-1) + ie.key.mod.alt=true; + if (mods.findn("S")!=-1) + ie.key.mod.shift=true; + if (mods.findn("M")!=-1) + ie.key.mod.meta=true; + } + value=ie; + return OK; + + } else if (id=="mbutton") { // compatibility with engine.cfg + + Vector<String> params; + Error err = _parse_enginecfg(p_stream,params,line,r_err_str); + if (err) + return err; + ERR_FAIL_COND_V(params.size()!=2,ERR_PARSE_ERROR); + + InputEvent ie; + ie.type=InputEvent::MOUSE_BUTTON; + ie.device=params[0].to_int(); + ie.mouse_button.button_index=params[1].to_int(); + + value=ie; + return OK; + } else if (id=="jbutton") { // compatibility with engine.cfg + + Vector<String> params; + Error err = _parse_enginecfg(p_stream,params,line,r_err_str); + if (err) + return err; + ERR_FAIL_COND_V(params.size()!=2,ERR_PARSE_ERROR); + InputEvent ie; + ie.type=InputEvent::JOYSTICK_BUTTON; + ie.device=params[0].to_int(); + ie.joy_button.button_index=params[1].to_int(); + + value=ie; + + return OK; + } else if (id=="jaxis") { // compatibility with engine.cfg + + Vector<String> params; + Error err = _parse_enginecfg(p_stream,params,line,r_err_str); + if (err) + return err; + ERR_FAIL_COND_V(params.size()!=2,ERR_PARSE_ERROR); + + InputEvent ie; + ie.type=InputEvent::JOYSTICK_MOTION; + ie.device=params[0].to_int(); + int axis=params[1].to_int(); + ie.joy_motion.axis=axis>>1; + ie.joy_motion.axis_value=axis&1?1:-1; + + value= ie; + + return OK; + } else if (id=="img") { // compatibility with engine.cfg + + Token token; + get_token(p_stream,token,line,r_err_str); + if (token.type!=TK_PARENTHESIS_OPEN) { + r_err_str="Expected '(' in old-style engine.cfg construct"; + return ERR_PARSE_ERROR; + } + + while(true) { + CharType c = p_stream->get_char(); + if (p_stream->is_eof()) { + r_err_str="Unexpected EOF in old style engine.cfg img()"; + return ERR_PARSE_ERROR; + } + if (c==')') + break; + } + + value=Image(); + + return OK; } else { r_err_str="Unexpected identifier: '"+id+"'."; @@ -1225,6 +1446,10 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in value=token.value; return OK; + } else if (token.type==TK_COLOR) { + + value=token.value; + return OK; } else { r_err_str="Expected value, got "+String(tk_name[token.type])+"."; return ERR_PARSE_ERROR; @@ -1360,7 +1585,7 @@ Error VariantParser::_parse_dictionary(Dictionary &object, Stream *p_stream, int } -Error VariantParser::_parse_tag(Token& token, Stream *p_stream, int &line, String &r_err_str, Tag& r_tag, ResourceParser *p_res_parser) { +Error VariantParser::_parse_tag(Token& token, Stream *p_stream, int &line, String &r_err_str, Tag& r_tag, ResourceParser *p_res_parser,bool p_simple_tag) { r_tag.fields.clear(); @@ -1370,6 +1595,29 @@ Error VariantParser::_parse_tag(Token& token, Stream *p_stream, int &line, Strin } + if (p_simple_tag) { + + r_tag.name=""; + r_tag.fields.clear(); + + while(true) { + + CharType c = p_stream->get_char(); + if (p_stream->is_eof()) { + r_err_str="Unexpected EOF while parsing simple tag"; + return ERR_PARSE_ERROR; + } + if (c==']') + break; + r_tag.name+=String::chr(c); + } + + r_tag.name = r_tag.name.strip_edges(); + + return OK; + + } + get_token(p_stream,token,line,r_err_str); @@ -1379,6 +1627,7 @@ Error VariantParser::_parse_tag(Token& token, Stream *p_stream, int &line, Strin } r_tag.name=token.value; + bool parsing_tag=true; while(true) { @@ -1391,6 +1640,16 @@ Error VariantParser::_parse_tag(Token& token, Stream *p_stream, int &line, Strin if (token.type==TK_BRACKET_CLOSE) break; + if (parsing_tag && token.type==TK_PERIOD) { + r_tag.name+="."; //support tags such as [someprop.Anroid] for specific platforms + get_token(p_stream,token,line,r_err_str); + } else if (parsing_tag && token.type==TK_COLON) { + r_tag.name+=":"; //support tags such as [someprop.Anroid] for specific platforms + get_token(p_stream,token,line,r_err_str); + } else { + parsing_tag=false; + } + if (token.type!=TK_IDENTIFIER) { r_err_str="Expected Identifier"; return ERR_PARSE_ERROR; @@ -1398,10 +1657,13 @@ Error VariantParser::_parse_tag(Token& token, Stream *p_stream, int &line, Strin String id=token.value; + if (parsing_tag) { + r_tag.name+=id; + continue; + } get_token(p_stream,token,line,r_err_str); if (token.type!=TK_EQUAL) { - r_err_str="Expected '='"; return ERR_PARSE_ERROR; } @@ -1420,7 +1682,7 @@ Error VariantParser::_parse_tag(Token& token, Stream *p_stream, int &line, Strin } -Error VariantParser::parse_tag(Stream *p_stream, int &line, String &r_err_str, Tag& r_tag, ResourceParser *p_res_parser) { +Error VariantParser::parse_tag(Stream *p_stream, int &line, String &r_err_str, Tag& r_tag, ResourceParser *p_res_parser, bool p_simple_tag) { Token token; get_token(p_stream,token,line,r_err_str); @@ -1434,14 +1696,15 @@ Error VariantParser::parse_tag(Stream *p_stream, int &line, String &r_err_str, T return ERR_PARSE_ERROR; } - return _parse_tag(token,p_stream,line,r_err_str,r_tag,p_res_parser); + return _parse_tag(token,p_stream,line,r_err_str,r_tag,p_res_parser,p_simple_tag); } -Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r_err_str, Tag& r_tag, String &r_assign, Variant &r_value, ResourceParser *p_res_parser) { +Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r_err_str, Tag& r_tag, String &r_assign, Variant &r_value, ResourceParser *p_res_parser, bool p_simple_tag) { //assign.. + r_assign=""; String what; while(true) { @@ -1459,11 +1722,23 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r if (p_stream->is_eof()) return ERR_FILE_EOF; + if (c==';') { //comment + while(true) { + CharType ch=p_stream->get_char(); + if (p_stream->is_eof()) { + return ERR_FILE_EOF; + } + if (ch=='\n') + break; + } + continue; + } + if (c=='[' && what.length()==0) { //it's a tag! p_stream->saved='['; //go back one - Error err = parse_tag(p_stream,line,r_err_str,r_tag,p_res_parser); + Error err = parse_tag(p_stream,line,r_err_str,r_tag,p_res_parser,p_simple_tag); return err; } @@ -1506,3 +1781,431 @@ Error VariantParser::parse(Stream *p_stream, Variant& r_ret, String &r_err_str, } + +////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + + +Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud,EncodeResourceFunc p_encode_res_func,void* p_encode_res_ud) { + + switch( p_variant.get_type() ) { + + case Variant::NIL: { + p_store_string_func(p_store_string_ud,"null"); + } break; + case Variant::BOOL: { + + p_store_string_func(p_store_string_ud,p_variant.operator bool() ? "true":"false" ); + } break; + case Variant::INT: { + + p_store_string_func(p_store_string_ud, itos(p_variant.operator int()) ); + } break; + case Variant::REAL: { + + String s = rtoss(p_variant.operator real_t()); + if (s.find(".")==-1 && s.find("e")==-1) + s+=".0"; + p_store_string_func(p_store_string_ud, s ); + } break; + case Variant::STRING: { + + String str=p_variant; + + str="\""+str.c_escape()+"\""; + p_store_string_func(p_store_string_ud, str ); + } break; + case Variant::VECTOR2: { + + Vector2 v = p_variant; + p_store_string_func(p_store_string_ud,"Vector2( "+rtoss(v.x) +", "+rtoss(v.y)+" )" ); + } break; + case Variant::RECT2: { + + Rect2 aabb = p_variant; + p_store_string_func(p_store_string_ud,"Rect2( "+rtoss(aabb.pos.x) +", "+rtoss(aabb.pos.y) +", "+rtoss(aabb.size.x) +", "+rtoss(aabb.size.y)+" )" ); + + } break; + case Variant::VECTOR3: { + + Vector3 v = p_variant; + p_store_string_func(p_store_string_ud,"Vector3( "+rtoss(v.x) +", "+rtoss(v.y)+", "+rtoss(v.z)+" )"); + } break; + case Variant::PLANE: { + + Plane p = p_variant; + p_store_string_func(p_store_string_ud,"Plane( "+rtoss(p.normal.x) +", "+rtoss(p.normal.y)+", "+rtoss(p.normal.z)+", "+rtoss(p.d)+" )" ); + + } break; + case Variant::_AABB: { + + AABB aabb = p_variant; + p_store_string_func(p_store_string_ud,"AABB( "+rtoss(aabb.pos.x) +", "+rtoss(aabb.pos.y) +", "+rtoss(aabb.pos.z) +", "+rtoss(aabb.size.x) +", "+rtoss(aabb.size.y) +", "+rtoss(aabb.size.z)+" )" ); + + } break; + case Variant::QUAT: { + + Quat quat = p_variant; + p_store_string_func(p_store_string_ud,"Quat( "+rtoss(quat.x)+", "+rtoss(quat.y)+", "+rtoss(quat.z)+", "+rtoss(quat.w)+" )"); + + } break; + case Variant::MATRIX32: { + + String s="Matrix32( "; + Matrix32 m3 = p_variant; + for (int i=0;i<3;i++) { + for (int j=0;j<2;j++) { + + if (i!=0 || j!=0) + s+=", "; + s+=rtoss( m3.elements[i][j] ); + } + } + + p_store_string_func(p_store_string_ud,s+" )"); + + } break; + case Variant::MATRIX3: { + + String s="Matrix3( "; + Matrix3 m3 = p_variant; + for (int i=0;i<3;i++) { + for (int j=0;j<3;j++) { + + if (i!=0 || j!=0) + s+=", "; + s+=rtoss( m3.elements[i][j] ); + } + } + + p_store_string_func(p_store_string_ud,s+" )"); + + } break; + case Variant::TRANSFORM: { + + String s="Transform( "; + Transform t = p_variant; + Matrix3 &m3 = t.basis; + for (int i=0;i<3;i++) { + for (int j=0;j<3;j++) { + + if (i!=0 || j!=0) + s+=", "; + s+=rtoss( m3.elements[i][j] ); + } + } + + s=s+", "+rtoss(t.origin.x) +", "+rtoss(t.origin.y)+", "+rtoss(t.origin.z); + + p_store_string_func(p_store_string_ud,s+" )"); + } break; + + // misc types + case Variant::COLOR: { + + Color c = p_variant; + p_store_string_func(p_store_string_ud,"Color( "+rtoss(c.r) +", "+rtoss(c.g)+", "+rtoss(c.b)+", "+rtoss(c.a)+" )"); + + } break; + case Variant::IMAGE: { + + + Image img=p_variant; + + if (img.empty()) { + p_store_string_func(p_store_string_ud,"Image()"); + break; + } + + String imgstr="Image( "; + imgstr+=itos(img.get_width()); + imgstr+=", "+itos(img.get_height()); + imgstr+=", "+itos(img.get_mipmaps()); + imgstr+=", "; + + switch(img.get_format()) { + + case Image::FORMAT_GRAYSCALE: imgstr+="GRAYSCALE"; break; + case Image::FORMAT_INTENSITY: imgstr+="INTENSITY"; break; + case Image::FORMAT_GRAYSCALE_ALPHA: imgstr+="GRAYSCALE_ALPHA"; break; + case Image::FORMAT_RGB: imgstr+="RGB"; break; + case Image::FORMAT_RGBA: imgstr+="RGBA"; break; + case Image::FORMAT_INDEXED : imgstr+="INDEXED"; break; + case Image::FORMAT_INDEXED_ALPHA: imgstr+="INDEXED_ALPHA"; break; + case Image::FORMAT_BC1: imgstr+="BC1"; break; + case Image::FORMAT_BC2: imgstr+="BC2"; break; + case Image::FORMAT_BC3: imgstr+="BC3"; break; + case Image::FORMAT_BC4: imgstr+="BC4"; break; + case Image::FORMAT_BC5: imgstr+="BC5"; break; + case Image::FORMAT_PVRTC2: imgstr+="PVRTC2"; break; + case Image::FORMAT_PVRTC2_ALPHA: imgstr+="PVRTC2_ALPHA"; break; + case Image::FORMAT_PVRTC4: imgstr+="PVRTC4"; break; + case Image::FORMAT_PVRTC4_ALPHA: imgstr+="PVRTC4_ALPHA"; break; + case Image::FORMAT_ETC: imgstr+="ETC"; break; + case Image::FORMAT_ATC: imgstr+="ATC"; break; + case Image::FORMAT_ATC_ALPHA_EXPLICIT: imgstr+="ATC_ALPHA_EXPLICIT"; break; + case Image::FORMAT_ATC_ALPHA_INTERPOLATED: imgstr+="ATC_ALPHA_INTERPOLATED"; break; + case Image::FORMAT_CUSTOM: imgstr+="CUSTOM"; break; + default: {} + } + + + String s; + + DVector<uint8_t> data = img.get_data(); + int len = data.size(); + DVector<uint8_t>::Read r = data.read(); + const uint8_t *ptr=r.ptr();; + for (int i=0;i<len;i++) { + + if (i>0) + s+=", "; + s+=itos(ptr[i]); + } + + imgstr+=", "; + p_store_string_func(p_store_string_ud,imgstr); + p_store_string_func(p_store_string_ud,s); + p_store_string_func(p_store_string_ud," )"); + } break; + case Variant::NODE_PATH: { + + String str=p_variant; + + str="NodePath(\""+str.c_escape()+"\")"; + p_store_string_func(p_store_string_ud,str); + + } break; + + case Variant::OBJECT: { + + RES res = p_variant; + if (res.is_null()) { + p_store_string_func(p_store_string_ud,"null"); + break; // don't save it + } + + String res_text; + + if (p_encode_res_func) { + + res_text=p_encode_res_func(p_encode_res_ud,res); + } + + if (res_text==String() && res->get_path().is_resource_file()) { + + //external resource + String path=res->get_path(); + res_text="Resource( \""+path+"\")"; + } + + if (res_text==String()) + res_text="null"; + + p_store_string_func(p_store_string_ud,res_text); + + } break; + case Variant::INPUT_EVENT: { + + p_store_string_func(p_store_string_ud,"InputEvent()"); //will be added later + } break; + case Variant::DICTIONARY: { + + Dictionary dict = p_variant; + + List<Variant> keys; + dict.get_key_list(&keys); + keys.sort(); + + p_store_string_func(p_store_string_ud,"{ "); + for(List<Variant>::Element *E=keys.front();E;E=E->next()) { + + //if (!_check_type(dict[E->get()])) + // continue; + write(E->get(),p_store_string_func,p_store_string_ud,p_encode_res_func,p_encode_res_ud); + p_store_string_func(p_store_string_ud,":"); + write(dict[E->get()],p_store_string_func,p_store_string_ud,p_encode_res_func,p_encode_res_ud); + if (E->next()) + p_store_string_func(p_store_string_ud,", "); + } + + + p_store_string_func(p_store_string_ud," }"); + + + } break; + case Variant::ARRAY: { + + p_store_string_func(p_store_string_ud,"[ "); + Array array = p_variant; + int len=array.size(); + for (int i=0;i<len;i++) { + + if (i>0) + p_store_string_func(p_store_string_ud,", "); + write(array[i],p_store_string_func,p_store_string_ud,p_encode_res_func,p_encode_res_ud); + + } + p_store_string_func(p_store_string_ud," ]"); + + } break; + + case Variant::RAW_ARRAY: { + + p_store_string_func(p_store_string_ud,"ByteArray( "); + String s; + DVector<uint8_t> data = p_variant; + int len = data.size(); + DVector<uint8_t>::Read r = data.read(); + const uint8_t *ptr=r.ptr();; + for (int i=0;i<len;i++) { + + if (i>0) + p_store_string_func(p_store_string_ud,", "); + + p_store_string_func(p_store_string_ud,itos(ptr[i])); + + } + + p_store_string_func(p_store_string_ud," )"); + + } break; + case Variant::INT_ARRAY: { + + p_store_string_func(p_store_string_ud,"IntArray( "); + DVector<int> data = p_variant; + int len = data.size(); + DVector<int>::Read r = data.read(); + const int *ptr=r.ptr();; + + for (int i=0;i<len;i++) { + + if (i>0) + p_store_string_func(p_store_string_ud,", "); + + p_store_string_func(p_store_string_ud,itos(ptr[i])); + } + + + p_store_string_func(p_store_string_ud," )"); + + } break; + case Variant::REAL_ARRAY: { + + p_store_string_func(p_store_string_ud,"FloatArray( "); + DVector<real_t> data = p_variant; + int len = data.size(); + DVector<real_t>::Read r = data.read(); + const real_t *ptr=r.ptr();; + + for (int i=0;i<len;i++) { + + if (i>0) + p_store_string_func(p_store_string_ud,", "); + p_store_string_func(p_store_string_ud,rtoss(ptr[i])); + } + + p_store_string_func(p_store_string_ud," )"); + + } break; + case Variant::STRING_ARRAY: { + + p_store_string_func(p_store_string_ud,"StringArray( "); + DVector<String> data = p_variant; + int len = data.size(); + DVector<String>::Read r = data.read(); + const String *ptr=r.ptr();; + String s; + //write_string("\n"); + + + + for (int i=0;i<len;i++) { + + if (i>0) + p_store_string_func(p_store_string_ud,", "); + String str=ptr[i]; + p_store_string_func(p_store_string_ud,"\""+str.c_escape()+"\""); + } + + p_store_string_func(p_store_string_ud," )"); + + } break; + case Variant::VECTOR2_ARRAY: { + + p_store_string_func(p_store_string_ud,"Vector2Array( "); + DVector<Vector2> data = p_variant; + int len = data.size(); + DVector<Vector2>::Read r = data.read(); + const Vector2 *ptr=r.ptr();; + + for (int i=0;i<len;i++) { + + if (i>0) + p_store_string_func(p_store_string_ud,", "); + p_store_string_func(p_store_string_ud,rtoss(ptr[i].x)+", "+rtoss(ptr[i].y) ); + } + + p_store_string_func(p_store_string_ud," )"); + + } break; + case Variant::VECTOR3_ARRAY: { + + p_store_string_func(p_store_string_ud,"Vector3Array( "); + DVector<Vector3> data = p_variant; + int len = data.size(); + DVector<Vector3>::Read r = data.read(); + const Vector3 *ptr=r.ptr();; + + for (int i=0;i<len;i++) { + + if (i>0) + p_store_string_func(p_store_string_ud,", "); + p_store_string_func(p_store_string_ud,rtoss(ptr[i].x)+", "+rtoss(ptr[i].y)+", "+rtoss(ptr[i].z) ); + } + + p_store_string_func(p_store_string_ud," )"); + + } break; + case Variant::COLOR_ARRAY: { + + p_store_string_func(p_store_string_ud,"ColorArray( "); + + DVector<Color> data = p_variant; + int len = data.size(); + DVector<Color>::Read r = data.read(); + const Color *ptr=r.ptr();; + + for (int i=0;i<len;i++) { + + if (i>0) + p_store_string_func(p_store_string_ud,", "); + + p_store_string_func(p_store_string_ud,rtoss(ptr[i].r)+", "+rtoss(ptr[i].g)+", "+rtoss(ptr[i].b)+", "+rtoss(ptr[i].a) ); + + } + p_store_string_func(p_store_string_ud," )"); + + } break; + default: {} + + } + + return OK; +} + +static Error _write_to_str(void *ud,const String& p_string) { + + String *str=(String*)ud; + (*str)+=p_string; + return OK; +} + +Error VariantWriter::write_to_string(const Variant& p_variant, String& r_string, EncodeResourceFunc p_encode_res_func, void *p_encode_res_ud) { + + r_string=String(); + + return write(p_variant,_write_to_str,&r_string,p_encode_res_func,p_encode_res_ud); + +} diff --git a/core/variant_parser.h b/core/variant_parser.h index e1d25f7512..00f6910b29 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -32,6 +32,19 @@ public: }; + struct StreamString : public Stream { + + String s; + int pos; + + virtual CharType get_char(); + virtual bool is_utf8() const; + virtual bool is_eof() const; + + StreamString() { pos=0; } + + }; + typedef Error (*ParseResourceFunc)(void* p_self, Stream* p_stream,Ref<Resource>& r_res,int &line,String &r_err_str); struct ResourceParser { @@ -53,8 +66,10 @@ public: TK_IDENTIFIER, TK_STRING, TK_NUMBER, + TK_COLOR, TK_COLON, TK_COMMA, + TK_PERIOD, TK_EQUAL, TK_EOF, TK_ERROR, @@ -86,18 +101,39 @@ private: template<class T> static Error _parse_construct(Stream *p_stream, Vector<T>& r_construct, int &line, String &r_err_str); + static Error _parse_enginecfg(Stream *p_stream, Vector<String>& strings, int &line, String &r_err_str); static Error _parse_dictionary(Dictionary &object, Stream *p_stream, int &line, String &r_err_str,ResourceParser *p_res_parser=NULL); static Error _parse_array(Array &array, Stream *p_stream, int &line, String &r_err_str,ResourceParser *p_res_parser=NULL); - static Error _parse_tag(Token& token,Stream *p_stream, int &line, String &r_err_str,Tag& r_tag,ResourceParser *p_res_parser=NULL); + static Error _parse_tag(Token& token,Stream *p_stream, int &line, String &r_err_str,Tag& r_tag,ResourceParser *p_res_parser=NULL,bool p_simple_tag=false); public: - static Error parse_tag(Stream *p_stream, int &line, String &r_err_str,Tag& r_tag,ResourceParser *p_res_parser=NULL); - static Error parse_tag_assign_eof(Stream *p_stream, int &line, String &r_err_str, Tag& r_tag, String &r_assign, Variant &r_value,ResourceParser *p_res_parser=NULL); + static Error parse_tag(Stream *p_stream, int &line, String &r_err_str,Tag& r_tag,ResourceParser *p_res_parser=NULL,bool p_simple_tag=false); + static Error parse_tag_assign_eof(Stream *p_stream, int &line, String &r_err_str, Tag& r_tag, String &r_assign, Variant &r_value,ResourceParser *p_res_parser=NULL,bool p_simple_tag=false); static Error parse_value(Token& token,Variant &value, Stream *p_stream, int &line, String &r_err_str,ResourceParser *p_res_parser=NULL); static Error get_token(Stream *p_stream,Token& r_token,int &line,String &r_err_str); static Error parse(Stream *p_stream, Variant &r_ret, String &r_err_str, int &r_err_line,ResourceParser *p_res_parser=NULL); }; + + + +class VariantWriter { +public: + + typedef Error (*StoreStringFunc)(void *ud,const String& p_string); + typedef String (*EncodeResourceFunc)(void *ud,const RES& p_resource); + + static Error write(const Variant& p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud,EncodeResourceFunc p_encode_res_func,void* p_encode_res_ud); + static Error write_to_string(const Variant& p_variant, String& r_string, EncodeResourceFunc p_encode_res_func=NULL,void* p_encode_res_ud=NULL); + + +}; + + + + + + #endif // VARIANT_PARSER_H diff --git a/core/vector.h b/core/vector.h index 78dff5eadb..641721f401 100644 --- a/core/vector.h +++ b/core/vector.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/vmap.cpp b/core/vmap.cpp index 32481eb9eb..e94198257a 100644 --- a/core/vmap.cpp +++ b/core/vmap.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/vmap.h b/core/vmap.h index 5ff8f73978..6880abf260 100644 --- a/core/vmap.h +++ b/core/vmap.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/vset.cpp b/core/vset.cpp index c849bf3367..cefafeb073 100644 --- a/core/vset.cpp +++ b/core/vset.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ diff --git a/core/vset.h b/core/vset.h index e1e02ab435..cafcb0bb2f 100644 --- a/core/vset.h +++ b/core/vset.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ |