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.56 by elmex, Wed Apr 21 10:22:20 2010 UTC vs.
Revision 1.57 by elmex, Thu Apr 22 15:02:06 2010 UTC

867 867
868sub init { 868sub init {
869 my ($self) = @_; 869 my ($self) = @_;
870 870
871 my $vb = new Gtk2::VBox; 871 my $vb = new Gtk2::VBox;
872 $self->add_mode_button ($vb, "auto", "auto", 1); 872 #not supported anymore: $self->add_mode_button ($vb, "auto", "auto", 1);
873 $self->add_mode_button ($vb, "exit", "exit"); 873 $self->add_mode_button ($vb, "exit", "exit");
874 $self->add_mode_button ($vb, "exit (no path)", "exit_no_slay");
874 $self->add_mode_button ($vb, "connect", "connect"); 875 $self->add_mode_button ($vb, "connect", "connect");
875 876
876 $vb->pack_start (my $l = Gtk2::Label->new, 0, 0, 0); 877 $vb->pack_start (my $l = Gtk2::Label->new, 0, 0, 0);
877 $l->set_text ("connection:"); 878 $l->set_text ("connection:");
878 $vb->pack_start ($self->{pcon} = Gtk2::SpinButton->new_with_range (1, 10000, 1), 0, 1, 0); 879 $vb->pack_start ($self->{pcon} = Gtk2::SpinButton->new_with_range (1, 10000, 1), 0, 1, 0);
907 if (arch_is_exit ($_)) { 908 if (arch_is_exit ($_)) {
908 $exit = $_; 909 $exit = $_;
909 } 910 }
910 } 911 }
911 912
912 if ($mode eq 'auto') { 913 if ($mode =~ /^exit/) {
913 $conns = [] if $exit;
914 } elsif ($mode eq 'exit') {
915 $conns = []; 914 $conns = [];
916 } elsif ($mode eq 'connect') {
917 $exit = undef;
918 }
919 915
920 my $mappath = $::MAPDIR;
921
922 if ($exit) {
923 if ($self->{sel_exit}) { 916 if ($self->{sel_pos}) {
917 my $pos = delete $self->{sel_pos};
924 918
925 $exit->{hp} = $self->{sel_exit}->[3]; 919 my ($path1, $path2);
926 $exit->{sp} = $self->{sel_exit}->[4]; 920 unless ($mode eq 'exit_no_slay') {
927#$exit->{slaying} = File::Spec->abs2rel ($self->{sel_exit}->[5], $ent); 921 ($path1, $path2) =
922 exit_paths ($::MAPDIR, $pos->{path}, $mapedit->{path});
923 }
928 924
929 my $exit2 = $self->{sel_exit}->[0]; 925 if ($pos->{exit}) {
930
931 $exit2->{hp} = $x; 926 $pos->{exit}->{hp} = $x;
932 $exit2->{sp} = $y; 927 $pos->{exit}->{sp} = $y;
933
934 my ($m1, $m2) = exit_paths ($mappath, $self->{sel_exit}->[5], $mapedit->{path});
935
936 $exit2->{slaying} = $m2; 928 $pos->{exit}->{slaying} = $path2
929 if $path2 ne '';
930 }
931
932 if ($exit) {
933 $exit->{hp} = $pos->{x};
934 $exit->{sp} = $pos->{y};
937 $exit->{slaying} = $m1; 935 $exit->{slaying} = $path1
936 if $path1 ne '';
937 }
938 938
939 $self->SUPER::begin ($map, $x, $y, $mapedit); 939 $self->SUPER::begin ($map, $x, $y, $mapedit);
940 $map->change_stack ($x, $y, $as); 940 $map->change_stack ($x, $y, $as);
941 $self->SUPER::end ($map); 941 $self->SUPER::end ($map);
942 $self->SUPER::begin ($self->{sel_exit}->[1], $exit->{hp}, $exit->{sp}); 942 $self->SUPER::begin ($pos->{map}, $pos->{x}, $pos->{y});
943 $self->{sel_exit}->[1]->change_stack ($exit->{hp}, $exit->{sp}, $self->{sel_exit}->[2]); 943 $pos->{map}->change_stack ($pos->{x}, $pos->{y}, $pos->{stack});
944 $self->SUPER::end ($self->{sel_exit}->[1]); 944 $self->SUPER::end ($pos->{map});
945 945
946 quick_msg ($mapedit, "$exit->{slaying} ($exit->{hp}:$exit->{sp}) $exit->{_name} <=> $exit2->{slaying} ($exit2->{hp}:$exit2->{sp}) $exit2->{_name}", 0); 946 #bothers schmorp: quick_msg ($mapedit, "$exit->{slaying} ($exit->{hp}:$exit->{sp}) $exit->{_name} <=> $exit2->{slaying} ($exit2->{hp}:$exit2->{sp}) $exit2->{_name}", 0);
947 947
948 $::MAINWIN->{edit_collection}{pick}->edit ($map, $x, $y); 948 $::MAINWIN->{edit_collection}{pick}->edit ($map, $x, $y);
949 949
950 $self->{sel_exit} = undef; 950 delete $self->{sel_pos};
951 $self->{sel_lbl}->set_text (''); 951 $self->{sel_lbl}->set_text ('');
952 } else { 952 } else {
953 my $pth = substr $mapedit->{path}, -10;
953 $self->{sel_lbl}->set_text ("src: ($x:$y) $exit->{_name}"); 954 $self->{sel_lbl}->set_text ("src: ($x:$y) $pth");
954 $self->{sel_exit} = [$exit, $map, $as, $x, $y, $mapedit->{path}]; 955 $self->{sel_pos} = {
956 x => $x,
957 y => $y,
958 path => $mapedit->{path},
959 stack => $as,
960 map => $map,
961 exit => $exit
955 } 962 };
956 963 }
957 } elsif (@$conns) { 964 } elsif ($mode eq 'connect') {
958 for (@$conns) { 965 for (@$conns) {
959 $_->{connected} = $self->{pcon}->get_value; 966 $_->{connected} = $self->{pcon}->get_value;
960 } 967 }
961 $self->SUPER::begin ($map, $x, $y, $mapedit); 968 $self->SUPER::begin ($map, $x, $y, $mapedit);
962 $map->change_stack ($x, $y, $as); 969 $map->change_stack ($x, $y, $as);
963 $self->SUPER::end ($map); 970 $self->SUPER::end ($map);
964
965 } elsif ($self->{sel_exit}) {
966 my $exit2 = $self->{sel_exit}->[0];
967
968 $exit2->{hp} = $x;
969 $exit2->{sp} = $y;
970 delete $exit2->{slaying};
971
972 $self->SUPER::begin ($self->{sel_exit}->[1], $self->{sel_exit}->[3], $self->{sel_exit}->[4]);
973 $self->{sel_exit}->[1]->change_stack ($self->{sel_exit}->[3], $self->{sel_exit}->[4], $self->{sel_exit}->[2]);
974 $self->SUPER::end ($self->{sel_exit}->[1]);
975
976 quick_msg ($mapedit, "($self->{sel_exit}->[3]:$self->{sel_exit}->[4]) $self->{sel_exit}->[0]->{_name} => ($x:$y)", 0);
977
978 $::MAINWIN->{edit_collection}{pick}->edit ($map, $x, $y);
979
980 delete $self->{sel_exit};
981 $self->{sel_lbl}->set_text ('');
982
983 } else {
984 quick_msg ($mapedit, "no exit or connection object found");
985 } 971 }
986} 972}
987
988 973
989=head1 AUTHOR 974=head1 AUTHOR
990 975
991 Marc Lehmann <schmorp@schmorp.de> 976 Marc Lehmann <schmorp@schmorp.de>
992 http://home.schmorp.de/ 977 http://home.schmorp.de/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines