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.46 by root, Wed Jun 28 21:17:01 2006 UTC vs.
Revision 1.51 by root, Sun Jul 2 21:07:26 2006 UTC

438 # try to create single paragraphs of multiple lines sent by the server 438 # try to create single paragraphs of multiple lines sent by the server
439 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; 439 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g;
440 $spell->{message} =~ s/\n+$//; 440 $spell->{message} =~ s/\n+$//;
441 $spell->{message} ||= "Server did not provide a description for this spell."; 441 $spell->{message} ||= "Server did not provide a description for this spell.";
442 442
443 $::SETUP_SPELLS->add_spell ($spell); 443 $::SPELL_PAGE->add_spell ($spell);
444 444
445 $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message}); 445 $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message});
446 $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message}); 446 $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message});
447} 447}
448 448
449sub spell_delete { 449sub spell_delete {
450 my ($self, $spell) = @_; 450 my ($self, $spell) = @_;
451
451 $::SETUP_SPELLS->remove_spell ($spell); 452 $::SPELL_PAGE->remove_spell ($spell);
452} 453}
453 454
454sub addme_success { 455sub addme_success {
455 my ($self) = @_; 456 my ($self) = @_;
456 457
536 537
537 $row++; 538 $row++;
538 } else { 539 } else {
539 $::FLOORBOX->add (1, $row, new CFClient::UI::Button 540 $::FLOORBOX->add (1, $row, new CFClient::UI::Button
540 text => "More...", 541 text => "More...",
541 on_activate => sub { $::INV_WINDOW->toggle_visibility; 0 }, 542 on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 },
542 ); 543 );
543 last; 544 last;
544 } 545 }
545 } 546 }
546 }); 547 });
569 } 570 }
570 571
571 $::INVR->set_items ($conn->{container}{$tag}); 572 $::INVR->set_items ($conn->{container}{$tag});
572} 573}
573 574
574sub update_container { 575sub update_containers {
575 my ($tag) = @_; 576 my ($self) = @_;
576 577
577 $::INVR->set_items ($::CONN->{container}{$::CONN->{open_container}}) 578 $CFClient::UI::ROOT->on_refresh ("update_containers_$self" => sub {
579 for my $tag (keys %{ delete $self->{update_container} }) {
580 if ($tag == 0) {
581 update_floorbox;
582 $::INVR->set_items ($self->{container}{0})
578 if $tag == $::CONN->{open_container}; 583 if $tag == $self->{open_container};
584 } elsif ($tag == $self->{player}{tag}) {
585 $::INV->set_items ($self->{container}{$tag})
586 } else {
587 $::INVR->set_items ($self->{container}{$tag})
588 if $tag == $self->{open_container};
589 }
590 }
591 });
579} 592}
580 593
581sub container_add { 594sub container_add {
582 my ($self, $tag, $items) = @_; 595 my ($self, $tag, $items) = @_;
583 596
584 #d# print "container_add: container $tag ($self->{player}{tag})\n"; 597 $self->{update_container}{$tag}++;
585 598 $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} 599}
599 600
600sub container_clear { 601sub container_clear {
601 my ($self, $tag) = @_; 602 my ($self, $tag) = @_;
602 603
603 #d# print "container_clear: container $tag ($self->{player}{tag})\n"; 604 $self->{update_container}{$tag}++;
604 605 $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} 606}
616 607
617sub item_delete { 608sub item_delete {
618 my ($self, @items) = @_; 609 my ($self, @items) = @_;
619 610
611 $self->{update_container}{$_->{container}}++
620 for (@items) { 612 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 } 613
614 $self->update_containers;
632} 615}
633 616
634sub item_update { 617sub item_update {
635 my ($self, $item) = @_; 618 my ($self, $item) = @_;
636 619
637 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; 620 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n";
638 621
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; 622 CFClient::Item::update_widgets $item;
645 623
646 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { 624 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) {
647 set_opencont ($::CONN, 0, "Floor"); 625 set_opencont ($::CONN, 0, "Floor");
648 626
649 } elsif ($item->{flags} & F_OPEN) { 627 } elsif ($item->{flags} & F_OPEN) {
650 set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item); 628 set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item);
629
651 } else { 630 } else {
631 $self->{update_container}{$item->{container}}++;
632 $self->update_containers;
652 if ($item->{container} == 0) { 633# if ($item->{container} == 0) {
653 update_floorbox; 634# update_floorbox;
654 update_container (0); 635# update_container (0);
655 } elsif ($item->{container} == $self->{player}{tag}) { 636# } elsif ($item->{container} == $self->{player}{tag}) {
656 $::INV->set_items ($self->{container}{$item->{container}}) 637# $::INV->set_items ($self->{container}{$item->{container}})
657 } 638# }
658 } 639 }
659} 640}
660 641
661sub player_update { 642sub player_update {
662 my ($self, $player) = @_; 643 my ($self, $player) = @_;
663
664 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); 644 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000);
665} 645}
666 646
667sub update_server_info { 647sub update_server_info {
668 my ($self) = @_; 648 my ($self) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines