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.41 by root, Fri Jun 23 22:35:16 2006 UTC vs.
Revision 1.44 by elmex, Wed Jun 28 10:37:19 2006 UTC

585 585
586 if ($tag == 0) { 586 if ($tag == 0) {
587 update_floorbox; 587 update_floorbox;
588 update_container (0); 588 update_container (0);
589 } elsif ($tag == $self->{player}{tag}) { 589 } elsif ($tag == $self->{player}{tag}) {
590 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $self->{player}->{weight} / 1000);
590 $::INV->set_items ($self->{container}{$self->{player}{tag}}) 591 $::INV->set_items ($self->{container}{$self->{player}{tag}})
591 } else { 592 } else {
592 update_container ($tag); 593 update_container ($tag);
593 } 594 }
594 595
812} 813}
813 814
814sub feed { 815sub feed {
815 my ($self, $data) = @_; 816 my ($self, $data) = @_;
816 817
818 Scalar::Util::weaken $self;
819
817 my ($type, $msg) = split / /, $data, 2; 820 my ($type, $msg) = split / /, $data, 2;
818 821
819 if ($type eq "msg") { 822 if ($type eq "msg") {
820 my ($msg, @kw) = split /\x00/, $msg; 823 my ($msg, @kw) = split /\x00/, $msg;
821 $self->{kw}{$_} = 1 for @kw; 824 $self->{kw}{$_} = 1 for @kw;
824 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; 827 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} };
825 my @link; 828 my @link;
826 $msg =~ s{ 829 $msg =~ s{
827 ($match) 830 ($match)
828 }{ 831 }{
832 my $kw = $1;
833
829 push @link, new CFClient::UI::Label 834 push @link, new CFClient::UI::Label
830 markup => "<span foreground='#c0c0ff' underline='single'>$1</span>", 835 markup => "<span foreground='#c0c0ff' underline='single'>$kw</span>",
831 can_hover => 1, 836 can_hover => 1,
832 can_events => 1; 837 can_events => 1,
838 padding_x => 0,
839 padding_y => 0,
840 on_button_up => sub {
841 $self->send ($kw);
842 };
833 843
834 chr 0xfffc 844 chr 0xfffc
835 }giex; 845 }giex;
836 846
837 $self->{textview}->add_paragraph ([1, 1, 1, 1], [$msg, @link]); 847 $self->{textview}->add_paragraph ([1, 1, 1, 1], [$msg, @link]);
848 $self->{textview}->scroll_to_bottom;
838 $self->update_options; 849 $self->update_options;
839 } else { 850 } else {
840 $self->destroy; 851 $self->destroy;
841 } 852 }
842 853
846sub send { 857sub send {
847 my ($self, $msg) = @_; 858 my ($self, $msg) = @_;
848 859
849 $self->{conn}->send ("ext npc_dialog_tell $self->{token} $msg"); 860 $self->{conn}->send ("ext npc_dialog_tell $self->{token} $msg");
850 $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::UI::Label::escape $msg); 861 $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::UI::Label::escape $msg);
862 $self->{textview}->scroll_to_bottom;
851} 863}
852 864
853sub destroy { 865sub destroy {
854 my ($self) = @_; 866 my ($self) = @_;
855 867

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines