1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
2 | |
2 | |
3 | my $startup_done = sub { }; |
3 | my $startup_done = sub { }; |
|
|
4 | our $PANGO = "1.5.0"; |
4 | |
5 | |
5 | # do splash-screen thingy on win32 |
6 | # do splash-screen thingy on win32 |
6 | BEGIN { |
7 | BEGIN { |
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) { |
… | |
… | |
43 | |
44 | |
44 | if ($^O eq "MSWin32") { |
45 | if ($^O eq "MSWin32") { |
45 | # relocatable |
46 | # relocatable |
46 | } else { |
47 | } else { |
47 | # unix, need to patch pango rc file |
48 | # unix, need to patch pango rc file |
48 | open my $fh, "<:perlio", "$tmp/usr/lib/pango/1.5.0/module-files.d/libpango1.0-0.modules" |
49 | open my $fh, "<:perlio", "$tmp/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules" |
49 | or die "$tmp/usr/lib/1.5.0/module-files.d/libpango1.0-0.modules: $!"; |
50 | or die "$tmp/usr/lib/$PANGO/module-files.d/libpango1.0-0.modules: $!"; |
50 | local $/; |
51 | local $/; |
51 | my $rc = <$fh>; |
52 | my $rc = <$fh>; |
52 | $rc =~ s/^\//$tmp\//gm; # replace abs paths by relative ones |
53 | $rc =~ s/^\//$tmp\//gm; # replace abs paths by relative ones |
53 | |
54 | |
54 | mkdir "$tmp/pango-modules"; |
55 | mkdir "$tmp/pango-modules"; |
… | |
… | |
158 | |
159 | |
159 | our $SDL_ACTIVE; |
160 | our $SDL_ACTIVE; |
160 | our %SDL_CB; |
161 | our %SDL_CB; |
161 | |
162 | |
162 | our $SDL_MIXER; |
163 | our $SDL_MIXER; |
|
|
164 | our $MUSIC_DEFAULT = "in_a_heartbeat.ogg"; |
|
|
165 | our @MUSIC_WANT; |
|
|
166 | our $MUSIC_PLAYING; |
|
|
167 | our $MUSIC_PLAYER; |
163 | our @SOUNDS; # event => file mapping |
168 | our @SOUNDS; # event => file mapping |
164 | our %AUDIO_CHUNKS; # audio files |
169 | our %AUDIO_CHUNKS; # audio files |
165 | |
170 | |
166 | our $ALT_ENTER_MESSAGE; |
171 | our $ALT_ENTER_MESSAGE; |
167 | our $STATUSBOX; |
172 | our $STATUSBOX; |
… | |
… | |
495 | $LOGIN_BUTTON->set_text ("Login"); |
500 | $LOGIN_BUTTON->set_text ("Login"); |
496 | $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); |
501 | $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); |
497 | $SETUP_DIALOG->show; |
502 | $SETUP_DIALOG->show; |
498 | $PL_WINDOW->hide; |
503 | $PL_WINDOW->hide; |
499 | $SPELL_LIST->clear_spells; |
504 | $SPELL_LIST->clear_spells; |
|
|
505 | $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN); |
500 | |
506 | |
501 | return unless $CONN; |
507 | return unless $CONN; |
502 | |
508 | |
503 | status "connection closed"; |
509 | status "connection closed"; |
504 | |
510 | |
… | |
… | |
745 | $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 }); |
746 | $table->add (0, 2, new CFPlus::UI::Label text => "Show FPS"); |
752 | $table->add (0, 2, new CFPlus::UI::Label text => "Show FPS"); |
747 | $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 }); |
748 | $table->add (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips"); |
754 | $table->add (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips"); |
749 | $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 }); |
750 | $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() } ); |
751 | |
757 | |
752 | 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); |
753 | |
759 | |
754 | for my $x (0..2) { |
760 | for my $x (0..2) { |
755 | for my $y (0 .. 2) { |
761 | for my $y (0 .. 2) { |
… | |
… | |
1453 | has_close_button => 1 |
1459 | has_close_button => 1 |
1454 | ; |
1460 | ; |
1455 | |
1461 | |
1456 | my $ntb = |
1462 | my $ntb = |
1457 | $PL_NOTEBOOK = |
1463 | $PL_NOTEBOOK = |
1458 | new CFPlus::UI::Notebook expand => 1, debug => 1; |
1464 | new CFPlus::UI::Notebook expand => 1; |
1459 | |
1465 | |
1460 | $ntb->add ( |
1466 | $ntb->add ( |
1461 | "Statistics (F2)" => $STATS_PAGE = stats_window, |
1467 | "Statistics (F2)" => $STATS_PAGE = stats_window, |
1462 | "Shows statistics, where all your Stats and Resistances are shown." |
1468 | "Shows statistics, where all your Stats and Resistances are shown." |
1463 | ); |
1469 | ); |
… | |
… | |
1475 | $ntb->add ( |
1481 | $ntb->add ( |
1476 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1482 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1477 | "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 :). " |
1478 | . "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." |
1479 | ); |
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."); |
1480 | |
1488 | |
1481 | $ntb->set_current_page ($INVENTORY_PAGE); |
1489 | $ntb->set_current_page ($INVENTORY_PAGE); |
1482 | |
1490 | |
1483 | $plwin->add ($ntb); |
1491 | $plwin->add ($ntb); |
1484 | $plwin |
1492 | $plwin |
… | |
… | |
1811 | |
1819 | |
1812 | $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, |
1820 | $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, |
1813 | "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."); |
1814 | $SETUP_NOTEBOOK->add (Client => client_setup, |
1822 | $SETUP_NOTEBOOK->add (Client => client_setup, |
1815 | "Configure various client-specific settings."); |
1823 | "Configure various client-specific settings."); |
1816 | $SETUP_NOTEBOOK->add (Pickup => autopickup_setup, |
|
|
1817 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
|
|
1818 | $SETUP_NOTEBOOK->add (Graphics => graphics_setup, |
1824 | $SETUP_NOTEBOOK->add (Graphics => graphics_setup, |
1819 | "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."); |
1820 | $SETUP_NOTEBOOK->add (Audio => audio_setup, |
1826 | $SETUP_NOTEBOOK->add (Audio => audio_setup, |
1821 | "Configure the use of audio, sound effects and background music."); |
1827 | "Configure the use of audio, sound effects and background music."); |
1822 | $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, |
1828 | $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, |
… | |
… | |
2000 | CFPlus::OpenGL::shutdown; |
2006 | CFPlus::OpenGL::shutdown; |
2001 | |
2007 | |
2002 | undef $SDL_ACTIVE; |
2008 | undef $SDL_ACTIVE; |
2003 | } |
2009 | } |
2004 | |
2010 | |
2005 | my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# |
|
|
2006 | my $bgmusic;#TODO#hack#d# |
|
|
2007 | |
|
|
2008 | sub audio_channel_finished { |
2011 | sub audio_channel_finished { |
2009 | my ($channel) = @_; |
2012 | my ($channel) = @_; |
2010 | |
2013 | |
2011 | #warn "channel $channel finished\n";#d# |
2014 | #warn "channel $channel finished\n";#d# |
2012 | } |
2015 | } |
2013 | |
2016 | |
|
|
2017 | sub 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 | |
|
|
2043 | sub audio_music_changed { |
|
|
2044 | return unless $CFG->{bgm_enable}; |
|
|
2045 | |
|
|
2046 | # default MUSIC_WANT == 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 $MUSIC_PLAYING |
|
|
2051 | && grep $MUSIC_PLAYING->{path} eq $_->{path}, @MUSIC_WANT; |
|
|
2052 | |
|
|
2053 | if ($MUSIC_PLAYING) { |
|
|
2054 | CFPlus::MixMusic::fade_out 1000; |
|
|
2055 | } else { |
|
|
2056 | my $music = $MUSIC_WANT [rand @MUSIC_WANT]; |
|
|
2057 | |
|
|
2058 | $MUSIC_PLAYING = $music; |
|
|
2059 | |
|
|
2060 | $MUSIC_PLAYER = new_from_file CFPlus::MixMusic $music->{path}; |
|
|
2061 | $MUSIC_PLAYER->play (0); |
|
|
2062 | } |
|
|
2063 | } |
|
|
2064 | |
2014 | sub audio_music_finished { |
2065 | sub audio_music_finished { |
2015 | return unless $CFG->{bgm_enable}; |
2066 | $MUSIC_PLAYING = undef; |
|
|
2067 | undef $MUSIC_PLAYER; |
2016 | |
2068 | |
2017 | # TODO: hack, do play loop and mood music |
2069 | audio_music_changed; |
2018 | $bgmusic = new_from_file CFPlus::MixMusic CFPlus::find_rcfile "music/$bgmusic[0]"; |
|
|
2019 | $bgmusic->play (0); |
|
|
2020 | |
|
|
2021 | push @bgmusic, shift @bgmusic; |
|
|
2022 | } |
2070 | } |
2023 | |
2071 | |
2024 | sub audio_init { |
2072 | sub audio_init { |
2025 | if ($CFG->{audio_enable}) { |
2073 | if ($CFG->{audio_enable}) { |
2026 | if (open my $fh, "<", CFPlus::find_rcfile "sounds/config") { |
2074 | if (open my $fh, "<", CFPlus::find_rcfile "sounds/config") { |