bool CollisionObject2D::_set(const StringName& p_name, const Variant& p_value) { String name=p_name; if (name=="shape_count") { shapes.resize(p_value); _update_shapes(); _change_notify(); } else if (name.begins_with("shapes/")) { int idx=name.get_slice("/",1).to_int(); String what=name.get_slice("/",2); if (what=="shape") set_shape(idx,RefPtr(p_value)); else if (what=="transform") set_shape_transform(idx,p_value); else if (what=="trigger") set_shape_as_trigger(idx,p_value); } else return false; return true; }
void AnimationTreeEditor::_edit_dialog_animation_changed() { Ref<Animation> anim = property_editor->get_variant().operator RefPtr(); anim_tree->animation_node_set_animation(edited_node,anim); update(); }
PasteCommandPtr PasteCommand::create(ApplicationPlayer* const ApplicationPlayer, HierarchyPanel* const HierarchyPanel, Node* const ParentNode, bool DeepClone) { return RefPtr(new PasteCommand(ApplicationPlayer,HierarchyPanel,ParentNode,DeepClone)); }
Variant::operator RefPtr() const { if (type==OBJECT) return _get_obj().ref; else return RefPtr(); }
void MainLoop::finish() { if (get_script_instance()) { get_script_instance()->call("_finalize"); set_script(RefPtr()); //clear script } }
bool CollisionObject2D::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; if (name.begins_with("shapes/")) { int idx = name.get_slicec('/', 1).to_int(); String what = name.get_slicec('/', 2); if (what == "shape") { if (idx >= shapes.size()) add_shape(RefPtr(p_value)); else set_shape(idx, RefPtr(p_value)); } else if (what == "transform") set_shape_transform(idx, p_value); else if (what == "trigger") set_shape_as_trigger(idx, p_value); } else return false; return true; }
void Object::set_script_instance(ScriptInstance *p_instance) { if (script_instance==p_instance) return; if (script_instance) memdelete(script_instance); script_instance=p_instance; if (p_instance) script=p_instance->get_script().get_ref_ptr(); else script=RefPtr(); }
void AnimationTreeEditor::_edit_dialog_edit_animation() { if (get_tree()->is_editor_hint()) { get_tree()->get_root()->get_child(0)->call("_resource_selected", property_editor->get_variant().operator RefPtr()); }; };
void ResourceFormatSaverTextInstance::_find_resources(const Variant& p_variant,bool p_main) { switch(p_variant.get_type()) { case Variant::OBJECT: { RES res = p_variant.operator RefPtr(); if (res.is_null() || external_resources.has(res)) return; if (!p_main && (!bundle_resources ) && res->get_path().length() && res->get_path().find("::") == -1 ) { int index = external_resources.size(); external_resources[res]=index; return; } if (resource_set.has(res)) return; List<PropertyInfo> property_list; res->get_property_list( &property_list ); property_list.sort(); List<PropertyInfo>::Element *I=property_list.front(); while(I) { PropertyInfo pi=I->get(); if (pi.usage&PROPERTY_USAGE_STORAGE || (bundle_resources && pi.usage&PROPERTY_USAGE_BUNDLE)) { Variant v=res->get(I->get().name); _find_resources(v); } I=I->next(); } resource_set.insert( res ); //saved after, so the childs it needs are available when loaded saved_resources.push_back(res); } break; case Variant::ARRAY: { Array varray=p_variant; int len=varray.size(); for(int i=0;i<len;i++) { Variant v=varray.get(i); _find_resources(v); } } break; case Variant::DICTIONARY: { Dictionary d=p_variant; List<Variant> keys; d.get_key_list(&keys); for(List<Variant>::Element *E=keys.front();E;E=E->next()) { Variant v = d[E->get()]; _find_resources(v); } } break; default: {} } }
PruneGraphOpCommandPtr PruneGraphOpCommand::create(NodeUnrecPtr RootNode) { return RefPtr(new PruneGraphOpCommand(RootNode)); }
AttachColGeomGraphOpCommandPtr AttachColGeomGraphOpCommand::create(Node* const RootNode) { return RefPtr(new AttachColGeomGraphOpCommand(RootNode)); }
InsertFieldElementCommandPtr InsertFieldElementCommand::create(FieldContainer* FC, UInt32 FieldId, const std::string& Value, UInt32 Index) { return RefPtr(new InsertFieldElementCommand(FC, FieldId, Value, Index)); }
void ResourceFormatSaverBinaryInstance::_find_resources(const Variant& p_variant,bool p_main) { switch(p_variant.get_type()) { case Variant::OBJECT: { RES res = p_variant.operator RefPtr(); if (res.is_null()) return; if (!p_main && (!bundle_resources ) && res->get_path().length() && res->get_path().find("::") == -1 ) { external_resources.insert(res); return; } if (resource_map.has(res)) return; List<PropertyInfo> property_list; res->get_property_list(&property_list); for(List<PropertyInfo>::Element *E=property_list.front();E;E=E->next()) { if (E->get().usage&PROPERTY_USAGE_STORAGE || (bundle_resources && E->get().usage&PROPERTY_USAGE_BUNDLE)) { _find_resources(res->get(E->get().name)); } } resource_map[ res ] = saved_resources.size(); saved_resources.push_back(res); } break; case Variant::ARRAY: { Array varray=p_variant; int len=varray.size(); for(int i=0;i<len;i++) { Variant v=varray.get(i); _find_resources(v); } } break; case Variant::DICTIONARY: { Dictionary d=p_variant; List<Variant> keys; d.get_key_list(&keys); for(List<Variant>::Element *E=keys.front();E;E=E->next()) { _find_resources(E->get()); Variant v = d[E->get()]; _find_resources(v); } } break; case Variant::NODE_PATH: { //take the chance and save node path strings NodePath np = p_variant; for(int i=0;i<np.get_name_count();i++) get_string_index(np.get_name(i)); for(int i=0;i<np.get_subname_count();i++) get_string_index(np.get_subname(i)); get_string_index(np.get_property()); } break; default: {} } }
LoadProjectCommandPtr LoadProjectCommand::create(void) { return RefPtr(new LoadProjectCommand()); }
void ShaderEditor::_draw_node(int p_node) { VisualServer::ShaderNodeType type=shader_graph.node_get_type(p_node); Ref<StyleBox> style = active_nodes.has(p_node)?get_stylebox("panel","PopupMenu"):get_stylebox("panel_disabled","PopupMenu"); Ref<Font> font = get_font("font","PopupMenu"); Color font_color = get_color("font_color","PopupMenu"); Color font_color_title = get_color("font_color_hover","PopupMenu"); Size2 size=get_node_size(p_node); Point2 pos = Point2( shader_graph.node_get_pos_x(p_node), shader_graph.node_get_pos_y(p_node) )-offset; if (click_type==CLICK_NODE && click_node==p_node) { pos+=click_motion-click_pos; } RID ci = get_canvas_item(); style->draw(ci,Rect2(pos,size)); Point2 ofs=style->get_offset()+pos; Point2 ascent=Point2(0,font->get_ascent()); float w = size.width-style->get_minimum_size().width; float h = font->get_height()+get_constant("vseparation","PopupMenu"); font->draw_halign( ci, ofs+ascent, HALIGN_CENTER,w, VisualServer::shader_node_get_type_info(type).name,font_color_title); ofs.y+=h; Ref<Texture> vec_icon = get_icon("NodeVecSlot","EditorIcons"); Ref<Texture> real_icon = get_icon("NodeRealSlot","EditorIcons"); float icon_h_ofs = Math::floor(( font->get_height()-vec_icon->get_height())/2.0 )+1; for(int i=0;i<VisualServer::shader_get_input_count(type);i++) { String name = VisualServer::shader_get_input_name(type,i); font->draw_halign( ci, ofs+ascent, HALIGN_LEFT,w, name,font_color); Ref<Texture> icon = VisualServer::shader_is_input_vector(type,i)?vec_icon:real_icon; icon->draw(ci,ofs+Point2(-real_icon->get_width(),icon_h_ofs)); ofs.y+=h; } for(int i=0;i<VisualServer::shader_get_output_count(type);i++) { String name = VisualServer::shader_get_output_name(type,i); font->draw_halign( ci, ofs+ascent, HALIGN_RIGHT,w, name,font_color); Ref<Texture> icon = VisualServer::shader_is_output_vector(type,i)?vec_icon:real_icon; icon->draw(ci,ofs+Point2(w,icon_h_ofs)); ofs.y+=h; } switch(type) { case VS::NODE_IN: case VS::NODE_OUT: case VS::NODE_PARAMETER: case VS::NODE_VEC_IN: case VS::NODE_COLOR_PARAMETER: case VS::NODE_VEC_OUT: case VS::NODE_TEXTURE_PARAMETER: case VS::NODE_TEXTURE_2D_PARAMETER: case VS::NODE_TEXTURE_CUBE_PARAMETER: case VS::NODE_TRANSFORM_CONSTANT: case VS::NODE_TRANSFORM_PARAMETER: case VS::NODE_VEC_PARAMETER: case VS::NODE_LABEL: { String text = shader_graph.node_get_param(p_node); font->draw_halign( ci, ofs+ascent, HALIGN_CENTER,w, text,font_color); } break; case VS::NODE_TIME: case VS::NODE_CONSTANT: { String text = rtos(shader_graph.node_get_param(p_node)); font->draw_halign( ci, ofs+ascent, HALIGN_CENTER,w, text,font_color); } break; case VS::NODE_VEC_CONSTANT: { String text = Vector3(shader_graph.node_get_param(p_node)); font->draw_halign( ci, ofs+ascent, HALIGN_CENTER,w, text,font_color); } break; case VS::NODE_COLOR_CONSTANT: { Color color = shader_graph.node_get_param(p_node); Rect2 r(ofs,Size2(w,h)); VisualServer::get_singleton()->canvas_item_add_rect(ci,r,color); } break; case VS::NODE_TEXTURE: case VS::NODE_VEC_TEXTURE_2D: case VS::NODE_VEC_TEXTURE_CUBE: { Rect2 r(ofs,Size2(w,(pos.y+size.y-style->get_margin(MARGIN_BOTTOM))-ofs.y)); Vector<Point2> points; Vector<Point2> uvs; points.resize(4); uvs.resize(4); points[0]=r.pos; points[1]=r.pos+Point2(r.size.x,0); points[2]=r.pos+r.size; points[3]=r.pos+Point2(0,r.size.y); uvs[0]=Point2(0,0); uvs[1]=Point2(1,0); uvs[2]=Point2(1,1); uvs[3]=Point2(0,1); Ref<Texture> texture = shader_graph.node_get_param(p_node).operator RefPtr(); if (texture.is_null() || texture->get_width()==0) { texture=get_icon("Click2Edit","EditorIcons"); } VisualServer::get_singleton()->canvas_item_add_primitive(ci,points,Vector<Color>(),uvs,texture->get_rid()); } break; default: {} } }
TravMaskCommandPtr TravMaskCommand::create(Node* const RootNode, UIDrawingSurface* const DrawingSurface) { return RefPtr(new TravMaskCommand(RootNode, DrawingSurface)); }
DeleteSelectedCommandPtr DeleteSelectedCommand::create(TextDomLayoutManagerRefPtr Manager,TextDomAreaRefPtr TheTextDomArea) { return RefPtr(new DeleteSelectedCommand(Manager,TheTextDomArea)); }
SetFieldValueCommandPtr SetFieldValueCommand::create(FieldContainer* FC, UInt32 FieldId, const std::string& Value,const std::string& PrevValue, UInt32 Index) { return RefPtr(new SetFieldValueCommand(FC, FieldId, Value,PrevValue, Index)); }
SwapFieldElementCommandPtr SwapFieldElementCommand::create(FieldContainer* FC, UInt32 FieldId, UInt32 FromIndex, UInt32 ToIndex) { return RefPtr(new SwapFieldElementCommand(FC, FieldId, FromIndex, ToIndex)); }
void SurfaceTool::_bind_methods() { ObjectTypeDB::bind_method(_MD("begin","primitive"),&SurfaceTool::begin); ObjectTypeDB::bind_method(_MD("add_vertex","vertex"),&SurfaceTool::add_vertex); ObjectTypeDB::bind_method(_MD("add_color","color"),&SurfaceTool::add_color); ObjectTypeDB::bind_method(_MD("add_normal","normal"),&SurfaceTool::add_normal); ObjectTypeDB::bind_method(_MD("add_tangent","tangent"),&SurfaceTool::add_tangent); ObjectTypeDB::bind_method(_MD("add_uv","uv"),&SurfaceTool::add_uv); ObjectTypeDB::bind_method(_MD("add_uv2","uv2"),&SurfaceTool::add_uv2); ObjectTypeDB::bind_method(_MD("add_bones","bones"),&SurfaceTool::add_bones); ObjectTypeDB::bind_method(_MD("add_weights","weights"),&SurfaceTool::add_weights); ObjectTypeDB::bind_method(_MD("set_material","material:Material"),&SurfaceTool::set_material); ObjectTypeDB::bind_method(_MD("index"),&SurfaceTool::index); ObjectTypeDB::bind_method(_MD("deindex"),&SurfaceTool::deindex); ObjectTypeDB::bind_method(_MD("generate_flat_normals"),&SurfaceTool::generate_flat_normals); ObjectTypeDB::bind_method(_MD("generate_smooth_normals"),&SurfaceTool::generate_smooth_normals); ObjectTypeDB::bind_method(_MD("generate_tangents"),&SurfaceTool::generate_tangents); ObjectTypeDB::bind_method(_MD("commit:Mesh","existing:Mesh"),&SurfaceTool::commit,DEFVAL( RefPtr() )); ObjectTypeDB::bind_method(_MD("clear"),&SurfaceTool::clear); }