--- deliantra/Deliantra-Client/DC/Protocol.pm 2006/06/28 10:37:19 1.44 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2006/06/28 21:43:15 1.47 @@ -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 @@ -581,54 +581,41 @@ sub container_add { my ($self, $tag, $items) = @_; - #d# print "container_add: container $tag ($self->{player}{tag})\n"; + $self->{update_container}{$tag}++; + $self->update_containers; +} - if ($tag == 0) { - 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); - } +sub update_containers { + my ($self) = @_; - # $self-<{player}{tag} => player inv - #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; + $CFClient::UI::ROOT->on_refresh ("update_containers_$self" => sub { + for my $tag (keys %{ delete $self->{update_container} }) { + if ($tag == 0) { + update_floorbox; + update_container (0); + } elsif ($tag == $self->{player}{tag}) { + $::INV->set_items ($self->{container}{$tag}) + } else { + update_container ($tag); + } + } + }); } 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}{$_->{tag}}++ + for @items; + + $self->update_containers; } sub item_update { @@ -648,13 +635,16 @@ } 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}}) +# } } }