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.152 by root, Tue Apr 24 01:13:15 2007 UTC vs.
Revision 1.166 by root, Thu Jul 12 19:13:20 2007 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3my $startup_done = sub { }; 3my $startup_done = sub { };
4our $PANGO = "1.5.0";
4 5
5# do splash-screen thingy on win32 6# do splash-screen thingy on win32
6BEGIN { 7BEGIN {
7 if (%PAR::LibCache && $^O eq "MSWin32") { 8 if (%PAR::LibCache && $^O eq "MSWin32") {
8 while (my ($filename, $zip) = each %PAR::LibCache) { 9 while (my ($filename, $zip) = each %PAR::LibCache) {
29# do things only needed for single-binary version (par) 30# do things only needed for single-binary version (par)
30BEGIN { 31BEGIN {
31 if (%PAR::LibCache) { 32 if (%PAR::LibCache) {
32 @INC = grep ref, @INC; # weed out all paths except pars loader refs 33 @INC = grep ref, @INC; # weed out all paths except pars loader refs
33 34
35 my $tmp = $ENV{PAR_TEMP};
36
34 while (my ($filename, $zip) = each %PAR::LibCache) { 37 while (my ($filename, $zip) = each %PAR::LibCache) {
35 for ($zip->memberNames) { 38 for ($zip->memberNames) {
36 next unless /^root\/(.*)/; 39 next unless /^root\/(.*)/;
37 $zip->extractMember ($_, "$ENV{PAR_TEMP}/$1") 40 $zip->extractMember ($_, "$tmp/$1")
38 unless -e "$ENV{PAR_TEMP}/$1"; 41 unless -e "$tmp/$1";
39 } 42 }
40 } 43 }
41 44
42 # TODO: pango-rc file, anybody? 45 if ($^O eq "MSWin32") {
46 # relocatable
47 } else {
48 # unix, need to patch pango rc file
49 open my $fh, "<:perlio", "$tmp/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules"
50 or die "$tmp/usr/lib/$PANGO/module-files.d/libpango1.0-0.modules: $!";
51 local $/;
52 my $rc = <$fh>;
53 $rc =~ s/^\//$tmp\//gm; # replace abs paths by relative ones
43 54
44 unshift @INC, $ENV{PAR_TEMP}; 55 mkdir "$tmp/pango-modules";
56 open my $fh, ">:perlio", "$tmp/pango-modules/pango.modules"
57 or die "$tmp/pango-modules/pango.modules: $!";
58 print $fh $rc;
59
60 $ENV{PANGO_RC_FILE} = "$tmp/pango.rc";
61 open my $fh, ">:perlio", $ENV{PANGO_RC_FILE}
62 or die "$ENV{PANGO_RC_FILE}: $!";
63 print $fh "[Pango]\nModuleFiles = $tmp/pango-modules\n";
64 }
65
66 unshift @INC, $tmp;
45 } 67 }
46} 68}
47 69
48# need to do it again because that pile of garbage called PAR nukes it before main 70# need to do it again because that pile of garbage called PAR nukes it before main
49unshift @INC, $ENV{PAR_TEMP} 71unshift @INC, $ENV{PAR_TEMP}
137 159
138our $SDL_ACTIVE; 160our $SDL_ACTIVE;
139our %SDL_CB; 161our %SDL_CB;
140 162
141our $SDL_MIXER; 163our $SDL_MIXER;
164our $MUSIC_DEFAULT = "in_a_heartbeat.ogg";
165our @MUSIC_WANT;
166our $MUSIC_PLAYING;
167our $MUSIC_PLAYER;
142our @SOUNDS; # event => file mapping 168our @SOUNDS; # event => file mapping
143our %AUDIO_CHUNKS; # audio files 169our %AUDIO_CHUNKS; # audio files
144 170
145our $ALT_ENTER_MESSAGE; 171our $ALT_ENTER_MESSAGE;
146our $STATUSBOX; 172our $STATUSBOX;
269 ellipsise => 0, 295 ellipsise => 0,
270 markup => "<span foreground='#ccccff'>$conn->{chargen_race_description}</span>", 296 markup => "<span foreground='#ccccff'>$conn->{chargen_race_description}</span>",
271 ; 297 ;
272 } 298 }
273 299
274 if ($conn->{chargen_race_title}) {
275 unshift @dialog, new CFPlus::UI::Face 300 unshift @dialog, new CFPlus::UI::Face
276 face => $conn->{player}{face}, 301 face => $conn->{player}{face},
277 bg => [.2, .2, .2, 1], 302 bg => [.2, .2, .2, 1],
278 min_w => 64, 303 min_w => 64,
279 min_h => 64, 304 min_h => 64,
280 ;
281 } 305 ;
282 306
283 if ($conn->{chargen_race_title}) { 307 if ($conn->{chargen_race_title}) {
284 unshift @dialog, new CFPlus::UI::Label 308 unshift @dialog, new CFPlus::UI::Label
285 allign => 1, 309 allign => 1,
286 ellipsise => 0, 310 ellipsise => 0,
476 $LOGIN_BUTTON->set_text ("Login"); 500 $LOGIN_BUTTON->set_text ("Login");
477 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); 501 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER);
478 $SETUP_DIALOG->show; 502 $SETUP_DIALOG->show;
479 $PL_WINDOW->hide; 503 $PL_WINDOW->hide;
480 $SPELL_LIST->clear_spells; 504 $SPELL_LIST->clear_spells;
505 $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN);
506
507 &audio_music_set ([]);
481 508
482 return unless $CONN; 509 return unless $CONN;
483 510
484 status "connection closed"; 511 status "connection closed";
485 512
726 $table->add (1, 1, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); 753 $table->add (1, 1, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 });
727 $table->add (0, 2, new CFPlus::UI::Label text => "Show FPS"); 754 $table->add (0, 2, new CFPlus::UI::Label text => "Show FPS");
728 $table->add (1, 2, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); 755 $table->add (1, 2, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 });
729 $table->add (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips"); 756 $table->add (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips");
730 $table->add (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); 757 $table->add (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 });
731 $table->add (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { die "violator" } ); 758 $table->add (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } );
732 759
733 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05); 760 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05);
734 761
735 for my $x (0..2) { 762 for my $x (0..2) {
736 for my $y (0 .. 2) { 763 for my $y (0 .. 2) {
1434 has_close_button => 1 1461 has_close_button => 1
1435 ; 1462 ;
1436 1463
1437 my $ntb = 1464 my $ntb =
1438 $PL_NOTEBOOK = 1465 $PL_NOTEBOOK =
1439 new CFPlus::UI::Notebook expand => 1, debug => 1; 1466 new CFPlus::UI::Notebook expand => 1;
1440 1467
1441 $ntb->add ( 1468 $ntb->add (
1442 "Statistics (F2)" => $STATS_PAGE = stats_window, 1469 "Statistics (F2)" => $STATS_PAGE = stats_window,
1443 "Shows statistics, where all your Stats and Resistances are shown." 1470 "Shows statistics, where all your Stats and Resistances are shown."
1444 ); 1471 );
1456 $ntb->add ( 1483 $ntb->add (
1457 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, 1484 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget,
1458 "Toggles the inventory window, where you can manage your loot (or treasures :). " 1485 "Toggles the inventory window, where you can manage your loot (or treasures :). "
1459 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." 1486 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."
1460 ); 1487 );
1488 $ntb->add (Pickup => autopickup_setup,
1489 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them.");
1461 1490
1462 $ntb->set_current_page ($INVENTORY_PAGE); 1491 $ntb->set_current_page ($INVENTORY_PAGE);
1463 1492
1464 $plwin->add ($ntb); 1493 $plwin->add ($ntb);
1465 $plwin 1494 $plwin
1792 1821
1793 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, 1822 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup,
1794 "Configure the server to play on, your username, password and other server-related options."); 1823 "Configure the server to play on, your username, password and other server-related options.");
1795 $SETUP_NOTEBOOK->add (Client => client_setup, 1824 $SETUP_NOTEBOOK->add (Client => client_setup,
1796 "Configure various client-specific settings."); 1825 "Configure various client-specific settings.");
1797 $SETUP_NOTEBOOK->add (Pickup => autopickup_setup,
1798 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them.");
1799 $SETUP_NOTEBOOK->add (Graphics => graphics_setup, 1826 $SETUP_NOTEBOOK->add (Graphics => graphics_setup,
1800 "Configure the video mode, performance, fonts and other graphical aspects of the game."); 1827 "Configure the video mode, performance, fonts and other graphical aspects of the game.");
1801 $SETUP_NOTEBOOK->add (Audio => audio_setup, 1828 $SETUP_NOTEBOOK->add (Audio => audio_setup,
1802 "Configure the use of audio, sound effects and background music."); 1829 "Configure the use of audio, sound effects and background music.");
1803 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, 1830 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup,
1981 CFPlus::OpenGL::shutdown; 2008 CFPlus::OpenGL::shutdown;
1982 2009
1983 undef $SDL_ACTIVE; 2010 undef $SDL_ACTIVE;
1984} 2011}
1985 2012
1986my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d#
1987my $bgmusic;#TODO#hack#d#
1988
1989sub audio_channel_finished { 2013sub audio_channel_finished {
1990 my ($channel) = @_; 2014 my ($channel) = @_;
1991 2015
1992 #warn "channel $channel finished\n";#d# 2016 #warn "channel $channel finished\n";#d#
1993} 2017}
1994 2018
2019sub audio_music_set {
2020 my ($songs) = @_;
2021
2022 my $count = @$songs;
2023 my @meta;
2024
2025 for my $name (@$songs) {
2026 CFPlus::DB::get resmap => $name, sub {
2027 my ($data) = @_;
2028
2029 if ($data) {
2030 $data = JSON::XS->new->utf8->decode ($data);
2031 $data->{path} = CFPlus::DB::path_of $name;
2032 push @meta, $data;
2033 }
2034
2035 unless (--$count) {
2036 if (@meta) {
2037 @MUSIC_WANT = @meta;
2038 &audio_music_changed ();
2039 }
2040 }
2041 };
2042 }
2043}
2044
2045sub audio_music_changed {
2046 return unless $CFG->{bgm_enable};
2047
2048 # default MUSIC_WANT == MUSIC_DEFAULT
2049 @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT;
2050
2051 # if the currently playing song is acceptable, let it continue
2052 return if $MUSIC_PLAYING
2053 && grep $MUSIC_PLAYING->{path} eq $_->{path}, @MUSIC_WANT;
2054
2055 if ($MUSIC_PLAYING) {
2056 CFPlus::MixMusic::fade_out 1000;
2057 } else {
2058 my $music = $MUSIC_WANT [rand @MUSIC_WANT];
2059
2060 $MUSIC_PLAYING = $music;
2061
2062 $MUSIC_PLAYER = new_from_file CFPlus::MixMusic $music->{path};
2063 $MUSIC_PLAYER->play (0);
2064 }
2065}
2066
1995sub audio_music_finished { 2067sub audio_music_finished {
1996 return unless $CFG->{bgm_enable}; 2068 $MUSIC_PLAYING = undef;
2069 undef $MUSIC_PLAYER;
1997 2070
1998 # TODO: hack, do play loop and mood music 2071 audio_music_changed;
1999 $bgmusic = new_from_file CFPlus::MixMusic CFPlus::find_rcfile "music/$bgmusic[0]";
2000 $bgmusic->play (0);
2001
2002 push @bgmusic, shift @bgmusic;
2003} 2072}
2004 2073
2005sub audio_init { 2074sub audio_init {
2006 if ($CFG->{audio_enable}) { 2075 if ($CFG->{audio_enable}) {
2007 if (open my $fh, "<", CFPlus::find_rcfile "sounds/config") { 2076 if (open my $fh, "<", CFPlus::find_rcfile "sounds/config") {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines