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.118 by elmex, Sun Apr 16 17:43:17 2006 UTC vs.
Revision 1.123 by root, Mon Apr 17 19:36:27 2006 UTC

309 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 309 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
310 expand => 1, 310 expand => 1,
311 fontsize => $::CFG->{log_fontsize}, 311 fontsize => $::CFG->{log_fontsize},
312 ); 312 );
313 313
314 $vbox->add (my $input = new CFClient::UI::LineEntry 314 $vbox->add (my $input = new CFClient::UI::Entry
315 connect_focus_in => sub { 315 connect_focus_in => sub {
316 my ($input, $prev_focus) = @_; 316 my ($input, $prev_focus) = @_;
317 317
318 delete $input->{refocus_map}; 318 delete $input->{refocus_map};
319 319
325 connect_activate => sub { 325 connect_activate => sub {
326 my ($input, $text) = @_; 326 my ($input, $text) = @_;
327 $input->set_text (''); 327 $input->set_text ('');
328 328
329 if ($text =~ /^\/(.*)/) { 329 if ($text =~ /^\/(.*)/) {
330 $::CONN->user_send ("command $1"); 330 $::CONN->user_send ($1);
331 } else { 331 } else {
332 my $say_cmd = $::CFG->{say_command} || 'say'; 332 my $say_cmd = $::CFG->{say_command} || 'say';
333 $::CONN->user_send ("command $say_cmd $text"); 333 $::CONN->user_send ("$say_cmd $text");
334 } 334 }
335 if ($input->{refocus_map}) { 335 if ($input->{refocus_map}) {
336 delete $input->{refocus_map}; 336 delete $input->{refocus_map};
337 $MAPWIDGET->focus_in 337 $MAPWIDGET->focus_in
338 } 338 }
404 padding => 0, 404 padding => 0,
405 y => $HEIGHT * 44 / 45 - $FONTSIZE; 405 y => $HEIGHT * 44 / 45 - $FONTSIZE;
406 $CFClient::UI::ROOT->add ($STATUS_LINE); 406 $CFClient::UI::ROOT->add ($STATUS_LINE);
407 407
408 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 408 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
409 padding => 0, 409 padding => 0,
410 y => $HEIGHT * 44 / 45, 410 y => $HEIGHT * 44 / 45,
411 height => $HEIGHT / 45, 411 fontsize => $HEIGHT / 45,
412 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 412 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
413 $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); 413 $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE);
414 414
415 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); 415 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget);
416 $MAPWIDGET->focus_in; 416 $MAPWIDGET->focus_in;
417 $MAPWIDGET->connect (activate_console => sub { 417 $MAPWIDGET->connect (activate_console => sub {
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
444sub destroy_screen { 444sub destroy_screen {
445 $CFClient::UI::ROOT->{children} = []; 445 $CFClient::UI::ROOT->{children} = [];
446 undef $SDL_ACTIVE; 446 undef $SDL_ACTIVE;
505@conn::ISA = Crossfire::Protocol::; 505@conn::ISA = Crossfire::Protocol::;
506 506
507sub conn::user_send { 507sub conn::user_send {
508 my ($self, $command) = @_; 508 my ($self, $command) = @_;
509 509
510 $self->send ($command); 510 $self->send_command ($command);
511 status $command; 511 status $command;
512}
513
514sub conn::map_scroll {
515 my ($self, $dx, $dy) = @_;
516
517 $MAP->scroll ($dx, $dy);
512} 518}
513 519
514sub conn::feed_map1a { 520sub 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
524sub conn::flush_map { 529sub conn::flush_map {
538 543
539sub conn::map_clear { 544sub 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
547sub conn::map_info {
548 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
549 553
550 $self->flush_map; 554sub 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
569sub conn::flood_fill {
570 my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_;
571
572 # the server does not allow map paths > 6
573 return if 6 <= length $path;
574
575 for my $tile (1..4) {
576 next if $self->{neigh}{$hash}[$tile];
577 next unless $flags & (1 << ($tile - 1));
578
579 my $neigh = $self->{neigh}{$hash} ||= [];
580
581 $self->send_mapinfo ("spatial $path$tile", sub {
582 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
583
584 #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d#
585 return if $mode ne "spatial";
586
587 $x += $MAP->ox;
588 $y += $MAP->oy;
589
590 $self->load_map ($hash, $x, $y);
591
592 $neigh->[$tile] = [$x, $y, $w, $h];
593
594 $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1)
595 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
596 });
597 }
598}
599
600sub conn::map_change {
601 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
602
603 $self->flush_map;
604
605 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
606
607 warn "$ox $oy map_info<$flags, $x, $y, $w, $h, $hash>\n";#d#
608
609 my $mapmapw = 250;
610 my $mapmaph = 250;
611
612 $self->flood_fill ("", $hash, $flags,
613 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5,
614 $ox + $mapmapw * 0.5, $oy + $mapmapw * 0.5);
615
616 $x += $ox;
617 $y += $oy;
618
619 $self->{map_info} = [$hash, $x, $y, $w, $h];
620
621 $self->load_map ($hash, $x, $y);
567} 622}
568 623
569sub conn::face_find { 624sub conn::face_find {
570 my ($self, $facenum, $face) = @_; 625 my ($self, $facenum, $face) = @_;
571 626
723 778
724@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 779@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
725 780
726$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 781$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
727 782
728init_screen;
729
730{ 783{
731 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 784 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf);
732 785
733 CFClient::add_font $_ for @fonts; 786 CFClient::add_font $_ for @fonts;
734 CFClient::set_font $fonts[0]; 787 CFClient::set_font $fonts[0];
735} 788}
736 789
790init_screen;
791
737Event::loop; 792Event::loop;
738 793
739 794

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines