… | |
… | |
11 | use DC::Pod; |
11 | use DC::Pod; |
12 | use DC::Macro; |
12 | use DC::Macro; |
13 | use DC::Item; |
13 | use DC::Item; |
14 | |
14 | |
15 | use base 'Deliantra::Protocol::Base'; |
15 | use base 'Deliantra::Protocol::Base'; |
|
|
16 | |
|
|
17 | our $TEX_DIALOGUE = new_from_resource DC::Texture |
|
|
18 | "dialogue.png", minify => 1, mipmap => 1; |
|
|
19 | |
|
|
20 | our $TEX_NOFACE = new_from_resource DC::Texture |
|
|
21 | "noface.png", minify => 1, mipmap => 1; |
|
|
22 | |
|
|
23 | our $TEX_HIDDEN = new_from_resource DC::Texture |
|
|
24 | "hidden.png", minify => 1, mipmap => 1; |
|
|
25 | |
|
|
26 | sub MIN_TEXTURE_UNUSED() { 1 }#d# |
16 | |
27 | |
17 | sub new { |
28 | sub new { |
18 | my ($class, %arg) = @_; |
29 | my ($class, %arg) = @_; |
19 | |
30 | |
20 | my $self = $class->SUPER::new (%arg, |
31 | my $self = $class->SUPER::new (%arg, |
… | |
… | |
64 | $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { |
75 | $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { |
65 | for my $ws (values %{delete $self->{widgetset} || {}}) { |
76 | for my $ws (values %{delete $self->{widgetset} || {}}) { |
66 | $_->destroy |
77 | $_->destroy |
67 | for values %{delete $ws->{w} || {}}; |
78 | for values %{delete $ws->{w} || {}}; |
68 | } |
79 | } |
|
|
80 | |
|
|
81 | delete $self->{items}; |
|
|
82 | $::INV->clear; |
|
|
83 | $::INVR->clear; |
|
|
84 | $::INVR_HB->clear; |
|
|
85 | $::FLOORBOX->clear; |
69 | }); |
86 | }); |
70 | |
87 | |
71 | $self->{map_widget}->add_command (@$_) |
88 | $self->{map_widget}->add_command (@$_) |
72 | for @cmd_help; |
89 | for @cmd_help; |
73 | |
90 | |
74 | { |
91 | { |
75 | $self->{dialogue} = my $tex = new_from_file DC::Texture |
92 | $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}}); |
93 | $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
78 | } |
94 | } |
79 | |
95 | |
80 | { |
96 | { |
81 | $self->{noface} = my $tex = new_from_file DC::Texture |
97 | $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}}); |
98 | $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
84 | } |
99 | } |
|
|
100 | |
|
|
101 | { |
|
|
102 | $self->{hidden} = my $tex = $TEX_HIDDEN; |
|
|
103 | $self->{map}->set_texture (3, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
|
|
104 | } |
|
|
105 | |
|
|
106 | # $self->{expire_count} = DC::DB::FIRST_TILE_ID; # minimum non-fixed tile id |
|
|
107 | # $self->{expire_w} = EV::timer 1, 1, sub { |
|
|
108 | # my $count = (int @{ $self->{texture} } / MIN_TEXTURE_UNUSED) || 1; |
|
|
109 | # |
|
|
110 | # for ($self->{map}->expire_textures ($self->{expire_count}, $count)) { |
|
|
111 | # warn DC::SvREFCNT $self->{texture}[$_]; |
|
|
112 | # $self->{texture}[$_]->unload; |
|
|
113 | # warn "expire texture $_\n";#d# |
|
|
114 | # } |
|
|
115 | # |
|
|
116 | # ($self->{expire_count} += $count) < @{ $self->{texture} } |
|
|
117 | # or $self->{expire_count} = DC::DB::FIRST_TILE_ID; |
|
|
118 | # warn "count is $count\n";#d# |
|
|
119 | # }; |
85 | |
120 | |
86 | $self->{open_container} = 0; |
121 | $self->{open_container} = 0; |
87 | |
122 | |
88 | # per server |
123 | # per server |
89 | $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; |
124 | $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; |
… | |
… | |
536 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
571 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
537 | ]; |
572 | ]; |
538 | |
573 | |
539 | my @add = @$sw; |
574 | my @add = @$sw; |
540 | |
575 | |
541 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; |
576 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use skill\nRight click - further options</small>"; |
542 | |
577 | |
543 | my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); |
578 | my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); |
544 | my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); |
579 | my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); |
545 | |
580 | |
546 | my ($x, $y) = (0, 1); |
581 | my ($x, $y) = (0, 1); |
… | |
… | |
632 | } |
667 | } |
633 | |
668 | |
634 | sub map_scroll { |
669 | sub map_scroll { |
635 | my ($self, $dx, $dy) = @_; |
670 | my ($self, $dx, $dy) = @_; |
636 | |
671 | |
637 | $self->{map}->scroll ($dx, $dy); |
672 | $self->{map_widget}->scroll ($dx, $dy); |
638 | } |
673 | } |
639 | |
674 | |
640 | sub feed_map1a { |
675 | sub feed_map1a { |
641 | my ($self, $data) = @_; |
676 | my ($self, $data) = @_; |
642 | |
677 | |
… | |
… | |
646 | for my $tile (@$missing) { |
681 | for my $tile (@$missing) { |
647 | next if $self->{delay}{$tile}; |
682 | next if $self->{delay}{$tile}; |
648 | |
683 | |
649 | $delay = 1; |
684 | $delay = 1; |
650 | |
685 | |
651 | if (my $tex = $::CONN->{texture}[$tile]) { |
686 | if (my $tex = $self->{texture}[$tile]) { |
652 | $tex->upload; |
687 | $tex->upload; |
653 | } else { |
688 | } else { |
654 | $self->{delay}{$tile} = 1; |
689 | $self->{delay}{$tile} = 1; |
655 | |
690 | |
656 | # we assume the face is in-flight and will eventually come |
691 | # we assume the face is in-flight and will eventually arrive |
657 | push @{$self->{tile_cb}{$tile}}, sub { |
692 | push @{$self->{tile_cb}{$tile}}, sub { |
658 | delete $self->{delay}{$tile}; |
693 | delete $self->{delay}{$tile}; |
659 | $_[0]->upload; |
694 | $_[0]->upload; |
660 | }; |
695 | }; |
661 | } |
696 | } |
662 | } |
697 | } |
663 | |
698 | |
664 | if ($delay) { |
699 | if ($delay) { |
665 | # delay the map drawing a tiny bit in the hope of getting the missing fetched |
700 | # delay the map drawing a tiny bit in the hope of getting the missing tiles fetched |
666 | EV::once undef, 0, 0.03, sub { |
701 | EV::once undef, 0, 0.03, sub { |
667 | $self->{map_widget}->update |
702 | $self->{map_widget}->update |
668 | if $self->{map_widget}; |
703 | if $self->{map_widget}; |
669 | }; |
704 | }; |
670 | } else { |
705 | } else { |
… | |
… | |
679 | } |
714 | } |
680 | |
715 | |
681 | sub flush_map { |
716 | sub flush_map { |
682 | my ($self) = @_; |
717 | my ($self) = @_; |
683 | |
718 | |
684 | my $map_info = delete $self->{map_info} |
719 | return unless $self->{map_info}; |
685 | or return; |
|
|
686 | |
720 | |
|
|
721 | for my $map_info (values %{ $self->{map_cache} || {} }) { |
687 | my ($hash, $x, $y, $w, $h) = @$map_info; |
722 | my ($hash, $rdata, $x, $y, $w, $h) = @$map_info; |
688 | |
723 | |
689 | my $data = Compress::LZF::compress $self->{map}->get_rect ($x, $y, $w, $h); |
724 | my $data = $self->{map}->get_rect ($x, $y, $w, $h); |
690 | $self->{map_cache_new}{$hash} = \$data; |
725 | |
|
|
726 | if ($data ne $$rdata) { |
|
|
727 | $map_info->[1] = \$data; |
|
|
728 | my $cdata = Compress::LZF::compress $data; |
691 | DC::DB::put $self->{mapcache} => $hash => $data, sub { }; |
729 | DC::DB::put $self->{mapcache} => $hash => $cdata, sub { }; |
|
|
730 | } |
|
|
731 | } |
692 | } |
732 | } |
693 | |
733 | |
694 | sub map_clear { |
734 | sub map_clear { |
695 | my ($self) = @_; |
735 | my ($self) = @_; |
696 | |
736 | |
697 | $self->flush_map; |
737 | $self->flush_map; |
|
|
738 | delete $self->{map_info}; |
698 | delete $self->{neigh_map}; |
739 | delete $self->{neigh_map}; |
699 | |
740 | |
700 | $self->{map}->clear; |
741 | $self->{map}->clear; |
701 | delete $self->{map_widget}{magicmap}; |
742 | delete $self->{map_widget}{magicmap}; |
702 | } |
743 | } |
… | |
… | |
723 | |
764 | |
724 | $self->bg_fetch; |
765 | $self->bg_fetch; |
725 | }; |
766 | }; |
726 | } |
767 | } |
727 | |
768 | |
728 | sub load_map($$$) { |
769 | sub load_map($$$$$$) { |
729 | my ($self, $hash, $x, $y) = @_; |
770 | my ($self, $hash, $x, $y, $w, $h) = @_; |
730 | |
771 | |
731 | my $gen = $self->{map_change_gen}; |
772 | my $map_info = $self->{map_cache}{$hash} = [$hash, \"", $x, $y, $w, $h]; |
732 | |
773 | |
733 | my $cb = sub { |
774 | my $cb = sub { |
734 | return unless $gen == $self->{map_change_gen}; |
775 | $map_info->[1] = \$_[0]; |
735 | |
776 | |
736 | my ($data) = @_; |
|
|
737 | |
|
|
738 | if (defined $data) { |
|
|
739 | $self->{map_cache_new}{$hash} = \$data; |
|
|
740 | |
|
|
741 | my $data = Compress::LZF::decompress $data; |
|
|
742 | |
|
|
743 | my $inprogress = @{ $self->{bg_fetch} || [] }; |
777 | my $inprogress = @{ $self->{bg_fetch} || [] }; |
744 | unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); |
778 | unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $_[0]); |
745 | $self->bg_fetch unless $inprogress; |
779 | $self->bg_fetch unless $inprogress; |
746 | } |
|
|
747 | }; |
780 | }; |
748 | |
781 | |
749 | if (my $rdata = $self->{map_cache_old}{$hash}) { |
782 | if (my $map_info = $self->{map_cache_old}{$hash}) { |
750 | $cb->($$rdata); |
783 | $cb->(${ $map_info->[1] }); |
751 | } else { |
784 | } else { |
|
|
785 | my $gen = $self->{map_change_gen}; |
|
|
786 | |
752 | DC::DB::get $self->{mapcache} => $hash, $cb; |
787 | DC::DB::get $self->{mapcache} => $hash, sub { |
|
|
788 | return unless $gen == $self->{map_change_gen}; |
|
|
789 | return unless defined $_[0]; |
|
|
790 | $cb->(Compress::LZF::decompress $_[0]); |
|
|
791 | }; |
753 | } |
792 | } |
754 | } |
793 | } |
755 | |
794 | |
756 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
795 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
757 | # (server resource,s latency, bandwidth), so this hack is warranted. |
796 | # (server resources, latency, bandwidth), so this hack is warranted. |
758 | # the right fix is to make real tiled maps with an overview file |
797 | # the right fix is to make real tiled maps with an overview file |
759 | sub send_mapinfo { |
798 | sub send_mapinfo { |
760 | my ($self, $data, $cb) = @_; |
799 | my ($self, $data, $cb) = @_; |
761 | |
800 | |
762 | if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) { |
801 | if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) { |
… | |
… | |
787 | } |
826 | } |
788 | |
827 | |
789 | # this method does a "flood fill" into every tile direction |
828 | # this method does a "flood fill" into every tile direction |
790 | # it assumes that tiles are arranged in a rectangular grid, |
829 | # it assumes that tiles are arranged in a rectangular grid, |
791 | # i.e. a map is the same as the left of the right map etc. |
830 | # i.e. a map is the same as the left of the right map etc. |
792 | # failure to comply are harmless and result in display errors |
831 | # failure to comply is harmless and results in display errors |
793 | # at worst. |
832 | # at worst. |
794 | sub flood_fill { |
833 | sub flood_fill { |
795 | my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; |
834 | my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; |
796 | |
835 | |
797 | # the server does not allow map paths > 6 |
836 | # the server does not allow map paths > 6 |
… | |
… | |
833 | return if $mode ne "spatial"; |
872 | return if $mode ne "spatial"; |
834 | |
873 | |
835 | $x += $self->{map}->ox; |
874 | $x += $self->{map}->ox; |
836 | $y += $self->{map}->oy; |
875 | $y += $self->{map}->oy; |
837 | |
876 | |
838 | $self->load_map ($hash, $x, $y) |
877 | $self->load_map ($hash, $x, $y, $w, $h) |
839 | unless $self->{neigh_map}{$hash}[5]++;#d# |
878 | unless $self->{neigh_map}{$hash}[5]++;#d# |
840 | |
879 | |
841 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
880 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
842 | |
881 | |
843 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
882 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
… | |
… | |
851 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
890 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
852 | |
891 | |
853 | $self->flush_map; |
892 | $self->flush_map; |
854 | |
893 | |
855 | ++$self->{map_change_gen}; |
894 | ++$self->{map_change_gen}; |
856 | $self->{map_cache_old} = delete $self->{map_cache_new}; |
895 | $self->{map_cache_old} = delete $self->{map_cache}; |
857 | |
896 | |
858 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
897 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
859 | |
898 | |
860 | my $mapmapw = $self->{mapmap}->{w}; |
899 | my $mapmapw = $self->{mapmap}->{w}; |
861 | my $mapmaph = $self->{mapmap}->{h}; |
900 | my $mapmaph = $self->{mapmap}->{h}; |
… | |
… | |
873 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
912 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
874 | |
913 | |
875 | (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; |
914 | (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; |
876 | $::STATWIDS->{map}->set_text ("Map: " . $map); |
915 | $::STATWIDS->{map}->set_text ("Map: " . $map); |
877 | |
916 | |
878 | $self->load_map ($hash, $x, $y); |
917 | $self->load_map ($hash, $x, $y, $w, $h); |
879 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
918 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
880 | } |
919 | } |
881 | |
920 | |
882 | sub face_find { |
921 | sub face_find { |
883 | my ($self, $facenum, $face, $cb) = @_; |
922 | my ($self, $facenum, $face, $cb) = @_; |
… | |
… | |
1025 | s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&/g; |
1064 | s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&/g; |
1026 | |
1065 | |
1027 | # handle some elements |
1066 | # handle some elements |
1028 | s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; |
1067 | s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; |
1029 | s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; |
1068 | s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; |
|
|
1069 | |
|
|
1070 | s/\s+$//; |
1030 | |
1071 | |
1031 | $_ |
1072 | $_ |
1032 | } |
1073 | } |
1033 | |
1074 | |
1034 | our %NAME_TO_COLOR = ( |
1075 | our %NAME_TO_COLOR = ( |
… | |
… | |
1081 | |
1122 | |
1082 | ## try to create single paragraphs of multiple lines sent by the server |
1123 | ## try to create single paragraphs of multiple lines sent by the server |
1083 | # no longer neecssary with TRT servers |
1124 | # no longer neecssary with TRT servers |
1084 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1125 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1085 | |
1126 | |
1086 | for (split /\n/, $text) { |
|
|
1087 | ::message ({ |
1127 | ::message ({ |
1088 | fg => $fg, |
1128 | fg => $fg, |
1089 | markup => $_, |
1129 | markup => $text, |
1090 | type => $type, |
1130 | type => $type, |
1091 | extra => [@extra], |
1131 | extra => [@extra], |
1092 | color_flags => $color, #d# ugly, kill |
1132 | color_flags => $color, #d# ugly, kill |
1093 | }); |
1133 | }); |
1094 | |
1134 | |
1095 | $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1135 | # $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1096 | # actually, this is an ugly design. _we_ should control the channels, |
1136 | # # actually, this is an ugly design. _we_ should control the channels, |
1097 | # not some random other widget, as the channels are clearly protocol-specific. |
1137 | # # not some random other widget, as the channels are clearly protocol-specific. |
1098 | # then we could also react to flags such as CLEAR without resorting to |
1138 | # # then we could also react to flags such as CLEAR without resorting to |
1099 | # hacks such as color_flags, above. |
1139 | # # hacks such as color_flags, above. |
1100 | } |
|
|
1101 | |
1140 | |
1102 | $self->{statusbox}->add ($text, |
1141 | $self->{statusbox}->add ($text, |
1103 | group => $text, |
1142 | group => $text, |
1104 | fg => $fg, |
1143 | fg => $fg, |
1105 | timeout => $color >= 2 ? 180 : 10, |
1144 | timeout => $color >= 2 ? 180 : 10, |
… | |
… | |
1170 | $::FLOORBOX->clear; |
1209 | $::FLOORBOX->clear; |
1171 | |
1210 | |
1172 | my @add; |
1211 | my @add; |
1173 | |
1212 | |
1174 | my $row; |
1213 | my $row; |
1175 | for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { |
1214 | for (sort { $b->{count} <=> $a->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { |
|
|
1215 | next if $_->{tag} & 0x80000000; |
1176 | if ($row < 6) { |
1216 | if ($row < 6) { |
1177 | local $_->{face_widget}; # hack to force recreation of widget |
1217 | local $_->{face_widget}; # hack to force recreation of widget |
1178 | local $_->{desc_widget}; # hack to force recreation of widget |
1218 | local $_->{desc_widget}; # hack to force recreation of widget |
1179 | DC::Item::update_widgets $_; |
1219 | DC::Item::update_widgets $_; |
1180 | |
1220 | |
… | |
… | |
1207 | sub set_opencont { |
1247 | sub set_opencont { |
1208 | my ($conn, $tag, $name) = @_; |
1248 | my ($conn, $tag, $name) = @_; |
1209 | $conn->{open_container} = $tag; |
1249 | $conn->{open_container} = $tag; |
1210 | update_floorbox; |
1250 | update_floorbox; |
1211 | |
1251 | |
1212 | $::INVR_HB->clear (); |
1252 | $::INVR_HB->clear; |
1213 | $::INVR_HB->add (new DC::UI::Label expand => 1, text => $name); |
1253 | $::INVR_HB->add (new DC::UI::Label expand => 1, text => $name); |
1214 | |
1254 | |
1215 | if ($tag != 0) { # Floor isn't closable, is it? |
1255 | if ($tag != 0) { # Floor isn't closable, is it? |
1216 | $::INVR_HB->add (new DC::UI::Button |
1256 | $::INVR_HB->add (new DC::UI::Button |
1217 | text => "Close container", |
1257 | text => "Close container", |
… | |
… | |
1273 | } |
1313 | } |
1274 | |
1314 | |
1275 | sub item_update { |
1315 | sub item_update { |
1276 | my ($self, $item) = @_; |
1316 | my ($self, $item) = @_; |
1277 | |
1317 | |
1278 | #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; |
1318 | #print "item_update: $item->{tag} in $item->{container} pt($self->{player}{tag}) oc($::CONN->{open_container}) f($item->{flags})\n"; |
1279 | |
1319 | |
1280 | DC::Item::update_widgets $item; |
1320 | DC::Item::update_widgets $item; |
1281 | |
1321 | |
1282 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
1322 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
1283 | set_opencont ($::CONN, 0, "Floor"); |
1323 | set_opencont ($::CONN, 0, "Floor"); |
1284 | |
1324 | |
1285 | } elsif ($item->{flags} & F_OPEN) { |
1325 | } elsif ($item->{flags} & F_OPEN) { |
1286 | set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item); |
1326 | set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item); |
… | |
… | |
1352 | |
1392 | |
1353 | $self->update_server_info; |
1393 | $self->update_server_info; |
1354 | |
1394 | |
1355 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1395 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1356 | $self->send_command ("pickup $::CFG->{pickup}"); |
1396 | $self->send_command ("pickup $::CFG->{pickup}"); |
|
|
1397 | |
|
|
1398 | $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]", |
|
|
1399 | DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d# |
1357 | } |
1400 | } |
1358 | |
1401 | |
1359 | sub lookat { |
1402 | sub lookat { |
1360 | my ($self, $x, $y) = @_; |
1403 | my ($self, $x, $y) = @_; |
1361 | |
1404 | |
… | |
… | |
1466 | DC::weaken $self; |
1509 | DC::weaken $self; |
1467 | |
1510 | |
1468 | $self->{options}->clear; |
1511 | $self->{options}->clear; |
1469 | $self->{options}->add ($self->{bye_button}); |
1512 | $self->{options}->add ($self->{bye_button}); |
1470 | |
1513 | |
1471 | for my $kw (sort keys %{ $self->[DC::Pod::N_KW] }) { |
1514 | for my $kw (sort keys %{ $self->{kw} }) { |
1472 | $self->{options}->add (new DC::UI::Button |
1515 | $self->{options}->add (new DC::UI::Button |
1473 | text => $kw, |
1516 | text => $kw, |
1474 | on_activate => sub { |
1517 | on_activate => sub { |
1475 | $self->send ($kw); |
1518 | $self->send ($kw); |
1476 | 0 |
1519 | 0 |
… | |
… | |
1485 | DC::weaken $self; |
1528 | DC::weaken $self; |
1486 | |
1529 | |
1487 | if ($type eq "update") { |
1530 | if ($type eq "update") { |
1488 | my (%info) = @arg; |
1531 | my (%info) = @arg; |
1489 | |
1532 | |
1490 | $self->[DC::Pod::N_KW]{$_} = 1 for @{$info{add_topics} || []}; |
1533 | $self->{kw}{$_} = 1 for @{$info{add_topics} || []}; |
1491 | $self->[DC::Pod::N_KW]{$_} = 0 for @{$info{del_topics} || []}; |
1534 | $self->{kw}{$_} = 0 for @{$info{del_topics} || []}; |
1492 | |
1535 | |
1493 | if (exists $info{msg}) { |
1536 | if (exists $info{msg}) { |
1494 | my $text = "\n" . DC::Protocol::sanitise_xml $info{msg}; |
1537 | my $text = "\n" . DC::Protocol::sanitise_xml $info{msg}; |
1495 | my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->[DC::Pod::N_KW] }; |
1538 | my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; |
1496 | my @link; |
1539 | my @link; |
1497 | $text =~ s{ |
1540 | $text =~ s{ |
1498 | ($match) |
1541 | ($match) |
1499 | }{ |
1542 | }{ |
1500 | my $kw = $1; |
1543 | my $kw = $1; |
… | |
… | |
1525 | } |
1568 | } |
1526 | |
1569 | |
1527 | sub send { |
1570 | sub send { |
1528 | my ($self, $msg) = @_; |
1571 | my ($self, $msg) = @_; |
1529 | |
1572 | |
1530 | $self->{textview}->add_paragraph ({ markup => "\n" . DC::asxml $msg }); |
1573 | $self->{textview}->add_paragraph ({ |
|
|
1574 | markup => |
|
|
1575 | "\n<span foreground='#ffff00'><b>" |
|
|
1576 | . (DC::asxml $msg) |
|
|
1577 | . "</b></span>" |
|
|
1578 | }); |
1531 | $self->{textview}->scroll_to_bottom; |
1579 | $self->{textview}->scroll_to_bottom; |
1532 | |
1580 | |
1533 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1581 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1534 | } |
1582 | } |
1535 | |
1583 | |