diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/plugins/canvas_item_editor_plugin.cpp | 4 | ||||
-rw-r--r-- | tools/editor/plugins/collision_polygon_editor_plugin.cpp | 22 | ||||
-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_editor.cpp | 7 | ||||
-rw-r--r-- | tools/editor/scene_tree_editor.h | 2 |
7 files changed, 111 insertions, 28 deletions
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 74c1d0d825..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)); 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/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_editor.cpp b/tools/editor/scene_tree_editor.cpp index 78f09aa767..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() { 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(); |