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.215 by root, Fri Aug 17 21:18:01 2007 UTC vs.
Revision 1.223 by root, Tue Aug 28 01:23:47 2007 UTC

126our $FONT_FIXED; 126our $FONT_FIXED;
127 127
128our $MAP; 128our $MAP;
129our $MAPMAP; 129our $MAPMAP;
130our $MAPWIDGET; 130our $MAPWIDGET;
131our $COMPLETER;
131our $BUTTONBAR; 132our $BUTTONBAR;
132our $METASERVER; 133our $METASERVER;
133our $LOGIN_BUTTON; 134our $LOGIN_BUTTON;
134our $QUIT_DIALOG; 135our $QUIT_DIALOG;
135our $HOST_ENTRY; 136our $HOST_ENTRY;
146our $PL_WINDOW; 147our $PL_WINDOW;
147 148
148our $MUSIC_PLAYING_WIDGET; 149our $MUSIC_PLAYING_WIDGET;
149our $LICENSE_WIDGET; 150our $LICENSE_WIDGET;
150 151
152our $PICKUP_PAGE;
151our $INVENTORY_PAGE; 153our $INVENTORY_PAGE;
152our $STATS_PAGE; 154our $STATS_PAGE;
153our $SKILL_PAGE; 155our $SKILL_PAGE;
154our $SPELL_PAGE; 156our $SPELL_PAGE;
155our $SPELL_LIST; 157our $SPELL_LIST;
228 $channel->set_position_r ($dx, $dy, 20); 230 $channel->set_position_r ($dx, $dy, 20);
229 $chunk->play ($channel); 231 $chunk->play ($channel);
230 } 232 }
231 } else { 233 } else {
232 # sound_meta not set means data is in flight either way 234 # sound_meta not set means data is in flight either way
233 my $meta = $CONN->{sound_meta}{$face} 235 my $meta = $CONN->{face}[$face]
234 or return; 236 or return;
235 237
238 $meta->{data}
239 or return;
240
236 # if its a jingle, play it as ambient music 241 # if its a jingle, play it as ambient music
237 if ($meta->{meta}{jingle}) { 242 if ($meta->{data}{jingle}) {
238 if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue 243 if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue
239 push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue 244 push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue
240 &audio_music_push ($face); 245 &audio_music_push ($face);
241 } 246 }
242 } else { 247 } else {
243 # fetch from database 248 # fetch from database
244 CFPlus::DB::get res_data => $meta->{name}, sub { 249 CFPlus::DB::get res_data => $meta->{name}, sub {
245 my $rwops = new CFPlus::RW $_[0]; 250 my $rwops = new CFPlus::RW $_[0];
246 my $chunk = new CFPlus::MixChunk $rwops 251 my $chunk = new CFPlus::MixChunk $rwops
247 or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; 252 or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError;
248 $chunk->volume (($meta->{meta}{volume} || 1) * 128); 253 $chunk->volume (($meta->{data}{volume} || 1) * 128);
249 $AUDIO_CHUNK{$face} = $chunk; 254 $AUDIO_CHUNK{$face} = $chunk;
250 255
251 audio_sound_push ($face); 256 audio_sound_push ($face);
252 }; 257 };
253 } 258 }
271sub audio_music_set_meta { 276sub audio_music_set_meta {
272 my ($meta) = @_; 277 my ($meta) = @_;
273 278
274 $MUSIC_PLAYING_META = $meta; 279 $MUSIC_PLAYING_META = $meta;
275 $MUSIC_PLAYING_WIDGET->set_markup ( 280 $MUSIC_PLAYING_WIDGET->set_markup (
276 "<b>Name</b>: " . (CFPlus::asxml $meta->{meta}{name}) . "\n" 281 "<b>Name</b>: " . (CFPlus::asxml $meta->{data}{name}) . "\n"
277 . "<b>Author</b>: " . (CFPlus::asxml $meta->{meta}{author}) . "\n" 282 . "<b>Author</b>: " . (CFPlus::asxml $meta->{data}{author}) . "\n"
278 . "<b>Source</b>: " . (CFPlus::asxml $meta->{meta}{source}) . "\n" 283 . "<b>Source</b>: " . (CFPlus::asxml $meta->{data}{source}) . "\n"
279 . "<b>License</b>: " . (CFPlus::asxml $meta->{meta}{license}) 284 . "<b>License</b>: " . (CFPlus::asxml $meta->{data}{license})
280 ); 285 );
281} 286}
282 287
283sub audio_music_update_volume { 288sub audio_music_update_volume {
284 return unless $MUSIC_PLAYING_META; 289 return unless $MUSIC_PLAYING_META;
285 my $volume = $MUSIC_PLAYING_META->{meta}{volume} || 1; 290 my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1;
286 my $base = $MUSIC_PLAYING_META->{meta}{jingle} ? 1 : $CFG->{bgm_volume}; 291 my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume};
287 CFPlus::MixMusic::volume $base * $volume * 128; 292 CFPlus::MixMusic::volume $base * $volume * 128;
288} 293}
289 294
290sub audio_music_start { 295sub audio_music_start {
291 my $meta = $MUSIC_PLAYING_META; 296 my $meta = $MUSIC_PLAYING_META;
334 $fade_out = 333; 339 $fade_out = 333;
335 } else { 340 } else {
336 return unless $CFG->{bgm_enable}; 341 return unless $CFG->{bgm_enable};
337 342
338 my @have = 343 my @have =
339 grep $_, 344 grep $_ && $_->{data},
340 map $CONN->{music_meta}{$_}, 345 map $CONN->{face}[$_],
341 @$MUSIC_WANT; 346 @$MUSIC_WANT;
342 347
343 @MUSIC_HAVE = @have 348 @MUSIC_HAVE = @have
344 if @have; 349 if @have;
345 350
769 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } 774 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
770 ); 775 );
771 776
772 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1"); 777 $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 778 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
774 state => $CFG->{opengl11}, 779 state => $CFG->{force_opengl11},
775 tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in " 780 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 " 781 . "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. " 782 . "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, " 783 . "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 " 784 . "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>", 785 . "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 } 786 on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 }
787 );
788
789 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures");
790 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
791 state => $CFG->{texture_compression},
792 tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but "
793 . "will save a lot of memory and increase performance. The compression algorithm "
794 . "can differ form card to card, so your mileage may vary. This setting is ignored in "
795 . "forced OpenGL 1.1 mode.",
796 on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 }
782 ); 797 );
783 798
784 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); 799 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
785 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 800 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
786 state => $CFG->{fast}, 801 state => $CFG->{fast},
908 expand => 1, state => $CFG->{bgm_enable}, 923 expand => 1, state => $CFG->{bgm_enable},
909 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", 924 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.",
910 on_changed => sub { 925 on_changed => sub {
911 $CFG->{bgm_enable} = $_[1]; 926 $CFG->{bgm_enable} = $_[1];
912 $CONN->update_fx_want if $CONN; 927 $CONN->update_fx_want if $CONN;
928 audio_music_push;
913 0 929 0
914 } 930 }
915 ); 931 );
916 $table->add_at (2, $row++, new CFPlus::UI::Slider 932 $table->add_at (2, $row++, new CFPlus::UI::Slider
917 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], 933 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128],
970 $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); 986 $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health");
971 $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); 987 $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana");
972 $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); 988 $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace");
973 $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); 989 $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food");
974 990
975 $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); 991 $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp");
992 $vbox->add (my $prg = new CFPlus::UI::ExperienceProgress);
993 $vbox->add (my $sklprg = new CFPlus::UI::ExperienceProgress);
976 $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); 994 $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged");
977 995
978 $GAUGES = { 996 $GAUGES = {
997 exp => $exp, prg => $prg, sklprg => $sklprg,
979 exp => $exp, win => $win, range => $rng, 998 win => $win, range => $rng,
980 food => $fg, mana => $mg, hp => $hg, grace => $gg 999 hp => $hg, mana => $mg, grace => $gg, food => $fg,
981 }; 1000 };
982 1001
983 &set_gauge_window_fontsize; 1002 &set_gauge_window_fontsize;
984 1003
985 $win 1004 $win
1186 $r 1205 $r
1187} 1206}
1188 1207
1189sub skill_window { 1208sub skill_window {
1190 my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); 1209 my $sw = new CFPlus::UI::ScrolledWindow (expand => 1);
1210
1191 $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, 0, 0, 1]); 1211 $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]);
1212
1192 $sw 1213 $sw
1193} 1214}
1194 1215
1195sub formsep($) { 1216sub formsep($) {
1196 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 1217 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1
1641} 1662}
1642 1663
1643sub add_license { 1664sub add_license {
1644 my ($meta) = @_; 1665 my ($meta) = @_;
1645 1666
1646 $meta = $meta->{meta} 1667 $meta = $meta->{data}
1647 or return; 1668 or return;
1648 1669
1649 $meta->{license} || $meta->{author} || $meta->{source} 1670 $meta->{license} || $meta->{author} || $meta->{source}
1650 or return; 1671 or return;
1651 1672
1705 $ntb->add_tab ( 1726 $ntb->add_tab (
1706 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, 1727 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget,
1707 "Toggles the inventory window, where you can manage your loot (or treasures :). " 1728 "Toggles the inventory window, where you can manage your loot (or treasures :). "
1708 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." 1729 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."
1709 ); 1730 );
1710 $ntb->add_tab (Pickup => autopickup_setup, 1731 $ntb->add_tab (Pickup => $PICKUP_PAGE = autopickup_setup,
1711 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); 1732 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them.");
1712 1733
1713 $ntb->add_tab (Media => media_window, 1734 $ntb->add_tab (Media => media_window,
1714 "License, Author and Source info for media sent by the server."); 1735 "License, Author and Source info for media sent by the server.");
1715 1736
1956 1977
1957 $SDL_ACTIVE = 1; 1978 $SDL_ACTIVE = 1;
1958 $LAST_REFRESH = time - 0.01; 1979 $LAST_REFRESH = time - 0.01;
1959 1980
1960 CFPlus::OpenGL::init; 1981 CFPlus::OpenGL::init;
1982 CFPlus::Macro::init;
1961 1983
1962 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 1984 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
1963 1985
1964 $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# 1986 $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d#
1965 1987
1966 ############################################################################# 1988 #############################################################################
1967 1989
1968 if ($DEBUG_STATUS) { 1990 if ($DEBUG_STATUS) {
1969 CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; 1991 CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h;
1970 } else { 1992 } else {
1971 # create the widgets 1993 # create/configure the widgets
1994
1995 $CFPlus::UI::ROOT->connect (key_down => sub {
1996 my (undef, $ev) = @_;
1997
1998 if (my @macros = CFPlus::Macro::find $ev) {
1999 CFPlus::Macro::execute $_ for @macros;
2000
2001 return 1;
2002 }
2003
2004 0
2005 });
1972 2006
1973 $DEBUG_STATUS = new CFPlus::UI::Label 2007 $DEBUG_STATUS = new CFPlus::UI::Label
1974 padding => 0, 2008 padding => 0,
1975 z => 100, 2009 z => 100,
1976 force_x => "max", 2010 force_x => "max",
2006 $MESSAGE_WINDOW->activate_console ($preset) 2040 $MESSAGE_WINDOW->activate_console ($preset)
2007 if $MESSAGE_WINDOW; 2041 if $MESSAGE_WINDOW;
2008 }); 2042 });
2009 $MAPWIDGET->show; 2043 $MAPWIDGET->show;
2010 $MAPWIDGET->grab_focus; 2044 $MAPWIDGET->grab_focus;
2045
2046 $COMPLETER = new CFPlus::MapWidget::Command::
2047 command => { },
2048 tooltip => "#completer_help",
2049 ;
2011 2050
2012 $SETUP_DIALOG = new CFPlus::UI::Toplevel 2051 $SETUP_DIALOG = new CFPlus::UI::Toplevel
2013 title => "Setup", 2052 title => "Setup",
2014 name => "setup_dialog", 2053 name => "setup_dialog",
2015 x => 'center', 2054 x => 'center',
2140 delete $animate_object{$widget}; 2179 delete $animate_object{$widget};
2141} 2180}
2142 2181
2143%SDL_CB = ( 2182%SDL_CB = (
2144 CFPlus::SDL_QUIT => sub { 2183 CFPlus::SDL_QUIT => sub {
2145 exit; 2184 Event::unloop_all;
2146 }, 2185 },
2147 CFPlus::SDL_VIDEORESIZE => sub { 2186 CFPlus::SDL_VIDEORESIZE => sub {
2148 }, 2187 },
2149 CFPlus::SDL_VIDEOEXPOSE => sub { 2188 CFPlus::SDL_VIDEOEXPOSE => sub {
2150 CFPlus::UI::full_refresh; 2189 CFPlus::UI::full_refresh;
2189 CFPlus::DB::Server::run; 2228 CFPlus::DB::Server::run;
2190 2229
2191 CFPlus::UI::set_layout ($::CFG->{layout}); 2230 CFPlus::UI::set_layout ($::CFG->{layout});
2192 2231
2193 my %DEF_CFG = ( 2232 my %DEF_CFG = (
2194 sdl_mode => 0, 2233 sdl_mode => 0,
2195 fullscreen => 0, 2234 fullscreen => 0,
2196 fast => 0, 2235 fast => 0,
2197 opengl11 => 0, 2236 force_opengl11 => undef,
2237 texture_compression => 1,
2198 map_scale => 1, 2238 map_scale => 1,
2199 fow_enable => 1, 2239 fow_enable => 1,
2200 fow_intensity => 0, 2240 fow_intensity => 0,
2201 map_smoothing => 1, 2241 map_smoothing => 1,
2202 gui_fontsize => 1, 2242 gui_fontsize => 1,
2203 log_fontsize => 0.7, 2243 log_fontsize => 0.7,
2204 gauge_fontsize => 1, 2244 gauge_fontsize => 1,
2205 gauge_size => 0.35, 2245 gauge_size => 0.35,
2206 stat_fontsize => 0.7, 2246 stat_fontsize => 0.7,
2207 mapsize => 100, 2247 mapsize => 100,
2208 audio_enable => 1, 2248 audio_enable => 1,
2209 effects_enable => 1, 2249 effects_enable => 1,
2210 effects_volume => 1, 2250 effects_volume => 1,
2211 bgm_enable => 1, 2251 bgm_enable => 1,
2212 bgm_volume => 0.5, 2252 bgm_volume => 0.5,
2213 output_sync => 1, 2253 output_sync => 1,
2214 output_count => 1, 2254 output_count => 1,
2215 output_rate => "", 2255 output_rate => "",
2216 pickup => 0, 2256 pickup => 0,
2217 inv_sort => "mtime", 2257 inv_sort => "mtime",
2218 default => "profile", # default profile 2258 default => "profile", # default profile
2219 show_tips => 1, 2259 show_tips => 1,
2220 logview_max_par => 1000, 2260 logview_max_par => 1000,
2221 ); 2261 );
2222 2262
2223 while (my ($k, $v) = each %DEF_CFG) { 2263 while (my ($k, $v) = each %DEF_CFG) {
2224 $CFG->{$k} = $v unless exists $CFG->{$k}; 2264 $CFG->{$k} = $v unless exists $CFG->{$k};
2225 } 2265 }
2282# } 2322# }
2283# my $t2 = Time::HiRes::time; 2323# my $t2 = Time::HiRes::time;
2284# warn $t2-$t1; 2324# warn $t2-$t1;
2285# } 2325# }
2286 2326
2287 $startup_done->();
2288
2289 video_init; 2327 video_init;
2290 audio_init; 2328 audio_init;
2291} 2329}
2292 2330
2293show_tip_of_the_day if $CFG->{show_tips}; 2331show_tip_of_the_day if $CFG->{show_tips};
2332
2333Event->idle (cb => sub {
2334 $_[0]->w->cancel;
2335 $startup_done->();
2336});
2294 2337
2295Event::loop; 2338Event::loop;
2296 2339
2297#video_shutdown; 2340#video_shutdown;
2298#audio_shutdown; 2341#audio_shutdown;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines