… | |
… | |
412 | |
412 | |
413 | $text = CFClient::UI::Label::escape $text; |
413 | $text = CFClient::UI::Label::escape $text; |
414 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
414 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
415 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
415 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
416 | |
416 | |
417 | $self->{logview}->add_paragraph ($color[$color], |
417 | $self->{logview}->add_paragraph ($color[$color], $_) |
418 | join "\n", map "$time $_", split /\n/, $text); |
418 | for map "$time $_", split /\n/, $text; |
|
|
419 | $self->{logview}->scroll_to_bottom; |
419 | |
420 | |
420 | $self->{statusbox}->add ($text, |
421 | $self->{statusbox}->add ($text, |
421 | group => $text, |
422 | group => $text, |
422 | fg => $color[$color], |
423 | fg => $color[$color], |
423 | timeout => $color >= 2 ? 60 : 10, |
424 | timeout => $color >= 2 ? 60 : 10, |
… | |
… | |
769 | }, |
770 | }, |
770 | ); |
771 | ); |
771 | |
772 | |
772 | $vbox->add ($self->{options} = new CFClient::UI::VBox); |
773 | $vbox->add ($self->{options} = new CFClient::UI::VBox); |
773 | |
774 | |
774 | $self->{close_button} = new CFClient::UI::Button |
775 | $self->{bye_button} = new CFClient::UI::Button |
775 | text => "Bye (close)", |
776 | text => "Bye (close)", |
776 | tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.", |
777 | tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.", |
777 | on_activate => sub { $this->destroy; 0 }, |
778 | on_activate => sub { $this->destroy; 0 }, |
778 | ; |
779 | ; |
779 | |
780 | |
… | |
… | |
795 | my ($self) = @_; |
796 | my ($self) = @_; |
796 | |
797 | |
797 | Scalar::Util::weaken $self; |
798 | Scalar::Util::weaken $self; |
798 | |
799 | |
799 | $self->{options}->clear; |
800 | $self->{options}->clear; |
800 | $self->{options}->add ($self->{close_button}); |
801 | $self->{options}->add ($self->{bye_button}); |
801 | |
802 | |
802 | for my $kw (sort keys %{ $self->{kw} }) { |
803 | for my $kw (sort keys %{ $self->{kw} }) { |
803 | $self->{options}->add (new CFClient::UI::Button |
804 | $self->{options}->add (new CFClient::UI::Button |
804 | text => $kw, |
805 | text => $kw, |
805 | on_activate => sub { |
806 | on_activate => sub { |
… | |
… | |
840 | } |
841 | } |
841 | |
842 | |
842 | sub destroy { |
843 | sub destroy { |
843 | my ($self) = @_; |
844 | my ($self) = @_; |
844 | |
845 | |
845 | #Carp::cluck "debug\n";#d# #todo# enable: destroyx gets called twice because scalar keys {} is 1 |
846 | #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1 |
846 | |
847 | |
847 | delete $self->{conn}{npc_dialog}; |
848 | delete $self->{conn}{npc_dialog}; |
848 | $self->{conn}->disconnect_ext ($self->{token}); |
849 | $self->{conn}->disconnect_ext ($self->{token}); |
849 | |
850 | |
850 | $self->SUPER::destroy; |
851 | $self->SUPER::destroy; |