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.163 by root, Thu Jul 12 17:56:51 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);
481 506
482 return unless $CONN; 507 return unless $CONN;
483 508
484 status "connection closed"; 509 status "connection closed";
485 510
726 $table->add (1, 1, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); 751 $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"); 752 $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 }); 753 $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"); 754 $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 }); 755 $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" } ); 756 $table->add (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } );
732 757
733 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05); 758 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05);
734 759
735 for my $x (0..2) { 760 for my $x (0..2) {
736 for my $y (0 .. 2) { 761 for my $y (0 .. 2) {
1434 has_close_button => 1 1459 has_close_button => 1
1435 ; 1460 ;
1436 1461
1437 my $ntb = 1462 my $ntb =
1438 $PL_NOTEBOOK = 1463 $PL_NOTEBOOK =
1439 new CFPlus::UI::Notebook expand => 1, debug => 1; 1464 new CFPlus::UI::Notebook expand => 1;
1440 1465
1441 $ntb->add ( 1466 $ntb->add (
1442 "Statistics (F2)" => $STATS_PAGE = stats_window, 1467 "Statistics (F2)" => $STATS_PAGE = stats_window,
1443 "Shows statistics, where all your Stats and Resistances are shown." 1468 "Shows statistics, where all your Stats and Resistances are shown."
1444 ); 1469 );
1456 $ntb->add ( 1481 $ntb->add (
1457 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, 1482 "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget,
1458 "Toggles the inventory window, where you can manage your loot (or treasures :). " 1483 "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." 1484 . "You can also hit the <b>Tab</b>-key to show/hide the Inventory."
1460 ); 1485 );
1486 $ntb->add (Pickup => autopickup_setup,
1487 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them.");
1461 1488
1462 $ntb->set_current_page ($INVENTORY_PAGE); 1489 $ntb->set_current_page ($INVENTORY_PAGE);
1463 1490
1464 $plwin->add ($ntb); 1491 $plwin->add ($ntb);
1465 $plwin 1492 $plwin
1792 1819
1793 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, 1820 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup,
1794 "Configure the server to play on, your username, password and other server-related options."); 1821 "Configure the server to play on, your username, password and other server-related options.");
1795 $SETUP_NOTEBOOK->add (Client => client_setup, 1822 $SETUP_NOTEBOOK->add (Client => client_setup,
1796 "Configure various client-specific settings."); 1823 "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, 1824 $SETUP_NOTEBOOK->add (Graphics => graphics_setup,
1800 "Configure the video mode, performance, fonts and other graphical aspects of the game."); 1825 "Configure the video mode, performance, fonts and other graphical aspects of the game.");
1801 $SETUP_NOTEBOOK->add (Audio => audio_setup, 1826 $SETUP_NOTEBOOK->add (Audio => audio_setup,
1802 "Configure the use of audio, sound effects and background music."); 1827 "Configure the use of audio, sound effects and background music.");
1803 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, 1828 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup,
1981 CFPlus::OpenGL::shutdown; 2006 CFPlus::OpenGL::shutdown;
1982 2007
1983 undef $SDL_ACTIVE; 2008 undef $SDL_ACTIVE;
1984} 2009}
1985 2010
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 { 2011sub audio_channel_finished {
1990 my ($channel) = @_; 2012 my ($channel) = @_;
1991 2013
1992 #warn "channel $channel finished\n";#d# 2014 #warn "channel $channel finished\n";#d#
1993} 2015}
1994 2016
2017sub audio_music_set {
2018 my ($songs) = @_;
2019
2020 my $count = @$songs;
2021 my @meta;
2022
2023 for my $name (@$songs) {
2024 CFPlus::DB::get resmap => $name, sub {
2025 my ($data) = @_;
2026
2027 if ($data) {
2028 $data = JSON::XS->new->utf8->decode ($data);
2029 $data->{path} = CFPlus::DB::path_of $name;
2030 push @meta, $data;
2031 }
2032
2033 unless (--$count) {
2034 if (@meta) {
2035 @MUSIC_WANT = @meta;
2036 &audio_music_changed ();
2037 }
2038 }
2039 };
2040 }
2041}
2042
2043sub audio_music_changed {
2044 return unless $CFG->{bgm_enable};
2045
2046 # default MUSIC_WANT, undef/0 == MUSIC_DEFAULT
2047 @MUSIC_WANT = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_WANT;
2048
2049 # if the currently playing song is acceptable, let it continue
2050 return if grep $MUSIC_PLAYING eq $_->{path}, @MUSIC_WANT;
2051
2052 if (defined $MUSIC_PLAYING) {
2053 warn "fade out";
2054 CFPlus::MixMusic::fade_out 2000;
2055 } else {
2056 warn "new music\n";
2057
2058 my $music = $MUSIC_WANT [rand @MUSIC_WANT];
2059
2060 $MUSIC_PLAYING = $music->{path};
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