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.183 by root, Wed Dec 26 21:03:21 2007 UTC vs.
Revision 1.206 by elmex, Sun Dec 7 16:20:44 2008 UTC

12use DC::Macro; 12use DC::Macro;
13use DC::Item; 13use DC::Item;
14 14
15use base 'Deliantra::Protocol::Base'; 15use base 'Deliantra::Protocol::Base';
16 16
17our $TEX_DIALOGUE = new_from_resource DC::Texture
18 "dialogue.png", minify => 1, mipmap => 1;
19
20our $TEX_NOFACE = new_from_resource DC::Texture
21 "noface.png", minify => 1, mipmap => 1;
22
23sub MIN_TEXTURE_UNUSED() { 1 }#d#
24
17sub new { 25sub new {
18 my ($class, %arg) = @_; 26 my ($class, %arg) = @_;
19 27
20 my $self = $class->SUPER::new (%arg, 28 my $self = $class->SUPER::new (%arg,
21 setup_req => { 29 setup_req => {
22 extmap => 1, 30 extmap => 1,
23 excmd => 1, 31 excmd => 1,
24 widget => 1, 32 widget => 2,
25 %{$arg{setup_req} || {}}, 33 %{$arg{setup_req} || {}},
26 }, 34 },
27 ); 35 );
28 36
29 $self->{map_widget}->clr_commands; 37 $self->{map_widget}->clr_commands;
30 38
31 my @cmd_help = map { 39 my @cmd_help = map {
32 $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x 40 $_->[DC::Pod::N_KW][0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
33 or die "unparseable command help: $_->{kw}[0]"; 41 or die "unparseable command help: $_->[DC::Pod::N_KW][0]";
34 42
35 my $cmd = $1; 43 my $cmd = $1;
36 my @args = split /\|/, $2; 44 my @args = split /\|/, $2;
37 @args = (".*") unless @args; 45 @args = (".*") unless @args;
38 46
43 for @args; 51 for @args;
44 52
45 map ["$cmd$_", $text], 53 map ["$cmd$_", $text],
46 sort { (length $a) <=> (length $b) } 54 sort { (length $a) <=> (length $b) }
47 @args 55 @args
48 } sort { $a->{par} <=> $b->{par} } 56 } sort { $a->[DC::Pod::N_PAR] <=> $b->[DC::Pod::N_PAR] }
49 DC::Pod::find command => "*"; 57 DC::Pod::find command => "*";
50 58
51 $self->{json_coder} 59 $self->{json_coder}
52 ->convert_blessed 60 ->convert_blessed
53 ->filter_json_single_key_object ("\fw" => sub { 61 ->filter_json_single_key_object ("\fw" => sub {
64 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { 72 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub {
65 for my $ws (values %{delete $self->{widgetset} || {}}) { 73 for my $ws (values %{delete $self->{widgetset} || {}}) {
66 $_->destroy 74 $_->destroy
67 for values %{delete $ws->{w} || {}}; 75 for values %{delete $ws->{w} || {}};
68 } 76 }
77
78 delete $self->{items};
79 $::INV->clear;
80 $::INVR->clear;
81 $::INVR_HB->clear;
82 $::FLOORBOX->clear;
69 }); 83 });
70 84
71 $self->{map_widget}->add_command (@$_) 85 $self->{map_widget}->add_command (@$_)
72 for @cmd_help; 86 for @cmd_help;
73 87
74 { 88 {
75 $self->{dialogue} = my $tex = new_from_file DC::Texture 89 $self->{dialogue} = my $tex = $TEX_DIALOGUE;
76 DC::find_rcfile "dialogue.png", minify => 1, mipmap => 1;
77 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 90 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}});
78 } 91 }
79 92
80 { 93 {
81 $self->{noface} = my $tex = new_from_file DC::Texture 94 $self->{noface} = my $tex = $TEX_NOFACE;
82 DC::find_rcfile "noface.png", minify => 1, mipmap => 1;
83 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 95 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}});
84 } 96 }
97
98# $self->{expire_count} = DC::DB::FIRST_TILE_ID; # minimum non-fixed tile id
99# $self->{expire_w} = EV::timer 1, 1, sub {
100# my $count = (int @{ $self->{texture} } / MIN_TEXTURE_UNUSED) || 1;
101#
102# for ($self->{map}->expire_textures ($self->{expire_count}, $count)) {
103# warn DC::SvREFCNT $self->{texture}[$_];
104# $self->{texture}[$_]->unload;
105# warn "expire texture $_\n";#d#
106# }
107#
108# ($self->{expire_count} += $count) < @{ $self->{texture} }
109# or $self->{expire_count} = DC::DB::FIRST_TILE_ID;
110# warn "count is $count\n";#d#
111# };
85 112
86 $self->{open_container} = 0; 113 $self->{open_container} = 0;
87 114
88 # per server 115 # per server
89 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; 116 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}";
102} 129}
103 130
104sub ext_capabilities { 131sub ext_capabilities {
105 my ($self, %cap) = @_; 132 my ($self, %cap) = @_;
106 133
107 #$self->send ("setup sound 0"); # we use a different protocol
108 $self->update_fx_want; 134 $self->update_fx_want;
109 135
110 $self->send_exti_req (resource => "exp_table", sub { 136 $self->send_exti_req (resource => "exp_table", sub {
111 my ($exp_table) = @_; 137 my ($exp_table) = @_;
112 138
191 $ws, $id => scalar eval { 217 $ws, $id => scalar eval {
192 local $SIG{__DIE__}; 218 local $SIG{__DIE__};
193 "DC::UI::$class"->new (%$args) 219 "DC::UI::$class"->new (%$args)
194 } 220 }
195 ); 221 );
222}
223
224# widgetset create template
225sub ext_ws_ct {
226 my ($self, $ws, $type, $template, $done_cb, $cfg) = @_;
227
228 $done_cb ||= sub { };
229
230 my $parse_list; $parse_list = sub {
231 my ($list) = @_;
232 my @w;
233
234 while (@$list) {
235 my ($class, $args) = splice @$list, 0, 2;
236 my $name = delete $args->{s_id};
237 my $cl = delete $args->{s_cl};
238 my $cfg = delete $cfg->{$name};
239 my $id = delete $cfg->{id};
240 my $w = eval { "DC::UI::$class"->new (%$args, %{ $cfg || {} }) }
241 or next;
242
243 $self->widget_associate ($ws, $id, $w)
244 if $id;
245
246 $w->add ($parse_list->($cl))
247 if $cl;
248
249 push @w, $w;
250 }
251
252 @w
253 };
254
255 # either array reference, or face #
256 if ($type eq "inline") {
257 $done_cb->();
258 $parse_list->($template);
259 } elsif ($type eq "face") {
260 my $handler; $handler = $self->register_face_handler ($template, sub {
261 my ($face) = @_;
262
263 undef $handler;
264 $done_cb->();
265 $parse_list->($self->{json_coder}->decode ($face->{data}));
266 });
267 } else {
268 $done_cb->(0);
269 }
196} 270}
197 271
198# widgetset associate 272# widgetset associate
199sub ext_ws_a { 273sub ext_ws_a {
200 my ($self, %ass) = @_; 274 my ($self, %ass) = @_;
228 spell_list => $::SPELL_LIST, 302 spell_list => $::SPELL_LIST,
229 303
230 floorbox => $::FLOORBOX, 304 floorbox => $::FLOORBOX,
231 help_window => $::HELP_WINDOW, 305 help_window => $::HELP_WINDOW,
232 message_window => $::MESSAGE_WINDOW, 306 message_window => $::MESSAGE_WINDOW,
307 message_dist => $::MESSAGE_DIST,
233 statusbox => $::SDTATUSBOX, 308 statusbox => $::SDTATUSBOX,
234 309
235 inv => $::INV, 310 inv => $::INV,
236 invr => $::INVR, 311 invr => $::INVR,
237 invr_hb => $::INVR_HB, 312 invr_hb => $::INVR_HB,
286 361
287# message window 362# message window
288sub ext_channel_info { 363sub ext_channel_info {
289 my ($self, $info) = @_; 364 my ($self, $info) = @_;
290 $self->{channels}->{$info->{id}} = $info; 365 $self->{channels}->{$info->{id}} = $info;
291 $::MESSAGE_WINDOW->add_channel ($info); 366 $::MESSAGE_DIST->add_channel ($info);
292} 367}
293 368
294############################################################################# 369#############################################################################
295 370
296sub logprint { 371sub logprint {
478 $sktbl->clear; 553 $sktbl->clear;
479 554
480 my $sw = $self->{skillwid}{""} ||= [ 555 my $sw = $self->{skillwid}{""} ||= [
481 0, 0, (new DC::UI::Label text => "Experience", align => 1), 556 0, 0, (new DC::UI::Label text => "Experience", align => 1),
482 1, 0, (new DC::UI::Label text => "Lvl.", align => 1), 557 1, 0, (new DC::UI::Label text => "Lvl.", align => 1),
483 2, 0, (new DC::UI::Label text => "Progress", align => 0), 558 2, 0, (new DC::UI::Label text => "Progress"),
484 3, 0, (new DC::UI::Label text => "Skill", expand => 1), 559 3, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0),
485 4, 0, (new DC::UI::Label text => "Experience", align => 1), 560 4, 0, (new DC::UI::Label text => "Experience", align => 1),
486 5, 0, (new DC::UI::Label text => "Lvl.", align => 1), 561 5, 0, (new DC::UI::Label text => "Lvl.", align => 1),
487 6, 0, (new DC::UI::Label text => "Progress", align => 0), 562 6, 0, (new DC::UI::Label text => "Progress"),
488 7, 0, (new DC::UI::Label text => "Skill", expand => 1), 563 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0),
489 ]; 564 ];
490 565
491 my @add = @$sw; 566 my @add = @$sw;
492 567
493 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; 568 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use skill\nRight click - further options</small>";
494 569
495 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 570 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the 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); 571 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
497 572
498 my ($x, $y) = (0, 1); 573 my ($x, $y) = (0, 1);
532 607
533 # progress 608 # progress
534 (new DC::UI::ExperienceProgress), 609 (new DC::UI::ExperienceProgress),
535 610
536 # label 611 # label
537 (new DC::UI::Label text => $name, on_button_down => $spell_cb, 612 (new DC::UI::Label text => $name, on_button_down => $spell_cb, align => 0,
538 can_events => 1, can_hover => 1, tooltip => (DC::Pod::section_label skill_description => $name) . $TOOLTIP_ALL), 613 can_events => 1, can_hover => 1, tooltip => (DC::Pod::section_label skill_description => $name) . $TOOLTIP_ALL),
539 ]; 614 ];
540 615
541 push @add, 616 push @add,
542 $x * 4 + 0, $y, $sw->[0], 617 $x * 4 + 0, $y, $sw->[0],
584} 659}
585 660
586sub map_scroll { 661sub map_scroll {
587 my ($self, $dx, $dy) = @_; 662 my ($self, $dx, $dy) = @_;
588 663
589 $self->{map}->scroll ($dx, $dy); 664 $self->{map_widget}->scroll ($dx, $dy);
590} 665}
591 666
592sub feed_map1a { 667sub feed_map1a {
593 my ($self, $data) = @_; 668 my ($self, $data) = @_;
594 669
598 for my $tile (@$missing) { 673 for my $tile (@$missing) {
599 next if $self->{delay}{$tile}; 674 next if $self->{delay}{$tile};
600 675
601 $delay = 1; 676 $delay = 1;
602 677
603 if (my $tex = $::CONN->{texture}[$tile]) { 678 if (my $tex = $self->{texture}[$tile]) {
604 $tex->upload; 679 $tex->upload;
605 } else { 680 } else {
606 $self->{delay}{$tile} = 1; 681 $self->{delay}{$tile} = 1;
607 682
608 # we assume the face is in-flight and will eventually come 683 # we assume the face is in-flight and will eventually arrive
609 push @{$self->{tile_cb}{$tile}}, sub { 684 push @{$self->{tile_cb}{$tile}}, sub {
610 delete $self->{delay}{$tile}; 685 delete $self->{delay}{$tile};
611 $_[0]->upload; 686 $_[0]->upload;
612 }; 687 };
613 } 688 }
614 } 689 }
615 690
616 if ($delay) { 691 if ($delay) {
617 # delay the map drawing a tiny bit in the hope of getting the missing fetched 692 # delay the map drawing a tiny bit in the hope of getting the missing tiles fetched
618 EV::once undef, 0, 0.03, sub { 693 EV::once undef, 0, 0.03, sub {
619 $self->{map_widget}->update 694 $self->{map_widget}->update
620 if $self->{map_widget}; 695 if $self->{map_widget};
621 }; 696 };
622 } else { 697 } else {
631} 706}
632 707
633sub flush_map { 708sub flush_map {
634 my ($self) = @_; 709 my ($self) = @_;
635 710
636 my $map_info = delete $self->{map_info} 711 return unless $self->{map_info};
637 or return;
638 712
713 for my $map_info (values %{ $self->{map_cache} || {} }) {
639 my ($hash, $x, $y, $w, $h) = @$map_info; 714 my ($hash, $rdata, $x, $y, $w, $h) = @$map_info;
640 715
641 my $data = Compress::LZF::compress $self->{map}->get_rect ($x, $y, $w, $h); 716 my $data = $self->{map}->get_rect ($x, $y, $w, $h);
642 $self->{map_cache_new}{$hash} = \$data; 717
718 if ($data ne $$rdata) {
719 $map_info->[1] = \$data;
720 my $cdata = Compress::LZF::compress $data;
643 DC::DB::put $self->{mapcache} => $hash => $data, sub { }; 721 DC::DB::put $self->{mapcache} => $hash => $cdata, sub { };
722 }
723 }
644} 724}
645 725
646sub map_clear { 726sub map_clear {
647 my ($self) = @_; 727 my ($self) = @_;
648 728
649 $self->flush_map; 729 $self->flush_map;
730 delete $self->{map_info};
650 delete $self->{neigh_map}; 731 delete $self->{neigh_map};
651 732
652 $self->{map}->clear; 733 $self->{map}->clear;
653 delete $self->{map_widget}{magicmap}; 734 delete $self->{map_widget}{magicmap};
654} 735}
675 756
676 $self->bg_fetch; 757 $self->bg_fetch;
677 }; 758 };
678} 759}
679 760
680sub load_map($$$) { 761sub load_map($$$$$$) {
681 my ($self, $hash, $x, $y) = @_; 762 my ($self, $hash, $x, $y, $w, $h) = @_;
682 763
683 my $gen = $self->{map_change_gen}; 764 my $map_info = $self->{map_cache}{$hash} = [$hash, \"", $x, $y, $w, $h];
684 765
685 my $cb = sub { 766 my $cb = sub {
686 return unless $gen == $self->{map_change_gen}; 767 $map_info->[1] = \$_[0];
687 768
688 my ($data) = @_;
689
690 if (defined $data) {
691 $self->{map_cache_new}{$hash} = \$data;
692
693 my $data = Compress::LZF::decompress $data;
694
695 my $inprogress = @{ $self->{bg_fetch} || [] }; 769 my $inprogress = @{ $self->{bg_fetch} || [] };
696 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); 770 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $_[0]);
697 $self->bg_fetch unless $inprogress; 771 $self->bg_fetch unless $inprogress;
698 }
699 }; 772 };
700 773
701 if (my $rdata = $self->{map_cache_old}{$hash}) { 774 if (my $map_info = $self->{map_cache_old}{$hash}) {
702 $cb->($$rdata); 775 $cb->(${ $map_info->[1] });
703 } else { 776 } else {
777 my $gen = $self->{map_change_gen};
778
704 DC::DB::get $self->{mapcache} => $hash, $cb; 779 DC::DB::get $self->{mapcache} => $hash, sub {
780 return unless $gen == $self->{map_change_gen};
781 return unless defined $_[0];
782 $cb->(Compress::LZF::decompress $_[0]);
783 };
705 } 784 }
706} 785}
707 786
708# hardcode /world/world_xxx_xxx map names, the savings are enourmous, 787# hardcode /world/world_xxx_xxx map names, the savings are enourmous,
709# (server resource,s latency, bandwidth), so this hack is warranted. 788# (server resources, latency, bandwidth), so this hack is warranted.
710# the right fix is to make real tiled maps with an overview file 789# the right fix is to make real tiled maps with an overview file
711sub send_mapinfo { 790sub send_mapinfo {
712 my ($self, $data, $cb) = @_; 791 my ($self, $data, $cb) = @_;
713 792
714 if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) { 793 if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) {
739} 818}
740 819
741# this method does a "flood fill" into every tile direction 820# this method does a "flood fill" into every tile direction
742# it assumes that tiles are arranged in a rectangular grid, 821# it assumes that tiles are arranged in a rectangular grid,
743# i.e. a map is the same as the left of the right map etc. 822# i.e. a map is the same as the left of the right map etc.
744# failure to comply are harmless and result in display errors 823# failure to comply is harmless and results in display errors
745# at worst. 824# at worst.
746sub flood_fill { 825sub flood_fill {
747 my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; 826 my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_;
748 827
749 # the server does not allow map paths > 6 828 # the server does not allow map paths > 6
785 return if $mode ne "spatial"; 864 return if $mode ne "spatial";
786 865
787 $x += $self->{map}->ox; 866 $x += $self->{map}->ox;
788 $y += $self->{map}->oy; 867 $y += $self->{map}->oy;
789 868
790 $self->load_map ($hash, $x, $y) 869 $self->load_map ($hash, $x, $y, $w, $h)
791 unless $self->{neigh_map}{$hash}[5]++;#d# 870 unless $self->{neigh_map}{$hash}[5]++;#d#
792 871
793 $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; 872 $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash];
794 873
795 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) 874 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags)
803 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 882 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
804 883
805 $self->flush_map; 884 $self->flush_map;
806 885
807 ++$self->{map_change_gen}; 886 ++$self->{map_change_gen};
808 $self->{map_cache_old} = delete $self->{map_cache_new}; 887 $self->{map_cache_old} = delete $self->{map_cache};
809 888
810 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 889 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
811 890
812 my $mapmapw = $self->{mapmap}->{w}; 891 my $mapmapw = $self->{mapmap}->{w};
813 my $mapmaph = $self->{mapmap}->{h}; 892 my $mapmaph = $self->{mapmap}->{h};
825 $self->{map_info} = [$hash, $x, $y, $w, $h]; 904 $self->{map_info} = [$hash, $x, $y, $w, $h];
826 905
827 (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; 906 (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/;
828 $::STATWIDS->{map}->set_text ("Map: " . $map); 907 $::STATWIDS->{map}->set_text ("Map: " . $map);
829 908
830 $self->load_map ($hash, $x, $y); 909 $self->load_map ($hash, $x, $y, $w, $h);
831 $self->flood_fill (0, 0, 0, "", $hash, $flags); 910 $self->flood_fill (0, 0, 0, "", $hash, $flags);
832} 911}
833 912
834sub face_find { 913sub face_find {
835 my ($self, $facenum, $face, $cb) = @_; 914 my ($self, $facenum, $face, $cb) = @_;
977 s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&amp;/g; 1056 s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&amp;/g;
978 1057
979 # handle some elements 1058 # handle some elements
980 s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; 1059 s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs;
981 s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; 1060 s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs;
1061
1062 s/\s+$//;
982 1063
983 $_ 1064 $_
984} 1065}
985 1066
986our %NAME_TO_COLOR = ( 1067our %NAME_TO_COLOR = (
1033 1114
1034 ## try to create single paragraphs of multiple lines sent by the server 1115 ## try to create single paragraphs of multiple lines sent by the server
1035 # no longer neecssary with TRT servers 1116 # no longer neecssary with TRT servers
1036 #$text =~ s/(?<=\S)\n(?=\w)/ /g; 1117 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
1037 1118
1038 for (split /\n/, $text) {
1039 ::message ({ 1119 ::message ({
1040 fg => $fg, 1120 fg => $fg,
1041 markup => $_, 1121 markup => $text,
1042 type => $type, 1122 type => $type,
1043 extra => [@extra], 1123 extra => [@extra],
1044 color_flags => $color, #d# ugly, kill 1124 color_flags => $color, #d# ugly, kill
1045 }); 1125 });
1046 1126
1047 $color &= ~NDI_CLEAR; # only clear once for multiline messages 1127# $color &= ~NDI_CLEAR; # only clear once for multiline messages
1048 # actually, this is an ugly design. _we_ should control the channels, 1128# # actually, this is an ugly design. _we_ should control the channels,
1049 # not some random other widget, as the channels are clearly protocol-specific. 1129# # 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 1130# # then we could also react to flags such as CLEAR without resorting to
1051 # hacks such as color_flags, above. 1131# # hacks such as color_flags, above.
1052 }
1053 1132
1054 $self->{statusbox}->add ($text, 1133 $self->{statusbox}->add ($text,
1055 group => $text, 1134 group => $text,
1056 fg => $fg, 1135 fg => $fg,
1057 timeout => $color >= 2 ? 180 : 10, 1136 timeout => $color >= 2 ? 180 : 10,
1092 1171
1093 my %skill_help; 1172 my %skill_help;
1094 1173
1095 for my $node (DC::Pod::find skill_description => "*") { 1174 for my $node (DC::Pod::find skill_description => "*") {
1096 my (undef, @par) = DC::Pod::section_of $node; 1175 my (undef, @par) = DC::Pod::section_of $node;
1097 $skill_help{$node->{kw}[0]} = DC::Pod::as_label @par; 1176 $skill_help{$node->[DC::Pod::N_KW][0]} = DC::Pod::as_label @par;
1098 }; 1177 };
1099 1178
1100 for my $skill (values %{$self->{skill_info}}) { 1179 for my $skill (values %{$self->{skill_info}}) {
1101 $self->{map_widget}->add_command ("ready_skill $skill", 1180 $self->{map_widget}->add_command ("ready_skill $skill",
1102 (DC::asxml "Ready the skill '$skill'\n\n") 1181 (DC::asxml "Ready the skill '$skill'\n\n")
1122 $::FLOORBOX->clear; 1201 $::FLOORBOX->clear;
1123 1202
1124 my @add; 1203 my @add;
1125 1204
1126 my $row; 1205 my $row;
1127 for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { 1206 for (sort { $b->{count} <=> $a->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) {
1207 next if $_->{tag} & 0x80000000;
1128 if ($row < 6) { 1208 if ($row < 6) {
1129 local $_->{face_widget}; # hack to force recreation of widget 1209 local $_->{face_widget}; # hack to force recreation of widget
1130 local $_->{desc_widget}; # hack to force recreation of widget 1210 local $_->{desc_widget}; # hack to force recreation of widget
1131 DC::Item::update_widgets $_; 1211 DC::Item::update_widgets $_;
1132 1212
1159sub set_opencont { 1239sub set_opencont {
1160 my ($conn, $tag, $name) = @_; 1240 my ($conn, $tag, $name) = @_;
1161 $conn->{open_container} = $tag; 1241 $conn->{open_container} = $tag;
1162 update_floorbox; 1242 update_floorbox;
1163 1243
1164 $::INVR_HB->clear (); 1244 $::INVR_HB->clear;
1165 $::INVR_HB->add (new DC::UI::Label align => 0, expand => 1, text => $name); 1245 $::INVR_HB->add (new DC::UI::Label expand => 1, text => $name);
1166 1246
1167 if ($tag != 0) { # Floor isn't closable, is it? 1247 if ($tag != 0) { # Floor isn't closable, is it?
1168 $::INVR_HB->add (new DC::UI::Button 1248 $::INVR_HB->add (new DC::UI::Button
1169 text => "Close container", 1249 text => "Close container",
1170 tooltip => "Close the currently open container (if one is open)", 1250 tooltip => "Close the currently open container (if one is open)",
1225} 1305}
1226 1306
1227sub item_update { 1307sub item_update {
1228 my ($self, $item) = @_; 1308 my ($self, $item) = @_;
1229 1309
1230 #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; 1310 #print "item_update: $item->{tag} in $item->{container} pt($self->{player}{tag}) oc($::CONN->{open_container}) f($item->{flags})\n";
1231 1311
1232 DC::Item::update_widgets $item; 1312 DC::Item::update_widgets $item;
1233 1313
1234 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { 1314 if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) {
1235 set_opencont ($::CONN, 0, "Floor"); 1315 set_opencont ($::CONN, 0, "Floor");
1236 1316
1237 } elsif ($item->{flags} & F_OPEN) { 1317 } elsif ($item->{flags} & F_OPEN) {
1238 set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item); 1318 set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item);
1254 1334
1255 my $weight = .001 * $self->{player}{weight}; 1335 my $weight = .001 * $self->{player}{weight};
1256 my $limit = .001 * $self->{stat}{+CS_STAT_WEIGHT_LIM}; 1336 my $limit = .001 * $self->{stat}{+CS_STAT_WEIGHT_LIM};
1257 1337
1258 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $weight); 1338 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $weight);
1259 $::STATWIDS->{m_weight}->set_text (sprintf "%.1fkg", $limit); 1339 $::STATWIDS->{m_weight}->set_text (sprintf "Max Weight: %.1fkg", $limit);
1260 $::STATWIDS->{i_weight}->set_text (sprintf "%.1f/%.1fkg", $weight, $limit); 1340 $::STATWIDS->{i_weight}->set_text (sprintf "%.1f/%.1fkg", $weight, $limit);
1261} 1341}
1262 1342
1263sub update_server_info { 1343sub update_server_info {
1264 my ($self) = @_; 1344 my ($self) = @_;
1272 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" 1352 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
1273 . "examine command support $yesno[$self->{setup}{excmd} > 0]\n" 1353 . "examine command support $yesno[$self->{setup}{excmd} > 0]\n"
1274 . "editing support $yesno[!!$self->{editor_support}]\n" 1354 . "editing support $yesno[!!$self->{editor_support}]\n"
1275 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" 1355 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
1276 . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n" 1356 . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n"
1277 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 1357 . "client support $yesno[$self->{cfplus_ext} > 0]"
1278 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 1358 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
1279 . "map size $self->{mapw}×$self->{maph}\n" 1359 . "map size $self->{mapw}×$self->{maph}\n"
1280 ); 1360 );
1281 1361
1282} 1362}
1304 1384
1305 $self->update_server_info; 1385 $self->update_server_info;
1306 1386
1307 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; 1387 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0;
1308 $self->send_command ("pickup $::CFG->{pickup}"); 1388 $self->send_command ("pickup $::CFG->{pickup}");
1389
1390 $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]",
1391 DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d#
1309} 1392}
1310 1393
1311sub lookat { 1394sub lookat {
1312 my ($self, $x, $y) = @_; 1395 my ($self, $x, $y) = @_;
1313 1396
1477} 1560}
1478 1561
1479sub send { 1562sub send {
1480 my ($self, $msg) = @_; 1563 my ($self, $msg) = @_;
1481 1564
1482 $self->{textview}->add_paragraph ({ markup => "\n" . DC::asxml $msg }); 1565 $self->{textview}->add_paragraph ({
1566 markup =>
1567 "\n<span foreground='#ffff00'><b>"
1568 . (DC::asxml $msg)
1569 . "</b></span>"
1570 });
1483 $self->{textview}->scroll_to_bottom; 1571 $self->{textview}->scroll_to_bottom;
1484 1572
1485 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); 1573 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg);
1486} 1574}
1487 1575

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines