void AnimationPlayer::_generate_node_caches(AnimationData* p_anim) { Node *parent = get_node(root); ERR_FAIL_COND(!parent); Animation *a=p_anim->animation.operator->(); p_anim->node_cache.resize( a->get_track_count() ); for (int i=0;i<a->get_track_count();i++) { p_anim->node_cache[i]=NULL; RES resource; Node *child = parent->get_node_and_resource(a->track_get_path(i),resource); if (!child) { ERR_EXPLAIN("On Animation: '"+p_anim->name+"', couldn't resolve track: '"+String(a->track_get_path(i))+"'"); } ERR_CONTINUE(!child); // couldn't find the child node uint32_t id=resource.is_valid()?resource->get_instance_ID():child->get_instance_ID(); int bone_idx=-1; if (a->track_get_path(i).get_property() && child->cast_to<Skeleton>()) { bone_idx = child->cast_to<Skeleton>()->find_bone( a->track_get_path(i).get_property() ); if (bone_idx==-1) { continue; } } { if (!child->is_connected("exit_tree",this,"_node_removed")) child->connect("exit_tree",this,"_node_removed",make_binds(child),CONNECT_ONESHOT); } TrackNodeCacheKey key; key.id=id; key.bone_idx=bone_idx; if (node_cache_map.has(key)) { p_anim->node_cache[i]=&node_cache_map[key]; } else { node_cache_map[key]=TrackNodeCache(); p_anim->node_cache[i]=&node_cache_map[key]; p_anim->node_cache[i]->node=child; p_anim->node_cache[i]->resource=resource; p_anim->node_cache[i]->node_2d=child->cast_to<Node2D>(); if (a->track_get_type(i)==Animation::TYPE_TRANSFORM) { // special cases and caches for transform tracks // cache spatial p_anim->node_cache[i]->spatial=child->cast_to<Spatial>(); // cache skeleton p_anim->node_cache[i]->skeleton=child->cast_to<Skeleton>(); if (p_anim->node_cache[i]->skeleton) { StringName bone_name=a->track_get_path(i).get_property(); if (bone_name.operator String()!="") { p_anim->node_cache[i]->bone_idx=p_anim->node_cache[i]->skeleton->find_bone(bone_name); if (p_anim->node_cache[i]->bone_idx<0) { // broken track (nonexistent bone) p_anim->node_cache[i]->skeleton=NULL; p_anim->node_cache[i]->spatial=NULL; printf("bone is %ls\n", String(bone_name).c_str()); ERR_CONTINUE( p_anim->node_cache[i]->bone_idx<0 ); } else { } } else { // no property, just use spatialnode p_anim->node_cache[i]->skeleton=NULL; } } } } if (a->track_get_type(i)==Animation::TYPE_VALUE) { StringName property = a->track_get_path(i).get_property(); if (!p_anim->node_cache[i]->property_anim.has(property)) { TrackNodeCache::PropertyAnim pa; pa.prop=property; pa.object=resource.is_valid()?(Object*)resource.ptr():(Object*)child; pa.special=SP_NONE; if (false && p_anim->node_cache[i]->node_2d) { if (pa.prop==SceneStringNames::get_singleton()->transform_pos) pa.special=SP_NODE2D_POS; else if (pa.prop==SceneStringNames::get_singleton()->transform_rot) pa.special=SP_NODE2D_ROT; else if (pa.prop==SceneStringNames::get_singleton()->transform_scale) pa.special=SP_NODE2D_SCALE; } p_anim->node_cache[i]->property_anim[property]=pa; } } } }
void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_area_shape, int p_self_shape) { bool area_in = p_status == PhysicsServer::AREA_BODY_ADDED; ObjectID objid = p_instance; Object *obj = ObjectDB::get_instance(objid); Node *node = Object::cast_to<Node>(obj); Map<ObjectID, AreaState>::Element *E = area_map.find(objid); ERR_FAIL_COND(!area_in && !E); locked = true; if (area_in) { if (!E) { E = area_map.insert(objid, AreaState()); E->get().rc = 0; E->get().in_tree = node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree, make_binds(objid)); node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->area_entered, node); } } } E->get().rc++; if (node) E->get().shapes.insert(AreaShapePair(p_area_shape, p_self_shape)); if (!node || E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->area_shape_entered, objid, node, p_area_shape, p_self_shape); } } else { E->get().rc--; if (node) E->get().shapes.erase(AreaShapePair(p_area_shape, p_self_shape)); bool eraseit = false; if (E->get().rc == 0) { if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree); node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->area_exited, obj); } } eraseit = true; } if (!node || E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->area_shape_exited, objid, obj, p_area_shape, p_self_shape); } if (eraseit) area_map.erase(E); } locked = false; }
SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelection *p_editor_selection,EditorData &p_editor_data) { editor=p_editor; edited_scene=NULL; editor_data=&p_editor_data; editor_selection=p_editor_selection; scene_root=p_scene_root; VBoxContainer *vbc = this; HBoxContainer *hbc_top = memnew( HBoxContainer ); vbc->add_child(hbc_top); ToolButton *tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_NEW, false)); tb->set_tooltip("Add/Create a New Node\n("+keycode_get_string(KEY_MASK_CMD|KEY_A)+")"); hbc_top->add_child(tb); tool_buttons[TOOL_NEW]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_INSTANCE, false)); tb->set_tooltip("Instance a Node from scene file."); hbc_top->add_child(tb); tool_buttons[TOOL_INSTANCE]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_REPLACE, false)); tb->set_tooltip("Replace a Node by Another Node Type"); hbc_top->add_child(tb); tool_buttons[TOOL_REPLACE]=tb; hbc_top->add_spacer(); tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_CONNECT, false)); tb->set_tooltip("Edit the Node Connections"); hbc_top->add_child(tb); tool_buttons[TOOL_CONNECT]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_GROUP, false)); tb->set_tooltip("Edit the Node Groups"); hbc_top->add_child(tb); tool_buttons[TOOL_GROUP]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_SCRIPT, false)); tb->set_tooltip("Edit/Create the Node Script"); hbc_top->add_child(tb); tool_buttons[TOOL_SCRIPT]=tb; scene_tree = memnew( SceneTreeEditor(false,true,true )); vbc->add_child(scene_tree); scene_tree->set_v_size_flags(SIZE_EXPAND|SIZE_FILL); scene_tree->connect("node_selected", this,"_node_selected",varray(),CONNECT_DEFERRED); scene_tree->connect("node_renamed", this,"_node_renamed",varray(),CONNECT_DEFERRED); scene_tree->connect("node_prerename", this,"_node_prerenamed"); scene_tree->connect("open",this,"_load_request"); scene_tree->connect("open_script",this,"_script_open_request"); scene_tree->set_undo_redo(&editor_data->get_undo_redo()); scene_tree->set_editor_selection(editor_selection); HBoxContainer *hbc_bottom = memnew( HBoxContainer ); vbc->add_child(hbc_bottom); tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_MOVE_UP, false)); tb->set_tooltip("Move Node Up\n("+keycode_get_string(KEY_MASK_CMD|KEY_UP)+")"); hbc_bottom->add_child(tb); tool_buttons[TOOL_MOVE_UP]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_MOVE_DOWN, false)); tb->set_tooltip("Move Node Down\n("+keycode_get_string(KEY_MASK_CMD|KEY_DOWN)+")"); hbc_bottom->add_child(tb); tool_buttons[TOOL_MOVE_DOWN]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_DUPLICATE, false)); tb->set_tooltip("Duplicate Selected Node(s)\n("+keycode_get_string(KEY_MASK_CMD|KEY_D)+")"); hbc_bottom->add_child(tb); tool_buttons[TOOL_DUPLICATE]=tb; tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_REPARENT, false)); tb->set_tooltip("Reparent Selected Node(s)"); hbc_bottom->add_child(tb); tool_buttons[TOOL_REPARENT]=tb; hbc_bottom->add_spacer(); tb = memnew( ToolButton ); tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_ERASE, false)); tb->set_tooltip("Erase Selected Node(s)"); hbc_bottom->add_child(tb); tool_buttons[TOOL_ERASE]=tb; create_dialog = memnew( CreateDialog ); create_dialog->set_base_type("Node"); add_child(create_dialog); create_dialog->connect("create",this,"_create"); groups_editor = memnew( GroupsEditor ); add_child(groups_editor); groups_editor->set_undo_redo(&editor_data->get_undo_redo()); connect_dialog = memnew( ConnectionsDialog(p_editor) ); add_child(connect_dialog); connect_dialog->set_undoredo(&editor_data->get_undo_redo()); script_create_dialog = memnew( ScriptCreateDialog ); add_child(script_create_dialog); script_create_dialog->connect("script_created",this,"_script_created"); reparent_dialog = memnew( ReparentDialog ); add_child(reparent_dialog); reparent_dialog->connect("reparent",this,"_node_reparent"); accept = memnew( AcceptDialog ); add_child(accept); file = memnew( FileDialog ); add_child(file); file->connect("file_selected",this,"instance"); set_process_unhandled_key_input(true); delete_dialog = memnew( ConfirmationDialog ); add_child(delete_dialog); delete_dialog->connect("confirmed",this,"_delete_confirm"); import_subscene_dialog = memnew( EditorSubScene ); add_child(import_subscene_dialog); import_subscene_dialog->connect("subscene_selected",this,"_import_subscene"); }
RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo) { scene_tree_editor = p_scene_tree_editor; undo_redo = p_undo_redo; preview_node = NULL; set_title(TTR("Batch Rename")); VBoxContainer *vbc = memnew(VBoxContainer); add_child(vbc); // -- Search/Replace Area GridContainer *grd_main = memnew(GridContainer); grd_main->set_columns(2); grd_main->set_v_size_flags(SIZE_EXPAND_FILL); vbc->add_child(grd_main); // ---- 1st & 2nd row Label *lbl_search = memnew(Label); lbl_search->set_text(TTR("Search")); lne_search = memnew(LineEdit); lne_search->set_placeholder(TTR("Search")); lne_search->set_name("lne_search"); lne_search->set_h_size_flags(SIZE_EXPAND_FILL); Label *lbl_replace = memnew(Label); lbl_replace->set_text(TTR("Replace")); lne_replace = memnew(LineEdit); lne_replace->set_placeholder(TTR("Replace")); lne_replace->set_name("lne_replace"); lne_replace->set_h_size_flags(SIZE_EXPAND_FILL); grd_main->add_child(lbl_search); grd_main->add_child(lbl_replace); grd_main->add_child(lne_search); grd_main->add_child(lne_replace); // ---- 3rd & 4th row Label *lbl_prefix = memnew(Label); lbl_prefix->set_text(TTR("Prefix")); lne_prefix = memnew(LineEdit); lne_prefix->set_placeholder(TTR("Prefix")); lne_prefix->set_name("lne_prefix"); lne_prefix->set_h_size_flags(SIZE_EXPAND_FILL); Label *lbl_suffix = memnew(Label); lbl_suffix->set_text(TTR("Suffix")); lne_suffix = memnew(LineEdit); lne_suffix->set_placeholder(TTR("Suffix")); lne_suffix->set_name("lne_suffix"); lne_suffix->set_h_size_flags(SIZE_EXPAND_FILL); grd_main->add_child(lbl_prefix); grd_main->add_child(lbl_suffix); grd_main->add_child(lne_prefix); grd_main->add_child(lne_suffix); // -- Feature Tabs const int feature_min_height = 160; Ref<Theme> collapse_theme = create_editor_theme(); collapse_theme->set_icon("checked", "CheckBox", collapse_theme->get_icon("GuiTreeArrowDown", "EditorIcons")); collapse_theme->set_icon("unchecked", "CheckBox", collapse_theme->get_icon("GuiTreeArrowRight", "EditorIcons")); CheckBox *chk_collapse_features = memnew(CheckBox); chk_collapse_features->set_text(TTR("Advanced options")); chk_collapse_features->set_theme(collapse_theme); chk_collapse_features->set_focus_mode(FOCUS_NONE); vbc->add_child(chk_collapse_features); tabc_features = memnew(TabContainer); tabc_features->set_tab_align(TabContainer::ALIGN_LEFT); vbc->add_child(tabc_features); // ---- Tab Substitute VBoxContainer *vbc_substitute = memnew(VBoxContainer); vbc_substitute->set_h_size_flags(SIZE_EXPAND_FILL); vbc_substitute->set_custom_minimum_size(Size2(0, feature_min_height)); vbc_substitute->set_name(TTR("Substitute")); tabc_features->add_child(vbc_substitute); cbut_substitute = memnew(CheckButton); cbut_substitute->set_text(TTR("Substitute")); vbc_substitute->add_child(cbut_substitute); GridContainer *grd_substitute = memnew(GridContainer); grd_substitute->set_columns(3); vbc_substitute->add_child(grd_substitute); // Name but_insert_name = memnew(Button); but_insert_name->set_text("NAME"); but_insert_name->set_tooltip(String("${NAME}\n") + TTR("Node name")); but_insert_name->set_focus_mode(FOCUS_NONE); but_insert_name->connect("pressed", this, "_insert_text", make_binds("${NAME}")); but_insert_name->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_name); // Parent but_insert_parent = memnew(Button); but_insert_parent->set_text("PARENT"); but_insert_parent->set_tooltip(String("${PARENT}\n") + TTR("Node's parent name, if available")); but_insert_parent->set_focus_mode(FOCUS_NONE); but_insert_parent->connect("pressed", this, "_insert_text", make_binds("${PARENT}")); but_insert_parent->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_parent); // Type but_insert_type = memnew(Button); but_insert_type->set_text("TYPE"); but_insert_type->set_tooltip(String("${TYPE}\n") + TTR("Node type")); but_insert_type->set_focus_mode(FOCUS_NONE); but_insert_type->connect("pressed", this, "_insert_text", make_binds("${TYPE}")); but_insert_type->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_type); // Scene but_insert_scene = memnew(Button); but_insert_scene->set_text("SCENE"); but_insert_scene->set_tooltip(String("${SCENE}\n") + TTR("Current scene name")); but_insert_scene->set_focus_mode(FOCUS_NONE); but_insert_scene->connect("pressed", this, "_insert_text", make_binds("${SCENE}")); but_insert_scene->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_scene); // Root but_insert_root = memnew(Button); but_insert_root->set_text("ROOT"); but_insert_root->set_tooltip(String("${ROOT}\n") + TTR("Root node name")); but_insert_root->set_focus_mode(FOCUS_NONE); but_insert_root->connect("pressed", this, "_insert_text", make_binds("${ROOT}")); but_insert_root->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_root); // Count but_insert_count = memnew(Button); but_insert_count->set_text("COUNTER"); but_insert_count->set_tooltip(String("${COUNTER}\n") + TTR("Sequential integer counter.\nCompare counter options.")); but_insert_count->set_focus_mode(FOCUS_NONE); but_insert_count->connect("pressed", this, "_insert_text", make_binds("${COUNTER}")); but_insert_count->set_h_size_flags(SIZE_EXPAND_FILL); grd_substitute->add_child(but_insert_count); chk_per_level_counter = memnew(CheckBox); chk_per_level_counter->set_text(TTR("Per Level counter")); chk_per_level_counter->set_tooltip(TTR("If set the counter restarts for each group of child nodes")); vbc_substitute->add_child(chk_per_level_counter); HBoxContainer *hbc_count_options = memnew(HBoxContainer); vbc_substitute->add_child(hbc_count_options); Label *lbl_count_start = memnew(Label); lbl_count_start->set_text(TTR("Start")); lbl_count_start->set_tooltip(TTR("Initial value for the counter")); hbc_count_options->add_child(lbl_count_start); spn_count_start = memnew(SpinBox); spn_count_start->set_tooltip(TTR("Initial value for the counter")); spn_count_start->set_step(1); spn_count_start->set_min(0); hbc_count_options->add_child(spn_count_start); Label *lbl_count_step = memnew(Label); lbl_count_step->set_text(TTR("Step")); lbl_count_step->set_tooltip(TTR("Ammount by which counter is incremented for each node")); hbc_count_options->add_child(lbl_count_step); spn_count_step = memnew(SpinBox); spn_count_step->set_tooltip(TTR("Ammount by which counter is incremented for each node")); spn_count_step->set_step(1); hbc_count_options->add_child(spn_count_step); Label *lbl_count_padding = memnew(Label); lbl_count_padding->set_text(TTR("Padding")); lbl_count_padding->set_tooltip(TTR("Minium number of digits for the counter.\nMissing digits are padded with leading zeros.")); hbc_count_options->add_child(lbl_count_padding); spn_count_padding = memnew(SpinBox); spn_count_padding->set_tooltip(TTR("Minium number of digits for the counter.\nMissing digits are padded with leading zeros.")); spn_count_padding->set_step(1); hbc_count_options->add_child(spn_count_padding); // ---- Tab RegEx VBoxContainer *vbc_regex = memnew(VBoxContainer); vbc_regex->set_h_size_flags(SIZE_EXPAND_FILL); vbc_regex->set_name(TTR("Regular Expressions")); vbc_regex->set_custom_minimum_size(Size2(0, feature_min_height)); tabc_features->add_child(vbc_regex); cbut_regex = memnew(CheckButton); cbut_regex->set_text(TTR("Regular Expressions")); vbc_regex->add_child(cbut_regex); // ---- Tab Process VBoxContainer *vbc_process = memnew(VBoxContainer); vbc_process->set_h_size_flags(SIZE_EXPAND_FILL); vbc_process->set_name(TTR("Post-Process")); vbc_process->set_custom_minimum_size(Size2(0, feature_min_height)); tabc_features->add_child(vbc_process); cbut_process = memnew(CheckButton); cbut_process->set_text(TTR("Post-Process")); vbc_process->add_child(cbut_process); // ------ Style HBoxContainer *hbc_style = memnew(HBoxContainer); vbc_process->add_child(hbc_style); Label *lbl_style = memnew(Label); lbl_style->set_text(TTR("Style")); hbc_style->add_child(lbl_style); opt_style = memnew(OptionButton); opt_style->add_item(TTR("Keep")); opt_style->add_item(TTR("CamelCase to under_scored")); opt_style->add_item(TTR("under_scored to CamelCase")); hbc_style->add_child(opt_style); // ------ Case HBoxContainer *hbc_case = memnew(HBoxContainer); vbc_process->add_child(hbc_case); Label *lbl_case = memnew(Label); lbl_case->set_text(TTR("Case")); hbc_case->add_child(lbl_case); opt_case = memnew(OptionButton); opt_case->add_item(TTR("Keep")); opt_case->add_item(TTR("To Lowercase")); opt_case->add_item(TTR("To Uppercase")); hbc_case->add_child(opt_case); // -- Preview HSeparator *sep_preview = memnew(HSeparator); sep_preview->set_custom_minimum_size(Size2(10, 20)); vbc->add_child(sep_preview); lbl_preview_title = memnew(Label); lbl_preview_title->set_text(TTR("Preview")); vbc->add_child(lbl_preview_title); lbl_preview = memnew(Label); lbl_preview->set_text(""); lbl_preview->add_color_override("font_color", Color(1, 0.5f, 0, 1)); vbc->add_child(lbl_preview); // ---- Dialog related set_custom_minimum_size(Size2(383, 0)); set_as_toplevel(true); get_ok()->set_text(TTR("Rename")); Button *but_reset = add_button(TTR("Reset")); eh.errfunc = _error_handler; eh.userdata = this; // ---- Connections chk_collapse_features->connect("toggled", this, "_features_toggled"); // Substitite Buttons lne_search->connect("focus_entered", this, "_update_substitute"); lne_search->connect("focus_exited", this, "_update_substitute"); lne_replace->connect("focus_entered", this, "_update_substitute"); lne_replace->connect("focus_exited", this, "_update_substitute"); lne_prefix->connect("focus_entered", this, "_update_substitute"); lne_prefix->connect("focus_exited", this, "_update_substitute"); lne_suffix->connect("focus_entered", this, "_update_substitute"); lne_suffix->connect("focus_exited", this, "_update_substitute"); // Preview lne_prefix->connect("text_changed", this, "_update_preview"); lne_suffix->connect("text_changed", this, "_update_preview"); lne_search->connect("text_changed", this, "_update_preview"); lne_replace->connect("text_changed", this, "_update_preview"); spn_count_start->connect("value_changed", this, "_update_preview_int"); spn_count_step->connect("value_changed", this, "_update_preview_int"); spn_count_padding->connect("value_changed", this, "_update_preview_int"); opt_style->connect("item_selected", this, "_update_preview_int"); opt_case->connect("item_selected", this, "_update_preview_int"); cbut_substitute->connect("pressed", this, "_update_preview", varray("")); cbut_regex->connect("pressed", this, "_update_preview", varray("")); cbut_process->connect("pressed", this, "_update_preview", varray("")); but_reset->connect("pressed", this, "reset"); reset(); _features_toggled(false); }
void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_body_shape,int p_area_shape) { bool body_in = p_status==Physics2DServer::AREA_BODY_ADDED; ObjectID objid=p_instance; Object *obj = ObjectDB::get_instance(objid); Node *node = obj ? obj->cast_to<Node>() : NULL; Map<ObjectID,BodyState>::Element *E=body_map.find(objid); ERR_FAIL_COND(!body_in && !E); locked=true; if (body_in) { if (!E) { E = body_map.insert(objid,BodyState()); E->get().rc=0; E->get().in_tree=node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid)); node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_enter,node); } } } E->get().rc++; if (node) E->get().shapes.insert(ShapePair(p_body_shape,p_area_shape)); if (!node || E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_area_shape); } } else { E->get().rc--; if (node) E->get().shapes.erase(ShapePair(p_body_shape,p_area_shape)); bool eraseit=false; if (E->get().rc==0) { if (node) { node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree); node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree); if (E->get().in_tree) emit_signal(SceneStringNames::get_singleton()->body_exit,obj); } eraseit=true; } if (!node || E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_area_shape); } if (eraseit) body_map.erase(E); } locked=false; }
ResourcesDock::ResourcesDock(EditorNode *p_editor) { editor=p_editor; VBoxContainer *vbc = this; HBoxContainer *hbc = memnew( HBoxContainer ); vbc->add_child(hbc); Button *b; b = memnew( ToolButton ); b->set_tooltip("Create New Resource"); b->connect("pressed",this,"_tool_selected",make_binds(TOOL_NEW)); hbc->add_child( b ); button_new=b; b = memnew( ToolButton ); b->set_tooltip("Open Resource"); b->connect("pressed",this,"_tool_selected",make_binds(TOOL_OPEN)); hbc->add_child( b ); button_open=b; MenuButton *mb = memnew( MenuButton ); mb->set_tooltip("Save Resource"); mb->get_popup()->add_item("Save Resource",TOOL_SAVE); mb->get_popup()->add_item("Save Resource As..",TOOL_SAVE_AS); mb->get_popup()->connect("item_pressed",this,"_tool_selected" ); hbc->add_child( mb ); button_save=mb; hbc->add_spacer(); mb = memnew( MenuButton ); mb->set_tooltip("Resource Tools"); mb->get_popup()->add_item("Make Local",TOOL_MAKE_LOCAL); mb->get_popup()->add_item("Copy",TOOL_COPY); mb->get_popup()->add_item("Paste",TOOL_PASTE); mb->get_popup()->connect("item_pressed",this,"_tool_selected" ); hbc->add_child( mb ); button_tools=mb; resources = memnew( Tree ); vbc->add_child(resources); resources->set_v_size_flags(SIZE_EXPAND_FILL); resources->create_item(); //root resources->set_hide_root(true); resources->connect("cell_selected",this,"_resource_selected"); resources->connect("button_pressed",this,"_delete"); create_dialog = memnew( CreateDialog ); add_child(create_dialog); create_dialog->set_base_type("Resource"); create_dialog->connect("create",this,"_create"); accept = memnew (AcceptDialog); add_child(accept); file = memnew( FileDialog ); add_child(file); file->connect("file_selected",this,"_file_action"); block_add=false; }
void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, int p_local_shape) { bool body_in = p_status == 1; ObjectID objid = p_instance; Object *obj = ObjectDB::get_instance(objid); Node *node = obj ? obj->cast_to<Node>() : NULL; Map<ObjectID, BodyState>::Element *E = contact_monitor->body_map.find(objid); ERR_FAIL_COND(!body_in && !E); if (body_in) { if (!E) { E = contact_monitor->body_map.insert(objid, BodyState()); //E->get().rc=0; E->get().in_tree = node && node->is_inside_tree(); if (node) { node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid)); node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_entered, node); } } } //E->get().rc++; if (node) E->get().shapes.insert(ShapePair(p_body_shape, p_local_shape)); if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_shape_entered, objid, node, p_body_shape, p_local_shape); } } else { //E->get().rc--; if (node) E->get().shapes.erase(ShapePair(p_body_shape, p_local_shape)); bool in_tree = E->get().in_tree; if (E->get().shapes.empty()) { if (node) { node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree); node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree); if (in_tree) emit_signal(SceneStringNames::get_singleton()->body_exited, obj); } contact_monitor->body_map.erase(E); } if (node && in_tree) { emit_signal(SceneStringNames::get_singleton()->body_shape_exited, objid, obj, p_body_shape, p_local_shape); } } }
TileMapEditor::TileMapEditor(EditorNode *p_editor) { node=NULL; canvas_item_editor=NULL; editor=p_editor; undo_redo=editor->get_undo_redo(); tool=TOOL_NONE; selection_active=false; mouse_over=false; flip_h=false; flip_v=false; transpose=false; search_box = memnew( LineEdit ); search_box->set_h_size_flags(SIZE_EXPAND_FILL); search_box->connect("text_entered", this, "_text_entered"); search_box->connect("text_changed", this, "_text_changed"); search_box->connect("input_event", this, "_sbox_input"); add_child(search_box); size_slider = memnew( HSlider ); size_slider->set_h_size_flags(SIZE_EXPAND_FILL); size_slider->set_min(0.1f); size_slider->set_max(4.0f); size_slider->set_step(0.1f); size_slider->set_val(1.0f); size_slider->connect("value_changed", this, "_icon_size_changed"); add_child(size_slider); int mw = EDITOR_DEF("tile_map/palette_min_width", 80); // Add tile palette palette = memnew( ItemList ); palette->set_v_size_flags(SIZE_EXPAND_FILL); palette->set_custom_minimum_size(Size2(mw,0)); add_child(palette); // Add menu items toolbar = memnew( HBoxContainer ); toolbar->set_h_size_flags(SIZE_EXPAND_FILL); toolbar->set_alignment(BoxContainer::ALIGN_END); CanvasItemEditor::get_singleton()->add_control_to_menu_panel(toolbar); options = memnew( MenuButton ); options->set_text("Tile Map"); options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("TileMap", "EditorIcons")); options->set_process_unhandled_key_input(false); PopupMenu *p = options->get_popup(); p->add_item(TTR("Bucket"), OPTION_BUCKET); p->add_separator(); p->add_item(TTR("Pick Tile"), OPTION_PICK_TILE, KEY_CONTROL); p->add_separator(); p->add_item(TTR("Select"), OPTION_SELECT, KEY_MASK_CMD+KEY_B); p->add_item(TTR("Duplicate Selection"), OPTION_DUPLICATE, KEY_MASK_CMD+KEY_D); p->add_item(TTR("Erase Selection"), OPTION_ERASE_SELECTION, KEY_DELETE); p->connect("item_pressed", this, "_menu_option"); toolbar->add_child(options); toolbar->add_child( memnew( VSeparator ) ); transp = memnew( ToolButton ); transp->set_toggle_mode(true); transp->set_tooltip(TTR("Transpose")); transp->set_focus_mode(FOCUS_NONE); transp->connect("pressed", this, "_update_transform_buttons", make_binds(transp)); toolbar->add_child(transp); mirror_x = memnew( ToolButton ); mirror_x->set_toggle_mode(true); mirror_x->set_tooltip(TTR("Mirror X (A)")); mirror_x->set_focus_mode(FOCUS_NONE); mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x)); toolbar->add_child(mirror_x); mirror_y = memnew( ToolButton ); mirror_y->set_toggle_mode(true); mirror_y->set_tooltip(TTR("Mirror Y (S)")); mirror_y->set_focus_mode(FOCUS_NONE); mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y)); toolbar->add_child(mirror_y); toolbar->add_child( memnew( VSeparator ) ); rotate_0 = memnew( ToolButton ); rotate_0->set_toggle_mode(true); rotate_0->set_tooltip(TTR("Rotate 0 degrees")); rotate_0->set_focus_mode(FOCUS_NONE); rotate_0->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_0)); toolbar->add_child(rotate_0); rotate_90 = memnew( ToolButton ); rotate_90->set_toggle_mode(true); rotate_90->set_tooltip(TTR("Rotate 90 degrees")); rotate_90->set_focus_mode(FOCUS_NONE); rotate_90->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_90)); toolbar->add_child(rotate_90); rotate_180 = memnew( ToolButton ); rotate_180->set_toggle_mode(true); rotate_180->set_tooltip(TTR("Rotate 180 degrees")); rotate_180->set_focus_mode(FOCUS_NONE); rotate_180->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_180)); toolbar->add_child(rotate_180); rotate_270 = memnew( ToolButton ); rotate_270->set_toggle_mode(true); rotate_270->set_tooltip(TTR("Rotate 270 degrees")); rotate_270->set_focus_mode(FOCUS_NONE); rotate_270->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_270)); toolbar->add_child(rotate_270); toolbar->hide(); rotate_0->set_pressed(true); }
EditorHelp::EditorHelp(EditorNode *p_editor) { editor=p_editor; VBoxContainer *vbc = this; HBoxContainer *panel_hb = memnew( HBoxContainer ); Button *b = memnew( Button ); b->set_text("Class List"); panel_hb->add_child(b); vbc->add_child(panel_hb); b->set_toggle_mode(true); b->set_pressed(true); b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_LIST)); class_list_button=b; class_list_button->hide(); b = memnew( Button ); b->set_text("Class"); panel_hb->add_child(b); edited_class=b; edited_class->hide(); b->set_toggle_mode(true); b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_DESC)); edited_class->hide(); b = memnew( Button ); b->set_text("Search in Classes"); panel_hb->add_child(b); b->connect("pressed",this,"_button_pressed",make_binds(CLASS_SEARCH)); Control *expand = memnew( Control ); expand->set_h_size_flags(SIZE_EXPAND_FILL); panel_hb->add_child(expand); b = memnew( Button ); panel_hb->add_child(b); back=b; b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_PREV)); b = memnew( Button ); panel_hb->add_child(b); forward=b; b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_NEXT)); Separator *hs = memnew( VSeparator ); panel_hb->add_child(hs); EmptyControl *ec = memnew( EmptyControl ); ec->set_minsize(Size2(200,1)); panel_hb->add_child(ec); search = memnew( LineEdit ); ec->add_child(search); search->set_area_as_parent_rect(); search->connect("text_entered",this,"_search"); b = memnew( Button ); b->set_text("Find"); panel_hb->add_child(b); b->connect("pressed",this,"_button_pressed",make_binds(PAGE_SEARCH)); hs = memnew( VSeparator ); panel_hb->add_child(hs); h_split = memnew( HSplitContainer ); h_split->set_v_size_flags(SIZE_EXPAND_FILL); vbc->add_child(h_split); class_list = memnew( Tree ); h_split->add_child(class_list); //class_list->connect("meta_clicked",this,"_class_list_select"); //class_list->set_selection_enabled(true); { PanelContainer *pc = memnew( PanelContainer ); pc->add_style_override("panel",get_stylebox("normal","TextEdit")); h_split->add_child(pc); class_desc = memnew( RichTextLabel ); pc->add_child(class_desc); class_desc->connect("meta_clicked",this,"_class_desc_select"); } class_desc->get_v_scroll()->connect("value_changed",this,"_scroll_changed"); class_desc->set_selection_enabled(true); editor=p_editor; history_pos=0; scroll_locked=false; select_locked=false; set_process_unhandled_key_input(true); h_split->set_split_offset(200); class_list->connect("cell_selected",this,"_tree_item_selected"); class_desc->hide(); class_search = memnew( EditorHelpSearch(editor) ); editor->get_gui_base()->add_child(class_search); class_search->connect("go_to_help",this,"_help_callback"); // prev_search_page=-1; }
TileMapEditor::TileMapEditor(EditorNode *p_editor) { node=NULL; canvas_item_editor=NULL; editor=p_editor; undo_redo = editor->get_undo_redo(); int mw = EDITOR_DEF("tile_map/palette_min_width",80); Control *ec = memnew( Control); ec->set_custom_minimum_size(Size2(mw,0)); add_child(ec); HBoxContainer *hb = memnew( HBoxContainer ); add_child(hb); hb->set_h_size_flags(SIZE_EXPAND_FILL); hb->add_spacer(true); button_thumbnail = memnew( ToolButton ); button_thumbnail->set_toggle_mode(true); button_thumbnail->set_pressed(true); button_thumbnail->set_icon(p_editor->get_gui_base()->get_icon("FileThumbnail","EditorIcons")); hb->add_child(button_thumbnail); button_thumbnail->connect("pressed", this, "_set_display_mode", varray(DISPLAY_THUMBNAIL)); button_list = memnew( ToolButton ); button_list->set_toggle_mode(true); button_list->set_pressed(false); button_list->set_icon(p_editor->get_gui_base()->get_icon("FileList","EditorIcons")); hb->add_child(button_list); button_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST)); // Add tile palette palette = memnew( ItemList ); palette->set_v_size_flags(SIZE_EXPAND_FILL); add_child(palette); // Add menu items canvas_item_editor_hb = memnew( HBoxContainer ); CanvasItemEditor::get_singleton()->add_control_to_menu_panel(canvas_item_editor_hb); canvas_item_editor_hb->add_child( memnew( VSeparator )); transpose = memnew( ToolButton ); transpose->set_toggle_mode(true); transpose->set_tooltip("Transpose"); transpose->set_focus_mode(FOCUS_NONE); transpose->connect("pressed", this, "_update_transform_buttons", make_binds(transpose)); canvas_item_editor_hb->add_child(transpose); mirror_x = memnew( ToolButton ); mirror_x->set_toggle_mode(true); mirror_x->set_tooltip("Mirror X (A)"); mirror_x->set_focus_mode(FOCUS_NONE); mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x)); canvas_item_editor_hb->add_child(mirror_x); mirror_y = memnew( ToolButton ); mirror_y->set_toggle_mode(true); mirror_y->set_tooltip("Mirror Y (S)"); mirror_y->set_focus_mode(FOCUS_NONE); mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y)); canvas_item_editor_hb->add_child(mirror_y); canvas_item_editor_hb->add_child(memnew(VSeparator)); rotate_0 = memnew( ToolButton ); rotate_0->set_toggle_mode(true); rotate_0->set_tooltip("Rotate 0 degrees"); rotate_0->set_focus_mode(FOCUS_NONE); rotate_0->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_0)); canvas_item_editor_hb->add_child(rotate_0); rotate_90 = memnew( ToolButton ); rotate_90->set_toggle_mode(true); rotate_90->set_tooltip("Rotate 90 degrees"); rotate_90->set_focus_mode(FOCUS_NONE); rotate_90->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_90)); canvas_item_editor_hb->add_child(rotate_90); rotate_180 = memnew( ToolButton ); rotate_180->set_toggle_mode(true); rotate_180->set_tooltip("Rotate 180 degrees"); rotate_180->set_focus_mode(FOCUS_NONE); rotate_180->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_180)); canvas_item_editor_hb->add_child(rotate_180); rotate_270 = memnew( ToolButton ); rotate_270->set_toggle_mode(true); rotate_270->set_tooltip("Rotate 270 degrees"); rotate_270->set_focus_mode(FOCUS_NONE); rotate_270->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_270)); canvas_item_editor_hb->add_child(rotate_270); canvas_item_editor_hb->hide(); rotate_0->set_pressed(true); tool=TOOL_NONE; selection_active=false; mouse_over=false; }