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