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.120 by root, Mon Apr 17 07:51:24 2006 UTC vs.
Revision 1.127 by elmex, Mon Apr 17 21:07:03 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 {
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}[1]->emit ("activate"); # pop up server setup 443 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
444
445 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0);
446 $tgw->add (my $hbox = new CFClient::UI::HBox ());
447
448 $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food', expand => 1));
449 $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana', expand => 1));
450 $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp', expand => 1));
451 $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace', expand => 1));
452
453 $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg };
454 $CFClient::UI::ROOT->add ($tgw);
442} 455}
443 456
444sub destroy_screen { 457sub destroy_screen {
445 $CFClient::UI::ROOT->{children} = []; 458 $CFClient::UI::ROOT->{children} = [];
446 undef $SDL_ACTIVE; 459 undef $SDL_ACTIVE;
502 delete $animate_object{$widget}; 515 delete $animate_object{$widget};
503} 516}
504 517
505@conn::ISA = Crossfire::Protocol::; 518@conn::ISA = Crossfire::Protocol::;
506 519
520sub conn::stats_update {
521 my ($self, $stats) = @_;
522
523 # i love text protocols!!!
524 # FIXME: the stats are somehow weird
525 my $hp = $stats->{1};
526 my $hp_m = $stats->{2};
527 my $sp = $stats->{3};
528 my $sp_m = $stats->{4};
529 my $fo = $stats->{18};
530 my $fo_m = 1000;
531 my $gr = $stats->{23};
532 my $gr_m = $stats->{24};
533
534 #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n";
535 $GAUGES->{hp}->set_value ($hp, $hp_m);
536 $GAUGES->{mana}->set_value ($sp, $sp_m);
537 $GAUGES->{food}->set_value ($fo, $fo_m);
538 $GAUGES->{grace}->set_value ($gr, $gr_m);
539}
540
507sub conn::user_send { 541sub conn::user_send {
508 my ($self, $command) = @_; 542 my ($self, $command) = @_;
509 543
510 $self->send ($command); 544 $self->send_command ($command);
511 status $command; 545 status $command;
512} 546}
513 547
514sub conn::map_scroll { 548sub conn::map_scroll {
515 my ($self, $dx, $dy) = @_; 549 my ($self, $dx, $dy) = @_;
567} 601}
568 602
569sub conn::flood_fill { 603sub conn::flood_fill {
570 my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_; 604 my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_;
571 605
572 # the server doe snot allow map paths > 6 606 # the server does not allow map paths > 6
573 return if 6 <= length $path; 607 return if 6 <= length $path;
574 608
575 for my $tile (1..4) { 609 for my $tile (1..4) {
576 next if $self->{neigh}{$hash}[$tile]; 610 next if $self->{neigh}{$hash}[$tile];
577 next unless $flags & (1 << ($tile - 1)); 611 next unless $flags & (1 << ($tile - 1));
579 my $neigh = $self->{neigh}{$hash} ||= []; 613 my $neigh = $self->{neigh}{$hash} ||= [];
580 614
581 $self->send_mapinfo ("spatial $path$tile", sub { 615 $self->send_mapinfo ("spatial $path$tile", sub {
582 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; 616 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
583 617
584 warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# 618 #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d#
585 return if $mode ne "spatial"; 619 return if $mode ne "spatial";
586 620
587 $x += $MAP->ox; 621 $x += $MAP->ox;
588 $y += $MAP->oy; 622 $y += $MAP->oy;
589 623
590 $self->load_map ($hash, $x, $y); 624 $self->load_map ($hash, $x, $y)
625 unless $self->{neigh}{$hash}[5]++;#d#
591 626
592 $neigh->[$tile] = [$x, $y, $w, $h]; 627 $neigh->[$tile] = [$x, $y, $w, $h];
593 628
594 $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) 629 $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1)
595 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; 630 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
778 813
779@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 814@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
780 815
781$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 816$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
782 817
783init_screen;
784
785{ 818{
786 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 819 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf);
787 820
788 CFClient::add_font $_ for @fonts; 821 CFClient::add_font $_ for @fonts;
789 CFClient::set_font $fonts[0]; 822 CFClient::set_font $fonts[0];
790} 823}
791 824
825init_screen;
826
792Event::loop; 827Event::loop;
793 828
794 829

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines