… | |
… | |
709 | } |
709 | } |
710 | |
710 | |
711 | sub update_floorbox { |
711 | sub update_floorbox { |
712 | $CFClient::UI::ROOT->on_refresh ($::FLOORBOX => sub { |
712 | $CFClient::UI::ROOT->on_refresh ($::FLOORBOX => sub { |
713 | return unless $::CONN; |
713 | return unless $::CONN; |
714 | |
714 | |
715 | $::FLOORBOX->clear; |
715 | $::FLOORBOX->clear; |
716 | |
716 | |
717 | my $row; |
717 | my $row; |
718 | for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{0} }) { |
718 | for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { |
719 | if ($row < 6) { |
719 | if ($row < 6) { |
720 | local $_->{face_widget}; # hack to force recreation of widget |
720 | local $_->{face_widget}; # hack to force recreation of widget |
721 | local $_->{desc_widget}; # hack to force recreation of widget |
721 | local $_->{desc_widget}; # hack to force recreation of widget |
722 | CFClient::Item::update_widgets $_; |
722 | CFClient::Item::update_widgets $_; |
723 | |
723 | |
… | |
… | |
731 | on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 }, |
731 | on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 }, |
732 | ); |
732 | ); |
733 | last; |
733 | last; |
734 | } |
734 | } |
735 | } |
735 | } |
|
|
736 | if ($::CONN->{open_container}) { |
|
|
737 | $::FLOORBOX->add (1, $row++, new CFClient::UI::Button |
|
|
738 | text => "Close container", |
|
|
739 | on_activate => sub { $::CONN->send ("apply $::CONN->{open_container}") } |
|
|
740 | ); |
|
|
741 | } |
736 | }); |
742 | }); |
737 | |
743 | |
738 | $::WANT_REFRESH++; |
744 | $::WANT_REFRESH++; |
739 | } |
745 | } |
740 | |
746 | |
741 | sub set_opencont { |
747 | sub set_opencont { |
742 | my ($conn, $tag, $name) = @_; |
748 | my ($conn, $tag, $name) = @_; |
743 | $conn->{open_container} = $tag; |
749 | $conn->{open_container} = $tag; |
|
|
750 | update_floorbox; |
744 | |
751 | |
745 | $::INV_RIGHT_HB->clear (); |
752 | $::INV_RIGHT_HB->clear (); |
746 | $::INV_RIGHT_HB->add (new CFClient::UI::Label align => 0, expand => 1, text => $name); |
753 | $::INV_RIGHT_HB->add (new CFClient::UI::Label align => 0, expand => 1, text => $name); |
747 | |
754 | |
748 | if ($tag != 0) { # Floor isn't closable, is it? |
755 | if ($tag != 0) { # Floor isn't closable, is it? |
… | |
… | |
767 | $CFClient::UI::ROOT->on_refresh ("update_containers_$self" => sub { |
774 | $CFClient::UI::ROOT->on_refresh ("update_containers_$self" => sub { |
768 | my $todo = delete $self->{update_container} |
775 | my $todo = delete $self->{update_container} |
769 | or return; |
776 | or return; |
770 | |
777 | |
771 | for my $tag (keys %$todo) { |
778 | for my $tag (keys %$todo) { |
|
|
779 | update_floorbox if $tag == 0 or $tag == $self->{open_container}; |
772 | if ($tag == 0) { |
780 | if ($tag == 0) { |
773 | update_floorbox; |
|
|
774 | $::INVR->set_items ($self->{container}{0}) |
781 | $::INVR->set_items ($self->{container}{0}) |
775 | if $tag == $self->{open_container}; |
782 | if $tag == $self->{open_container}; |
776 | } elsif ($tag == $self->{player}{tag}) { |
783 | } elsif ($tag == $self->{player}{tag}) { |
777 | $::INV->set_items ($self->{container}{$tag}) |
784 | $::INV->set_items ($self->{container}{$tag}) |
778 | } else { |
785 | } else { |