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.224 by root, Thu Aug 30 07:57:59 2007 UTC vs.
Revision 1.228 by root, Mon Oct 8 16:10:14 2007 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3# do splash-screen thingy on win32
3my $startup_done = sub { }; 4my $startup_done = sub { };
4our $PANGO = "1.5.0";
5
6# do splash-screen thingy on win32
7BEGIN { 5BEGIN {
8 if (%PAR::LibCache && $^O eq "MSWin32") { 6 if (%PAR::LibCache && $^O eq "MSWin32") {
9 while (my ($filename, $zip) = each %PAR::LibCache) { 7 while (my ($filename, $zip) = each %PAR::LibCache) {
10 $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp"); 8 $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp");
11 } 9 }
30# do things only needed for single-binary version (par) 28# do things only needed for single-binary version (par)
31BEGIN { 29BEGIN {
32 if (%PAR::LibCache) { 30 if (%PAR::LibCache) {
33 @INC = grep ref, @INC; # weed out all paths except pars loader refs 31 @INC = grep ref, @INC; # weed out all paths except pars loader refs
34 32
35 my $tmp = $ENV{PAR_TEMP}; 33 my $root = $ENV{PAR_TEMP};
36 34
37 while (my ($filename, $zip) = each %PAR::LibCache) { 35 while (my ($filename, $zip) = each %PAR::LibCache) {
38 for ($zip->memberNames) { 36 for ($zip->memberNames) {
39 next unless /^root\/(.*)/; 37 next unless /^root\/(.*)/;
40 $zip->extractMember ($_, "$tmp/$1") 38 $zip->extractMember ($_, "$root/$1")
41 unless -e "$tmp/$1"; 39 unless -e "$root/$1";
42 } 40 }
43 } 41 }
44 42
45 if ($^O eq "MSWin32") { 43 if ($^O eq "MSWin32") {
46 # relocatable 44 # pango is relocatable on win32
47 } else { 45 } else {
46 open my $fh, "<:perlio", "$root/pangoversion"
47 or die "pangoversion: $!";
48 my $PANGO = <$fh>;
48 # unix, need to patch pango rc file 49 # unix, need to patch pango rc file
49 open my $fh, "<:perlio", "$tmp/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules" 50 open my $fh, "<:perlio", "$root/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules"
50 or die "$tmp/usr/lib/$PANGO/module-files.d/libpango1.0-0.modules: $!"; 51 or die "$root/usr/lib/$PANGO/module-files.d/libpango1.0-0.modules: $!";
51 local $/; 52 local $/;
52 my $rc = <$fh>; 53 my $rc = <$fh>;
53 $rc =~ s/^\//$tmp\//gm; # replace abs paths by relative ones 54 $rc =~ s/^\//$root\//gm; # replace abs paths by relative ones
54 55
55 mkdir "$tmp/pango-modules"; 56 mkdir "$root/pango-modules";
56 open my $fh, ">:perlio", "$tmp/pango-modules/pango.modules" 57 open my $fh, ">:perlio", "$root/pango-modules/pango.modules"
57 or die "$tmp/pango-modules/pango.modules: $!"; 58 or die "$root/pango-modules/pango.modules: $!";
58 print $fh $rc; 59 print $fh $rc;
59 60
60 $ENV{PANGO_RC_FILE} = "$tmp/pango.rc"; 61 $ENV{PANGO_RC_FILE} = "$root/pango.rc";
61 open my $fh, ">:perlio", $ENV{PANGO_RC_FILE} 62 open my $fh, ">:perlio", $ENV{PANGO_RC_FILE}
62 or die "$ENV{PANGO_RC_FILE}: $!"; 63 or die "$ENV{PANGO_RC_FILE}: $!";
63 print $fh "[Pango]\nModuleFiles = $tmp/pango-modules\n"; 64 print $fh "[Pango]\nModuleFiles = $root/pango-modules\n";
64 } 65 }
65 66
66 unshift @INC, $tmp; 67 unshift @INC, $root;
67 } 68 }
68} 69}
69 70
70# need to do it again because that pile of garbage called PAR nukes it before main 71# need to do it again because that pile of garbage called PAR nukes it before main
71unshift @INC, $ENV{PAR_TEMP} 72unshift @INC, $ENV{PAR_TEMP}
86use CFPlus::DB; 87use CFPlus::DB;
87use CFPlus::UI; 88use CFPlus::UI;
88use CFPlus::UI::Canvas; 89use CFPlus::UI::Canvas;
89use CFPlus::UI::Inventory; 90use CFPlus::UI::Inventory;
90use CFPlus::UI::SpellList; 91use CFPlus::UI::SpellList;
92use CFPlus::UI::Dockable;
91use CFPlus::UI::MessageWindow; 93use CFPlus::UI::MessageWindow;
94use CFPlus::UI::ChatView;
92use CFPlus::Pod; 95use CFPlus::Pod;
93use CFPlus::MapWidget; 96use CFPlus::MapWidget;
94use CFPlus::Macro; 97use CFPlus::Macro;
95 98
96$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 99$SIG{QUIT} = sub { Carp::cluck "QUIT" };
182sub debug { 185sub debug {
183 $DEBUG_STATUS->set_text ($_[0]); 186 $DEBUG_STATUS->set_text ($_[0]);
184} 187}
185 188
186sub message { 189sub message {
187 my ($para) = @_;
188 $MESSAGE_WINDOW->message ($para); 190 $MESSAGE_WINDOW->message (@_);
189} 191}
190 192
191############################################################################# 193#############################################################################
192#TODO: maybe move into own audio module... 194#TODO: maybe move into own audio module...
193 195
406} 408}
407 409
408sub audio_init { 410sub audio_init {
409 if ($CFG->{audio_enable}) { 411 if ($CFG->{audio_enable}) {
410 $ENV{MIX_EFFECTSMAXSPEED} = 1; 412 $ENV{MIX_EFFECTSMAXSPEED} = 1;
411 $SDL_MIXER = !CFPlus::Mix_OpenAudio; 413 $SDL_MIXER = !CFPlus::Mix_OpenAudio
414 $CFG->{audio_hw_frequency},
415 CFPlus::MIX_DEFAULT_FORMAT,
416 $CFG->{audio_hw_channels},
417 $CFG->{audio_hw_chunksize};
412 418
413 unless ($SDL_MIXER) { 419 if ($SDL_MIXER) {
420 CFPlus::Mix_AllocateChannels $CFG->{audio_mix_channels};
421
422 audio_music_finished;
423 } else {
414 status "Unable to open sound device: there will be no sound"; 424 status "Unable to open sound device: there will be no sound";
415 return;
416 } 425 }
417
418 CFPlus::Mix_AllocateChannels 16;
419
420 audio_music_finished;
421 } else { 426 } else {
422 undef $SDL_MIXER; 427 undef $SDL_MIXER;
423 } 428 }
429
430 sub audio_tab_update;
431 audio_tab_update;
424} 432}
425 433
426sub audio_shutdown { 434sub audio_shutdown {
427 undef $MUSIC_PLAYER; 435 undef $MUSIC_PLAYER;
428 undef $MUSIC_PLAYING_META; 436 undef $MUSIC_PLAYING_META;
888 ); 896 );
889 897
890 $vbox 898 $vbox
891} 899}
892 900
901our $AUDIO_HW_CHUNKSIZE;
902our $AUDIO_INFO;
903
904sub audio_tab_update {
905 my ($freq, $format, $chans) = CFPlus::Mix_QuerySpec;
906
907 $AUDIO_HW_CHUNKSIZE->set_options ([
908 map {
909 my $ms = sprintf "%dms", 1000 * $_ / $CFG->{audio_hw_frequency};
910 [$_, $ms, "$ms ($_ samples)"],
911 } 256, 512, 1024, 2048, 4096, 8192, 16384, 32768
912 ]);
913
914 my $text = !$freq
915 ? "audio is off"
916 : "Frequency (Hz): $freq\n"
917 . "Channels: $chans";
918
919 $AUDIO_INFO->set_text ($text);
920}
921
893sub audio_setup { 922sub audio_setup {
894 my $vbox = new CFPlus::UI::VBox; 923 my $vbox = new CFPlus::UI::VBox;
895 924
896 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1]); 925 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1]);
897 926
899 928
900 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Audio Enable"); 929 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Audio Enable");
901 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 930 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
902 state => $CFG->{audio_enable}, 931 state => $CFG->{audio_enable},
903 tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.", 932 tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.",
904 on_changed => sub { $CFG->{audio_enable} = $_[1]; 0 } 933 on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 }
905 ); 934 );
906# $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume");
907# $table->add_at (1, 8, new CFPlus::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub {
908# $CFG->{effects_volume} = $_[1];
909# });
910 935
911 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects"); 936 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects");
912 $table->add_at (1, $row, new CFPlus::UI::CheckBox 937 $table->add_at (1, $row, new CFPlus::UI::CheckBox
913 expand => 1, state => $CFG->{effects_enable}, 938 expand => 1, state => $CFG->{effects_enable},
914 tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", 939 tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.",
915 on_changed => sub { 940 on_changed => sub {
916 $CFG->{effects_enable} = $_[1]; 941 $CFG->{effects_enable} = $_[1];
917 $CONN->update_fx_want if $CONN; 942 $CONN->update_fx_want if $CONN;
918 0 943 1
919 } 944 }
920 ); 945 );
921 $table->add_at (2, $row++, new CFPlus::UI::Slider 946 $table->add_at (2, $row++, new CFPlus::UI::Slider
922 expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], 947 expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128],
923 tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " 948 tooltip => "The relative volume of sound effects. Best audio quality is achieved if this "
924 . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.", 949 . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.",
925 on_changed => sub { $CFG->{effects_volume} = $_[1]; 0 } 950 on_changed => sub { $CFG->{effects_volume} = $_[1]; 1 }
926 ); 951 );
927 952
928 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); 953 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music");
929 $table->add_at (1, $row, new CFPlus::UI::CheckBox 954 $table->add_at (1, $row, new CFPlus::UI::CheckBox
930 expand => 1, state => $CFG->{bgm_enable}, 955 expand => 1, state => $CFG->{bgm_enable},
931 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", 956 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.",
932 on_changed => sub { 957 on_changed => sub {
933 $CFG->{bgm_enable} = $_[1]; 958 $CFG->{bgm_enable} = $_[1];
934 $CONN->update_fx_want if $CONN; 959 $CONN->update_fx_want if $CONN;
935 audio_music_push; 960 audio_music_push;
936 0 961 1
937 } 962 }
938 ); 963 );
939 $table->add_at (2, $row++, new CFPlus::UI::Slider 964 $table->add_at (2, $row++, new CFPlus::UI::Slider
940 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], 965 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128],
941 tooltip => "The volume of the background music. Changes are instant.", 966 tooltip => "The volume of the background music. Changes are instant.",
942 on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } 967 on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 }
968 );
969
970 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Frequency");
971 $table->add_at (1, $row++, new CFPlus::UI::Selector
972 c_colspan => 2, expand => 1,
973 value => $CFG->{audio_hw_frequency},
974 options => [
975 [11025, "11 kHz" , "11kHz (low quality)"],
976 [22050, "22 kHz" , "22kHz (reduced quality)"],
977 [44100, "44.1 kHz", "44.1kHz (cd quality)"],
978 [48000, "48 kHz" , "48kHz (studio quality)"],
979 ],
980 tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.",
981 on_changed => sub {
982 $CFG->{audio_hw_frequency} = $_[1];
983 audio_tab_update;
984 1
985 }
986 );
987
988 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Channels");
989 $table->add_at (1, $row++, new CFPlus::UI::Selector
990 c_colspan => 2, expand => 1,
991 value => $CFG->{audio_hw_channels},
992 options => [
993 [1, "Mono" , "Mono (single channel, low quality)"],
994 [2, "Stereo" , "Stereo (dual channe, standard quality)"],
995 [4, "4 Ch Surround", "4 Channel Surround Sound (3d sound, high quality)"],
996 [6, "6 Ch Surround", "6 Channel Surround Sound (3d sound + center + lfe)"],
997 ],
998 tooltip => "The number of independent sound channels to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.",
999 on_changed => sub {
1000 $CFG->{audio_hw_channels} = $_[1];
1001 audio_tab_update;
1002 1
1003 }
1004 );
1005
1006 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Latency");
1007 $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new CFPlus::UI::Selector
1008 c_colspan => 2, expand => 1,
1009 value => $CFG->{audio_hw_chunksize},
1010 tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback "
1011 . "is stuttering, increase this value. Values of 50-100ms are optimal.",
1012 on_changed => sub {
1013 $CFG->{audio_hw_chunksize} = $_[1]
1014 if $_[1];
1015 audio_tab_update;
1016 1
1017 }
1018 );
1019
1020 # should really be a slider
1021 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Mixer Voices");
1022 $table->add_at (1, $row++, new CFPlus::UI::ValSlider
1023 c_colspan => 2, expand => 1,
1024 tooltip => "The number of simultaneous sound effects possible. Higher is better, but also more cpu-intensive and might cause stuttering.",
1025 range => [$::CFG->{audio_mix_channels}, 4, 32, 0, 1],
1026 template => ">= 99",
1027 on_changed => sub {
1028 my ($slider, $value) = @_;
1029
1030 $CFG->{audio_mix_channels} = $value
1031 if $value;
1032 1;
1033 }
943 ); 1034 );
944 1035
945 $table->add_at (1, $row++, new CFPlus::UI::Button 1036 $table->add_at (1, $row++, new CFPlus::UI::Button
946 c_colspan => 2, expand => 1, align => 0, text => "Apply", 1037 c_colspan => 2, expand => 1, align => 0, text => "Apply",
947 tooltip => "Apply the audio settings", 1038 tooltip => "Apply the audio settings",
949 audio_shutdown (); 1040 audio_shutdown ();
950 audio_init (); 1041 audio_init ();
951 0 1042 0
952 } 1043 }
953 ); 1044 );
1045
1046 $vbox->add (new CFPlus::UI::FancyFrame
1047 expand => 1,
1048 label => "Audio Info",
1049 child => ($AUDIO_INFO = new CFPlus::UI::Label ellipsise => 0),
1050 );
1051
1052 audio_tab_update;
954 1053
955 $vbox 1054 $vbox
956} 1055}
957 1056
958sub set_gauge_window_fontsize { 1057sub set_gauge_window_fontsize {
2251 gauge_fontsize => 1, 2350 gauge_fontsize => 1,
2252 gauge_size => 0.35, 2351 gauge_size => 0.35,
2253 stat_fontsize => 0.7, 2352 stat_fontsize => 0.7,
2254 mapsize => 100, 2353 mapsize => 100,
2255 audio_enable => 1, 2354 audio_enable => 1,
2355 audio_hw_channels => 2,
2356 audio_hw_frequency => 22050,
2357 audio_hw_chunksize => 2048,
2358 audio_mix_channels => 8,
2256 effects_enable => 1, 2359 effects_enable => 1,
2257 effects_volume => 1, 2360 effects_volume => 1,
2258 bgm_enable => 1, 2361 bgm_enable => 1,
2259 bgm_volume => 0.5, 2362 bgm_volume => 0.5,
2260 output_sync => 1, 2363 output_sync => 1,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines