… | |
… | |
113 | our $CONN; |
113 | our $CONN; |
114 | our $PROFILE; # current profile |
114 | our $PROFILE; # current profile |
115 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
115 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
116 | |
116 | |
117 | our $WANT_REFRESH; |
117 | our $WANT_REFRESH; |
118 | our $CAN_REFRESH; |
|
|
119 | |
118 | |
120 | our @SDL_MODES; |
119 | our @SDL_MODES; |
121 | our $WIDTH; |
120 | our $WIDTH; |
122 | our $HEIGHT; |
121 | our $HEIGHT; |
123 | our $FULLSCREEN; |
122 | our $FULLSCREEN; |
… | |
… | |
144 | our $SETUP_KEYBOARD; |
143 | our $SETUP_KEYBOARD; |
145 | |
144 | |
146 | our $PL_NOTEBOOK; |
145 | our $PL_NOTEBOOK; |
147 | our $PL_WINDOW; |
146 | our $PL_WINDOW; |
148 | |
147 | |
|
|
148 | our $MUSIC_PLAYING_WIDGET; |
|
|
149 | our $LICENSE_WIDGET; |
|
|
150 | |
149 | our $INVENTORY_PAGE; |
151 | our $INVENTORY_PAGE; |
150 | our $STATS_PAGE; |
152 | our $STATS_PAGE; |
151 | our $SKILL_PAGE; |
153 | our $SKILL_PAGE; |
152 | our $SPELL_PAGE; |
154 | our $SPELL_PAGE; |
153 | our $SPELL_LIST; |
155 | our $SPELL_LIST; |
… | |
… | |
159 | our $STATWIDS; |
161 | our $STATWIDS; |
160 | |
162 | |
161 | our $SDL_ACTIVE; |
163 | our $SDL_ACTIVE; |
162 | our %SDL_CB; |
164 | our %SDL_CB; |
163 | |
165 | |
|
|
166 | our $ALT_ENTER_MESSAGE; |
|
|
167 | our $STATUSBOX; |
|
|
168 | our $DEBUG_STATUS; |
|
|
169 | |
|
|
170 | our $INV; |
|
|
171 | our $INVR; |
|
|
172 | our $INVR_HB; |
|
|
173 | |
|
|
174 | ############################################################################# |
|
|
175 | |
|
|
176 | sub status { |
|
|
177 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
|
|
178 | } |
|
|
179 | |
|
|
180 | sub debug { |
|
|
181 | $DEBUG_STATUS->set_text ($_[0]); |
|
|
182 | } |
|
|
183 | |
|
|
184 | sub message { |
|
|
185 | my ($para) = @_; |
|
|
186 | $MESSAGE_WINDOW->message ($para); |
|
|
187 | } |
|
|
188 | |
|
|
189 | ############################################################################# |
|
|
190 | #TODO: maybe move into own audio module... |
|
|
191 | |
164 | our $SDL_MIXER; |
192 | our $SDL_MIXER; |
|
|
193 | |
165 | our $MUSIC_DEFAULT = "in_a_heartbeat.ogg"; |
194 | our $MUSIC_DEFAULT = "in_a_heartbeat.ogg"; |
166 | our @MUSIC_WANT; |
195 | our $MUSIC_WANT; # arryref of ambient music we want to play |
|
|
196 | our @MUSIC_HAVE; # ambient music we have on disk |
167 | our $MUSIC_START; |
197 | our $MUSIC_START; |
|
|
198 | our @MUSIC_JINGLE; # which jingles to play next |
168 | our $MUSIC_PLAYING_DATA; |
199 | our $MUSIC_PLAYING_DATA; |
169 | our $MUSIC_PLAYING_META; |
200 | our $MUSIC_PLAYING_META; |
170 | our $MUSIC_PLAYER; |
201 | our $MUSIC_PLAYER; |
171 | our $MUSIC_RESUME = 30; # resume music when players less than these many seconds before |
202 | our $MUSIC_RESUME = 30; # resume music when played less than these many seconds before |
172 | our @SOUNDS; # event => file mapping |
203 | |
173 | our %AUDIO_CHUNK; # audio files |
204 | our %AUDIO_CHUNK; # audio "files" |
|
|
205 | our %AUDIO_PLAY; # which audio faces should be played |
174 | |
206 | |
175 | our $ALT_ENTER_MESSAGE; |
207 | sub audio_channel_finished { |
176 | our $STATUSBOX; |
208 | my ($channel) = @_; |
177 | our $DEBUG_STATUS; |
|
|
178 | |
209 | |
179 | our $INV; |
210 | # warn "channel $channel finished\n";#d# |
180 | our $INVR; |
|
|
181 | our $INV_RIGHT_HB; |
|
|
182 | |
|
|
183 | our $PICKUP_CFG; |
|
|
184 | |
|
|
185 | sub status { |
|
|
186 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
|
|
187 | } |
211 | } |
188 | |
212 | |
189 | sub debug { |
213 | sub audio_sound_push($) { |
190 | $DEBUG_STATUS->set_text ($_[0]); |
|
|
191 | } |
|
|
192 | |
|
|
193 | sub message { |
|
|
194 | my ($para) = @_; |
214 | my ($face) = @_; |
195 | $MESSAGE_WINDOW->message ($para); |
215 | |
|
|
216 | $CFG->{effects_enable} |
|
|
217 | or return; |
|
|
218 | |
|
|
219 | $AUDIO_PLAY{$face} |
|
|
220 | or return; |
|
|
221 | |
|
|
222 | if (my $chunk = $AUDIO_CHUNK{$face}) { |
|
|
223 | for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { |
|
|
224 | my (undef, $dx, $dy, $vol) = @$_; |
|
|
225 | |
|
|
226 | my $channel = CFPlus::Channel::find; |
|
|
227 | $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); |
|
|
228 | $channel->set_position_r ($dx, $dy, 20); |
|
|
229 | $chunk->play ($channel); |
|
|
230 | } |
|
|
231 | } else { |
|
|
232 | # sound_meta not set means data is in flight either way |
|
|
233 | my $meta = $CONN->{sound_meta}{$face} |
|
|
234 | or return; |
|
|
235 | |
|
|
236 | # if its a jingle, play it as ambient music |
|
|
237 | if ($meta->{meta}{jingle}) { |
|
|
238 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
|
|
239 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
|
|
240 | &audio_music_push ($face); |
|
|
241 | } |
|
|
242 | } else { |
|
|
243 | # fetch from database |
|
|
244 | CFPlus::DB::get res_data => $meta->{name}, sub { |
|
|
245 | my $rwops = new CFPlus::RW $_[0]; |
|
|
246 | my $chunk = new CFPlus::MixChunk $rwops |
|
|
247 | or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
|
|
248 | $chunk->volume (($meta->{meta}{volume} || 1) * 128); |
|
|
249 | $AUDIO_CHUNK{$face} = $chunk; |
|
|
250 | |
|
|
251 | audio_sound_push ($face); |
|
|
252 | }; |
|
|
253 | } |
|
|
254 | } |
196 | } |
255 | } |
|
|
256 | |
|
|
257 | sub audio_sound_play { |
|
|
258 | my ($face, $dx, $dy, $vol) = @_; |
|
|
259 | |
|
|
260 | $SDL_MIXER |
|
|
261 | or return; |
|
|
262 | $CFG->{effects_enable} |
|
|
263 | or return; |
|
|
264 | |
|
|
265 | my $queue = $AUDIO_PLAY{$face} ||= []; |
|
|
266 | push @$queue, [Event::time + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events |
|
|
267 | audio_sound_push $face |
|
|
268 | unless @$queue > 1; |
|
|
269 | } |
|
|
270 | |
|
|
271 | sub audio_music_set_meta { |
|
|
272 | my ($meta) = @_; |
|
|
273 | |
|
|
274 | $MUSIC_PLAYING_META = $meta; |
|
|
275 | $MUSIC_PLAYING_WIDGET->set_markup ( |
|
|
276 | "<b>Name</b>: " . (CFPlus::asxml $meta->{meta}{name}) . "\n" |
|
|
277 | . "<b>Author</b>: " . (CFPlus::asxml $meta->{meta}{author}) . "\n" |
|
|
278 | . "<b>Source</b>: " . (CFPlus::asxml $meta->{meta}{source}) . "\n" |
|
|
279 | . "<b>License</b>: " . (CFPlus::asxml $meta->{meta}{license}) |
|
|
280 | ); |
|
|
281 | } |
|
|
282 | |
|
|
283 | sub audio_music_update_volume { |
|
|
284 | return unless $MUSIC_PLAYING_META; |
|
|
285 | my $volume = $MUSIC_PLAYING_META->{meta}{volume} || 1; |
|
|
286 | my $base = $MUSIC_PLAYING_META->{meta}{jingle} ? 1 : $CFG->{bgm_volume}; |
|
|
287 | CFPlus::MixMusic::volume $base * $volume * 128; |
|
|
288 | } |
|
|
289 | |
|
|
290 | sub audio_music_start { |
|
|
291 | my $meta = $MUSIC_PLAYING_META; |
|
|
292 | |
|
|
293 | CFPlus::DB::get res_data => $meta->{name}, sub { |
|
|
294 | return unless $SDL_MIXER; |
|
|
295 | |
|
|
296 | # music might have changed... |
|
|
297 | $meta eq $MUSIC_PLAYING_META |
|
|
298 | or return &audio_music_start (); |
|
|
299 | |
|
|
300 | audio_music_update_volume; |
|
|
301 | |
|
|
302 | $MUSIC_PLAYING_DATA = \$_[0]; |
|
|
303 | |
|
|
304 | my $rwops = $meta->{path} |
|
|
305 | ? new_from_file CFPlus::RW $meta->{path} |
|
|
306 | : new CFPlus::RW $$MUSIC_PLAYING_DATA; |
|
|
307 | |
|
|
308 | $MUSIC_PLAYER = new CFPlus::MixMusic $rwops |
|
|
309 | or Carp::confess "music face $meta->{face} unloadable: " . CFPlus::Mix_GetError; |
|
|
310 | |
|
|
311 | my $NOW = time; |
|
|
312 | |
|
|
313 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
|
|
314 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
|
|
315 | $MUSIC_PLAYER->fade_in_pos (0, 1000, $pos); |
|
|
316 | $MUSIC_START = time - $pos; |
|
|
317 | } else { |
|
|
318 | $MUSIC_PLAYER->play (0); |
|
|
319 | $MUSIC_START = time; |
|
|
320 | } |
|
|
321 | |
|
|
322 | delete $meta->{stop_time}; |
|
|
323 | delete $meta->{stop_pos}; |
|
|
324 | } |
|
|
325 | } |
|
|
326 | |
|
|
327 | sub audio_music_push { |
|
|
328 | return unless $SDL_MIXER; |
|
|
329 | |
|
|
330 | my $fade_out; |
|
|
331 | |
|
|
332 | if (@MUSIC_JINGLE) { |
|
|
333 | @MUSIC_HAVE = $MUSIC_JINGLE[0]; |
|
|
334 | $fade_out = 333; |
|
|
335 | } else { |
|
|
336 | return unless $CFG->{bgm_enable}; |
|
|
337 | |
|
|
338 | my @have = |
|
|
339 | grep $_, |
|
|
340 | map $CONN->{music_meta}{$_}, |
|
|
341 | @$MUSIC_WANT; |
|
|
342 | |
|
|
343 | @MUSIC_HAVE = @have |
|
|
344 | if @have; |
|
|
345 | |
|
|
346 | # default MUSIC_HAVE == MUSIC_DEFAULT |
|
|
347 | @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; |
|
|
348 | $fade_out = 1000; |
|
|
349 | } |
|
|
350 | |
|
|
351 | # if the currently playing song is acceptable, let it continue |
|
|
352 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
|
|
353 | |
|
|
354 | my $NOW = time; |
|
|
355 | |
|
|
356 | if ($MUSIC_PLAYING_META) { |
|
|
357 | $MUSIC_PLAYING_META->{stop_time} = $NOW; |
|
|
358 | $MUSIC_PLAYING_META->{stop_pos} = $NOW - $MUSIC_START; |
|
|
359 | CFPlus::MixMusic::fade_out $fade_out; |
|
|
360 | } else { |
|
|
361 | # sort by stop time, oldest first |
|
|
362 | @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; |
|
|
363 | |
|
|
364 | # if the most recently-played piece played very recently, |
|
|
365 | # resume it, else choose the oldest piece for rotation. |
|
|
366 | audio_music_set_meta |
|
|
367 | $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME |
|
|
368 | ? $MUSIC_HAVE[-1] |
|
|
369 | : $MUSIC_HAVE[0]; |
|
|
370 | |
|
|
371 | audio_music_start; |
|
|
372 | } |
|
|
373 | } |
|
|
374 | |
|
|
375 | sub audio_music_set_ambient { |
|
|
376 | my ($songs) = @_; |
|
|
377 | |
|
|
378 | $MUSIC_WANT = $songs; |
|
|
379 | audio_music_push; |
|
|
380 | } |
|
|
381 | |
|
|
382 | sub audio_music_finished { |
|
|
383 | # we compress multiple jingles of the same type |
|
|
384 | shift @MUSIC_JINGLE |
|
|
385 | while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0]; |
|
|
386 | |
|
|
387 | $MUSIC_PLAYING_WIDGET->clear; |
|
|
388 | |
|
|
389 | undef $MUSIC_PLAYER; |
|
|
390 | undef $MUSIC_PLAYING_META; |
|
|
391 | undef $MUSIC_PLAYING_DATA; |
|
|
392 | |
|
|
393 | audio_music_push; |
|
|
394 | } |
|
|
395 | |
|
|
396 | sub audio_init { |
|
|
397 | if ($CFG->{audio_enable}) { |
|
|
398 | $ENV{MIX_EFFECTSMAXSPEED} = 1; |
|
|
399 | $SDL_MIXER = !CFPlus::Mix_OpenAudio; |
|
|
400 | |
|
|
401 | unless ($SDL_MIXER) { |
|
|
402 | status "Unable to open sound device: there will be no sound"; |
|
|
403 | return; |
|
|
404 | } |
|
|
405 | |
|
|
406 | CFPlus::Mix_AllocateChannels 16; |
|
|
407 | |
|
|
408 | audio_music_finished; |
|
|
409 | } else { |
|
|
410 | undef $SDL_MIXER; |
|
|
411 | } |
|
|
412 | } |
|
|
413 | |
|
|
414 | sub audio_shutdown { |
|
|
415 | undef $MUSIC_PLAYER; |
|
|
416 | undef $MUSIC_PLAYING_META; |
|
|
417 | undef $MUSIC_PLAYING_DATA; |
|
|
418 | |
|
|
419 | $MUSIC_WANT = []; |
|
|
420 | @MUSIC_JINGLE = (); |
|
|
421 | %AUDIO_PLAY = (); |
|
|
422 | %AUDIO_CHUNK = (); |
|
|
423 | |
|
|
424 | CFPlus::Mix_CloseAudio if $SDL_MIXER; |
|
|
425 | undef $SDL_MIXER; |
|
|
426 | } |
|
|
427 | |
|
|
428 | ############################################################################# |
197 | |
429 | |
198 | sub destroy_query_dialog { |
430 | sub destroy_query_dialog { |
199 | (delete $_[0]{query_dialog})->destroy |
431 | (delete $_[0]{query_dialog})->destroy |
200 | if $_[0]{query_dialog}; |
432 | if $_[0]{query_dialog}; |
201 | } |
433 | } |
… | |
… | |
535 | state => $CFG->{fullscreen}, |
767 | state => $CFG->{fullscreen}, |
536 | tooltip => "Bring the client into fullscreen mode.", |
768 | tooltip => "Bring the client into fullscreen mode.", |
537 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
769 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
538 | ); |
770 | ); |
539 | |
771 | |
|
|
772 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1"); |
|
|
773 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
|
|
774 | state => $CFG->{opengl11}, |
|
|
775 | tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in " |
|
|
776 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
|
|
777 | . "cards that claim to support a feature but fall back to software rendering. " |
|
|
778 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
|
|
779 | . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " |
|
|
780 | . "experience extremely low framerates and your card should do better, try this option.</b>", |
|
|
781 | on_changed => sub { my ($self, $value) = @_; $CFG->{opengl11} = $value; 0 } |
|
|
782 | ); |
|
|
783 | |
540 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
784 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
541 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
785 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
542 | state => $CFG->{fast}, |
786 | state => $CFG->{fast}, |
543 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
787 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
544 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
788 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
… | |
… | |
570 | |
814 | |
571 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); |
815 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); |
572 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
816 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
573 | state => $CFG->{map_smoothing}, |
817 | state => $CFG->{map_smoothing}, |
574 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
818 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
575 | . "This increases load on the graphics subsystem and works only with 2.x servers. " |
819 | . "This increases load on the graphics subsystem and works only with TRT servers. " |
576 | . "Changes take effect at next connection only.", |
820 | . "Changes take effect at next login only.", |
577 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
821 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
578 | ); |
822 | ); |
579 | |
823 | |
580 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
824 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
581 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
825 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
… | |
… | |
592 | ); |
836 | ); |
593 | |
837 | |
594 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
838 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
595 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
839 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
596 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
840 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
597 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", |
841 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant, " |
|
|
842 | . "but you still need to press apply to correctly re-layout the widget.", |
598 | on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
843 | on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
599 | ); |
844 | ); |
600 | |
845 | |
601 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
846 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
602 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
847 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
… | |
… | |
624 | } |
869 | } |
625 | |
870 | |
626 | sub audio_setup { |
871 | sub audio_setup { |
627 | my $vbox = new CFPlus::UI::VBox; |
872 | my $vbox = new CFPlus::UI::VBox; |
628 | |
873 | |
629 | $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); |
874 | $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1]); |
630 | |
875 | |
631 | my $row = 0; |
876 | my $row = 0; |
632 | |
877 | |
633 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Audio Enable"); |
878 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Audio Enable"); |
634 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
879 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
… | |
… | |
638 | ); |
883 | ); |
639 | # $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
884 | # $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
640 | # $table->add_at (1, 8, new CFPlus::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub { |
885 | # $table->add_at (1, 8, new CFPlus::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub { |
641 | # $CFG->{effects_volume} = $_[1]; |
886 | # $CFG->{effects_volume} = $_[1]; |
642 | # }); |
887 | # }); |
|
|
888 | |
|
|
889 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects"); |
|
|
890 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
|
|
891 | expand => 1, state => $CFG->{effects_enable}, |
|
|
892 | tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", |
|
|
893 | on_changed => sub { |
|
|
894 | $CFG->{effects_enable} = $_[1]; |
|
|
895 | $CONN->update_fx_want if $CONN; |
|
|
896 | 0 |
|
|
897 | } |
|
|
898 | ); |
|
|
899 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
|
|
900 | expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], |
|
|
901 | tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " |
|
|
902 | . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.", |
|
|
903 | on_changed => sub { $CFG->{effects_volume} = $_[1]; 0 } |
|
|
904 | ); |
|
|
905 | |
643 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); |
906 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); |
644 | $table->add_at (1, $row++, my $hbox = new CFPlus::UI::HBox); |
907 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
645 | $hbox->add (new CFPlus::UI::CheckBox |
|
|
646 | expand => 1, state => $CFG->{bgm_enable}, |
908 | expand => 1, state => $CFG->{bgm_enable}, |
647 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
909 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
648 | on_changed => sub { $CFG->{bgm_enable} = $_[1]; 0 } |
910 | on_changed => sub { |
|
|
911 | $CFG->{bgm_enable} = $_[1]; |
|
|
912 | $CONN->update_fx_want if $CONN; |
|
|
913 | 0 |
|
|
914 | } |
649 | ); |
915 | ); |
650 | $hbox->add (new CFPlus::UI::Slider |
916 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
651 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
917 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
652 | tooltip => "The volume of the background music. Changes are instant.", |
918 | tooltip => "The volume of the background music. Changes are instant.", |
653 | on_changed => sub { $CFG->{bgm_volume} = $_[1]; CFPlus::MixMusic::volume $_[1] * 128; 0 } |
919 | on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } |
654 | ); |
920 | ); |
655 | |
921 | |
656 | $table->add_at (1, $row++, new CFPlus::UI::Button |
922 | $table->add_at (1, $row++, new CFPlus::UI::Button |
657 | expand => 1, align => 0, text => "Apply", |
923 | c_colspan => 2, expand => 1, align => 0, text => "Apply", |
658 | tooltip => "Apply the audio settings", |
924 | tooltip => "Apply the audio settings", |
659 | on_activate => sub { |
925 | on_activate => sub { |
660 | audio_shutdown (); |
926 | audio_shutdown (); |
661 | audio_init (); |
927 | audio_init (); |
662 | 0 |
928 | 0 |
… | |
… | |
733 | $table->add_at (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } ); |
999 | $table->add_at (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } ); |
734 | |
1000 | |
735 | $table->add_at (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d# |
1001 | $table->add_at (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d# |
736 | |
1002 | |
737 | $table->add_at (7,7, my $t = new CFPlus::UI::Table expand => 0); |
1003 | $table->add_at (7,7, my $t = new CFPlus::UI::Table expand => 0); |
738 | $t->add_at (0,0, new CFPlus::UI::Label text => "a a a a", rowspan => 1, colspan => 2); |
1004 | $t->add_at (0,0, new CFPlus::UI::Label text => "a a a a", c_rowspan => 1, c_colspan => 2); |
739 | $t->add_at (2,0, new CFPlus::UI::Label text => "b\nb", rowspan => 2, colspan => 1); |
1005 | $t->add_at (2,0, new CFPlus::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1); |
740 | $t->add_at (1,2, new CFPlus::UI::Label text => "c c c c", rowspan => 1, colspan => 2); |
1006 | $t->add_at (1,2, new CFPlus::UI::Label text => "c c c c", c_rowspan => 1, c_colspan => 2); |
741 | $t->add_at (0,1, new CFPlus::UI::Label text => "d\nd", rowspan => 2, colspan => 1); |
1007 | $t->add_at (0,1, new CFPlus::UI::Label text => "d\nd", c_rowspan => 2, c_colspan => 1); |
742 | $t->add_at (1,1, new CFPlus::UI::Label text => "e"); |
1008 | $t->add_at (1,1, new CFPlus::UI::Label text => "e"); |
743 | |
1009 | |
744 | $table->add_at (7, 6, my $c = new CFPlus::UI::Canvas); |
1010 | $table->add_at (7, 6, my $c = new CFPlus::UI::Canvas); |
745 | |
1011 | |
746 | $c->add_items ({ |
1012 | $c->add_items ({ |
… | |
… | |
1342 | $sw1->add ($INV = new CFPlus::UI::Inventory); |
1608 | $sw1->add ($INV = new CFPlus::UI::Inventory); |
1343 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
1609 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
1344 | |
1610 | |
1345 | $hb->add (my $vb2 = new CFPlus::UI::VBox); |
1611 | $hb->add (my $vb2 = new CFPlus::UI::VBox); |
1346 | |
1612 | |
1347 | $vb2->add ($INV_RIGHT_HB = new CFPlus::UI::HBox); |
1613 | $vb2->add ($INVR_HB = new CFPlus::UI::HBox); |
1348 | |
1614 | |
1349 | $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1615 | $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1350 | $sw2->add ($INVR = new CFPlus::UI::Inventory); |
1616 | $sw2->add ($INVR = new CFPlus::UI::Inventory); |
1351 | |
1617 | |
1352 | # XXX: Call after $INVR = ... because set_opencont sets the items |
1618 | # XXX: Call after $INVR = ... because set_opencont sets the items |
1353 | CFPlus::Protocol::set_opencont ($::CONN, 0, "Floor"); |
1619 | CFPlus::Protocol::set_opencont ($::CONN, 0, "Floor"); |
1354 | |
1620 | |
1355 | $hb |
1621 | $hb |
|
|
1622 | } |
|
|
1623 | |
|
|
1624 | sub media_window { |
|
|
1625 | my $vb = new CFPlus::UI::VBox; |
|
|
1626 | |
|
|
1627 | $vb->add (new CFPlus::UI::FancyFrame |
|
|
1628 | label => "Currently playing music", |
|
|
1629 | child => new CFPlus::UI::ScrolledWindow scroll_x => 1, scroll_y => 0, |
|
|
1630 | child => ($MUSIC_PLAYING_WIDGET = new CFPlus::UI::Label ellipsise => 0, fontsize => 0.8), |
|
|
1631 | ); |
|
|
1632 | |
|
|
1633 | $vb->add (new CFPlus::UI::FancyFrame |
|
|
1634 | label => "Other media used in this session", |
|
|
1635 | expand => 1, |
|
|
1636 | child => ($LICENSE_WIDGET = new CFPlus::UI::TextScroller |
|
|
1637 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4), |
|
|
1638 | ); |
|
|
1639 | |
|
|
1640 | $vb |
|
|
1641 | } |
|
|
1642 | |
|
|
1643 | sub add_license { |
|
|
1644 | my ($meta) = @_; |
|
|
1645 | |
|
|
1646 | $meta = $meta->{meta} |
|
|
1647 | or return; |
|
|
1648 | |
|
|
1649 | $meta->{license} || $meta->{author} || $meta->{source} |
|
|
1650 | or return; |
|
|
1651 | |
|
|
1652 | $LICENSE_WIDGET->add_paragraph ({ |
|
|
1653 | fg => [1, 1, 1, 1], |
|
|
1654 | markup => "<small>" |
|
|
1655 | . "<b>Name:</b> " . (CFPlus::asxml $meta->{name}) . "\n" |
|
|
1656 | . "<b>Author:</b> " . (CFPlus::asxml $meta->{author}) . "\n" |
|
|
1657 | . "<b>Source:</b> " . (CFPlus::asxml $meta->{source}) . "\n" |
|
|
1658 | . "<b>License:</b> " . (CFPlus::asxml $meta->{license}) . "\n" |
|
|
1659 | . "</small>", |
|
|
1660 | }); |
|
|
1661 | $LICENSE_WIDGET->scroll_to_bottom; |
1356 | } |
1662 | } |
1357 | |
1663 | |
1358 | sub toggle_player_page { |
1664 | sub toggle_player_page { |
1359 | my ($widget) = @_; |
1665 | my ($widget) = @_; |
1360 | |
1666 | |
… | |
… | |
1399 | $ntb->add_tab ( |
1705 | $ntb->add_tab ( |
1400 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1706 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1401 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1707 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1402 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1708 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1403 | ); |
1709 | ); |
1404 | $ntb->add_tab (Pickup => autopickup_setup, |
1710 | $ntb->add_tab (Pickup => autopickup_setup, |
1405 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1711 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
|
|
1712 | |
|
|
1713 | $ntb->add_tab (Media => media_window, |
|
|
1714 | "License, Author and Source info for media sent by the server."); |
1406 | |
1715 | |
1407 | $ntb->set_current_page ($INVENTORY_PAGE); |
1716 | $ntb->set_current_page ($INVENTORY_PAGE); |
1408 | |
1717 | |
1409 | $plwin->add ($ntb); |
1718 | $plwin->add ($ntb); |
1410 | $plwin |
1719 | $plwin |
… | |
… | |
1564 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
1873 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
1565 | ); |
1874 | ); |
1566 | $hb->add (new CFPlus::UI::Button |
1875 | $hb->add (new CFPlus::UI::Button |
1567 | text => "Quit anyway", |
1876 | text => "Quit anyway", |
1568 | expand => 1, |
1877 | expand => 1, |
1569 | on_activate => sub { exit }, |
1878 | on_activate => sub { Event::unloop_all }, |
1570 | ); |
1879 | ); |
1571 | } |
1880 | } |
1572 | |
1881 | |
1573 | $QUIT_DIALOG->show; |
1882 | $QUIT_DIALOG->show; |
1574 | $QUIT_DIALOG->grab_focus; |
1883 | $QUIT_DIALOG->grab_focus; |
… | |
… | |
1768 | tooltip => "Terminates the program", |
2077 | tooltip => "Terminates the program", |
1769 | on_activate => sub { |
2078 | on_activate => sub { |
1770 | if ($CONN) { |
2079 | if ($CONN) { |
1771 | open_quit_dialog; |
2080 | open_quit_dialog; |
1772 | } else { |
2081 | } else { |
1773 | exit; |
2082 | Event::unloop_all; |
1774 | } |
2083 | } |
1775 | 0 |
2084 | 0 |
1776 | }, |
2085 | }, |
1777 | ); |
2086 | ); |
1778 | |
2087 | |
1779 | $BUTTONBAR->show; |
2088 | $BUTTONBAR->show; |
1780 | $SETUP_DIALOG->show; |
2089 | $SETUP_DIALOG->show; |
|
|
2090 | $MESSAGE_WINDOW->show; |
1781 | } |
2091 | } |
1782 | |
2092 | |
1783 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2093 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
1784 | } |
2094 | } |
1785 | |
2095 | |
… | |
… | |
1787 | CFPlus::OpenGL::shutdown; |
2097 | CFPlus::OpenGL::shutdown; |
1788 | |
2098 | |
1789 | undef $SDL_ACTIVE; |
2099 | undef $SDL_ACTIVE; |
1790 | } |
2100 | } |
1791 | |
2101 | |
1792 | sub audio_channel_finished { |
|
|
1793 | my ($channel) = @_; |
|
|
1794 | |
|
|
1795 | # warn "channel $channel finished\n";#d# |
|
|
1796 | } |
|
|
1797 | |
|
|
1798 | our %AUDIO_PLAY; |
|
|
1799 | our %AUDIO_CHUNK; |
|
|
1800 | |
|
|
1801 | sub audio_sound_push($) { |
|
|
1802 | my ($face) = @_; |
|
|
1803 | |
|
|
1804 | if (my $chunk = $AUDIO_CHUNK{$face}) { |
|
|
1805 | for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { |
|
|
1806 | my (undef, $dx, $dy, $vol) = @$_; |
|
|
1807 | |
|
|
1808 | my $channel = CFPlus::Channel::find; |
|
|
1809 | $channel->volume (128 + $vol); |
|
|
1810 | $dx = $dx / 10 * 255; |
|
|
1811 | $channel->set_panning ((min 255, 255 - $dx), (min 255, 255 + $dx)); |
|
|
1812 | |
|
|
1813 | # my $angle = $dx ? : $dx < 0 ? |
|
|
1814 | # my $distance = -$vol; |
|
|
1815 | # $channel->set_position ($angle, $distance); |
|
|
1816 | |
|
|
1817 | $chunk->play ($channel); |
|
|
1818 | } |
|
|
1819 | } else { |
|
|
1820 | # sound_meta not set means data is in flight either way |
|
|
1821 | my $meta = $CONN->{sound_meta}{$face} |
|
|
1822 | or return; |
|
|
1823 | |
|
|
1824 | # fetch from database |
|
|
1825 | CFPlus::DB::get res_data => $meta->{name}, sub { |
|
|
1826 | my $vol = $meta->{meta}{volume} || 1; |
|
|
1827 | my $rwops = new CFPlus::RW $_[0]; |
|
|
1828 | my $chunk = new CFPlus::MixChunk $rwops; |
|
|
1829 | $chunk->volume ($vol * 128); |
|
|
1830 | $AUDIO_CHUNK{$face} = $chunk; |
|
|
1831 | |
|
|
1832 | audio_sound_push ($face); |
|
|
1833 | }; |
|
|
1834 | } |
|
|
1835 | } |
|
|
1836 | |
|
|
1837 | sub audio_sound_play { |
|
|
1838 | my ($face, $dx, $dy, $vol) = @_; |
|
|
1839 | |
|
|
1840 | $SDL_MIXER |
|
|
1841 | or return; |
|
|
1842 | |
|
|
1843 | my $queue = $AUDIO_PLAY{$face} ||= []; |
|
|
1844 | push @$queue, [Event::time + 0.2, $dx, $dy, $vol]; # delay sound by max. 0.2s |
|
|
1845 | audio_sound_push $face |
|
|
1846 | unless @$queue > 1; |
|
|
1847 | } |
|
|
1848 | |
|
|
1849 | sub audio_music_set_ambient { |
|
|
1850 | my ($songs) = @_; |
|
|
1851 | |
|
|
1852 | my @want = |
|
|
1853 | grep $_, |
|
|
1854 | map $CONN->{music_meta}{$_}, |
|
|
1855 | @$songs; |
|
|
1856 | |
|
|
1857 | if (@want) { |
|
|
1858 | @MUSIC_WANT = @want; |
|
|
1859 | &audio_music_changed (); |
|
|
1860 | } |
|
|
1861 | } |
|
|
1862 | |
|
|
1863 | sub audio_music_start { |
|
|
1864 | my $meta = $MUSIC_PLAYING_META; |
|
|
1865 | |
|
|
1866 | CFPlus::DB::get res_data => $meta->{name}, sub { |
|
|
1867 | return unless $SDL_MIXER; |
|
|
1868 | |
|
|
1869 | # music might have changed... |
|
|
1870 | $meta eq $MUSIC_PLAYING_META |
|
|
1871 | or return &audio_music_start (); |
|
|
1872 | |
|
|
1873 | $MUSIC_PLAYING_DATA = \$_[0]; |
|
|
1874 | |
|
|
1875 | my $rwops = $meta->{path} |
|
|
1876 | ? new_from_file CFPlus::RW $meta->{path} |
|
|
1877 | : new CFPlus::RW $$MUSIC_PLAYING_DATA; |
|
|
1878 | |
|
|
1879 | $MUSIC_PLAYER = new CFPlus::MixMusic $rwops |
|
|
1880 | or ((warn CFPlus::Mix_GetError), return); # pretty fatal error |
|
|
1881 | |
|
|
1882 | my $NOW = time; |
|
|
1883 | |
|
|
1884 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
|
|
1885 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
|
|
1886 | $MUSIC_PLAYER->fade_in_pos (0, 1000, $pos); |
|
|
1887 | $MUSIC_START = time - $pos; |
|
|
1888 | } else { |
|
|
1889 | $MUSIC_PLAYER->play (0); |
|
|
1890 | $MUSIC_START = time; |
|
|
1891 | } |
|
|
1892 | |
|
|
1893 | delete $MUSIC_PLAYING_META->{stop_time}; |
|
|
1894 | delete $MUSIC_PLAYING_META->{stop_pos}; |
|
|
1895 | } |
|
|
1896 | } |
|
|
1897 | |
|
|
1898 | sub audio_music_changed { |
|
|
1899 | return unless $CFG->{bgm_enable}; |
|
|
1900 | return unless $SDL_MIXER; |
|
|
1901 | |
|
|
1902 | # default MUSIC_WANT == MUSIC_DEFAULT |
|
|
1903 | @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT; |
|
|
1904 | |
|
|
1905 | # if the currently playing song is acceptable, let it continue |
|
|
1906 | return if $MUSIC_PLAYING_META |
|
|
1907 | && grep $MUSIC_PLAYING_META == $_, @MUSIC_WANT; |
|
|
1908 | |
|
|
1909 | my $NOW = time; |
|
|
1910 | |
|
|
1911 | if ($MUSIC_PLAYING_META) { |
|
|
1912 | $MUSIC_PLAYING_META->{stop_time} = $NOW; |
|
|
1913 | $MUSIC_PLAYING_META->{stop_pos} = $NOW - $MUSIC_START; |
|
|
1914 | CFPlus::MixMusic::fade_out 1000; |
|
|
1915 | } else { |
|
|
1916 | # sort by stop time, oldest first |
|
|
1917 | @MUSIC_WANT = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_WANT; |
|
|
1918 | |
|
|
1919 | # if the most recently-played piece played very recently, |
|
|
1920 | # resume it, else choose the oldest piece for rotation. |
|
|
1921 | $MUSIC_PLAYING_META = |
|
|
1922 | $MUSIC_WANT[-1]{stop_time} > $NOW - $MUSIC_RESUME |
|
|
1923 | ? $MUSIC_WANT[-1] |
|
|
1924 | : $MUSIC_WANT[0]; |
|
|
1925 | |
|
|
1926 | audio_music_start; |
|
|
1927 | } |
|
|
1928 | } |
|
|
1929 | |
|
|
1930 | sub audio_music_finished { |
|
|
1931 | undef $MUSIC_PLAYER; |
|
|
1932 | undef $MUSIC_PLAYING_META; |
|
|
1933 | undef $MUSIC_PLAYING_DATA; |
|
|
1934 | |
|
|
1935 | audio_music_changed; |
|
|
1936 | } |
|
|
1937 | |
|
|
1938 | sub audio_init { |
|
|
1939 | if ($CFG->{audio_enable}) { |
|
|
1940 | $ENV{MIX_EFFECTSMAXSPEED} = 1; |
|
|
1941 | $SDL_MIXER = !CFPlus::Mix_OpenAudio; |
|
|
1942 | |
|
|
1943 | unless ($SDL_MIXER) { |
|
|
1944 | status "Unable to open sound device: there will be no sound"; |
|
|
1945 | return; |
|
|
1946 | } |
|
|
1947 | |
|
|
1948 | CFPlus::Mix_AllocateChannels 16; |
|
|
1949 | CFPlus::MixMusic::volume $CFG->{bgm_volume} * 128; |
|
|
1950 | |
|
|
1951 | audio_music_finished; |
|
|
1952 | } else { |
|
|
1953 | undef $SDL_MIXER; |
|
|
1954 | } |
|
|
1955 | } |
|
|
1956 | |
|
|
1957 | sub audio_shutdown { |
|
|
1958 | CFPlus::Mix_CloseAudio if $SDL_MIXER; |
|
|
1959 | undef $SDL_MIXER; |
|
|
1960 | @SOUNDS = (); |
|
|
1961 | %AUDIO_CHUNK = (); |
|
|
1962 | } |
|
|
1963 | |
|
|
1964 | my %animate_object; |
2102 | my %animate_object; |
1965 | my $animate_timer; |
2103 | my $animate_timer; |
1966 | |
2104 | |
1967 | my $fps = 9; |
2105 | my $fps = 9; |
1968 | |
2106 | |
1969 | sub force_refresh { |
2107 | sub force_refresh { |
|
|
2108 | if ($ENV{CFPLUS_DEBUG} & 4) { |
1970 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
2109 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
1971 | debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; |
2110 | debug sprintf "%3.2f", $fps; |
|
|
2111 | } |
1972 | |
2112 | |
1973 | $CFPlus::UI::ROOT->draw; |
2113 | $CFPlus::UI::ROOT->draw; |
1974 | |
2114 | CFPlus::SDL_GL_SwapBuffers; |
1975 | $WANT_REFRESH = 0; |
|
|
1976 | $CAN_REFRESH = 0; |
|
|
1977 | $LAST_REFRESH = $NOW; |
2115 | $LAST_REFRESH = $NOW; |
1978 | |
2116 | $WANT_REFRESH->stop; |
1979 | CFPlus::SDL_GL_SwapBuffers; |
|
|
1980 | } |
2117 | } |
1981 | |
2118 | |
|
|
2119 | $WANT_REFRESH = Event->idle (min => 0.001, max => 0.06, parked => 1, cb => \&force_refresh); |
|
|
2120 | |
1982 | my $refresh_watcher = Event->timer (after => 0, hard => 0, interval => 1 / $MAX_FPS, cb => sub { |
2121 | my $input = Event->timer (after => 0, hard => 0, interval => 1 / 50, cb => sub { |
1983 | $NOW = time; |
2122 | $NOW = time; |
1984 | |
2123 | |
1985 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2124 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
1986 | for CFPlus::poll_events; |
2125 | for CFPlus::poll_events; |
1987 | |
2126 | |
1988 | if (%animate_object) { |
2127 | if (%animate_object) { |
1989 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2128 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
1990 | ++$WANT_REFRESH; |
2129 | $WANT_REFRESH->start; |
1991 | } |
|
|
1992 | |
|
|
1993 | if ($WANT_REFRESH) { |
|
|
1994 | force_refresh; |
|
|
1995 | } else { |
|
|
1996 | $CAN_REFRESH = 1; |
|
|
1997 | } |
2130 | } |
1998 | }); |
2131 | }); |
1999 | |
2132 | |
2000 | sub animation_start { |
2133 | sub animation_start { |
2001 | my ($widget) = @_; |
2134 | my ($widget) = @_; |
… | |
… | |
2059 | |
2192 | |
2060 | my %DEF_CFG = ( |
2193 | my %DEF_CFG = ( |
2061 | sdl_mode => 0, |
2194 | sdl_mode => 0, |
2062 | fullscreen => 0, |
2195 | fullscreen => 0, |
2063 | fast => 0, |
2196 | fast => 0, |
|
|
2197 | opengl11 => 0, |
2064 | map_scale => 1, |
2198 | map_scale => 1, |
2065 | fow_enable => 1, |
2199 | fow_enable => 1, |
2066 | fow_intensity => 0, |
2200 | fow_intensity => 0, |
2067 | map_smoothing => 1, |
2201 | map_smoothing => 1, |
2068 | gui_fontsize => 1, |
2202 | gui_fontsize => 1, |
… | |
… | |
2070 | gauge_fontsize => 1, |
2204 | gauge_fontsize => 1, |
2071 | gauge_size => 0.35, |
2205 | gauge_size => 0.35, |
2072 | stat_fontsize => 0.7, |
2206 | stat_fontsize => 0.7, |
2073 | mapsize => 100, |
2207 | mapsize => 100, |
2074 | audio_enable => 1, |
2208 | audio_enable => 1, |
|
|
2209 | effects_enable => 1, |
|
|
2210 | effects_volume => 1, |
2075 | bgm_enable => 1, |
2211 | bgm_enable => 1, |
2076 | bgm_volume => 0.25, |
2212 | bgm_volume => 0.5, |
2077 | output_sync => 1, |
2213 | output_sync => 1, |
2078 | output_count => 1, |
2214 | output_count => 1, |
2079 | output_rate => "", |
2215 | output_rate => "", |
2080 | pickup => 0, |
2216 | pickup => 0, |
2081 | inv_sort => "mtime", |
2217 | inv_sort => "mtime", |
… | |
… | |
2155 | } |
2291 | } |
2156 | |
2292 | |
2157 | show_tip_of_the_day if $CFG->{show_tips}; |
2293 | show_tip_of_the_day if $CFG->{show_tips}; |
2158 | |
2294 | |
2159 | Event::loop; |
2295 | Event::loop; |
|
|
2296 | |
|
|
2297 | #video_shutdown; |
|
|
2298 | #audio_shutdown; |
2160 | #CFPlus::SDL_Quit; |
2299 | CFPlus::SDL_Quit; |
2161 | #CFPlus::_exit 0; |
|
|
2162 | |
|
|
2163 | END { |
|
|
2164 | CFPlus::SDL_Quit; |
|
|
2165 | CFPlus::DB::Server::stop; |
2300 | CFPlus::DB::Server::stop; |
2166 | } |
|
|
2167 | |
2301 | |
2168 | =head1 NAME |
2302 | =head1 NAME |
2169 | |
2303 | |
2170 | cfplus - A Crossfire+ and Crossfire game client |
2304 | cfplus - A Crossfire TRT and Crossfire game client |
2171 | |
2305 | |
2172 | =head1 SYNOPSIS |
2306 | =head1 SYNOPSIS |
2173 | |
2307 | |
2174 | Just run it - no commandline arguments are supported. |
2308 | Just run it - no commandline arguments are supported. |
2175 | |
2309 | |
2176 | =head1 USAGE |
2310 | =head1 USAGE |
2177 | |
2311 | |
2178 | cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used |
2312 | cfplus utilises OpenGL for all UI elements and the game. It is supposed to |
2179 | fullscreen and interactively. |
2313 | be used in fullscreen mode and interactively. |
2180 | |
2314 | |
2181 | =head1 DEBUGGING |
2315 | =head1 DEBUGGING |
2182 | |
2316 | |
2183 | |
2317 | |
2184 | CFPLUS_DEBUG - environment variable |
2318 | CFPLUS_DEBUG - environment variable |