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.212 by root, Sun Aug 12 13:09:44 2007 UTC vs.
Revision 1.224 by root, Thu Aug 30 07:57:59 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;
167our $STATUSBOX; 169our $STATUSBOX;
168our $DEBUG_STATUS; 170our $DEBUG_STATUS;
169 171
170our $INV; 172our $INV;
171our $INVR; 173our $INVR;
172our $INV_RIGHT_HB; 174our $INVR_HB;
173
174our $PICKUP_CFG;
175 175
176############################################################################# 176#############################################################################
177 177
178sub status { 178sub status {
179 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 179 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
230 $channel->set_position_r ($dx, $dy, 20); 230 $channel->set_position_r ($dx, $dy, 20);
231 $chunk->play ($channel); 231 $chunk->play ($channel);
232 } 232 }
233 } else { 233 } else {
234 # sound_meta not set means data is in flight either way 234 # sound_meta not set means data is in flight either way
235 my $meta = $CONN->{sound_meta}{$face} 235 my $meta = $CONN->{face}[$face]
236 or return; 236 or return;
237 237
238 $meta->{data}
239 or return;
240
238 # if its a jingle, play it as ambient music 241 # if its a jingle, play it as ambient music
239 if ($meta->{meta}{jingle}) { 242 if ($meta->{data}{jingle}) {
240 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
241 push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue 244 push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue
242 &audio_music_push ($face); 245 &audio_music_push ($face);
243 } 246 }
244 } else { 247 } else {
245 # fetch from database 248 # fetch from database
246 CFPlus::DB::get res_data => $meta->{name}, sub { 249 CFPlus::DB::get res_data => $meta->{name}, sub {
247 my $rwops = new CFPlus::RW $_[0]; 250 my $rwops = new CFPlus::RW $_[0];
248 my $chunk = new CFPlus::MixChunk $rwops 251 my $chunk = new CFPlus::MixChunk $rwops
249 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;
250 $chunk->volume (($meta->{meta}{volume} || 1) * 128); 253 $chunk->volume (($meta->{data}{volume} || 1) * 128);
251 $AUDIO_CHUNK{$face} = $chunk; 254 $AUDIO_CHUNK{$face} = $chunk;
252 255
253 audio_sound_push ($face); 256 audio_sound_push ($face);
254 }; 257 };
255 } 258 }
273sub audio_music_set_meta { 276sub audio_music_set_meta {
274 my ($meta) = @_; 277 my ($meta) = @_;
275 278
276 $MUSIC_PLAYING_META = $meta; 279 $MUSIC_PLAYING_META = $meta;
277 $MUSIC_PLAYING_WIDGET->set_markup ( 280 $MUSIC_PLAYING_WIDGET->set_markup (
278 "<b>Name</b>: " . (CFPlus::asxml $meta->{meta}{name}) . "\n" 281 "<b>Name</b>: " . (CFPlus::asxml $meta->{data}{name}) . "\n"
279 . "<b>Author</b>: " . (CFPlus::asxml $meta->{meta}{author}) . "\n" 282 . "<b>Author</b>: " . (CFPlus::asxml $meta->{data}{author}) . "\n"
280 . "<b>Source</b>: " . (CFPlus::asxml $meta->{meta}{source}) . "\n" 283 . "<b>Source</b>: " . (CFPlus::asxml $meta->{data}{source}) . "\n"
281 . "<b>License</b>: " . (CFPlus::asxml $meta->{meta}{license}) 284 . "<b>License</b>: " . (CFPlus::asxml $meta->{data}{license})
282 ); 285 );
283} 286}
284 287
285sub audio_music_update_volume { 288sub audio_music_update_volume {
286 return unless $MUSIC_PLAYING_META; 289 return unless $MUSIC_PLAYING_META;
287 my $volume = $MUSIC_PLAYING_META->{meta}{volume} || 1; 290 my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1;
288 my $base = $MUSIC_PLAYING_META->{meta}{jingle} ? 1 : $CFG->{bgm_volume}; 291 my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume};
289 CFPlus::MixMusic::volume $base * $volume * 128; 292 CFPlus::MixMusic::volume $base * $volume * 128;
290} 293}
291 294
292sub audio_music_start { 295sub audio_music_start {
293 my $meta = $MUSIC_PLAYING_META; 296 my $meta = $MUSIC_PLAYING_META;
312 315
313 my $NOW = time; 316 my $NOW = time;
314 317
315 if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { 318 if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) {
316 my $pos = $MUSIC_PLAYING_META->{stop_pos}; 319 my $pos = $MUSIC_PLAYING_META->{stop_pos};
317 $MUSIC_PLAYER->fade_in_pos (0, 1000, $pos); 320 $MUSIC_PLAYER->fade_in_pos (0, 700, $pos);
318 $MUSIC_START = time - $pos; 321 $MUSIC_START = time - $pos;
319 } else { 322 } else {
320 $MUSIC_PLAYER->play (0); 323 $MUSIC_PLAYER->play (0);
321 $MUSIC_START = time; 324 $MUSIC_START = time;
322 } 325 }
336 $fade_out = 333; 339 $fade_out = 333;
337 } else { 340 } else {
338 return unless $CFG->{bgm_enable}; 341 return unless $CFG->{bgm_enable};
339 342
340 my @have = 343 my @have =
341 grep $_, 344 grep $_ && $_->{data},
342 map $CONN->{music_meta}{$_}, 345 map $CONN->{face}[$_],
343 @$MUSIC_WANT; 346 @$MUSIC_WANT;
347
348 # randomize music a bit so that the order is not always the same
349 $_->{stop_time} ||= rand for @have;
344 350
345 @MUSIC_HAVE = @have 351 @MUSIC_HAVE = @have
346 if @have; 352 if @have;
347 353
348 # default MUSIC_HAVE == MUSIC_DEFAULT 354 # default MUSIC_HAVE == MUSIC_DEFAULT
349 @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; 355 @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE;
350 $fade_out = 1000; 356 $fade_out = 700;
351 } 357 }
352 358
353 # if the currently playing song is acceptable, let it continue 359 # if the currently playing song is acceptable, let it continue
354 return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; 360 return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE;
355 361
364 @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; 370 @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE;
365 371
366 # if the most recently-played piece played very recently, 372 # if the most recently-played piece played very recently,
367 # resume it, else choose the oldest piece for rotation. 373 # resume it, else choose the oldest piece for rotation.
368 audio_music_set_meta 374 audio_music_set_meta
369 $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME 375 $MUSIC_HAVE[-1]{stop_pos} && $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME
370 ? $MUSIC_HAVE[-1] 376 ? $MUSIC_HAVE[-1]
371 : $MUSIC_HAVE[0]; 377 : $MUSIC_HAVE[0];
372 378
373 audio_music_start; 379 audio_music_start;
374 } 380 }
380 $MUSIC_WANT = $songs; 386 $MUSIC_WANT = $songs;
381 audio_music_push; 387 audio_music_push;
382} 388}
383 389
384sub audio_music_finished { 390sub audio_music_finished {
391 if ($MUSIC_PLAYING_META) {
392 $MUSIC_PLAYING_META->{stop_time} = time;
393 }
394
385 # we compress multiple jingles of the same type 395 # we compress multiple jingles of the same type
386 shift @MUSIC_JINGLE 396 shift @MUSIC_JINGLE
387 while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0]; 397 while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0];
388 398
389 $MUSIC_PLAYING_WIDGET->clear; 399 $MUSIC_PLAYING_WIDGET->clear;
771 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } 781 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
772 ); 782 );
773 783
774 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1"); 784 $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 785 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
776 state => $CFG->{opengl11}, 786 state => $CFG->{force_opengl11},
777 tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in " 787 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 " 788 . "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. " 789 . "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, " 790 . "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 " 791 . "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>", 792 . "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 } 793 on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 }
794 );
795
796 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures");
797 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
798 state => $CFG->{texture_compression},
799 tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but "
800 . "will save a lot of memory and increase performance. The compression algorithm "
801 . "can differ form card to card, so your mileage may vary. This setting is ignored in "
802 . "forced OpenGL 1.1 mode.",
803 on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 }
784 ); 804 );
785 805
786 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); 806 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
787 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 807 $table->add_at (1, $row++, new CFPlus::UI::CheckBox
788 state => $CFG->{fast}, 808 state => $CFG->{fast},
910 expand => 1, state => $CFG->{bgm_enable}, 930 expand => 1, state => $CFG->{bgm_enable},
911 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", 931 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.",
912 on_changed => sub { 932 on_changed => sub {
913 $CFG->{bgm_enable} = $_[1]; 933 $CFG->{bgm_enable} = $_[1];
914 $CONN->update_fx_want if $CONN; 934 $CONN->update_fx_want if $CONN;
935 audio_music_push;
915 0 936 0
916 } 937 }
917 ); 938 );
918 $table->add_at (2, $row++, new CFPlus::UI::Slider 939 $table->add_at (2, $row++, new CFPlus::UI::Slider
919 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], 940 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128],
972 $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); 993 $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health");
973 $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); 994 $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana");
974 $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); 995 $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace");
975 $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); 996 $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food");
976 997
977 $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); 998 $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp");
999 $vbox->add (my $prg = new CFPlus::UI::ExperienceProgress);
1000 $vbox->add (my $sklprg = new CFPlus::UI::ExperienceProgress);
978 $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); 1001 $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged");
979 1002
980 $GAUGES = { 1003 $GAUGES = {
1004 exp => $exp, prg => $prg, sklprg => $sklprg,
981 exp => $exp, win => $win, range => $rng, 1005 win => $win, range => $rng,
982 food => $fg, mana => $mg, hp => $hg, grace => $gg 1006 hp => $hg, mana => $mg, grace => $gg, food => $fg,
983 }; 1007 };
984 1008
985 &set_gauge_window_fontsize; 1009 &set_gauge_window_fontsize;
986 1010
987 $win 1011 $win
1188 $r 1212 $r
1189} 1213}
1190 1214
1191sub skill_window { 1215sub skill_window {
1192 my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); 1216 my $sw = new CFPlus::UI::ScrolledWindow (expand => 1);
1217
1193 $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, 0, 0, 1]); 1218 $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]);
1219
1194 $sw 1220 $sw
1195} 1221}
1196 1222
1197sub formsep($) { 1223sub formsep($) {
1198 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 1224 scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1
1610 $sw1->add ($INV = new CFPlus::UI::Inventory); 1636 $sw1->add ($INV = new CFPlus::UI::Inventory);
1611 $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); 1637 $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}});
1612 1638
1613 $hb->add (my $vb2 = new CFPlus::UI::VBox); 1639 $hb->add (my $vb2 = new CFPlus::UI::VBox);
1614 1640
1615 $vb2->add ($INV_RIGHT_HB = new CFPlus::UI::HBox); 1641 $vb2->add ($INVR_HB = new CFPlus::UI::HBox);
1616 1642
1617 $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); 1643 $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1);
1618 $sw2->add ($INVR = new CFPlus::UI::Inventory); 1644 $sw2->add ($INVR = new CFPlus::UI::Inventory);
1619 1645
1620 # XXX: Call after $INVR = ... because set_opencont sets the items 1646 # XXX: Call after $INVR = ... because set_opencont sets the items
1643} 1669}
1644 1670
1645sub add_license { 1671sub add_license {
1646 my ($meta) = @_; 1672 my ($meta) = @_;
1647 1673
1648 $meta = $meta->{meta} 1674 $meta = $meta->{data}
1649 or return; 1675 or return;
1650 1676
1651 $meta->{license} || $meta->{author} || $meta->{source} 1677 $meta->{license} || $meta->{author} || $meta->{source}
1652 or return; 1678 or return;
1653 1679
1707 $ntb->add_tab ( 1733 $ntb->add_tab (
1708 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, 1734 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget,
1709 "Toggles the inventory window, where you can manage your loot (or treasures :). " 1735 "Toggles the inventory window, where you can manage your loot (or treasures :). "
1710 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." 1736 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."
1711 ); 1737 );
1712 $ntb->add_tab (Pickup => autopickup_setup, 1738 $ntb->add_tab (Pickup => $PICKUP_PAGE = autopickup_setup,
1713 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); 1739 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them.");
1714 1740
1715 $ntb->add_tab (Media => media_window, 1741 $ntb->add_tab (Media => media_window,
1716 "License, Author and Source info for media sent by the server."); 1742 "License, Author and Source info for media sent by the server.");
1717 1743
1875 on_activate => sub { $QUIT_DIALOG->hide; 0 }, 1901 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1876 ); 1902 );
1877 $hb->add (new CFPlus::UI::Button 1903 $hb->add (new CFPlus::UI::Button
1878 text => "Quit anyway", 1904 text => "Quit anyway",
1879 expand => 1, 1905 expand => 1,
1880 on_activate => sub { exit }, 1906 on_activate => sub { Event::unloop_all },
1881 ); 1907 );
1882 } 1908 }
1883 1909
1884 $QUIT_DIALOG->show; 1910 $QUIT_DIALOG->show;
1885 $QUIT_DIALOG->grab_focus; 1911 $QUIT_DIALOG->grab_focus;
1958 1984
1959 $SDL_ACTIVE = 1; 1985 $SDL_ACTIVE = 1;
1960 $LAST_REFRESH = time - 0.01; 1986 $LAST_REFRESH = time - 0.01;
1961 1987
1962 CFPlus::OpenGL::init; 1988 CFPlus::OpenGL::init;
1989 CFPlus::Macro::init;
1963 1990
1964 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 1991 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
1965 1992
1966 $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# 1993 $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d#
1967 1994
1968 ############################################################################# 1995 #############################################################################
1969 1996
1970 if ($DEBUG_STATUS) { 1997 if ($DEBUG_STATUS) {
1971 CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; 1998 CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h;
1972 } else { 1999 } else {
1973 # create the widgets 2000 # create/configure the widgets
2001
2002 $CFPlus::UI::ROOT->connect (key_down => sub {
2003 my (undef, $ev) = @_;
2004
2005 if (my @macros = CFPlus::Macro::find $ev) {
2006 CFPlus::Macro::execute $_ for @macros;
2007
2008 return 1;
2009 }
2010
2011 0
2012 });
1974 2013
1975 $DEBUG_STATUS = new CFPlus::UI::Label 2014 $DEBUG_STATUS = new CFPlus::UI::Label
1976 padding => 0, 2015 padding => 0,
1977 z => 100, 2016 z => 100,
1978 force_x => "max", 2017 force_x => "max",
2008 $MESSAGE_WINDOW->activate_console ($preset) 2047 $MESSAGE_WINDOW->activate_console ($preset)
2009 if $MESSAGE_WINDOW; 2048 if $MESSAGE_WINDOW;
2010 }); 2049 });
2011 $MAPWIDGET->show; 2050 $MAPWIDGET->show;
2012 $MAPWIDGET->grab_focus; 2051 $MAPWIDGET->grab_focus;
2052
2053 $COMPLETER = new CFPlus::MapWidget::Command::
2054 command => { },
2055 tooltip => "#completer_help",
2056 ;
2013 2057
2014 $SETUP_DIALOG = new CFPlus::UI::Toplevel 2058 $SETUP_DIALOG = new CFPlus::UI::Toplevel
2015 title => "Setup", 2059 title => "Setup",
2016 name => "setup_dialog", 2060 name => "setup_dialog",
2017 x => 'center', 2061 x => 'center',
2079 tooltip => "Terminates the program", 2123 tooltip => "Terminates the program",
2080 on_activate => sub { 2124 on_activate => sub {
2081 if ($CONN) { 2125 if ($CONN) {
2082 open_quit_dialog; 2126 open_quit_dialog;
2083 } else { 2127 } else {
2084 exit; 2128 Event::unloop_all;
2085 } 2129 }
2086 0 2130 0
2087 }, 2131 },
2088 ); 2132 );
2089 2133
2090 $BUTTONBAR->show; 2134 $BUTTONBAR->show;
2091 $SETUP_DIALOG->show; 2135 $SETUP_DIALOG->show;
2136 $MESSAGE_WINDOW->show;
2092 } 2137 }
2093 2138
2094 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 2139 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
2095} 2140}
2096 2141
2141 delete $animate_object{$widget}; 2186 delete $animate_object{$widget};
2142} 2187}
2143 2188
2144%SDL_CB = ( 2189%SDL_CB = (
2145 CFPlus::SDL_QUIT => sub { 2190 CFPlus::SDL_QUIT => sub {
2146 exit; 2191 Event::unloop_all;
2147 }, 2192 },
2148 CFPlus::SDL_VIDEORESIZE => sub { 2193 CFPlus::SDL_VIDEORESIZE => sub {
2149 }, 2194 },
2150 CFPlus::SDL_VIDEOEXPOSE => sub { 2195 CFPlus::SDL_VIDEOEXPOSE => sub {
2151 CFPlus::UI::full_refresh; 2196 CFPlus::UI::full_refresh;
2190 CFPlus::DB::Server::run; 2235 CFPlus::DB::Server::run;
2191 2236
2192 CFPlus::UI::set_layout ($::CFG->{layout}); 2237 CFPlus::UI::set_layout ($::CFG->{layout});
2193 2238
2194 my %DEF_CFG = ( 2239 my %DEF_CFG = (
2195 sdl_mode => 0, 2240 sdl_mode => 0,
2196 fullscreen => 0, 2241 fullscreen => 0,
2197 fast => 0, 2242 fast => 0,
2198 opengl11 => 0, 2243 force_opengl11 => undef,
2244 texture_compression => 1,
2199 map_scale => 1, 2245 map_scale => 1,
2200 fow_enable => 1, 2246 fow_enable => 1,
2201 fow_intensity => 0, 2247 fow_intensity => 0,
2202 map_smoothing => 1, 2248 map_smoothing => 1,
2203 gui_fontsize => 1, 2249 gui_fontsize => 1,
2204 log_fontsize => 0.7, 2250 log_fontsize => 0.7,
2205 gauge_fontsize => 1, 2251 gauge_fontsize => 1,
2206 gauge_size => 0.35, 2252 gauge_size => 0.35,
2207 stat_fontsize => 0.7, 2253 stat_fontsize => 0.7,
2208 mapsize => 100, 2254 mapsize => 100,
2209 audio_enable => 1, 2255 audio_enable => 1,
2210 effects_enable => 1, 2256 effects_enable => 1,
2211 effects_volume => 1, 2257 effects_volume => 1,
2212 bgm_enable => 1, 2258 bgm_enable => 1,
2213 bgm_volume => 0.5, 2259 bgm_volume => 0.5,
2214 output_sync => 1, 2260 output_sync => 1,
2215 output_count => 1, 2261 output_count => 1,
2216 output_rate => "", 2262 output_rate => "",
2217 pickup => 0, 2263 pickup => 0,
2218 inv_sort => "mtime", 2264 inv_sort => "mtime",
2219 default => "profile", # default profile 2265 default => "profile", # default profile
2220 show_tips => 1, 2266 show_tips => 1,
2221 logview_max_par => 1000, 2267 logview_max_par => 1000,
2222 ); 2268 );
2223 2269
2224 while (my ($k, $v) = each %DEF_CFG) { 2270 while (my ($k, $v) = each %DEF_CFG) {
2225 $CFG->{$k} = $v unless exists $CFG->{$k}; 2271 $CFG->{$k} = $v unless exists $CFG->{$k};
2226 } 2272 }
2283# } 2329# }
2284# my $t2 = Time::HiRes::time; 2330# my $t2 = Time::HiRes::time;
2285# warn $t2-$t1; 2331# warn $t2-$t1;
2286# } 2332# }
2287 2333
2288 $startup_done->();
2289
2290 video_init; 2334 video_init;
2291 audio_init; 2335 audio_init;
2292} 2336}
2293 2337
2294show_tip_of_the_day if $CFG->{show_tips}; 2338show_tip_of_the_day if $CFG->{show_tips};
2295 2339
2340Event->idle (cb => sub {
2341 $_[0]->w->cancel;
2342 $startup_done->();
2343});
2344
2296Event::loop; 2345Event::loop;
2346
2347#video_shutdown;
2348#audio_shutdown;
2297#CFPlus::SDL_Quit; 2349CFPlus::SDL_Quit;
2298#CFPlus::_exit 0;
2299
2300END {
2301 video_shutdown;
2302 audio_shutdown;
2303 CFPlus::SDL_Quit;
2304 CFPlus::DB::Server::stop; 2350CFPlus::DB::Server::stop;
2305}
2306 2351
2307=head1 NAME 2352=head1 NAME
2308 2353
2309cfplus - A Crossfire TRT and Crossfire game client 2354cfplus - A Crossfire TRT and Crossfire game client
2310 2355

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines