… | |
… | |
83 | |
83 | |
84 | print $fh "$ts ", @a, "\n"; |
84 | print $fh "$ts ", @a, "\n"; |
85 | $fh->flush; |
85 | $fh->flush; |
86 | } |
86 | } |
87 | |
87 | |
88 | |
|
|
89 | |
|
|
90 | sub stats_update { |
88 | sub stats_update { |
91 | my ($self, $stats) = @_; |
89 | my ($self, $stats) = @_; |
92 | |
90 | |
93 | if (my $exp = $stats->{+CS_STAT_EXP64}) { |
91 | if (my $exp = $stats->{+CS_STAT_EXP64}) { |
94 | my $diff = $exp - $self->{prev_exp}; |
92 | my $diff = $exp - $self->{prev_exp}; |
… | |
… | |
160 | |
158 | |
161 | $self->flush_map; |
159 | $self->flush_map; |
162 | delete $self->{neigh_map}; |
160 | delete $self->{neigh_map}; |
163 | |
161 | |
164 | $self->{map}->clear; |
162 | $self->{map}->clear; |
|
|
163 | delete $self->{map_widget}{magicmap}; |
165 | } |
164 | } |
166 | |
165 | |
167 | |
166 | |
168 | sub load_map($$$) { |
167 | sub load_map($$$) { |
169 | my ($self, $hash, $x, $y) = @_; |
168 | my ($self, $hash, $x, $y) = @_; |
… | |
… | |
536 | |
535 | |
537 | $row++; |
536 | $row++; |
538 | } else { |
537 | } else { |
539 | $::FLOORBOX->add (1, $row, new CFClient::UI::Button |
538 | $::FLOORBOX->add (1, $row, new CFClient::UI::Button |
540 | text => "More...", |
539 | text => "More...", |
541 | on_activate => sub { $::INV_WINDOW->toggle_visibility }, |
540 | on_activate => sub { $::INV_WINDOW->toggle_visibility; 0 }, |
542 | ); |
541 | ); |
543 | last; |
542 | last; |
544 | } |
543 | } |
545 | } |
544 | } |
546 | }); |
545 | }); |
… | |
… | |
561 | tooltip => "Close the currently open container (if one is open)", |
560 | tooltip => "Close the currently open container (if one is open)", |
562 | on_activate => sub { |
561 | on_activate => sub { |
563 | $::CONN->send ("apply $tag") # $::CONN->{open_container}") |
562 | $::CONN->send ("apply $tag") # $::CONN->{open_container}") |
564 | if $tag != 0; |
563 | if $tag != 0; |
565 | #if $CONN->{open_container} != 0; |
564 | #if $CONN->{open_container} != 0; |
|
|
565 | 0 |
566 | }, |
566 | }, |
567 | ); |
567 | ); |
568 | } |
568 | } |
569 | |
569 | |
570 | $::INVR->set_items ($conn->{container}{$tag}); |
570 | $::INVR->set_items ($conn->{container}{$tag}); |
… | |
… | |
762 | |
762 | |
763 | return unless $text =~ /\S/; |
763 | return unless $text =~ /\S/; |
764 | |
764 | |
765 | $entry->set_text (""); |
765 | $entry->set_text (""); |
766 | $this->send ($text); |
766 | $this->send ($text); |
|
|
767 | |
|
|
768 | 0 |
767 | }, |
769 | }, |
768 | ); |
770 | ); |
769 | |
771 | |
770 | $vbox->add ($self->{options} = new CFClient::UI::VBox); |
772 | $vbox->add ($self->{options} = new CFClient::UI::VBox); |
771 | |
773 | |
772 | $self->{close_button} = new CFClient::UI::Button |
774 | $self->{bye_button} = new CFClient::UI::Button |
773 | text => "Bye (close)", |
775 | text => "Bye (close)", |
774 | tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.", |
776 | tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.", |
775 | on_activate => sub { $this->destroy }, |
777 | on_activate => sub { $this->destroy; 0 }, |
776 | ; |
778 | ; |
777 | |
779 | |
778 | $self->update_options; |
780 | $self->update_options; |
779 | |
781 | |
780 | $self->{token} = $self->{conn}->ext_token; |
782 | $self->{token} = $self->{conn}->ext_token; |
781 | $self->{conn}->connect_ext ($self->{token} => sub { $this->feed (@_) }); |
783 | $self->{conn}->connect_ext ($self->{token} => sub { $this->feed (@_) }); |
782 | $self->{conn}->send ("ext npc_dialog_begin $self->{token} $self->{dx} $self->{dy}"); |
784 | $self->{conn}->send ("ext npc_dialog_begin $self->{token} $self->{dx} $self->{dy}"); |
783 | |
785 | |
784 | $self->{entry}->focus_in; |
786 | $self->{entry}->grab_focus; |
785 | |
787 | |
786 | $self->{textview}->add_paragraph ([1, 1, 0, 1], "<small>[starting conversation with <b>$self->{title}</b>]</small>\n\n"); |
788 | $self->{textview}->add_paragraph ([1, 1, 0, 1], "<small>[starting conversation with <b>$self->{title}</b>]</small>\n\n"); |
787 | |
789 | |
788 | $self->show; |
790 | $self->show; |
789 | $self |
791 | $self |
… | |
… | |
793 | my ($self) = @_; |
795 | my ($self) = @_; |
794 | |
796 | |
795 | Scalar::Util::weaken $self; |
797 | Scalar::Util::weaken $self; |
796 | |
798 | |
797 | $self->{options}->clear; |
799 | $self->{options}->clear; |
798 | $self->{options}->add ($self->{close_button}); |
800 | $self->{options}->add ($self->{bye_button}); |
799 | |
801 | |
800 | for my $kw (sort keys %{ $self->{kw} }) { |
802 | for my $kw (sort keys %{ $self->{kw} }) { |
801 | $self->{options}->add (new CFClient::UI::Button |
803 | $self->{options}->add (new CFClient::UI::Button |
802 | text => $kw, |
804 | text => $kw, |
803 | on_activate => sub { |
805 | on_activate => sub { |
804 | $self->send ($kw); |
806 | $self->send ($kw); |
|
|
807 | 0 |
805 | }, |
808 | }, |
806 | ); |
809 | ); |
807 | } |
810 | } |
808 | } |
811 | } |
809 | |
812 | |
… | |
… | |
837 | } |
840 | } |
838 | |
841 | |
839 | sub destroy { |
842 | sub destroy { |
840 | my ($self) = @_; |
843 | my ($self) = @_; |
841 | |
844 | |
842 | #Carp::cluck "debug\n";#d# #todo# enable: destroyx gets called twice because scalar keys {} is 1 |
845 | #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1 |
843 | |
846 | |
844 | delete $self->{conn}{npc_dialog}; |
847 | delete $self->{conn}{npc_dialog}; |
845 | $self->{conn}->disconnect_ext ($self->{token}); |
848 | $self->{conn}->disconnect_ext ($self->{token}); |
846 | |
849 | |
847 | $self->SUPER::destroy; |
850 | $self->SUPER::destroy; |