… | |
… | |
569 | } |
569 | } |
570 | |
570 | |
571 | $::INVR->set_items ($conn->{container}{$tag}); |
571 | $::INVR->set_items ($conn->{container}{$tag}); |
572 | } |
572 | } |
573 | |
573 | |
574 | sub update_container { |
574 | sub update_containers { |
575 | my ($tag) = @_; |
575 | my ($self) = @_; |
576 | |
576 | |
577 | $::INVR->set_items ($::CONN->{container}{$::CONN->{open_container}}) |
577 | $CFClient::UI::ROOT->on_refresh ("update_containers_$self" => sub { |
|
|
578 | # TODO: scara had a bug where $self->{uipdate_container} was not defined |
|
|
579 | # but this should not possibly happen? |
|
|
580 | for my $tag (keys %{ delete $self->{update_container} }) { |
|
|
581 | if ($tag == 0) { |
|
|
582 | update_floorbox; |
|
|
583 | $::INVR->set_items ($self->{container}{0}) |
578 | if $tag == $::CONN->{open_container}; |
584 | if $tag == $self->{open_container}; |
|
|
585 | } elsif ($tag == $self->{player}{tag}) { |
|
|
586 | $::INV->set_items ($self->{container}{$tag}) |
|
|
587 | } else { |
|
|
588 | $::INVR->set_items ($self->{container}{$tag}) |
|
|
589 | if $tag == $self->{open_container}; |
|
|
590 | } |
|
|
591 | } |
|
|
592 | }); |
579 | } |
593 | } |
580 | |
594 | |
581 | sub container_add { |
595 | sub container_add { |
582 | my ($self, $tag, $items) = @_; |
596 | my ($self, $tag, $items) = @_; |
583 | |
597 | |
584 | #d# print "container_add: container $tag ($self->{player}{tag})\n"; |
598 | $self->{update_container}{$tag}++; |
585 | |
599 | $self->update_containers; |
586 | if ($tag == 0) { |
|
|
587 | update_floorbox; |
|
|
588 | update_container (0); |
|
|
589 | } elsif ($tag == $self->{player}{tag}) { |
|
|
590 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $self->{player}->{weight} / 1000); |
|
|
591 | $::INV->set_items ($self->{container}{$self->{player}{tag}}) |
|
|
592 | } else { |
|
|
593 | update_container ($tag); |
|
|
594 | } |
|
|
595 | |
|
|
596 | # $self-<{player}{tag} => player inv |
|
|
597 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
|
|
598 | } |
600 | } |
599 | |
601 | |
600 | sub container_clear { |
602 | sub container_clear { |
601 | my ($self, $tag) = @_; |
603 | my ($self, $tag) = @_; |
602 | |
604 | |
603 | #d# print "container_clear: container $tag ($self->{player}{tag})\n"; |
605 | $self->{update_container}{$tag}++; |
604 | |
606 | $self->update_containers; |
605 | if ($tag == 0) { |
|
|
606 | update_floorbox; |
|
|
607 | update_container (0); |
|
|
608 | } elsif ($tag == $self->{player}{tag}) { |
|
|
609 | $::INV->set_items ($self->{container}{$tag}) |
|
|
610 | } else { |
|
|
611 | update_container ($tag); |
|
|
612 | } |
|
|
613 | |
|
|
614 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
|
|
615 | } |
607 | } |
616 | |
608 | |
617 | sub item_delete { |
609 | sub item_delete { |
618 | my ($self, @items) = @_; |
610 | my ($self, @items) = @_; |
619 | |
611 | |
|
|
612 | $self->{update_container}{$_->{tag}}++ |
620 | for (@items) { |
613 | for @items; |
621 | #d# print "item_delete: $_->{tag} from $_->{container} ($self->{player}{tag})\n"; |
|
|
622 | |
|
|
623 | if ($_->{container} == 0) { |
|
|
624 | update_floorbox; |
|
|
625 | update_container ($_->{tag}); |
|
|
626 | } elsif ($_->{container} == $self->{player}{tag}) { |
|
|
627 | $::INV->set_items ($self->{container}{$self->{player}{tag}}) |
|
|
628 | } else { |
|
|
629 | update_container ($_->{container}); |
|
|
630 | } |
|
|
631 | } |
614 | |
|
|
615 | $self->update_containers; |
632 | } |
616 | } |
633 | |
617 | |
634 | sub item_update { |
618 | sub item_update { |
635 | my ($self, $item) = @_; |
619 | my ($self, $item) = @_; |
636 | |
620 | |
… | |
… | |
646 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
630 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
647 | set_opencont ($::CONN, 0, "Floor"); |
631 | set_opencont ($::CONN, 0, "Floor"); |
648 | |
632 | |
649 | } elsif ($item->{flags} & F_OPEN) { |
633 | } elsif ($item->{flags} & F_OPEN) { |
650 | set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item); |
634 | set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item); |
|
|
635 | |
651 | } else { |
636 | } else { |
|
|
637 | $self->{update_container}{$item->{container}}++; |
|
|
638 | $self->update_containers; |
652 | if ($item->{container} == 0) { |
639 | # if ($item->{container} == 0) { |
653 | update_floorbox; |
640 | # update_floorbox; |
654 | update_container (0); |
641 | # update_container (0); |
655 | } elsif ($item->{container} == $self->{player}{tag}) { |
642 | # } elsif ($item->{container} == $self->{player}{tag}) { |
656 | $::INV->set_items ($self->{container}{$item->{container}}) |
643 | # $::INV->set_items ($self->{container}{$item->{container}}) |
657 | } |
644 | # } |
658 | } |
645 | } |
659 | } |
646 | } |
660 | |
647 | |
661 | sub player_update { |
648 | sub player_update { |
662 | my ($self, $player) = @_; |
649 | my ($self, $player) = @_; |