--- deliantra/Deliantra-Client/DC/Protocol.pm 2006/06/23 22:35:16 1.41
+++ deliantra/Deliantra-Client/DC/Protocol.pm 2006/07/02 16:25:19 1.50
@@ -107,7 +107,7 @@
$self->logprint ("send: ", $command);
$self->send_command ($command);
- ::status $command;
+ ::status ($command);
}
sub start_record {
@@ -525,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
@@ -571,63 +571,46 @@
$::INVR->set_items ($conn->{container}{$tag});
}
-sub update_container {
- my ($tag) = @_;
+sub update_containers {
+ my ($self) = @_;
- $::INVR->set_items ($::CONN->{container}{$::CONN->{open_container}})
- if $tag == $::CONN->{open_container};
+ $CFClient::UI::ROOT->on_refresh ("update_containers_$self" => sub {
+ for my $tag (keys %{ delete $self->{update_container} }) {
+ if ($tag == 0) {
+ update_floorbox;
+ $::INVR->set_items ($self->{container}{0})
+ if $tag == $self->{open_container};
+ } elsif ($tag == $self->{player}{tag}) {
+ $::INV->set_items ($self->{container}{$tag})
+ } else {
+ $::INVR->set_items ($self->{container}{$tag})
+ if $tag == $self->{open_container};
+ }
+ }
+ });
}
sub container_add {
my ($self, $tag, $items) = @_;
- #d# print "container_add: container $tag ($self->{player}{tag})\n";
-
- if ($tag == 0) {
- update_floorbox;
- update_container (0);
- } elsif ($tag == $self->{player}{tag}) {
- $::INV->set_items ($self->{container}{$self->{player}{tag}})
- } else {
- update_container ($tag);
- }
-
- # $self-<{player}{tag} => player inv
- #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
+ $self->{update_container}{$tag}++;
+ $self->update_containers;
}
sub container_clear {
my ($self, $tag) = @_;
- #d# print "container_clear: container $tag ($self->{player}{tag})\n";
-
- if ($tag == 0) {
- update_floorbox;
- update_container (0);
- } elsif ($tag == $self->{player}{tag}) {
- $::INV->set_items ($self->{container}{$tag})
- } else {
- update_container ($tag);
- }
-
-# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
+ $self->{update_container}{$tag}++;
+ $self->update_containers;
}
sub item_delete {
my ($self, @items) = @_;
- for (@items) {
- #d# print "item_delete: $_->{tag} from $_->{container} ($self->{player}{tag})\n";
-
- if ($_->{container} == 0) {
- update_floorbox;
- update_container ($_->{tag});
- } elsif ($_->{container} == $self->{player}{tag}) {
- $::INV->set_items ($self->{container}{$self->{player}{tag}})
- } else {
- update_container ($_->{container});
- }
- }
+ $self->{update_container}{$_->{container}}++
+ for @items;
+
+ $self->update_containers;
}
sub item_update {
@@ -635,11 +618,6 @@
#d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n";
- if ($item->{tag} == $self->{player}{tag}) {
- $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $item->{weight} / 1000);
- return;
- }
-
CFClient::Item::update_widgets $item;
if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) {
@@ -647,19 +625,21 @@
} elsif ($item->{flags} & F_OPEN) {
set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item);
+
} else {
- if ($item->{container} == 0) {
- update_floorbox;
- update_container (0);
- } elsif ($item->{container} == $self->{player}{tag}) {
- $::INV->set_items ($self->{container}{$item->{container}})
- }
+ $self->{update_container}{$item->{container}}++;
+ $self->update_containers;
+# if ($item->{container} == 0) {
+# update_floorbox;
+# update_container (0);
+# } elsif ($item->{container} == $self->{player}{tag}) {
+# $::INV->set_items ($self->{container}{$item->{container}})
+# }
}
}
sub player_update {
my ($self, $player) = @_;
-
$::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000);
}
@@ -814,6 +794,8 @@
sub feed {
my ($self, $data) = @_;
+ Scalar::Util::weaken $self;
+
my ($type, $msg) = split / /, $data, 2;
if ($type eq "msg") {
@@ -826,15 +808,23 @@
$msg =~ s{
($match)
}{
+ my $kw = $1;
+
push @link, new CFClient::UI::Label
- markup => "$1",
+ markup => "$kw",
can_hover => 1,
- can_events => 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], [$msg, @link]);
+ $self->{textview}->scroll_to_bottom;
$self->update_options;
} else {
$self->destroy;
@@ -848,6 +838,7 @@
$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 {