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.36 by root, Thu Jun 15 15:33:58 2006 UTC vs.
Revision 1.41 by root, Fri Jun 23 22:35:16 2006 UTC

83 83
84 print $fh "$ts ", @a, "\n"; 84 print $fh "$ts ", @a, "\n";
85 $fh->flush; 85 $fh->flush;
86} 86}
87 87
88
89
90sub stats_update { 88sub stats_update {
91 my ($self, $stats) = @_; 89 my ($self, $stats) = @_;
92 90
93 if (my $exp = $stats->{+CS_STAT_EXP64}) { 91 if (my $exp = $stats->{+CS_STAT_EXP64}) {
94 my $diff = $exp - $self->{prev_exp}; 92 my $diff = $exp - $self->{prev_exp};
160 158
161 $self->flush_map; 159 $self->flush_map;
162 delete $self->{neigh_map}; 160 delete $self->{neigh_map};
163 161
164 $self->{map}->clear; 162 $self->{map}->clear;
163 delete $self->{map_widget}{magicmap};
165} 164}
166 165
167 166
168sub load_map($$$) { 167sub load_map($$$) {
169 my ($self, $hash, $x, $y) = @_; 168 my ($self, $hash, $x, $y) = @_;
413 412
414 $text = CFClient::UI::Label::escape $text; 413 $text = CFClient::UI::Label::escape $text;
415 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 414 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
416 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 415 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
417 416
418 $self->{logview}->add_paragraph ($color[$color], 417 $self->{logview}->add_paragraph ($color[$color], $_)
419 join "\n", map "$time $_", split /\n/, $text); 418 for map "$time $_", split /\n/, $text;
419 $self->{logview}->scroll_to_bottom;
420 420
421 $self->{statusbox}->add ($text, 421 $self->{statusbox}->add ($text,
422 group => $text, 422 group => $text,
423 fg => $color[$color], 423 fg => $color[$color],
424 timeout => $color >= 2 ? 60 : 10, 424 timeout => $color >= 2 ? 60 : 10,
536 536
537 $row++; 537 $row++;
538 } else { 538 } else {
539 $::FLOORBOX->add (1, $row, new CFClient::UI::Button 539 $::FLOORBOX->add (1, $row, new CFClient::UI::Button
540 text => "More...", 540 text => "More...",
541 on_activate => sub { $::INV_WINDOW->toggle_visibility }, 541 on_activate => sub { $::INV_WINDOW->toggle_visibility; 0 },
542 ); 542 );
543 last; 543 last;
544 } 544 }
545 } 545 }
546 }); 546 });
561 tooltip => "Close the currently open container (if one is open)", 561 tooltip => "Close the currently open container (if one is open)",
562 on_activate => sub { 562 on_activate => sub {
563 $::CONN->send ("apply $tag") # $::CONN->{open_container}") 563 $::CONN->send ("apply $tag") # $::CONN->{open_container}")
564 if $tag != 0; 564 if $tag != 0;
565 #if $CONN->{open_container} != 0; 565 #if $CONN->{open_container} != 0;
566 0
566 }, 567 },
567 ); 568 );
568 } 569 }
569 570
570 $::INVR->set_items ($conn->{container}{$tag}); 571 $::INVR->set_items ($conn->{container}{$tag});
762 763
763 return unless $text =~ /\S/; 764 return unless $text =~ /\S/;
764 765
765 $entry->set_text (""); 766 $entry->set_text ("");
766 $this->send ($text); 767 $this->send ($text);
768
769 0
767 }, 770 },
768 ); 771 );
769 772
770 $vbox->add ($self->{options} = new CFClient::UI::VBox); 773 $vbox->add ($self->{options} = new CFClient::UI::VBox);
771 774
772 $self->{close_button} = new CFClient::UI::Button 775 $self->{bye_button} = new CFClient::UI::Button
773 text => "Bye (close)", 776 text => "Bye (close)",
774 tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.", 777 tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.",
775 on_activate => sub { $this->destroy }, 778 on_activate => sub { $this->destroy; 0 },
776 ; 779 ;
777 780
778 $self->update_options; 781 $self->update_options;
779 782
780 $self->{token} = $self->{conn}->ext_token; 783 $self->{token} = $self->{conn}->ext_token;
781 $self->{conn}->connect_ext ($self->{token} => sub { $this->feed (@_) }); 784 $self->{conn}->connect_ext ($self->{token} => sub { $this->feed (@_) });
782 $self->{conn}->send ("ext npc_dialog_begin $self->{token} $self->{dx} $self->{dy}"); 785 $self->{conn}->send ("ext npc_dialog_begin $self->{token} $self->{dx} $self->{dy}");
783 786
784 $self->{entry}->focus_in; 787 $self->{entry}->grab_focus;
785 788
786 $self->{textview}->add_paragraph ([1, 1, 0, 1], "<small>[starting conversation with <b>$self->{title}</b>]</small>\n\n"); 789 $self->{textview}->add_paragraph ([1, 1, 0, 1], "<small>[starting conversation with <b>$self->{title}</b>]</small>\n\n");
787 790
788 $self->show; 791 $self->show;
789 $self 792 $self
793 my ($self) = @_; 796 my ($self) = @_;
794 797
795 Scalar::Util::weaken $self; 798 Scalar::Util::weaken $self;
796 799
797 $self->{options}->clear; 800 $self->{options}->clear;
798 $self->{options}->add ($self->{close_button}); 801 $self->{options}->add ($self->{bye_button});
799 802
800 for my $kw (sort keys %{ $self->{kw} }) { 803 for my $kw (sort keys %{ $self->{kw} }) {
801 $self->{options}->add (new CFClient::UI::Button 804 $self->{options}->add (new CFClient::UI::Button
802 text => $kw, 805 text => $kw,
803 on_activate => sub { 806 on_activate => sub {
804 $self->send ($kw); 807 $self->send ($kw);
808 0
805 }, 809 },
806 ); 810 );
807 } 811 }
808} 812}
809 813
814 818
815 if ($type eq "msg") { 819 if ($type eq "msg") {
816 my ($msg, @kw) = split /\x00/, $msg; 820 my ($msg, @kw) = split /\x00/, $msg;
817 $self->{kw}{$_} = 1 for @kw; 821 $self->{kw}{$_} = 1 for @kw;
818 822
819 $msg = CFClient::UI::Label::escape $msg; 823 $msg = "\n" . CFClient::UI::Label::escape $msg;
820 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; 824 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} };
821 $msg =~ s/($match)/<span foreground='#c0c0ff' underline='none'>$1<\/span>/gi; # underline when http-ready, huh. 825 my @link;
826 $msg =~ s{
827 ($match)
828 }{
829 push @link, new CFClient::UI::Label
830 markup => "<span foreground='#c0c0ff' underline='single'>$1</span>",
831 can_hover => 1,
832 can_events => 1;
833
834 chr 0xfffc
835 }giex;
822 836
823 $self->{textview}->add_paragraph ([1, 1, 1, 1], "\n$msg"); 837 $self->{textview}->add_paragraph ([1, 1, 1, 1], [$msg, @link]);
824 $self->update_options; 838 $self->update_options;
825 } else { 839 } else {
826 $self->destroy; 840 $self->destroy;
827 } 841 }
828 842
837} 851}
838 852
839sub destroy { 853sub destroy {
840 my ($self) = @_; 854 my ($self) = @_;
841 855
842 #Carp::cluck "debug\n";#d# #todo# enable: destroyx gets called twice because scalar keys {} is 1 856 #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1
843 857
844 delete $self->{conn}{npc_dialog}; 858 delete $self->{conn}{npc_dialog};
845 $self->{conn}->disconnect_ext ($self->{token}); 859 $self->{conn}->disconnect_ext ($self->{token});
846 860
847 $self->SUPER::destroy; 861 $self->SUPER::destroy;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines