diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-02-11 06:51:20 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-02-11 06:51:20 -0300 |
commit | 1d54c2dd1c94cd8b44fc9cd5a67deba88dbabdda (patch) | |
tree | 4f5645c5c8933a8fa60fce41e98c9943828c4763 | |
parent | d22b256f0841a0ff97f45c5a11aeccd7658b79fa (diff) |
added missing set_shader_param functions
also added code completion hint for shader params
-rw-r--r-- | scene/2d/canvas_item.cpp | 23 | ||||
-rw-r--r-- | scene/2d/canvas_item.h | 2 | ||||
-rw-r--r-- | scene/resources/material.cpp | 2 |
3 files changed, 25 insertions, 2 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 6b892839bb..44a7e25725 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -810,6 +810,23 @@ void CanvasItem::_shader_changed() { } #endif +void CanvasItem::get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const { + + if (p_idx==0 && shader.is_valid() && (p_function.operator String()=="get_shader_param" || p_function.operator String()=="set_shader_param")) { + + List<PropertyInfo> pl; + shader->get_param_list(&pl); + for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) { + r_options->push_back("\""+E->get().name.replace_first("shader_param/","")+"\""); + } + + return; + } + + Node::get_argument_options(p_function,p_idx,r_options); +} + + void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("_sort_children"),&CanvasItem::_sort_children); @@ -845,7 +862,7 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_self_opacity","self_opacity"),&CanvasItem::set_self_opacity); ObjectTypeDB::bind_method(_MD("get_self_opacity"),&CanvasItem::get_self_opacity); - ObjectTypeDB::bind_method(_MD("set_draw_behind_parent","enabe"),&CanvasItem::set_draw_behind_parent); + ObjectTypeDB::bind_method(_MD("set_draw_behind_parent","enable"),&CanvasItem::set_draw_behind_parent); ObjectTypeDB::bind_method(_MD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled); ObjectTypeDB::bind_method(_MD("_set_on_top","on_top"),&CanvasItem::_set_on_top); @@ -882,6 +899,10 @@ void CanvasItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_use_parent_shader","enable"),&CanvasItem::set_use_parent_shader); ObjectTypeDB::bind_method(_MD("get_use_parent_shader"),&CanvasItem::get_use_parent_shader); + ObjectTypeDB::bind_method(_MD("set_shader_param","param","value"),&CanvasItem::set_shader_param); + ObjectTypeDB::bind_method(_MD("get_shader_param","param"),&CanvasItem::get_shader_param); + + BIND_VMETHOD(MethodInfo("_draw")); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") ); diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index ed3ade9df2..e7260a6530 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -221,6 +221,8 @@ public: void set_shader_param(const StringName& p_param,const Variant& p_value); Variant get_shader_param(const StringName& p_param) const; + void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const; + CanvasItem(); ~CanvasItem(); }; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 08c752cff9..633dd72ce3 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -582,7 +582,7 @@ void ShaderMaterial::get_argument_options(const StringName& p_function,int p_idx List<PropertyInfo> pl; shader->get_param_list(&pl); for (List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) { - r_options->push_back("\""+E->get().name.replace("shader_param/","")+"\""); + r_options->push_back("\""+E->get().name.replace_first("shader_param/","")+"\""); } } } |