ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/GCE/EditAction.pm
(Generate patch)

Comparing deliantra/gde/GCE/EditAction.pm (file contents):
Revision 1.38 by elmex, Thu Jun 1 14:33:14 2006 UTC vs.
Revision 1.39 by elmex, Thu Jun 1 15:02:59 2006 UTC

794 794
795sub init { 795sub init {
796 my ($self) = @_; 796 my ($self) = @_;
797 797
798 my $vb = new Gtk2::VBox; 798 my $vb = new Gtk2::VBox;
799 $self->add_mode_button ($vb, "auto", "auto", 1);
799 $self->add_mode_button ($vb, "exit", "exit"); 800 $self->add_mode_button ($vb, "exit", "exit");
801 $self->add_mode_button ($vb, "connect", "connect");
800 802
801 $vb->pack_start (my $l = Gtk2::Label->new, 0, 0, 0); 803 $vb->pack_start (my $l = Gtk2::Label->new, 0, 0, 0);
802 $l->set_text ("connection:"); 804 $l->set_text ("connection:");
803 $vb->pack_start ($self->{pcon} = Gtk2::SpinButton->new_with_range (1, 10000, 1), 0, 1, 0); 805 $vb->pack_start ($self->{pcon} = Gtk2::SpinButton->new_with_range (1, 10000, 1), 0, 1, 0);
804 $vb->pack_start ($self->{sel_lbl} = Gtk2::Label->new, 0, 0, 0); 806 $vb->pack_start ($self->{sel_lbl} = Gtk2::Label->new, 0, 0, 0);
815 my ($self, $map, $x, $y, $mapedit) = @_; 817 my ($self, $map, $x, $y, $mapedit) = @_;
816 818
817 my $pick = $::MAINWIN->get_pick; 819 my $pick = $::MAINWIN->get_pick;
818 my $as = $map->get ($x, $y); 820 my $as = $map->get ($x, $y);
819 821
822 my $mode = $self->get_mode;
823
820 my $exit; 824 my $exit;
821 my $conns = []; 825 my $conns = [];
822 for (@$as) { 826 for (@$as) {
823 if (arch_is_connector ($_)) { 827 if (arch_is_connector ($_)) {
824 push @$conns, $_; 828 push @$conns, $_;
829 }
825 } elsif (arch_is_exit ($_)) { 830 if (arch_is_exit ($_)) {
826 $exit = $_; 831 $exit = $_;
827 } 832 }
833 }
834
835 if ($mode eq 'auto') {
836 $conns = [] if $exit;
837 } elsif ($mode eq 'exit') {
838 $conns = [];
839 } elsif ($mode eq 'connect') {
840 $exit = undef;
828 } 841 }
829 842
830 my $mappath = $::CFG->{MAPDIR}; 843 my $mappath = $::CFG->{MAPDIR};
831 844
832 if ($exit) { 845 if ($exit) {
861 $self->{sel_lbl}->set_text (''); 874 $self->{sel_lbl}->set_text ('');
862 } else { 875 } else {
863 $self->{sel_lbl}->set_text ("src: ($x:$y) $exit->{_name}"); 876 $self->{sel_lbl}->set_text ("src: ($x:$y) $exit->{_name}");
864 $self->{sel_exit} = [$exit, $map, $as, $x, $y, $mapedit->{path}]; 877 $self->{sel_exit} = [$exit, $map, $as, $x, $y, $mapedit->{path}];
865 } 878 }
866 } elsif (@{$conns}) { 879 } elsif (@$conns) {
867 for (@{$conns}) { 880 for (@$conns) {
868 $_->{connected} = $self->{pcon}->get_value; 881 $_->{connected} = $self->{pcon}->get_value;
869 } 882 }
870 $self->SUPER::begin ($map, $x, $y, $mapedit); 883 $self->SUPER::begin ($map, $x, $y, $mapedit);
871 $map->change_stack ($x, $y, $as); 884 $map->change_stack ($x, $y, $as);
872 $self->SUPER::end ($map); 885 $self->SUPER::end ($map);
886 } elsif ($self->{sel_exit}) {
887 my $exit2 = $self->{sel_exit}->[0];
888
889 $exit2->{hp} = $x;
890 $exit2->{sp} = $y;
891 $exit2->{slaying} = undef;
892
893 unless ($exit2->{slaying} =~ m/^\.\./) {
894 $exit2->{slaying} = '/' . $exit2->{slaying};
895 }
896
897 $self->SUPER::begin ($self->{sel_exit}->[1], $self->{sel_exit}->[3], $self->{sel_exit}->[4]);
898 $self->{sel_exit}->[1]->change_stack ($self->{sel_exit}->[3], $self->{sel_exit}->[4], $self->{sel_exit}->[2]);
899 $self->SUPER::end ($self->{sel_exit}->[1]);
900
901 quick_msg ($mapedit, "($self->{sel_exit}->[3]:$self->{sel_exit}->[4]) $self->{sel_exit}->[0]->{_name} => ($x:$y) $exit2->{_name}", 0);
902
903 $::MAINWIN->{edit_collection}{pick}->edit ($map, $x, $y);
904
905 $self->{sel_exit} = undef;
906 $self->{sel_lbl}->set_text ('');
873 } else { 907 } else {
874 if ($self->{sel_exit}) {
875
876 my $exit2 = $self->{sel_exit}->[0];
877
878 $exit2->{hp} = $x;
879 $exit2->{sp} = $y;
880 $exit2->{slaying} = undef;
881
882 unless ($exit2->{slaying} =~ m/^\.\./) {
883 $exit2->{slaying} = '/' . $exit2->{slaying};
884 }
885
886 $self->SUPER::begin ($self->{sel_exit}->[1], $exit->{hp}, $exit->{sp});
887 $self->{sel_exit}->[1]->change_stack ($self->{sel_exit}->[3], $self->{sel_exit}->[4], $self->{sel_exit}->[2]);
888 $self->SUPER::end ($self->{sel_exit}->[1]);
889
890 quick_msg ($mapedit, "($self->{sel_exit}->[3]:$self->{sel_exit}->[4]) $self->{sel_exit}->[0]->{_name} => ($x:$y) $exit2->{_name}", 0);
891
892 $::MAINWIN->{edit_collection}{pick}->edit ($map, $x, $y);
893
894 $self->{sel_exit} = undef;
895 $self->{sel_lbl}->set_text ('');
896 } else {
897 quick_msg ($mapedit, "no exit or connection object found"); 908 quick_msg ($mapedit, "no exit or connection object found");
898 }
899 } 909 }
900} 910}
901 911
902 912
903=head1 AUTHOR 913=head1 AUTHOR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines