diff options
-rw-r--r-- | core/variant.h | 1 | ||||
-rw-r--r-- | core/variant_call.cpp | 70 | ||||
-rw-r--r-- | doc/classes/SpriteFrames.xml | 18 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 3 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | modules/visual_script/visual_script_func_nodes.cpp | 4 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 1 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_chorus.cpp | 3 | ||||
-rw-r--r-- | servers/audio/effects/audio_effect_limiter.cpp | 2 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_wrap_mt.cpp | 3 |
10 files changed, 74 insertions, 33 deletions
diff --git a/core/variant.h b/core/variant.h index 5ea540a63f..e0d0bf05c8 100644 --- a/core/variant.h +++ b/core/variant.h @@ -368,6 +368,7 @@ public: static Vector<Variant> get_method_default_arguments(Variant::Type p_type, const StringName &p_method); static Variant::Type get_method_return_type(Variant::Type p_type, const StringName &p_method, bool *r_has_return = NULL); static Vector<StringName> get_method_argument_names(Variant::Type p_type, const StringName &p_method); + static bool is_method_const(Variant::Type p_type, const StringName &p_method); void set_named(const StringName &p_index, const Variant &p_value, bool *r_valid = NULL); Variant get_named(const StringName &p_index, bool *r_valid = NULL) const; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 7205280938..d141621fbb 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -53,6 +53,7 @@ struct _VariantCall { Vector<StringName> arg_names; Variant::Type return_type; + bool _const; #ifdef DEBUG_ENABLED bool returns; #endif @@ -145,11 +146,12 @@ struct _VariantCall { #endif } - static void addfunc(Variant::Type p_type, Variant::Type p_return, const StringName &p_name, VariantFunc p_func, const Vector<Variant> &p_defaultarg, const Arg &p_argtype1 = Arg(), const Arg &p_argtype2 = Arg(), const Arg &p_argtype3 = Arg(), const Arg &p_argtype4 = Arg(), const Arg &p_argtype5 = Arg()) { + static void addfunc(bool p_const, Variant::Type p_type, Variant::Type p_return, const StringName &p_name, VariantFunc p_func, const Vector<Variant> &p_defaultarg, const Arg &p_argtype1 = Arg(), const Arg &p_argtype2 = Arg(), const Arg &p_argtype3 = Arg(), const Arg &p_argtype4 = Arg(), const Arg &p_argtype5 = Arg()) { FuncData funcdata; funcdata.func = p_func; funcdata.default_args = p_defaultarg; + funcdata._const = p_const; #ifdef DEBUG_ENABLED funcdata.return_type = p_return; funcdata.returns = p_return != Variant::NIL; @@ -1201,6 +1203,17 @@ Vector<Variant::Type> Variant::get_method_argument_types(Variant::Type p_type, c return E->get().arg_types; } +bool Variant::is_method_const(Variant::Type p_type, const StringName &p_method) { + + const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type]; + + const Map<StringName, _VariantCall::FuncData>::Element *E = fd.functions.find(p_method); + if (!E) + return false; + + return E->get()._const; +} + Vector<StringName> Variant::get_method_argument_names(Variant::Type p_type, const StringName &p_method) { const _VariantCall::TypeFunc &fd = _VariantCall::type_funcs[p_type]; @@ -1248,6 +1261,10 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const { MethodInfo mi; mi.name = E->key(); + if (fd._const) { + mi.flags |= METHOD_FLAG_CONST; + } + for (int i = 0; i < fd.arg_types.size(); i++) { PropertyInfo pi; @@ -1360,15 +1377,26 @@ void register_variant_methods() { _VariantCall::constant_data = memnew_arr(_VariantCall::ConstantData, Variant::VARIANT_MAX); #define ADDFUNC0(m_vtype, m_ret, m_class, m_method, m_defarg) \ - _VariantCall::addfunc(Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); #define ADDFUNC1(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \ - _VariantCall::addfunc(Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); #define ADDFUNC2(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \ - _VariantCall::addfunc(Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); #define ADDFUNC3(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \ - _VariantCall::addfunc(Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); #define ADDFUNC4(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \ - _VariantCall::addfunc(Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); + _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); + +#define ADDFUNC0NC(m_vtype, m_ret, m_class, m_method, m_defarg) \ + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg); +#define ADDFUNC1NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \ + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1))); +#define ADDFUNC2NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \ + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2))); +#define ADDFUNC3NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \ + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3))); +#define ADDFUNC4NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \ + _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4))); /* STRING */ ADDFUNC1(STRING, INT, String, casecmp_to, STRING, "to", varray()); @@ -1545,7 +1573,7 @@ void register_variant_methods() { ADDFUNC0(DICTIONARY, INT, Dictionary, size, varray()); ADDFUNC0(DICTIONARY, BOOL, Dictionary, empty, varray()); - ADDFUNC0(DICTIONARY, NIL, Dictionary, clear, varray()); + ADDFUNC0NC(DICTIONARY, NIL, Dictionary, clear, varray()); ADDFUNC1(DICTIONARY, BOOL, Dictionary, has, NIL, "key", varray()); ADDFUNC1(DICTIONARY, BOOL, Dictionary, has_all, ARRAY, "keys", varray()); ADDFUNC1(DICTIONARY, NIL, Dictionary, erase, NIL, "key", varray()); @@ -1555,15 +1583,15 @@ void register_variant_methods() { ADDFUNC0(ARRAY, INT, Array, size, varray()); ADDFUNC0(ARRAY, BOOL, Array, empty, varray()); - ADDFUNC0(ARRAY, NIL, Array, clear, varray()); + ADDFUNC0NC(ARRAY, NIL, Array, clear, varray()); ADDFUNC0(ARRAY, INT, Array, hash, varray()); - ADDFUNC1(ARRAY, NIL, Array, push_back, NIL, "value", varray()); - ADDFUNC1(ARRAY, NIL, Array, push_front, NIL, "value", varray()); - ADDFUNC1(ARRAY, NIL, Array, append, NIL, "value", varray()); - ADDFUNC1(ARRAY, NIL, Array, resize, INT, "size", varray()); - ADDFUNC2(ARRAY, NIL, Array, insert, INT, "position", NIL, "value", varray()); - ADDFUNC1(ARRAY, NIL, Array, remove, INT, "position", varray()); - ADDFUNC1(ARRAY, NIL, Array, erase, NIL, "value", varray()); + ADDFUNC1NC(ARRAY, NIL, Array, push_back, NIL, "value", varray()); + ADDFUNC1NC(ARRAY, NIL, Array, push_front, NIL, "value", varray()); + ADDFUNC1NC(ARRAY, NIL, Array, append, NIL, "value", varray()); + ADDFUNC1NC(ARRAY, NIL, Array, resize, INT, "size", varray()); + ADDFUNC2NC(ARRAY, NIL, Array, insert, INT, "position", NIL, "value", varray()); + ADDFUNC1NC(ARRAY, NIL, Array, remove, INT, "position", varray()); + ADDFUNC1NC(ARRAY, NIL, Array, erase, NIL, "value", varray()); ADDFUNC0(ARRAY, NIL, Array, front, varray()); ADDFUNC0(ARRAY, NIL, Array, back, varray()); ADDFUNC2(ARRAY, INT, Array, find, NIL, "what", INT, "from", varray(0)); @@ -1571,12 +1599,12 @@ void register_variant_methods() { ADDFUNC1(ARRAY, INT, Array, find_last, NIL, "value", varray()); ADDFUNC1(ARRAY, INT, Array, count, NIL, "value", varray()); ADDFUNC1(ARRAY, BOOL, Array, has, NIL, "value", varray()); - ADDFUNC0(ARRAY, NIL, Array, pop_back, varray()); - ADDFUNC0(ARRAY, NIL, Array, pop_front, varray()); - ADDFUNC0(ARRAY, NIL, Array, sort, varray()); - ADDFUNC2(ARRAY, NIL, Array, sort_custom, OBJECT, "obj", STRING, "func", varray()); - ADDFUNC0(ARRAY, NIL, Array, invert, varray()); - ADDFUNC0(ARRAY, ARRAY, Array, duplicate, varray()); + ADDFUNC0NC(ARRAY, NIL, Array, pop_back, varray()); + ADDFUNC0NC(ARRAY, NIL, Array, pop_front, varray()); + ADDFUNC0NC(ARRAY, NIL, Array, sort, varray()); + ADDFUNC2NC(ARRAY, NIL, Array, sort_custom, OBJECT, "obj", STRING, "func", varray()); + ADDFUNC0NC(ARRAY, NIL, Array, invert, varray()); + ADDFUNC0NC(ARRAY, ARRAY, Array, duplicate, varray()); ADDFUNC0(POOL_BYTE_ARRAY, INT, PoolByteArray, size, varray()); ADDFUNC2(POOL_BYTE_ARRAY, NIL, PoolByteArray, set, INT, "idx", INT, "byte", varray()); diff --git a/doc/classes/SpriteFrames.xml b/doc/classes/SpriteFrames.xml index f4a8eeabe4..e46fdc80e0 100644 --- a/doc/classes/SpriteFrames.xml +++ b/doc/classes/SpriteFrames.xml @@ -4,7 +4,7 @@ Sprite frame library for AnimatedSprite. </brief_description> <description> - Sprite frame library for [AnimatedSprite]. + Sprite frame library for [AnimatedSprite]. Contains frames and animation data for playback. </description> <tutorials> </tutorials> @@ -17,6 +17,7 @@ <argument index="0" name="anim" type="String"> </argument> <description> + Adds a new animation to the the library. </description> </method> <method name="add_frame"> @@ -29,6 +30,7 @@ <argument index="2" name="at_position" type="int" default="-1"> </argument> <description> + Adds a frame to the given animation. </description> </method> <method name="clear"> @@ -37,12 +39,14 @@ <argument index="0" name="anim" type="String"> </argument> <description> + Removes all frames from the given animation. </description> </method> <method name="clear_all"> <return type="void"> </return> <description> + Removes all animations. A "default" animation will be created. </description> </method> <method name="get_animation_loop" qualifiers="const"> @@ -51,6 +55,7 @@ <argument index="0" name="anim" type="String"> </argument> <description> + If [code]true[/code] the given animation will loop. </description> </method> <method name="get_animation_speed" qualifiers="const"> @@ -59,6 +64,7 @@ <argument index="0" name="anim" type="String"> </argument> <description> + The animation's speed in frames per second. </description> </method> <method name="get_frame" qualifiers="const"> @@ -69,6 +75,7 @@ <argument index="1" name="idx" type="int"> </argument> <description> + Returns the animation's selected frame. </description> </method> <method name="get_frame_count" qualifiers="const"> @@ -77,6 +84,7 @@ <argument index="0" name="anim" type="String"> </argument> <description> + Returns the number of frames in the animation. </description> </method> <method name="has_animation" qualifiers="const"> @@ -85,6 +93,7 @@ <argument index="0" name="anim" type="String"> </argument> <description> + If [code]true[/code] the named animation exists. </description> </method> <method name="remove_animation"> @@ -93,6 +102,7 @@ <argument index="0" name="anim" type="String"> </argument> <description> + Removes the given animation. </description> </method> <method name="remove_frame"> @@ -103,6 +113,7 @@ <argument index="1" name="idx" type="int"> </argument> <description> + Removes the animation's selected frame. </description> </method> <method name="rename_animation"> @@ -113,6 +124,7 @@ <argument index="1" name="newname" type="String"> </argument> <description> + Changes the animation's name to [code]newname[/code]. </description> </method> <method name="set_animation_loop"> @@ -123,6 +135,7 @@ <argument index="1" name="loop" type="bool"> </argument> <description> + If [code]true[/code] the animation will loop. </description> </method> <method name="set_animation_speed"> @@ -133,6 +146,7 @@ <argument index="1" name="speed" type="float"> </argument> <description> + The animation's speed in frames per second. </description> </method> <method name="set_frame"> @@ -145,11 +159,13 @@ <argument index="2" name="txt" type="Texture"> </argument> <description> + Sets the texture of the given frame. </description> </method> </methods> <members> <member name="animations" type="Array" setter="_set_animations" getter="_get_animations"> + An [Array] containing the [code]name[/code], [code]speed[/code], [code]loop[/code], and [code]frames[/code] of each animation. </member> <member name="frames" type="Array" setter="_set_frames" getter="_get_frames"> </member> diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 51fdef37cf..ca337551eb 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -802,7 +802,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_tooltip->set_bg_color(Color(mono_color.r, mono_color.g, mono_color.b, 0.9)); style_tooltip->set_border_width_all(border_width); style_tooltip->set_border_color_all(mono_color); - theme->set_color("font_color", "TooltipPanel", font_color); + theme->set_color("font_color", "TooltipLabel", font_color.inverted()); + theme->set_color("font_color_shadow", "TooltipLabel", mono_color.inverted() * Color(1, 1, 1, 0.1)); theme->set_stylebox("panel", "TooltipPanel", style_tooltip); // PopupPanel diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index c591bc733b..d3a0685777 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3823,7 +3823,6 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { snap_config_menu = memnew(MenuButton); hb->add_child(snap_config_menu); - snap_config_menu->get_popup()->connect("id_pressed", this, "_popup_callback"); snap_config_menu->set_h_size_flags(SIZE_SHRINK_END); snap_config_menu->set_tooltip(TTR("Snapping options")); @@ -3877,7 +3876,6 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p = skeleton_menu->get_popup(); p->set_hide_on_checkable_item_selection(false); - p->connect("id_pressed", this, "_popup_callback"); p->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_make_bones", TTR("Make Bones"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B), SKELETON_MAKE_BONES); p->add_shortcut(ED_SHORTCUT("canvas_item_editor/skeleton_clear_bones", TTR("Clear Bones")), SKELETON_CLEAR_BONES); p->add_separator(); diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index f02e797fe6..c17265d275 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -42,7 +42,7 @@ int VisualScriptFunctionCall::get_output_sequence_port_count() const { - if (method_cache.flags & METHOD_FLAG_CONST || call_mode == CALL_MODE_BASIC_TYPE) + if (method_cache.flags & METHOD_FLAG_CONST || (call_mode == CALL_MODE_BASIC_TYPE && Variant::is_method_const(basic_type, function))) return 0; else return 1; @@ -50,7 +50,7 @@ int VisualScriptFunctionCall::get_output_sequence_port_count() const { bool VisualScriptFunctionCall::has_input_sequence_port() const { - if (method_cache.flags & METHOD_FLAG_CONST || call_mode == CALL_MODE_BASIC_TYPE) + if (method_cache.flags & METHOD_FLAG_CONST || (call_mode == CALL_MODE_BASIC_TYPE && Variant::is_method_const(basic_type, function))) return false; else return true; diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 4f62d88934..b020238cac 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -2216,6 +2216,7 @@ void SceneTree::_bind_methods() { BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP); BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP_WIDTH); BIND_ENUM_CONSTANT(STRETCH_ASPECT_KEEP_HEIGHT); + BIND_ENUM_CONSTANT(STRETCH_ASPECT_EXPAND); } SceneTree *SceneTree::singleton = NULL; diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp index 76dd585ffa..32631beb2c 100644 --- a/servers/audio/effects/audio_effect_chorus.cpp +++ b/servers/audio/effects/audio_effect_chorus.cpp @@ -182,9 +182,8 @@ Ref<AudioEffectInstance> AudioEffectChorus::instance() { void AudioEffectChorus::set_voice_count(int p_voices) { - ERR_FAIL_COND(p_voices < 1 || p_voices >= MAX_VOICES); + ERR_FAIL_COND(p_voices < 1 || p_voices > MAX_VOICES); voice_count = p_voices; - _change_notify(); } int AudioEffectChorus::get_voice_count() const { diff --git a/servers/audio/effects/audio_effect_limiter.cpp b/servers/audio/effects/audio_effect_limiter.cpp index 9787ba8109..c50dd804f2 100644 --- a/servers/audio/effects/audio_effect_limiter.cpp +++ b/servers/audio/effects/audio_effect_limiter.cpp @@ -110,7 +110,7 @@ void AudioEffectLimiter::set_soft_clip_ratio(float p_soft_clip) { } float AudioEffectLimiter::get_soft_clip_ratio() const { - return soft_clip; + return soft_clip_ratio; } void AudioEffectLimiter::_bind_methods() { diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp index a4e6abfd45..f8f3b620d4 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp +++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp @@ -109,16 +109,13 @@ void Physics2DServerWrapMT::init() { if (create_thread) { step_sem = Semaphore::create(); - print_line("CREATING PHYSICS 2D THREAD"); //OS::get_singleton()->release_rendering_thread(); if (create_thread) { thread = Thread::create(_thread_callback, this); - print_line("STARTING PHYISICS 2D THREAD"); } while (!step_thread_up) { OS::get_singleton()->delay_usec(1000); } - print_line("DONE PHYSICS 2D THREAD"); } else { physics_2d_server->init(); |