… | |
… | |
49 | our $BUTTONBAR; |
49 | our $BUTTONBAR; |
50 | our $LOGVIEW; |
50 | our $LOGVIEW; |
51 | our $CONSOLE; |
51 | our $CONSOLE; |
52 | our $METASERVER; |
52 | our $METASERVER; |
53 | |
53 | |
|
|
54 | our $GAUGES; |
|
|
55 | |
54 | our $SDL_ACTIVE; |
56 | our $SDL_ACTIVE; |
55 | our $SDL_EV; |
57 | our $SDL_EV; |
56 | our %SDL_CB; |
58 | our %SDL_CB; |
57 | |
59 | |
58 | our $ALT_ENTER_MESSAGE; |
60 | our $ALT_ENTER_MESSAGE; |
59 | our $STATUS_LINE; |
61 | our $STATUS_LINE; |
60 | our $DEBUG_STATUS; |
62 | our $DEBUG_STATUS; |
61 | |
63 | |
62 | sub status { |
64 | sub 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 | |
68 | sub debug { |
69 | sub 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 | |
74 | sub start_game { |
74 | sub start_game { |
75 | status "logging in..."; |
75 | status "logging in..."; |
76 | |
76 | |
… | |
… | |
146 | |
146 | |
147 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); |
147 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); |
148 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
148 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
149 | my ($self, $value) = @_; |
149 | my ($self, $value) = @_; |
150 | $CFG->{fow_smooth} = $value; |
150 | $CFG->{fow_smooth} = $value; |
|
|
151 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
151 | }); |
152 | }); |
152 | |
153 | |
153 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); |
154 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); |
154 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { |
155 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { |
155 | my ($self, $value) = @_; |
156 | my ($self, $value) = @_; |
… | |
… | |
300 | |
301 | |
301 | sub message_window { |
302 | sub message_window { |
302 | my $window = new CFClient::UI::FancyFrame |
303 | my $window = new CFClient::UI::FancyFrame |
303 | border_bg => [1, 1, 1, 0.5], |
304 | border_bg => [1, 1, 1, 0.5], |
304 | bg => [0.3, 0.3, 0.3, 0.8], |
305 | bg => [0.3, 0.3, 0.3, 0.8], |
305 | user_w => $::WIDTH/4, |
306 | user_w => int $::WIDTH / 3, |
306 | user_h => $::HEIGHT, |
307 | user_h => int $::HEIGHT / 5, |
307 | child => (my $vbox = new CFClient::UI::VBox); |
308 | child => (my $vbox = new CFClient::UI::VBox); |
308 | |
309 | |
309 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
310 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
310 | expand => 1, |
311 | expand => 1, |
311 | fontsize => $::CFG->{log_fontsize}, |
312 | fontsize => $::CFG->{log_fontsize}, |
… | |
… | |
349 | |
350 | |
350 | $window |
351 | $window |
351 | } |
352 | } |
352 | |
353 | |
353 | sub sdl_init { |
354 | sub sdl_init { |
354 | #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
355 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
355 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
356 | #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
356 | and die "SDL::Init failed!\n"; |
357 | and die "SDL::Init failed!\n"; |
357 | } |
358 | } |
358 | |
359 | |
359 | sub init_screen { |
360 | sub init_screen { |
360 | sdl_init; |
361 | sdl_init; |
… | |
… | |
437 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
438 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
438 | status "Configuration Saved"; |
439 | status "Configuration Saved"; |
439 | }); |
440 | }); |
440 | |
441 | |
441 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
442 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
|
|
443 | |
|
|
444 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0); |
|
|
445 | $tgw->add (my $hbox = new CFClient::UI::HBox ()); |
|
|
446 | |
|
|
447 | $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp')); |
|
|
448 | $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana')); |
|
|
449 | $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace')); |
|
|
450 | $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food')); |
|
|
451 | |
|
|
452 | $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg }; |
|
|
453 | $CFClient::UI::ROOT->add ($tgw); |
442 | } |
454 | } |
443 | |
455 | |
444 | sub destroy_screen { |
456 | sub 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 | |
|
|
519 | sub 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 | |
507 | sub conn::user_send { |
540 | sub conn::user_send { |
508 | my ($self, $command) = @_; |
541 | my ($self, $command) = @_; |
509 | |
542 | |
510 | $self->send_command ($command); |
543 | $self->send_command ($command); |
511 | status $command; |
544 | status $command; |
… | |
… | |
585 | return if $mode ne "spatial"; |
618 | return if $mode ne "spatial"; |
586 | |
619 | |
587 | $x += $MAP->ox; |
620 | $x += $MAP->ox; |
588 | $y += $MAP->oy; |
621 | $y += $MAP->oy; |
589 | |
622 | |
590 | $self->load_map ($hash, $x, $y); |
623 | $self->load_map ($hash, $x, $y) |
|
|
624 | unless $self->{neigh}{$hash}[5]++;#d# |
591 | |
625 | |
592 | $neigh->[$tile] = [$x, $y, $w, $h]; |
626 | $neigh->[$tile] = [$x, $y, $w, $h]; |
593 | |
627 | |
594 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
628 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
595 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
629 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
… | |
… | |
601 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
635 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
602 | |
636 | |
603 | $self->flush_map; |
637 | $self->flush_map; |
604 | |
638 | |
605 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
639 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
606 | |
|
|
607 | warn "$ox $oy map_info<$flags, $x, $y, $w, $h, $hash>\n";#d# |
|
|
608 | |
640 | |
609 | my $mapmapw = 250; |
641 | my $mapmapw = 250; |
610 | my $mapmaph = 250; |
642 | my $mapmaph = 250; |
611 | |
643 | |
612 | $self->flood_fill ("", $hash, $flags, |
644 | $self->flood_fill ("", $hash, $flags, |
… | |
… | |
743 | }, |
775 | }, |
744 | ); |
776 | ); |
745 | |
777 | |
746 | ############################################################################# |
778 | ############################################################################# |
747 | |
779 | |
|
|
780 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
|
|
781 | |
748 | $TILECACHE = CFClient::db_table "tilecache"; |
782 | $TILECACHE = CFClient::db_table "tilecache"; |
749 | $FACEMAP = CFClient::db_table "facemap"; |
783 | $FACEMAP = CFClient::db_table "facemap"; |
750 | |
784 | |
751 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
785 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
752 | |
786 | |
… | |
… | |
789 | |
823 | |
790 | init_screen; |
824 | init_screen; |
791 | |
825 | |
792 | Event::loop; |
826 | Event::loop; |
793 | |
827 | |
|
|
828 | END { SDL::Quit } |
794 | |
829 | |
|
|
830 | |