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.125 by elmex, Mon Apr 17 20:29:37 2006 UTC

48our $MAPWIDGET; 48our $MAPWIDGET;
49our $BUTTONBAR; 49our $BUTTONBAR;
50our $LOGVIEW; 50our $LOGVIEW;
51our $CONSOLE; 51our $CONSOLE;
52our $METASERVER; 52our $METASERVER;
53
54our $GAUGES;
53 55
54our $SDL_ACTIVE; 56our $SDL_ACTIVE;
55our $SDL_EV; 57our $SDL_EV;
56our %SDL_CB; 58our %SDL_CB;
57 59
300 302
301sub message_window { 303sub message_window {
302 my $window = new CFClient::UI::FancyFrame 304 my $window = new CFClient::UI::FancyFrame
303 border_bg => [1, 1, 1, 0.5], 305 border_bg => [1, 1, 1, 0.5],
304 bg => [0.3, 0.3, 0.3, 0.8], 306 bg => [0.3, 0.3, 0.3, 0.8],
305 user_w => $::WIDTH/4, 307 user_w => int $::WIDTH / 3,
306 user_h => $::HEIGHT, 308 user_h => int $::HEIGHT / 5,
307 child => (my $vbox = new CFClient::UI::VBox); 309 child => (my $vbox = new CFClient::UI::VBox);
308 310
309 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 311 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
310 expand => 1, 312 expand => 1,
311 fontsize => $::CFG->{log_fontsize}, 313 fontsize => $::CFG->{log_fontsize},
312 ); 314 );
313 315
314 $vbox->add (my $input = new CFClient::UI::LineEntry 316 $vbox->add (my $input = new CFClient::UI::Entry
315 connect_focus_in => sub { 317 connect_focus_in => sub {
316 my ($input, $prev_focus) = @_; 318 my ($input, $prev_focus) = @_;
317 319
318 delete $input->{refocus_map}; 320 delete $input->{refocus_map};
319 321
325 connect_activate => sub { 327 connect_activate => sub {
326 my ($input, $text) = @_; 328 my ($input, $text) = @_;
327 $input->set_text (''); 329 $input->set_text ('');
328 330
329 if ($text =~ /^\/(.*)/) { 331 if ($text =~ /^\/(.*)/) {
330 $::CONN->user_send ("command $1"); 332 $::CONN->user_send ($1);
331 } else { 333 } else {
332 my $say_cmd = $::CFG->{say_command} || 'say'; 334 my $say_cmd = $::CFG->{say_command} || 'say';
333 $::CONN->user_send ("command $say_cmd $text"); 335 $::CONN->user_send ("$say_cmd $text");
334 } 336 }
335 if ($input->{refocus_map}) { 337 if ($input->{refocus_map}) {
336 delete $input->{refocus_map}; 338 delete $input->{refocus_map};
337 $MAPWIDGET->focus_in 339 $MAPWIDGET->focus_in
338 } 340 }
404 padding => 0, 406 padding => 0,
405 y => $HEIGHT * 44 / 45 - $FONTSIZE; 407 y => $HEIGHT * 44 / 45 - $FONTSIZE;
406 $CFClient::UI::ROOT->add ($STATUS_LINE); 408 $CFClient::UI::ROOT->add ($STATUS_LINE);
407 409
408 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 410 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
409 padding => 0, 411 padding => 0,
410 y => $HEIGHT * 44 / 45, 412 y => $HEIGHT * 44 / 45,
411 height => $HEIGHT / 45, 413 fontsize => $HEIGHT / 45,
412 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 414 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
413 $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); 415 $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE);
414 416
415 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); 417 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget);
416 $MAPWIDGET->focus_in; 418 $MAPWIDGET->focus_in;
417 $MAPWIDGET->connect (activate_console => sub { 419 $MAPWIDGET->connect (activate_console => sub {
436 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 438 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
437 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 439 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
438 status "Configuration Saved"; 440 status "Configuration Saved";
439 }); 441 });
440 442
441 $BUTTONBAR->{children}[0]->emit ("activate"); 443 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
444
445 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 150, y => 0);
446 $tgw->add (my $hb = new CFClient::UI::HBox (req_w => 60, req_h => 150));
447 $hb->add (my $fg = new CFClient::UI::VGauge (w => 30, h => 150, gauge => 'food', expand => 1));
448 $hb->add (my $mg = new CFClient::UI::VGauge (w => 30, h => 150, gauge => 'mana', expand => 1));
449 $hb->add (my $hg = new CFClient::UI::VGauge (w => 30, h => 150, gauge => 'hp', expand => 1));
450 $hb->add (my $gg = new CFClient::UI::VGauge (w => 30, h => 150, gauge => 'grace', expand => 1));
451
452 $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg };
453 $CFClient::UI::ROOT->add ($tgw);
442} 454}
443 455
444sub destroy_screen { 456sub destroy_screen {
445 $CFClient::UI::ROOT->{children} = []; 457 $CFClient::UI::ROOT->{children} = [];
446 undef $SDL_ACTIVE; 458 undef $SDL_ACTIVE;
502 delete $animate_object{$widget}; 514 delete $animate_object{$widget};
503} 515}
504 516
505@conn::ISA = Crossfire::Protocol::; 517@conn::ISA = Crossfire::Protocol::;
506 518
519sub conn::stats_update {
520 my ($self, $stats) = @_;
521
522 # i love text protocols!!!
523 # FIXME: the stats are somehow weird
524 my $hp = $stats->{1};
525 my $hp_m = $stats->{2};
526 my $sp = $stats->{3};
527 my $sp_m = $stats->{4};
528 my $fo = $stats->{18};
529 my $fo_m = 1000;
530 my $gr = $stats->{23};
531 my $gr_m = $stats->{24};
532
533 #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n";
534 $GAUGES->{hp}->set_value ($hp, $hp_m);
535 $GAUGES->{mana}->set_value ($sp, $sp_m);
536 $GAUGES->{food}->set_value ($fo, $fo_m);
537 $GAUGES->{grace}->set_value ($gr, $gr_m);
538}
539
507sub conn::user_send { 540sub conn::user_send {
508 my ($self, $command) = @_; 541 my ($self, $command) = @_;
509 542
510 $self->send ($command); 543 $self->send_command ($command);
511 status $command; 544 status $command;
545}
546
547sub conn::map_scroll {
548 my ($self, $dx, $dy) = @_;
549
550 $MAP->scroll ($dx, $dy);
512} 551}
513 552
514sub conn::feed_map1a { 553sub conn::feed_map1a {
515 my ($self, $data) = @_; 554 my ($self, $data) = @_;
516 555
517# $self->Crossfire::Protocol::feed_map1a ($data); 556# $self->Crossfire::Protocol::feed_map1a ($data);
518 557
519 $MAP->scroll (delete $self->{delayed_scroll_x}, delete $self->{delayed_scroll_y});
520 $MAP->map1a_update ($data); 558 $MAP->map1a_update ($data);
521 $MAPWIDGET->update; 559 $MAPWIDGET->update;
522} 560}
523 561
524sub conn::flush_map { 562sub conn::flush_map {
538 576
539sub conn::map_clear { 577sub conn::map_clear {
540 my ($self) = @_; 578 my ($self) = @_;
541 579
542 $self->flush_map; 580 $self->flush_map;
581 delete $self->{neigh};
543 582
544 $MAP->clear; 583 $MAP->clear;
545} 584}
546 585
547sub conn::map_info {
548 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
549 586
550 $self->flush_map; 587sub conn::load_map($$$) {
551 588 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 589
557 if (defined (my $data = $MAPCACHE->get ($hash))) { 590 if (defined (my $data = $MAPCACHE->get ($hash))) {
558 $data = Compress::LZF::decompress $data; 591 $data = Compress::LZF::decompress $data;
559 warn sprintf "LOADmap[%s] length %d\n", $hash, length $data;#d# 592 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)) { 593 for my $id ($MAP->set_rect ($x, $y, $data)) {
561 my $data = $TILECACHE->get ($id) 594 my $data = $TILECACHE->get ($id)
562 or next; 595 or next;
563 596
564 $self->set_texture ($id => $data); 597 $self->set_texture ($id => $data);
565 } 598 }
566 } 599 }
600}
601
602sub conn::flood_fill {
603 my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_;
604
605 # the server does not allow map paths > 6
606 return if 6 <= length $path;
607
608 for my $tile (1..4) {
609 next if $self->{neigh}{$hash}[$tile];
610 next unless $flags & (1 << ($tile - 1));
611
612 my $neigh = $self->{neigh}{$hash} ||= [];
613
614 $self->send_mapinfo ("spatial $path$tile", sub {
615 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
616
617 #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d#
618 return if $mode ne "spatial";
619
620 $x += $MAP->ox;
621 $y += $MAP->oy;
622
623 $self->load_map ($hash, $x, $y)
624 unless $self->{neigh}{$hash}[5]++;#d#
625
626 $neigh->[$tile] = [$x, $y, $w, $h];
627
628 $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1)
629 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
630 });
631 }
632}
633
634sub conn::map_change {
635 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
636
637 $self->flush_map;
638
639 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
640
641 warn "$ox $oy map_info<$flags, $x, $y, $w, $h, $hash>\n";#d#
642
643 my $mapmapw = 250;
644 my $mapmaph = 250;
645
646 $self->flood_fill ("", $hash, $flags,
647 $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5,
648 $ox + $mapmapw * 0.5, $oy + $mapmapw * 0.5);
649
650 $x += $ox;
651 $y += $oy;
652
653 $self->{map_info} = [$hash, $x, $y, $w, $h];
654
655 $self->load_map ($hash, $x, $y);
567} 656}
568 657
569sub conn::face_find { 658sub conn::face_find {
570 my ($self, $facenum, $face) = @_; 659 my ($self, $facenum, $face) = @_;
571 660
723 812
724@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 813@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
725 814
726$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 815$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
727 816
728init_screen;
729
730{ 817{
731 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 818 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf);
732 819
733 CFClient::add_font $_ for @fonts; 820 CFClient::add_font $_ for @fonts;
734 CFClient::set_font $fonts[0]; 821 CFClient::set_font $fonts[0];
735} 822}
736 823
824init_screen;
825
737Event::loop; 826Event::loop;
738 827
739 828

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines