… | |
… | |
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 | |
… | |
… | |
349 | |
349 | |
350 | $window |
350 | $window |
351 | } |
351 | } |
352 | |
352 | |
353 | sub sdl_init { |
353 | sub 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 | |
359 | sub init_screen { |
359 | sub init_screen { |
360 | sdl_init; |
360 | sdl_init; |
… | |
… | |
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 | |
444 | sub destroy_screen { |
455 | sub destroy_screen { |
445 | $CFClient::UI::ROOT->{children} = []; |
456 | $CFClient::UI::ROOT->{children} = []; |
446 | undef $SDL_ACTIVE; |
457 | undef $SDL_ACTIVE; |
… | |
… | |
501 | my ($widget) = @_; |
512 | my ($widget) = @_; |
502 | delete $animate_object{$widget}; |
513 | delete $animate_object{$widget}; |
503 | } |
514 | } |
504 | |
515 | |
505 | @conn::ISA = Crossfire::Protocol::; |
516 | @conn::ISA = Crossfire::Protocol::; |
|
|
517 | |
|
|
518 | sub 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 | } |
506 | |
538 | |
507 | sub conn::user_send { |
539 | sub conn::user_send { |
508 | my ($self, $command) = @_; |
540 | my ($self, $command) = @_; |
509 | |
541 | |
510 | $self->send_command ($command); |
542 | $self->send_command ($command); |