… | |
… | |
634 | $LAST_QUERY = $prompt; |
634 | $LAST_QUERY = $prompt; |
635 | |
635 | |
636 | $self->{query}-> ($self, $flags, $prompt); |
636 | $self->{query}-> ($self, $flags, $prompt); |
637 | } |
637 | } |
638 | |
638 | |
|
|
639 | our %NAME_TO_COLOR = ( |
|
|
640 | black => 0, |
|
|
641 | white => 1, |
|
|
642 | darkblue => 2, |
|
|
643 | red => 3, |
|
|
644 | orange => 4, |
|
|
645 | lightblue => 5, |
|
|
646 | darkorange => 6, |
|
|
647 | green => 7, |
|
|
648 | darkgreen => 8, |
|
|
649 | grey => 9, |
|
|
650 | brown => 10, |
|
|
651 | yellow => 11, |
|
|
652 | tan => 12, |
|
|
653 | ); |
|
|
654 | |
639 | our @CF_COLOR = ( |
655 | our @CF_COLOR = ( |
640 | [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], |
656 | [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], |
641 | [1.00, 1.00, 1.00], |
657 | [1.00, 1.00, 1.00], |
642 | [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] |
658 | [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] |
643 | [1.00, 0.00, 0.00], |
659 | [1.00, 0.00, 0.00], |
… | |
… | |
650 | [0.75, 0.61, 0.20], |
666 | [0.75, 0.61, 0.20], |
651 | [0.99, 0.77, 0.26], |
667 | [0.99, 0.77, 0.26], |
652 | [0.74, 0.65, 0.41], |
668 | [0.74, 0.65, 0.41], |
653 | ); |
669 | ); |
654 | |
670 | |
655 | sub drawinfo { |
671 | sub msg { |
656 | my ($self, $color, $text) = @_; |
672 | my ($self, $color, $type, $text, @extra) = @_; |
657 | |
673 | |
|
|
674 | if (my $cb = $self->{cb_msg}{$type}) { |
|
|
675 | $_->($self, $color, $type, $text, @extra) for values %$cb; |
|
|
676 | } elsif ($type =~ /^(?:chargen-race-title|chargen-race-description)$/) { |
|
|
677 | $type =~ s/-/_/g; |
|
|
678 | $self->{$type} = $text; |
|
|
679 | } else { |
|
|
680 | $self->logprint ("msg: ", $text); |
|
|
681 | return if $color < 0; # negative color == ignore if not understood |
|
|
682 | |
658 | my $fg = $CF_COLOR[$color % @CF_COLOR]; |
683 | my $fg = $CF_COLOR[$color % @CF_COLOR]; |
659 | |
684 | |
660 | $self->logprint ("info: ", $text); |
|
|
661 | |
|
|
662 | ## try to create single paragraphs of multiple lines sent by the server |
685 | ## try to create single paragraphs of multiple lines sent by the server |
663 | # no longer neecssary with TRT servers |
686 | # no longer neecssary with TRT servers |
664 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
687 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
665 | |
688 | |
666 | $text = CFPlus::asxml $text; |
|
|
667 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
|
|
668 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
|
|
669 | |
|
|
670 | ::message ({ fg => $fg, markup => $_ }) |
689 | ::message ({ fg => $fg, markup => $_ }) |
671 | for split /\n/, $text; |
690 | for split /\n/, $text; |
672 | |
691 | |
673 | $self->{statusbox}->add ($text, |
692 | $self->{statusbox}->add ($text, |
674 | group => $text, |
693 | group => $text, |
675 | fg => $fg, |
694 | fg => $fg, |
676 | timeout => $color >= 2 ? 180 : 10, |
695 | timeout => $color >= 2 ? 180 : 10, |
677 | tooltip_font => $::FONT_FIXED, |
696 | tooltip_font => $::FONT_FIXED, |
678 | ); |
697 | ); |
679 | } |
698 | } |
680 | |
|
|
681 | sub drawextinfo { |
|
|
682 | my ($self, $color, $type, $subtype, $message) = @_; |
|
|
683 | |
|
|
684 | $self->drawinfo ($color, $message); |
|
|
685 | } |
699 | } |
686 | |
700 | |
687 | sub spell_add { |
701 | sub spell_add { |
688 | my ($self, $spell) = @_; |
702 | my ($self, $spell) = @_; |
689 | |
703 | |