… | |
… | |
58 | }); |
58 | }); |
59 | |
59 | |
60 | $self->connect_ext (capabilities => sub { |
60 | $self->connect_ext (capabilities => sub { |
61 | my (%cap) = @_; |
61 | my (%cap) = @_; |
62 | |
62 | |
|
|
63 | #$self->send ("setup sound 0"); # we use a different protocol |
|
|
64 | |
63 | $self->send_exti_msg (fx_want => { |
65 | $self->send_exti_msg (fx_want => { |
64 | 3 => !!$::CFG->{bgm_enable}, # FT_MUSIC |
66 | 3 => !!$::CFG->{bgm_enable}, # FT_MUSIC |
65 | 5 => !!$::CFG->{audio_enable}, # FT_SOUND |
67 | #5 => !!$::CFG->{audio_enable}, # FT_SOUND |
66 | }); |
68 | }); |
67 | |
69 | |
68 | if (my $ts = $cap{tileset}) { |
70 | if (my $ts = $cap{tileset}) { |
69 | if (my ($default) = grep $_->[2] & 1, @$ts) { |
71 | if (my ($default) = grep $_->[2] & 1, @$ts) { |
70 | $self->{tileset} = $default; |
72 | $self->{tileset} = $default; |
… | |
… | |
183 | |
185 | |
184 | my $w = $self->{widget}{$id} |
186 | my $w = $self->{widget}{$id} |
185 | or return; |
187 | or return; |
186 | |
188 | |
187 | $self->send_exti_msg (w_r => $rid, [map $w->{$_}, @$attr]); |
189 | $self->send_exti_msg (w_r => $rid, [map $w->{$_}, @$attr]); |
|
|
190 | }); |
|
|
191 | |
|
|
192 | # message window |
|
|
193 | $self->connect_ext (channel_info => sub { |
|
|
194 | my ($info) = @_; |
|
|
195 | $self->{channels}->{$info->{id}} = $info; |
|
|
196 | $::MESSAGE_WINDOW->add_channel ($info); |
188 | }); |
197 | }); |
189 | |
198 | |
190 | # destroy widgets on logout |
199 | # destroy widgets on logout |
191 | $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { |
200 | $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { |
192 | for my $ws (values %{delete $self->{widgetset} || {}}) { |
201 | for my $ws (values %{delete $self->{widgetset} || {}}) { |
… | |
… | |
753 | |
762 | |
754 | &::audio_music_set ($self->{songs}); |
763 | &::audio_music_set ($self->{songs}); |
755 | }; |
764 | }; |
756 | } |
765 | } |
757 | |
766 | |
|
|
767 | my $path = CFPlus::DB::path_of_res $face->{name}; |
|
|
768 | |
758 | if ($changed) { # new data |
769 | if ($changed) { # new data |
759 | my ($meta_json, $data) = unpack "(w/a*)*", delete $face->{data}; |
770 | my ($meta_json, $data) = unpack "(w/a*)*", delete $face->{data}; |
760 | my $path = CFPlus::DB::path_of_res $face->{name}; |
|
|
761 | |
771 | |
762 | CFPlus::DB::write_file $path, $data, sub { |
772 | CFPlus::DB::write_file $path, $data, sub { |
763 | CFPlus::DB::put "res-metadata" => $face->{name} => $meta_json, sub { |
773 | CFPlus::DB::put "res-metadata" => $face->{name} => $meta_json, sub { |
764 | $face->{meta} = $self->{json_coder}->decode ($meta_json); |
774 | $face->{meta} = $self->{json_coder}->decode ($meta_json); |
765 | $face->{path} = $path; |
775 | $face->{path} = $path; |
… | |
… | |
767 | $cb->(); |
777 | $cb->(); |
768 | }; |
778 | }; |
769 | }; |
779 | }; |
770 | } else { |
780 | } else { |
771 | $face->{meta} = $self->{json_coder}->decode (delete $face->{data}); |
781 | $face->{meta} = $self->{json_coder}->decode (delete $face->{data}); |
|
|
782 | $face->{path} = $path; |
772 | $cb->(); |
783 | $cb->(); |
773 | } |
784 | } |
774 | } |
785 | } |
775 | } |
786 | } |
776 | |
787 | |
… | |
… | |
807 | } |
818 | } |
808 | } |
819 | } |
809 | |
820 | |
810 | sub sound_play { |
821 | sub sound_play { |
811 | my ($self, $x, $y, $soundnum, $type) = @_; |
822 | my ($self, $x, $y, $soundnum, $type) = @_; |
|
|
823 | warn "sound play <@_>\n";#d# |
812 | |
824 | |
813 | $self->{sound_play}->($x, $y, $soundnum, $type); |
825 | #$self->{sound_play}->($x, $y, $soundnum, $type); |
814 | } |
826 | } |
815 | |
827 | |
816 | my $LAST_QUERY; # server is stupid, stupid, stupid |
828 | my $LAST_QUERY; # server is stupid, stupid, stupid |
817 | |
829 | |
818 | sub query { |
830 | sub query { |
… | |
… | |
883 | $self->{$type} = $text; |
895 | $self->{$type} = $text; |
884 | } else { |
896 | } else { |
885 | $self->logprint ("msg: ", $text); |
897 | $self->logprint ("msg: ", $text); |
886 | return if $color < 0; # negative color == ignore if not understood |
898 | return if $color < 0; # negative color == ignore if not understood |
887 | |
899 | |
888 | my $fg = $CF_COLOR[$color % @CF_COLOR]; |
900 | my $fg = $CF_COLOR[$color & 0x1f] || [1, 0, 0]; |
889 | |
901 | |
890 | ## try to create single paragraphs of multiple lines sent by the server |
902 | ## try to create single paragraphs of multiple lines sent by the server |
891 | # no longer neecssary with TRT servers |
903 | # no longer neecssary with TRT servers |
892 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
904 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
893 | |
905 | |
894 | ::message ({ fg => $fg, markup => $_ }) |
906 | ::message ({ fg => $fg, markup => $_, type => $type, extra => [@extra] }) |
895 | for split /\n/, $text; |
907 | for split /\n/, $text; |
896 | |
908 | |
897 | $self->{statusbox}->add ($text, |
909 | $self->{statusbox}->add ($text, |
898 | group => $text, |
910 | group => $text, |
899 | fg => $fg, |
911 | fg => $fg, |
… | |
… | |
1155 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
1167 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
1156 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
1168 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
1157 | . "map size $self->{mapw}×$self->{maph}\n" |
1169 | . "map size $self->{mapw}×$self->{maph}\n" |
1158 | ); |
1170 | ); |
1159 | |
1171 | |
1160 | ::setup_build_button ($self->{editor_support}->{builder_ui}); |
|
|
1161 | } |
1172 | } |
1162 | |
1173 | |
1163 | sub logged_in { |
1174 | sub logged_in { |
1164 | my ($self) = @_; |
1175 | my ($self) = @_; |
1165 | |
1176 | |
… | |
… | |
1185 | |
1196 | |
1186 | $self->send_command ("output-sync $::CFG->{output_sync}"); |
1197 | $self->send_command ("output-sync $::CFG->{output_sync}"); |
1187 | $self->send_command ("output-count $::CFG->{output_count}"); |
1198 | $self->send_command ("output-count $::CFG->{output_count}"); |
1188 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1199 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1189 | $self->send_command ("pickup $::CFG->{pickup}"); |
1200 | $self->send_command ("pickup $::CFG->{pickup}"); |
1190 | } |
|
|
1191 | |
|
|
1192 | sub buildat { |
|
|
1193 | my ($self, $builditem, $x, $y) = @_; |
|
|
1194 | |
|
|
1195 | if ($self->{cfplus_ext}) { |
|
|
1196 | $self->send_ext_msg (builder_build => dx => $x, dy => $y, (ref ($builditem) eq 'HASH') ? %$builditem : (item => $builditem)); |
|
|
1197 | } |
|
|
1198 | } |
1201 | } |
1199 | |
1202 | |
1200 | sub lookat { |
1203 | sub lookat { |
1201 | my ($self, $x, $y) = @_; |
1204 | my ($self, $x, $y) = @_; |
1202 | |
1205 | |