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.159 by root, Tue Aug 21 17:54:02 2007 UTC vs.
Revision 1.183 by root, Wed Dec 26 21:03:21 2007 UTC

1package CFPlus::Protocol; 1package DC::Protocol;
2 2
3use utf8; 3use utf8;
4use strict; 4use strict;
5 5
6use Crossfire::Protocol::Constants; 6use Deliantra::Protocol::Constants;
7 7
8use CFPlus; 8use DC;
9use CFPlus::DB; 9use DC::DB;
10use CFPlus::UI; 10use DC::UI;
11use CFPlus::Pod; 11use DC::Pod;
12use CFPlus::Macro; 12use DC::Macro;
13use CFPlus::Item; 13use DC::Item;
14 14
15use Crossfire::Protocol::Base 0.95;
16
17use base 'Crossfire::Protocol::Base'; 15use base 'Deliantra::Protocol::Base';
18 16
19sub new { 17sub new {
20 my ($class, %arg) = @_; 18 my ($class, %arg) = @_;
21 19
22 my $self = $class->SUPER::new (%arg, 20 my $self = $class->SUPER::new (%arg,
23 setup_req => { 21 setup_req => {
24 extmap => 1, 22 extmap => 1,
25 excmd => 1, 23 excmd => 1,
26 xwidget1 => 1,#d# 24 widget => 1,
27 %{$arg{setup_req} || {}}, 25 %{$arg{setup_req} || {}},
28 }, 26 },
29 ); 27 );
30 28
31 $self->{map_widget}->clr_commands; 29 $self->{map_widget}->clr_commands;
36 34
37 my $cmd = $1; 35 my $cmd = $1;
38 my @args = split /\|/, $2; 36 my @args = split /\|/, $2;
39 @args = (".*") unless @args; 37 @args = (".*") unless @args;
40 38
41 my (undef, @par) = CFPlus::Pod::section_of $_; 39 my (undef, @par) = DC::Pod::section_of $_;
42 my $text = CFPlus::Pod::as_label @par; 40 my $text = DC::Pod::as_label @par;
43 41
44 $_ = $_ eq ".*" ? "" : " $_" 42 $_ = $_ eq ".*" ? "" : " $_"
45 for @args; 43 for @args;
46 44
47 map ["$cmd$_", $text], 45 map ["$cmd$_", $text],
48 sort { (length $a) <=> (length $b) } 46 sort { (length $a) <=> (length $b) }
49 @args 47 @args
50 } sort { $a->{par} <=> $b->{par} } 48 } sort { $a->{par} <=> $b->{par} }
51 CFPlus::Pod::find command => "*"; 49 DC::Pod::find command => "*";
52 50
53 $self->{json_coder} 51 $self->{json_coder}
54 ->convert_blessed 52 ->convert_blessed
55 ->filter_json_single_key_object (__w_ => sub { 53 ->filter_json_single_key_object ("\fw" => sub {
56 $self->{widget}{$_[0]} 54 $self->{widget}{$_[0]}
55 })
56 ->filter_json_single_key_object ("\fc" => sub {
57 my ($id) = @_;
58 sub {
59 $self->send_exti_msg (w_e => $id, @_);
60 }
57 }); 61 });
58 62
59 # destroy widgets on logout 63 # destroy widgets on logout
60 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { 64 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub {
61 for my $ws (values %{delete $self->{widgetset} || {}}) { 65 for my $ws (values %{delete $self->{widgetset} || {}}) {
66 70
67 $self->{map_widget}->add_command (@$_) 71 $self->{map_widget}->add_command (@$_)
68 for @cmd_help; 72 for @cmd_help;
69 73
70 { 74 {
71 $self->{dialogue} = my $tex = new_from_file CFPlus::Texture 75 $self->{dialogue} = my $tex = new_from_file DC::Texture
72 CFPlus::find_rcfile "dialogue.png", minify => 1, mipmap => 1; 76 DC::find_rcfile "dialogue.png", minify => 1, mipmap => 1;
73 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 77 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}});
74 } 78 }
75 79
76 { 80 {
77 $self->{noface} = my $tex = new_from_file CFPlus::Texture 81 $self->{noface} = my $tex = new_from_file DC::Texture
78 CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1; 82 DC::find_rcfile "noface.png", minify => 1, mipmap => 1;
79 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 83 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}});
80 } 84 }
81 85
82 $self->{open_container} = 0; 86 $self->{open_container} = 0;
83 87
138############################################################################# 142#############################################################################
139 143
140sub widget_associate { 144sub widget_associate {
141 my ($self, $ws, $id, $widget) = @_; 145 my ($self, $ws, $id, $widget) = @_;
142 146
143 if ($widget) { 147 $widget ||= new DC::UI::Bin;
148
144 $widget->{s_id} = $id; 149 $widget->{s_id} = $id;
145 $self->{widget}{$id} = $widget; 150 $self->{widget}{$id} = $widget;
146 151
147 if ($ws) { 152 if ($ws) {
148 $widget->{s_ws} = $ws; 153 $widget->{s_ws} = $ws;
149 $self->{widgetset}{$ws}{w}{$id} = $widget; 154 $self->{widgetset}{$ws}{w}{$id} = $widget;
150 } 155 }
151 156
152 $widget->connect (on_destroy => sub { 157 $widget->connect (on_destroy => sub {
153 my ($widget) = @_; 158 my ($widget) = @_;
154 159
155 delete $self->{widget}{$widget->{s_id}}; 160 delete $self->{widget}{$widget->{s_id}};
156 delete $self->{widgetset}{$widget->{s_ws}}{$widget->{s_id}} 161 delete $self->{widgetset}{$widget->{s_ws}}{$widget->{s_id}}
157 if exists $widget->{s_ws}; 162 if exists $widget->{s_ws};
158 }); 163 });
159
160 1
161 } else {
162 $self->send_exti_msg (w_e => $id, undef);
163
164 0
165 }
166} 164}
167 165
168# widgetset new 166# widgetset new
169sub ext_ws_n { 167sub ext_ws_n {
170 my ($id) = @_; 168 my ($self, $id) = @_;
171 169
172 $self->{widgetset}{$id} = { 170 $self->{widgetset}{$id} = {
173 w => {}, 171 w => {},
174 }; 172 };
175} 173}
176 174
177# widgetset destroy 175# widgetset destroy
178sub ext_ws_d { 176sub ext_ws_d {
179 my ($id) = @_; 177 my ($self, $id) = @_;
180 178
181 my $ws = delete $self->{widgetset}{$id} 179 my $ws = delete $self->{widgetset}{$id}
182 or return; 180 or return;
183 181
184 $_->destroy 182 $_->destroy
185 for values %{$ws->{w}}; 183 for values %{$ws->{w}};
186} 184}
187 185
188# widgetset create 186# widgetset create
189sub ext_ws_c => sub { 187sub ext_ws_c {
190 my ($ws, $id, $class, $args) = @_; 188 my ($self, $ws, $id, $class, $args) = @_;
191
192 for my $ev (grep /^on_/, keys %$args) {
193 my $rid = $args->{$ev};
194 $args->{$ev} = sub {
195 my $id = shift->{s_id};
196 $self->send_exti_msg (w_e => $id, $rid, @_);
197
198 1
199 };
200 }
201 189
202 $self->widget_associate ( 190 $self->widget_associate (
203 $ws, $id => scalar eval { 191 $ws, $id => scalar eval {
204 local $SIG{__DIE__}; 192 local $SIG{__DIE__};
205 "CFPlus::UI::$class"->new (%$args) 193 "DC::UI::$class"->new (%$args)
206 } 194 }
207 ) or warn "server failed creating client-side widget " . (CFPlus::to_json $class) . ": $@\n"; 195 );
208} 196}
209 197
210# widgetset associate 198# widgetset associate
211sub ext_ws_a { 199sub ext_ws_a {
212 my (%ass) = @_; 200 my ($self, %ass) = @_;
213 201
214 # everything that has a name, wether conceivably useful or not 202 # everything that has a name, wether conceivably useful or not
215 my %wkw = ( 203 my %wkw = (
216 root => $CFPlus::UI::ROOT, 204 root => $DC::UI::ROOT,
217 tooltip => $CFPlus::UI::TOOLTIP, 205 tooltip => $DC::UI::TOOLTIP,
218 206
219 mapwidget => $::MAPWIDGET, 207 mapwidget => $::MAPWIDGET,
220 buttonbar => $::BUTTONBAR, 208 buttonbar => $::BUTTONBAR,
221 metaserver => $::METASERVER, 209 metaserver => $::METASERVER,
222 buttonbar => $::BUTTONBAR, 210 buttonbar => $::BUTTONBAR,
248 invr => $::INVR, 236 invr => $::INVR,
249 invr_hb => $::INVR_HB, 237 invr_hb => $::INVR_HB,
250 ); 238 );
251 239
252 while (my ($id, $name) = each %ass) { 240 while (my ($id, $name) = each %ass) {
253 $self->widget_associate (undef, $id => $wkw{$name}) 241 $self->widget_associate (undef, $id => $wkw{$name});
254 or warn "server failed to associate non-existent well-known widget $name\n";
255 } 242 }
256} 243}
257 244
258# widget call 245# widget call
259sub ext_w_c { 246sub ext_w_c {
260 my ($id, $rid, $method, @args) = @_; 247 my ($self, $id, $rcb, $method, @args) = @_;
261 248
262 my $w = $self->{widget}{$id} 249 my $w = $self->{widget}{$id}
263 or return; 250 or return;
264 251
265 if ($rid) { 252 if ($rcb) {
266 $self->send_exti_msg (w_r => $rid, $w->$method (@args)); 253 $rcb->($w->$method (@args));
267 } else { 254 } else {
268 $w->$method (@args); 255 $w->$method (@args);
269 } 256 }
270} 257}
271 258
272# widget set 259# widget set
273sub ext_w_s { 260sub ext_w_s {
274 my ($id, $attr) = @_; 261 my ($self, $id, $attr) = @_;
275 262
276 my $w = $self->{widget}{$id} 263 my $w = $self->{widget}{$id}
277 or return; 264 or return;
278 265
279 for (my $i = 0; $i < $#$attr; $i += 2) { 266 for (my $i = 0; $i < $#$attr; $i += 2) {
287 } 274 }
288} 275}
289 276
290# widget get 277# widget get
291sub ext_w_g { 278sub ext_w_g {
292 my ($id, $rid, $attr) = @_; 279 my ($self, $id, $rid, @attr) = @_;
293 280
294 my $w = $self->{widget}{$id} 281 my $w = $self->{widget}{$id}
295 or return; 282 or return;
296 283
297 $self->send_exti_msg (w_r => $rid, [map $w->{$_}, @$attr]); 284 $self->send_exti_msg (w_e => $rid, map $w->{$_}, @attr);
298}) 285}
299 286
300# message window 287# message window
301sub ext_channel_info { 288sub ext_channel_info {
302 my ($info) = @_; 289 my ($self, $info) = @_;
303 $self->{channels}->{$info->{id}} = $info; 290 $self->{channels}->{$info->{id}} = $info;
304 $::MESSAGE_WINDOW->add_channel ($info); 291 $::MESSAGE_WINDOW->add_channel ($info);
305} 292}
306 293
307############################################################################# 294#############################################################################
308 295
309sub logprint { 296sub logprint {
310 my ($self, @a) = @_; 297 my ($self, @a) = @_;
311 298
312 CFPlus::DB::logprint "$Crossfire::VARDIR/log.$self->{host}" => (join "", @a), sub { }; 299 DC::DB::logprint "$Deliantra::VARDIR/log.$self->{host}" => (join "", @a), sub { };
313} 300}
314 301
315sub _stat_numdiff { 302sub _stat_numdiff {
316 my ($self, $name, $old, $new) = @_; 303 my ($self, $name, $old, $new) = @_;
317 304
401 388
402 if ( 389 if (
403 my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange 390 my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange
404 ) { 391 ) {
405 my $msg = "<b>stat change</b>: " . (join " ", @diffs); 392 my $msg = "<b>stat change</b>: " . (join " ", @diffs);
406 $self->{statusbox}->add ($msg, group => "stat $msg", fg => [0.8, 1, 0.2, 1], timeout => 10); 393 $self->{statusbox}->add ($msg, group => "stat $msg", fg => [0.8, 1, 0.2, 1], timeout => 20);
407 } 394 }
408 395
409 $self->update_stats_window ($stats, $prev); 396 $self->update_stats_window ($stats, $prev);
410 397
411 $self->{prev_stats} = { %$stats }; 398 $self->{prev_stats} = { %$stats };
478 for keys %RES_TBL; 465 for keys %RES_TBL;
479 466
480 my $sktbl = $::STATWIDS->{skill_tbl}; 467 my $sktbl = $::STATWIDS->{skill_tbl};
481 my @skills = keys %{ $self->{skill_info} }; 468 my @skills = keys %{ $self->{skill_info} };
482 469
483 if (grep +(exists $stats->{$_}) != (exists $prev->{$_}), @skills) { 470 my @order = sort { $stats->{$b->[0]}[1] <=> $stats->{$a->[0]}[1] or $a->[1] cmp $b->[1] }
471 map [$_, $self->{skill_info}{$_}],
472 grep exists $stats->{$_},
473 @skills;
474
475 if ($self->{stat_order} ne join ",", map $_->[0], @order) {
476 $self->{stat_order} = join ",", map $_->[0], @order;
477
484 $sktbl->clear; 478 $sktbl->clear;
485 479
486 my $sw = $self->{skillwid}{""} ||= [ 480 my $sw = $self->{skillwid}{""} ||= [
487 0, 0, (new CFPlus::UI::Label text => "Experience", align => 1), 481 0, 0, (new DC::UI::Label text => "Experience", align => 1),
488 1, 0, (new CFPlus::UI::Label text => "Lvl.", align => 1), 482 1, 0, (new DC::UI::Label text => "Lvl.", align => 1),
489 2, 0, (new CFPlus::UI::Label text => "Progress", align => 0), 483 2, 0, (new DC::UI::Label text => "Progress", align => 0),
490 3, 0, (new CFPlus::UI::Label text => "Skill", expand => 1), 484 3, 0, (new DC::UI::Label text => "Skill", expand => 1),
491 4, 0, (new CFPlus::UI::Label text => "Experience", align => 1), 485 4, 0, (new DC::UI::Label text => "Experience", align => 1),
492 5, 0, (new CFPlus::UI::Label text => "Lvl.", align => 1), 486 5, 0, (new DC::UI::Label text => "Lvl.", align => 1),
493 6, 0, (new CFPlus::UI::Label text => "Progress", align => 0), 487 6, 0, (new DC::UI::Label text => "Progress", align => 0),
494 7, 0, (new CFPlus::UI::Label text => "Skill", expand => 1), 488 7, 0, (new DC::UI::Label text => "Skill", expand => 1),
495 ]; 489 ];
496 490
497 my @add = @$sw; 491 my @add = @$sw;
498 492
499 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; 493 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>";
500 494
501 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 495 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
502 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 496 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
503 497
504 my ($x, $y) = (0, 1); 498 my ($x, $y) = (0, 1);
505 for ( 499 for (@order) {
506 sort { $stats->{$b->[0]}[1] <=> $stats->{$a->[0]}[1] or $a->[1] cmp $b->[1] }
507 map [$_, $self->{skill_info}{$_}],
508 grep exists $stats->{$_},
509 @skills
510 ) {
511 my ($idx, $name) = @$_; 500 my ($idx, $name) = @$_;
512 501
513 my $spell_cb = sub { 502 my $spell_cb = sub {
514 my ($widget, $ev) = @_; 503 my ($widget, $ev) = @_;
515 504
516 if ($ev->{button} == 1) { 505 if ($ev->{button} == 1) {
517 $::CONN->user_send ("ready_skill $name"); 506 $::CONN->user_send ("ready_skill $name");
518 } elsif ($ev->{button} == 2) { 507 } elsif ($ev->{button} == 2) {
519 $::CONN->user_send ("use_skill $name"); 508 $::CONN->user_send ("use_skill $name");
520 } elsif ($ev->{button} == 3) { 509 } elsif ($ev->{button} == 3) {
521 my $shortname = CFPlus::shorten $name, 14; 510 my $shortname = DC::shorten $name, 14;
522 (new CFPlus::UI::Menu 511 (new DC::UI::Menu
523 items => [ 512 items => [
524 ["bind <i>ready_skill $shortname</i> to a key" => sub { CFPlus::Macro::quick_macro ["ready_skill $name"] }], 513 ["bind <i>ready_skill $shortname</i> to a key" => sub { DC::Macro::quick_macro ["ready_skill $name"] }],
525 ["bind <i>use_skill $shortname</i> to a key" => sub { CFPlus::Macro::quick_macro ["use_skill $name"] }], 514 ["bind <i>use_skill $shortname</i> to a key" => sub { DC::Macro::quick_macro ["use_skill $name"] }],
526 ], 515 ],
527 )->popup ($ev); 516 )->popup ($ev);
528 } else { 517 } else {
529 return 0; 518 return 0;
530 } 519 }
532 1 521 1
533 }; 522 };
534 523
535 my $sw = $self->{skillwid}{$idx} ||= [ 524 my $sw = $self->{skillwid}{$idx} ||= [
536 # exp 525 # exp
537 (new CFPlus::UI::Label 526 (new DC::UI::Label
538 align => 1, font => $::FONT_FIXED, fg => [1, 1, 0], on_button_down => $spell_cb, @TOOLTIP_EXP), 527 align => 1, font => $::FONT_FIXED, fg => [1, 1, 0], on_button_down => $spell_cb, @TOOLTIP_EXP),
539 528
540 # level 529 # level
541 (new CFPlus::UI::Label 530 (new DC::UI::Label
542 text => "0", align => 1, font => $::FONT_FIXED, fg => [0, 1, 0], padding_x => 4, on_button_down => $spell_cb, @TOOLTIP_LVL), 531 text => "0", align => 1, font => $::FONT_FIXED, fg => [0, 1, 0], padding_x => 4, on_button_down => $spell_cb, @TOOLTIP_LVL),
543 532
544 # progress 533 # progress
545 (new CFPlus::UI::ExperienceProgress), 534 (new DC::UI::ExperienceProgress),
546 535
547 # label 536 # label
548 (new CFPlus::UI::Label text => $name, on_button_down => $spell_cb, 537 (new DC::UI::Label text => $name, on_button_down => $spell_cb,
549 can_events => 1, can_hover => 1, tooltip => (CFPlus::Pod::section_label skill_description => $name) . $TOOLTIP_ALL), 538 can_events => 1, can_hover => 1, tooltip => (DC::Pod::section_label skill_description => $name) . $TOOLTIP_ALL),
550 ]; 539 ];
551 540
552 push @add, 541 push @add,
553 $x * 4 + 0, $y, $sw->[0], 542 $x * 4 + 0, $y, $sw->[0],
554 $x * 4 + 1, $y, $sw->[1], 543 $x * 4 + 1, $y, $sw->[1],
560 } 549 }
561 550
562 $sktbl->add_at (@add); 551 $sktbl->add_at (@add);
563 } 552 }
564 553
565 for (grep exists $stats->{$_}, @skills) { 554 for (@order) {
555 my ($idx, $name) = @$_;
556 my $val = $stats->{$idx};
557
558 next if $prev->{$idx}[1] eq $val->[1];
559
566 my $sw = $self->{skillwid}{$_}; 560 my $sw = $self->{skillwid}{$idx};
567 $sw->[0]->set_text (::formsep ($stats->{$_}[1])); 561 $sw->[0]->set_text (::formsep ($val->[1]));
568 $sw->[1]->set_text ($stats->{$_}[0] * 1); 562 $sw->[1]->set_text ($val->[0] * 1);
569 $sw->[2]->set_value (@{$stats->{$_}}); 563 $sw->[2]->set_value (@$val);
570 }
571}
572 564
573sub macro_send { 565 $::GAUGES->{sklprg}->set_label ("$name %d%%");
574 my ($self, $macro) = @_; 566 $::GAUGES->{sklprg}->set_value (@$val);
575
576 for my $cmd (@{ $macro->{action} }) {
577 $self->send_command ($cmd);
578 } 567 }
579} 568}
580 569
581sub user_send { 570sub user_send {
582 my ($self, $command) = @_; 571 my ($self, $command) = @_;
584 $self->{record}->($command) 573 $self->{record}->($command)
585 if $self->{record}; 574 if $self->{record};
586 575
587 $self->logprint ("send: ", $command); 576 $self->logprint ("send: ", $command);
588 $self->send_command ($command); 577 $self->send_command ($command);
589 ::status ($command);
590} 578}
591 579
592sub record { 580sub record {
593 my ($self, $cb) = @_; 581 my ($self, $cb) = @_;
594 582
625 } 613 }
626 } 614 }
627 615
628 if ($delay) { 616 if ($delay) {
629 # delay the map drawing a tiny bit in the hope of getting the missing fetched 617 # delay the map drawing a tiny bit in the hope of getting the missing fetched
630 Event->timer (after => 0.03, cb => sub { 618 EV::once undef, 0, 0.03, sub {
631 $_[0]->w->cancel;
632 $self->{map_widget}->update; 619 $self->{map_widget}->update
620 if $self->{map_widget};
633 }); 621 };
634 } else { 622 } else {
635 $self->{map_widget}->update; 623 $self->{map_widget}->update;
636 } 624 }
637} 625}
638 626
650 638
651 my ($hash, $x, $y, $w, $h) = @$map_info; 639 my ($hash, $x, $y, $w, $h) = @$map_info;
652 640
653 my $data = Compress::LZF::compress $self->{map}->get_rect ($x, $y, $w, $h); 641 my $data = Compress::LZF::compress $self->{map}->get_rect ($x, $y, $w, $h);
654 $self->{map_cache_new}{$hash} = \$data; 642 $self->{map_cache_new}{$hash} = \$data;
655 CFPlus::DB::put $self->{mapcache} => $hash => $data, sub { }; 643 DC::DB::put $self->{mapcache} => $hash => $data, sub { };
656} 644}
657 645
658sub map_clear { 646sub map_clear {
659 my ($self) = @_; 647 my ($self) = @_;
660 648
673 do { 661 do {
674 $tile = pop @{$self->{bg_fetch}} 662 $tile = pop @{$self->{bg_fetch}}
675 or return; 663 or return;
676 } while $self->{texture}[$tile]; 664 } while $self->{texture}[$tile];
677 665
678 CFPlus::DB::get tilecache => $tile, sub { 666 DC::DB::get tilecache => $tile, sub {
679 my ($data) = @_; 667 my ($data) = @_;
680 668
681 return unless $self->{map}; # stop when destroyed 669 return unless $self->{map}; # stop when destroyed
682 670
683 if (defined $data) { 671 if (defined $data) {
711 }; 699 };
712 700
713 if (my $rdata = $self->{map_cache_old}{$hash}) { 701 if (my $rdata = $self->{map_cache_old}{$hash}) {
714 $cb->($$rdata); 702 $cb->($$rdata);
715 } else { 703 } else {
716 CFPlus::DB::get $self->{mapcache} => $hash, $cb; 704 DC::DB::get $self->{mapcache} => $hash, $cb;
717 } 705 }
718} 706}
719 707
720# hardcode /world/world_xxx_xxx map names, the savings are enourmous, 708# hardcode /world/world_xxx_xxx map names, the savings are enourmous,
721# (server resource,s latency, bandwidth), so this hack is warranted. 709# (server resource,s latency, bandwidth), so this hack is warranted.
845 833
846sub face_find { 834sub face_find {
847 my ($self, $facenum, $face, $cb) = @_; 835 my ($self, $facenum, $face, $cb) = @_;
848 836
849 if ($face->{type} == 0) { # FT_FACE 837 if ($face->{type} == 0) { # FT_FACE
850 my $id = CFPlus::DB::get_tile_id_sync $face->{name}; 838 my $id = DC::DB::get_tile_id_sync $face->{name};
851 839
852 $face->{id} = $id; 840 $face->{id} = $id;
853 $self->{map}->set_tileid ($facenum => $id); 841 $self->{map}->set_tileid ($facenum => $id);
854 842
855 CFPlus::DB::get tilecache => $id, $cb; 843 DC::DB::get tilecache => $id, $cb;
856 844
857 } elsif ($face->{type} & 1) { # with metadata 845 } elsif ($face->{type} & 1) { # with metadata
858 CFPlus::DB::get res_meta => $face->{name}, $cb; 846 DC::DB::get res_meta => $face->{name}, $cb;
859 847
860 } else { # no metadata 848 } else { # no metadata
861 CFPlus::DB::get res_data => $face->{name}, $cb; 849 DC::DB::get res_data => $face->{name}, $cb;
862 } 850 }
863} 851}
864 852
865sub face_update { 853sub face_update {
866 my ($self, $facenum, $face, $changed) = @_; 854 my ($self, $facenum, $face, $changed) = @_;
867 855
868 if ($face->{type} == 0) { 856 if ($face->{type} == 0) {
869 # image, FT_FACE 857 # image, FT_FACE
870 CFPlus::DB::put tilecache => $face->{id} => $face->{data}, sub { } 858 DC::DB::put tilecache => $face->{id} => $face->{data}, sub { }
871 if $changed; 859 if $changed;
872 860
873 $self->have_tile ($face->{id}, delete $face->{data}); 861 $self->have_tile ($face->{id}, delete $face->{data});
874 862
875 } elsif ($face->{type} & 1) { 863 } elsif ($face->{type} & 1) {
876 # split metadata case, FT_MUSIC, FT_SOUND 864 # split metadata case, FT_MUSIC, FT_SOUND
877 if ($changed) { # new data 865 if ($changed) { # new data
878 my ($meta, $data) = unpack "(w/a*)*", $face->{data}; 866 my ($meta, $data) = unpack "(w/a*)*", $face->{data};
879 $face->{data} = $meta; 867 $face->{data} = $meta;
880 868
869 # rely on strict ordering here and also on later fetch
881 CFPlus::DB::put res_data => $face->{name} => $data, sub { }; 870 DC::DB::put res_data => $face->{name} => $data, sub { };
882 CFPlus::DB::put res_meta => $face->{name} => $meta, sub { }; 871 DC::DB::put res_meta => $face->{name} => $meta, sub { };
883 } 872 }
884 873
885 $face->{data} = $self->{json_coder}->decode ($face->{data}); 874 $face->{data} = $self->{json_coder}->decode ($face->{data});
886
887 ::add_license ($face); 875 ::add_license ($face);
876 ::message ({ markup => DC::asxml "downloaded resource '$face->{data}{name}', type $face->{type}." })
877 if $changed;
888 878
889 if ($face->{type} == 3) { # FT_MUSIC 879 if ($face->{type} == 3) { # FT_MUSIC
890 ::message ({ markup => "downloaded song #$facenum" })
891 if $changed;
892
893 &::audio_music_push ($facenum); 880 &::audio_music_push ($facenum);
894 } elsif ($face->{type} == 5) { # FT_SOUND 881 } elsif ($face->{type} == 5) { # FT_SOUND
895 ::message ({ markup => "downloaded sound #$facenum" })
896 if $changed;
897
898 &::audio_sound_push ($facenum); 882 &::audio_sound_push ($facenum);
899 } 883 }
900 884
901 } else { 885 } else {
902 # flat resource case, FT_RSRC 886 # flat resource case, FT_RSRC
903 CFPlus::DB::put res_data => $face->{name} => $face->{data}, sub { } 887 DC::DB::put res_data => $face->{name} => $face->{data}, sub { }
904 if $changed; 888 if $changed;
905 } 889 }
906 890
907 if (my $cbs = $self->{face_cb}{$facenum}) { 891 if (my $cbs = $self->{face_cb}{$facenum}) {
908 $_->($face, $changed) for @$cbs; 892 $_->($face, $changed) for @$cbs;
919 my ($self, $tile, $data) = @_; 903 my ($self, $tile, $data) = @_;
920 904
921 return unless $self->{map}; 905 return unless $self->{map};
922 906
923 my $tex = $self->{texture}[$tile] ||= 907 my $tex = $self->{texture}[$tile] ||=
924 new CFPlus::Texture 908 new DC::Texture
925 tile => $tile, 909 tile => $tile,
926 image => $data, delete_image => 1, 910 image => $data, delete_image => 1,
927 minify => 1, mipmap => 1; 911 minify => 1, mipmap => 1;
928 912
929 if (my $cbs = delete $self->{tile_cb}{$tile}) { 913 if (my $cbs = delete $self->{tile_cb}{$tile}) {
937 my ($self, $num, $cb) = @_; 921 my ($self, $num, $cb) = @_;
938 922
939 push @{$self->{face_cb}{$num}}, $cb; 923 push @{$self->{face_cb}{$num}}, $cb;
940 924
941 defined wantarray 925 defined wantarray
942 ? CFPlus::guard { 926 ? DC::guard {
943 @{$self->{face_cb}{$num}} 927 @{$self->{face_cb}{$num}}
944 = grep $_ != $cb, 928 = grep $_ != $cb,
945 @{$self->{face_cb}{$num}}; 929 @{$self->{face_cb}{$num}};
946 } 930 }
947 : () 931 : ()
982 966
983sub sanitise_xml($) { 967sub sanitise_xml($) {
984 local $_ = shift; 968 local $_ = shift;
985 969
986 # we now weed out all tags we do not support 970 # we now weed out all tags we do not support
987 s%<(?!/?i>|/?u>|/?b>|fg |/fg>)%&lt;%g; 971 s{ <(?! /?i> | /?u> | /?b> | /?big | /?small | /?s | /?tt | fg\ | /fg>)
972 }{
973 "&lt;"
974 }gex;
975
988 # now all entities 976 # now all entities
989 s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&amp;/g; 977 s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&amp;/g;
990 978
991 # handle some elements 979 # handle some elements
992 s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; 980 s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs;
1045 1033
1046 ## try to create single paragraphs of multiple lines sent by the server 1034 ## try to create single paragraphs of multiple lines sent by the server
1047 # no longer neecssary with TRT servers 1035 # no longer neecssary with TRT servers
1048 #$text =~ s/(?<=\S)\n(?=\w)/ /g; 1036 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
1049 1037
1038 for (split /\n/, $text) {
1050 ::message ({ 1039 ::message ({
1051 fg => $fg, 1040 fg => $fg,
1052 markup => $_, 1041 markup => $_,
1053 type => $type, 1042 type => $type,
1054 extra => [@extra], 1043 extra => [@extra],
1055 color_flags => $color 1044 color_flags => $color, #d# ugly, kill
1056 }) for split /\n/, $text; 1045 });
1046
1047 $color &= ~NDI_CLEAR; # only clear once for multiline messages
1048 # actually, this is an ugly design. _we_ should control the channels,
1049 # not some random other widget, as the channels are clearly protocol-specific.
1050 # then we could also react to flags such as CLEAR without resorting to
1051 # hacks such as color_flags, above.
1052 }
1057 1053
1058 $self->{statusbox}->add ($text, 1054 $self->{statusbox}->add ($text,
1059 group => $text, 1055 group => $text,
1060 fg => $fg, 1056 fg => $fg,
1061 timeout => $color >= 2 ? 180 : 10, 1057 timeout => $color >= 2 ? 180 : 10,
1062 tooltip_font => $::FONT_FIXED, 1058 tooltip_font => $::FONT_FIXED,
1063 ); 1059 ) if $type eq "info";
1064 } 1060 }
1065} 1061}
1066 1062
1067sub spell_add { 1063sub spell_add {
1068 my ($self, $spell) = @_; 1064 my ($self, $spell) = @_;
1072 $spell->{message} =~ s/\n+$//; 1068 $spell->{message} =~ s/\n+$//;
1073 $spell->{message} ||= "Server did not provide a description for this spell."; 1069 $spell->{message} ||= "Server did not provide a description for this spell.";
1074 1070
1075 $::SPELL_LIST->add_spell ($spell); 1071 $::SPELL_LIST->add_spell ($spell);
1076 1072
1077 $self->{map_widget}->add_command ("invoke $spell->{name}", CFPlus::asxml $spell->{message}); 1073 $self->{map_widget}->add_command ("invoke $spell->{name}", DC::asxml $spell->{message});
1078 $self->{map_widget}->add_command ("cast $spell->{name}", CFPlus::asxml $spell->{message}); 1074 $self->{map_widget}->add_command ("cast $spell->{name}", DC::asxml $spell->{message});
1079} 1075}
1080 1076
1081sub spell_delete { 1077sub spell_delete {
1082 my ($self, $spell) = @_; 1078 my ($self, $spell) = @_;
1083 1079
1094sub addme_success { 1090sub addme_success {
1095 my ($self) = @_; 1091 my ($self) = @_;
1096 1092
1097 my %skill_help; 1093 my %skill_help;
1098 1094
1099 for my $node (CFPlus::Pod::find skill_description => "*") { 1095 for my $node (DC::Pod::find skill_description => "*") {
1100 my (undef, @par) = CFPlus::Pod::section_of $node; 1096 my (undef, @par) = DC::Pod::section_of $node;
1101 $skill_help{$node->{kw}[0]} = CFPlus::Pod::as_label @par; 1097 $skill_help{$node->{kw}[0]} = DC::Pod::as_label @par;
1102 }; 1098 };
1103 1099
1104 for my $skill (values %{$self->{skill_info}}) { 1100 for my $skill (values %{$self->{skill_info}}) {
1105 $self->{map_widget}->add_command ("ready_skill $skill", 1101 $self->{map_widget}->add_command ("ready_skill $skill",
1106 (CFPlus::asxml "Ready the skill '$skill'\n\n") 1102 (DC::asxml "Ready the skill '$skill'\n\n")
1107 . $skill_help{$skill}); 1103 . $skill_help{$skill});
1108 $self->{map_widget}->add_command ("use_skill $skill", 1104 $self->{map_widget}->add_command ("use_skill $skill",
1109 (CFPlus::asxml "Immediately use the skill '$skill'\n\n") 1105 (DC::asxml "Immediately use the skill '$skill'\n\n")
1110 . $skill_help{$skill}); 1106 . $skill_help{$skill});
1111 } 1107 }
1112} 1108}
1113 1109
1114sub eof { 1110sub eof {
1118 1114
1119 ::stop_game (); 1115 ::stop_game ();
1120} 1116}
1121 1117
1122sub update_floorbox { 1118sub update_floorbox {
1123 $CFPlus::UI::ROOT->on_refresh ($::FLOORBOX => sub { 1119 $DC::UI::ROOT->on_refresh ($::FLOORBOX => sub {
1124 return unless $::CONN; 1120 return unless $::CONN;
1125 1121
1126 $::FLOORBOX->clear; 1122 $::FLOORBOX->clear;
1127 1123
1128 my @add; 1124 my @add;
1130 my $row; 1126 my $row;
1131 for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { 1127 for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) {
1132 if ($row < 6) { 1128 if ($row < 6) {
1133 local $_->{face_widget}; # hack to force recreation of widget 1129 local $_->{face_widget}; # hack to force recreation of widget
1134 local $_->{desc_widget}; # hack to force recreation of widget 1130 local $_->{desc_widget}; # hack to force recreation of widget
1135 CFPlus::Item::update_widgets $_; 1131 DC::Item::update_widgets $_;
1136 1132
1137 push @add, 1133 push @add,
1138 0, $row, $_->{face_widget}, 1134 0, $row, $_->{face_widget},
1139 1, $row, $_->{desc_widget}; 1135 1, $row, $_->{desc_widget};
1140 1136
1141 $row++; 1137 $row++;
1142 } else { 1138 } else {
1143 push @add, 1, $row, new CFPlus::UI::Button 1139 push @add, 1, $row, new DC::UI::Button
1144 text => "More...", 1140 text => "More...",
1145 on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 }, 1141 on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 },
1146 ; 1142 ;
1147 last; 1143 last;
1148 } 1144 }
1149 } 1145 }
1150 if ($::CONN->{open_container}) { 1146 if ($::CONN->{open_container}) {
1151 push @add, 1, $row++, new CFPlus::UI::Button 1147 push @add, 1, $row++, new DC::UI::Button
1152 text => "Close container", 1148 text => "Close container",
1153 on_activate => sub { $::CONN->send ("apply $::CONN->{open_container}") } 1149 on_activate => sub { $::CONN->send ("apply $::CONN->{open_container}") }
1154 ; 1150 ;
1155 } 1151 }
1156 1152
1157 $::FLOORBOX->add_at (@add); 1153 $::FLOORBOX->add_at (@add);
1158 }); 1154 });
1159 1155
1160 $::WANT_REFRESH->start; 1156 $::WANT_REFRESH = 1;
1161} 1157}
1162 1158
1163sub set_opencont { 1159sub set_opencont {
1164 my ($conn, $tag, $name) = @_; 1160 my ($conn, $tag, $name) = @_;
1165 $conn->{open_container} = $tag; 1161 $conn->{open_container} = $tag;
1166 update_floorbox; 1162 update_floorbox;
1167 1163
1168 $::INVR_HB->clear (); 1164 $::INVR_HB->clear ();
1169 $::INVR_HB->add (new CFPlus::UI::Label align => 0, expand => 1, text => $name); 1165 $::INVR_HB->add (new DC::UI::Label align => 0, expand => 1, text => $name);
1170 1166
1171 if ($tag != 0) { # Floor isn't closable, is it? 1167 if ($tag != 0) { # Floor isn't closable, is it?
1172 $::INVR_HB->add (new CFPlus::UI::Button 1168 $::INVR_HB->add (new DC::UI::Button
1173 text => "Close container", 1169 text => "Close container",
1174 tooltip => "Close the currently open container (if one is open)", 1170 tooltip => "Close the currently open container (if one is open)",
1175 on_activate => sub { 1171 on_activate => sub {
1176 $::CONN->send ("apply $tag") # $::CONN->{open_container}") 1172 $::CONN->send ("apply $tag") # $::CONN->{open_container}")
1177 if $tag != 0; 1173 if $tag != 0;
1184} 1180}
1185 1181
1186sub update_containers { 1182sub update_containers {
1187 my ($self) = @_; 1183 my ($self) = @_;
1188 1184
1189 $CFPlus::UI::ROOT->on_refresh ("update_containers_$self" => sub { 1185 $DC::UI::ROOT->on_refresh ("update_containers_$self" => sub {
1190 my $todo = delete $self->{update_container} 1186 my $todo = delete $self->{update_container}
1191 or return; 1187 or return;
1192 1188
1193 for my $tag (keys %$todo) { 1189 for my $tag (keys %$todo) {
1194 update_floorbox if $tag == 0 or $tag == $self->{open_container}; 1190 update_floorbox if $tag == 0 or $tag == $self->{open_container};
1231sub item_update { 1227sub item_update {
1232 my ($self, $item) = @_; 1228 my ($self, $item) = @_;
1233 1229
1234 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; 1230 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n";
1235 1231
1236 CFPlus::Item::update_widgets $item; 1232 DC::Item::update_widgets $item;
1237 1233
1238 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { 1234 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) {
1239 set_opencont ($::CONN, 0, "Floor"); 1235 set_opencont ($::CONN, 0, "Floor");
1240 1236
1241 } elsif ($item->{flags} & F_OPEN) { 1237 } elsif ($item->{flags} & F_OPEN) {
1242 set_opencont ($::CONN, $item->{tag}, CFPlus::Item::desc_string $item); 1238 set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item);
1243 1239
1244 } else { 1240 } else {
1245 $self->{update_container}{$item->{container}}++; 1241 $self->{update_container}{$item->{container}}++;
1246 $self->update_containers; 1242 $self->update_containers;
1247 } 1243 }
1306 0 1302 0
1307 }); 1303 });
1308 1304
1309 $self->update_server_info; 1305 $self->update_server_info;
1310 1306
1311 $self->send_command ("output-sync $::CFG->{output_sync}");
1312 $self->send_command ("output-count $::CFG->{output_count}");
1313 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; 1307 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0;
1314 $self->send_command ("pickup $::CFG->{pickup}"); 1308 $self->send_command ("pickup $::CFG->{pickup}");
1315} 1309}
1316 1310
1317sub lookat { 1311sub lookat {
1321 $self->send_ext_req (lookat => $x, $y, sub { 1315 $self->send_ext_req (lookat => $x, $y, sub {
1322 my (%msg) = @_; 1316 my (%msg) = @_;
1323 1317
1324 if (exists $msg{npc_dialog}) { 1318 if (exists $msg{npc_dialog}) {
1325 # start npc chat dialog 1319 # start npc chat dialog
1326 $self->{npc_dialog} = new CFPlus::NPCDialog:: 1320 $self->{npc_dialog} = new DC::NPCDialog::
1327 token => $msg{npc_dialog}, 1321 token => $msg{npc_dialog},
1328 title => "$msg{npc_dialog}[0] (NPC)", 1322 title => "$msg{npc_dialog}[0] (NPC)",
1329 conn => $self, 1323 conn => $self,
1330 ; 1324 ;
1331 } 1325 }
1344 $self->SUPER::destroy; 1338 $self->SUPER::destroy;
1345 1339
1346 %$self = (); 1340 %$self = ();
1347} 1341}
1348 1342
1349package CFPlus::NPCDialog; 1343package DC::NPCDialog;
1350 1344
1351our @ISA = 'CFPlus::UI::Toplevel'; 1345our @ISA = 'DC::UI::Toplevel';
1352 1346
1353sub new { 1347sub new {
1354 my $class = shift; 1348 my $class = shift;
1355 1349
1356 my $self = $class->SUPER::new ( 1350 my $self = $class->SUPER::new (
1363 kw => { hi => 0, yes => 0, no => 0 }, 1357 kw => { hi => 0, yes => 0, no => 0 },
1364 has_close_button => 1, 1358 has_close_button => 1,
1365 @_, 1359 @_,
1366 ); 1360 );
1367 1361
1368 CFPlus::weaken (my $this = $self); 1362 DC::weaken (my $this = $self);
1369 1363
1370 $self->connect (delete => sub { $this->destroy; 1 }); 1364 $self->connect (delete => sub { $this->destroy; 1 });
1371 1365
1372 # better use a pane... 1366 # better use a pane...
1373 $self->add (my $hbox = new CFPlus::UI::HBox); 1367 $self->add (my $hbox = new DC::UI::HBox);
1374 $hbox->add ($self->{textview} = new CFPlus::UI::TextScroller expand => 1); 1368 $hbox->add ($self->{textview} = new DC::UI::TextScroller expand => 1);
1375 1369
1376 $hbox->add (my $vbox = new CFPlus::UI::VBox); 1370 $hbox->add (my $vbox = new DC::UI::VBox);
1377 1371
1378 $vbox->add (new CFPlus::UI::Label text => "Message Entry:"); 1372 $vbox->add (new DC::UI::Label text => "Message Entry:");
1379 $vbox->add ($self->{entry} = new CFPlus::UI::Entry 1373 $vbox->add ($self->{entry} = new DC::UI::Entry
1380 tooltip => "#npc_message_entry", 1374 tooltip => "#npc_message_entry",
1381 on_activate => sub { 1375 on_activate => sub {
1382 my ($entry, $text) = @_; 1376 my ($entry, $text) = @_;
1383 1377
1384 return unless $text =~ /\S/; 1378 return unless $text =~ /\S/;
1388 1382
1389 0 1383 0
1390 }, 1384 },
1391 ); 1385 );
1392 1386
1393 $vbox->add ($self->{options} = new CFPlus::UI::VBox); 1387 $vbox->add ($self->{options} = new DC::UI::VBox);
1394 1388
1395 $self->{bye_button} = new CFPlus::UI::Button 1389 $self->{bye_button} = new DC::UI::Button
1396 text => "Bye (close)", 1390 text => "Bye (close)",
1397 tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.", 1391 tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.",
1398 on_activate => sub { $this->destroy; 1 }, 1392 on_activate => sub { $this->destroy; 1 },
1399 ; 1393 ;
1400 1394
1419}; 1413};
1420 1414
1421sub update_options { 1415sub update_options {
1422 my ($self) = @_; 1416 my ($self) = @_;
1423 1417
1424 CFPlus::weaken $self; 1418 DC::weaken $self;
1425 1419
1426 $self->{options}->clear; 1420 $self->{options}->clear;
1427 $self->{options}->add ($self->{bye_button}); 1421 $self->{options}->add ($self->{bye_button});
1428 1422
1429 for my $kw (sort keys %{ $self->{kw} }) { 1423 for my $kw (sort keys %{ $self->{kw} }) {
1430 $self->{options}->add (new CFPlus::UI::Button 1424 $self->{options}->add (new DC::UI::Button
1431 text => $kw, 1425 text => $kw,
1432 on_activate => sub { 1426 on_activate => sub {
1433 $self->send ($kw); 1427 $self->send ($kw);
1434 0 1428 0
1435 }, 1429 },
1438} 1432}
1439 1433
1440sub feed { 1434sub feed {
1441 my ($self, $type, @arg) = @_; 1435 my ($self, $type, @arg) = @_;
1442 1436
1443 CFPlus::weaken $self; 1437 DC::weaken $self;
1444 1438
1445 if ($type eq "update") { 1439 if ($type eq "update") {
1446 my (%info) = @arg; 1440 my (%info) = @arg;
1447 1441
1448 $self->{kw}{$_} = 1 for @{$info{add_topics} || []}; 1442 $self->{kw}{$_} = 1 for @{$info{add_topics} || []};
1449 $self->{kw}{$_} = 0 for @{$info{del_topics} || []}; 1443 $self->{kw}{$_} = 0 for @{$info{del_topics} || []};
1450 1444
1451 if (exists $info{msg}) { 1445 if (exists $info{msg}) {
1452 my $text = "\n" . CFPlus::Protocol::sanitise_xml $info{msg}; 1446 my $text = "\n" . DC::Protocol::sanitise_xml $info{msg};
1453 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; 1447 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} };
1454 my @link; 1448 my @link;
1455 $text =~ s{ 1449 $text =~ s{
1456 ($match) 1450 ($match)
1457 }{ 1451 }{
1458 my $kw = $1; 1452 my $kw = $1;
1459 1453
1460 push @link, new CFPlus::UI::Label 1454 push @link, new DC::UI::Label
1461 markup => "<span foreground='#c0c0ff' underline='single'>$kw</span>", 1455 markup => "<span foreground='#c0c0ff' underline='single'>$kw</span>",
1462 can_hover => 1, 1456 can_hover => 1,
1463 can_events => 1, 1457 can_events => 1,
1464 padding_x => 0, 1458 padding_x => 0,
1465 padding_y => 0, 1459 padding_y => 0,
1483} 1477}
1484 1478
1485sub send { 1479sub send {
1486 my ($self, $msg) = @_; 1480 my ($self, $msg) = @_;
1487 1481
1488 $self->{textview}->add_paragraph ({ markup => "\n" . CFPlus::asxml $msg }); 1482 $self->{textview}->add_paragraph ({ markup => "\n" . DC::asxml $msg });
1489 $self->{textview}->scroll_to_bottom; 1483 $self->{textview}->scroll_to_bottom;
1490 1484
1491 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); 1485 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg);
1492} 1486}
1493 1487

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines