… | |
… | |
673 | socketpair $SOUND_SERVER, my $fh, &Socket::AF_UNIX, &Socket::SOCK_STREAM, 0 |
673 | socketpair $SOUND_SERVER, my $fh, &Socket::AF_UNIX, &Socket::SOCK_STREAM, 0 |
674 | or return; |
674 | or return; |
675 | |
675 | |
676 | my $pid = fork; |
676 | my $pid = fork; |
677 | |
677 | |
678 | if ($pid || !defined $pid) { |
678 | if ($pid) { |
679 | # parent |
679 | # parent |
680 | close $fh; |
680 | close $fh; |
681 | |
681 | |
682 | } else { |
682 | } elsif (defined $pid) { |
683 | # child |
683 | # child |
684 | close $SOUND_SERVER; |
684 | close $SOUND_SERVER; |
685 | |
685 | |
|
|
686 | close STDIN; |
|
|
687 | close STDOUT; |
|
|
688 | close STDERR; |
|
|
689 | |
|
|
690 | # ok, this is a bit pathetic |
|
|
691 | POSIX::close $_ for grep $_ != fileno $fh, 3 .. 1000; |
|
|
692 | |
686 | my %sound; |
693 | my %sound; |
687 | |
694 | |
688 | while (<$SOUND_SERVER>) { |
695 | while (<$fh>) { |
689 | chomp; |
696 | chomp; |
690 | |
697 | |
691 | eval { |
698 | eval { |
692 | my $sound = $sound{$_} ||= do { |
699 | my $sound = $sound{$_} ||= do { |
693 | my $path = findfile "$_.au" |
700 | my $path = findfile "$_.au" |
… | |
… | |
702 | $data->Load ($fh); |
709 | $data->Load ($fh); |
703 | |
710 | |
704 | $data |
711 | $data |
705 | }; |
712 | }; |
706 | |
713 | |
707 | my $server = new Audio::Play (1); |
714 | my $server = new Audio::Play; |
708 | |
|
|
709 | $server->play ($sound); |
715 | $server->play ($sound); |
710 | $server->flush; |
716 | $server->flush; |
711 | }; |
717 | }; |
712 | } |
718 | } |
713 | |
719 | |
714 | kill 9, $$; # required for windows, as a mere exit |
720 | kill 9, $$; # required for windows, as a mere exit |
|
|
721 | } else { |
|
|
722 | undef $SOUND_SERVER; |
|
|
723 | return; |
715 | } |
724 | } |
716 | } |
725 | } |
|
|
726 | |
|
|
727 | syswrite $SOUND_SERVER, "$_[0]\n"; |
717 | } |
728 | } |
718 | |
729 | |
719 | 1; |
730 | 1; |
720 | |
731 | |
721 | =back |
732 | =back |
… | |
… | |
748 | $game->{board}[18][1] = MARK_W; |
759 | $game->{board}[18][1] = MARK_W; |
749 | |
760 | |
750 | my $board = new Gtk2::GoBoard; |
761 | my $board = new Gtk2::GoBoard; |
751 | $board->set_board ($game); |
762 | $board->set_board ($game); |
752 | |
763 | |
|
|
764 | Gtk2::GoBoard::play_sound "gamestart"; # ping |
|
|
765 | |
753 | # enable cursor for black, till click |
766 | # enable cursor for black, till click |
754 | $board->set (cursor => sub { |
767 | $board->set (cursor => sub { |
755 | my ($mark, $x, $y) = @_; |
768 | my ($mark, $x, $y) = @_; |
756 | |
769 | |
757 | $mark |= MARK_GRAYED | MARK_B |
770 | $mark |= MARK_GRAYED | MARK_B |
… | |
… | |
764 | $board->signal_connect (button_release => sub { |
777 | $board->signal_connect (button_release => sub { |
765 | my ($board, $button, $x, $y) = @_; |
778 | my ($board, $button, $x, $y) = @_; |
766 | |
779 | |
767 | $game->{board}[$x][$y] |= MARK_CIRCLE; |
780 | $game->{board}[$x][$y] |= MARK_CIRCLE; |
768 | $board->set_board ($game); # force update |
781 | $board->set_board ($game); # force update |
|
|
782 | |
|
|
783 | Gtk2::GoBoard::play_sound "move"; # play click sound |
769 | |
784 | |
770 | $board->set (cursor => undef); # disable cursor |
785 | $board->set (cursor => undef); # disable cursor |
771 | }); |
786 | }); |
772 | |
787 | |
773 | my $w = new Gtk2::Window "toplevel"; |
788 | my $w = new Gtk2::Window "toplevel"; |