… | |
… | |
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}"; |
… | |
… | |
250 | my %wkw = ( |
285 | my %wkw = ( |
251 | root => $DC::UI::ROOT, |
286 | root => $DC::UI::ROOT, |
252 | tooltip => $DC::UI::TOOLTIP, |
287 | tooltip => $DC::UI::TOOLTIP, |
253 | |
288 | |
254 | mapwidget => $::MAPWIDGET, |
289 | mapwidget => $::MAPWIDGET, |
|
|
290 | menubar => $::MENUBAR, |
|
|
291 | menupopup => $::MENUPOPUP, |
255 | buttonbar => $::BUTTONBAR, |
292 | buttonbar => $::BUTTONBAR, |
256 | metaserver => $::METASERVER, |
293 | metaserver => $::METASERVER, |
257 | buttonbar => $::BUTTONBAR, |
294 | buttonbar => $::BUTTONBAR, |
258 | login_button => $::LOGIN_BUTTON, |
295 | login_button => $::LOGIN_BUTTON, |
259 | quit_dialog => $::QUIT_DIALOG, |
296 | quit_dialog => $::QUIT_DIALOG, |
… | |
… | |
276 | |
313 | |
277 | floorbox => $::FLOORBOX, |
314 | floorbox => $::FLOORBOX, |
278 | help_window => $::HELP_WINDOW, |
315 | help_window => $::HELP_WINDOW, |
279 | message_window => $::MESSAGE_WINDOW, |
316 | message_window => $::MESSAGE_WINDOW, |
280 | message_dist => $::MESSAGE_DIST, |
317 | message_dist => $::MESSAGE_DIST, |
281 | statusbox => $::SDTATUSBOX, |
318 | statusbox => $::STATUSBOX, |
282 | |
319 | |
283 | inv => $::INV, |
320 | inv => $::INV, |
284 | invr => $::INVR, |
321 | invr => $::INVR, |
285 | invr_hb => $::INVR_HB, |
322 | invr_hb => $::INVR_HB, |
286 | ); |
323 | ); |
… | |
… | |
536 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
573 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
537 | ]; |
574 | ]; |
538 | |
575 | |
539 | my @add = @$sw; |
576 | my @add = @$sw; |
540 | |
577 | |
541 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; |
578 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use skill\nRight click - further options</small>"; |
542 | |
579 | |
543 | my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); |
580 | 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); |
581 | my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); |
545 | |
582 | |
546 | my ($x, $y) = (0, 1); |
583 | my ($x, $y) = (0, 1); |
… | |
… | |
632 | } |
669 | } |
633 | |
670 | |
634 | sub map_scroll { |
671 | sub map_scroll { |
635 | my ($self, $dx, $dy) = @_; |
672 | my ($self, $dx, $dy) = @_; |
636 | |
673 | |
637 | $self->{map}->scroll ($dx, $dy); |
674 | $self->{map_widget}->scroll ($dx, $dy); |
638 | } |
675 | } |
639 | |
676 | |
640 | sub feed_map1a { |
677 | sub feed_map1a { |
641 | my ($self, $data) = @_; |
678 | my ($self, $data) = @_; |
642 | |
679 | |
… | |
… | |
646 | for my $tile (@$missing) { |
683 | for my $tile (@$missing) { |
647 | next if $self->{delay}{$tile}; |
684 | next if $self->{delay}{$tile}; |
648 | |
685 | |
649 | $delay = 1; |
686 | $delay = 1; |
650 | |
687 | |
651 | if (my $tex = $::CONN->{texture}[$tile]) { |
688 | if (my $tex = $self->{texture}[$tile]) { |
652 | $tex->upload; |
689 | $tex->upload; |
653 | } else { |
690 | } else { |
654 | $self->{delay}{$tile} = 1; |
691 | $self->{delay}{$tile} = 1; |
655 | |
692 | |
656 | # we assume the face is in-flight and will eventually come |
693 | # we assume the face is in-flight and will eventually arrive |
657 | push @{$self->{tile_cb}{$tile}}, sub { |
694 | push @{$self->{tile_cb}{$tile}}, sub { |
658 | delete $self->{delay}{$tile}; |
695 | delete $self->{delay}{$tile}; |
659 | $_[0]->upload; |
696 | $_[0]->upload; |
660 | }; |
697 | }; |
661 | } |
698 | } |
662 | } |
699 | } |
663 | |
700 | |
664 | if ($delay) { |
701 | if ($delay) { |
665 | # delay the map drawing a tiny bit in the hope of getting the missing fetched |
702 | # delay the map drawing a tiny bit in the hope of getting the missing tiles fetched |
666 | EV::once undef, 0, 0.03, sub { |
703 | EV::once undef, 0, 0.03, sub { |
667 | $self->{map_widget}->update |
704 | $self->{map_widget}->update |
668 | if $self->{map_widget}; |
705 | if $self->{map_widget}; |
669 | }; |
706 | }; |
670 | } else { |
707 | } else { |
… | |
… | |
679 | } |
716 | } |
680 | |
717 | |
681 | sub flush_map { |
718 | sub flush_map { |
682 | my ($self) = @_; |
719 | my ($self) = @_; |
683 | |
720 | |
684 | my $map_info = delete $self->{map_info} |
721 | return unless $self->{map_info}; |
685 | or return; |
|
|
686 | |
722 | |
|
|
723 | for my $map_info (values %{ $self->{map_cache} || {} }) { |
687 | my ($hash, $x, $y, $w, $h) = @$map_info; |
724 | my ($hash, $rdata, $x, $y, $w, $h) = @$map_info; |
688 | |
725 | |
689 | my $data = Compress::LZF::compress $self->{map}->get_rect ($x, $y, $w, $h); |
726 | my $data = $self->{map}->get_rect ($x, $y, $w, $h); |
690 | $self->{map_cache_new}{$hash} = \$data; |
727 | |
|
|
728 | if ($data ne $$rdata) { |
|
|
729 | $map_info->[1] = \$data; |
|
|
730 | my $cdata = Compress::LZF::compress $data; |
691 | DC::DB::put $self->{mapcache} => $hash => $data, sub { }; |
731 | DC::DB::put $self->{mapcache} => $hash => $cdata, sub { }; |
|
|
732 | } |
|
|
733 | } |
692 | } |
734 | } |
693 | |
735 | |
694 | sub map_clear { |
736 | sub map_clear { |
695 | my ($self) = @_; |
737 | my ($self) = @_; |
696 | |
738 | |
697 | $self->flush_map; |
739 | $self->flush_map; |
|
|
740 | delete $self->{map_info}; |
698 | delete $self->{neigh_map}; |
741 | delete $self->{neigh_map}; |
699 | |
742 | |
700 | $self->{map}->clear; |
743 | $self->{map}->clear; |
701 | delete $self->{map_widget}{magicmap}; |
744 | delete $self->{map_widget}{magicmap}; |
702 | } |
745 | } |
… | |
… | |
723 | |
766 | |
724 | $self->bg_fetch; |
767 | $self->bg_fetch; |
725 | }; |
768 | }; |
726 | } |
769 | } |
727 | |
770 | |
728 | sub load_map($$$) { |
771 | sub load_map($$$$$$) { |
729 | my ($self, $hash, $x, $y) = @_; |
772 | my ($self, $hash, $x, $y, $w, $h) = @_; |
730 | |
773 | |
731 | my $gen = $self->{map_change_gen}; |
774 | my $map_info = $self->{map_cache}{$hash} = [$hash, \"", $x, $y, $w, $h]; |
732 | |
775 | |
733 | my $cb = sub { |
776 | my $cb = sub { |
734 | return unless $gen == $self->{map_change_gen}; |
777 | $map_info->[1] = \$_[0]; |
735 | |
778 | |
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} || [] }; |
779 | my $inprogress = @{ $self->{bg_fetch} || [] }; |
744 | unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); |
780 | unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $_[0]); |
745 | $self->bg_fetch unless $inprogress; |
781 | $self->bg_fetch unless $inprogress; |
746 | } |
|
|
747 | }; |
782 | }; |
748 | |
783 | |
749 | if (my $rdata = $self->{map_cache_old}{$hash}) { |
784 | if (my $map_info = $self->{map_cache_old}{$hash}) { |
750 | $cb->($$rdata); |
785 | $cb->(${ $map_info->[1] }); |
751 | } else { |
786 | } else { |
|
|
787 | my $gen = $self->{map_change_gen}; |
|
|
788 | |
752 | DC::DB::get $self->{mapcache} => $hash, $cb; |
789 | DC::DB::get $self->{mapcache} => $hash, sub { |
|
|
790 | return unless $gen == $self->{map_change_gen}; |
|
|
791 | return unless defined $_[0]; |
|
|
792 | $cb->(Compress::LZF::decompress $_[0]); |
|
|
793 | }; |
753 | } |
794 | } |
754 | } |
795 | } |
755 | |
796 | |
756 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
797 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
757 | # (server resource,s latency, bandwidth), so this hack is warranted. |
798 | # (server resources, latency, bandwidth), so this hack is warranted. |
758 | # the right fix is to make real tiled maps with an overview file |
799 | # the right fix is to make real tiled maps with an overview file |
759 | sub send_mapinfo { |
800 | sub send_mapinfo { |
760 | my ($self, $data, $cb) = @_; |
801 | my ($self, $data, $cb) = @_; |
761 | |
802 | |
762 | if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) { |
803 | if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) { |
… | |
… | |
787 | } |
828 | } |
788 | |
829 | |
789 | # this method does a "flood fill" into every tile direction |
830 | # this method does a "flood fill" into every tile direction |
790 | # it assumes that tiles are arranged in a rectangular grid, |
831 | # 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. |
832 | # 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 |
833 | # failure to comply is harmless and results in display errors |
793 | # at worst. |
834 | # at worst. |
794 | sub flood_fill { |
835 | sub flood_fill { |
795 | my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; |
836 | my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; |
796 | |
837 | |
797 | # the server does not allow map paths > 6 |
838 | # the server does not allow map paths > 6 |
… | |
… | |
833 | return if $mode ne "spatial"; |
874 | return if $mode ne "spatial"; |
834 | |
875 | |
835 | $x += $self->{map}->ox; |
876 | $x += $self->{map}->ox; |
836 | $y += $self->{map}->oy; |
877 | $y += $self->{map}->oy; |
837 | |
878 | |
838 | $self->load_map ($hash, $x, $y) |
879 | $self->load_map ($hash, $x, $y, $w, $h) |
839 | unless $self->{neigh_map}{$hash}[5]++;#d# |
880 | unless $self->{neigh_map}{$hash}[5]++;#d# |
840 | |
881 | |
841 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
882 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
842 | |
883 | |
843 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
884 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
… | |
… | |
851 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
892 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
852 | |
893 | |
853 | $self->flush_map; |
894 | $self->flush_map; |
854 | |
895 | |
855 | ++$self->{map_change_gen}; |
896 | ++$self->{map_change_gen}; |
856 | $self->{map_cache_old} = delete $self->{map_cache_new}; |
897 | $self->{map_cache_old} = delete $self->{map_cache}; |
857 | |
898 | |
858 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
899 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
859 | |
900 | |
860 | my $mapmapw = $self->{mapmap}->{w}; |
901 | my $mapmapw = $self->{mapmap}->{w}; |
861 | my $mapmaph = $self->{mapmap}->{h}; |
902 | my $mapmaph = $self->{mapmap}->{h}; |
… | |
… | |
873 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
914 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
874 | |
915 | |
875 | (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; |
916 | (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; |
876 | $::STATWIDS->{map}->set_text ("Map: " . $map); |
917 | $::STATWIDS->{map}->set_text ("Map: " . $map); |
877 | |
918 | |
878 | $self->load_map ($hash, $x, $y); |
919 | $self->load_map ($hash, $x, $y, $w, $h); |
879 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
920 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
880 | } |
921 | } |
881 | |
922 | |
882 | sub face_find { |
923 | sub face_find { |
883 | my ($self, $facenum, $face, $cb) = @_; |
924 | my ($self, $facenum, $face, $cb) = @_; |
… | |
… | |
1025 | s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&/g; |
1066 | s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&/g; |
1026 | |
1067 | |
1027 | # handle some elements |
1068 | # handle some elements |
1028 | s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; |
1069 | s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; |
1029 | s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; |
1070 | s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; |
|
|
1071 | |
|
|
1072 | s/\s+$//; |
1030 | |
1073 | |
1031 | $_ |
1074 | $_ |
1032 | } |
1075 | } |
1033 | |
1076 | |
1034 | our %NAME_TO_COLOR = ( |
1077 | our %NAME_TO_COLOR = ( |
… | |
… | |
1081 | |
1124 | |
1082 | ## try to create single paragraphs of multiple lines sent by the server |
1125 | ## try to create single paragraphs of multiple lines sent by the server |
1083 | # no longer neecssary with TRT servers |
1126 | # no longer neecssary with TRT servers |
1084 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1127 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1085 | |
1128 | |
1086 | for (split /\n/, $text) { |
|
|
1087 | ::message ({ |
1129 | ::message ({ |
1088 | fg => $fg, |
1130 | fg => $fg, |
1089 | markup => $_, |
1131 | markup => $text, |
1090 | type => $type, |
1132 | type => $type, |
1091 | extra => [@extra], |
1133 | extra => [@extra], |
1092 | color_flags => $color, #d# ugly, kill |
1134 | color_flags => $color, #d# ugly, kill |
1093 | }); |
1135 | }); |
1094 | |
1136 | |
1095 | $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1137 | # $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1096 | # actually, this is an ugly design. _we_ should control the channels, |
1138 | # # actually, this is an ugly design. _we_ should control the channels, |
1097 | # not some random other widget, as the channels are clearly protocol-specific. |
1139 | # # 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 |
1140 | # # then we could also react to flags such as CLEAR without resorting to |
1099 | # hacks such as color_flags, above. |
1141 | # # hacks such as color_flags, above. |
1100 | } |
|
|
1101 | |
1142 | |
1102 | $self->{statusbox}->add ($text, |
1143 | $self->{statusbox}->add ($text, |
1103 | group => $text, |
1144 | group => $text, |
1104 | fg => $fg, |
1145 | fg => $fg, |
1105 | timeout => $color >= 2 ? 180 : 10, |
1146 | timeout => $color >= 2 ? 180 : 10, |
… | |
… | |
1170 | $::FLOORBOX->clear; |
1211 | $::FLOORBOX->clear; |
1171 | |
1212 | |
1172 | my @add; |
1213 | my @add; |
1173 | |
1214 | |
1174 | my $row; |
1215 | my $row; |
1175 | for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { |
1216 | for (sort { $b->{count} <=> $a->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { |
|
|
1217 | next if $_->{tag} & 0x80000000; |
1176 | if ($row < 6) { |
1218 | if ($row < 6) { |
1177 | local $_->{face_widget}; # hack to force recreation of widget |
1219 | local $_->{face_widget}; # hack to force recreation of widget |
1178 | local $_->{desc_widget}; # hack to force recreation of widget |
1220 | local $_->{desc_widget}; # hack to force recreation of widget |
1179 | DC::Item::update_widgets $_; |
1221 | DC::Item::update_widgets $_; |
1180 | |
1222 | |
… | |
… | |
1207 | sub set_opencont { |
1249 | sub set_opencont { |
1208 | my ($conn, $tag, $name) = @_; |
1250 | my ($conn, $tag, $name) = @_; |
1209 | $conn->{open_container} = $tag; |
1251 | $conn->{open_container} = $tag; |
1210 | update_floorbox; |
1252 | update_floorbox; |
1211 | |
1253 | |
1212 | $::INVR_HB->clear (); |
1254 | $::INVR_HB->clear; |
1213 | $::INVR_HB->add (new DC::UI::Label expand => 1, text => $name); |
1255 | $::INVR_HB->add (new DC::UI::Label expand => 1, text => $name); |
1214 | |
1256 | |
1215 | if ($tag != 0) { # Floor isn't closable, is it? |
1257 | if ($tag != 0) { # Floor isn't closable, is it? |
1216 | $::INVR_HB->add (new DC::UI::Button |
1258 | $::INVR_HB->add (new DC::UI::Button |
1217 | text => "Close container", |
1259 | text => "Close container", |
… | |
… | |
1273 | } |
1315 | } |
1274 | |
1316 | |
1275 | sub item_update { |
1317 | sub item_update { |
1276 | my ($self, $item) = @_; |
1318 | my ($self, $item) = @_; |
1277 | |
1319 | |
1278 | #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; |
1320 | #print "item_update: $item->{tag} in $item->{container} pt($self->{player}{tag}) oc($::CONN->{open_container}) f($item->{flags})\n"; |
1279 | |
1321 | |
1280 | DC::Item::update_widgets $item; |
1322 | DC::Item::update_widgets $item; |
1281 | |
1323 | |
1282 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
1324 | if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { |
1283 | set_opencont ($::CONN, 0, "Floor"); |
1325 | set_opencont ($::CONN, 0, "Floor"); |
1284 | |
1326 | |
1285 | } elsif ($item->{flags} & F_OPEN) { |
1327 | } elsif ($item->{flags} & F_OPEN) { |
1286 | set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item); |
1328 | set_opencont ($::CONN, $item->{tag}, DC::Item::desc_string $item); |
… | |
… | |
1352 | |
1394 | |
1353 | $self->update_server_info; |
1395 | $self->update_server_info; |
1354 | |
1396 | |
1355 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1397 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1356 | $self->send_command ("pickup $::CFG->{pickup}"); |
1398 | $self->send_command ("pickup $::CFG->{pickup}"); |
|
|
1399 | |
|
|
1400 | $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]", |
|
|
1401 | DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d# |
1357 | } |
1402 | } |
1358 | |
1403 | |
1359 | sub lookat { |
1404 | sub lookat { |
1360 | my ($self, $x, $y) = @_; |
1405 | my ($self, $x, $y) = @_; |
1361 | |
1406 | |
… | |
… | |
1525 | } |
1570 | } |
1526 | |
1571 | |
1527 | sub send { |
1572 | sub send { |
1528 | my ($self, $msg) = @_; |
1573 | my ($self, $msg) = @_; |
1529 | |
1574 | |
1530 | $self->{textview}->add_paragraph ({ markup => "\n" . DC::asxml $msg }); |
1575 | $self->{textview}->add_paragraph ({ |
|
|
1576 | markup => |
|
|
1577 | "\n<span foreground='#ffff00'><b>" |
|
|
1578 | . (DC::asxml $msg) |
|
|
1579 | . "</b></span>" |
|
|
1580 | }); |
1531 | $self->{textview}->scroll_to_bottom; |
1581 | $self->{textview}->scroll_to_bottom; |
1532 | |
1582 | |
1533 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1583 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1534 | } |
1584 | } |
1535 | |
1585 | |