… | |
… | |
624 | $idx = stack_find ($stack, 'from_top', sub { $_[0]->{_name} eq $pick_name }); |
624 | $idx = stack_find ($stack, 'from_top', sub { $_[0]->{_name} eq $pick_name }); |
625 | } |
625 | } |
626 | } |
626 | } |
627 | } |
627 | } |
628 | |
628 | |
|
|
629 | package GCE::EditAction::Connect; |
|
|
630 | use Storable qw/dclone/; |
|
|
631 | use GCE::Util; |
|
|
632 | use Gtk2; |
|
|
633 | use File::Spec::Functions; |
|
|
634 | use strict; |
|
|
635 | |
|
|
636 | our @ISA = qw/GCE::EditAction::RadioModed/; |
|
|
637 | |
|
|
638 | sub name { 'connect' } |
|
|
639 | |
|
|
640 | sub init { |
|
|
641 | my ($self) = @_; |
|
|
642 | |
|
|
643 | my $vb = new Gtk2::VBox; |
|
|
644 | $self->add_mode_button ($vb, "exit", "exit"); |
|
|
645 | # $self->add_mode_button ($vb, "triggers", "trig"); |
|
|
646 | $vb->pack_start ($self->{sel_lbl} = Gtk2::Label->new, 0, 0, 0); |
|
|
647 | $self->tool_widget ($vb); |
|
|
648 | } |
|
|
649 | |
|
|
650 | sub want_cursor { 0 } |
|
|
651 | |
|
|
652 | sub begin { |
|
|
653 | my ($self, $map, $x, $y, $mapedit) = @_; |
|
|
654 | |
|
|
655 | $self->edit ($map, $x, $y, $mapedit); |
|
|
656 | } |
|
|
657 | |
|
|
658 | sub edit { |
|
|
659 | my ($self, $map, $x, $y, $mapedit) = @_; |
|
|
660 | |
|
|
661 | my $pick = $::MAINWIN->get_pick; |
|
|
662 | my $as = $map->get ($x, $y); |
|
|
663 | |
|
|
664 | my $exit; |
|
|
665 | for (@$as) { |
|
|
666 | my $a = $Crossfire::ARCH{$_->{_name}}; |
|
|
667 | if ($a->{type} eq '66') { |
|
|
668 | $exit = $_; |
|
|
669 | } |
|
|
670 | } |
|
|
671 | |
|
|
672 | if ($exit) { |
|
|
673 | if ($self->{sel_exit}) { |
|
|
674 | my $ent = catfile ($Crossfire::LIB, 'maps'); |
|
|
675 | |
|
|
676 | $exit->{hp} = $self->{sel_exit}->[3]; |
|
|
677 | $exit->{sp} = $self->{sel_exit}->[4]; |
|
|
678 | $exit->{slaying} = File::Spec->abs2rel ($self->{sel_exit}->[5], $ent); |
|
|
679 | |
|
|
680 | my $exit2 = $self->{sel_exit}->[0]; |
|
|
681 | |
|
|
682 | $exit2->{hp} = $x; |
|
|
683 | $exit2->{sp} = $y; |
|
|
684 | $exit2->{slaying} = File::Spec->abs2rel ($mapedit->{path}, $ent); |
|
|
685 | |
|
|
686 | unless ($exit2->{slaying} =~ m/^\.\./) { |
|
|
687 | $exit2->{slaying} = '/' . $exit2->{slaying}; |
|
|
688 | } |
|
|
689 | unless ($exit->{slaying} =~ m/^\.\./) { |
|
|
690 | $exit->{slaying} = '/' . $exit->{slaying}; |
|
|
691 | } |
|
|
692 | |
|
|
693 | $self->SUPER::begin ($map, $x, $y, $mapedit); |
|
|
694 | $map->change_stack ($x, $y, $as); |
|
|
695 | $self->SUPER::end ($map); |
|
|
696 | $self->SUPER::begin ($self->{sel_exit}->[1], $exit->{hp}, $exit->{sp}); |
|
|
697 | $self->{sel_exit}->[1]->change_stack ($exit->{hp}, $exit->{sp}, $self->{sel_exit}->[2]); |
|
|
698 | $self->SUPER::end ($self->{sel_exit}->[1]); |
|
|
699 | |
|
|
700 | quick_msg ($mapedit, "$exit->{slaying} ($x:$y) $exit->{_name} <=> $exit2->{slaying} ($exit2->{hp}:$exit2->{sp}) $exit2->{_name}", 0); |
|
|
701 | |
|
|
702 | $::MAINWIN->{edit_collection}{pick}->edit ($map, $x, $y); |
|
|
703 | |
|
|
704 | $self->{sel_exit} = undef; |
|
|
705 | $self->{sel_lbl}->set_text (''); |
|
|
706 | } else { |
|
|
707 | $self->{sel_lbl}->set_text ("src: ($x:$y) $exit->{_name}"); |
|
|
708 | $self->{sel_exit} = [$exit, $map, $as, $x, $y, $mapedit->{path}]; |
|
|
709 | } |
|
|
710 | } else { |
|
|
711 | quick_msg ($mapedit, "no exit object found"); |
|
|
712 | } |
|
|
713 | |
|
|
714 | # $self->stack_action ($as, dclone ($pick)); |
|
|
715 | #$map->change_stack ($x, $y, $as); # insert_arch_stack_layer ($as, $arch)); |
|
|
716 | } |
|
|
717 | |
|
|
718 | sub end {} |
629 | |
719 | |
630 | |
720 | |
631 | =head1 AUTHOR |
721 | =head1 AUTHOR |
632 | |
722 | |
633 | Marc Lehmann <schmorp@schmorp.de> |
723 | Marc Lehmann <schmorp@schmorp.de> |