ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Protocol.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.39 by root, Mon Jun 19 06:50:45 2006 UTC vs.
Revision 1.42 by root, Fri Jun 23 23:54:30 2006 UTC

412 412
413 $text = CFClient::UI::Label::escape $text; 413 $text = CFClient::UI::Label::escape $text;
414 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 414 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
415 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 415 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
416 416
417 $self->{logview}->add_paragraph ($color[$color], 417 $self->{logview}->add_paragraph ($color[$color], $_)
418 join "\n", map "$time $_", split /\n/, $text); 418 for map "$time $_", split /\n/, $text;
419 $self->{logview}->scroll_to_bottom;
419 420
420 $self->{statusbox}->add ($text, 421 $self->{statusbox}->add ($text,
421 group => $text, 422 group => $text,
422 fg => $color[$color], 423 fg => $color[$color],
423 timeout => $color >= 2 ? 60 : 10, 424 timeout => $color >= 2 ? 60 : 10,
811} 812}
812 813
813sub feed { 814sub feed {
814 my ($self, $data) = @_; 815 my ($self, $data) = @_;
815 816
817 Scalar::Util::weaken $self;
818
816 my ($type, $msg) = split / /, $data, 2; 819 my ($type, $msg) = split / /, $data, 2;
817 820
818 if ($type eq "msg") { 821 if ($type eq "msg") {
819 my ($msg, @kw) = split /\x00/, $msg; 822 my ($msg, @kw) = split /\x00/, $msg;
820 $self->{kw}{$_} = 1 for @kw; 823 $self->{kw}{$_} = 1 for @kw;
821 824
822 $msg = CFClient::UI::Label::escape $msg; 825 $msg = "\n" . CFClient::UI::Label::escape $msg;
823 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; 826 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} };
824 $msg =~ s/($match)/<span foreground='#c0c0ff' underline='none'>$1<\/span>/gi; # underline when http-ready, huh. 827 my @link;
828 $msg =~ s{
829 ($match)
830 }{
831 my $kw = $1;
832
833 push @link, new CFClient::UI::Label
834 markup => "<span foreground='#c0c0ff' underline='single'>$kw</span>",
835 can_hover => 1,
836 can_events => 1,
837 on_button_up => sub {
838 $self->send ($kw);
839 };
840
841 chr 0xfffc
842 }giex;
825 843
826 $self->{textview}->add_paragraph ([1, 1, 1, 1], "\n$msg"); 844 $self->{textview}->add_paragraph ([1, 1, 1, 1], [$msg, @link]);
845 $self->{textview}->scroll_to_bottom;
827 $self->update_options; 846 $self->update_options;
828 } else { 847 } else {
829 $self->destroy; 848 $self->destroy;
830 } 849 }
831 850
835sub send { 854sub send {
836 my ($self, $msg) = @_; 855 my ($self, $msg) = @_;
837 856
838 $self->{conn}->send ("ext npc_dialog_tell $self->{token} $msg"); 857 $self->{conn}->send ("ext npc_dialog_tell $self->{token} $msg");
839 $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::UI::Label::escape $msg); 858 $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::UI::Label::escape $msg);
859 $self->{textview}->scroll_to_bottom;
840} 860}
841 861
842sub destroy { 862sub destroy {
843 my ($self) = @_; 863 my ($self) = @_;
844 864

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines