ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/pclient
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.149 by root, Thu Apr 20 02:43:01 2006 UTC vs.
Revision 1.150 by root, Thu Apr 20 07:12:58 2006 UTC

98 undef $CONN; 98 undef $CONN;
99} 99}
100 100
101sub client_setup { 101sub client_setup {
102 my $dialog = new CFClient::UI::FancyFrame 102 my $dialog = new CFClient::UI::FancyFrame
103 title => "Client Setup",
103 child => (my $vbox = new CFClient::UI::VBox); 104 child => (my $vbox = new CFClient::UI::VBox);
104 $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Client Setup");
105 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 105 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
106 106
107 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode"); 107 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode");
108 $table->add (1, 0, my $hbox = new CFClient::UI::HBox); 108 $table->add (1, 0, my $hbox = new CFClient::UI::HBox);
109 109
110 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); 110 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]);
111 $hbox->add (my $mode_label = new CFClient::UI::Label valign => 0, height => 0.8); 111 $hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999");
112 112
113 $mode_slider->connect (changed => sub { 113 $mode_slider->connect (changed => sub {
114 my ($self, $value) = @_; 114 my ($self, $value) = @_;
115 115
116 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 116 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
191 $dialog 191 $dialog
192} 192}
193 193
194sub metaserver_dialog { 194sub metaserver_dialog {
195 my $dialog = new CFClient::UI::FancyFrame 195 my $dialog = new CFClient::UI::FancyFrame
196 title => "Metaserver",
196 child => (my $vbox = new CFClient::UI::VBox); 197 child => (my $vbox = new CFClient::UI::VBox);
197 198
198 $vbox->add ($dialog->{table} = new CFClient::UI::Table); 199 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
199 200
200 $dialog 201 $dialog
266 }); 267 });
267} 268}
268 269
269sub server_setup { 270sub server_setup {
270 my $dialog = new CFClient::UI::FancyFrame 271 my $dialog = new CFClient::UI::FancyFrame
272 title => "Server Setup",
271 child => (my $vbox = new CFClient::UI::VBox); 273 child => (my $vbox = new CFClient::UI::VBox);
272 274
273 $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Server Setup");
274 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 275 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
275 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); 276 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port");
276 277
277 { 278 {
278 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 279 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
325 $dialog 326 $dialog
326} 327}
327 328
328sub message_window { 329sub message_window {
329 my $window = new CFClient::UI::FancyFrame 330 my $window = new CFClient::UI::FancyFrame
331 title => "Messages",
330 border_bg => [1, 1, 1, 0.5], 332 border_bg => [1, 1, 1, 0.5],
331 bg => [0.3, 0.3, 0.3, 0.8], 333 bg => [0.3, 0.3, 0.3, 0.8],
332 user_w => int $::WIDTH / 3, 334 user_w => int $::WIDTH / 3,
333 user_h => int $::HEIGHT / 5, 335 user_h => int $::HEIGHT / 5,
334 child => (my $vbox = new CFClient::UI::VBox); 336 child => (my $vbox = new CFClient::UI::VBox);
443 status "Configuration Saved"; 445 status "Configuration Saved";
444 }); 446 });
445 447
446 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 448 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
447 449
448 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0); 450 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0, title => "Stats");
449 $tgw->add (my $hbox = new CFClient::UI::HBox ()); 451 $tgw->add (my $hbox = new CFClient::UI::HBox ());
450 452
451 $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp')); 453 $hbox->add (my $hg = new CFClient::UI::Gauge (type => 'hp'));
452 $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana')); 454 $hbox->add (my $mg = new CFClient::UI::Gauge (type => 'mana'));
453 $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace')); 455 $hbox->add (my $gg = new CFClient::UI::Gauge (type => 'grace'));
454 $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food')); 456 $hbox->add (my $fg = new CFClient::UI::Gauge (type => 'food'));
455 457
456 $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg }; 458 $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg };
457 $CFClient::UI::ROOT->add ($tgw); 459 $CFClient::UI::ROOT->add ($tgw);
458} 460}
459 461
569 my $hp = $stats->{1}; 571 my $hp = $stats->{1};
570 my $hp_m = $stats->{2}; 572 my $hp_m = $stats->{2};
571 my $sp = $stats->{3}; 573 my $sp = $stats->{3};
572 my $sp_m = $stats->{4}; 574 my $sp_m = $stats->{4};
573 my $fo = $stats->{18}; 575 my $fo = $stats->{18};
574 my $fo_m = 1000; 576 my $fo_m = 999;
575 my $gr = $stats->{23}; 577 my $gr = $stats->{23};
576 my $gr_m = $stats->{24}; 578 my $gr_m = $stats->{24};
577 579
578 #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n"; 580 #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n";
579 $GAUGES->{hp}->set_value ($hp, $hp_m); 581 $GAUGES->{hp} ->set_value ($hp, $hp_m);
580 $GAUGES->{mana}->set_value ($sp, $sp_m); 582 $GAUGES->{mana} ->set_value ($sp, $sp_m);
581 $GAUGES->{food}->set_value ($fo, $fo_m); 583 $GAUGES->{food} ->set_value ($fo, $fo_m);
582 $GAUGES->{grace}->set_value ($gr, $gr_m); 584 $GAUGES->{grace}->set_value ($gr, $gr_m);
583} 585}
584 586
585sub conn::user_send { 587sub conn::user_send {
586 my ($self, $command) = @_; 588 my ($self, $command) = @_;
621 623
622sub conn::map_clear { 624sub conn::map_clear {
623 my ($self) = @_; 625 my ($self) = @_;
624 626
625 $self->flush_map; 627 $self->flush_map;
626 delete $self->{neigh}; 628 delete $self->{neigh_map};
627 629
628 $MAP->clear; 630 $MAP->clear;
629} 631}
630 632
631 633
643 } 645 }
644 } 646 }
645} 647}
646 648
647sub conn::flood_fill { 649sub conn::flood_fill {
648 my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_; 650 my ($self, $gx, $gy, $path, $hash, $flags) = @_;
649 651
650 # the server does not allow map paths > 6 652 # the server does not allow map paths > 6
651 return if 6 <= length $path; 653 return if 6 <= length $path;
652 654
653 for my $tile (1..4) { 655 my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}};
654 next if $self->{neigh}{$hash}[$tile]; 656
657 for (
658 [1, 0, -1],
659 [2, 1, 0],
660 [3, 0, 1],
661 [4, -1, 0],
662 ) {
663 my ($tile, $dx, $dy) = @$_;
664
665 my $gx = $gx + $dx;
666 my $gy = $gy + $dy;
667
655 next unless $flags & (1 << ($tile - 1)); 668 next unless $flags & (1 << ($tile - 1));
669 next if $self->{neigh_grid}{$gx, $gy}++;
656 670
657 my $neigh = $self->{neigh}{$hash} ||= []; 671 my $neigh = $self->{neigh_map}{$hash} ||= [];
658 672 if (my $info = $neigh->[$tile]) {
659 $self->send_mapinfo ("spatial $path$tile", sub {
660 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; 673 my ($flags, $x, $y, $w, $h, $hash) = @$info;
661 674
662 #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d#
663 return if $mode ne "spatial";
664
665 $x += $MAP->ox;
666 $y += $MAP->oy;
667
668 $self->load_map ($hash, $x, $y)
669 unless $self->{neigh}{$hash}[5]++;#d#
670
671 $neigh->[$tile] = [$x, $y, $w, $h];
672
673 $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) 675 $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags)
674 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; 676 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
677
678 } else {
679 $self->send_mapinfo ("spatial $path$tile", sub {
680 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
681
682 #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d#
683 return if $mode ne "spatial";
684
685 $x += $MAP->ox;
686 $y += $MAP->oy;
687
688 $self->load_map ($hash, $x, $y)
689 unless $self->{neigh_map}{$hash}[5]++;#d#
690
691 $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash];
692
693 $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags)
694 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
695 });
675 }); 696 }
676 } 697 }
677} 698}
678 699
679sub conn::map_change { 700sub conn::map_change {
680 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 701 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
683 704
684 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 705 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
685 706
686 my $mapmapw = 250; 707 my $mapmapw = 250;
687 my $mapmaph = 250; 708 my $mapmaph = 250;
709
710 $self->{neigh_rect} = [
711 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5,
712 $ox + $mapmapw * 0.5, $oy + $mapmapw * 0.5,
713 ];
688 714
715 delete $self->{neigh_grid};
689 $self->flood_fill ("", $hash, $flags, 716 $self->flood_fill (0, 0, "", $hash, $flags);
690 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5,
691 $ox + $mapmapw * 0.5, $oy + $mapmapw * 0.5);
692 717
693 $x += $ox; 718 $x += $ox;
694 $y += $oy; 719 $y += $oy;
695 720
696 $self->{map_info} = [$hash, $x, $y, $w, $h]; 721 $self->{map_info} = [$hash, $x, $y, $w, $h];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines