String PopupMenu::_get_accel_text(int p_item) const { ERR_FAIL_INDEX_V(p_item, items.size(), String()); if (items[p_item].shortcut.is_valid()) return items[p_item].shortcut->get_as_text(); else if (items[p_item].accel) return keycode_get_string(items[p_item].accel); return String(); /* String atxt; if (p_accel&KEY_MASK_SHIFT) atxt+="Shift+"; if (p_accel&KEY_MASK_ALT) atxt+="Alt+"; if (p_accel&KEY_MASK_CTRL) atxt+="Ctrl+"; if (p_accel&KEY_MASK_META) atxt+="Meta+"; p_accel&=KEY_CODE_MASK; atxt+=String::chr(p_accel).to_upper(); return atxt; */ }
String PopupMenu::_get_accel_text(int p_item) const { ERR_FAIL_INDEX_V(p_item, items.size(), String()); if (items[p_item].shortcut.is_valid()) return items[p_item].shortcut->get_as_text(); else if (items[p_item].accel) return keycode_get_string(items[p_item].accel); return String(); }
String InputEventKey::as_text() const { String kc = keycode_get_string(scancode); if (kc == String()) return kc; if (get_metakey()) { kc = find_keycode_name(KEY_META) + ("+" + kc); } if (get_alt()) { kc = find_keycode_name(KEY_ALT) + ("+" + kc); } if (get_shift()) { kc = find_keycode_name(KEY_SHIFT) + ("+" + kc); } if (get_control()) { kc = find_keycode_name(KEY_CONTROL) + ("+" + kc); } return kc; }
String PopupMenu::_get_accel_text(uint32_t p_accel) const { return keycode_get_string(p_accel); /* String atxt; if (p_accel&KEY_MASK_SHIFT) atxt+="Shift+"; if (p_accel&KEY_MASK_ALT) atxt+="Alt+"; if (p_accel&KEY_MASK_CTRL) atxt+="Ctrl+"; if (p_accel&KEY_MASK_META) atxt+="Meta+"; p_accel&=KEY_CODE_MASK; atxt+=String::chr(p_accel).to_upper(); return atxt; */ }
void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed() && k->get_scancode() != 0) { last_wait_for_key = k; String str = keycode_get_string(k->get_scancode()).capitalize(); if (k->get_metakey()) str = vformat("%s+", find_keycode_name(KEY_META)) + str; if (k->get_shift()) str = TTR("Shift+") + str; if (k->get_alt()) str = TTR("Alt+") + str; if (k->get_control()) str = TTR("Control+") + str; press_a_key_label->set_text(str); press_a_key->accept_event(); } }
void ProjectSettings::_wait_for_key(const InputEvent& p_event) { if (p_event.type==InputEvent::KEY && p_event.key.pressed && p_event.key.scancode!=0) { last_wait_for_key=p_event; String str=keycode_get_string(p_event.key.scancode).capitalize(); if (p_event.key.mod.meta) str="Meta+"+str; if (p_event.key.mod.shift) str="Shift+"+str; if (p_event.key.mod.alt) str="Alt+"+str; if (p_event.key.mod.control) str="Control+"+str; press_a_key_label->set_text(str); press_a_key->accept_event(); } }
PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) { path = NULL; editor = p_node; singleton = this; path_material = Ref<FixedMaterial>(memnew(FixedMaterial)); path_material->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(0.5, 0.5, 1.0, 0.8)); path_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); path_material->set_line_width(3); path_material->set_flag(Material::FLAG_DOUBLE_SIDED, true); path_material->set_flag(Material::FLAG_UNSHADED, true); path_thin_material = Ref<FixedMaterial>(memnew(FixedMaterial)); path_thin_material->set_parameter(FixedMaterial::PARAM_DIFFUSE, Color(0.5, 0.5, 1.0, 0.4)); path_thin_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true); path_thin_material->set_line_width(1); path_thin_material->set_flag(Material::FLAG_DOUBLE_SIDED, true); path_thin_material->set_flag(Material::FLAG_UNSHADED, true); // SpatialEditor::get_singleton()->add_gizmo_plugin(this); sep = memnew(VSeparator); sep->hide(); SpatialEditor::get_singleton()->add_control_to_menu_panel(sep); curve_edit = memnew(ToolButton); curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons")); curve_edit->set_toggle_mode(true); curve_edit->hide(); curve_edit->set_focus_mode(Control::FOCUS_NONE); curve_edit->set_tooltip(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Right Click: Delete Point")); SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_edit); curve_create = memnew(ToolButton); curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons")); curve_create->set_toggle_mode(true); curve_create->hide(); curve_create->set_focus_mode(Control::FOCUS_NONE); curve_create->set_tooltip(TTR("Add Point (in empty space)") + "\n" + TTR("Split Segment (in curve)")); SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_create); curve_del = memnew(ToolButton); curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons")); curve_del->set_toggle_mode(true); curve_del->hide(); curve_del->set_focus_mode(Control::FOCUS_NONE); curve_del->set_tooltip(TTR("Delete Point")); SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_del); curve_close = memnew(ToolButton); curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveClose", "EditorIcons")); curve_close->hide(); curve_close->set_focus_mode(Control::FOCUS_NONE); curve_close->set_tooltip(TTR("Close Curve")); SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_close); curve_edit->set_pressed(true); /* collision_polygon_editor = memnew( PathEditor(p_node) ); editor->get_viewport()->add_child(collision_polygon_editor); collision_polygon_editor->set_margin(MARGIN_LEFT,200); collision_polygon_editor->set_margin(MARGIN_RIGHT,230); collision_polygon_editor->set_margin(MARGIN_TOP,0); collision_polygon_editor->set_margin(MARGIN_BOTTOM,10); collision_polygon_editor->hide(); */ }
GridMapEditor::GridMapEditor(EditorNode *p_editor) { input_action=INPUT_NONE; editor=p_editor; undo_redo=p_editor->get_undo_redo(); int mw = EDITOR_DEF("editors/grid_map/palette_min_width",230); Control *ec = memnew( Control); ec->set_custom_minimum_size(Size2(mw,0)); add_child(ec); spatial_editor_hb = memnew( HBoxContainer ); SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb); options = memnew( MenuButton ); spatial_editor_hb->add_child(options); spatial_editor_hb->hide(); options->set_text("Grid"); options->get_popup()->add_check_item("Snap View",MENU_OPTION_LOCK_VIEW); options->get_popup()->add_separator(); options->get_popup()->add_item("Prev Level ("+keycode_get_string(KEY_MASK_CMD)+"Down Wheel)",MENU_OPTION_PREV_LEVEL); options->get_popup()->add_item("Next Level ("+keycode_get_string(KEY_MASK_CMD)+"Up Wheel)",MENU_OPTION_NEXT_LEVEL); options->get_popup()->add_separator(); options->get_popup()->add_check_item("Clip Disabled",MENU_OPTION_CLIP_DISABLED); options->get_popup()->set_item_checked( options->get_popup()->get_item_index(MENU_OPTION_CLIP_DISABLED), true ); options->get_popup()->add_check_item("Clip Above",MENU_OPTION_CLIP_ABOVE); options->get_popup()->add_check_item("Clip Below",MENU_OPTION_CLIP_BELOW); options->get_popup()->add_separator(); options->get_popup()->add_check_item("Edit X Axis",MENU_OPTION_X_AXIS,KEY_Z); options->get_popup()->add_check_item("Edit Y Axis",MENU_OPTION_Y_AXIS,KEY_X); options->get_popup()->add_check_item("Edit Z Axis",MENU_OPTION_Z_AXIS,KEY_C); options->get_popup()->set_item_checked( options->get_popup()->get_item_index(MENU_OPTION_Y_AXIS), true ); options->get_popup()->add_separator(); options->get_popup()->add_item("Cursor Rotate X",MENU_OPTION_CURSOR_ROTATE_X,KEY_A); options->get_popup()->add_item("Cursor Rotate Y",MENU_OPTION_CURSOR_ROTATE_Y,KEY_S); options->get_popup()->add_item("Cursor Rotate Z",MENU_OPTION_CURSOR_ROTATE_Z,KEY_D); options->get_popup()->add_item("Cursor Back Rotate X",MENU_OPTION_CURSOR_BACK_ROTATE_X,KEY_MASK_SHIFT+KEY_A); options->get_popup()->add_item("Cursor Back Rotate Y",MENU_OPTION_CURSOR_BACK_ROTATE_Y,KEY_MASK_SHIFT+KEY_S); options->get_popup()->add_item("Cursor Back Rotate Z",MENU_OPTION_CURSOR_BACK_ROTATE_Z,KEY_MASK_SHIFT+KEY_D); options->get_popup()->add_item("Cursor Clear Rotation",MENU_OPTION_CURSOR_CLEAR_ROTATION,KEY_W); options->get_popup()->add_separator(); options->get_popup()->add_check_item("Duplicate Selects",MENU_OPTION_DUPLICATE_SELECTS); options->get_popup()->add_separator(); options->get_popup()->add_item("Create Area",MENU_OPTION_SELECTION_MAKE_AREA,KEY_CONTROL+KEY_C); options->get_popup()->add_item("Create Exterior Connector",MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR); options->get_popup()->add_item("Erase Area",MENU_OPTION_REMOVE_AREA); options->get_popup()->add_separator(); options->get_popup()->add_item("Selection -> Duplicate",MENU_OPTION_SELECTION_DUPLICATE,KEY_MASK_SHIFT+KEY_INSERT); options->get_popup()->add_item("Selection -> Clear",MENU_OPTION_SELECTION_CLEAR,KEY_MASK_SHIFT+KEY_DELETE); //options->get_popup()->add_separator(); //options->get_popup()->add_item("Configure",MENU_OPTION_CONFIGURE); options->get_popup()->add_separator(); options->get_popup()->add_item("Settings", MENU_OPTION_GRIDMAP_SETTINGS); settings_dialog = memnew(ConfirmationDialog); settings_dialog->set_title("GridMap Settings"); add_child(settings_dialog); settings_vbc = memnew(VBoxContainer); settings_vbc->set_custom_minimum_size(Size2(200, 0)); settings_dialog->add_child(settings_vbc); settings_pick_distance = memnew(SpinBox); settings_pick_distance->set_max(10000.0f); settings_pick_distance->set_min(500.0f); settings_pick_distance->set_step(1.0f); settings_pick_distance->set_value(EDITOR_DEF("editors/grid_map/pick_distance", 5000.0)); settings_vbc->add_margin_child("Pick Distance:", settings_pick_distance); clip_mode=CLIP_DISABLED; options->get_popup()->connect("id_pressed", this,"_menu_option"); HBoxContainer *hb = memnew( HBoxContainer ); add_child(hb); hb->set_h_size_flags(SIZE_EXPAND_FILL); edit_mode = memnew(OptionButton); edit_mode->set_area_as_parent_rect(); edit_mode->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_BEGIN,24); edit_mode->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,14); edit_mode->add_item("Tiles"); edit_mode->add_item("Areas"); hb->add_child(edit_mode); edit_mode->set_h_size_flags(SIZE_EXPAND_FILL); mode_thumbnail = memnew( ToolButton ); mode_thumbnail->set_toggle_mode(true); mode_thumbnail->set_pressed(true); mode_thumbnail->set_icon(p_editor->get_gui_base()->get_icon("FileThumbnail","EditorIcons")); hb->add_child(mode_thumbnail); mode_thumbnail->connect("pressed", this, "_set_display_mode", varray(DISPLAY_THUMBNAIL)); mode_list = memnew( ToolButton ); mode_list->set_toggle_mode(true); mode_list->set_pressed(false); mode_list->set_icon(p_editor->get_gui_base()->get_icon("FileList", "EditorIcons")); hb->add_child(mode_list); mode_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST)); EDITOR_DEF("editors/grid_map/preview_size",64) display_mode = DISPLAY_THUMBNAIL; selected_area=-1; theme_pallete = memnew( ItemList ); add_child(theme_pallete); theme_pallete->set_v_size_flags(SIZE_EXPAND_FILL); area_list = memnew( Tree ); add_child(area_list); area_list->set_v_size_flags(SIZE_EXPAND_FILL); area_list->hide(); spatial_editor_hb->add_child(memnew(VSeparator)); Label *fl = memnew(Label); fl->set_text(" Floor: "); spatial_editor_hb->add_child(fl); floor = memnew( SpinBox ); floor->set_min(-32767); floor->set_max(32767); floor->set_step(1); floor->get_line_edit()->add_constant_override("minimum_spaces",16); spatial_editor_hb->add_child(floor); floor->connect("value_changed",this,"_floor_changed"); edit_axis=Vector3::AXIS_Y; edit_floor[0]=-1; edit_floor[1]=-1; edit_floor[2]=-1; cursor_visible=false; selected_pallete=-1; lock_view=false; cursor_rot=0; last_mouseover=Vector3(-1,-1,-1); selection_mesh = VisualServer::get_singleton()->mesh_create(); duplicate_mesh = VisualServer::get_singleton()->mesh_create(); { //selection mesh create PoolVector<Vector3> lines; PoolVector<Vector3> triangles; for (int i=0;i<6;i++) { Vector3 face_points[4]; for (int j=0;j<4;j++) { float v[3]; v[0]=1.0; v[1]=1-2*((j>>1)&1); v[2]=v[1]*(1-2*(j&1)); for (int k=0;k<3;k++) { if (i<3) face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1); else face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1); } } triangles.push_back(face_points[0]*0.5+Vector3(0.5,0.5,0.5)); triangles.push_back(face_points[1]*0.5+Vector3(0.5,0.5,0.5)); triangles.push_back(face_points[2]*0.5+Vector3(0.5,0.5,0.5)); triangles.push_back(face_points[2]*0.5+Vector3(0.5,0.5,0.5)); triangles.push_back(face_points[3]*0.5+Vector3(0.5,0.5,0.5)); triangles.push_back(face_points[0]*0.5+Vector3(0.5,0.5,0.5)); } for(int i=0;i<12;i++) { Rect3 base(Vector3(0,0,0),Vector3(1,1,1)); Vector3 a,b; base.get_edge(i,a,b); lines.push_back(a); lines.push_back(b); } Array d; d.resize(VS::ARRAY_MAX); inner_mat = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->fixed_material_set_param(inner_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.3)); VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_ONTOP,true); VisualServer::get_singleton()->material_set_flag(inner_mat,VS::MATERIAL_FLAG_UNSHADED,true); VisualServer::get_singleton()->fixed_material_set_flag( inner_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true ); d[VS::ARRAY_VERTEX]=triangles; VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_TRIANGLES,d); VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,0,inner_mat); outer_mat = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->fixed_material_set_param(outer_mat,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.7,0.7,1.0,0.8)); VisualServer::get_singleton()->material_set_line_width(outer_mat,3.0); VisualServer::get_singleton()->material_set_flag(outer_mat,VS::MATERIAL_FLAG_ONTOP,true); VisualServer::get_singleton()->material_set_flag(outer_mat,VS::MATERIAL_FLAG_UNSHADED,true); VisualServer::get_singleton()->fixed_material_set_flag( outer_mat, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true ); d[VS::ARRAY_VERTEX]=lines; VisualServer::get_singleton()->mesh_add_surface(selection_mesh,VS::PRIMITIVE_LINES,d); VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh,1,outer_mat); inner_mat_dup = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->fixed_material_set_param(inner_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.3)); VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_ONTOP,true); VisualServer::get_singleton()->material_set_flag(inner_mat_dup,VS::MATERIAL_FLAG_UNSHADED,true); VisualServer::get_singleton()->fixed_material_set_flag( inner_mat_dup, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true ); d[VS::ARRAY_VERTEX]=triangles; VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_TRIANGLES,d); VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,0,inner_mat_dup); outer_mat_dup = VisualServer::get_singleton()->fixed_material_create(); VisualServer::get_singleton()->fixed_material_set_param(outer_mat_dup,VS::FIXED_MATERIAL_PARAM_DIFFUSE,Color(1.0,0.7,0.7,0.8)); VisualServer::get_singleton()->material_set_line_width(outer_mat_dup,3.0); VisualServer::get_singleton()->material_set_flag(outer_mat_dup,VS::MATERIAL_FLAG_ONTOP,true); VisualServer::get_singleton()->material_set_flag(outer_mat_dup,VS::MATERIAL_FLAG_UNSHADED,true); VisualServer::get_singleton()->fixed_material_set_flag( outer_mat_dup, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true ); d[VS::ARRAY_VERTEX]=lines; VisualServer::get_singleton()->mesh_add_surface(duplicate_mesh,VS::PRIMITIVE_LINES,d); VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh,1,outer_mat_dup); } selection.active=false; updating=false; }
void ProjectSettings::_update_actions() { if (setting) return; input_editor->clear(); TreeItem *root = input_editor->create_item(); input_editor->set_hide_root(true); List<PropertyInfo> props; Globals::get_singleton()->get_property_list(&props); for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) { const PropertyInfo &pi=E->get(); if (!pi.name.begins_with("input/")) continue; String name = pi.name.get_slice("/",1); if (name=="") continue; TreeItem *item=input_editor->create_item(root); item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); item->set_text(0,name); item->add_button(0,get_icon("Add","EditorIcons"),1); item->add_button(0,get_icon("Del","EditorIcons"),2); item->set_custom_bg_color(0,get_color("prop_subsection","Editor")); item->set_editable(0,true); item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED); Array actions=Globals::get_singleton()->get(pi.name); for(int i=0;i<actions.size();i++) { if (actions[i].get_type()!=Variant::INPUT_EVENT) continue; InputEvent ie = actions[i]; TreeItem *action = input_editor->create_item(item); switch(ie.type) { case InputEvent::KEY: { String str=keycode_get_string(ie.key.scancode).capitalize(); if (ie.key.mod.meta) str="Meta+"+str; if (ie.key.mod.shift) str="Shift+"+str; if (ie.key.mod.alt) str="Alt+"+str; if (ie.key.mod.control) str="Control+"+str; action->set_text(0,str); action->set_icon(0,get_icon("Keyboard","EditorIcons")); } break; case InputEvent::JOYSTICK_BUTTON: { String str = "Device "+itos(ie.device)+", Button "+itos(ie.joy_button.button_index); if (ie.joy_button.button_index>=0 && ie.joy_button.button_index<14) str+=String()+" ("+_button_names[ie.joy_button.button_index]+")."; else str+="."; action->set_text(0,str); action->set_icon(0,get_icon("JoyButton","EditorIcons")); } break; case InputEvent::MOUSE_BUTTON: { String str = "Device "+itos(ie.device)+", "; switch (ie.mouse_button.button_index) { case BUTTON_LEFT: str+="Left Button."; break; case BUTTON_RIGHT: str+="Right Button."; break; case BUTTON_MIDDLE: str+="Middle Button."; break; case BUTTON_WHEEL_UP: str+="Wheel Up."; break; case BUTTON_WHEEL_DOWN: str+="Wheel Down."; break; default: str+="Button "+itos(ie.mouse_button.button_index)+"."; } action->set_text(0,str); action->set_icon(0,get_icon("Mouse","EditorIcons")); } break; case InputEvent::JOYSTICK_MOTION: { String str = "Device "+itos(ie.device)+", Axis "+itos(ie.joy_motion.axis)+"."; action->set_text(0,str); action->set_icon(0,get_icon("JoyAxis","EditorIcons")); } break; } action->add_button(0,get_icon("Del","EditorIcons"),2); action->set_metadata(0,i); } } }
Path2DEditor::Path2DEditor(EditorNode *p_editor) { canvas_item_editor=NULL; editor=p_editor; undo_redo = editor->get_undo_redo(); mode=MODE_EDIT; action=ACTION_NONE; #if 0 options = memnew( MenuButton ); add_child(options); options->set_area_as_parent_rect(); options->set_text("Polygon"); //options->get_popup()->add_item("Parse BBCode",PARSE_BBCODE); options->get_popup()->connect("item_pressed", this,"_menu_option"); #endif base_hb = memnew( HBoxContainer ); CanvasItemEditor::get_singleton()->add_control_to_menu_panel(base_hb); sep = memnew( VSeparator); base_hb->add_child(sep); curve_edit = memnew( ToolButton ); curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit","EditorIcons")); curve_edit->set_toggle_mode(true); curve_edit->set_focus_mode(Control::FOCUS_NONE); curve_edit->set_tooltip(TTR("Select Points")+"\n"+TTR("Shift+Drag: Select Control Points")+"\n"+keycode_get_string(KEY_MASK_CMD)+TTR("Click: Add Point")+"\n"+TTR("Right Click: Delete Point")); curve_edit->connect("pressed",this,"_mode_selected",varray(MODE_EDIT)); base_hb->add_child(curve_edit); curve_edit_curve = memnew( ToolButton ); curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCurve","EditorIcons")); curve_edit_curve->set_toggle_mode(true); curve_edit_curve->set_focus_mode(Control::FOCUS_NONE); curve_edit_curve->set_tooltip(TTR("Select Control Points (Shift+Drag)")); curve_edit_curve->connect("pressed",this,"_mode_selected",varray(MODE_EDIT_CURVE)); base_hb->add_child(curve_edit_curve); curve_create = memnew( ToolButton ); curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate","EditorIcons")); curve_create->set_toggle_mode(true); curve_create->set_focus_mode(Control::FOCUS_NONE); curve_create->set_tooltip(TTR("Add Point (in empty space)")+"\n"+TTR("Split Segment (in curve)")); curve_create->connect("pressed",this,"_mode_selected",varray(MODE_CREATE)); base_hb->add_child(curve_create); curve_del = memnew( ToolButton ); curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete","EditorIcons")); curve_del->set_toggle_mode(true); curve_del->set_focus_mode(Control::FOCUS_NONE); curve_del->set_tooltip(TTR("Delete Point")); curve_del->connect("pressed",this,"_mode_selected",varray(MODE_DELETE)); base_hb->add_child(curve_del); curve_close = memnew( ToolButton ); curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveClose","EditorIcons")); curve_close->set_focus_mode(Control::FOCUS_NONE); curve_close->set_tooltip(TTR("Close Curve")); curve_close->connect("pressed",this,"_mode_selected",varray(ACTION_CLOSE)); base_hb->add_child(curve_close); base_hb->hide(); curve_edit->set_pressed(true); }
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"); }
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: {} }
PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) { path = NULL; editor = p_node; singleton = this; mirror_handle_angle = true; mirror_handle_length = true; Ref<PathSpatialGizmoPlugin> gizmo_plugin; gizmo_plugin.instance(); SpatialEditor::get_singleton()->register_gizmo_plugin(gizmo_plugin); sep = memnew(VSeparator); sep->hide(); SpatialEditor::get_singleton()->add_control_to_menu_panel(sep); curve_edit = memnew(ToolButton); curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons")); curve_edit->set_toggle_mode(true); curve_edit->hide(); curve_edit->set_focus_mode(Control::FOCUS_NONE); curve_edit->set_tooltip(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Right Click: Delete Point")); SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_edit); curve_create = memnew(ToolButton); curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons")); curve_create->set_toggle_mode(true); curve_create->hide(); curve_create->set_focus_mode(Control::FOCUS_NONE); curve_create->set_tooltip(TTR("Add Point (in empty space)") + "\n" + TTR("Split Segment (in curve)")); SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_create); curve_del = memnew(ToolButton); curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons")); curve_del->set_toggle_mode(true); curve_del->hide(); curve_del->set_focus_mode(Control::FOCUS_NONE); curve_del->set_tooltip(TTR("Delete Point")); SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_del); curve_close = memnew(ToolButton); curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveClose", "EditorIcons")); curve_close->hide(); curve_close->set_focus_mode(Control::FOCUS_NONE); curve_close->set_tooltip(TTR("Close Curve")); SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_close); PopupMenu *menu; handle_menu = memnew(MenuButton); handle_menu->set_text(TTR("Options")); handle_menu->hide(); SpatialEditor::get_singleton()->add_control_to_menu_panel(handle_menu); menu = handle_menu->get_popup(); menu->add_check_item(TTR("Mirror Handle Angles")); menu->set_item_checked(HANDLE_OPTION_ANGLE, mirror_handle_angle); menu->add_check_item(TTR("Mirror Handle Lengths")); menu->set_item_checked(HANDLE_OPTION_LENGTH, mirror_handle_length); menu->connect("id_pressed", this, "_handle_option_pressed"); curve_edit->set_pressed(true); /* collision_polygon_editor = memnew( PathEditor(p_node) ); editor->get_viewport()->add_child(collision_polygon_editor); collision_polygon_editor->set_margin(MARGIN_LEFT,200); collision_polygon_editor->set_margin(MARGIN_RIGHT,230); collision_polygon_editor->set_margin(MARGIN_TOP,0); collision_polygon_editor->set_margin(MARGIN_BOTTOM,10); collision_polygon_editor->hide(); */ }
String VisualScriptInputFilter::get_output_sequence_port_text(int p_port) const { String text; switch(filters[p_port].type) { case InputEvent::NONE: { text="None"; } break; case InputEvent::KEY: { InputEventKey k = filters[p_port].key; if (k.scancode==0 && k.unicode==0) { text="No Key"; } else { if (k.scancode!=0) { text="KeyCode: "+keycode_get_string(k.scancode); } else if (k.unicode!=0) { text="Uniode: "+String::chr(k.unicode); } if (k.pressed) text+=", Pressed"; else text+=", Released"; if (k.echo) text+=", Echo"; if (k.mod.alt) text="Alt+"+text; if (k.mod.shift) text="Shift+"+text; if (k.mod.control) text="Ctrl+"+text; if (k.mod.meta) text="Meta+"+text; } } break; case InputEvent::MOUSE_MOTION: { InputEventMouseMotion mm = filters[p_port].mouse_motion; text="Mouse Motion"; String b = "Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight"; for(int i=0;i<7;i++) { if (mm.button_mask&(1<<i)) { text=b.get_slice(",",i)+"+"+text; } } if (mm.mod.alt) text="Alt+"+text; if (mm.mod.shift) text="Shift+"+text; if (mm.mod.control) text="Ctrl+"+text; if (mm.mod.meta) text="Meta+"+text; } break; case InputEvent::MOUSE_BUTTON: { InputEventMouseButton mb = filters[p_port].mouse_button; String b = "Any,Left,Right,Middle,WheelUp,WheelDown,WheelLeft,WheelRight"; text=b.get_slice(",",mb.button_index)+" Mouse Button"; if (mb.pressed) text+=", Pressed"; else text+=", Released"; if (mb.doubleclick) text+=", DblClick"; if (mb.mod.alt) text="Alt+"+text; if (mb.mod.shift) text="Shift+"+text; if (mb.mod.control) text="Ctrl+"+text; if (mb.mod.meta) text="Meta+"+text; } break; case InputEvent::JOYSTICK_MOTION: { InputEventJoystickMotion jm = filters[p_port].joy_motion; text="JoyMotion Axis "+itos(jm.axis>>1); if (jm.axis&1) text+=" > "+rtos(jm.axis_value); else text+=" < "+rtos(-jm.axis_value); } break; case InputEvent::JOYSTICK_BUTTON: { InputEventJoystickButton jb = filters[p_port].joy_button; text="JoyButton "+itos(jb.button_index); if (jb.pressed) text+=", Pressed"; else text+=", Released"; } break; case InputEvent::SCREEN_TOUCH: { InputEventScreenTouch sd = filters[p_port].screen_touch; text="Touch Finger "+itos(sd.index); if (sd.pressed) text+=", Pressed"; else text+=", Released"; } break; case InputEvent::SCREEN_DRAG: { InputEventScreenDrag sd = filters[p_port].screen_drag; text="Drag Finger "+itos(sd.index); } break; case InputEvent::ACTION: { List<PropertyInfo> pinfo; Globals::get_singleton()->get_property_list(&pinfo); int index=1; text="No Action"; for(List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) { const PropertyInfo &pi=E->get(); if (!pi.name.begins_with("input/")) continue; if (filters[p_port].action.action==index) { text="Action "+pi.name.substr(pi.name.find("/")+1,pi.name.length()); break; } index++; } if (filters[p_port].action.pressed) text+=", Pressed"; else text+=", Released"; } break; } return text+" - "+itos(p_port); }
bool VisualScriptInputFilter::_get(const StringName& p_name,Variant &r_ret) const{ if (p_name=="filter_count") { r_ret=filters.size(); return true; } if (String(p_name).begins_with("filter_")) { int idx = String(p_name).replace_first("filters_","").get_slice("/",0).to_int(); ERR_FAIL_INDEX_V(idx,filters.size(),false); String what = String(p_name).get_slice("/",1); if (what=="type") { r_ret=filters[idx].type; return true; } if (what=="device") { r_ret=filters[idx].device; return true; } switch(filters[idx].type) { case InputEvent::KEY: { if (what=="scancode") { if (filters[idx].key.scancode==0) r_ret=String(); else { r_ret=keycode_get_string(filters[idx].key.scancode); } } else if (what=="unicode") { if (filters[idx].key.unicode==0) { r_ret=String(); } else { CharType str[2]={ (CharType)filters[idx].key.unicode, 0}; r_ret=String(str); } } else if (what=="pressed") { r_ret=filters[idx].key.pressed; } else if (what=="echo") { r_ret=filters[idx].key.echo; } else if (what=="mod_alt") { r_ret=filters[idx].key.mod.alt; } else if (what=="mod_shift") { r_ret=filters[idx].key.mod.shift; } else if (what=="mod_ctrl") { r_ret=filters[idx].key.mod.control; } else if (what=="mod_meta") { r_ret=filters[idx].key.mod.meta; } else { return false; } return true; } break; case InputEvent::MOUSE_MOTION: { if (what=="button_mask") { r_ret=filters[idx].mouse_motion.button_mask; } else if (what=="mod_alt") { r_ret=filters[idx].mouse_motion.mod.alt; } else if (what=="mod_shift") { r_ret=filters[idx].mouse_motion.mod.shift; } else if (what=="mod_ctrl") { r_ret=filters[idx].mouse_motion.mod.control; } else if (what=="mod_meta") { r_ret=filters[idx].mouse_motion.mod.meta; } else { return false; } return true; } break; case InputEvent::MOUSE_BUTTON: { if (what=="button_index") { r_ret=filters[idx].mouse_button.button_index; } else if (what=="pressed") { r_ret=filters[idx].mouse_button.pressed; } else if (what=="doubleclicked") { r_ret=filters[idx].mouse_button.doubleclick; } else if (what=="mod_alt") { r_ret=filters[idx].mouse_button.mod.alt; } else if (what=="mod_shift") { r_ret=filters[idx].mouse_button.mod.shift; } else if (what=="mod_ctrl") { r_ret=filters[idx].mouse_button.mod.control; } else if (what=="mod_meta") { r_ret=filters[idx].mouse_button.mod.meta; } else { return false; } return true; } break; case InputEvent::JOYSTICK_MOTION: { if (what=="axis_index") { r_ret=filters[idx].joy_motion.axis>>1; } else if (what=="mode") { r_ret=filters[idx].joy_motion.axis&1; } else if (what=="treshold") { r_ret=filters[idx].joy_motion.axis_value; } else { return false; } return true; } break;