ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/cfplus
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/cfplus (file contents):
Revision 1.196 by root, Tue Jul 31 02:03:13 2007 UTC vs.
Revision 1.206 by root, Thu Aug 9 03:40:44 2007 UTC

144our $SETUP_KEYBOARD; 144our $SETUP_KEYBOARD;
145 145
146our $PL_NOTEBOOK; 146our $PL_NOTEBOOK;
147our $PL_WINDOW; 147our $PL_WINDOW;
148 148
149our $MUSIC_PLAYING_WIDGET;
150our $LICENSE_WIDGET;
151
149our $INVENTORY_PAGE; 152our $INVENTORY_PAGE;
150our $STATS_PAGE; 153our $STATS_PAGE;
151our $SKILL_PAGE; 154our $SKILL_PAGE;
152our $SPELL_PAGE; 155our $SPELL_PAGE;
153our $SPELL_LIST; 156our $SPELL_LIST;
159our $STATWIDS; 162our $STATWIDS;
160 163
161our $SDL_ACTIVE; 164our $SDL_ACTIVE;
162our %SDL_CB; 165our %SDL_CB;
163 166
167our $ALT_ENTER_MESSAGE;
168our $STATUSBOX;
169our $DEBUG_STATUS;
170
171our $INV;
172our $INVR;
173our $INV_RIGHT_HB;
174
175our $PICKUP_CFG;
176
177#############################################################################
178
179sub status {
180 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
181}
182
183sub debug {
184 $DEBUG_STATUS->set_text ($_[0]);
185}
186
187sub message {
188 my ($para) = @_;
189 $MESSAGE_WINDOW->message ($para);
190}
191
192#############################################################################
193#TODO: maybe move into own audio module...
194
164our $SDL_MIXER; 195our $SDL_MIXER;
196
165our $MUSIC_DEFAULT = "in_a_heartbeat.ogg"; 197our $MUSIC_DEFAULT = "in_a_heartbeat.ogg";
166our $MUSIC_WANT; # arryref of ambient music 198our $MUSIC_WANT; # arryref of ambient music we want to play
167our @MUSIC_HAVE; # ambient music we want now 199our @MUSIC_HAVE; # ambient music we have on disk
168our $MUSIC_START; 200our $MUSIC_START;
201our @MUSIC_JINGLE; # which jingles to play next
169our $MUSIC_PLAYING_DATA; 202our $MUSIC_PLAYING_DATA;
170our $MUSIC_PLAYING_META; 203our $MUSIC_PLAYING_META;
171our $MUSIC_PLAYER; 204our $MUSIC_PLAYER;
172our $MUSIC_RESUME = 30; # resume music when players less than these many seconds before 205our $MUSIC_RESUME = 30; # resume music when played less than these many seconds before
173our @SOUNDS; # event => file mapping 206
174our %AUDIO_CHUNK; # audio files 207our %AUDIO_CHUNK; # audio "files"
175 208our %AUDIO_PLAY; # which audio faces should be played
176our $ALT_ENTER_MESSAGE;
177our $STATUSBOX;
178our $DEBUG_STATUS;
179
180our $INV;
181our $INVR;
182our $INV_RIGHT_HB;
183
184our $PICKUP_CFG;
185
186#############################################################################
187#TODO: maybe move into own audio module...
188 209
189sub audio_channel_finished { 210sub audio_channel_finished {
190 my ($channel) = @_; 211 my ($channel) = @_;
191 212
192# warn "channel $channel finished\n";#d# 213# warn "channel $channel finished\n";#d#
193} 214}
194 215
195our %AUDIO_PLAY;
196our %AUDIO_CHUNK;
197
198sub audio_sound_push($) { 216sub audio_sound_push($) {
199 my ($face) = @_; 217 my ($face) = @_;
218
219 $CFG->{effects_enable}
220 or return;
221
222 $AUDIO_PLAY{$face}
223 or return;
200 224
201 if (my $chunk = $AUDIO_CHUNK{$face}) { 225 if (my $chunk = $AUDIO_CHUNK{$face}) {
202 for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { 226 for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) {
203 my (undef, $dx, $dy, $vol) = @$_; 227 my (undef, $dx, $dy, $vol) = @$_;
204 228
205 my $channel = CFPlus::Channel::find; 229 my $channel = CFPlus::Channel::find;
206 $channel->volume ($vol * 128 / 255); 230 $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255);
207 $dx = $dx / 10 * 255; 231 $dx = $dx / 10 * 255;
208 $channel->set_panning (255 - $dx, 255 + $dx); 232 $channel->set_panning (255 - $dx, 255 + $dx);
209 233
210# my $angle = $dx ? : $dx < 0 ? 234# my $angle = $dx ? : $dx < 0 ?
211# my $distance = -$vol; 235# my $distance = -$vol;
216 } else { 240 } else {
217 # sound_meta not set means data is in flight either way 241 # sound_meta not set means data is in flight either way
218 my $meta = $CONN->{sound_meta}{$face} 242 my $meta = $CONN->{sound_meta}{$face}
219 or return; 243 or return;
220 244
245 # if its a jingle, play it as ambient music
246 if ($meta->{meta}{jingle}) {
247 if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue
248 push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue
249 &audio_music_push ($face);
250 }
251 } else {
221 # fetch from database 252 # fetch from database
222 CFPlus::DB::get res_data => $meta->{name}, sub { 253 CFPlus::DB::get res_data => $meta->{name}, sub {
223 my $rwops = new CFPlus::RW $_[0]; 254 my $rwops = new CFPlus::RW $_[0];
224 my $chunk = new CFPlus::MixChunk $rwops; 255 my $chunk = new CFPlus::MixChunk $rwops
256 or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError;
225 $chunk->volume (($meta->{meta}{volume} || 1) * 128); 257 $chunk->volume (($meta->{meta}{volume} || 1) * 128);
226 $AUDIO_CHUNK{$face} = $chunk; 258 $AUDIO_CHUNK{$face} = $chunk;
227 259
228 audio_sound_push ($face); 260 audio_sound_push ($face);
261 };
229 }; 262 }
230 } 263 }
231} 264}
232 265
233sub audio_sound_play { 266sub audio_sound_play {
234 my ($face, $dx, $dy, $vol) = @_; 267 my ($face, $dx, $dy, $vol) = @_;
235 268
236 $SDL_MIXER 269 $SDL_MIXER
270 or return;
271 $CFG->{effects_enable}
237 or return; 272 or return;
238 273
239 my $queue = $AUDIO_PLAY{$face} ||= []; 274 my $queue = $AUDIO_PLAY{$face} ||= [];
240 push @$queue, [Event::time + 0.2, $dx, $dy, $vol]; # delay sound by max. 0.2s 275 push @$queue, [Event::time + 0.2, $dx, $dy, $vol]; # delay sound by max. 0.2s
241 audio_sound_push $face 276 audio_sound_push $face
242 unless @$queue > 1; 277 unless @$queue > 1;
243} 278}
244 279
280sub audio_music_set_meta {
281 my ($meta) = @_;
282
283 $MUSIC_PLAYING_META = $meta;
284 $MUSIC_PLAYING_WIDGET->set_markup (
285 "<b>Name</b>: " . (CFPlus::asxml $meta->{meta}{name}) . "\n"
286 . "<b>Author</b>: " . (CFPlus::asxml $meta->{meta}{author}) . "\n"
287 . "<b>Source</b>: " . (CFPlus::asxml $meta->{meta}{source}) . "\n"
288 . "<b>License</b>: " . (CFPlus::asxml $meta->{meta}{license})
289 );
290}
291
245sub audio_music_update_volume { 292sub audio_music_update_volume {
246 return unless $MUSIC_PLAYING_META; 293 return unless $MUSIC_PLAYING_META;
247 my $volume = $MUSIC_PLAYING_META->{meta}{volume} || 1; 294 my $volume = $MUSIC_PLAYING_META->{meta}{volume} || 1;
248 my $base = $CFG->{bgm_volume}; 295 my $base = $MUSIC_PLAYING_META->{meta}{jingle} ? 1 : $CFG->{bgm_volume};
249 CFPlus::MixMusic::volume $base * $volume * 128; 296 CFPlus::MixMusic::volume $base * $volume * 128;
250}
251
252sub audio_music_push {
253 my @have =
254 grep $_,
255 map $CONN->{music_meta}{$_},
256 @$MUSIC_WANT;
257
258 if (@have) {
259 @MUSIC_HAVE = @have;
260 &audio_music_changed ();
261 }
262}
263
264sub audio_music_set_ambient {
265 my ($songs) = @_;
266
267 $MUSIC_WANT = $songs;
268
269 audio_music_push;
270} 297}
271 298
272sub audio_music_start { 299sub audio_music_start {
273 my $meta = $MUSIC_PLAYING_META; 300 my $meta = $MUSIC_PLAYING_META;
274 301
286 my $rwops = $meta->{path} 313 my $rwops = $meta->{path}
287 ? new_from_file CFPlus::RW $meta->{path} 314 ? new_from_file CFPlus::RW $meta->{path}
288 : new CFPlus::RW $$MUSIC_PLAYING_DATA; 315 : new CFPlus::RW $$MUSIC_PLAYING_DATA;
289 316
290 $MUSIC_PLAYER = new CFPlus::MixMusic $rwops 317 $MUSIC_PLAYER = new CFPlus::MixMusic $rwops
291 or ((warn CFPlus::Mix_GetError), return); # pretty fatal error 318 or Carp::confess "music face $meta->{face} unloadable: " . CFPlus::Mix_GetError;
292 319
293 my $NOW = time; 320 my $NOW = time;
294 321
295 if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { 322 if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) {
296 my $pos = $MUSIC_PLAYING_META->{stop_pos}; 323 my $pos = $MUSIC_PLAYING_META->{stop_pos};
299 } else { 326 } else {
300 $MUSIC_PLAYER->play (0); 327 $MUSIC_PLAYER->play (0);
301 $MUSIC_START = time; 328 $MUSIC_START = time;
302 } 329 }
303 330
304 delete $MUSIC_PLAYING_META->{stop_time}; 331 delete $meta->{stop_time};
305 delete $MUSIC_PLAYING_META->{stop_pos}; 332 delete $meta->{stop_pos};
306 } 333 }
307} 334}
308 335
309sub audio_music_changed { 336sub audio_music_push {
310 return unless $CFG->{bgm_enable};
311 return unless $SDL_MIXER; 337 return unless $SDL_MIXER;
312 338
339 my $fade_out;
340
341 if (@MUSIC_JINGLE) {
342 @MUSIC_HAVE = $MUSIC_JINGLE[0];
343 $fade_out = 333;
344 } else {
345 return unless $CFG->{bgm_enable};
346
347 my @have =
348 grep $_,
349 map $CONN->{music_meta}{$_},
350 @$MUSIC_WANT;
351
352 @MUSIC_HAVE = @have
353 if @have;
354
313 # default MUSIC_HAVE == MUSIC_DEFAULT 355 # default MUSIC_HAVE == MUSIC_DEFAULT
314 @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; 356 @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE;
357 $fade_out = 1000;
358 }
315 359
316 # if the currently playing song is acceptable, let it continue 360 # if the currently playing song is acceptable, let it continue
317 return if $MUSIC_PLAYING_META
318 && grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; 361 return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE;
319 362
320 my $NOW = time; 363 my $NOW = time;
321 364
322 if ($MUSIC_PLAYING_META) { 365 if ($MUSIC_PLAYING_META) {
323 $MUSIC_PLAYING_META->{stop_time} = $NOW; 366 $MUSIC_PLAYING_META->{stop_time} = $NOW;
324 $MUSIC_PLAYING_META->{stop_pos} = $NOW - $MUSIC_START; 367 $MUSIC_PLAYING_META->{stop_pos} = $NOW - $MUSIC_START;
325 CFPlus::MixMusic::fade_out 1000; 368 CFPlus::MixMusic::fade_out $fade_out;
326 } else { 369 } else {
327 # sort by stop time, oldest first 370 # sort by stop time, oldest first
328 @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; 371 @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE;
329 372
330 # if the most recently-played piece played very recently, 373 # if the most recently-played piece played very recently,
331 # resume it, else choose the oldest piece for rotation. 374 # resume it, else choose the oldest piece for rotation.
332 $MUSIC_PLAYING_META = 375 audio_music_set_meta
333 $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME 376 $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME
334 ? $MUSIC_HAVE[-1] 377 ? $MUSIC_HAVE[-1]
335 : $MUSIC_HAVE[0]; 378 : $MUSIC_HAVE[0];
336 379
337 audio_music_start; 380 audio_music_start;
338 } 381 }
339} 382}
340 383
384sub audio_music_set_ambient {
385 my ($songs) = @_;
386
387 $MUSIC_WANT = $songs;
388 audio_music_push;
389}
390
341sub audio_music_finished { 391sub audio_music_finished {
392 # we compress multiple jingles of the same type
393 shift @MUSIC_JINGLE
394 while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0];
395
396 $MUSIC_PLAYING_WIDGET->clear;
397
342 undef $MUSIC_PLAYER; 398 undef $MUSIC_PLAYER;
343 undef $MUSIC_PLAYING_META; 399 undef $MUSIC_PLAYING_META;
344 undef $MUSIC_PLAYING_DATA; 400 undef $MUSIC_PLAYING_DATA;
345 401
346 audio_music_changed; 402 audio_music_push;
403}
404
405sub audio_init {
406 if ($CFG->{audio_enable}) {
407 $ENV{MIX_EFFECTSMAXSPEED} = 1;
408 $SDL_MIXER = !CFPlus::Mix_OpenAudio;
409
410 unless ($SDL_MIXER) {
411 status "Unable to open sound device: there will be no sound";
412 return;
413 }
414
415 CFPlus::Mix_AllocateChannels 16;
416
417 audio_music_finished;
418 } else {
419 undef $SDL_MIXER;
420 }
421}
422
423sub audio_shutdown {
424 undef $MUSIC_PLAYER;
425 undef $MUSIC_PLAYING_META;
426 undef $MUSIC_PLAYING_DATA;
427
428 $MUSIC_WANT = [];
429 @MUSIC_JINGLE = ();
430 %AUDIO_PLAY = ();
431 %AUDIO_CHUNK = ();
432
433 CFPlus::Mix_CloseAudio if $SDL_MIXER;
434 undef $SDL_MIXER;
347} 435}
348 436
349############################################################################# 437#############################################################################
350
351sub status {
352 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
353}
354
355sub debug {
356 $DEBUG_STATUS->set_text ($_[0]);
357}
358
359sub message {
360 my ($para) = @_;
361 $MESSAGE_WINDOW->message ($para);
362}
363 438
364sub destroy_query_dialog { 439sub destroy_query_dialog {
365 (delete $_[0]{query_dialog})->destroy 440 (delete $_[0]{query_dialog})->destroy
366 if $_[0]{query_dialog}; 441 if $_[0]{query_dialog};
367} 442}
790} 865}
791 866
792sub audio_setup { 867sub audio_setup {
793 my $vbox = new CFPlus::UI::VBox; 868 my $vbox = new CFPlus::UI::VBox;
794 869
795 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); 870 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1]);
796 871
797 my $row = 0; 872 my $row = 0;
798 873
799 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Audio Enable"); 874 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Audio Enable");
800 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 875 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
804 ); 879 );
805# $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume"); 880# $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume");
806# $table->add_at (1, 8, new CFPlus::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub { 881# $table->add_at (1, 8, new CFPlus::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub {
807# $CFG->{effects_volume} = $_[1]; 882# $CFG->{effects_volume} = $_[1];
808# }); 883# });
884
885 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects");
886 $table->add_at (1, $row, new CFPlus::UI::CheckBox
887 expand => 1, state => $CFG->{effects_enable},
888 tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.",
889 on_changed => sub {
890 $CFG->{effects_enable} = $_[1];
891 $CONN->update_fx_want if $CONN;
892 0
893 }
894 );
895 $table->add_at (2, $row++, new CFPlus::UI::Slider
896 expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128],
897 tooltip => "The relative volume of sound effects. Best audio quality is achieved if this "
898 . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.",
899 on_changed => sub { $CFG->{effects_volume} = $_[1]; 0 }
900 );
901
809 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); 902 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music");
810 $table->add_at (1, $row++, my $hbox = new CFPlus::UI::HBox); 903 $table->add_at (1, $row, new CFPlus::UI::CheckBox
811 $hbox->add (new CFPlus::UI::CheckBox
812 expand => 1, state => $CFG->{bgm_enable}, 904 expand => 1, state => $CFG->{bgm_enable},
813 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", 905 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.",
814 on_changed => sub { $CFG->{bgm_enable} = $_[1]; 0 } 906 on_changed => sub {
907 $CFG->{bgm_enable} = $_[1];
908 $CONN->update_fx_want if $CONN;
909 0
910 }
815 ); 911 );
816 $hbox->add (new CFPlus::UI::Slider 912 $table->add_at (2, $row++, new CFPlus::UI::Slider
817 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], 913 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128],
818 tooltip => "The volume of the background music. Changes are instant.", 914 tooltip => "The volume of the background music. Changes are instant.",
819 on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } 915 on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 }
820 ); 916 );
821 917
822 $table->add_at (1, $row++, new CFPlus::UI::Button 918 $table->add_at (1, $row++, new CFPlus::UI::Button
823 expand => 1, align => 0, text => "Apply", 919 c_colspan => 2, expand => 1, align => 0, text => "Apply",
824 tooltip => "Apply the audio settings", 920 tooltip => "Apply the audio settings",
825 on_activate => sub { 921 on_activate => sub {
826 audio_shutdown (); 922 audio_shutdown ();
827 audio_init (); 923 audio_init ();
828 0 924 0
899 $table->add_at (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } ); 995 $table->add_at (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } );
900 996
901 $table->add_at (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d# 997 $table->add_at (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d#
902 998
903 $table->add_at (7,7, my $t = new CFPlus::UI::Table expand => 0); 999 $table->add_at (7,7, my $t = new CFPlus::UI::Table expand => 0);
904 $t->add_at (0,0, new CFPlus::UI::Label text => "a a a a", rowspan => 1, colspan => 2); 1000 $t->add_at (0,0, new CFPlus::UI::Label text => "a a a a", c_rowspan => 1, c_colspan => 2);
905 $t->add_at (2,0, new CFPlus::UI::Label text => "b\nb", rowspan => 2, colspan => 1); 1001 $t->add_at (2,0, new CFPlus::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1);
906 $t->add_at (1,2, new CFPlus::UI::Label text => "c c c c", rowspan => 1, colspan => 2); 1002 $t->add_at (1,2, new CFPlus::UI::Label text => "c c c c", c_rowspan => 1, c_colspan => 2);
907 $t->add_at (0,1, new CFPlus::UI::Label text => "d\nd", rowspan => 2, colspan => 1); 1003 $t->add_at (0,1, new CFPlus::UI::Label text => "d\nd", c_rowspan => 2, c_colspan => 1);
908 $t->add_at (1,1, new CFPlus::UI::Label text => "e"); 1004 $t->add_at (1,1, new CFPlus::UI::Label text => "e");
909 1005
910 $table->add_at (7, 6, my $c = new CFPlus::UI::Canvas); 1006 $table->add_at (7, 6, my $c = new CFPlus::UI::Canvas);
911 1007
912 $c->add_items ({ 1008 $c->add_items ({
1519 CFPlus::Protocol::set_opencont ($::CONN, 0, "Floor"); 1615 CFPlus::Protocol::set_opencont ($::CONN, 0, "Floor");
1520 1616
1521 $hb 1617 $hb
1522} 1618}
1523 1619
1620sub media_window {
1621 my $vb = new CFPlus::UI::VBox;
1622
1623 $vb->add (new CFPlus::UI::FancyFrame
1624 label => "Currently playing music",
1625 child => new CFPlus::UI::ScrolledWindow scroll_x => 1, scroll_y => 0,
1626 child => ($MUSIC_PLAYING_WIDGET = new CFPlus::UI::Label ellipsise => 0, fontsize => 0.8),
1627 );
1628
1629 $vb->add (new CFPlus::UI::FancyFrame
1630 label => "Other media used in this session",
1631 expand => 1,
1632 child => ($LICENSE_WIDGET = new CFPlus::UI::TextScroller
1633 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4),
1634 );
1635
1636 $vb
1637}
1638
1639sub add_license {
1640 my ($meta) = @_;
1641
1642 $meta = $meta->{meta}
1643 or return;
1644
1645 $meta->{license} || $meta->{author} || $meta->{source}
1646 or return;
1647
1648 $LICENSE_WIDGET->add_paragraph ({
1649 fg => [1, 1, 1, 1],
1650 markup => "<small>"
1651 . "<b>Name:</b> " . (CFPlus::asxml $meta->{name}) . "\n"
1652 . "<b>Author:</b> " . (CFPlus::asxml $meta->{author}) . "\n"
1653 . "<b>Source:</b> " . (CFPlus::asxml $meta->{source}) . "\n"
1654 . "<b>License:</b> " . (CFPlus::asxml $meta->{license}) . "\n"
1655 . "</small>",
1656 });
1657 $LICENSE_WIDGET->scroll_to_bottom;
1658}
1659
1524sub toggle_player_page { 1660sub toggle_player_page {
1525 my ($widget) = @_; 1661 my ($widget) = @_;
1526 1662
1527 if ($PL_WINDOW->{visible} && $PL_NOTEBOOK->get_current_page == $widget) { 1663 if ($PL_WINDOW->{visible} && $PL_NOTEBOOK->get_current_page == $widget) {
1528 $PL_WINDOW->hide; 1664 $PL_WINDOW->hide;
1565 $ntb->add_tab ( 1701 $ntb->add_tab (
1566 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, 1702 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget,
1567 "Toggles the inventory window, where you can manage your loot (or treasures :). " 1703 "Toggles the inventory window, where you can manage your loot (or treasures :). "
1568 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." 1704 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."
1569 ); 1705 );
1570 $ntb->add_tab (Pickup => autopickup_setup, 1706 $ntb->add_tab (Pickup => autopickup_setup,
1571 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); 1707 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them.");
1708
1709 $ntb->add_tab (Media => media_window,
1710 "License, Author and Source info for media sent by the server.");
1572 1711
1573 $ntb->set_current_page ($INVENTORY_PAGE); 1712 $ntb->set_current_page ($INVENTORY_PAGE);
1574 1713
1575 $plwin->add ($ntb); 1714 $plwin->add ($ntb);
1576 $plwin 1715 $plwin
1951 2090
1952sub video_shutdown { 2091sub video_shutdown {
1953 CFPlus::OpenGL::shutdown; 2092 CFPlus::OpenGL::shutdown;
1954 2093
1955 undef $SDL_ACTIVE; 2094 undef $SDL_ACTIVE;
1956}
1957
1958sub audio_init {
1959 if ($CFG->{audio_enable}) {
1960 $ENV{MIX_EFFECTSMAXSPEED} = 1;
1961 $SDL_MIXER = !CFPlus::Mix_OpenAudio;
1962
1963 unless ($SDL_MIXER) {
1964 status "Unable to open sound device: there will be no sound";
1965 return;
1966 }
1967
1968 CFPlus::Mix_AllocateChannels 16;
1969
1970 audio_music_finished;
1971 } else {
1972 undef $SDL_MIXER;
1973 }
1974}
1975
1976sub audio_shutdown {
1977 CFPlus::Mix_CloseAudio if $SDL_MIXER;
1978 undef $SDL_MIXER;
1979 @SOUNDS = ();
1980 %AUDIO_CHUNK = ();
1981} 2095}
1982 2096
1983my %animate_object; 2097my %animate_object;
1984my $animate_timer; 2098my $animate_timer;
1985 2099
2089 gauge_fontsize => 1, 2203 gauge_fontsize => 1,
2090 gauge_size => 0.35, 2204 gauge_size => 0.35,
2091 stat_fontsize => 0.7, 2205 stat_fontsize => 0.7,
2092 mapsize => 100, 2206 mapsize => 100,
2093 audio_enable => 1, 2207 audio_enable => 1,
2208 effects_enable => 1,
2209 effects_volume => 1,
2094 bgm_enable => 1, 2210 bgm_enable => 1,
2095 bgm_volume => 0.25, 2211 bgm_volume => 0.5,
2096 output_sync => 1, 2212 output_sync => 1,
2097 output_count => 1, 2213 output_count => 1,
2098 output_rate => "", 2214 output_rate => "",
2099 pickup => 0, 2215 pickup => 0,
2100 inv_sort => "mtime", 2216 inv_sort => "mtime",
2178Event::loop; 2294Event::loop;
2179#CFPlus::SDL_Quit; 2295#CFPlus::SDL_Quit;
2180#CFPlus::_exit 0; 2296#CFPlus::_exit 0;
2181 2297
2182END { 2298END {
2299 video_shutdown;
2300 audio_shutdown;
2183 CFPlus::SDL_Quit; 2301 CFPlus::SDL_Quit;
2184 CFPlus::DB::Server::stop; 2302 CFPlus::DB::Server::stop;
2185} 2303}
2186 2304
2187=head1 NAME 2305=head1 NAME
2188 2306
2189cfplus - A Crossfire+ and Crossfire game client 2307cfplus - A Crossfire TRT and Crossfire game client
2190 2308
2191=head1 SYNOPSIS 2309=head1 SYNOPSIS
2192 2310
2193Just run it - no commandline arguments are supported. 2311Just run it - no commandline arguments are supported.
2194 2312
2195=head1 USAGE 2313=head1 USAGE
2196 2314
2197cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used 2315cfplus utilises OpenGL for all UI elements and the game. It is supposed to
2198fullscreen and interactively. 2316be used in fullscreen mode and interactively.
2199 2317
2200=head1 DEBUGGING 2318=head1 DEBUGGING
2201 2319
2202 2320
2203CFPLUS_DEBUG - environment variable 2321CFPLUS_DEBUG - environment variable

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines