diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/editor_file_system.cpp | 6 | ||||
-rw-r--r-- | tools/editor/editor_help.cpp | 2 | ||||
-rw-r--r-- | tools/editor/editor_node.cpp | 4 | ||||
-rw-r--r-- | tools/editor/editor_settings.cpp | 2 | ||||
-rw-r--r-- | tools/editor/plugins/canvas_item_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | tools/editor/plugins/collision_polygon_editor_plugin.cpp | 22 | ||||
-rw-r--r-- | tools/editor/plugins/shader_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | tools/editor/plugins/spatial_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | tools/editor/plugins/tile_map_editor_plugin.cpp | 83 | ||||
-rw-r--r-- | tools/editor/plugins/tile_map_editor_plugin.h | 3 | ||||
-rw-r--r-- | tools/editor/plugins/tile_set_editor_plugin.cpp | 18 | ||||
-rw-r--r-- | tools/editor/scene_tree_dock.cpp | 2 | ||||
-rw-r--r-- | tools/editor/scene_tree_editor.cpp | 10 | ||||
-rw-r--r-- | tools/editor/scene_tree_editor.h | 2 |
14 files changed, 122 insertions, 42 deletions
diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index 861b6a9e3c..daba52be03 100644 --- a/tools/editor/editor_file_system.cpp +++ b/tools/editor/editor_file_system.cpp @@ -630,7 +630,7 @@ void EditorFileSystem::scan_sources() { s.priority=Thread::PRIORITY_LOW; thread_sources = Thread::create(_thread_func_sources,this,s); //tree->hide(); - print_line("SCAN BEGIN!"); + //print_line("SCAN BEGIN!"); //progress->show(); } @@ -724,7 +724,7 @@ void EditorFileSystem::_notification(int p_what) { Thread::wait_to_finish(thread_sources); memdelete(thread_sources); thread_sources=NULL; - print_line("sources changed: "+itos(sources_changed.size())); + //print_line("sources changed: "+itos(sources_changed.size())); emit_signal("sources_changed",sources_changed.size()>0); } } else if (!scanning) { @@ -748,7 +748,7 @@ void EditorFileSystem::_notification(int p_what) { thread=NULL; emit_signal("filesystem_changed"); emit_signal("sources_changed",sources_changed.size()>0); - print_line("initial sources changed: "+itos(sources_changed.size())); + //print_line("initial sources changed: "+itos(sources_changed.size())); diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index 75b902dc64..19e65f3844 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -1333,7 +1333,7 @@ EditorHelp::EditorHelp(EditorNode *p_editor) { history_pos=0; scroll_locked=false; select_locked=false; - add_to_group("unhandled_key_input"); + set_process_unhandled_key_input(true); h_split->set_split_offset(200); class_list->connect("cell_selected",this,"_tree_item_selected"); class_desc->hide(); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 197754cf81..4ed565fdc3 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -2711,8 +2711,6 @@ Error EditorNode::load_scene(const String& p_scene) { return ERR_FILE_NOT_FOUND; } - print_line("OPEN FILENAME: "+new_scene->get_filename()); - /* Node *old_scene = edited_scene; _hide_top_editors(); @@ -3932,7 +3930,7 @@ EditorNode::EditorNode() { file_templates->set_mode(FileDialog::MODE_OPEN_FILE); file_templates->set_access(FileDialog::ACCESS_FILESYSTEM); file_templates->clear_filters(); - file_templates->add_filter("*.zip ; Zip Template Package"); + file_templates->add_filter("*.tpz ; Template Package"); file = memnew( FileDialog ); diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 6d3384d0f7..e09e090b16 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -321,7 +321,7 @@ void EditorSettings::scan_plugins() { d->list_dir_begin(); String base = d->get_current_dir(); - print_line("list diring on: "+base); + //print_line("list diring on: "+base); while(true) { String p = d->get_next(); if (p=="") diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 5144092402..1a365d7f32 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -2142,18 +2142,22 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { hb->add_child(lock_button); lock_button->connect("pressed",this,"_popup_callback",varray(LOCK_SELECTED)); + lock_button->set_tooltip("Lock the selected object in-place (can't be moved)."); unlock_button = memnew( ToolButton ); hb->add_child(unlock_button); unlock_button->connect("pressed",this,"_popup_callback",varray(UNLOCK_SELECTED)); + unlock_button->set_tooltip("Unlock the selected object (can be moved)."); group_button = memnew( ToolButton ); hb->add_child(group_button); group_button->connect("pressed",this,"_popup_callback",varray(GROUP_SELECTED)); + group_button->set_tooltip("Makes sure the object's' children are not selectable."); ungroup_button = memnew( ToolButton ); hb->add_child(ungroup_button); ungroup_button->connect("pressed",this,"_popup_callback",varray(UNGROUP_SELECTED)); + ungroup_button->set_tooltip("Restores the object's' children ability to be selected."); hb->add_child(memnew(VSeparator)); @@ -2245,7 +2249,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { //zoom=0.5; singleton=this; editor->get_animation_editor()->connect("keying_changed",this,"_keying_changed"); - add_to_group("unhandled_key_input"); + set_process_unhandled_key_input(true); can_move_pivot=false; pixel_snap=false; drag=DRAG_NONE; diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp index c083764723..fc40320e29 100644 --- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp @@ -120,7 +120,9 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { Vector2 gpoint = Point2(mb.x,mb.y); - Vector2 cpoint = xform.affine_inverse().xform(gpoint); + Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint); + cpoint=snap_point(cpoint); + cpoint = node->get_global_transform().affine_inverse().xform(cpoint); Vector<Vector2> poly = node->get_polygon(); @@ -138,9 +140,9 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { if (!wip_active) { wip.clear(); - wip.push_back( snap_point(cpoint) ); + wip.push_back( cpoint ); wip_active=true; - edited_point_pos=snap_point(cpoint); + edited_point_pos=cpoint; canvas_item_editor->get_viewport_control()->update(); edited_point=1; return true; @@ -154,7 +156,7 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { return true; } else { - wip.push_back( snap_point(cpoint) ); + wip.push_back( cpoint ); edited_point=wip.size(); canvas_item_editor->get_viewport_control()->update(); return true; @@ -216,9 +218,9 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { if (closest_idx>=0) { pre_move_edit=poly; - poly.insert(closest_idx+1,snap_point(xform.affine_inverse().xform(closest_pos))); + poly.insert(closest_idx+1,xform.affine_inverse().xform(closest_pos)); edited_point=closest_idx+1; - edited_point_pos=snap_point(xform.affine_inverse().xform(closest_pos)); + edited_point_pos=xform.affine_inverse().xform(closest_pos); node->set_polygon(poly); canvas_item_editor->get_viewport_control()->update(); return true; @@ -320,11 +322,11 @@ bool CollisionPolygonEditor::forward_input_event(const InputEvent& p_event) { if (edited_point!=-1 && (wip_active || mm.button_mask&BUTTON_MASK_LEFT)) { - - Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - Vector2 gpoint = Point2(mm.x,mm.y); - edited_point_pos = snap_point(xform.affine_inverse().xform(gpoint)); + Vector2 cpoint = canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint); + cpoint=snap_point(cpoint); + edited_point_pos = node->get_global_transform().affine_inverse().xform(cpoint); + canvas_item_editor->get_viewport_control()->update(); } diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp index 4670005cf4..9b6b07dc2e 100644 --- a/tools/editor/plugins/shader_editor_plugin.cpp +++ b/tools/editor/plugins/shader_editor_plugin.cpp @@ -153,7 +153,7 @@ void ShaderTextEditor::_validate_script() { void ShaderTextEditor::_bind_methods() { - ADD_SIGNAL( MethodInfo("script_changed") ); + //ADD_SIGNAL( MethodInfo("script_changed") ); } diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 8161025731..98108c2de7 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -3334,7 +3334,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { scenario_debug=VisualServer::SCENARIO_DEBUG_DISABLED; - add_to_group("unhandled_key_input"); + set_process_unhandled_key_input(true); add_to_group("_spatial_editor_group"); } diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index 27e964cc47..09f26c8ca0 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -74,7 +74,7 @@ int TileMapEditor::get_selected_tile() const { return item->get_metadata(0); } -void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bool p_flip_v) { +void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bool p_flip_v,bool p_with_undo) { ERR_FAIL_COND(!node); @@ -85,15 +85,15 @@ void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bo if (p_value==prev_val && p_flip_h==prev_flip_h && p_flip_v==prev_flip_v) return; //check that it's actually different - node->set_cell(p_pos.x,p_pos.y,p_value,p_flip_h,p_flip_v); -#if 0 -//not yet - undo_redo->create_action("Set Tile"); - undo_redo->add_do_method(node,"set_cell",p_pos.x,p_pos.y,p_value,p_flip_h,p_flip_v); - undo_redo->add_undo_method(node,"set_cell",p_pos.x,p_pos.y,prev_val,prev_flip_h,prev_flip_v); - undo_redo->commit_action(); -#endif + if (p_with_undo) { + undo_redo->add_do_method(node,"set_cell",p_pos.x,p_pos.y,p_value,p_flip_h,p_flip_v); + undo_redo->add_undo_method(node,"set_cell",p_pos.x,p_pos.y,prev_val,prev_flip_h,prev_flip_v); + } else { + + node->set_cell(p_pos.x,p_pos.y,p_value,p_flip_h,p_flip_v); + + } } @@ -199,11 +199,13 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { } } + undo_redo->create_action("Duplicate"); for (List<_TileMapEditorCopyData>::Element *E=dupdata.front();E;E=E->next()) { - _set_cell(E->get().pos+ofs,E->get().cell,E->get().flip_h,E->get().flip_v); + _set_cell(E->get().pos+ofs,E->get().cell,E->get().flip_h,E->get().flip_v,true); } + undo_redo->commit_action(); tool=TOOL_NONE; canvas_item_editor->update(); @@ -258,6 +260,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { } undo_redo->commit_action(); + paint_undo.clear(); } } tool=TOOL_NONE; @@ -276,12 +279,38 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { tool=TOOL_ERASING; Point2i local =(xform_inv.xform(Point2(mb.x,mb.y))/snap).floor(); + paint_undo.clear(); + CellOp op; + op.idx = node->get_cell(local.x,local.y); + if (op.idx>=0) { + if (node->is_cell_x_flipped(local.x,local.y)) + op.xf=true; + if (node->is_cell_y_flipped(local.x,local.y)) + op.yf=true; + } + paint_undo[local]=op; + //node->set_cell(local.x,local.y,id,mirror_x->is_pressed(),mirror_y->is_pressed()); + //return true; _set_cell(local,TileMap::INVALID_CELL); return true; } else { if (tool==TOOL_ERASING) { + if (paint_undo.size()) { + undo_redo->create_action("Erase TileMap"); + for(Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) { + + Point2i p=E->key(); + //undo_redo->add_do_method(node,"set_cell",p.x,p.y,node->get_cell(p.x,p.y),node->is_cell_x_flipped(p.x,p.y),node->is_cell_y_flipped(p.x,p.y)); + _set_cell(p,TileMap::INVALID_CELL,false,false,true); + undo_redo->add_undo_method(node,"set_cell",p.x,p.y,E->get().idx,E->get().xf,E->get().yf); + } + + undo_redo->commit_action(); + paint_undo.clear(); + + } tool=TOOL_NONE; return true; } @@ -347,7 +376,20 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { } if (tool==TOOL_ERASING) { - Point2i local =over_tile; + Point2i local =over_tile; + if (!paint_undo.has(over_tile)) { + + CellOp op; + op.idx = node->get_cell(over_tile.x,over_tile.y); + if (op.idx>=0) { + if (node->is_cell_x_flipped(over_tile.x,over_tile.y)) + op.xf=true; + if (node->is_cell_y_flipped(over_tile.x,over_tile.y)) + op.yf=true; + } + paint_undo[over_tile]=op; + } + //node->set_cell(over_tile.x,over_tile.y,id,mirror_x->is_pressed(),mirror_y->is_pressed()); _set_cell(local,TileMap::INVALID_CELL); return true; } @@ -362,6 +404,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { if (k.pressed && k.scancode==KEY_DELETE && selection_active && tool==TOOL_NONE) { + undo_redo->create_action("Delete"); for(int i=selection.pos.y;i<=selection.pos.y+selection.size.y;i++) { for(int j=selection.pos.x;j<=selection.pos.x+selection.size.x;j++) { @@ -370,13 +413,14 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { _set_cell(Point2i(j,i),TileMap::INVALID_CELL); } } + undo_redo->commit_action(); selection_active=false; canvas_item_editor->update(); return true; } - if (mouse_over && k.pressed && k.scancode==KEY_A && tool==TOOL_NONE) { + if (mouse_over && k.pressed && k.scancode==KEY_A && tool==TOOL_NONE && !k.mod.command) { /*int cell = node->get_cell(over_tile.x,over_tile.y); if (cell!=TileMap::INVALID_CELL) { @@ -389,7 +433,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { canvas_item_editor->update(); return true; } - if (mouse_over && k.pressed && k.scancode==KEY_S && tool==TOOL_NONE) { + if (mouse_over && k.pressed && k.scancode==KEY_S && tool==TOOL_NONE && !k.mod.command) { /* @@ -550,6 +594,8 @@ void TileMapEditor::edit(Node *p_tile_map) { canvas_item_editor=CanvasItemEditor::get_singleton()->get_viewport_control(); } + if (node) + node->disconnect("settings_changed",this,"_tileset_settings_changed"); if (p_tile_map) { node=p_tile_map->cast_to<TileMap>(); @@ -575,7 +621,16 @@ void TileMapEditor::edit(Node *p_tile_map) { _update_palette(); } + if (node) + node->connect("settings_changed",this,"_tileset_settings_changed"); + +} + +void TileMapEditor::_tileset_settings_changed() { + _update_palette(); + if (canvas_item_editor) + canvas_item_editor->update(); } void TileMapEditor::_pane_drag(const Point2& p_to) { @@ -597,11 +652,13 @@ void TileMapEditor::_bind_methods() { ObjectTypeDB::bind_method(_MD("_pane_drag"),&TileMapEditor::_pane_drag); ObjectTypeDB::bind_method(_MD("_canvas_mouse_enter"),&TileMapEditor::_canvas_mouse_enter); ObjectTypeDB::bind_method(_MD("_canvas_mouse_exit"),&TileMapEditor::_canvas_mouse_exit); + ObjectTypeDB::bind_method(_MD("_tileset_settings_changed"),&TileMapEditor::_tileset_settings_changed); } TileMapEditor::TileMapEditor(EditorNode *p_editor) { + node=NULL; canvas_item_editor=NULL; editor=p_editor; undo_redo = editor->get_undo_redo(); diff --git a/tools/editor/plugins/tile_map_editor_plugin.h b/tools/editor/plugins/tile_map_editor_plugin.h index cd037113b0..2336507f1b 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.h +++ b/tools/editor/plugins/tile_map_editor_plugin.h @@ -92,10 +92,11 @@ class TileMapEditor : public HBoxContainer { void _canvas_draw(); void _menu_option(int p_option); - void _set_cell(const Point2i& p_pos,int p_value,bool p_flip_h=false, bool p_flip_v=false); + void _set_cell(const Point2i& p_pos, int p_value, bool p_flip_h=false, bool p_flip_v=false, bool p_with_undo=false); void _canvas_mouse_enter(); void _canvas_mouse_exit(); + void _tileset_settings_changed(); friend class TileMapEditorPlugin; diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp index 7d9b55433e..6026cda4dc 100644 --- a/tools/editor/plugins/tile_set_editor_plugin.cpp +++ b/tools/editor/plugins/tile_set_editor_plugin.cpp @@ -72,8 +72,16 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me p_library->tile_set_texture(id,texture); + Vector2 phys_offset = mi->get_offset(); + if (mi->is_centered()) { - p_library->tile_set_texture_offset(id,texture->get_size()/2); + Size2 s; + if (mi->is_region()) { + s=mi->get_region_rect().size; + } else { + s=texture->get_size(); + } + phys_offset+=-s/2; } if (mi->is_region()) { p_library->tile_set_region(id,mi->get_region_rect()); @@ -90,15 +98,21 @@ void TileSetEditor::_import_scene(Node *scene, Ref<TileSet> p_library, bool p_me if (sb->get_shape_count()==0) continue; Ref<Shape2D> collision=sb->get_shape(0); - if (collision.is_valid()) + if (collision.is_valid()) { collisions.push_back(collision); + } } if (collisions.size()) { p_library->tile_set_shapes(id,collisions); + p_library->tile_set_shape_offset(id,-phys_offset); + } else { + p_library->tile_set_shape_offset(id,Vector2()); + } + p_library->tile_set_texture_offset(id,Vector2()); } } diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 9a43cbfe57..1810139f2a 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -1196,7 +1196,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor,Node *p_scene_root,EditorSelec file = memnew( FileDialog ); add_child(file); file->connect("file_selected",this,"instance"); - add_to_group("unhandled_key_input"); + set_process_unhandled_key_input(true); delete_dialog = memnew( ConfirmationDialog ); add_child(delete_dialog); diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index 162475cb9f..b5928efdac 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -398,6 +398,7 @@ void SceneTreeEditor::_notification(int p_what) { get_scene()->disconnect("node_removed",this,"_node_removed"); _update_tree(); } + } @@ -699,10 +700,12 @@ void SceneTreeDialog::_notification(int p_what) { get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size())); } - if (p_what==NOTIFICATION_POST_POPUP) { - + if (p_what==NOTIFICATION_VISIBILITY_CHANGED && is_visible()) { + tree->update_tree(); } + + } void SceneTreeDialog::_cancel() { @@ -715,8 +718,7 @@ void SceneTreeDialog::_cancel() { void SceneTreeDialog::_select() { if (tree->get_selected()) { - Node *scene = EditorNode::get_singleton()->get_edited_scene(); - emit_signal("selected","/root/" + scene->get_parent()->get_path_to(tree->get_selected())); + emit_signal("selected",tree->get_selected()->get_path()); hide(); } } diff --git a/tools/editor/scene_tree_editor.h b/tools/editor/scene_tree_editor.h index edd67a4047..fafaffc10c 100644 --- a/tools/editor/scene_tree_editor.h +++ b/tools/editor/scene_tree_editor.h @@ -110,6 +110,8 @@ public: void set_can_rename(bool p_can_rename) { can_rename=p_can_rename; } void set_editor_selection(EditorSelection *p_selection); + void update_tree() { _update_tree(); } + SceneTreeEditor(bool p_label=true,bool p_can_rename=false, bool p_can_open_instance=false); ~SceneTreeEditor(); |