… | |
… | |
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}; |
… | |
… | |
134 | |
132 | |
135 | $self->{map}->map1a_update ($data); |
133 | $self->{map}->map1a_update ($data); |
136 | $self->{map_widget}->update; |
134 | $self->{map_widget}->update; |
137 | } |
135 | } |
138 | |
136 | |
|
|
137 | sub magicmap { |
|
|
138 | my ($self, $w, $h, $x, $y, $data) = @_; |
|
|
139 | |
|
|
140 | $self->{map_widget}->set_magicmap ($w, $h, $x, $y, $data); |
|
|
141 | } |
|
|
142 | |
139 | sub flush_map { |
143 | sub flush_map { |
140 | my ($self) = @_; |
144 | my ($self) = @_; |
141 | |
145 | |
142 | my $map_info = delete $self->{map_info} |
146 | my $map_info = delete $self->{map_info} |
143 | or return; |
147 | or return; |
… | |
… | |
154 | |
158 | |
155 | $self->flush_map; |
159 | $self->flush_map; |
156 | delete $self->{neigh_map}; |
160 | delete $self->{neigh_map}; |
157 | |
161 | |
158 | $self->{map}->clear; |
162 | $self->{map}->clear; |
|
|
163 | delete $self->{map_widget}{magicmap}; |
159 | } |
164 | } |
160 | |
165 | |
161 | |
166 | |
162 | sub load_map($$$) { |
167 | sub load_map($$$) { |
163 | my ($self, $hash, $x, $y) = @_; |
168 | my ($self, $hash, $x, $y) = @_; |
… | |
… | |
530 | |
535 | |
531 | $row++; |
536 | $row++; |
532 | } else { |
537 | } else { |
533 | $::FLOORBOX->add (1, $row, new CFClient::UI::Button |
538 | $::FLOORBOX->add (1, $row, new CFClient::UI::Button |
534 | text => "More...", |
539 | text => "More...", |
535 | on_activate => sub { $::INV_WINDOW->toggle_visibility }, |
540 | on_activate => sub { $::INV_WINDOW->toggle_visibility; 0 }, |
536 | ); |
541 | ); |
537 | last; |
542 | last; |
538 | } |
543 | } |
539 | } |
544 | } |
540 | }); |
545 | }); |
… | |
… | |
555 | tooltip => "Close the currently open container (if one is open)", |
560 | tooltip => "Close the currently open container (if one is open)", |
556 | on_activate => sub { |
561 | on_activate => sub { |
557 | $::CONN->send ("apply $tag") # $::CONN->{open_container}") |
562 | $::CONN->send ("apply $tag") # $::CONN->{open_container}") |
558 | if $tag != 0; |
563 | if $tag != 0; |
559 | #if $CONN->{open_container} != 0; |
564 | #if $CONN->{open_container} != 0; |
|
|
565 | 0 |
560 | }, |
566 | }, |
561 | ); |
567 | ); |
562 | } |
568 | } |
563 | |
569 | |
564 | $::INVR->set_items ($conn->{container}{$tag}); |
570 | $::INVR->set_items ($conn->{container}{$tag}); |
… | |
… | |
756 | |
762 | |
757 | return unless $text =~ /\S/; |
763 | return unless $text =~ /\S/; |
758 | |
764 | |
759 | $entry->set_text (""); |
765 | $entry->set_text (""); |
760 | $this->send ($text); |
766 | $this->send ($text); |
|
|
767 | |
|
|
768 | 0 |
761 | }, |
769 | }, |
762 | ); |
770 | ); |
763 | |
771 | |
764 | $vbox->add ($self->{options} = new CFClient::UI::VBox); |
772 | $vbox->add ($self->{options} = new CFClient::UI::VBox); |
765 | |
773 | |
766 | $self->{close_button} = new CFClient::UI::Button |
774 | $self->{bye_button} = new CFClient::UI::Button |
767 | text => "Bye (close)", |
775 | text => "Bye (close)", |
768 | 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.", |
769 | on_activate => sub { $this->destroy }, |
777 | on_activate => sub { $this->destroy; 0 }, |
770 | ; |
778 | ; |
771 | |
779 | |
772 | $self->update_options; |
780 | $self->update_options; |
773 | |
781 | |
774 | $self->{token} = $self->{conn}->ext_token; |
782 | $self->{token} = $self->{conn}->ext_token; |
775 | $self->{conn}->connect_ext ($self->{token} => sub { $this->feed (@_) }); |
783 | $self->{conn}->connect_ext ($self->{token} => sub { $this->feed (@_) }); |
776 | $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}"); |
777 | |
785 | |
778 | $self->{entry}->focus_in; |
786 | $self->{entry}->grab_focus; |
779 | |
787 | |
780 | $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"); |
781 | |
789 | |
782 | $self->show; |
790 | $self->show; |
783 | $self |
791 | $self |
… | |
… | |
787 | my ($self) = @_; |
795 | my ($self) = @_; |
788 | |
796 | |
789 | Scalar::Util::weaken $self; |
797 | Scalar::Util::weaken $self; |
790 | |
798 | |
791 | $self->{options}->clear; |
799 | $self->{options}->clear; |
792 | $self->{options}->add ($self->{close_button}); |
800 | $self->{options}->add ($self->{bye_button}); |
793 | |
801 | |
794 | for my $kw (sort keys %{ $self->{kw} }) { |
802 | for my $kw (sort keys %{ $self->{kw} }) { |
795 | $self->{options}->add (new CFClient::UI::Button |
803 | $self->{options}->add (new CFClient::UI::Button |
796 | text => $kw, |
804 | text => $kw, |
797 | on_activate => sub { |
805 | on_activate => sub { |
798 | $self->send ($kw); |
806 | $self->send ($kw); |
|
|
807 | 0 |
799 | }, |
808 | }, |
800 | ); |
809 | ); |
801 | } |
810 | } |
802 | } |
811 | } |
803 | |
812 | |
… | |
… | |
831 | } |
840 | } |
832 | |
841 | |
833 | sub destroy { |
842 | sub destroy { |
834 | my ($self) = @_; |
843 | my ($self) = @_; |
835 | |
844 | |
836 | #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 |
837 | |
846 | |
838 | delete $self->{conn}{npc_dialog}; |
847 | delete $self->{conn}{npc_dialog}; |
839 | $self->{conn}->disconnect_ext ($self->{token}); |
848 | $self->{conn}->disconnect_ext ($self->{token}); |
840 | |
849 | |
841 | $self->SUPER::destroy; |
850 | $self->SUPER::destroy; |