… | |
… | |
48 | our $MAPWIDGET; |
48 | our $MAPWIDGET; |
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 | |
|
|
54 | our $GAUGES; |
53 | |
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 | |
… | |
… | |
300 | |
302 | |
301 | sub message_window { |
303 | sub 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 - 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 | |
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); |
543 | $self->send_command ($command); |
511 | status $command; |
544 | status $command; |
512 | } |
545 | } |
513 | |
546 | |
514 | sub conn::map_scroll { |
547 | sub conn::map_scroll { |
515 | my ($self, $dx, $dy) = @_; |
548 | my ($self, $dx, $dy) = @_; |
… | |
… | |
567 | } |
600 | } |
568 | |
601 | |
569 | sub conn::flood_fill { |
602 | sub conn::flood_fill { |
570 | my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_; |
603 | my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_; |
571 | |
604 | |
|
|
605 | # the server does not allow map paths > 6 |
|
|
606 | return if 6 <= length $path; |
|
|
607 | |
572 | for my $tile (1..4) { |
608 | for my $tile (1..4) { |
573 | next if $self->{neigh}{$hash}[$tile]; |
609 | next if $self->{neigh}{$hash}[$tile]; |
574 | next unless $flags & (1 << ($tile - 1)); |
610 | next unless $flags & (1 << ($tile - 1)); |
575 | |
611 | |
576 | my $neigh = $self->{neigh}{$hash} ||= []; |
612 | my $neigh = $self->{neigh}{$hash} ||= []; |
577 | |
613 | |
578 | $self->send_mapinfo ("spatial $path$tile", sub { |
614 | $self->send_mapinfo ("spatial $path$tile", sub { |
579 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
615 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
580 | |
616 | |
581 | warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# |
617 | #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# |
582 | return if $mode ne "spatial"; |
618 | return if $mode ne "spatial"; |
583 | |
619 | |
584 | $x += $MAP->ox; |
620 | $x += $MAP->ox; |
585 | $y += $MAP->oy; |
621 | $y += $MAP->oy; |
586 | |
622 | |
587 | $self->load_map ($hash, $x, $y); |
623 | $self->load_map ($hash, $x, $y) |
|
|
624 | unless $self->{neigh}{$hash}[5]++;#d# |
588 | |
625 | |
589 | $neigh->[$tile] = [$x, $y, $w, $h]; |
626 | $neigh->[$tile] = [$x, $y, $w, $h]; |
590 | |
627 | |
591 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
628 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
592 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
629 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
… | |
… | |
775 | |
812 | |
776 | @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)"; |
777 | |
814 | |
778 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
815 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
779 | |
816 | |
780 | init_screen; |
|
|
781 | |
|
|
782 | { |
817 | { |
783 | 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); |
784 | |
819 | |
785 | CFClient::add_font $_ for @fonts; |
820 | CFClient::add_font $_ for @fonts; |
786 | CFClient::set_font $fonts[0]; |
821 | CFClient::set_font $fonts[0]; |
787 | } |
822 | } |
788 | |
823 | |
|
|
824 | init_screen; |
|
|
825 | |
789 | Event::loop; |
826 | Event::loop; |
790 | |
827 | |
791 | |
828 | |