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.202 by root, Tue Sep 9 10:27:26 2008 UTC vs.
Revision 1.224 by root, Wed Nov 7 00:25:46 2012 UTC

1package DC::Protocol; 1package DC::Protocol;
2 2
3use utf8; 3use common::sense;
4use strict; 4
5use Guard ();
5 6
6use Deliantra::Protocol::Constants; 7use Deliantra::Protocol::Constants;
7 8
8use DC; 9use DC;
9use DC::DB; 10use DC::DB;
13use DC::Item; 14use DC::Item;
14 15
15use base 'Deliantra::Protocol::Base'; 16use base 'Deliantra::Protocol::Base';
16 17
17our $TEX_DIALOGUE = new_from_resource DC::Texture 18our $TEX_DIALOGUE = new_from_resource DC::Texture
18 "dialogue.png", minify => 1, mipmap => 1; 19 "dialogue.png", minify => 1, mipmap => 1;
19 20
20our $TEX_NOFACE = new_from_resource DC::Texture 21our $TEX_NOFACE = new_from_resource DC::Texture
21 "noface.png", minify => 1, mipmap => 1; 22 "noface.png", minify => 1, mipmap => 1, wrap => 1;
23
24sub MIN_TEXTURE_UNUSED() { 1 }#d#
22 25
23sub new { 26sub new {
24 my ($class, %arg) = @_; 27 my ($class, %arg) = @_;
25 28
26 my $self = $class->SUPER::new (%arg, 29 my $self = $class->SUPER::new (%arg,
27 setup_req => { 30 setup_req => {
28 extmap => 1, 31 extmap => 1,
29 excmd => 1,
30 widget => 2, 32 widget => 2,
31 %{$arg{setup_req} || {}}, 33 %{$arg{setup_req} || {}},
32 }, 34 },
33 ); 35 );
36
37 $self->update_fx_want;
38
39 my $exp_guard = $self->addme_guard;
40 my $skl_guard = $self->addme_guard;
41 my $spl_guard = $self->addme_guard;
42 $self->send_exti_req (resource => qw(exp_table skill_info spell_paths), sub {
43 my ($exp, $skl, $spl) = @_;
44
45 $self->register_face_handler ($exp, sub {
46 my ($face) = @_;
47
48 undef $exp_guard;
49 $self->{exp_table} = $self->{json_coder}->decode (delete $face->{data});
50 $_->() for values %{ $self->{on_exp_update} };
51 });
52
53 $self->register_face_handler ($skl, sub {
54 my ($face) = @_;
55
56 undef $skl_guard;
57 my $info = $self->{json_coder}->decode (delete $face->{data});
58 $self->{skill_info} = { map { CS_STAT_SKILLINFO + $_ => $info->[$_][0] } 0 .. $#$info };
59 });
60
61 $self->register_face_handler ($spl, sub {
62 my ($face) = @_;
63
64 undef $spl_guard;
65 my $info = $self->{json_coder}->decode (delete $face->{data});
66 $self->{spell_paths} = { map { (1 << $_) => $info->[$_][0] } 0 .. $#$info };
67 });
68
69 ()
70 });
34 71
35 $self->{map_widget}->clr_commands; 72 $self->{map_widget}->clr_commands;
36 73
37 my @cmd_help = map { 74 my @cmd_help = map {
38 $_->[DC::Pod::N_KW][0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x 75 $_->[DC::Pod::N_KW][0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
73 for values %{delete $ws->{w} || {}}; 110 for values %{delete $ws->{w} || {}};
74 } 111 }
75 112
76 delete $self->{items}; 113 delete $self->{items};
77 $::INV->clear; 114 $::INV->clear;
115 $::INVR->clear;
78 $::INVR_HB->clear; 116 $::INVR_HB->clear;
79 $::FLOORBOX->clear; 117 $::FLOORBOX->clear;
80 }); 118 });
81 119
82 $self->{map_widget}->add_command (@$_) 120 $self->{map_widget}->add_command (@$_)
89 127
90 { 128 {
91 $self->{noface} = my $tex = $TEX_NOFACE; 129 $self->{noface} = my $tex = $TEX_NOFACE;
92 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 130 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}});
93 } 131 }
132
133# $self->{expire_count} = DC::DB::FIRST_TILE_ID; # minimum non-fixed tile id
134# $self->{expire_w} = AE::timer 1, 1, sub {
135# my $count = (int @{ $self->{texture} } / MIN_TEXTURE_UNUSED) || 1;
136#
137# for ($self->{map}->expire_textures ($self->{expire_count}, $count)) {
138# warn DC::SvREFCNT $self->{texture}[$_];
139# $self->{texture}[$_]->unload;
140# warn "expire texture $_\n";#d#
141# }
142#
143# ($self->{expire_count} += $count) < @{ $self->{texture} }
144# or $self->{expire_count} = DC::DB::FIRST_TILE_ID;
145# warn "count is $count\n";#d#
146# };
94 147
95 $self->{open_container} = 0; 148 $self->{open_container} = 0;
96 149
97 # per server 150 # per server
98 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; 151 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}";
110 }); 163 });
111} 164}
112 165
113sub ext_capabilities { 166sub ext_capabilities {
114 my ($self, %cap) = @_; 167 my ($self, %cap) = @_;
115
116 $self->update_fx_want;
117
118 $self->send_exti_req (resource => "exp_table", sub {
119 my ($exp_table) = @_;
120
121 $self->register_face_handler ($exp_table, sub {
122 my ($face) = @_;
123
124 $self->{exp_table} = $self->{json_coder}->decode (delete $face->{data});
125 $_->() for values %{ $self->{on_exp_update} || {} };
126 });
127
128 ()
129 });
130 168
131 if (my $ts = $cap{tileset}) { 169 if (my $ts = $cap{tileset}) {
132 if (my ($default) = grep $_->[2] & 1, @$ts) { 170 if (my ($default) = grep $_->[2] & 1, @$ts) {
133 $self->{tileset} = $default; 171 $self->{tileset} = $default;
134 $self->{tilesize} = $default->[3]; 172 $self->{tilesize} = $default->[3];
259 my %wkw = ( 297 my %wkw = (
260 root => $DC::UI::ROOT, 298 root => $DC::UI::ROOT,
261 tooltip => $DC::UI::TOOLTIP, 299 tooltip => $DC::UI::TOOLTIP,
262 300
263 mapwidget => $::MAPWIDGET, 301 mapwidget => $::MAPWIDGET,
302 menubar => $::MENUBAR,
303 menupopup => $::MENUPOPUP,
304 pickup_enable => $::PICKUP_ENABLE,
264 buttonbar => $::BUTTONBAR, 305 buttonbar => $::BUTTONBAR,
265 metaserver => $::METASERVER, 306 metaserver => $::METASERVER,
266 buttonbar => $::BUTTONBAR, 307 buttonbar => $::BUTTONBAR,
267 login_button => $::LOGIN_BUTTON, 308 login_button => $::LOGIN_BUTTON,
268 quit_dialog => $::QUIT_DIALOG, 309 quit_dialog => $::QUIT_DIALOG,
285 326
286 floorbox => $::FLOORBOX, 327 floorbox => $::FLOORBOX,
287 help_window => $::HELP_WINDOW, 328 help_window => $::HELP_WINDOW,
288 message_window => $::MESSAGE_WINDOW, 329 message_window => $::MESSAGE_WINDOW,
289 message_dist => $::MESSAGE_DIST, 330 message_dist => $::MESSAGE_DIST,
290 statusbox => $::SDTATUSBOX, 331 statusbox => $::STATUSBOX,
291 332
292 inv => $::INV, 333 inv => $::INV,
293 invr => $::INVR, 334 invr => $::INVR,
294 invr_hb => $::INVR_HB, 335 invr_hb => $::INVR_HB,
295 ); 336 );
379 ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_}) 420 ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_})
380 : () 421 : ()
381 } 422 }
382 sort { $a <=> $b } keys %{$self->{spell_paths}}; 423 sort { $a <=> $b } keys %{$self->{spell_paths}};
383 424
384 join "", @diff 425 "\u$name: " . (join ", ", @diff)
385} 426}
386 427
387# all stats that are chacked against changes 428# all stats that are chacked against changes
388my @statchange = ( 429my @statchange = (
389 [&CS_STAT_STR => \&_stat_numdiff, "Str"], 430 [&CS_STAT_STR => \&_stat_numdiff, "Str"],
432 473
433 if (my @diffs = 474 if (my @diffs =
434 ( 475 (
435 ($stats->{+CS_STAT_EXP64} > $prev->{+CS_STAT_EXP64} ? ($stats->{+CS_STAT_EXP64} - $prev->{+CS_STAT_EXP64}) . " experience gained" : ()), 476 ($stats->{+CS_STAT_EXP64} > $prev->{+CS_STAT_EXP64} ? ($stats->{+CS_STAT_EXP64} - $prev->{+CS_STAT_EXP64}) . " experience gained" : ()),
436 map { 477 map {
437 $stats->{$_} && $prev->{$_} 478 $stats->{$_} && $prev->{$_}
438 && $stats->{$_}[1] > $prev->{$_}[1] ? "($self->{skill_info}{$_}+" . ($stats->{$_}[1] - $prev->{$_}[1]) . ")" : () 479 && $stats->{$_}[1] > $prev->{$_}[1] ? "($self->{skill_info}{$_}+" . ($stats->{$_}[1] - $prev->{$_}[1]) . ")" : ()
439 } sort { $a <=> $b } keys %{$self->{skill_info}} 480 } sort { $a <=> $b } keys %{$self->{skill_info}}
440 ) 481 )
441 ) { 482 ) {
442 my $msg = join " ", @diffs; 483 my $msg = join " ", @diffs;
444 } 485 }
445 486
446 if ( 487 if (
447 my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange 488 my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange
448 ) { 489 ) {
449 my $msg = "<b>stat change</b>: " . (join " ", @diffs); 490 my $msg = "<b>stat change</b>: " . (join " ", map "($_)", @diffs);
450 $self->{statusbox}->add ($msg, group => "stat $msg", fg => [0.8, 1, 0.2, 1], timeout => 20); 491 $self->{statusbox}->add ($msg, group => "stat $msg", fg => [0.8, 1, 0.2, 1], timeout => 20);
451 } 492 }
452 493
453 $self->update_stats_window ($stats, $prev); 494 $self->update_stats_window ($stats, $prev);
454 495
492 533
493 $::GAUGES->{hp} ->set_value ($hp, $hp_m); 534 $::GAUGES->{hp} ->set_value ($hp, $hp_m);
494 $::GAUGES->{mana} ->set_value ($sp, $sp_m); 535 $::GAUGES->{mana} ->set_value ($sp, $sp_m);
495 $::GAUGES->{food} ->set_value ($fo, $fo_m); 536 $::GAUGES->{food} ->set_value ($fo, $fo_m);
496 $::GAUGES->{grace} ->set_value ($gr, $gr_m); 537 $::GAUGES->{grace} ->set_value ($gr, $gr_m);
497 $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64})) 538 $::GAUGES->{exp} ->set_label ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64}))#d#
498 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); 539 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")");
499 $::GAUGES->{prg} ->set_value ($stats->{+CS_STAT_LEVEL}, $stats->{+CS_STAT_EXP64}); 540 $::GAUGES->{exp} ->set_value ($stats->{+CS_STAT_LEVEL}, $stats->{+CS_STAT_EXP64});
500 $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE}); 541 $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE});
501 my $title = $stats->{+CS_STAT_TITLE}; 542 my $title = $stats->{+CS_STAT_TITLE};
502 $title =~ s/^Player: //; 543 $title =~ s/^Player: //;
503 $::STATWIDS->{title} ->set_text ("Title: " . $title); 544 $::STATWIDS->{title} ->set_text ("Title: " . $title);
504 545
516 $::STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED}); 557 $::STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED});
517 $::STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP}); 558 $::STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP});
518 559
519 $self->update_weight; 560 $self->update_weight;
520 561
521 $::STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$RES_TBL{$_}}) 562 $::STATWIDS->{"res_$_"}->set_text (sprintf "%d%%", $stats->{$RES_TBL{$_}})
522 for keys %RES_TBL; 563 for keys %RES_TBL;
523 564
524 my $sktbl = $::STATWIDS->{skill_tbl}; 565 my $sktbl = $::STATWIDS->{skill_tbl};
525 my @skills = keys %{ $self->{skill_info} }; 566 my @skills = keys %{ $self->{skill_info} };
526 567
545 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), 586 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0),
546 ]; 587 ];
547 588
548 my @add = @$sw; 589 my @add = @$sw;
549 590
550 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; 591 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use skill\nRight click - further options</small>";
551 592
552 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 593 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
553 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 594 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
554 595
555 my ($x, $y) = (0, 1); 596 my ($x, $y) = (0, 1);
617 my $sw = $self->{skillwid}{$idx}; 658 my $sw = $self->{skillwid}{$idx};
618 $sw->[0]->set_text (::formsep ($val->[1])); 659 $sw->[0]->set_text (::formsep ($val->[1]));
619 $sw->[1]->set_text ($val->[0] * 1); 660 $sw->[1]->set_text ($val->[0] * 1);
620 $sw->[2]->set_value (@$val); 661 $sw->[2]->set_value (@$val);
621 662
622 $::GAUGES->{sklprg}->set_label ("$name %d%%"); 663 $::GAUGES->{skillexp}->set_label ("$name %d%%");
623 $::GAUGES->{sklprg}->set_value (@$val); 664 $::GAUGES->{skillexp}->set_value (@$val);
624 } 665 }
625} 666}
626 667
627sub user_send { 668sub user_send {
628 my ($self, $command) = @_; 669 my ($self, $command) = @_;
647} 688}
648 689
649sub feed_map1a { 690sub feed_map1a {
650 my ($self, $data) = @_; 691 my ($self, $data) = @_;
651 692
652 my $missing = $self->{map}->map1a_update ($data, $self->{setup}{extmap}); 693 my $missing = $self->{map}->map1a_update ($data);
653 my $delay; 694 my $delay;
654 695
655 for my $tile (@$missing) { 696 for my $tile (@$missing) {
656 next if $self->{delay}{$tile}; 697 next if $self->{delay}{$tile};
657 698
658 $delay = 1; 699 $delay = 1;
659 700
660 if (my $tex = $::CONN->{texture}[$tile]) { 701 if (my $tex = $self->{texture}[$tile]) {
661 $tex->upload; 702 $tex->upload;
662 } else { 703 } else {
663 $self->{delay}{$tile} = 1; 704 $self->{delay}{$tile} = 1;
664 705
665 # we assume the face is in-flight and will eventually come 706 # we assume the face is in-flight and will eventually arrive
666 push @{$self->{tile_cb}{$tile}}, sub { 707 push @{$self->{tile_cb}{$tile}}, sub {
667 delete $self->{delay}{$tile}; 708 delete $self->{delay}{$tile};
668 $_[0]->upload; 709 $_[0]->upload;
669 }; 710 };
670 } 711 }
671 } 712 }
672 713
673 if ($delay) { 714 if ($delay) {
674 # delay the map drawing a tiny bit in the hope of getting the missing fetched 715 # delay the map drawing a tiny bit in the hope of getting the missing tiles fetched
675 EV::once undef, 0, 0.03, sub { 716 EV::once undef, 0, 0.03, sub {
676 $self->{map_widget}->update 717 $self->{map_widget}->update
677 if $self->{map_widget}; 718 if $self->{map_widget};
678 }; 719 };
679 } else { 720 } else {
967 1008
968 my $tex = $self->{texture}[$tile] ||= 1009 my $tex = $self->{texture}[$tile] ||=
969 new DC::Texture 1010 new DC::Texture
970 tile => $tile, 1011 tile => $tile,
971 image => $data, delete_image => 1, 1012 image => $data, delete_image => 1,
972 minify => 1, mipmap => 1; 1013 minify => 1;
973 1014
974 if (my $cbs = delete $self->{tile_cb}{$tile}) { 1015 if (my $cbs = delete $self->{tile_cb}{$tile}) {
975 $_->($tex) for @$cbs; 1016 $_->($tex) for @$cbs;
976 } 1017 }
977} 1018}
982 my ($self, $num, $cb) = @_; 1023 my ($self, $num, $cb) = @_;
983 1024
984 push @{$self->{face_cb}{$num}}, $cb; 1025 push @{$self->{face_cb}{$num}}, $cb;
985 1026
986 defined wantarray 1027 defined wantarray
987 ? DC::guard { 1028 ? Guard::guard {
988 @{$self->{face_cb}{$num}} 1029 @{$self->{face_cb}{$num}}
989 = grep $_ != $cb, 1030 = grep $_ != $cb,
990 @{$self->{face_cb}{$num}}; 1031 @{$self->{face_cb}{$num}};
991 } 1032 }
992 : () 1033 : ()
1020 my ($self, $flags, $prompt) = @_; 1061 my ($self, $flags, $prompt) = @_;
1021 1062
1022 $prompt = $LAST_QUERY unless length $prompt; 1063 $prompt = $LAST_QUERY unless length $prompt;
1023 $LAST_QUERY = $prompt; 1064 $LAST_QUERY = $prompt;
1024 1065
1025 $self->{query}-> ($self, $flags, $prompt); 1066 $self->{query}->($self, $flags, $prompt);
1026} 1067}
1027 1068
1028sub sanitise_xml($) { 1069sub sanitise_xml($) {
1029 local $_ = shift; 1070 local $_ = shift;
1030 1071
1062 tan => 12, 1103 tan => 12,
1063); 1104);
1064 1105
1065our @CF_COLOR = ( 1106our @CF_COLOR = (
1066 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], 1107 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
1067 [1.00, 1.00, 1.00], 1108 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
1068 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] 1109 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55],
1069 [1.00, 0.00, 0.00], 1110 [1.00, 0.00, 0.00],
1070 [1.00, 0.54, 0.00], 1111 [1.00, 0.54, 0.00],
1071 [0.11, 0.56, 1.00], 1112 [0.11, 0.56, 1.00],
1072 [0.93, 0.46, 0.00], 1113 [0.93, 0.46, 0.00],
1073 [0.18, 0.54, 0.34], 1114 [0.18, 0.54, 0.34],
1091 } else { 1132 } else {
1092 $self->logprint ("msg: ", $text); 1133 $self->logprint ("msg: ", $text);
1093 return if $color < 0; # negative color == ignore if not understood 1134 return if $color < 0; # negative color == ignore if not understood
1094 1135
1095 my $fg = $CF_COLOR[$color & NDI_COLOR_MASK] || [1, 0, 0]; 1136 my $fg = $CF_COLOR[$color & NDI_COLOR_MASK] || [1, 0, 0];
1096
1097 ## try to create single paragraphs of multiple lines sent by the server
1098 # no longer neecssary with TRT servers
1099 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
1100 1137
1101 ::message ({ 1138 ::message ({
1102 fg => $fg, 1139 fg => $fg,
1103 markup => $text, 1140 markup => $text,
1104 type => $type, 1141 type => $type,
1325sub update_server_info { 1362sub update_server_info {
1326 my ($self) = @_; 1363 my ($self) = @_;
1327 1364
1328 my @yesno = ("<span foreground='red'>no</span>", "<span foreground='green'>yes</span>"); 1365 my @yesno = ("<span foreground='red'>no</span>", "<span foreground='green'>yes</span>");
1329 1366
1367 my $version = JSON::XS->new->encode ($self->{s_version});
1368
1330 $::SERVER_INFO->set_markup ( 1369 $::SERVER_INFO->set_markup (
1331 "server <tt>$self->{host}:$self->{port}</tt>\n" 1370 "server <tt>$self->{host}:$self->{port}</tt>\n"
1332 . "protocol version <tt>$self->{version}</tt>\n" 1371 . "protocol version <tt>$version</tt>\n"
1333 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
1334 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
1335 . "examine command support $yesno[$self->{setup}{excmd} > 0]\n"
1336 . "editing support $yesno[!!$self->{editor_support}]\n" 1372 . "editing support $yesno[!!$self->{editor_support}]\n"
1337 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
1338 . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n"
1339 . "client support $yesno[$self->{cfplus_ext} > 0]" 1373 . "client support $yesno[$self->{cfplus_ext} > 0]"
1340 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 1374 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
1341 . "map size $self->{mapw}×$self->{maph}\n" 1375 . "map size $self->{mapw}×$self->{maph}\n"
1342 ); 1376 );
1343 1377
1365 }); 1399 });
1366 1400
1367 $self->update_server_info; 1401 $self->update_server_info;
1368 1402
1369 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; 1403 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0;
1370 $self->send_command ("pickup $::CFG->{pickup}"); 1404 $self->send_pickup ($::CFG->{pickup});
1371
1372 $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]",
1373 DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d#
1374} 1405}
1375 1406
1376sub lookat { 1407sub lookat {
1377 my ($self, $x, $y) = @_; 1408 my ($self, $x, $y) = @_;
1378 1409
1380 $self->send_ext_req (lookat => $x, $y, sub { 1411 $self->send_ext_req (lookat => $x, $y, sub {
1381 my (%msg) = @_; 1412 my (%msg) = @_;
1382 1413
1383 if (exists $msg{npc_dialog}) { 1414 if (exists $msg{npc_dialog}) {
1384 # start npc chat dialog 1415 # start npc chat dialog
1385 $self->{npc_dialog} = new DC::NPCDialog:: 1416 $self->{w}{npc_dialog} = new DC::NPCDialog::
1386 token => $msg{npc_dialog}, 1417 token => $msg{npc_dialog},
1387 title => "$msg{npc_dialog}[0] (NPC)", 1418 title => "$msg{npc_dialog}[0] (NPC)",
1388 conn => $self, 1419 conn => $self,
1389 ; 1420 ;
1390 } 1421 }
1395} 1426}
1396 1427
1397sub destroy { 1428sub destroy {
1398 my ($self) = @_; 1429 my ($self) = @_;
1399 1430
1400 (delete $self->{npc_dialog})->destroy 1431 $_->destroy
1401 if $self->{npc_dialog}; 1432 for values %{ $self->{w} };
1402 1433
1403 $self->SUPER::destroy; 1434 $self->SUPER::destroy;
1404 1435
1405 %$self = (); 1436 %$self = ();
1406} 1437}
1542} 1573}
1543 1574
1544sub send { 1575sub send {
1545 my ($self, $msg) = @_; 1576 my ($self, $msg) = @_;
1546 1577
1547 $self->{textview}->add_paragraph ({ markup => "\n" . DC::asxml $msg }); 1578 $self->{textview}->add_paragraph ({
1579 markup =>
1580 "\n<span foreground='#ffff00'><b>"
1581 . (DC::asxml $msg)
1582 . "</b></span>"
1583 });
1548 $self->{textview}->scroll_to_bottom; 1584 $self->{textview}->scroll_to_bottom;
1549 1585
1550 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); 1586 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg);
1551} 1587}
1552 1588
1555 1591
1556 #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1 1592 #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1
1557 1593
1558 if ($self->{conn}) { 1594 if ($self->{conn}) {
1559 $self->{conn}->send_ext_msg (npc_dialog_end => $self->{id}) if $self->{id}; 1595 $self->{conn}->send_ext_msg (npc_dialog_end => $self->{id}) if $self->{id};
1560 delete $self->{conn}{npc_dialog}; 1596 delete $self->{conn}{w}{npc_dialog};
1561 $self->{conn}->disconnect_ext ($self->{id}); 1597 $self->{conn}->disconnect_ext ($self->{id});
1562 } 1598 }
1563 1599
1564 $self->SUPER::destroy; 1600 $self->SUPER::destroy;
1565} 1601}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines