… | |
… | |
436 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
436 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
437 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
437 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
438 | status "Configuration Saved"; |
438 | status "Configuration Saved"; |
439 | }); |
439 | }); |
440 | |
440 | |
441 | $BUTTONBAR->{children}[0]->emit ("activate"); |
441 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
442 | } |
442 | } |
443 | |
443 | |
444 | sub destroy_screen { |
444 | sub destroy_screen { |
445 | $CFClient::UI::ROOT->{children} = []; |
445 | $CFClient::UI::ROOT->{children} = []; |
446 | undef $SDL_ACTIVE; |
446 | undef $SDL_ACTIVE; |
… | |
… | |
509 | |
509 | |
510 | $self->send ($command); |
510 | $self->send ($command); |
511 | status $command; |
511 | status $command; |
512 | } |
512 | } |
513 | |
513 | |
|
|
514 | sub conn::map_scroll { |
|
|
515 | my ($self, $dx, $dy) = @_; |
|
|
516 | |
|
|
517 | $MAP->scroll ($dx, $dy); |
|
|
518 | } |
|
|
519 | |
514 | sub conn::feed_map1a { |
520 | sub conn::feed_map1a { |
515 | my ($self, $data) = @_; |
521 | my ($self, $data) = @_; |
516 | |
522 | |
517 | # $self->Crossfire::Protocol::feed_map1a ($data); |
523 | # $self->Crossfire::Protocol::feed_map1a ($data); |
518 | |
524 | |
519 | $MAP->scroll (delete $self->{delayed_scroll_x}, delete $self->{delayed_scroll_y}); |
|
|
520 | $MAP->map1a_update ($data); |
525 | $MAP->map1a_update ($data); |
521 | $MAPWIDGET->update; |
526 | $MAPWIDGET->update; |
522 | } |
527 | } |
523 | |
528 | |
524 | sub conn::flush_map { |
529 | sub conn::flush_map { |
… | |
… | |
538 | |
543 | |
539 | sub conn::map_clear { |
544 | sub conn::map_clear { |
540 | my ($self) = @_; |
545 | my ($self) = @_; |
541 | |
546 | |
542 | $self->flush_map; |
547 | $self->flush_map; |
|
|
548 | delete $self->{neigh}; |
543 | |
549 | |
544 | $MAP->clear; |
550 | $MAP->clear; |
545 | } |
551 | } |
546 | |
552 | |
547 | sub conn::map_info { |
|
|
548 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
|
|
549 | |
553 | |
550 | $self->flush_map; |
554 | sub conn::load_map($$$) { |
551 | |
555 | my ($self, $hash, $x, $y) = @_; |
552 | $x = $::MAP->ox - $x; |
|
|
553 | $y = $::MAP->oy - $y; |
|
|
554 | |
|
|
555 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
|
|
556 | |
556 | |
557 | if (defined (my $data = $MAPCACHE->get ($hash))) { |
557 | if (defined (my $data = $MAPCACHE->get ($hash))) { |
558 | $data = Compress::LZF::decompress $data; |
558 | $data = Compress::LZF::decompress $data; |
559 | warn sprintf "LOADmap[%s] length %d\n", $hash, length $data;#d# |
559 | warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
560 | for my $id ($MAP->set_rect ($x, $y, $data)) { |
560 | for my $id ($MAP->set_rect ($x, $y, $data)) { |
561 | my $data = $TILECACHE->get ($id) |
561 | my $data = $TILECACHE->get ($id) |
562 | or next; |
562 | or next; |
563 | |
563 | |
564 | $self->set_texture ($id => $data); |
564 | $self->set_texture ($id => $data); |
565 | } |
565 | } |
566 | } |
566 | } |
|
|
567 | } |
|
|
568 | |
|
|
569 | sub conn::flood_fill { |
|
|
570 | my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_; |
|
|
571 | |
|
|
572 | for my $tile (1..4) { |
|
|
573 | next if $self->{neigh}{$hash}[$tile]; |
|
|
574 | next unless $flags & (1 << ($tile - 1)); |
|
|
575 | |
|
|
576 | my $neigh = $self->{neigh}{$hash} ||= []; |
|
|
577 | |
|
|
578 | $self->send_mapinfo ("spatial $path$tile", sub { |
|
|
579 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
|
|
580 | |
|
|
581 | warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# |
|
|
582 | return if $mode ne "spatial"; |
|
|
583 | |
|
|
584 | $x += $MAP->ox; |
|
|
585 | $y += $MAP->oy; |
|
|
586 | |
|
|
587 | $self->load_map ($hash, $x, $y); |
|
|
588 | |
|
|
589 | $neigh->[$tile] = [$x, $y, $w, $h]; |
|
|
590 | |
|
|
591 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
|
|
592 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
|
|
593 | }); |
|
|
594 | } |
|
|
595 | } |
|
|
596 | |
|
|
597 | sub conn::map_change { |
|
|
598 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
|
|
599 | |
|
|
600 | $self->flush_map; |
|
|
601 | |
|
|
602 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
|
|
603 | |
|
|
604 | warn "$ox $oy map_info<$flags, $x, $y, $w, $h, $hash>\n";#d# |
|
|
605 | |
|
|
606 | my $mapmapw = 250; |
|
|
607 | my $mapmaph = 250; |
|
|
608 | |
|
|
609 | $self->flood_fill ("", $hash, $flags, |
|
|
610 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
|
|
611 | $ox + $mapmapw * 0.5, $oy + $mapmapw * 0.5); |
|
|
612 | |
|
|
613 | $x += $ox; |
|
|
614 | $y += $oy; |
|
|
615 | |
|
|
616 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
|
|
617 | |
|
|
618 | $self->load_map ($hash, $x, $y); |
567 | } |
619 | } |
568 | |
620 | |
569 | sub conn::face_find { |
621 | sub conn::face_find { |
570 | my ($self, $facenum, $face) = @_; |
622 | my ($self, $facenum, $face) = @_; |
571 | |
623 | |