… | |
… | |
77 | } |
77 | } |
78 | |
78 | |
79 | sub open_map_editor { |
79 | sub open_map_editor { |
80 | my ($self, $mapfile) = @_; |
80 | my ($self, $mapfile) = @_; |
81 | |
81 | |
|
|
82 | unless (File::Spec->file_name_is_absolute ($mapfile)) { |
|
|
83 | $mapfile = File::Spec->rel2abs ($mapfile); |
|
|
84 | } |
|
|
85 | |
82 | # XXX: last_map_window is a dirty trick to get the position and size |
86 | # XXX: last_map_window is a dirty trick to get the position and size |
83 | # for save layout |
87 | # for save layout |
84 | |
88 | |
|
|
89 | unless (ref $mapfile) { |
|
|
90 | if (defined $self->{loaded_maps}->{$mapfile}) { |
|
|
91 | $self->{loaded_maps}->{$mapfile}->get_toplevel->present; |
|
|
92 | return; |
|
|
93 | } |
|
|
94 | } |
|
|
95 | |
85 | my $w = $self->{last_map_window} = GCE::MapEditor->new; |
96 | my $w = $self->{last_map_window} = GCE::MapEditor->new; |
|
|
97 | |
|
|
98 | unless (ref $mapfile) { |
|
|
99 | $self->{loaded_maps}->{$mapfile} = $w; |
|
|
100 | $w->signal_connect ('delete-event' => sub { |
|
|
101 | delete $self->{loaded_maps}->{$mapfile}; |
|
|
102 | }); |
|
|
103 | } |
86 | |
104 | |
87 | $w->open_map ($mapfile); |
105 | $w->open_map ($mapfile); |
88 | |
106 | |
89 | ::set_pos_and_size ($w, $main::CFG->{map_window}, 500, 500, 200, 0); |
107 | ::set_pos_and_size ($w, $main::CFG->{map_window}, 500, 500, 200, 0); |
90 | |
108 | |
… | |
… | |
239 | } |
257 | } |
240 | |
258 | |
241 | sub build_buttons { |
259 | sub build_buttons { |
242 | my ($self) = @_; |
260 | my ($self) = @_; |
243 | |
261 | |
244 | my $tbl = Gtk2::Table->new (2, 3); |
262 | my $tbl = Gtk2::Table->new (2, 4); |
245 | my $plcinfo = { width => 2, height => 3, next => [0, 0] }; |
263 | my $plcinfo = { width => 2, height => 4, next => [0, 0] }; |
246 | |
264 | |
247 | $self->{edit_collection}{pick} = GCE::EditAction::Pick->new; |
265 | $self->{edit_collection}{pick} = GCE::EditAction::Pick->new; |
248 | $self->{edit_collection}{place} = GCE::EditAction::Place->new; |
266 | $self->{edit_collection}{place} = GCE::EditAction::Place->new; |
249 | $self->{edit_collection}{erase} = GCE::EditAction::Erase->new; |
267 | $self->{edit_collection}{erase} = GCE::EditAction::Erase->new; |
250 | $self->{edit_collection}{select} = GCE::EditAction::Select->new; |
268 | $self->{edit_collection}{select} = GCE::EditAction::Select->new; |
251 | $self->{edit_collection}{perl} = GCE::EditAction::Perl->new; |
269 | $self->{edit_collection}{perl} = GCE::EditAction::Perl->new; |
252 | $self->{edit_collection}{connect} = GCE::EditAction::Connect->new; |
270 | $self->{edit_collection}{connectexit} = GCE::EditAction::ConnectExit->new; |
|
|
271 | $self->{edit_collection}{followexit} = GCE::EditAction::FollowExit->new; |
253 | |
272 | |
254 | $self->set_edit_tool ('pick'); |
273 | $self->set_edit_tool ('pick'); |
255 | |
274 | |
256 | $self->add_button ($tbl, $plcinfo, "Pick", sub { $self->set_edit_tool ('pick') }); |
275 | $self->add_button ($tbl, $plcinfo, "Pick", sub { $self->set_edit_tool ('pick') }); |
257 | $self->add_button ($tbl, $plcinfo, "Place", sub { $self->set_edit_tool ('place') }); |
276 | $self->add_button ($tbl, $plcinfo, "Place", sub { $self->set_edit_tool ('place') }); |
258 | $self->add_button ($tbl, $plcinfo, "Erase", sub { $self->set_edit_tool ('erase') }); |
277 | $self->add_button ($tbl, $plcinfo, "Erase", sub { $self->set_edit_tool ('erase') }); |
259 | $self->add_button ($tbl, $plcinfo, "Select", sub { $self->set_edit_tool ('select') }); |
278 | $self->add_button ($tbl, $plcinfo, "Select", sub { $self->set_edit_tool ('select') }); |
260 | $self->add_button ($tbl, $plcinfo, "Eval", sub { $self->set_edit_tool ('perl') }); |
279 | $self->add_button ($tbl, $plcinfo, "Eval", sub { $self->set_edit_tool ('perl') }); |
261 | $self->add_button ($tbl, $plcinfo, "Connect", sub { $self->set_edit_tool ('connect') }); |
280 | $self->add_button ($tbl, $plcinfo, "Connect Exit", sub { $self->set_edit_tool ('connectexit') }); |
|
|
281 | $self->add_button ($tbl, $plcinfo, "Follow Exit", sub { $self->set_edit_tool ('followexit') }); |
262 | |
282 | |
263 | return $tbl; |
283 | return $tbl; |
264 | } |
284 | } |
265 | |
285 | |
266 | sub set_edit_tool { |
286 | sub set_edit_tool { |
… | |
… | |
274 | $self->update_edit_tool ($self->{edit_collection}{erase}, "Erase");; |
294 | $self->update_edit_tool ($self->{edit_collection}{erase}, "Erase");; |
275 | } elsif ($name eq 'select') { |
295 | } elsif ($name eq 'select') { |
276 | $self->update_edit_tool ($self->{edit_collection}{select}, "Select");; |
296 | $self->update_edit_tool ($self->{edit_collection}{select}, "Select");; |
277 | } elsif ($name eq 'perl') { |
297 | } elsif ($name eq 'perl') { |
278 | $self->update_edit_tool ($self->{edit_collection}{perl}, "Eval");; |
298 | $self->update_edit_tool ($self->{edit_collection}{perl}, "Eval");; |
279 | } elsif ($name eq 'connect') { |
299 | } elsif ($name eq 'connectexit') { |
280 | $self->update_edit_tool ($self->{edit_collection}{connect}, "Connect");; |
300 | $self->update_edit_tool ($self->{edit_collection}{connectexit}, "Connect Exit");; |
|
|
301 | } elsif ($name eq 'followexit') { |
|
|
302 | $self->update_edit_tool ($self->{edit_collection}{followexit}, "Follow Exit");; |
281 | } |
303 | } |
282 | } |
304 | } |
283 | |
305 | |
284 | sub update_edit_tool { |
306 | sub update_edit_tool { |
285 | my ($self, $tool, $name) = @_; |
307 | my ($self, $tool, $name) = @_; |