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.206 by root, Thu Aug 9 03:40:44 2007 UTC vs.
Revision 1.215 by root, Fri Aug 17 21:18:01 2007 UTC

113our $CONN; 113our $CONN;
114our $PROFILE; # current profile 114our $PROFILE; # current profile
115our $FAST; # fast, low-quality mode, possibly useful for software-rendering 115our $FAST; # fast, low-quality mode, possibly useful for software-rendering
116 116
117our $WANT_REFRESH; 117our $WANT_REFRESH;
118our $CAN_REFRESH;
119 118
120our @SDL_MODES; 119our @SDL_MODES;
121our $WIDTH; 120our $WIDTH;
122our $HEIGHT; 121our $HEIGHT;
123our $FULLSCREEN; 122our $FULLSCREEN;
168our $STATUSBOX; 167our $STATUSBOX;
169our $DEBUG_STATUS; 168our $DEBUG_STATUS;
170 169
171our $INV; 170our $INV;
172our $INVR; 171our $INVR;
173our $INV_RIGHT_HB; 172our $INVR_HB;
174
175our $PICKUP_CFG;
176 173
177############################################################################# 174#############################################################################
178 175
179sub status { 176sub status {
180 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 177 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
226 for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { 223 for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) {
227 my (undef, $dx, $dy, $vol) = @$_; 224 my (undef, $dx, $dy, $vol) = @$_;
228 225
229 my $channel = CFPlus::Channel::find; 226 my $channel = CFPlus::Channel::find;
230 $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); 227 $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255);
231 $dx = $dx / 10 * 255;
232 $channel->set_panning (255 - $dx, 255 + $dx);
233
234# my $angle = $dx ? : $dx < 0 ?
235# my $distance = -$vol;
236# $channel->set_position ($angle, $distance); 228 $channel->set_position_r ($dx, $dy, 20);
237
238 $chunk->play ($channel); 229 $chunk->play ($channel);
239 } 230 }
240 } else { 231 } else {
241 # sound_meta not set means data is in flight either way 232 # sound_meta not set means data is in flight either way
242 my $meta = $CONN->{sound_meta}{$face} 233 my $meta = $CONN->{sound_meta}{$face}
270 or return; 261 or return;
271 $CFG->{effects_enable} 262 $CFG->{effects_enable}
272 or return; 263 or return;
273 264
274 my $queue = $AUDIO_PLAY{$face} ||= []; 265 my $queue = $AUDIO_PLAY{$face} ||= [];
275 push @$queue, [Event::time + 0.2, $dx, $dy, $vol]; # delay sound by max. 0.2s 266 push @$queue, [Event::time + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events
276 audio_sound_push $face 267 audio_sound_push $face
277 unless @$queue > 1; 268 unless @$queue > 1;
278} 269}
279 270
280sub audio_music_set_meta { 271sub audio_music_set_meta {
776 state => $CFG->{fullscreen}, 767 state => $CFG->{fullscreen},
777 tooltip => "Bring the client into fullscreen mode.", 768 tooltip => "Bring the client into fullscreen mode.",
778 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } 769 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
779 ); 770 );
780 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
781 $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");
782 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 785 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
783 state => $CFG->{fast}, 786 state => $CFG->{fast},
784 tooltip => "Lower the visual quality considerably to speed up rendering.", 787 tooltip => "Lower the visual quality considerably to speed up rendering.",
785 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } 788 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 }
811 814
812 $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");
813 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 816 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
814 state => $CFG->{map_smoothing}, 817 state => $CFG->{map_smoothing},
815 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. "
816 . "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. "
817 . "Changes take effect at next connection only.", 820 . "Changes take effect at next login only.",
818 on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } 821 on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 }
819 ); 822 );
820 823
821 $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");
822 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 825 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
833 ); 836 );
834 837
835 $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");
836 $table->add_at (1, $row++, new CFPlus::UI::Slider 839 $table->add_at (1, $row++, new CFPlus::UI::Slider
837 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 840 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1],
838 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.",
839 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 },
840 ); 844 );
841 845
842 $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");
843 $table->add_at (1, $row++, new CFPlus::UI::Slider 847 $table->add_at (1, $row++, new CFPlus::UI::Slider
1604 $sw1->add ($INV = new CFPlus::UI::Inventory); 1608 $sw1->add ($INV = new CFPlus::UI::Inventory);
1605 $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); 1609 $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}});
1606 1610
1607 $hb->add (my $vb2 = new CFPlus::UI::VBox); 1611 $hb->add (my $vb2 = new CFPlus::UI::VBox);
1608 1612
1609 $vb2->add ($INV_RIGHT_HB = new CFPlus::UI::HBox); 1613 $vb2->add ($INVR_HB = new CFPlus::UI::HBox);
1610 1614
1611 $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);
1612 $sw2->add ($INVR = new CFPlus::UI::Inventory); 1616 $sw2->add ($INVR = new CFPlus::UI::Inventory);
1613 1617
1614 # XXX: Call after $INVR = ... because set_opencont sets the items 1618 # XXX: Call after $INVR = ... because set_opencont sets the items
1869 on_activate => sub { $QUIT_DIALOG->hide; 0 }, 1873 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1870 ); 1874 );
1871 $hb->add (new CFPlus::UI::Button 1875 $hb->add (new CFPlus::UI::Button
1872 text => "Quit anyway", 1876 text => "Quit anyway",
1873 expand => 1, 1877 expand => 1,
1874 on_activate => sub { exit }, 1878 on_activate => sub { Event::unloop_all },
1875 ); 1879 );
1876 } 1880 }
1877 1881
1878 $QUIT_DIALOG->show; 1882 $QUIT_DIALOG->show;
1879 $QUIT_DIALOG->grab_focus; 1883 $QUIT_DIALOG->grab_focus;
2073 tooltip => "Terminates the program", 2077 tooltip => "Terminates the program",
2074 on_activate => sub { 2078 on_activate => sub {
2075 if ($CONN) { 2079 if ($CONN) {
2076 open_quit_dialog; 2080 open_quit_dialog;
2077 } else { 2081 } else {
2078 exit; 2082 Event::unloop_all;
2079 } 2083 }
2080 0 2084 0
2081 }, 2085 },
2082 ); 2086 );
2083 2087
2084 $BUTTONBAR->show; 2088 $BUTTONBAR->show;
2085 $SETUP_DIALOG->show; 2089 $SETUP_DIALOG->show;
2090 $MESSAGE_WINDOW->show;
2086 } 2091 }
2087 2092
2088 $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]);
2089} 2094}
2090 2095
2098my $animate_timer; 2103my $animate_timer;
2099 2104
2100my $fps = 9; 2105my $fps = 9;
2101 2106
2102sub force_refresh { 2107sub force_refresh {
2108 if ($ENV{CFPLUS_DEBUG} & 4) {
2103 $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;
2104 debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; 2110 debug sprintf "%3.2f", $fps;
2111 }
2105 2112
2106 $CFPlus::UI::ROOT->draw; 2113 $CFPlus::UI::ROOT->draw;
2107 2114 CFPlus::SDL_GL_SwapBuffers;
2108 $WANT_REFRESH = 0;
2109 $CAN_REFRESH = 0;
2110 $LAST_REFRESH = $NOW; 2115 $LAST_REFRESH = $NOW;
2111 2116 $WANT_REFRESH->stop;
2112 CFPlus::SDL_GL_SwapBuffers;
2113} 2117}
2114 2118
2119$WANT_REFRESH = Event->idle (min => 0.001, max => 0.06, parked => 1, cb => \&force_refresh);
2120
2115my $refresh_watcher = Event->timer (after => 0, hard => 0, interval => 1 / $MAX_FPS, cb => sub { 2121my $input = Event->timer (after => 0, hard => 0, interval => 1 / 50, cb => sub {
2116 $NOW = time; 2122 $NOW = time;
2117 2123
2118 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) 2124 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_)
2119 for CFPlus::poll_events; 2125 for CFPlus::poll_events;
2120 2126
2121 if (%animate_object) { 2127 if (%animate_object) {
2122 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; 2128 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object;
2123 ++$WANT_REFRESH; 2129 $WANT_REFRESH->start;
2124 }
2125
2126 if ($WANT_REFRESH) {
2127 force_refresh;
2128 } else {
2129 $CAN_REFRESH = 1;
2130 } 2130 }
2131}); 2131});
2132 2132
2133sub animation_start { 2133sub animation_start {
2134 my ($widget) = @_; 2134 my ($widget) = @_;
2192 2192
2193 my %DEF_CFG = ( 2193 my %DEF_CFG = (
2194 sdl_mode => 0, 2194 sdl_mode => 0,
2195 fullscreen => 0, 2195 fullscreen => 0,
2196 fast => 0, 2196 fast => 0,
2197 opengl11 => 0,
2197 map_scale => 1, 2198 map_scale => 1,
2198 fow_enable => 1, 2199 fow_enable => 1,
2199 fow_intensity => 0, 2200 fow_intensity => 0,
2200 map_smoothing => 1, 2201 map_smoothing => 1,
2201 gui_fontsize => 1, 2202 gui_fontsize => 1,
2290} 2291}
2291 2292
2292show_tip_of_the_day if $CFG->{show_tips}; 2293show_tip_of_the_day if $CFG->{show_tips};
2293 2294
2294Event::loop; 2295Event::loop;
2296
2297#video_shutdown;
2298#audio_shutdown;
2295#CFPlus::SDL_Quit; 2299CFPlus::SDL_Quit;
2296#CFPlus::_exit 0;
2297
2298END {
2299 video_shutdown;
2300 audio_shutdown;
2301 CFPlus::SDL_Quit;
2302 CFPlus::DB::Server::stop; 2300CFPlus::DB::Server::stop;
2303}
2304 2301
2305=head1 NAME 2302=head1 NAME
2306 2303
2307cfplus - A Crossfire TRT and Crossfire game client 2304cfplus - A Crossfire TRT and Crossfire game client
2308 2305

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines