… | |
… | |
1042 | my ($self, $flags, $prompt) = @_; |
1042 | my ($self, $flags, $prompt) = @_; |
1043 | |
1043 | |
1044 | $prompt = $LAST_QUERY unless length $prompt; |
1044 | $prompt = $LAST_QUERY unless length $prompt; |
1045 | $LAST_QUERY = $prompt; |
1045 | $LAST_QUERY = $prompt; |
1046 | |
1046 | |
1047 | $self->{query}-> ($self, $flags, $prompt); |
1047 | $self->{query}->($self, $flags, $prompt); |
1048 | } |
1048 | } |
1049 | |
1049 | |
1050 | sub sanitise_xml($) { |
1050 | sub sanitise_xml($) { |
1051 | local $_ = shift; |
1051 | local $_ = shift; |
1052 | |
1052 | |
… | |
… | |
1114 | $self->logprint ("msg: ", $text); |
1114 | $self->logprint ("msg: ", $text); |
1115 | return if $color < 0; # negative color == ignore if not understood |
1115 | return if $color < 0; # negative color == ignore if not understood |
1116 | |
1116 | |
1117 | my $fg = $CF_COLOR[$color & NDI_COLOR_MASK] || [1, 0, 0]; |
1117 | my $fg = $CF_COLOR[$color & NDI_COLOR_MASK] || [1, 0, 0]; |
1118 | |
1118 | |
1119 | ## try to create single paragraphs of multiple lines sent by the server |
|
|
1120 | # no longer neecssary with TRT servers |
|
|
1121 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
|
|
1122 | |
|
|
1123 | ::message ({ |
1119 | ::message ({ |
1124 | fg => $fg, |
1120 | fg => $fg, |
1125 | markup => $text, |
1121 | markup => $text, |
1126 | type => $type, |
1122 | type => $type, |
1127 | extra => [@extra], |
1123 | extra => [@extra], |
… | |
… | |
1401 | $self->send_ext_req (lookat => $x, $y, sub { |
1397 | $self->send_ext_req (lookat => $x, $y, sub { |
1402 | my (%msg) = @_; |
1398 | my (%msg) = @_; |
1403 | |
1399 | |
1404 | if (exists $msg{npc_dialog}) { |
1400 | if (exists $msg{npc_dialog}) { |
1405 | # start npc chat dialog |
1401 | # start npc chat dialog |
1406 | $self->{npc_dialog} = new DC::NPCDialog:: |
1402 | $self->{w}{npc_dialog} = new DC::NPCDialog:: |
1407 | token => $msg{npc_dialog}, |
1403 | token => $msg{npc_dialog}, |
1408 | title => "$msg{npc_dialog}[0] (NPC)", |
1404 | title => "$msg{npc_dialog}[0] (NPC)", |
1409 | conn => $self, |
1405 | conn => $self, |
1410 | ; |
1406 | ; |
1411 | } |
1407 | } |
… | |
… | |
1416 | } |
1412 | } |
1417 | |
1413 | |
1418 | sub destroy { |
1414 | sub destroy { |
1419 | my ($self) = @_; |
1415 | my ($self) = @_; |
1420 | |
1416 | |
1421 | (delete $self->{npc_dialog})->destroy |
1417 | $_->destroy |
1422 | if $self->{npc_dialog}; |
1418 | for values %{ $self->{w} }; |
1423 | |
1419 | |
1424 | $self->SUPER::destroy; |
1420 | $self->SUPER::destroy; |
1425 | |
1421 | |
1426 | %$self = (); |
1422 | %$self = (); |
1427 | } |
1423 | } |
… | |
… | |
1581 | |
1577 | |
1582 | #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1 |
1578 | #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1 |
1583 | |
1579 | |
1584 | if ($self->{conn}) { |
1580 | if ($self->{conn}) { |
1585 | $self->{conn}->send_ext_msg (npc_dialog_end => $self->{id}) if $self->{id}; |
1581 | $self->{conn}->send_ext_msg (npc_dialog_end => $self->{id}) if $self->{id}; |
1586 | delete $self->{conn}{npc_dialog}; |
1582 | delete $self->{conn}{w}{npc_dialog}; |
1587 | $self->{conn}->disconnect_ext ($self->{id}); |
1583 | $self->{conn}->disconnect_ext ($self->{id}); |
1588 | } |
1584 | } |
1589 | |
1585 | |
1590 | $self->SUPER::destroy; |
1586 | $self->SUPER::destroy; |
1591 | } |
1587 | } |