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

Comparing deliantra/gde/GCE/MapEditor.pm (file contents):
Revision 1.49 by elmex, Fri Jan 5 19:20:44 2007 UTC vs.
Revision 1.59 by elmex, Mon Aug 20 07:56:58 2007 UTC

327 } 327 }
328 328
329 push @refs, 329 push @refs,
330 GCE::ArchRef->new ( 330 GCE::ArchRef->new (
331 arch => $arch, 331 arch => $arch,
332 source => 'map',
332 cb => sub { 333 cb => sub {
333 $map->change_begin ('attredit'); 334 $map->change_begin ('attredit');
334 $map->change_stack ($ox, $oy, $cstack); 335 $map->change_stack ($ox, $oy, $cstack);
335 336
336 if (my $changeset = $map->change_end) { 337 if (my $changeset = $map->change_end) {
383 $self->{map}->set_map ($path); 384 $self->{map}->set_map ($path);
384 delete $self->{meta_info}; 385 delete $self->{meta_info};
385 $self->set_title ('<ram>'); 386 $self->set_title ('<ram>');
386 387
387 } else { 388 } else {
389 my $ok = 0;
388 unless (-e $path && -f $path) { 390 if (-e $path && -f $path) {
391 $ok = 1;
392 } else {
393 unless ($path =~ m/\.map$/) { # yuck
394 my $p = $path . '.map';
395 if ($ok = -e $p && -f $p) {
396 $path = $p;
397 }
398 }
399 }
400 unless ($ok) {
389 die "Couldn't open '$path': No such file or it is not a file.\n"; 401 die "Couldn't open '$path' or find '$path.map': No such file or it is not a file.\n";
390 } 402 }
391 $self->{path} = $path; 403 $self->{path} = $path;
392 $self->{map}->set_map (my $m = new_from_file Crossfire::Map $path); 404 $self->{map}->set_map (my $m = new_from_file Crossfire::Map $path);
393 $self->{meta_info} = load_meta_info ($path); 405 $self->{meta_info} = load_meta_info ($path);
394 $self->set_title ("gce - map editor - $self->{path}"); 406 $self->set_title ("gce - map editor - $self->{path}");
407 $::MAINWIN->add_recent($path);
395 } 408 }
396 $self->close_windows; 409 $self->close_windows;
397} 410}
398 411
399sub save_map { 412sub save_map {
404 if ($self->{meta_info}) { 417 if ($self->{meta_info}) {
405 save_meta_info ($self->{path}, $self->{meta_info}); 418 save_meta_info ($self->{path}, $self->{meta_info});
406 } 419 }
407 quick_msg ($self, "saved to $self->{path}"); 420 quick_msg ($self, "saved to $self->{path}");
408 $self->set_title ("gce - map editor - $self->{path}"); 421 $self->set_title ("gce - map editor - $self->{path}");
422 $::MAINWIN->add_recent($self->{path});
409 } else { 423 } else {
410 $self->save_map_as; 424 $self->save_map_as;
411 } 425 }
412} 426}
413 427
419 if ('ok' eq $fc->run) { 433 if ('ok' eq $fc->run) {
420 434
421 $::MAINWIN->{fc_last_folder} = $fc->get_current_folder; 435 $::MAINWIN->{fc_last_folder} = $fc->get_current_folder;
422 $::MAINWIN->{fc_last_folders}->{$self->{fc_last_folder}}++; 436 $::MAINWIN->{fc_last_folders}->{$self->{fc_last_folder}}++;
423 437
424 $self->{map}{map}->write_file ($self->{path} = $fc->get_filename); 438 if($fc->get_filename) {
425 if ($self->{meta_info}) { 439 $self->{path} = $fc->get_filename;
426 save_meta_info ($self->{path}, $self->{meta_info}); 440 $self->save_map;
427 } 441 }
428 quick_msg ($self, "saved to $self->{path}");
429 $self->set_title ("gce - map editor - $self->{path}");
430 } 442 }
431 443
432 $fc->destroy; 444 $fc->destroy;
433} 445}
434 446
450 ref_hash => $self->{map}{map}{info}, 462 ref_hash => $self->{map}{map}{info},
451 dialog => [ 463 dialog => [
452 [width => 'Width' => 'string'], 464 [width => 'Width' => 'string'],
453 [height => 'Height' => 'string'], 465 [height => 'Height' => 'string'],
454 ], 466 ],
467 close_on_save => 1,
468 save_button_label => 'resize',
455 save_cb => sub { 469 save_cb => sub {
456 my ($info) = @_; 470 my ($info) = @_;
457 $self->{map}{map}->resize ($info->{width}, $info->{height}); 471 $self->{map}{map}->resize ($info->{width}, $info->{height});
458 $self->{map}->invalidate_all; 472 $self->{map}->set_map ($self->{map}{map});
459 $w->destroy;
460 } 473 }
461 ); 474 );
462 475
463 $w->signal_connect (destroy => sub { delete $self->{meta_info_win} }); 476 $w->signal_connect (destroy => sub { delete $self->{meta_info_win} });
464 477
503 [undef => x => 'sep' ], 516 [undef => x => 'sep' ],
504 [cf_login => 'Server login name' => 'string'], 517 [cf_login => 'Server login name' => 'string'],
505 [cf_password=> 'Password' => 'password'], 518 [cf_password=> 'Password' => 'password'],
506 [path => 'Map path' => 'string'], 519 [path => 'Map path' => 'string'],
507 ], 520 ],
521 close_on_save => 1,
508 save_cb => sub { 522 save_cb => sub {
509 my ($meta) = @_; 523 my ($meta) = @_;
510 warn "UPLOAD[".Crossfire::to_json ($meta)."]\n"; 524 warn "UPLOAD[".Crossfire::to_json ($meta)."]\n";
511 } 525 }
512 ); 526 );
629 $w->init ( 643 $w->init (
630 dialog_default_size => [500, 500, 220, 20], 644 dialog_default_size => [500, 500, 220, 20],
631 layout_name => 'map_prop_win', 645 layout_name => 'map_prop_win',
632 title => 'map properties', 646 title => 'map properties',
633 ref_hash => $self->{map}{map}{info}, 647 ref_hash => $self->{map}{map}{info},
648 close_on_save => 1,
634 dialog => [ 649 dialog => [
635 [qw/name Name string/], 650 [qw/name Name string/],
636 [qw/region Region string/], 651 [qw/region Region string/],
637 [qw/enter_x Enter-x string/], 652 [qw/enter_x Enter-x string/],
638 [qw/enter_y Enter-y string/], 653 [qw/enter_y Enter-y string/],
654 # [qw/msg Text text/], 669 # [qw/msg Text text/],
655# [qw/maplore Maplore text/], 670# [qw/maplore Maplore text/],
656 [qw/outdoor Outdoor check/], 671 [qw/outdoor Outdoor check/],
657 [qw/unique Unique check/], 672 [qw/unique Unique check/],
658 [qw/fixed_resettime Fixed-resettime check/], 673 [qw/fixed_resettime Fixed-resettime check/],
674 [per_player => 'Per player' => 'check'],
675 [per_party => 'Per party' => 'check'],
676 [no_reset => 'No reset' => 'check'],
677 [music => 'Map Music' => 'string'],
659 [undef, qw/x sep/], 678 [undef, qw/x sep/],
660 [qw/tile_path_1 Northpath string/], 679 [qw/tile_path_1 Northpath string/],
661 [qw/tile_path_2 Eastpath string/], 680 [qw/tile_path_2 Eastpath string/],
662 [qw/tile_path_3 Southpath string/], 681 [qw/tile_path_3 Southpath string/],
663 [qw/tile_path_4 Westpath string/], 682 [qw/tile_path_4 Westpath string/],

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines