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.226 by root, Sat Sep 1 07:22:21 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines