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.121 by root, Mon Apr 17 09:33:12 2006 UTC vs.
Revision 1.131 by root, Tue Apr 18 02:04:23 2006 UTC

49our $BUTTONBAR; 49our $BUTTONBAR;
50our $LOGVIEW; 50our $LOGVIEW;
51our $CONSOLE; 51our $CONSOLE;
52our $METASERVER; 52our $METASERVER;
53 53
54our $GAUGES;
55
54our $SDL_ACTIVE; 56our $SDL_ACTIVE;
55our $SDL_EV; 57our $SDL_EV;
56our %SDL_CB; 58our %SDL_CB;
57 59
58our $ALT_ENTER_MESSAGE; 60our $ALT_ENTER_MESSAGE;
59our $STATUS_LINE; 61our $STATUS_LINE;
60our $DEBUG_STATUS; 62our $DEBUG_STATUS;
61 63
62sub status { 64sub status {
63 $STATUS_LINE->set_text ($_[0]); 65 $STATUS_LINE->set_text ($_[0]);
64 my ($w, $h) = $STATUS_LINE->size_request;
65 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); 66 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h});
66} 67}
67 68
68sub debug { 69sub debug {
69 $DEBUG_STATUS->set_text ($_[0]); 70 $DEBUG_STATUS->set_text ($_[0]);
70 my ($w, $h) = $DEBUG_STATUS->size_request; 71 $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0, $DEBUG_STATUS->{w}, $DEBUG_STATUS->{h});
71 $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h);
72} 72}
73 73
74sub start_game { 74sub start_game {
75 status "logging in..."; 75 status "logging in...";
76 76
300 300
301sub message_window { 301sub message_window {
302 my $window = new CFClient::UI::FancyFrame 302 my $window = new CFClient::UI::FancyFrame
303 border_bg => [1, 1, 1, 0.5], 303 border_bg => [1, 1, 1, 0.5],
304 bg => [0.3, 0.3, 0.3, 0.8], 304 bg => [0.3, 0.3, 0.3, 0.8],
305 user_w => $::WIDTH/4, 305 user_w => int $::WIDTH / 3,
306 user_h => $::HEIGHT, 306 user_h => int $::HEIGHT / 5,
307 child => (my $vbox = new CFClient::UI::VBox); 307 child => (my $vbox = new CFClient::UI::VBox);
308 308
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 }
349 349
350 $window 350 $window
351} 351}
352 352
353sub sdl_init { 353sub sdl_init {
354 #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE 354 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE
355 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO 355 #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO
356 and die "SDL::Init failed!\n"; 356 and die "SDL::Init failed!\n";
357} 357}
358 358
359sub init_screen { 359sub init_screen {
360 sdl_init; 360 sdl_init;
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 {
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}[1]->emit ("activate"); # pop up server setup 441 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
442
443 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0);
444 $tgw->add (my $hbox = new CFClient::UI::HBox ());
445
446 $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp'));
447 $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana'));
448 $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace'));
449 $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food'));
450
451 $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg };
452 $CFClient::UI::ROOT->add ($tgw);
442} 453}
443 454
444sub destroy_screen { 455sub destroy_screen {
445 $CFClient::UI::ROOT->{children} = []; 456 $CFClient::UI::ROOT->{children} = [];
446 undef $SDL_ACTIVE; 457 undef $SDL_ACTIVE;
502 delete $animate_object{$widget}; 513 delete $animate_object{$widget};
503} 514}
504 515
505@conn::ISA = Crossfire::Protocol::; 516@conn::ISA = Crossfire::Protocol::;
506 517
518sub conn::stats_update {
519 my ($self, $stats) = @_;
520
521 # i love text protocols!!!
522 # FIXME: the stats are somehow weird
523 my $hp = $stats->{1};
524 my $hp_m = $stats->{2};
525 my $sp = $stats->{3};
526 my $sp_m = $stats->{4};
527 my $fo = $stats->{18};
528 my $fo_m = 1000;
529 my $gr = $stats->{23};
530 my $gr_m = $stats->{24};
531
532 #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n";
533 $GAUGES->{hp}->set_value ($hp, $hp_m);
534 $GAUGES->{mana}->set_value ($sp, $sp_m);
535 $GAUGES->{food}->set_value ($fo, $fo_m);
536 $GAUGES->{grace}->set_value ($gr, $gr_m);
537}
538
507sub conn::user_send { 539sub conn::user_send {
508 my ($self, $command) = @_; 540 my ($self, $command) = @_;
509 541
510 $self->send ($command); 542 $self->send_command ($command);
511 status $command; 543 status $command;
512} 544}
513 545
514sub conn::map_scroll { 546sub conn::map_scroll {
515 my ($self, $dx, $dy) = @_; 547 my ($self, $dx, $dy) = @_;
579 my $neigh = $self->{neigh}{$hash} ||= []; 611 my $neigh = $self->{neigh}{$hash} ||= [];
580 612
581 $self->send_mapinfo ("spatial $path$tile", sub { 613 $self->send_mapinfo ("spatial $path$tile", sub {
582 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; 614 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
583 615
584 warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# 616 #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d#
585 return if $mode ne "spatial"; 617 return if $mode ne "spatial";
586 618
587 $x += $MAP->ox; 619 $x += $MAP->ox;
588 $y += $MAP->oy; 620 $y += $MAP->oy;
589 621
590 $self->load_map ($hash, $x, $y); 622 $self->load_map ($hash, $x, $y)
623 unless $self->{neigh}{$hash}[5]++;#d#
591 624
592 $neigh->[$tile] = [$x, $y, $w, $h]; 625 $neigh->[$tile] = [$x, $y, $w, $h];
593 626
594 $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) 627 $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1)
595 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; 628 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
601 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 634 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
602 635
603 $self->flush_map; 636 $self->flush_map;
604 637
605 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 638 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
606
607 warn "$ox $oy map_info<$flags, $x, $y, $w, $h, $hash>\n";#d#
608 639
609 my $mapmapw = 250; 640 my $mapmapw = 250;
610 my $mapmaph = 250; 641 my $mapmaph = 250;
611 642
612 $self->flood_fill ("", $hash, $flags, 643 $self->flood_fill ("", $hash, $flags,
743 }, 774 },
744); 775);
745 776
746############################################################################# 777#############################################################################
747 778
779$SIG{INT} = $SIG{TERM} = sub { exit };
780
748$TILECACHE = CFClient::db_table "tilecache"; 781$TILECACHE = CFClient::db_table "tilecache";
749$FACEMAP = CFClient::db_table "facemap"; 782$FACEMAP = CFClient::db_table "facemap";
750 783
751CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; 784CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
752 785
778 811
779@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 812@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
780 813
781$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 814$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
782 815
783init_screen;
784
785{ 816{
786 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 817 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf);
787 818
788 CFClient::add_font $_ for @fonts; 819 CFClient::add_font $_ for @fonts;
789 CFClient::set_font $fonts[0]; 820 CFClient::set_font $fonts[0];
790} 821}
791 822
823init_screen;
824
792Event::loop; 825Event::loop;
793 826
827END { SDL::Quit }
794 828
829

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines