Method: FXMapperWindow.paste_selected
- Defined in:
- lib/IFMapper/FXMapperWindow.rb
.paste_selected(map) ⇒ Object
Paste selected elements
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 652 def self.paste_selected(map) return if not @@copy_buffer return map. if map. sel = @@copy_buffer pos = map.find_empty_area( sel[0] ) if not pos w = FXWarningBox.new( map.window, ERR_NO_FREE_ROOM) w.execute else map.clear_selection # Add rooms r_to_nr = {} # orig room to new room hash rooms = sel[0] rooms.each { |r| nr = map.new_room(r.x + pos[0], r.y + pos[1]) nr.selected = true nr.copy(r) # copy the room data r_to_nr[r] = nr } if rooms.empty? # Add connections only (no rooms copied) sel[1].each { |c| exitA, exitB = c.dirs roomA = c.roomA roomB = c.roomB sect = map.sections[map.section] if not sect.rooms.include?(roomA) or (roomB and not sect.rooms.include?(roomB)) next end begin nc = map.new_connection(roomA, exitA, roomB, exitB) nc.selected = true nc.dir = c.dir nc.type = c.type rescue end } else # Add connections sel[1].each { |c| exitA, exitB = c.dirs roomA = r_to_nr[c.roomA] if c.roomB roomB = r_to_nr[c.roomB] else roomB = nil end next if not roomA begin nc = map.new_connection(roomA, exitA, roomB, exitB) nc.selected = true nc.dir = c.dir nc.type = c.type rescue Section::ConnectionError => e puts c puts e end } end map.create_pathmap map.draw end end |