1 |
elmex |
1.1 |
package GCE::EditAction; |
2 |
|
|
|
3 |
|
|
=head1 NAME |
4 |
|
|
|
5 |
|
|
GCE::EditActions - this is the abstraction of edit actions (placing, deleting, etc.) |
6 |
|
|
|
7 |
|
|
=cut |
8 |
|
|
|
9 |
|
|
use Gtk2; |
10 |
|
|
use Gtk2::Gdk::Keysyms; |
11 |
|
|
use Gtk2::SimpleMenu; |
12 |
|
|
|
13 |
root |
1.51 |
use Deliantra; |
14 |
|
|
use Deliantra::MapWidget; |
15 |
elmex |
1.1 |
|
16 |
|
|
use strict; |
17 |
|
|
|
18 |
|
|
sub new { |
19 |
|
|
my $class = shift; |
20 |
|
|
my $self = { @_ }; |
21 |
|
|
bless $self, $class; |
22 |
elmex |
1.6 |
$self->init; |
23 |
elmex |
1.1 |
return $self; |
24 |
|
|
} |
25 |
|
|
|
26 |
elmex |
1.10 |
sub name { } # a unique name for this tool (for storing it in a hash in the main window) |
27 |
|
|
|
28 |
elmex |
1.7 |
sub tool_widget { if ($_[1]) { $_[0]->{widget} = $_[1] } $_[0]->{widget} } |
29 |
elmex |
1.6 |
sub init { } |
30 |
|
|
|
31 |
elmex |
1.1 |
sub want_cursor { 1 } |
32 |
|
|
|
33 |
elmex |
1.42 |
sub only_on_click { 0 } |
34 |
|
|
|
35 |
elmex |
1.1 |
sub special_arrow { } |
36 |
|
|
|
37 |
|
|
# edits one tile of the map |
38 |
|
|
sub edit_one { |
39 |
|
|
my ($self, $x, $y) = @_; |
40 |
|
|
# do one edition |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
# edits a selection |
44 |
|
|
sub edit_selection { |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
# abstraction for edit_one and edit_selection ? |
48 |
|
|
# takes selection if present |
49 |
|
|
sub edit { |
50 |
elmex |
1.10 |
my ($self, $map, $x, $y) = @_; |
51 |
elmex |
1.1 |
} |
52 |
|
|
|
53 |
|
|
sub begin { |
54 |
elmex |
1.10 |
my ($self, $map, $x, $y) = @_; |
55 |
elmex |
1.43 |
#d# warn "CHANGE BEGIN ".(ref $self)."\n"; |
56 |
root |
1.3 |
$map->change_begin (ref $self); |
57 |
elmex |
1.1 |
} |
58 |
root |
1.3 |
|
59 |
elmex |
1.1 |
sub end { |
60 |
root |
1.3 |
my ($self, $map) = @_; |
61 |
|
|
|
62 |
elmex |
1.43 |
#d# warn "CHANGE END ".(ref $self)."\n"; |
63 |
root |
1.3 |
if (my $changeset = $map->change_end) { |
64 |
|
|
splice @{ $map->{undo_stack} ||= [] }, |
65 |
root |
1.4 |
$map->{undo_stack_pos}++, 1e6, |
66 |
root |
1.3 |
$changeset; |
67 |
|
|
|
68 |
|
|
#TODO: limit undo stack size to some preconfigured limit |
69 |
|
|
} |
70 |
elmex |
1.1 |
} |
71 |
|
|
|
72 |
elmex |
1.7 |
package GCE::EditAction::RadioModed; |
73 |
|
|
|
74 |
|
|
our @ISA = qw/GCE::EditAction/; |
75 |
|
|
|
76 |
|
|
sub add_mode_button { |
77 |
|
|
my ($self, $vb, $lbl, $mode, $default) = @_; |
78 |
|
|
|
79 |
|
|
$vb->pack_start (my $b = Gtk2::RadioButton->new ($self->{place_radio_grp}, $lbl), 0, 1, 0); |
80 |
|
|
unless (defined $self->{place_radio_grp}) { |
81 |
|
|
$self->{place_radio_grp} = $b->get_group; |
82 |
|
|
|
83 |
|
|
unless (defined $default) { |
84 |
|
|
$b->set_active (1); |
85 |
|
|
$self->set_mode ($mode); |
86 |
|
|
} |
87 |
|
|
} |
88 |
|
|
if ($default) { |
89 |
|
|
$b->set_active (1); |
90 |
|
|
$self->set_mode ($mode); |
91 |
|
|
} |
92 |
|
|
$b->signal_connect (clicked => sub { |
93 |
|
|
$self->set_mode ($mode); |
94 |
|
|
}); |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
sub set_mode { |
98 |
|
|
my ($self, $mode) = @_; |
99 |
|
|
$self->{place_mode} = $mode; |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
sub get_mode { |
103 |
|
|
my ($self) = @_; |
104 |
|
|
$self->{place_mode} |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
sub init { |
108 |
|
|
my ($self) = @_; |
109 |
|
|
|
110 |
|
|
die "Implement me!!"; |
111 |
|
|
|
112 |
|
|
# my $vb = new Gtk2::VBox; |
113 |
|
|
# $self->_add_mode_button ($vb, "auto", "auto"); |
114 |
|
|
# $self->_add_mode_button ($vb, "top", "top"); |
115 |
|
|
# $self->_add_mode_button ($vb, "above floor", "above"); |
116 |
|
|
# $self->_add_mode_button ($vb, "below floor", "below"); |
117 |
|
|
# $self->_add_mode_button ($vb, "bottom", "bottom"); |
118 |
|
|
# |
119 |
|
|
# $self->{widget} = $vb; |
120 |
|
|
} |
121 |
elmex |
1.1 |
|
122 |
|
|
package GCE::EditAction::Pick; |
123 |
elmex |
1.34 |
use GCE::ArchRef; |
124 |
elmex |
1.49 |
use GCE::Util; |
125 |
elmex |
1.7 |
use strict; |
126 |
elmex |
1.1 |
|
127 |
elmex |
1.23 |
our @ISA = qw/GCE::EditAction::RadioModed/; |
128 |
elmex |
1.1 |
|
129 |
elmex |
1.10 |
sub name { 'pick' } |
130 |
|
|
|
131 |
elmex |
1.7 |
sub want_cursor { 0 } |
132 |
|
|
|
133 |
elmex |
1.42 |
sub only_on_click { 1 } |
134 |
|
|
|
135 |
elmex |
1.1 |
sub special_arrow { 'GDK_HAND2' } |
136 |
|
|
|
137 |
elmex |
1.23 |
sub init { |
138 |
|
|
my ($self) = @_; |
139 |
|
|
|
140 |
|
|
my $vb = new Gtk2::VBox; |
141 |
|
|
$self->{widget} = $vb; |
142 |
|
|
} |
143 |
|
|
|
144 |
elmex |
1.40 |
# Pick does not change the stack |
145 |
|
|
sub begin {} |
146 |
|
|
sub end {} |
147 |
|
|
|
148 |
elmex |
1.1 |
sub edit { |
149 |
elmex |
1.10 |
my ($self, $map, $x, $y) = @_; |
150 |
elmex |
1.1 |
|
151 |
|
|
my $cstack = $map->get ($x, $y); |
152 |
elmex |
1.49 |
my ($ox, $oy) = ($x, $y); |
153 |
elmex |
1.1 |
|
154 |
elmex |
1.34 |
return unless @$cstack; |
155 |
|
|
|
156 |
elmex |
1.1 |
my $arch = $cstack->[-1]; |
157 |
elmex |
1.49 |
($x, $y, $arch, $cstack) = devirtualize ($map, $x, $y, $arch, $cstack); |
158 |
elmex |
1.1 |
|
159 |
elmex |
1.34 |
my $aref = |
160 |
|
|
GCE::ArchRef->new ( |
161 |
|
|
arch => $arch, |
162 |
elmex |
1.47 |
source => 'map', |
163 |
elmex |
1.34 |
cb => sub { |
164 |
|
|
$map->change_begin ('attredit'); |
165 |
|
|
$map->change_stack ($x, $y, $cstack); |
166 |
|
|
|
167 |
|
|
if (my $changeset = $map->change_end) { |
168 |
|
|
splice @{ $map->{undo_stack} ||= [] }, |
169 |
|
|
$map->{undo_stack_pos}++, 1e6, |
170 |
|
|
$changeset; |
171 |
|
|
} |
172 |
|
|
} |
173 |
|
|
); |
174 |
|
|
|
175 |
|
|
$::MAINWIN->update_attr_editor ($aref); |
176 |
elmex |
1.49 |
$::MAINWIN->update_stack_view ($map, $ox, $oy); |
177 |
elmex |
1.23 |
} |
178 |
elmex |
1.1 |
|
179 |
elmex |
1.13 |
package GCE::EditAction::Perl; |
180 |
|
|
|
181 |
|
|
use GCE::Util; |
182 |
|
|
use Gtk2; |
183 |
|
|
use strict; |
184 |
|
|
|
185 |
|
|
our @ISA = qw/GCE::EditAction/; |
186 |
|
|
|
187 |
|
|
sub name { 'perl' } |
188 |
|
|
|
189 |
elmex |
1.15 |
sub special_arrow { 'GDK_HEART' } |
190 |
|
|
|
191 |
elmex |
1.13 |
sub init { |
192 |
|
|
my ($self) = @_; |
193 |
|
|
|
194 |
|
|
my $vb = new Gtk2::VBox; |
195 |
elmex |
1.20 |
$vb->pack_start (my $combo = Gtk2::ComboBox->new_text, 0, 1, 0); |
196 |
elmex |
1.13 |
$vb->pack_start (my $sw = Gtk2::ScrolledWindow->new, 1, 1, 0); |
197 |
|
|
$sw->add ($self->{txt} = Gtk2::TextView->new); |
198 |
|
|
|
199 |
elmex |
1.20 |
my $code = {}; |
200 |
|
|
for (['unique floor' => 'my $i = 0; for (@$os) { $_->{is_floor} and $as->[$i]->{unique} = 1; $i++ }']) { |
201 |
|
|
$combo->append_text ($_->[0]); |
202 |
|
|
$code->{$_->[0]} = $_->[1]; |
203 |
|
|
} |
204 |
|
|
|
205 |
|
|
$combo->signal_connect (changed => sub { |
206 |
|
|
my ($combo) = @_; |
207 |
|
|
my $str = $combo->get_active_text; |
208 |
|
|
$self->{txt}->get_buffer->set_text ($code->{$str}); |
209 |
|
|
}); |
210 |
|
|
|
211 |
elmex |
1.13 |
$self->tool_widget ($vb); |
212 |
|
|
} |
213 |
|
|
|
214 |
|
|
sub want_cursor { 0 } |
215 |
|
|
|
216 |
|
|
sub edit { |
217 |
|
|
my ($self, $map, $x, $y) = @_; |
218 |
|
|
|
219 |
|
|
my $pick = $::MAINWIN->get_pick; |
220 |
|
|
my $as = $map->get ($x, $y); |
221 |
|
|
|
222 |
|
|
$as = $self->eval ($map, $pick, $as, $x, $y); |
223 |
|
|
$map->change_stack ($x, $y, $as); # insert_arch_stack_layer ($as, $arch)); |
224 |
|
|
} |
225 |
|
|
|
226 |
|
|
sub eval { |
227 |
elmex |
1.20 |
my ($self, $map, $pick, $as, $x, $y) = @_; |
228 |
elmex |
1.13 |
my $buf = $self->{txt}->get_buffer; |
229 |
|
|
my $code = $buf->get_text ($buf->get_start_iter, $buf->get_end_iter, 0); |
230 |
elmex |
1.20 |
my $f_idx = stack_find_floor ($as, 'from_top'); |
231 |
|
|
my $w_idx = stack_find_wall ($as, 'from_top'); |
232 |
root |
1.51 |
my $os = [ map { $Deliantra::ARCH{$_->{_name}} } @$as ]; |
233 |
elmex |
1.20 |
|
234 |
|
|
unless (arch_is_floor ($as->[$f_idx])) { $f_idx = undef; } |
235 |
|
|
unless (arch_is_floor ($as->[$w_idx])) { $w_idx = undef; } |
236 |
elmex |
1.13 |
|
237 |
|
|
eval $code; |
238 |
elmex |
1.20 |
return $as; |
239 |
elmex |
1.13 |
} |
240 |
|
|
|
241 |
elmex |
1.18 |
package GCE::EditAction::FollowExit; |
242 |
|
|
use Storable qw/dclone/; |
243 |
|
|
use File::Spec::Functions; |
244 |
|
|
use GCE::Util; |
245 |
|
|
use Gtk2; |
246 |
|
|
use strict; |
247 |
|
|
|
248 |
|
|
our @ISA = qw/GCE::EditAction/; |
249 |
|
|
|
250 |
|
|
sub name { 'place' } |
251 |
|
|
|
252 |
|
|
sub init { |
253 |
|
|
my ($self) = @_; |
254 |
|
|
|
255 |
|
|
my $vb = new Gtk2::VBox; |
256 |
|
|
|
257 |
|
|
$self->tool_widget ($vb); |
258 |
|
|
} |
259 |
|
|
|
260 |
|
|
sub want_cursor { 0 } |
261 |
|
|
|
262 |
|
|
sub edit { |
263 |
elmex |
1.21 |
my ($self, $map, $x, $y, $mape) = @_; |
264 |
elmex |
1.18 |
|
265 |
|
|
my $as = $map->get ($x, $y); |
266 |
|
|
|
267 |
|
|
my $exit; |
268 |
elmex |
1.27 |
for my $arch (@$as) { |
269 |
elmex |
1.50 |
my ($rx, $ry, $rarch) = devirtualize ($map, $x, $y, $arch, $as); |
270 |
|
|
if (arch_is_exit ($rarch)) { |
271 |
|
|
$exit = $rarch; |
272 |
elmex |
1.18 |
} |
273 |
|
|
} |
274 |
|
|
|
275 |
elmex |
1.32 |
if ($exit and $exit->{slaying} !~ /^!/) { |
276 |
elmex |
1.22 |
my $dest = map2abs ($exit->{slaying}, $mape); |
277 |
elmex |
1.45 |
my $file = $dest; |
278 |
elmex |
1.32 |
# XXX: Replace with statusbar message |
279 |
elmex |
1.45 |
unless (-f $file) { |
280 |
|
|
$file .= ".map"; |
281 |
|
|
unless (-f $file) { |
282 |
|
|
quick_msg ($mape, "Couldn't find map file at '$dest' or '$dest.map'.", 1); |
283 |
|
|
return |
284 |
|
|
} |
285 |
elmex |
1.32 |
} |
286 |
elmex |
1.45 |
$::MAINWIN->open_map_editor ($file); |
287 |
elmex |
1.18 |
} |
288 |
|
|
} |
289 |
|
|
|
290 |
elmex |
1.1 |
package GCE::EditAction::Place; |
291 |
root |
1.28 |
|
292 |
elmex |
1.14 |
use Storable qw/dclone/; |
293 |
elmex |
1.2 |
use GCE::Util; |
294 |
elmex |
1.6 |
use Gtk2; |
295 |
|
|
use strict; |
296 |
elmex |
1.2 |
|
297 |
elmex |
1.7 |
our @ISA = qw/GCE::EditAction::RadioModed/; |
298 |
elmex |
1.6 |
|
299 |
elmex |
1.10 |
sub name { 'place' } |
300 |
|
|
|
301 |
elmex |
1.6 |
sub init { |
302 |
|
|
my ($self) = @_; |
303 |
|
|
|
304 |
|
|
my $vb = new Gtk2::VBox; |
305 |
root |
1.28 |
|
306 |
elmex |
1.7 |
$self->add_mode_button ($vb, "auto", "auto"); |
307 |
|
|
$self->add_mode_button ($vb, "top", "top"); |
308 |
|
|
$self->add_mode_button ($vb, "above floor", "above"); |
309 |
|
|
$self->add_mode_button ($vb, "below floor", "below"); |
310 |
|
|
$self->add_mode_button ($vb, "bottom", "bottom"); |
311 |
elmex |
1.6 |
|
312 |
elmex |
1.7 |
$self->tool_widget ($vb); |
313 |
elmex |
1.6 |
} |
314 |
|
|
|
315 |
elmex |
1.1 |
sub want_cursor { 0 } |
316 |
|
|
|
317 |
root |
1.28 |
# 1 up 2 right 4 down 8 left |
318 |
|
|
my @join_ext = ( |
319 |
|
|
"0", # 0 |
320 |
|
|
"1_2", # 1 |
321 |
|
|
"1_4", # 2 |
322 |
|
|
"2_2_1", # 3 |
323 |
|
|
"1_1", # 4 |
324 |
|
|
"2_1_1", # 5 |
325 |
|
|
"2_2_2", # 6 |
326 |
|
|
"3_2", # 7 |
327 |
|
|
"1_3", # 8 |
328 |
|
|
"2_2_4", # 9 |
329 |
|
|
"2_1_2", # 10 |
330 |
|
|
"3_1", # 11 |
331 |
|
|
"2_2_3", # 12 |
332 |
|
|
"3_4", # 13 |
333 |
|
|
"3_3", # 14 |
334 |
|
|
"4", # 15 |
335 |
|
|
); |
336 |
|
|
|
337 |
|
|
sub autojoin { |
338 |
|
|
my ($map, $pick, $x1, $y1, $x2, $y2) = @_; |
339 |
|
|
|
340 |
|
|
my $dx = $x2 - $x1; |
341 |
|
|
my $dy = $y2 - $y1; |
342 |
|
|
|
343 |
|
|
my $dir = $dy ? ($dy == -1 ? 1 : $dy == 1 ? 4 : return) |
344 |
|
|
: ($dx == -1 ? 8 : $dx == 1 ? 2 : $dx == 0 ? 0 : return); |
345 |
|
|
|
346 |
|
|
my $as = $map->get ($x1, $y1); |
347 |
|
|
|
348 |
|
|
(my $base = $pick->{_name}) =~ s/_0$//; |
349 |
|
|
|
350 |
|
|
for my $idx (0 .. $#$as) { |
351 |
|
|
my $arch = $as->[$idx]; |
352 |
|
|
for my $dirs (0..15) { |
353 |
|
|
my $name = $arch->{_name}; |
354 |
|
|
|
355 |
|
|
if ($arch->{_name} eq "$base\_$join_ext[$dirs]") { |
356 |
|
|
$dirs |= $dir; |
357 |
|
|
|
358 |
|
|
my $name = "$base\_$join_ext[$dirs]"; |
359 |
|
|
|
360 |
root |
1.51 |
if ($Deliantra::ARCH{$name}) { |
361 |
root |
1.28 |
%$arch = ( _name => $name ); |
362 |
|
|
$map->change_stack ($x1, $y1, $as); |
363 |
|
|
|
364 |
|
|
return 1; |
365 |
|
|
} |
366 |
|
|
} |
367 |
|
|
} |
368 |
|
|
} |
369 |
|
|
|
370 |
|
|
return 0; |
371 |
|
|
} |
372 |
|
|
|
373 |
elmex |
1.1 |
sub edit { |
374 |
elmex |
1.10 |
my ($self, $map, $x, $y) = @_; |
375 |
elmex |
1.1 |
|
376 |
elmex |
1.10 |
my $pick = $::MAINWIN->get_pick; |
377 |
|
|
my $as = $map->get ($x, $y); |
378 |
elmex |
1.1 |
|
379 |
root |
1.28 |
my $autojoin = $pick->{_name} =~ /_0$/ |
380 |
|
|
&& $self->get_mode eq "auto"; |
381 |
|
|
|
382 |
|
|
autojoin $map, $pick, @{$self->{last_pos}}, $x, $y |
383 |
|
|
if $autojoin && $self->{last_pos}; |
384 |
|
|
|
385 |
|
|
if (!$autojoin |
386 |
|
|
|| !($self->{last_pos} ? autojoin $map, $pick, $x, $y, @{$self->{last_pos}}, |
387 |
|
|
: autojoin $map, $pick, $x, $y, $x, $y)) { |
388 |
|
|
$self->stack_action ($as, dclone $pick); |
389 |
|
|
$map->change_stack ($x, $y, $as); |
390 |
|
|
autojoin $map, $pick, $x, $y, @{$self->{last_pos}} |
391 |
|
|
if $autojoin && $self->{last_pos}; |
392 |
|
|
} |
393 |
|
|
|
394 |
|
|
$self->{last_pos} = [$x, $y]; |
395 |
elmex |
1.1 |
} |
396 |
|
|
|
397 |
elmex |
1.17 |
sub end { |
398 |
|
|
my ($self, $map, $x, $y, $mape) = @_; |
399 |
elmex |
1.37 |
|
400 |
elmex |
1.22 |
# now actualize stack and attr editor |
401 |
|
|
$::MAINWIN->update_stack_view ($map, $x, $y); |
402 |
|
|
|
403 |
|
|
my $cstack = $map->get ($x, $y); |
404 |
|
|
|
405 |
|
|
my $arch = $cstack->[-1]; |
406 |
|
|
|
407 |
root |
1.28 |
delete $self->{last_pos}; |
408 |
|
|
|
409 |
elmex |
1.22 |
# virtual... grmbl.... |
410 |
|
|
# FIXME: I have to patch the stack of the real arch??? argl.. how?? |
411 |
|
|
if ($arch->{_virtual}) { |
412 |
|
|
$x = $arch->{virtual_x}; |
413 |
|
|
$y = $arch->{virtual_y}; |
414 |
|
|
$arch = $arch->{_virtual}; |
415 |
|
|
$cstack = $map->get ($x, $y); |
416 |
|
|
} |
417 |
|
|
|
418 |
elmex |
1.17 |
$self->SUPER::end ($map, $x, $y, $mape); |
419 |
|
|
} |
420 |
|
|
|
421 |
elmex |
1.6 |
sub stack_action { |
422 |
|
|
my ($self, $stack, $arch) = @_; |
423 |
|
|
|
424 |
elmex |
1.7 |
my $m = $self->get_mode; |
425 |
elmex |
1.6 |
|
426 |
|
|
if ($m eq 'top') { |
427 |
elmex |
1.52 |
push @$stack, $arch; |
428 |
elmex |
1.6 |
|
429 |
|
|
} elsif ($m eq 'bottom') { |
430 |
elmex |
1.52 |
unshift @$stack, $arch; |
431 |
elmex |
1.6 |
|
432 |
|
|
} elsif ($m eq 'above') { |
433 |
|
|
my $fidx = stack_find_floor ($stack, 'from_top'); |
434 |
|
|
|
435 |
elmex |
1.52 |
if (defined $fidx) { |
436 |
|
|
if ($stack->[$fidx + 1] |
437 |
|
|
&& $stack->[$fidx + 1]->{_name} eq $arch->{_name}) |
438 |
|
|
{ |
439 |
|
|
$stack->[$fidx + 1] = $arch; |
440 |
|
|
|
441 |
|
|
} else { |
442 |
|
|
splice (@$stack, $fidx + 1, 0, $arch); |
443 |
|
|
} |
444 |
|
|
|
445 |
|
|
} else { |
446 |
|
|
push @$stack, $arch; |
447 |
elmex |
1.6 |
} |
448 |
|
|
|
449 |
|
|
} elsif ($m eq 'below') { |
450 |
|
|
my $fidx = stack_find_floor ($stack, 'from_bottom'); |
451 |
|
|
|
452 |
elmex |
1.52 |
if (defined $fidx) { |
453 |
|
|
if ($stack->[$fidx - 1] |
454 |
|
|
&& $stack->[$fidx - 1]->{_name} eq $arch->{_name}) |
455 |
|
|
{ |
456 |
|
|
$stack->[$fidx - 1] = $arch; |
457 |
|
|
|
458 |
|
|
} else { |
459 |
|
|
splice (@$stack, $fidx, 0, $arch); |
460 |
|
|
} |
461 |
|
|
|
462 |
|
|
} else { |
463 |
|
|
unshift @$stack, $arch; |
464 |
elmex |
1.6 |
} |
465 |
|
|
|
466 |
|
|
} elsif ($m eq 'auto') { |
467 |
|
|
my $fidx = stack_find_floor ($stack, 'from_top'); |
468 |
|
|
my $widx = stack_find_wall ($stack); |
469 |
|
|
|
470 |
|
|
if (arch_is_floor ($arch)) { # we want to place a floor tile |
471 |
|
|
|
472 |
|
|
if (arch_is_floor ($stack->[$fidx])) { # replace |
473 |
|
|
$stack->[$fidx] = $arch; |
474 |
|
|
|
475 |
|
|
} else { # insert on bottom |
476 |
|
|
unshift @$stack, $arch; |
477 |
|
|
} |
478 |
|
|
|
479 |
|
|
} elsif (arch_is_wall ($arch)) { # we want to place a wall |
480 |
|
|
|
481 |
|
|
if (arch_is_wall ($stack->[$widx])) { # replace |
482 |
|
|
$stack->[$widx] = $arch; |
483 |
|
|
|
484 |
elmex |
1.52 |
} else { # insert around floor |
485 |
elmex |
1.6 |
splice (@$stack, $fidx + 1, 0, $arch); |
486 |
|
|
} |
487 |
|
|
|
488 |
|
|
} else { |
489 |
|
|
|
490 |
|
|
if (arch_is_wall ($stack->[$widx])) { |
491 |
elmex |
1.9 |
# if we have a wall above the floor, replace it with the to place item |
492 |
|
|
$stack->[$widx] = $arch; |
493 |
elmex |
1.6 |
return; |
494 |
|
|
} |
495 |
|
|
|
496 |
|
|
if (@$stack == 0 |
497 |
|
|
or not ($stack->[-1]) |
498 |
|
|
or $stack->[-1]->{_name} ne $arch->{_name}) |
499 |
|
|
{ |
500 |
|
|
push @$stack, $arch; |
501 |
elmex |
1.36 |
|
502 |
|
|
} elsif ($stack->[-1]->{_name} eq $arch->{_name}) { |
503 |
|
|
$stack->[-1] = $arch; |
504 |
elmex |
1.6 |
} |
505 |
|
|
} |
506 |
|
|
} |
507 |
|
|
} |
508 |
|
|
|
509 |
elmex |
1.12 |
package GCE::EditAction::Select; |
510 |
elmex |
1.11 |
use GCE::Util; |
511 |
|
|
use Gtk2; |
512 |
root |
1.51 |
use Deliantra; |
513 |
elmex |
1.12 |
use Storable qw/dclone/; |
514 |
elmex |
1.11 |
use strict; |
515 |
|
|
|
516 |
|
|
our @ISA = qw/GCE::EditAction::RadioModed/; |
517 |
|
|
|
518 |
elmex |
1.12 |
sub name { 'select' } |
519 |
elmex |
1.11 |
|
520 |
elmex |
1.15 |
sub special_arrow { 'GDK_CIRCLE' } |
521 |
|
|
|
522 |
elmex |
1.11 |
sub init { |
523 |
|
|
my ($self) = @_; |
524 |
|
|
|
525 |
|
|
my $vb = new Gtk2::VBox; |
526 |
|
|
|
527 |
elmex |
1.19 |
$vb->pack_start (my $bt = Gtk2::Button->new_with_mnemonic ("_copy"), 0, 1, 0); |
528 |
elmex |
1.12 |
$bt->signal_connect (clicked => sub { $self->copy }); |
529 |
|
|
$vb->pack_start ($self->{paste_top} = Gtk2::CheckButton->new ('paste on top'), 0, 1, 0); |
530 |
elmex |
1.19 |
$vb->pack_start (my $bt = Gtk2::Button->new_with_mnemonic ("paste (_v)"), 0, 1, 0); |
531 |
elmex |
1.12 |
$bt->signal_connect (clicked => sub { $self->paste }); |
532 |
|
|
$vb->pack_start (Gtk2::HSeparator->new, 0, 1, 0); |
533 |
|
|
$self->add_mode_button ($vb, "place", "place"); |
534 |
|
|
$self->add_mode_button ($vb, "erase", "erase"); |
535 |
elmex |
1.15 |
$self->add_mode_button ($vb, "perl", "perl"); |
536 |
elmex |
1.19 |
$vb->pack_start (my $bt = Gtk2::Button->new_with_mnemonic ("i_nvoke"), 0, 1, 0); |
537 |
elmex |
1.12 |
$bt->signal_connect (clicked => sub { $self->invoke }); |
538 |
elmex |
1.11 |
|
539 |
|
|
$self->tool_widget ($vb); |
540 |
|
|
} |
541 |
|
|
|
542 |
elmex |
1.12 |
sub copy { |
543 |
|
|
my ($self) = @_; |
544 |
|
|
|
545 |
|
|
return unless $self->{selection}->{a}; |
546 |
|
|
my ($x1, $y1) = @{$self->{selection}->{a}}; |
547 |
|
|
my ($x2, $y2) = @{$self->{selection}->{b}}; |
548 |
|
|
|
549 |
|
|
if ($x1 > $x2) { ($x2, $x1) = ($x1, $x2) } |
550 |
|
|
if ($y1 > $y2) { ($y2, $y1) = ($y1, $y2) } |
551 |
|
|
|
552 |
|
|
my $map = $self->{selection}->{map}; |
553 |
|
|
|
554 |
|
|
$self->{copy_coords} = [$x1, $y1, $x2, $y2]; |
555 |
|
|
$self->{copy}; |
556 |
|
|
for (my $x = $x1; $x <= $x2; $x++) { |
557 |
|
|
for (my $y = $y1; $y <= $y2; $y++) { |
558 |
|
|
$self->{copy}->[$x - $x1]->[$y - $y1] = $map->get ($x, $y); |
559 |
|
|
} |
560 |
|
|
} |
561 |
|
|
} |
562 |
|
|
|
563 |
|
|
sub paste { |
564 |
elmex |
1.23 |
my ($self, $map, $xp, $yp) = @_; |
565 |
elmex |
1.12 |
|
566 |
|
|
return unless $self->{selection}->{a}; |
567 |
|
|
|
568 |
|
|
my ($x1, $y1); |
569 |
|
|
|
570 |
elmex |
1.15 |
if (defined $xp) { |
571 |
elmex |
1.12 |
($x1, $y1) = ($xp, $yp); |
572 |
|
|
} else { |
573 |
|
|
($x1, $y1) = @{$self->{selection}->{a}}; |
574 |
|
|
} |
575 |
|
|
|
576 |
elmex |
1.23 |
$map ||= $self->{selection}->{map}; |
577 |
elmex |
1.12 |
|
578 |
|
|
my $p_o_top = $self->{paste_top}->get_active * 1; |
579 |
|
|
|
580 |
|
|
my $w = $self->{copy_coords}->[2] - $self->{copy_coords}->[0]; |
581 |
|
|
my $h = $self->{copy_coords}->[3] - $self->{copy_coords}->[1]; |
582 |
|
|
$self->{copy}; |
583 |
|
|
$self->SUPER::begin ($map, $x1, $y1); |
584 |
|
|
for (my $x = $x1; $x <= ($x1 + $w); $x++) { |
585 |
|
|
for (my $y = $y1; $y <= ($y1 + $h); $y++) { |
586 |
|
|
my $cstck = $map->get ($x, $y); |
587 |
|
|
|
588 |
|
|
if ($p_o_top) { |
589 |
|
|
push @$cstck, @{dclone ($self->{copy}->[$x - $x1]->[$y - $y1] || [])}; |
590 |
|
|
$map->change_stack ($x, $y, $cstck); |
591 |
|
|
} else { |
592 |
|
|
$map->change_stack ($x, $y, dclone ($self->{copy}->[$x - $x1]->[$y - $y1] || [])); |
593 |
|
|
} |
594 |
|
|
} |
595 |
|
|
} |
596 |
|
|
$self->SUPER::end ($map); |
597 |
|
|
$map->invalidate_all; |
598 |
|
|
} |
599 |
|
|
|
600 |
|
|
sub invoke { |
601 |
|
|
my ($self) = @_; |
602 |
|
|
|
603 |
|
|
return unless $self->{selection}->{a}; |
604 |
|
|
my ($x1, $y1) = @{$self->{selection}->{a}}; |
605 |
|
|
my ($x2, $y2) = @{$self->{selection}->{b}}; |
606 |
|
|
|
607 |
|
|
if ($x1 > $x2) { ($x2, $x1) = ($x1, $x2) } |
608 |
|
|
if ($y1 > $y2) { ($y2, $y1) = ($y1, $y2) } |
609 |
|
|
|
610 |
|
|
my $map = $self->{selection}->{map}; |
611 |
|
|
|
612 |
|
|
my $m = $self->get_mode; |
613 |
|
|
$self->SUPER::begin ($map, $x1, $y1); |
614 |
|
|
for (my $x = $x1; $x <= $x2; $x++) { |
615 |
|
|
for (my $y = $y1; $y <= $y2; $y++) { |
616 |
|
|
if ($m eq 'place') { |
617 |
|
|
$::MAINWIN->{edit_collection}{place}->edit ($map, $x, $y); |
618 |
|
|
} elsif ($m eq 'erase') { |
619 |
|
|
$::MAINWIN->{edit_collection}{erase}->edit ($map, $x, $y); |
620 |
elmex |
1.15 |
} elsif ($m eq 'perl') { |
621 |
|
|
$::MAINWIN->{edit_collection}{perl}->edit ($map, $x, $y); |
622 |
elmex |
1.12 |
} |
623 |
|
|
} |
624 |
|
|
} |
625 |
|
|
$self->SUPER::end ($map); |
626 |
|
|
} |
627 |
|
|
|
628 |
elmex |
1.11 |
sub want_cursor { 0 } |
629 |
|
|
|
630 |
|
|
sub begin { |
631 |
|
|
my ($self, $map, $x, $y) = @_; |
632 |
|
|
|
633 |
elmex |
1.29 |
if ($self->{selection}->{map}) { |
634 |
|
|
$self->{selection}->{map}->overlay ('selection'); |
635 |
|
|
} |
636 |
elmex |
1.11 |
delete $self->{selection}; |
637 |
|
|
|
638 |
elmex |
1.12 |
$self->{selection}->{a} = [$x, $y]; |
639 |
|
|
} |
640 |
elmex |
1.11 |
|
641 |
elmex |
1.12 |
sub end { |
642 |
elmex |
1.11 |
} |
643 |
|
|
|
644 |
|
|
sub edit { |
645 |
|
|
my ($self, $map, $x, $y) = @_; |
646 |
|
|
|
647 |
|
|
$self->{selection}->{b} = [$x, $y]; |
648 |
elmex |
1.12 |
$self->{selection}->{map} = $map; |
649 |
elmex |
1.29 |
$self->update_overlay (); |
650 |
elmex |
1.11 |
} |
651 |
|
|
|
652 |
|
|
sub update_overlay { |
653 |
elmex |
1.29 |
my ($self) = @_; |
654 |
|
|
|
655 |
|
|
my $map = $self->{selection}->{map}; |
656 |
|
|
|
657 |
|
|
return unless (defined $self->{selection}->{a} and defined $self->{selection}->{b}); |
658 |
elmex |
1.11 |
|
659 |
elmex |
1.12 |
my ($x1, $y1) = @{$self->{selection}->{a}}; |
660 |
|
|
my ($x2, $y2) = @{$self->{selection}->{b}}; |
661 |
|
|
|
662 |
|
|
if ($x1 > $x2) { ($x2, $x1) = ($x1, $x2) } |
663 |
|
|
if ($y1 > $y2) { ($y2, $y1) = ($y1, $y2) } |
664 |
elmex |
1.11 |
|
665 |
elmex |
1.12 |
my $w = ($x2 - $x1) + 1; |
666 |
|
|
my $h = ($y2 - $y1) + 1; |
667 |
|
|
|
668 |
|
|
$map->overlay (selection => |
669 |
|
|
$x1 * TILESIZE, $y1 * TILESIZE, |
670 |
elmex |
1.48 |
$w * TILESIZE, $h * TILESIZE, |
671 |
elmex |
1.12 |
sub { |
672 |
|
|
my ($self, $x, $y) = @_; |
673 |
|
|
$self->{window}->draw_rectangle ( |
674 |
|
|
$_ & 1 ? $self->style->black_gc : $self->style->white_gc, |
675 |
|
|
0, |
676 |
|
|
$x + $_, $y + $_, |
677 |
|
|
($w * TILESIZE) - 1 - $_ * 2, |
678 |
|
|
($h * TILESIZE) - 1 - $_ * 2 |
679 |
|
|
) for 0..3; |
680 |
|
|
} |
681 |
|
|
); |
682 |
elmex |
1.11 |
} |
683 |
|
|
|
684 |
elmex |
1.1 |
package GCE::EditAction::Erase; |
685 |
elmex |
1.7 |
use GCE::Util; |
686 |
|
|
use Gtk2; |
687 |
|
|
use strict; |
688 |
elmex |
1.1 |
|
689 |
elmex |
1.7 |
our @ISA = qw/GCE::EditAction::RadioModed/; |
690 |
elmex |
1.1 |
|
691 |
elmex |
1.10 |
sub name { 'erase' } |
692 |
|
|
|
693 |
elmex |
1.1 |
sub want_cursor { 0 } |
694 |
|
|
|
695 |
elmex |
1.15 |
sub special_arrow { 'GDK_DIAMOND_CROSS' } |
696 |
elmex |
1.10 |
|
697 |
elmex |
1.7 |
sub init { |
698 |
|
|
my ($self) = @_; |
699 |
|
|
|
700 |
|
|
my $vb = new Gtk2::VBox; |
701 |
|
|
$self->add_mode_button ($vb, "top", "top"); |
702 |
|
|
$self->add_mode_button ($vb, "walls", "walls"); |
703 |
|
|
$self->add_mode_button ($vb, "above floor", "above", 'default'); |
704 |
|
|
$self->add_mode_button ($vb, "floor", "floor"); |
705 |
|
|
$self->add_mode_button ($vb, "below floor", "below"); |
706 |
|
|
$self->add_mode_button ($vb, "bottom", "bottom"); |
707 |
|
|
$self->add_mode_button ($vb, "pick match", "match"); |
708 |
|
|
|
709 |
|
|
$self->tool_widget ($vb); |
710 |
|
|
|
711 |
root |
1.25 |
$vb->pack_start ($self->{no_wall_check} = Gtk2::CheckButton->new ("protect walls"), 0, 1, 0); |
712 |
|
|
$vb->pack_start ($self->{no_monsters_check} = Gtk2::CheckButton->new ("protect monsters"), 0, 1, 0); |
713 |
elmex |
1.7 |
} |
714 |
|
|
|
715 |
|
|
sub check_excluded { |
716 |
|
|
my ($self, $arch) = @_; |
717 |
|
|
|
718 |
elmex |
1.37 |
my $r = ($self->{no_wall_check}->get_active && arch_is_wall ($arch)) |
719 |
|
|
|| ($self->{no_monsters_check}->get_active && arch_is_monster ($arch)); |
720 |
elmex |
1.7 |
|
721 |
elmex |
1.37 |
return $r; |
722 |
elmex |
1.1 |
} |
723 |
|
|
|
724 |
|
|
sub edit { |
725 |
elmex |
1.10 |
my ($self, $map, $x, $y) = @_; |
726 |
elmex |
1.1 |
|
727 |
|
|
my $as = $map->get ($x, $y); |
728 |
elmex |
1.7 |
$self->stack_action ($as); |
729 |
root |
1.3 |
$map->change_stack ($x, $y, $as); |
730 |
elmex |
1.1 |
} |
731 |
|
|
|
732 |
elmex |
1.7 |
sub stack_action { |
733 |
|
|
my ($self, $stack) = @_; |
734 |
|
|
|
735 |
|
|
my $m = $self->get_mode; |
736 |
|
|
|
737 |
|
|
if ($m eq 'top') { |
738 |
|
|
pop @$stack; |
739 |
|
|
|
740 |
|
|
} elsif ($m eq 'bottom') { |
741 |
|
|
shift @$stack; |
742 |
|
|
|
743 |
|
|
} elsif ($m eq 'above') { |
744 |
|
|
my $fidx = stack_find_floor ($stack, 'from_top'); |
745 |
|
|
|
746 |
|
|
if (arch_is_floor ($stack->[$fidx]) and $stack->[$fidx + 1]) { |
747 |
|
|
splice (@$stack, $fidx + 1, 1) |
748 |
|
|
unless $self->check_excluded ($stack->[$fidx + 1]) |
749 |
|
|
|
750 |
|
|
} elsif (not arch_is_floor ($stack->[$fidx])) { |
751 |
|
|
splice (@$stack, $fidx, 1) |
752 |
|
|
unless $self->check_excluded ($stack->[$fidx]) |
753 |
|
|
|
754 |
|
|
} |
755 |
|
|
|
756 |
|
|
} elsif ($m eq 'below') { |
757 |
|
|
my $fidx = stack_find_floor ($stack, 'from_bottom'); |
758 |
|
|
|
759 |
|
|
if ($fidx > 0 and not arch_is_floor ($stack->[$fidx - 1])) { |
760 |
|
|
splice (@$stack, $fidx - 1, 1) |
761 |
|
|
unless $self->check_excluded ($stack->[$fidx - 1]) |
762 |
|
|
|
763 |
|
|
} elsif (not arch_is_floor ($stack->[$fidx])) { # no floor found |
764 |
|
|
splice (@$stack, $fidx, 1) |
765 |
|
|
unless $self->check_excluded ($stack->[$fidx]) |
766 |
|
|
|
767 |
|
|
} |
768 |
|
|
|
769 |
|
|
} elsif ($m eq 'walls') { |
770 |
|
|
my $widx = stack_find_wall ($stack, 'from_top'); |
771 |
|
|
|
772 |
|
|
while (arch_is_wall ($stack->[$widx])) { |
773 |
|
|
splice (@$stack, $widx, 1); |
774 |
|
|
$widx = stack_find_wall ($stack, 'from_top') |
775 |
|
|
} |
776 |
|
|
|
777 |
|
|
} elsif ($m eq 'floor') { |
778 |
|
|
my $fidx = stack_find_floor ($stack, 'from_top'); |
779 |
|
|
|
780 |
|
|
while (arch_is_floor ($stack->[$fidx])) { |
781 |
|
|
splice (@$stack, $fidx, 1); |
782 |
|
|
$fidx = stack_find_floor ($stack, 'from_top') |
783 |
|
|
} |
784 |
|
|
|
785 |
|
|
} elsif ($m eq 'match') { |
786 |
|
|
my $pick_name = $::MAINWIN->get_pick ()->{_name}; |
787 |
|
|
my $idx = stack_find ($stack, 'from_top', sub { $_[0]->{_name} eq $pick_name }); |
788 |
|
|
|
789 |
|
|
while ($stack->[$idx] and $stack->[$idx]->{_name} eq $pick_name) { |
790 |
|
|
splice (@$stack, $idx, 1); |
791 |
|
|
$idx = stack_find ($stack, 'from_top', sub { $_[0]->{_name} eq $pick_name }); |
792 |
|
|
} |
793 |
|
|
} |
794 |
|
|
} |
795 |
|
|
|
796 |
elmex |
1.38 |
package GCE::EditAction::Connect; |
797 |
elmex |
1.16 |
use Storable qw/dclone/; |
798 |
|
|
use GCE::Util; |
799 |
|
|
use Gtk2; |
800 |
|
|
use File::Spec::Functions; |
801 |
|
|
use strict; |
802 |
|
|
|
803 |
|
|
our @ISA = qw/GCE::EditAction::RadioModed/; |
804 |
|
|
|
805 |
elmex |
1.38 |
sub name { 'connect' } |
806 |
elmex |
1.16 |
|
807 |
|
|
sub init { |
808 |
|
|
my ($self) = @_; |
809 |
|
|
|
810 |
|
|
my $vb = new Gtk2::VBox; |
811 |
elmex |
1.39 |
$self->add_mode_button ($vb, "auto", "auto", 1); |
812 |
elmex |
1.16 |
$self->add_mode_button ($vb, "exit", "exit"); |
813 |
elmex |
1.39 |
$self->add_mode_button ($vb, "connect", "connect"); |
814 |
elmex |
1.37 |
|
815 |
elmex |
1.38 |
$vb->pack_start (my $l = Gtk2::Label->new, 0, 0, 0); |
816 |
|
|
$l->set_text ("connection:"); |
817 |
|
|
$vb->pack_start ($self->{pcon} = Gtk2::SpinButton->new_with_range (1, 10000, 1), 0, 1, 0); |
818 |
elmex |
1.16 |
$vb->pack_start ($self->{sel_lbl} = Gtk2::Label->new, 0, 0, 0); |
819 |
|
|
$self->tool_widget ($vb); |
820 |
|
|
} |
821 |
|
|
|
822 |
|
|
sub want_cursor { 0 } |
823 |
|
|
|
824 |
elmex |
1.37 |
#XXX: change_begin/end is handled in edit |
825 |
|
|
sub begin { } |
826 |
|
|
sub end { } |
827 |
elmex |
1.16 |
|
828 |
|
|
sub edit { |
829 |
|
|
my ($self, $map, $x, $y, $mapedit) = @_; |
830 |
|
|
|
831 |
|
|
my $pick = $::MAINWIN->get_pick; |
832 |
|
|
my $as = $map->get ($x, $y); |
833 |
|
|
|
834 |
elmex |
1.39 |
my $mode = $self->get_mode; |
835 |
|
|
|
836 |
elmex |
1.16 |
my $exit; |
837 |
elmex |
1.38 |
my $conns = []; |
838 |
elmex |
1.16 |
for (@$as) { |
839 |
elmex |
1.54 |
if ($_->{_virtual}) { |
840 |
|
|
# FIXME: implement virtual handling for connect, for now ignore |
841 |
|
|
next; |
842 |
elmex |
1.50 |
} |
843 |
elmex |
1.38 |
if (arch_is_connector ($_)) { |
844 |
|
|
push @$conns, $_; |
845 |
elmex |
1.39 |
} |
846 |
|
|
if (arch_is_exit ($_)) { |
847 |
elmex |
1.16 |
$exit = $_; |
848 |
|
|
} |
849 |
|
|
} |
850 |
|
|
|
851 |
elmex |
1.39 |
if ($mode eq 'auto') { |
852 |
|
|
$conns = [] if $exit; |
853 |
|
|
} elsif ($mode eq 'exit') { |
854 |
|
|
$conns = []; |
855 |
|
|
} elsif ($mode eq 'connect') { |
856 |
|
|
$exit = undef; |
857 |
|
|
} |
858 |
|
|
|
859 |
elmex |
1.46 |
my $mappath = $::MAPDIR; |
860 |
elmex |
1.26 |
|
861 |
elmex |
1.16 |
if ($exit) { |
862 |
|
|
if ($self->{sel_exit}) { |
863 |
|
|
|
864 |
|
|
$exit->{hp} = $self->{sel_exit}->[3]; |
865 |
|
|
$exit->{sp} = $self->{sel_exit}->[4]; |
866 |
elmex |
1.26 |
#$exit->{slaying} = File::Spec->abs2rel ($self->{sel_exit}->[5], $ent); |
867 |
elmex |
1.16 |
|
868 |
|
|
my $exit2 = $self->{sel_exit}->[0]; |
869 |
|
|
|
870 |
|
|
$exit2->{hp} = $x; |
871 |
|
|
$exit2->{sp} = $y; |
872 |
|
|
|
873 |
elmex |
1.26 |
my ($m1, $m2) = exit_paths ($mappath, $self->{sel_exit}->[5], $mapedit->{path}); |
874 |
|
|
|
875 |
|
|
$exit2->{slaying} = $m2; |
876 |
|
|
$exit->{slaying} = $m1; |
877 |
elmex |
1.16 |
|
878 |
|
|
$self->SUPER::begin ($map, $x, $y, $mapedit); |
879 |
|
|
$map->change_stack ($x, $y, $as); |
880 |
|
|
$self->SUPER::end ($map); |
881 |
|
|
$self->SUPER::begin ($self->{sel_exit}->[1], $exit->{hp}, $exit->{sp}); |
882 |
|
|
$self->{sel_exit}->[1]->change_stack ($exit->{hp}, $exit->{sp}, $self->{sel_exit}->[2]); |
883 |
|
|
$self->SUPER::end ($self->{sel_exit}->[1]); |
884 |
|
|
|
885 |
elmex |
1.26 |
quick_msg ($mapedit, "$exit->{slaying} ($exit->{hp}:$exit->{sp}) $exit->{_name} <=> $exit2->{slaying} ($exit2->{hp}:$exit2->{sp}) $exit2->{_name}", 0); |
886 |
elmex |
1.16 |
|
887 |
|
|
$::MAINWIN->{edit_collection}{pick}->edit ($map, $x, $y); |
888 |
|
|
|
889 |
|
|
$self->{sel_exit} = undef; |
890 |
|
|
$self->{sel_lbl}->set_text (''); |
891 |
|
|
} else { |
892 |
|
|
$self->{sel_lbl}->set_text ("src: ($x:$y) $exit->{_name}"); |
893 |
|
|
$self->{sel_exit} = [$exit, $map, $as, $x, $y, $mapedit->{path}]; |
894 |
|
|
} |
895 |
elmex |
1.53 |
|
896 |
elmex |
1.39 |
} elsif (@$conns) { |
897 |
|
|
for (@$conns) { |
898 |
elmex |
1.38 |
$_->{connected} = $self->{pcon}->get_value; |
899 |
|
|
} |
900 |
|
|
$self->SUPER::begin ($map, $x, $y, $mapedit); |
901 |
|
|
$map->change_stack ($x, $y, $as); |
902 |
|
|
$self->SUPER::end ($map); |
903 |
elmex |
1.53 |
|
904 |
elmex |
1.39 |
} elsif ($self->{sel_exit}) { |
905 |
|
|
my $exit2 = $self->{sel_exit}->[0]; |
906 |
elmex |
1.18 |
|
907 |
elmex |
1.39 |
$exit2->{hp} = $x; |
908 |
|
|
$exit2->{sp} = $y; |
909 |
elmex |
1.53 |
delete $exit2->{slaying}; |
910 |
elmex |
1.18 |
|
911 |
elmex |
1.39 |
$self->SUPER::begin ($self->{sel_exit}->[1], $self->{sel_exit}->[3], $self->{sel_exit}->[4]); |
912 |
|
|
$self->{sel_exit}->[1]->change_stack ($self->{sel_exit}->[3], $self->{sel_exit}->[4], $self->{sel_exit}->[2]); |
913 |
|
|
$self->SUPER::end ($self->{sel_exit}->[1]); |
914 |
elmex |
1.18 |
|
915 |
elmex |
1.41 |
quick_msg ($mapedit, "($self->{sel_exit}->[3]:$self->{sel_exit}->[4]) $self->{sel_exit}->[0]->{_name} => ($x:$y)", 0); |
916 |
elmex |
1.18 |
|
917 |
elmex |
1.39 |
$::MAINWIN->{edit_collection}{pick}->edit ($map, $x, $y); |
918 |
elmex |
1.18 |
|
919 |
elmex |
1.53 |
delete $self->{sel_exit}; |
920 |
elmex |
1.39 |
$self->{sel_lbl}->set_text (''); |
921 |
elmex |
1.53 |
|
922 |
elmex |
1.39 |
} else { |
923 |
|
|
quick_msg ($mapedit, "no exit or connection object found"); |
924 |
elmex |
1.16 |
} |
925 |
|
|
} |
926 |
|
|
|
927 |
elmex |
1.7 |
|
928 |
elmex |
1.1 |
=head1 AUTHOR |
929 |
|
|
|
930 |
|
|
Marc Lehmann <schmorp@schmorp.de> |
931 |
|
|
http://home.schmorp.de/ |
932 |
|
|
|
933 |
|
|
Robin Redeker <elmex@ta-sa.org> |
934 |
|
|
http://www.ta-sa.org/ |
935 |
|
|
|
936 |
|
|
=cut |
937 |
root |
1.5 |
|
938 |
|
|
1 |
939 |
elmex |
1.1 |
|