… | |
… | |
371 | [0.74, 0.65, 0.41], |
371 | [0.74, 0.65, 0.41], |
372 | ); |
372 | ); |
373 | |
373 | |
374 | my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0]; |
374 | my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0]; |
375 | |
375 | |
|
|
376 | # try to create single paragraphs of multiple lines sent by the server |
|
|
377 | $text =~ s/(?<=\S)\n(?=\w)/ /g; |
|
|
378 | |
376 | $text = CFClient::UI::Label::escape $text; |
379 | $text = CFClient::UI::Label::escape $text; |
377 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
380 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
378 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
381 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
379 | |
382 | |
380 | $self->{logview}->add_paragraph ($color[$color], |
383 | $self->{logview}->add_paragraph ($color[$color], |
… | |
… | |
395 | } |
398 | } |
396 | |
399 | |
397 | sub spell_add { |
400 | sub spell_add { |
398 | my ($self, $spell) = @_; |
401 | my ($self, $spell) = @_; |
399 | |
402 | |
400 | # TODO |
403 | # try to create single paragraphs of multiple lines sent by the server |
401 | # create a widget dynamically, using spell face (CF::Protocol downloads them) |
404 | $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; |
|
|
405 | $spell->{message} =~ s/\n+$//; |
|
|
406 | $spell->{message} ||= "Server did not provide a description for this spell."; |
|
|
407 | |
402 | $::SETUP_SPELLS->add_spell ($spell); |
408 | $::SETUP_SPELLS->add_spell ($spell); |
403 | |
409 | |
404 | $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message}); |
410 | $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message}); |
405 | $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message}); |
411 | $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message}); |
406 | } |
412 | } |
… | |
… | |
483 | |
489 | |
484 | $::FLOORBOX->clear; |
490 | $::FLOORBOX->clear; |
485 | |
491 | |
486 | my $row; |
492 | my $row; |
487 | for (@{ $::CONN->{container}{0} }) { |
493 | for (@{ $::CONN->{container}{0} }) { |
488 | if ($row < 7) { |
494 | if ($row < 6) { |
489 | local $_->{face_widget}; # hack to force recreation of widget |
495 | local $_->{face_widget}; # hack to force recreation of widget |
490 | local $_->{desc_widget}; # hack to force recreation of widget |
496 | local $_->{desc_widget}; # hack to force recreation of widget |
491 | CFClient::Item::update_widgets $_; |
497 | CFClient::Item::update_widgets $_; |
492 | |
498 | |
493 | $::FLOORBOX->add (0, $row, $_->{face_widget}); |
499 | $::FLOORBOX->add (0, $row, $_->{face_widget}); |
494 | $::FLOORBOX->add (1, $row, $_->{desc_widget}); |
500 | $::FLOORBOX->add (1, $row, $_->{desc_widget}); |
495 | |
501 | |
496 | $row++; |
502 | $row++; |
497 | } else { |
503 | } else { |
498 | $::FLOORBOX->add (1, $row, new CFClient::UI::Label text => "More..."); |
504 | $::FLOORBOX->add (1, $row, new CFClient::UI::Button |
|
|
505 | text => "More...", |
|
|
506 | on_activate => sub { $::INV_WINDOW->toggle_visibility }, |
|
|
507 | ); |
499 | last; |
508 | last; |
500 | } |
509 | } |
501 | } |
510 | } |
502 | }); |
511 | }); |
503 | |
512 | |
… | |
… | |
612 | } |
621 | } |
613 | } |
622 | } |
614 | |
623 | |
615 | sub player_update { |
624 | sub player_update { |
616 | my ($self, $player) = @_; |
625 | my ($self, $player) = @_; |
|
|
626 | |
617 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); |
627 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); |
|
|
628 | } |
618 | |
629 | |
619 | # do it here because it is ignored earlier, and there is no "login" event |
630 | sub logged_in { |
|
|
631 | my ($self) = @_; |
|
|
632 | |
|
|
633 | $self->send_ext_req (cfplus => "version", "1", sub { |
|
|
634 | $self->{cfplus_ext} = $_[0]; |
|
|
635 | }); |
|
|
636 | |
620 | $self->send_command ("output-sync $::CFG->{output_sync}"); |
637 | $self->send_command ("output-sync $::CFG->{output_sync}"); |
621 | $self->send_command ("output-count $::CFG->{output_count}"); |
638 | $self->send_command ("output-count $::CFG->{output_count}"); |
|
|
639 | $self->send_command ("pickup $::CFG->{pickup}"); |
|
|
640 | |
|
|
641 | my @yesno = ("<span foreground='red'>no</span>", "<span foreground='green'>yes</span>"); |
|
|
642 | |
|
|
643 | $::SERVER_INFO->set_markup ( |
|
|
644 | "server <tt>$self->{host}:$self->{port}</tt>\n" |
|
|
645 | . "protocol version <tt>$self->{version}</tt>\n" |
|
|
646 | . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" |
|
|
647 | . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" |
|
|
648 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]\n" |
|
|
649 | . "map size $self->{mapw}×$self->{maph}\n" |
|
|
650 | ); |
622 | } |
651 | } |
623 | |
652 | |
624 | 1; |
653 | 1; |