ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Protocol.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.44 by elmex, Wed Jun 28 10:37:19 2006 UTC vs.
Revision 1.49 by root, Wed Jun 28 23:39:15 2006 UTC

105 push @{$self->{record}}, $command; 105 push @{$self->{record}}, $command;
106 } 106 }
107 107
108 $self->logprint ("send: ", $command); 108 $self->logprint ("send: ", $command);
109 $self->send_command ($command); 109 $self->send_command ($command);
110 ::status $command; 110 ::status ($command);
111} 111}
112 112
113sub start_record { 113sub start_record {
114 my ($self) = @_; 114 my ($self) = @_;
115 115
523 return unless $::CONN; 523 return unless $::CONN;
524 524
525 $::FLOORBOX->clear; 525 $::FLOORBOX->clear;
526 526
527 my $row; 527 my $row;
528 for (@{ $::CONN->{container}{0} }) { 528 for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{0} }) {
529 if ($row < 6) { 529 if ($row < 6) {
530 local $_->{face_widget}; # hack to force recreation of widget 530 local $_->{face_widget}; # hack to force recreation of widget
531 local $_->{desc_widget}; # hack to force recreation of widget 531 local $_->{desc_widget}; # hack to force recreation of widget
532 CFClient::Item::update_widgets $_; 532 CFClient::Item::update_widgets $_;
533 533
569 } 569 }
570 570
571 $::INVR->set_items ($conn->{container}{$tag}); 571 $::INVR->set_items ($conn->{container}{$tag});
572} 572}
573 573
574sub update_container { 574sub 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
581sub container_add { 593sub 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
600sub container_clear { 600sub 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
617sub item_delete { 607sub 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
634sub item_update { 616sub item_update {
635 my ($self, $item) = @_; 617 my ($self, $item) = @_;
636 618
646 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { 628 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) {
647 set_opencont ($::CONN, 0, "Floor"); 629 set_opencont ($::CONN, 0, "Floor");
648 630
649 } elsif ($item->{flags} & F_OPEN) { 631 } elsif ($item->{flags} & F_OPEN) {
650 set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item); 632 set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item);
633
651 } else { 634 } else {
635 $self->{update_container}{$item->{container}}++;
636 $self->update_containers;
652 if ($item->{container} == 0) { 637# if ($item->{container} == 0) {
653 update_floorbox; 638# update_floorbox;
654 update_container (0); 639# update_container (0);
655 } elsif ($item->{container} == $self->{player}{tag}) { 640# } elsif ($item->{container} == $self->{player}{tag}) {
656 $::INV->set_items ($self->{container}{$item->{container}}) 641# $::INV->set_items ($self->{container}{$item->{container}})
657 } 642# }
658 } 643 }
659} 644}
660 645
661sub player_update { 646sub player_update {
662 my ($self, $player) = @_; 647 my ($self, $player) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines