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

Comparing deliantra/gde/GCE/MainWindow.pm (file contents):
Revision 1.32 by elmex, Sun Mar 12 23:32:58 2006 UTC vs.
Revision 1.33 by elmex, Wed Mar 15 21:45:54 2006 UTC

236 my ($self) = @_; 236 my ($self) = @_;
237 237
238 my $tbl = Gtk2::Table->new (2, 2); 238 my $tbl = Gtk2::Table->new (2, 2);
239 my $plcinfo = { width => 1, height => 3, next => [0, 0] }; 239 my $plcinfo = { width => 1, height => 3, next => [0, 0] };
240 240
241 $self->{edit_collection}{pick} = GCE::EditAction::Pick->new; 241 $self->{edit_collection}{pick} = GCE::EditAction::Pick->new;
242 $self->{edit_collection}{place} = GCE::EditAction::Place->new; 242 $self->{edit_collection}{place} = GCE::EditAction::Place->new;
243 $self->{edit_collection}{erase} = GCE::EditAction::Erase->new; 243 $self->{edit_collection}{erase} = GCE::EditAction::Erase->new;
244 244
245 $self->update_edit_tool ($self->{edit_collection}{pick}, "Pick"); 245 $self->set_edit_tool ('pick');
246 246
247 $self->add_button ($tbl, $plcinfo, "Pick", sub { 247 $self->add_button ($tbl, $plcinfo, "Pick", sub { $self->set_edit_tool ('pick') });
248 $self->add_button ($tbl, $plcinfo, "Place", sub { $self->set_edit_tool ('place') });
249 $self->add_button ($tbl, $plcinfo, "Erase", sub { $self->set_edit_tool ('erase') });
250
251 return $tbl;
252}
253
254sub set_edit_tool {
255 my ($self, $name) = @_;
256
257 if ($name eq 'pick') {
248 $self->update_edit_tool ($self->{edit_collection}{pick}, "Pick");; 258 $self->update_edit_tool ($self->{edit_collection}{pick}, "Pick");;
249 }); 259 } elsif ($name eq 'place') {
250 $self->add_button ($tbl, $plcinfo, "Place", sub {
251 $self->update_edit_tool ($self->{edit_collection}{place}, "Place");; 260 $self->update_edit_tool ($self->{edit_collection}{place}, "Place");;
252 }); 261 } elsif ($name eq 'erase') {
253 $self->add_button ($tbl, $plcinfo, "Erase", sub {
254 $self->update_edit_tool ($self->{edit_collection}{erase}, "Erase");; 262 $self->update_edit_tool ($self->{edit_collection}{erase}, "Erase");;
255 }); 263 }
256
257 return $tbl;
258} 264}
259 265
260sub update_edit_tool { 266sub update_edit_tool {
261 my ($self, $tool, $name) = @_; 267 my ($self, $tool, $name) = @_;
262 268
288 or return; 294 or return;
289 295
290 fill_pb_from_arch ($self->{pick_view_pb}, $arch); 296 fill_pb_from_arch ($self->{pick_view_pb}, $arch);
291 $self->{pick_view_img}->set_from_pixbuf ($self->{pick_view_pb}); 297 $self->{pick_view_img}->set_from_pixbuf ($self->{pick_view_pb});
292 298
293 $self->{pick_view_lbl}->set_text ($arch->{_name}); 299 $self->{pick_view_btn}->set_label ($arch->{_name});
294} 300}
295 301
296sub INIT_INSTANCE { 302sub INIT_INSTANCE {
297 my ($self) = @_; 303 my ($self) = @_;
298 304
306 $self->add (my $vb = Gtk2::VBox->new); 312 $self->add (my $vb = Gtk2::VBox->new);
307 $vb->pack_start ($self->build_menu, 0, 1, 0); 313 $vb->pack_start ($self->build_menu, 0, 1, 0);
308 314
309 $vb->pack_start (my $hb = $self->{pick_view_hb} = Gtk2::HBox->new, 0, 1, 0); 315 $vb->pack_start (my $hb = $self->{pick_view_hb} = Gtk2::HBox->new, 0, 1, 0);
310 $hb->pack_start ($self->{pick_view_img} = Gtk2::Image->new, 0, 1, 0); 316 $hb->pack_start ($self->{pick_view_img} = Gtk2::Image->new, 0, 1, 0);
311 $hb->pack_start ($self->{pick_view_lbl} = Gtk2::Label->new, 0, 1, 0); 317 $hb->pack_start ($self->{pick_view_btn} = Gtk2::Button->new, 0, 1, 0);
318 $self->{pick_view_btn}->drag_source_set (['button1_mask'], ['move'],
319 { target => 'STRING', flags => [], info => 'TARGET_STRING' }
320 );
321 $self->{pick_view_btn}->signal_connect (drag_data_get => sub {
322 my ($widget, $context, $data, $info, $time) = @_;
323 $data->set ($data->target, 8, "pick");
324 });
312 $self->{pick_view_pb} = new_arch_pb (); 325 $self->{pick_view_pb} = new_arch_pb ();
313 326
314 $vb->pack_start (Gtk2::HSeparator->new, 0, 1, 0); 327 $vb->pack_start (Gtk2::HSeparator->new, 0, 1, 0);
315 $vb->pack_start (my $tbl = $self->build_buttons, 0, 1, 0); 328 $vb->pack_start (my $tbl = $self->build_buttons, 0, 1, 0);
316 329
341 add_table_widget ($tbl, 0, $width, 'string'); 354 add_table_widget ($tbl, 0, $width, 'string');
342 add_table_widget ($tbl, 1, $height, 'string'); 355 add_table_widget ($tbl, 1, $height, 'string');
343 add_table_widget ($tbl, 2, 'new', 'button', sub { 356 add_table_widget ($tbl, 2, 'new', 'button', sub {
344 if ($width->[1] > 0 and $height->[1] > 0) { 357 if ($width->[1] > 0 and $height->[1] > 0) {
345 my $map = Crossfire::Map->new ($width->[1], $height->[1]); 358 my $map = Crossfire::Map->new ($width->[1], $height->[1]);
359 $map->resize ($width->[1], $height->[1]);
346 $self->open_map_editor ($map); 360 $self->open_map_editor ($map);
347 } 361 }
348 $w->destroy; 362 $w->destroy;
349 1; 363 1;
350 }); 364 });
351 add_table_widget ($tbl, 3, 'close', 'button', sub { $w->destroy }); 365 add_table_widget ($tbl, 3, 'close', 'button', sub { $w->destroy });
352 $w->show_all; 366 $w->show_all;
353} 367}
354 368
355sub new_filechooser { 369sub new_filechooser {
356 my ($self) = @_; 370 my ($self, $title, $save) = @_;
357 371
372 $title ||= 'gce - open map';
358 my $fc = new Gtk2::FileChooserDialog ( 373 my $fc = new Gtk2::FileChooserDialog (
359 'gce - open map', undef, 'open', 'gtk-cancel' => 'cancel', 'gtk-ok' => 'ok' 374 $title, undef, $save ? 'save' : 'open', 'gtk-cancel' => 'cancel', 'gtk-ok' => 'ok'
360 ); 375 );
361 376
362 $fc->add_shortcut_folder ("$Crossfire::LIB/maps") if -d "$Crossfire::LIB/maps"; 377 $fc->add_shortcut_folder ("$Crossfire::LIB/maps") if -d "$Crossfire::LIB/maps";
363 $fc->add_shortcut_folder ($_) for keys %{$self->{fc_last_folders}}; 378 $fc->add_shortcut_folder ($_) for keys %{$self->{fc_last_folders}};
364 $fc->set_current_folder ($self->{fc_last_folder} || "$Crossfire::LIB/maps"); 379 $fc->set_current_folder ($self->{fc_last_folder} || "$Crossfire::LIB/maps");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines