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.191 by root, Sun Jul 29 21:31:48 2007 UTC vs.
Revision 1.194 by root, Tue Jul 31 00:50:04 2007 UTC

168our $MUSIC_PLAYING_DATA; 168our $MUSIC_PLAYING_DATA;
169our $MUSIC_PLAYING_META; 169our $MUSIC_PLAYING_META;
170our $MUSIC_PLAYER; 170our $MUSIC_PLAYER;
171our $MUSIC_RESUME = 30; # resume music when players less than these many seconds before 171our $MUSIC_RESUME = 30; # resume music when players less than these many seconds before
172our @SOUNDS; # event => file mapping 172our @SOUNDS; # event => file mapping
173our %AUDIO_CHUNKS; # audio files 173our %AUDIO_CHUNK; # audio files
174 174
175our $ALT_ENTER_MESSAGE; 175our $ALT_ENTER_MESSAGE;
176our $STATUSBOX; 176our $STATUSBOX;
177our $DEBUG_STATUS; 177our $DEBUG_STATUS;
178 178
481 $SETUP_DIALOG->show; 481 $SETUP_DIALOG->show;
482 $PL_WINDOW->hide; 482 $PL_WINDOW->hide;
483 $SPELL_LIST->clear_spells; 483 $SPELL_LIST->clear_spells;
484 $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN); 484 $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN);
485 485
486 &audio_music_set ([]); 486 &audio_music_set_ambient ([]);
487 487
488 return unless $CONN; 488 return unless $CONN;
489 489
490 status "connection closed"; 490 status "connection closed";
491 491
1071 text => $CFG->{profile}{default}{host}, 1071 text => $CFG->{profile}{default}{host},
1072 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to", 1072 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to",
1073 on_changed => sub { 1073 on_changed => sub {
1074 my ($self, $value) = @_; 1074 my ($self, $value) = @_;
1075 $CFG->{profile}{default}{host} = $value; 1075 $CFG->{profile}{default}{host} = $value;
1076 0 1076 1
1077 } 1077 }
1078 ); 1078 );
1079 1079
1080 $vbox->add (new CFPlus::UI::Button 1080 $vbox->add (new CFPlus::UI::Button
1081 expand => 1, 1081 expand => 1,
1082 text => "Server List", 1082 text => "Server List",
1083 other => $METASERVER, 1083 other => $METASERVER,
1084 tooltip => "Show a list of available crossfire servers", 1084 tooltip => "Show a list of available crossfire servers",
1085 on_activate => sub { $METASERVER->toggle_visibility; 0 }, 1085 on_activate => sub { $METASERVER->toggle_visibility; 0 },
1086 on_visibility_change => sub { $METASERVER->hide unless $_[1]; 0 }, 1086 on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 },
1087 ); 1087 );
1088 } 1088 }
1089 1089
1090 $table->add_at (0, 4, new CFPlus::UI::Label valign => 0, align => 1, text => "Username"); 1090 $table->add_at (0, 4, new CFPlus::UI::Label valign => 0, align => 1, text => "Username");
1091 $table->add_at (1, 4, new CFPlus::UI::Entry 1091 $table->add_at (1, 4, new CFPlus::UI::Entry
1092 text => $CFG->{profile}{default}{user}, 1092 text => $CFG->{profile}{default}{user},
1093 tooltip => "The name of your character on the server", 1093 tooltip => "The name of your character on the server",
1094 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value } 1094 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 }
1095 ); 1095 );
1096 1096
1097 $table->add_at (0, 5, new CFPlus::UI::Label valign => 0, align => 1, text => "Password"); 1097 $table->add_at (0, 5, new CFPlus::UI::Label valign => 0, align => 1, text => "Password");
1098 $table->add_at (1, 5, new CFPlus::UI::Entry 1098 $table->add_at (1, 5, new CFPlus::UI::Entry
1099 text => $CFG->{profile}{default}{password}, 1099 text => $CFG->{profile}{default}{password},
1100 hidden => 1, 1100 hidden => 1,
1101 tooltip => "The password for your character", 1101 tooltip => "The password for your character",
1102 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value } 1102 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 }
1103 ); 1103 );
1104 1104
1105 $table->add_at (0, 7, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Size"); 1105 $table->add_at (0, 7, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Size");
1106 $table->add_at (1, 7, new CFPlus::UI::Slider 1106 $table->add_at (1, 7, new CFPlus::UI::Slider
1107 force_w => 100, 1107 force_w => 100,
1108 range => [$CFG->{mapsize}, 10, 100, 0, 1], 1108 range => [$CFG->{mapsize}, 10, 100, 0, 1],
1109 tooltip => "This is the size of the portion of the map update the server sends you. " 1109 tooltip => "This is the size of the portion of the map update the server sends you. "
1110 . "If you set this to a high value you will be able to see further, " 1110 . "If you set this to a high value you will be able to see further, "
1111 . "but you also increase bandwidth requirements and latency. " 1111 . "but you also increase bandwidth requirements and latency. "
1112 . "This option is only used once at log-in.", 1112 . "This option is only used once at log-in.",
1113 on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 0 }, 1113 on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 1 },
1114 ); 1114 );
1115 1115
1116 $table->add_at (0, 8, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate"); 1116 $table->add_at (0, 8, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate");
1117 $table->add_at (1, 8, new CFPlus::UI::Entry 1117 $table->add_at (1, 8, new CFPlus::UI::Entry
1118 text => $CFG->{output_rate}, 1118 text => $CFG->{output_rate},
1119 tooltip => "The approximate bandwidth in bytes per second that the server should not exceed " 1119 tooltip => "The maximum bandwidth in bytes per second that the server should not exceed "
1120 . "when sending images, to ensure interactiveness. When 0 or unset, the server " 1120 . "when sending data. When 0 or unset, the server "
1121 . "default will be used, which is usually around 100kb/s.", 1121 . "default will be used, which is usually around 100kb/s. Most servers will "
1122 . "dynamically find an optimal rate, so adjust this only when necessary.",
1122 on_changed => sub { $CFG->{output_rate} = $_[1]; 0 }, 1123 on_changed => sub { $CFG->{output_rate} = $_[1]; 1 },
1123 ); 1124 );
1124 1125
1125 $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count"); 1126 $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count");
1126 $table->add_at (1, 9, new CFPlus::UI::Entry 1127 $table->add_at (1, 9, new CFPlus::UI::Entry
1127 text => $CFG->{output_count}, 1128 text => $CFG->{output_count},
1128 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", 1129 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.",
1129 on_changed => sub { $CFG->{output_count} = $_[1]; 0 }, 1130 on_changed => sub { $CFG->{output_count} = $_[1]; 1 },
1130 ); 1131 );
1131 1132
1132 $table->add_at (0, 10, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync"); 1133 $table->add_at (0, 10, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync");
1133 $table->add_at (1, 10, new CFPlus::UI::Entry 1134 $table->add_at (1, 10, new CFPlus::UI::Entry
1134 text => $CFG->{output_sync}, 1135 text => $CFG->{output_sync},
1135 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", 1136 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.",
1136 on_changed => sub { $CFG->{output_sync} = $_[1]; 0 }, 1137 on_changed => sub { $CFG->{output_sync} = $_[1]; 1 },
1137 ); 1138 );
1138 1139
1139 $table->add_at (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button 1140 $table->add_at (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button
1140 expand => 1, 1141 expand => 1,
1141 align => 0, 1142 align => 0,
1142 text => "Login", 1143 text => "Login",
1143 on_activate => sub { 1144 on_activate => sub {
1144 $CONN ? stop_game 1145 $CONN ? stop_game
1145 : start_game; 1146 : start_game;
1146 0 1147 1
1147 }, 1148 },
1148 ); 1149 );
1149 1150
1150 $vbox->add (new CFPlus::UI::FancyFrame 1151 $vbox->add (new CFPlus::UI::FancyFrame
1151 label => "Server Info", 1152 label => "Server Info",
1802 1803
1803 if (my $chunk = $AUDIO_CHUNK{$face}) { 1804 if (my $chunk = $AUDIO_CHUNK{$face}) {
1804 for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { 1805 for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) {
1805 my (undef, $dx, $dy, $vol) = @$_; 1806 my (undef, $dx, $dy, $vol) = @$_;
1806 1807
1807 my $channel = $chunk->play 1808 my $channel = CFPlus::Channel::find;
1808 or return;
1809
1810 $channel->volume (128 + $vol); 1809 $channel->volume (128 + $vol);
1811 $dx = $dx / 10 * 255; 1810 $dx = $dx / 10 * 255;
1812 $channel->set_panning ((min 255, 255 - $dx), (min 255, 255 + $dx)); 1811 $channel->set_panning ((min 255, 255 - $dx), (min 255, 255 + $dx));
1812
1813# my $angle = $dx ? : $dx < 0 ? 1813# my $angle = $dx ? : $dx < 0 ?
1814# my $distance = -$vol; 1814# my $distance = -$vol;
1815# $channel->set_position ($angle, $distance); 1815# $channel->set_position ($angle, $distance);
1816
1817 $chunk->play ($channel);
1816 } 1818 }
1817 } else { 1819 } else {
1818 # sound_meta not set means data is in flight either way 1820 # sound_meta not set means data is in flight either way
1819 my $meta = $CONN->{sound_meta}{$face} 1821 my $meta = $CONN->{sound_meta}{$face}
1820 or return; 1822 or return;
1821 1823
1822 # fetch from database 1824 # fetch from database
1823 CFPlus::DB::get res_data => $meta->{name}, sub { 1825 CFPlus::DB::get res_data => $meta->{name}, sub {
1824 my $vol = $meta->{meta}{volume} || 100; 1826 my $vol = $meta->{meta}{volume} || 1;
1825 my $rwops = new CFPlus::RW $_[0]; 1827 my $rwops = new CFPlus::RW $_[0];
1826 my $chunk = new CFPlus::MixChunk $rwops; 1828 my $chunk = new CFPlus::MixChunk $rwops;
1827 $chunk->volume ($vol * 128 / 100); 1829 $chunk->volume ($vol * 128);
1828 $AUDIO_CHUNK{$face} = $chunk; 1830 $AUDIO_CHUNK{$face} = $chunk;
1829 1831
1830 audio_sound_push ($face); 1832 audio_sound_push ($face);
1831 }; 1833 };
1832 } 1834 }
1842 push @$queue, [Event::time + 0.2, $dx, $dy, $vol]; # delay sound by max. 0.2s 1844 push @$queue, [Event::time + 0.2, $dx, $dy, $vol]; # delay sound by max. 0.2s
1843 audio_sound_push $face 1845 audio_sound_push $face
1844 unless @$queue > 1; 1846 unless @$queue > 1;
1845} 1847}
1846 1848
1847sub audio_music_set { 1849sub audio_music_set_ambient {
1848 my ($songs) = @_; 1850 my ($songs) = @_;
1849 1851
1850 my @want = 1852 my @want =
1851 grep $_, 1853 grep $_,
1852 map $CONN->{music_meta}{$_}, 1854 map $CONN->{music_meta}{$_},
1954 1956
1955sub audio_shutdown { 1957sub audio_shutdown {
1956 CFPlus::Mix_CloseAudio if $SDL_MIXER; 1958 CFPlus::Mix_CloseAudio if $SDL_MIXER;
1957 undef $SDL_MIXER; 1959 undef $SDL_MIXER;
1958 @SOUNDS = (); 1960 @SOUNDS = ();
1959 %AUDIO_CHUNKS = (); 1961 %AUDIO_CHUNK = ();
1960} 1962}
1961 1963
1962my %animate_object; 1964my %animate_object;
1963my $animate_timer; 1965my $animate_timer;
1964 1966
1965my $fps = 9; 1967my $fps = 9;
1966
1967my %demo;#d#
1968 1968
1969sub force_refresh { 1969sub force_refresh {
1970 $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; 1970 $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05;
1971 debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; 1971 debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4;
1972 1972
2057 2057
2058 CFPlus::UI::set_layout ($::CFG->{layout}); 2058 CFPlus::UI::set_layout ($::CFG->{layout});
2059 2059
2060 my %DEF_CFG = ( 2060 my %DEF_CFG = (
2061 sdl_mode => 0, 2061 sdl_mode => 0,
2062 width => 640,
2063 height => 480,
2064 fullscreen => 0, 2062 fullscreen => 0,
2065 fast => 0, 2063 fast => 0,
2066 map_scale => 1, 2064 map_scale => 1,
2067 fow_enable => 1, 2065 fow_enable => 1,
2068 fow_intensity => 0, 2066 fow_intensity => 0,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines