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.217 by root, Sun Aug 19 14:09:28 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]);
264 or return; 261 or return;
265 $CFG->{effects_enable} 262 $CFG->{effects_enable}
266 or return; 263 or return;
267 264
268 my $queue = $AUDIO_PLAY{$face} ||= []; 265 my $queue = $AUDIO_PLAY{$face} ||= [];
269 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
270 audio_sound_push $face 267 audio_sound_push $face
271 unless @$queue > 1; 268 unless @$queue > 1;
272} 269}
273 270
274sub audio_music_set_meta { 271sub audio_music_set_meta {
770 state => $CFG->{fullscreen}, 767 state => $CFG->{fullscreen},
771 tooltip => "Bring the client into fullscreen mode.", 768 tooltip => "Bring the client into fullscreen mode.",
772 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } 769 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
773 ); 770 );
774 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->{force_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->{force_opengl11} = $value; 0 }
782 );
783
784 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures");
785 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
786 state => $CFG->{texture_compression},
787 tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but "
788 . "will save a lot of memory and increase performance. The compression algorithm "
789 . "can differ form card to card, so your mileage may vary.",
790 on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 }
791 );
792
775 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); 793 $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 794 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
777 state => $CFG->{fast}, 795 state => $CFG->{fast},
778 tooltip => "Lower the visual quality considerably to speed up rendering.", 796 tooltip => "Lower the visual quality considerably to speed up rendering.",
779 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } 797 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 }
805 823
806 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); 824 $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 825 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
808 state => $CFG->{map_smoothing}, 826 state => $CFG->{map_smoothing},
809 tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " 827 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. " 828 . "This increases load on the graphics subsystem and works only with TRT servers. "
811 . "Changes take effect at next connection only.", 829 . "Changes take effect at next login only.",
812 on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } 830 on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 }
813 ); 831 );
814 832
815 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); 833 $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 834 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
827 ); 845 );
828 846
829 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); 847 $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 848 $table->add_at (1, $row++, new CFPlus::UI::Slider
831 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 849 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.", 850 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant, "
851 . "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 }, 852 on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
834 ); 853 );
835 854
836 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); 855 $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 856 $table->add_at (1, $row++, new CFPlus::UI::Slider
1598 $sw1->add ($INV = new CFPlus::UI::Inventory); 1617 $sw1->add ($INV = new CFPlus::UI::Inventory);
1599 $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); 1618 $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}});
1600 1619
1601 $hb->add (my $vb2 = new CFPlus::UI::VBox); 1620 $hb->add (my $vb2 = new CFPlus::UI::VBox);
1602 1621
1603 $vb2->add ($INV_RIGHT_HB = new CFPlus::UI::HBox); 1622 $vb2->add ($INVR_HB = new CFPlus::UI::HBox);
1604 1623
1605 $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); 1624 $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1);
1606 $sw2->add ($INVR = new CFPlus::UI::Inventory); 1625 $sw2->add ($INVR = new CFPlus::UI::Inventory);
1607 1626
1608 # XXX: Call after $INVR = ... because set_opencont sets the items 1627 # XXX: Call after $INVR = ... because set_opencont sets the items
1863 on_activate => sub { $QUIT_DIALOG->hide; 0 }, 1882 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1864 ); 1883 );
1865 $hb->add (new CFPlus::UI::Button 1884 $hb->add (new CFPlus::UI::Button
1866 text => "Quit anyway", 1885 text => "Quit anyway",
1867 expand => 1, 1886 expand => 1,
1868 on_activate => sub { exit }, 1887 on_activate => sub { Event::unloop_all },
1869 ); 1888 );
1870 } 1889 }
1871 1890
1872 $QUIT_DIALOG->show; 1891 $QUIT_DIALOG->show;
1873 $QUIT_DIALOG->grab_focus; 1892 $QUIT_DIALOG->grab_focus;
2067 tooltip => "Terminates the program", 2086 tooltip => "Terminates the program",
2068 on_activate => sub { 2087 on_activate => sub {
2069 if ($CONN) { 2088 if ($CONN) {
2070 open_quit_dialog; 2089 open_quit_dialog;
2071 } else { 2090 } else {
2072 exit; 2091 Event::unloop_all;
2073 } 2092 }
2074 0 2093 0
2075 }, 2094 },
2076 ); 2095 );
2077 2096
2078 $BUTTONBAR->show; 2097 $BUTTONBAR->show;
2079 $SETUP_DIALOG->show; 2098 $SETUP_DIALOG->show;
2099 $MESSAGE_WINDOW->show;
2080 } 2100 }
2081 2101
2082 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 2102 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
2083} 2103}
2084 2104
2092my $animate_timer; 2112my $animate_timer;
2093 2113
2094my $fps = 9; 2114my $fps = 9;
2095 2115
2096sub force_refresh { 2116sub force_refresh {
2117 if ($ENV{CFPLUS_DEBUG} & 4) {
2097 $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; 2118 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02;
2098 debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; 2119 debug sprintf "%3.2f", $fps;
2120 }
2099 2121
2100 $CFPlus::UI::ROOT->draw; 2122 $CFPlus::UI::ROOT->draw;
2101 2123 CFPlus::SDL_GL_SwapBuffers;
2102 $WANT_REFRESH = 0;
2103 $CAN_REFRESH = 0;
2104 $LAST_REFRESH = $NOW; 2124 $LAST_REFRESH = $NOW;
2105 2125 $WANT_REFRESH->stop;
2106 CFPlus::SDL_GL_SwapBuffers;
2107} 2126}
2108 2127
2128$WANT_REFRESH = Event->idle (min => 0.001, max => 0.06, parked => 1, cb => \&force_refresh);
2129
2109my $refresh_watcher = Event->timer (after => 0, hard => 0, interval => 1 / $MAX_FPS, cb => sub { 2130my $input = Event->timer (after => 0, hard => 0, interval => 1 / 50, cb => sub {
2110 $NOW = time; 2131 $NOW = time;
2111 2132
2112 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) 2133 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_)
2113 for CFPlus::poll_events; 2134 for CFPlus::poll_events;
2114 2135
2115 if (%animate_object) { 2136 if (%animate_object) {
2116 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; 2137 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object;
2117 ++$WANT_REFRESH; 2138 $WANT_REFRESH->start;
2118 }
2119
2120 if ($WANT_REFRESH) {
2121 force_refresh;
2122 } else {
2123 $CAN_REFRESH = 1;
2124 } 2139 }
2125}); 2140});
2126 2141
2127sub animation_start { 2142sub animation_start {
2128 my ($widget) = @_; 2143 my ($widget) = @_;
2183 CFPlus::DB::Server::run; 2198 CFPlus::DB::Server::run;
2184 2199
2185 CFPlus::UI::set_layout ($::CFG->{layout}); 2200 CFPlus::UI::set_layout ($::CFG->{layout});
2186 2201
2187 my %DEF_CFG = ( 2202 my %DEF_CFG = (
2188 sdl_mode => 0, 2203 sdl_mode => 0,
2189 fullscreen => 0, 2204 fullscreen => 0,
2190 fast => 0, 2205 fast => 0,
2206 force_opengl11 => undef,
2207 texture_compression => 1,
2191 map_scale => 1, 2208 map_scale => 1,
2192 fow_enable => 1, 2209 fow_enable => 1,
2193 fow_intensity => 0, 2210 fow_intensity => 0,
2194 map_smoothing => 1, 2211 map_smoothing => 1,
2195 gui_fontsize => 1, 2212 gui_fontsize => 1,
2196 log_fontsize => 0.7, 2213 log_fontsize => 0.7,
2197 gauge_fontsize => 1, 2214 gauge_fontsize => 1,
2198 gauge_size => 0.35, 2215 gauge_size => 0.35,
2199 stat_fontsize => 0.7, 2216 stat_fontsize => 0.7,
2200 mapsize => 100, 2217 mapsize => 100,
2201 audio_enable => 1, 2218 audio_enable => 1,
2202 effects_enable => 1, 2219 effects_enable => 1,
2203 effects_volume => 1, 2220 effects_volume => 1,
2204 bgm_enable => 1, 2221 bgm_enable => 1,
2205 bgm_volume => 0.5, 2222 bgm_volume => 0.5,
2206 output_sync => 1, 2223 output_sync => 1,
2207 output_count => 1, 2224 output_count => 1,
2208 output_rate => "", 2225 output_rate => "",
2209 pickup => 0, 2226 pickup => 0,
2210 inv_sort => "mtime", 2227 inv_sort => "mtime",
2211 default => "profile", # default profile 2228 default => "profile", # default profile
2212 show_tips => 1, 2229 show_tips => 1,
2213 logview_max_par => 1000, 2230 logview_max_par => 1000,
2214 ); 2231 );
2215 2232
2216 while (my ($k, $v) = each %DEF_CFG) { 2233 while (my ($k, $v) = each %DEF_CFG) {
2217 $CFG->{$k} = $v unless exists $CFG->{$k}; 2234 $CFG->{$k} = $v unless exists $CFG->{$k};
2218 } 2235 }
2284} 2301}
2285 2302
2286show_tip_of_the_day if $CFG->{show_tips}; 2303show_tip_of_the_day if $CFG->{show_tips};
2287 2304
2288Event::loop; 2305Event::loop;
2306
2307#video_shutdown;
2308#audio_shutdown;
2289#CFPlus::SDL_Quit; 2309CFPlus::SDL_Quit;
2290#CFPlus::_exit 0;
2291
2292END {
2293 video_shutdown;
2294 audio_shutdown;
2295 CFPlus::SDL_Quit;
2296 CFPlus::DB::Server::stop; 2310CFPlus::DB::Server::stop;
2297}
2298 2311
2299=head1 NAME 2312=head1 NAME
2300 2313
2301cfplus - A Crossfire TRT and Crossfire game client 2314cfplus - A Crossfire TRT and Crossfire game client
2302 2315

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines