--- deliantra/Deliantra-Client/DC/Protocol.pm 2006/06/18 17:13:11 1.38 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2006/06/28 21:17:01 1.46 @@ -107,7 +107,7 @@ $self->logprint ("send: ", $command); $self->send_command ($command); - ::status $command; + ::status ($command); } sub start_record { @@ -414,8 +414,9 @@ $text =~ s/\[b\](.*?)\[\/b\]/\1<\/b>/g; $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/\2<\/span>/g; - $self->{logview}->add_paragraph ($color[$color], - join "\n", map "$time $_", split /\n/, $text); + $self->{logview}->add_paragraph ($color[$color], $_) + for map "$time $_", split /\n/, $text; + $self->{logview}->scroll_to_bottom; $self->{statusbox}->add ($text, group => $text, @@ -524,7 +525,7 @@ $::FLOORBOX->clear; my $row; - for (@{ $::CONN->{container}{0} }) { + for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{0} }) { if ($row < 6) { local $_->{face_widget}; # hack to force recreation of widget local $_->{desc_widget}; # hack to force recreation of widget @@ -586,6 +587,7 @@ update_floorbox; update_container (0); } elsif ($tag == $self->{player}{tag}) { + $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $self->{player}->{weight} / 1000); $::INV->set_items ($self->{container}{$self->{player}{tag}}) } else { update_container ($tag); @@ -771,7 +773,7 @@ $vbox->add ($self->{options} = new CFClient::UI::VBox); - $self->{close_button} = new CFClient::UI::Button + $self->{bye_button} = new CFClient::UI::Button text => "Bye (close)", tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.", on_activate => sub { $this->destroy; 0 }, @@ -797,7 +799,7 @@ Scalar::Util::weaken $self; $self->{options}->clear; - $self->{options}->add ($self->{close_button}); + $self->{options}->add ($self->{bye_button}); for my $kw (sort keys %{ $self->{kw} }) { $self->{options}->add (new CFClient::UI::Button @@ -813,17 +815,37 @@ sub feed { my ($self, $data) = @_; + Scalar::Util::weaken $self; + my ($type, $msg) = split / /, $data, 2; if ($type eq "msg") { my ($msg, @kw) = split /\x00/, $msg; $self->{kw}{$_} = 1 for @kw; - $msg = CFClient::UI::Label::escape $msg; + $msg = "\n" . CFClient::UI::Label::escape $msg; my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; - $msg =~ s/($match)/$1<\/span>/gi; # underline when http-ready, huh. + my @link; + $msg =~ s{ + ($match) + }{ + my $kw = $1; + + push @link, new CFClient::UI::Label + markup => "$kw", + can_hover => 1, + can_events => 1, + padding_x => 0, + padding_y => 0, + on_button_up => sub { + $self->send ($kw); + }; + + chr 0xfffc + }giex; - $self->{textview}->add_paragraph ([1, 1, 1, 1], "\n$msg"); + $self->{textview}->add_paragraph ([1, 1, 1, 1], [$msg, @link]); + $self->{textview}->scroll_to_bottom; $self->update_options; } else { $self->destroy; @@ -837,12 +859,13 @@ $self->{conn}->send ("ext npc_dialog_tell $self->{token} $msg"); $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::UI::Label::escape $msg); + $self->{textview}->scroll_to_bottom; } sub destroy { my ($self) = @_; - #Carp::cluck "debug\n";#d# #todo# enable: destroyx gets called twice because scalar keys {} is 1 + #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1 delete $self->{conn}{npc_dialog}; $self->{conn}->disconnect_ext ($self->{token});