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.22 by elmex, Fri Mar 17 17:59:43 2006 UTC vs.
Revision 1.23 by elmex, Sun Mar 19 19:30:38 2006 UTC

117} 117}
118 118
119package GCE::EditAction::Pick; 119package GCE::EditAction::Pick;
120use strict; 120use strict;
121 121
122our @ISA = qw/GCE::EditAction/; 122our @ISA = qw/GCE::EditAction::RadioModed/;
123 123
124sub name { 'pick' } 124sub name { 'pick' }
125 125
126sub want_cursor { 0 } 126sub want_cursor { 0 }
127 127
128sub special_arrow { 'GDK_HAND2' } 128sub special_arrow { 'GDK_HAND2' }
129 129
130sub init {
131 my ($self) = @_;
132
133 my $vb = new Gtk2::VBox;
134 $vb->pack_start ($self->{only_attr} = Gtk2::CheckButton->new ('pick attr'), 0, 1, 0);
135 $self->{widget} = $vb;
136}
137
130sub begin { 138sub begin {
131 my ($self, $map, $x, $y) = @_; 139 my ($self, $map, $x, $y) = @_;
132
133 $self->SUPER::begin ($map, $x, $y);
134 $self->edit ($map, $x, $y); 140 $self->edit ($map, $x, $y);
135} 141}
136 142
137sub edit { 143sub edit {
138 my ($self, $map, $x, $y) = @_; 144 my ($self, $map, $x, $y) = @_;
145
146 $::MAINWIN->update_stack_view ($map, $x, $y);
139 147
140 my $cstack = $map->get ($x, $y); 148 my $cstack = $map->get ($x, $y);
141 149
142 my $arch = $cstack->[-1]; 150 my $arch = $cstack->[-1];
143 151
148 $y = $arch->{virtual_y}; 156 $y = $arch->{virtual_y};
149 $arch = $arch->{_virtual}; 157 $arch = $arch->{_virtual};
150 $cstack = $map->get ($x, $y); 158 $cstack = $map->get ($x, $y);
151 } 159 }
152 160
161 unless ($self->{only_attr}->get_active) {
153 $::MAINWIN->set_pick ($arch) 162 $::MAINWIN->set_pick ($arch)
154 if @$cstack; 163 if @$cstack;
164 }
155 165
156 $::MAINWIN->update_attr_editor ($arch, sub { 166 $::MAINWIN->update_attr_editor ($arch, sub {
157 $map->change_begin (ref $self); 167 $map->change_begin (ref $self);
158 $map->change_stack ($x, $y, $cstack); 168 $map->change_stack ($x, $y, $cstack);
159 # XXX: Put this into a generic function!!! See also EditTools.pm 169 # XXX: Put this into a generic function!!! See also EditTools.pm
162 splice @{ $map->{undo_stack} ||= [] }, 172 splice @{ $map->{undo_stack} ||= [] },
163 $map->{undo_stack_pos}++, 1e6, 173 $map->{undo_stack_pos}++, 1e6,
164 $changeset; 174 $changeset;
165 } 175 }
166 }); 176 });
167
168 $::MAINWIN->update_stack_view ($map, $x, $y);
169} 177}
178
179sub end {}
170 180
171package GCE::EditAction::Perl; 181package GCE::EditAction::Perl;
172 182
173use GCE::Util; 183use GCE::Util;
174use Gtk2; 184use Gtk2;
503 } 513 }
504 } 514 }
505} 515}
506 516
507sub paste { 517sub paste {
508 my ($self, $xp, $yp) = @_; 518 my ($self, $map, $xp, $yp) = @_;
509 519
510 return unless $self->{selection}->{a}; 520 return unless $self->{selection}->{a};
511 521
512 my ($x1, $y1); 522 my ($x1, $y1);
513 523
515 ($x1, $y1) = ($xp, $yp); 525 ($x1, $y1) = ($xp, $yp);
516 } else { 526 } else {
517 ($x1, $y1) = @{$self->{selection}->{a}}; 527 ($x1, $y1) = @{$self->{selection}->{a}};
518 } 528 }
519 529
520 my $map = $self->{selection}->{map}; 530 $map ||= $self->{selection}->{map};
521 531
522 my $p_o_top = $self->{paste_top}->get_active * 1; 532 my $p_o_top = $self->{paste_top}->get_active * 1;
523 533
524 my $w = $self->{copy_coords}->[2] - $self->{copy_coords}->[0]; 534 my $w = $self->{copy_coords}->[2] - $self->{copy_coords}->[0];
525 my $h = $self->{copy_coords}->[3] - $self->{copy_coords}->[1]; 535 my $h = $self->{copy_coords}->[3] - $self->{copy_coords}->[1];
829 my $exit2 = $self->{sel_exit}->[0]; 839 my $exit2 = $self->{sel_exit}->[0];
830 840
831 $exit2->{hp} = $x; 841 $exit2->{hp} = $x;
832 $exit2->{sp} = $y; 842 $exit2->{sp} = $y;
833 $exit2->{slaying} = File::Spec->abs2rel ($mapedit->{path}, $ent); 843 $exit2->{slaying} = File::Spec->abs2rel ($mapedit->{path}, $ent);
834 print "TO: $x:$y => $exit2->{slaying}\n";
835 844
836 unless ($exit2->{slaying} =~ m/^\.\./) { 845 unless ($exit2->{slaying} =~ m/^\.\./) {
837 $exit2->{slaying} = '/' . $exit2->{slaying}; 846 $exit2->{slaying} = '/' . $exit2->{slaying};
838 } 847 }
839 848

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines