--- deliantra/Deliantra-Client/DC/Protocol.pm 2007/04/23 19:17:41 1.103 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2007/04/24 01:13:15 1.105 @@ -636,6 +636,22 @@ $self->{query}-> ($self, $flags, $prompt); } +our %NAME_TO_COLOR = ( + black => 0, + white => 1, + darkblue => 2, + red => 3, + orange => 4, + lightblue => 5, + darkorange => 6, + green => 7, + darkgreen => 8, + grey => 9, + brown => 10, + yellow => 11, + tan => 12, +); + our @CF_COLOR = ( [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], [1.00, 1.00, 1.00], @@ -652,36 +668,34 @@ [0.74, 0.65, 0.41], ); -sub drawinfo { - my ($self, $color, $text) = @_; - - my $fg = $CF_COLOR[$color % @CF_COLOR]; - - $self->logprint ("info: ", $text); - - ## try to create single paragraphs of multiple lines sent by the server - # no longer neecssary with TRT servers - #$text =~ s/(?<=\S)\n(?=\w)/ /g; - - $text = CFPlus::asxml $text; - $text =~ s/\[b\](.*?)\[\/b\]/\1<\/b>/g; - $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/\2<\/span>/g; +sub msg { + my ($self, $color, $type, $text, @extra) = @_; - ::message ({ fg => $fg, markup => $_ }) - for split /\n/, $text; - - $self->{statusbox}->add ($text, - group => $text, - fg => $fg, - timeout => $color >= 2 ? 180 : 10, - tooltip_font => $::FONT_FIXED, - ); -} + if (my $cb = $self->{cb_msg}{$type}) { + $_->($self, $color, $type, $text, @extra) for values %$cb; + } elsif ($type =~ /^(?:chargen-race-title|chargen-race-description)$/) { + $type =~ s/-/_/g; + $self->{$type} = $text; + } else { + $self->logprint ("msg: ", $text); + return if $color < 0; # negative color == ignore if not understood -sub drawextinfo { - my ($self, $color, $type, $subtype, $message) = @_; + my $fg = $CF_COLOR[$color % @CF_COLOR]; - $self->drawinfo ($color, $message); + ## try to create single paragraphs of multiple lines sent by the server + # no longer neecssary with TRT servers + #$text =~ s/(?<=\S)\n(?=\w)/ /g; + + ::message ({ fg => $fg, markup => $_ }) + for split /\n/, $text; + + $self->{statusbox}->add ($text, + group => $text, + fg => $fg, + timeout => $color >= 2 ? 180 : 10, + tooltip_font => $::FONT_FIXED, + ); + } } sub spell_add { @@ -924,8 +938,10 @@ . "protocol version $self->{version}\n" . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" + . "examine command support $yesno[$self->{setup}{excmd} > 0]\n" . "editing support $yesno[!!$self->{editor_support}]\n" . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" + . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n" . "cfplus support $yesno[$self->{cfplus_ext} > 0]" . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" . "map size $self->{mapw}×$self->{maph}\n"