… | |
… | |
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 | for my $tag (keys %{ delete $self->{update_container} }) { |
|
|
579 | if ($tag == 0) { |
|
|
580 | update_floorbox; |
|
|
581 | $::INVR->set_items ($self->{container}{0}) |
578 | if $tag == $::CONN->{open_container}; |
582 | if $tag == $self->{open_container}; |
|
|
583 | } elsif ($tag == $self->{player}{tag}) { |
|
|
584 | $::INV->set_items ($self->{container}{$tag}) |
|
|
585 | } else { |
|
|
586 | $::INVR->set_items ($self->{container}{$tag}) |
|
|
587 | if $tag == $self->{open_container}; |
|
|
588 | } |
|
|
589 | } |
|
|
590 | }); |
579 | } |
591 | } |
580 | |
592 | |
581 | sub container_add { |
593 | sub container_add { |
582 | my ($self, $tag, $items) = @_; |
594 | my ($self, $tag, $items) = @_; |
583 | |
595 | |
584 | #d# print "container_add: container $tag ($self->{player}{tag})\n"; |
596 | $self->{update_container}{$tag}++; |
585 | |
597 | $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 | } |
598 | } |
599 | |
599 | |
600 | sub container_clear { |
600 | sub container_clear { |
601 | my ($self, $tag) = @_; |
601 | my ($self, $tag) = @_; |
602 | |
602 | |
603 | #d# print "container_clear: container $tag ($self->{player}{tag})\n"; |
603 | $self->{update_container}{$tag}++; |
604 | |
604 | $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 | } |
605 | } |
616 | |
606 | |
617 | sub item_delete { |
607 | sub item_delete { |
618 | my ($self, @items) = @_; |
608 | my ($self, @items) = @_; |
619 | |
609 | |
|
|
610 | $self->{update_container}{$_->{container}}++ |
620 | for (@items) { |
611 | 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 | } |
612 | |
|
|
613 | $self->update_containers; |
632 | } |
614 | } |
633 | |
615 | |
634 | sub item_update { |
616 | sub item_update { |
635 | my ($self, $item) = @_; |
617 | my ($self, $item) = @_; |
636 | |
618 | |
637 | #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; |
619 | #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; |
638 | |
620 | |
639 | if ($item->{tag} == $self->{player}{tag}) { |
|
|
640 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $item->{weight} / 1000); |
|
|
641 | return; |
|
|
642 | } |
|
|
643 | |
|
|
644 | CFClient::Item::update_widgets $item; |
621 | CFClient::Item::update_widgets $item; |
645 | |
622 | |
646 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
623 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
647 | set_opencont ($::CONN, 0, "Floor"); |
624 | set_opencont ($::CONN, 0, "Floor"); |
648 | |
625 | |
649 | } elsif ($item->{flags} & F_OPEN) { |
626 | } elsif ($item->{flags} & F_OPEN) { |
650 | set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item); |
627 | set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item); |
|
|
628 | |
651 | } else { |
629 | } else { |
|
|
630 | $self->{update_container}{$item->{container}}++; |
|
|
631 | $self->update_containers; |
652 | if ($item->{container} == 0) { |
632 | # if ($item->{container} == 0) { |
653 | update_floorbox; |
633 | # update_floorbox; |
654 | update_container (0); |
634 | # update_container (0); |
655 | } elsif ($item->{container} == $self->{player}{tag}) { |
635 | # } elsif ($item->{container} == $self->{player}{tag}) { |
656 | $::INV->set_items ($self->{container}{$item->{container}}) |
636 | # $::INV->set_items ($self->{container}{$item->{container}}) |
657 | } |
637 | # } |
658 | } |
638 | } |
659 | } |
639 | } |
660 | |
640 | |
661 | sub player_update { |
641 | sub player_update { |
662 | my ($self, $player) = @_; |
642 | my ($self, $player) = @_; |
663 | |
|
|
664 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); |
643 | $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); |
665 | } |
644 | } |
666 | |
645 | |
667 | sub update_server_info { |
646 | sub update_server_info { |
668 | my ($self) = @_; |
647 | my ($self) = @_; |