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.207 by root, Thu Aug 9 11:02:08 2007 UTC vs.
Revision 1.214 by elmex, Tue Aug 14 14:12:46 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;
264 or return; 263 or return;
265 $CFG->{effects_enable} 264 $CFG->{effects_enable}
266 or return; 265 or return;
267 266
268 my $queue = $AUDIO_PLAY{$face} ||= []; 267 my $queue = $AUDIO_PLAY{$face} ||= [];
269 push @$queue, [Event::time + 0.2, $dx, $dy, $vol]; # delay sound by max. 0.2s 268 push @$queue, [Event::time + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events
270 audio_sound_push $face 269 audio_sound_push $face
271 unless @$queue > 1; 270 unless @$queue > 1;
272} 271}
273 272
274sub audio_music_set_meta { 273sub audio_music_set_meta {
770 state => $CFG->{fullscreen}, 769 state => $CFG->{fullscreen},
771 tooltip => "Bring the client into fullscreen mode.", 770 tooltip => "Bring the client into fullscreen mode.",
772 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } 771 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
773 ); 772 );
774 773
774 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1");
775 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
776 state => $CFG->{opengl11},
777 tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in "
778 . "higher memory usage and slower performance. It will, however, help tremendously on "
779 . "cards that claim to support a feature but fall back to software rendering. "
780 . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, "
781 . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you "
782 . "experience extremely low framerates and your card should do better, try this option.</b>",
783 on_changed => sub { my ($self, $value) = @_; $CFG->{opengl11} = $value; 0 }
784 );
785
775 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); 786 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
776 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 787 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
777 state => $CFG->{fast}, 788 state => $CFG->{fast},
778 tooltip => "Lower the visual quality considerably to speed up rendering.", 789 tooltip => "Lower the visual quality considerably to speed up rendering.",
779 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } 790 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 }
805 816
806 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); 817 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing");
807 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 818 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
808 state => $CFG->{map_smoothing}, 819 state => $CFG->{map_smoothing},
809 tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " 820 tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. "
810 . "This increases load on the graphics subsystem and works only with 2.x servers. " 821 . "This increases load on the graphics subsystem and works only with TRT servers. "
811 . "Changes take effect at next connection only.", 822 . "Changes take effect at next login only.",
812 on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } 823 on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 }
813 ); 824 );
814 825
815 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); 826 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War");
816 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 827 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
827 ); 838 );
828 839
829 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); 840 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize");
830 $table->add_at (1, $row++, new CFPlus::UI::Slider 841 $table->add_at (1, $row++, new CFPlus::UI::Slider
831 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 842 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1],
832 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", 843 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant, "
844 . "but you still need to press apply to correctly re-layout the widget.",
833 on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, 845 on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
834 ); 846 );
835 847
836 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); 848 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
837 $table->add_at (1, $row++, new CFPlus::UI::Slider 849 $table->add_at (1, $row++, new CFPlus::UI::Slider
1863 on_activate => sub { $QUIT_DIALOG->hide; 0 }, 1875 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1864 ); 1876 );
1865 $hb->add (new CFPlus::UI::Button 1877 $hb->add (new CFPlus::UI::Button
1866 text => "Quit anyway", 1878 text => "Quit anyway",
1867 expand => 1, 1879 expand => 1,
1868 on_activate => sub { exit }, 1880 on_activate => sub { Event::unloop_all },
1869 ); 1881 );
1870 } 1882 }
1871 1883
1872 $QUIT_DIALOG->show; 1884 $QUIT_DIALOG->show;
1873 $QUIT_DIALOG->grab_focus; 1885 $QUIT_DIALOG->grab_focus;
2067 tooltip => "Terminates the program", 2079 tooltip => "Terminates the program",
2068 on_activate => sub { 2080 on_activate => sub {
2069 if ($CONN) { 2081 if ($CONN) {
2070 open_quit_dialog; 2082 open_quit_dialog;
2071 } else { 2083 } else {
2072 exit; 2084 Event::unloop_all;
2073 } 2085 }
2074 0 2086 0
2075 }, 2087 },
2076 ); 2088 );
2077 2089
2078 $BUTTONBAR->show; 2090 $BUTTONBAR->show;
2079 $SETUP_DIALOG->show; 2091 $SETUP_DIALOG->show;
2092 $MESSAGE_WINDOW->show;
2080 } 2093 }
2081 2094
2082 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 2095 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
2083} 2096}
2084 2097
2092my $animate_timer; 2105my $animate_timer;
2093 2106
2094my $fps = 9; 2107my $fps = 9;
2095 2108
2096sub force_refresh { 2109sub force_refresh {
2110 if ($ENV{CFPLUS_DEBUG} & 4) {
2097 $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; 2111 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02;
2098 debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; 2112 debug sprintf "%3.2f", $fps;
2113 }
2099 2114
2100 $CFPlus::UI::ROOT->draw; 2115 $CFPlus::UI::ROOT->draw;
2101 2116 CFPlus::SDL_GL_SwapBuffers;
2102 $WANT_REFRESH = 0;
2103 $CAN_REFRESH = 0;
2104 $LAST_REFRESH = $NOW; 2117 $LAST_REFRESH = $NOW;
2105 2118 $WANT_REFRESH->stop;
2106 CFPlus::SDL_GL_SwapBuffers;
2107} 2119}
2108 2120
2121$WANT_REFRESH = Event->idle (min => 0.001, max => 0.06, parked => 1, cb => \&force_refresh);
2122
2109my $refresh_watcher = Event->timer (after => 0, hard => 0, interval => 1 / $MAX_FPS, cb => sub { 2123my $input = Event->timer (after => 0, hard => 0, interval => 1 / 50, cb => sub {
2110 $NOW = time; 2124 $NOW = time;
2111 2125
2112 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) 2126 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_)
2113 for CFPlus::poll_events; 2127 for CFPlus::poll_events;
2114 2128
2115 if (%animate_object) { 2129 if (%animate_object) {
2116 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; 2130 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object;
2117 ++$WANT_REFRESH; 2131 $WANT_REFRESH->start;
2118 }
2119
2120 if ($WANT_REFRESH) {
2121 force_refresh;
2122 } else {
2123 $CAN_REFRESH = 1;
2124 } 2132 }
2125}); 2133});
2126 2134
2127sub animation_start { 2135sub animation_start {
2128 my ($widget) = @_; 2136 my ($widget) = @_;
2186 2194
2187 my %DEF_CFG = ( 2195 my %DEF_CFG = (
2188 sdl_mode => 0, 2196 sdl_mode => 0,
2189 fullscreen => 0, 2197 fullscreen => 0,
2190 fast => 0, 2198 fast => 0,
2199 opengl11 => 0,
2191 map_scale => 1, 2200 map_scale => 1,
2192 fow_enable => 1, 2201 fow_enable => 1,
2193 fow_intensity => 0, 2202 fow_intensity => 0,
2194 map_smoothing => 1, 2203 map_smoothing => 1,
2195 gui_fontsize => 1, 2204 gui_fontsize => 1,
2284} 2293}
2285 2294
2286show_tip_of_the_day if $CFG->{show_tips}; 2295show_tip_of_the_day if $CFG->{show_tips};
2287 2296
2288Event::loop; 2297Event::loop;
2298
2299#video_shutdown;
2300#audio_shutdown;
2289#CFPlus::SDL_Quit; 2301CFPlus::SDL_Quit;
2290#CFPlus::_exit 0;
2291
2292END {
2293 video_shutdown;
2294 audio_shutdown;
2295 CFPlus::SDL_Quit;
2296 CFPlus::DB::Server::stop; 2302CFPlus::DB::Server::stop;
2297}
2298 2303
2299=head1 NAME 2304=head1 NAME
2300 2305
2301cfplus - A Crossfire TRT and Crossfire game client 2306cfplus - A Crossfire TRT and Crossfire game client
2302 2307

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines