ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Protocol.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.33 by root, Mon Jun 12 14:06:27 2006 UTC vs.
Revision 1.53 by root, Mon Jul 3 22:32:52 2006 UTC

7 7
8use CFClient; 8use CFClient;
9use CFClient::UI; 9use CFClient::UI;
10 10
11use base 'Crossfire::Protocol::Base'; 11use base 'Crossfire::Protocol::Base';
12
13our %open_logs;
12 14
13sub new { 15sub new {
14 my $class = shift; 16 my $class = shift;
15 17
16 my $self = $class->SUPER::new (@_); 18 my $self = $class->SUPER::new (@_);
59 $self->{mapcache} = CFClient::db_table "mapcache_$self->{host}_$self->{port}"; 61 $self->{mapcache} = CFClient::db_table "mapcache_$self->{host}_$self->{port}";
60 62
61 $self 63 $self
62} 64}
63 65
66sub logprint {
67 my ($self, @a) = @_;
68 my $filename = "$Crossfire::VARDIR/log.$self->{host}";
69
70 my $fh = $open_logs{$filename};
71 unless ($fh) {
72 # FIXME: handle this more gracefully?
73 open $fh, ">>", $filename
74 or die "Couldn't open logfile: log.$self->{host}: $!";
75
76 $open_logs{$filename} = $fh;
77 }
78
79 my ($sec, $min, $hour, $mday, $mon, $year) = localtime (time);
80
81 my $ts = sprintf "%04d-%02d-%02d %02d:%02d:%02d",
82 $year + 1900, $mon + 1, $mday, $hour, $min, $sec;
83
84 print $fh "$ts ", @a, "\n";
85 $fh->flush;
86}
87
88sub _stat_numdiff {
89 my ($self, $old, $new) = @_;
90
91 my $diff = $new - $old;
92 $diff > 0 ? "+$diff" : $diff
93}
94
95sub _stat_skillmaskdiff {
96 my ($self, $old, $new) = @_;
97
98 my $diff = $old ^ $new;
99
100 my @diff = map
101 {
102 $diff & $_
103 ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_})
104 : ()
105 }
106 sort { $a <=> $b } keys %{$self->{spell_paths}};
107
108 join "", @diff
109}
110
111# all stats that are chacked against changes
112my @statchange = (
113 [&CS_STAT_STR => \&_stat_numdiff, "Str"],
114 [&CS_STAT_INT => \&_stat_numdiff, "Int"],
115 [&CS_STAT_WIS => \&_stat_numdiff, "Wis"],
116 [&CS_STAT_DEX => \&_stat_numdiff, "Dex"],
117 [&CS_STAT_CON => \&_stat_numdiff, "Con"],
118 [&CS_STAT_CHA => \&_stat_numdiff, "Cha"],
119 [&CS_STAT_POW => \&_stat_numdiff, "Pow"],
120 [&CS_STAT_WC => \&_stat_numdiff, "Wc"],
121 [&CS_STAT_AC => \&_stat_numdiff, "Ac"],
122 [&CS_STAT_DAM => \&_stat_numdiff, "Dam"],
123 [&CS_STAT_SPEED => \&_stat_numdiff, "Speed"],
124 [&CS_STAT_WEAP_SP => \&_stat_numdiff, "WSp"],
125 [&CS_STAT_MAXHP => \&_stat_numdiff, "HP"],
126 [&CS_STAT_MAXSP => \&_stat_numdiff, "Mana"],
127 [&CS_STAT_MAXGRACE => \&_stat_numdiff, "Grace"],
128 [&CS_STAT_WEIGHT_LIM => \&_stat_numdiff, "Weight"],
129 [&CS_STAT_SPELL_ATTUNE => \&_stat_skillmaskdiff, "attuned"],
130 [&CS_STAT_SPELL_REPEL => \&_stat_skillmaskdiff, "repelled"],
131 [&CS_STAT_SPELL_DENY => \&_stat_skillmaskdiff, "denied"],
132 [&CS_STAT_RES_PHYS => \&_stat_numdiff, "phys"],
133 [&CS_STAT_RES_MAG => \&_stat_numdiff, "magic"],
134 [&CS_STAT_RES_FIRE => \&_stat_numdiff, "fire"],
135 [&CS_STAT_RES_ELEC => \&_stat_numdiff, "electricity"],
136 [&CS_STAT_RES_COLD => \&_stat_numdiff, "cold"],
137 [&CS_STAT_RES_CONF => \&_stat_numdiff, "confusion"],
138 [&CS_STAT_RES_ACID => \&_stat_numdiff, "acid"],
139 [&CS_STAT_RES_DRAIN => \&_stat_numdiff, "drain"],
140 [&CS_STAT_RES_GHOSTHIT => \&_stat_numdiff, "ghosthit"],
141 [&CS_STAT_RES_POISON => \&_stat_numdiff, "poison"],
142 [&CS_STAT_RES_SLOW => \&_stat_numdiff, "slow"],
143 [&CS_STAT_RES_PARA => \&_stat_numdiff, "paralyse"],
144 [&CS_STAT_TURN_UNDEAD => \&_stat_numdiff, "turnundead"],
145 [&CS_STAT_RES_FEAR => \&_stat_numdiff, "fear"],
146 [&CS_STAT_RES_DEPLETE => \&_stat_numdiff, "depletion"],
147 [&CS_STAT_RES_DEATH => \&_stat_numdiff, "death"],
148 [&CS_STAT_RES_HOLYWORD => \&_stat_numdiff, "godpower"],
149 [&CS_STAT_RES_BLIND => \&_stat_numdiff, "blind"],
150);
151
64sub stats_update { 152sub stats_update {
65 my ($self, $stats) = @_; 153 my ($self, $stats) = @_;
66 154
67 if (my $exp = $stats->{+CS_STAT_EXP64}) { 155 if (my $prev = $self->{prev_stats}) {
68 my $diff = $exp - $self->{prev_exp}; 156 if (my $diff = $stats->{+CS_STAT_EXP64} - $prev->{+CS_STAT_EXP64}) {
69 $self->{statusbox}->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5) 157 $self->{statusbox}->add ("$diff experience gained", group => "experience $diff", fg => [0.5, 1, 0.5, 0.8], timeout => 5);
70 if exists $self->{prev_exp} && $diff; 158 }
71 $self->{prev_exp} = $exp; 159
160 if (
161 my @diffs = map {
162 $stats->{$_->[0]} != $prev->{$_->[0]}
163 ? $_->[2] . $_->[1]->($self, $prev->{$_->[0]}, $stats->{$_->[0]}) : ();
164 }
165 @statchange
166 ) {
167 my $msg = "<b>stat change</b>: " . (join " ", @diffs);
168 $self->{statusbox}->add ($msg, group => $msg, fg => [0.8, 1, 0.2, 1], timeout => 10);
169 }
72 } 170 }
171
172 $self->{prev_stats} = { %$stats };
73 173
74 ::update_stats_window ($stats); 174 ::update_stats_window ($stats);
75} 175}
76 176
77sub user_send { 177sub user_send {
79 179
80 if ($self->{record}) { 180 if ($self->{record}) {
81 push @{$self->{record}}, $command; 181 push @{$self->{record}}, $command;
82 } 182 }
83 183
184 $self->logprint ("send: ", $command);
84 $self->send_command ($command); 185 $self->send_command ($command);
85 ::status $command; 186 ::status ($command);
86} 187}
87 188
88sub start_record { 189sub start_record {
89 my ($self) = @_; 190 my ($self) = @_;
90 191
105sub feed_map1a { 206sub feed_map1a {
106 my ($self, $data) = @_; 207 my ($self, $data) = @_;
107 208
108 $self->{map}->map1a_update ($data); 209 $self->{map}->map1a_update ($data);
109 $self->{map_widget}->update; 210 $self->{map_widget}->update;
211}
212
213sub magicmap {
214 my ($self, $w, $h, $x, $y, $data) = @_;
215
216 $self->{map_widget}->set_magicmap ($w, $h, $x, $y, $data);
110} 217}
111 218
112sub flush_map { 219sub flush_map {
113 my ($self) = @_; 220 my ($self) = @_;
114 221
127 234
128 $self->flush_map; 235 $self->flush_map;
129 delete $self->{neigh_map}; 236 delete $self->{neigh_map};
130 237
131 $self->{map}->clear; 238 $self->{map}->clear;
239 delete $self->{map_widget}{magicmap};
132} 240}
133 241
134 242
135sub load_map($$$) { 243sub load_map($$$) {
136 my ($self, $hash, $x, $y) = @_; 244 my ($self, $hash, $x, $y) = @_;
279 # I love transactions 387 # I love transactions
280 for (1..100) { 388 for (1..100) {
281 my $txn = $CFClient::DB_ENV->txn_begin; 389 my $txn = $CFClient::DB_ENV->txn_begin;
282 my $status = $self->{facemap}->db_get (id => $id); 390 my $status = $self->{facemap}->db_get (id => $id);
283 if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { 391 if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) {
284 $id = ($id || 16) + 1; 392 $id = ($id || 64) + 1;
285 if ($self->{facemap}->put (id => $id) == 0 393 if ($self->{facemap}->put (id => $id) == 0
286 && $self->{facemap}->put ($hash => $id) == 0) { 394 && $self->{facemap}->put ($hash => $id) == 0) {
287 $txn->txn_commit; 395 $txn->txn_commit;
288 396
289 goto gotid; 397 goto gotid;
369 [0.55, 0.41, 0.13], 477 [0.55, 0.41, 0.13],
370 [0.99, 0.77, 0.26], 478 [0.99, 0.77, 0.26],
371 [0.74, 0.65, 0.41], 479 [0.74, 0.65, 0.41],
372 ); 480 );
373 481
482 $self->logprint ("info: ", $text);
483
374 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0]; 484 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
375 485
376 # try to create single paragraphs of multiple lines sent by the server 486 # try to create single paragraphs of multiple lines sent by the server
377 $text =~ s/(?<=\S)\n(?=\w)/ /g; 487 $text =~ s/(?<=\S)\n(?=\w)/ /g;
378 488
379 $text = CFClient::UI::Label::escape $text; 489 $text = CFClient::UI::Label::escape $text;
380 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 490 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
381 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 491 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
382 492
383 $self->{logview}->add_paragraph ($color[$color], 493 $self->{logview}->add_paragraph ($color[$color], $_)
384 join "\n", map "$time $_", split /\n/, $text); 494 for map "$time $_", split /\n/, $text;
495 $self->{logview}->scroll_to_bottom;
385 496
386 $self->{statusbox}->add ($text, 497 $self->{statusbox}->add ($text,
387 group => $text, 498 group => $text,
388 fg => $color[$color], 499 fg => $color[$color],
389 timeout => $color >= 2 ? 60 : 10, 500 timeout => $color >= 2 ? 60 : 10,
403 # try to create single paragraphs of multiple lines sent by the server 514 # try to create single paragraphs of multiple lines sent by the server
404 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g; 515 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g;
405 $spell->{message} =~ s/\n+$//; 516 $spell->{message} =~ s/\n+$//;
406 $spell->{message} ||= "Server did not provide a description for this spell."; 517 $spell->{message} ||= "Server did not provide a description for this spell.";
407 518
408 $::SETUP_SPELLS->add_spell ($spell); 519 $::SPELL_PAGE->add_spell ($spell);
409 520
410 $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message}); 521 $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message});
411 $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message}); 522 $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message});
412} 523}
413 524
414sub spell_delete { 525sub spell_delete {
415 my ($self, $spell) = @_; 526 my ($self, $spell) = @_;
527
416 $::SETUP_SPELLS->remove_spell ($spell); 528 $::SPELL_PAGE->remove_spell ($spell);
417} 529}
418 530
419sub addme_success { 531sub addme_success {
420 my ($self) = @_; 532 my ($self) = @_;
421 533
488 return unless $::CONN; 600 return unless $::CONN;
489 601
490 $::FLOORBOX->clear; 602 $::FLOORBOX->clear;
491 603
492 my $row; 604 my $row;
493 for (@{ $::CONN->{container}{0} }) { 605 for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{0} }) {
494 if ($row < 6) { 606 if ($row < 6) {
495 local $_->{face_widget}; # hack to force recreation of widget 607 local $_->{face_widget}; # hack to force recreation of widget
496 local $_->{desc_widget}; # hack to force recreation of widget 608 local $_->{desc_widget}; # hack to force recreation of widget
497 CFClient::Item::update_widgets $_; 609 CFClient::Item::update_widgets $_;
498 610
501 613
502 $row++; 614 $row++;
503 } else { 615 } else {
504 $::FLOORBOX->add (1, $row, new CFClient::UI::Button 616 $::FLOORBOX->add (1, $row, new CFClient::UI::Button
505 text => "More...", 617 text => "More...",
506 on_activate => sub { $::INV_WINDOW->toggle_visibility }, 618 on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 },
507 ); 619 );
508 last; 620 last;
509 } 621 }
510 } 622 }
511 }); 623 });
526 tooltip => "Close the currently open container (if one is open)", 638 tooltip => "Close the currently open container (if one is open)",
527 on_activate => sub { 639 on_activate => sub {
528 $::CONN->send ("apply $tag") # $::CONN->{open_container}") 640 $::CONN->send ("apply $tag") # $::CONN->{open_container}")
529 if $tag != 0; 641 if $tag != 0;
530 #if $CONN->{open_container} != 0; 642 #if $CONN->{open_container} != 0;
643 0
531 }, 644 },
532 ); 645 );
533 } 646 }
534 647
535 $::INVR->set_items ($conn->{container}{$tag}); 648 $::INVR->set_items ($conn->{container}{$tag});
536} 649}
537 650
538sub update_container { 651sub update_containers {
539 my ($tag) = @_; 652 my ($self) = @_;
540 653
541 $::INVR->set_items ($::CONN->{container}{$::CONN->{open_container}}) 654 $CFClient::UI::ROOT->on_refresh ("update_containers_$self" => sub {
655 for my $tag (keys %{ delete $self->{update_container} }) {
656 if ($tag == 0) {
657 update_floorbox;
658 $::INVR->set_items ($self->{container}{0})
542 if $tag == $::CONN->{open_container}; 659 if $tag == $self->{open_container};
660 } elsif ($tag == $self->{player}{tag}) {
661 $::INV->set_items ($self->{container}{$tag})
662 } else {
663 $::INVR->set_items ($self->{container}{$tag})
664 if $tag == $self->{open_container};
665 }
666 }
667 });
543} 668}
544 669
545sub container_add { 670sub container_add {
546 my ($self, $tag, $items) = @_; 671 my ($self, $tag, $items) = @_;
547 672
548 #d# print "container_add: container $tag ($self->{player}{tag})\n"; 673 $self->{update_container}{$tag}++;
549 674 $self->update_containers;
550 if ($tag == 0) {
551 update_floorbox;
552 update_container (0);
553 } elsif ($tag == $self->{player}{tag}) {
554 $::INV->set_items ($self->{container}{$self->{player}{tag}})
555 } else {
556 update_container ($tag);
557 }
558
559 # $self-<{player}{tag} => player inv
560 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
561} 675}
562 676
563sub container_clear { 677sub container_clear {
564 my ($self, $tag) = @_; 678 my ($self, $tag) = @_;
565 679
566 #d# print "container_clear: container $tag ($self->{player}{tag})\n"; 680 $self->{update_container}{$tag}++;
567 681 $self->update_containers;
568 if ($tag == 0) {
569 update_floorbox;
570 update_container (0);
571 } elsif ($tag == $self->{player}{tag}) {
572 $::INV->set_items ($self->{container}{$tag})
573 } else {
574 update_container ($tag);
575 }
576
577# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
578} 682}
579 683
580sub item_delete { 684sub item_delete {
581 my ($self, @items) = @_; 685 my ($self, @items) = @_;
582 686
687 $self->{update_container}{$_->{container}}++
583 for (@items) { 688 for @items;
584 #d# print "item_delete: $_->{tag} from $_->{container} ($self->{player}{tag})\n";
585
586 if ($_->{container} == 0) {
587 update_floorbox;
588 update_container ($_->{tag});
589 } elsif ($_->{container} == $self->{player}{tag}) {
590 $::INV->set_items ($self->{container}{$self->{player}{tag}})
591 } else {
592 update_container ($_->{container});
593 }
594 } 689
690 $self->update_containers;
595} 691}
596 692
597sub item_update { 693sub item_update {
598 my ($self, $item) = @_; 694 my ($self, $item) = @_;
599 695
600 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; 696 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n";
601 697
602 if ($item->{tag} == $self->{player}{tag}) {
603 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $item->{weight} / 1000);
604 return;
605 }
606
607 CFClient::Item::update_widgets $item; 698 CFClient::Item::update_widgets $item;
608 699
609 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { 700 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) {
610 set_opencont ($::CONN, 0, "Floor"); 701 set_opencont ($::CONN, 0, "Floor");
611 702
612 } elsif ($item->{flags} & F_OPEN) { 703 } elsif ($item->{flags} & F_OPEN) {
613 set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item); 704 set_opencont ($::CONN, $item->{tag}, CFClient::Item::desc_string $item);
705
614 } else { 706 } else {
707 $self->{update_container}{$item->{container}}++;
708 $self->update_containers;
615 if ($item->{container} == 0) { 709# if ($item->{container} == 0) {
616 update_floorbox; 710# update_floorbox;
617 update_container (0); 711# update_container (0);
618 } elsif ($item->{container} == $self->{player}{tag}) { 712# } elsif ($item->{container} == $self->{player}{tag}) {
619 $::INV->set_items ($self->{container}{$item->{container}}) 713# $::INV->set_items ($self->{container}{$item->{container}})
620 } 714# }
621 } 715 }
622} 716}
623 717
624sub player_update { 718sub player_update {
625 my ($self, $player) = @_; 719 my ($self, $player) = @_;
626
627 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); 720 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000);
628} 721}
629 722
630sub update_server_info { 723sub update_server_info {
631 my ($self) = @_; 724 my ($self) = @_;
727 820
728 return unless $text =~ /\S/; 821 return unless $text =~ /\S/;
729 822
730 $entry->set_text (""); 823 $entry->set_text ("");
731 $this->send ($text); 824 $this->send ($text);
825
826 0
732 }, 827 },
733 ); 828 );
734 829
735 $vbox->add ($self->{options} = new CFClient::UI::VBox); 830 $vbox->add ($self->{options} = new CFClient::UI::VBox);
736 831
737 $self->{close_button} = new CFClient::UI::Button 832 $self->{bye_button} = new CFClient::UI::Button
738 text => "Bye (close)", 833 text => "Bye (close)",
739 tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.", 834 tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.",
740 on_activate => sub { $this->destroy }, 835 on_activate => sub { $this->destroy; 0 },
741 ; 836 ;
742 837
743 $self->update_options; 838 $self->update_options;
744 839
745 $self->{token} = $self->{conn}->ext_token; 840 $self->{token} = $self->{conn}->ext_token;
746 $self->{conn}->connect_ext ($self->{token} => sub { $this->feed (@_) }); 841 $self->{conn}->connect_ext ($self->{token} => sub { $this->feed (@_) });
747 $self->{conn}->send ("ext npc_dialog_begin $self->{token} $self->{dx} $self->{dy}"); 842 $self->{conn}->send ("ext npc_dialog_begin $self->{token} $self->{dx} $self->{dy}");
748 843
749 $self->{entry}->focus_in; 844 $self->{entry}->grab_focus;
750 845
751 $self->{textview}->add_paragraph ([1, 1, 0, 1], "<small>[starting conversation with <b>$self->{title}</b>]</small>\n\n"); 846 $self->{textview}->add_paragraph ([1, 1, 0, 1], "<small>[starting conversation with <b>$self->{title}</b>]</small>\n\n");
752 847
753 $self->show; 848 $self->show;
754 $self 849 $self
758 my ($self) = @_; 853 my ($self) = @_;
759 854
760 Scalar::Util::weaken $self; 855 Scalar::Util::weaken $self;
761 856
762 $self->{options}->clear; 857 $self->{options}->clear;
763 $self->{options}->add ($self->{close_button}); 858 $self->{options}->add ($self->{bye_button});
764 859
765 for my $kw (sort keys %{ $self->{kw} }) { 860 for my $kw (sort keys %{ $self->{kw} }) {
766 $self->{options}->add (new CFClient::UI::Button 861 $self->{options}->add (new CFClient::UI::Button
767 text => $kw, 862 text => $kw,
768 on_activate => sub { 863 on_activate => sub {
769 $self->send ($kw); 864 $self->send ($kw);
865 0
770 }, 866 },
771 ); 867 );
772 } 868 }
773} 869}
774 870
775sub feed { 871sub feed {
776 my ($self, $data) = @_; 872 my ($self, $data) = @_;
873
874 Scalar::Util::weaken $self;
777 875
778 my ($type, $msg) = split / /, $data, 2; 876 my ($type, $msg) = split / /, $data, 2;
779 877
780 if ($type eq "msg") { 878 if ($type eq "msg") {
781 my ($msg, @kw) = split /\x00/, $msg; 879 my ($msg, @kw) = split /\x00/, $msg;
782 $self->{kw}{$_} = 1 for @kw; 880 $self->{kw}{$_} = 1 for @kw;
783 881
784 $msg = CFClient::UI::Label::escape $msg; 882 $msg = "\n" . CFClient::UI::Label::escape $msg;
785 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; 883 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} };
786 $msg =~ s/($match)/<span foreground='#c0c0ff' underline='none'>$1<\/span>/gi; # underline when http-ready, huh. 884 my @link;
885 $msg =~ s{
886 ($match)
887 }{
888 my $kw = $1;
889
890 push @link, new CFClient::UI::Label
891 markup => "<span foreground='#c0c0ff' underline='single'>$kw</span>",
892 can_hover => 1,
893 can_events => 1,
894 padding_x => 0,
895 padding_y => 0,
896 on_button_up => sub {
897 $self->send ($kw);
898 };
899
900 chr 0xfffc
901 }giex;
787 902
788 $self->{textview}->add_paragraph ([1, 1, 1, 1], "\n$msg"); 903 $self->{textview}->add_paragraph ([1, 1, 1, 1], [$msg, @link]);
904 $self->{textview}->scroll_to_bottom;
789 $self->update_options; 905 $self->update_options;
790 } else { 906 } else {
791 $self->destroy; 907 $self->destroy;
792 } 908 }
793 909
797sub send { 913sub send {
798 my ($self, $msg) = @_; 914 my ($self, $msg) = @_;
799 915
800 $self->{conn}->send ("ext npc_dialog_tell $self->{token} $msg"); 916 $self->{conn}->send ("ext npc_dialog_tell $self->{token} $msg");
801 $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::UI::Label::escape $msg); 917 $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::UI::Label::escape $msg);
918 $self->{textview}->scroll_to_bottom;
802} 919}
803 920
804sub destroy { 921sub destroy {
805 my ($self) = @_; 922 my ($self) = @_;
806 923
807 #Carp::cluck "debug\n";#d# #todo# enable: destroyx gets called twice because scalar keys {} is 1 924 #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1
808 925
809 delete $self->{conn}{npc_dialog}; 926 delete $self->{conn}{npc_dialog};
810 $self->{conn}->disconnect_ext ($self->{token}); 927 $self->{conn}->disconnect_ext ($self->{token});
811 928
812 $self->SUPER::destroy; 929 $self->SUPER::destroy;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines