ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Gtk2-GoBoard/GoBoard.pm
(Generate patch)

Comparing Gtk2-GoBoard/GoBoard.pm (file contents):
Revision 1.1 by root, Sun Jun 22 16:07:01 2008 UTC vs.
Revision 1.3 by root, Sun Jun 22 16:31:17 2008 UTC

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 # required for windows, as a mere _exit kills your parent process...
721 kill 9, $$;
722 } else {
723 undef $SOUND_SERVER;
724 return;
715 } 725 }
716 } 726 }
727
728 syswrite $SOUND_SERVER, "$_[0]\n";
717} 729}
718 730
7191; 7311;
720 732
721=back 733=back
748 $game->{board}[18][1] = MARK_W; 760 $game->{board}[18][1] = MARK_W;
749 761
750 my $board = new Gtk2::GoBoard; 762 my $board = new Gtk2::GoBoard;
751 $board->set_board ($game); 763 $board->set_board ($game);
752 764
765 Gtk2::GoBoard::play_sound "gamestart"; # ping
766
753 # enable cursor for black, till click 767 # enable cursor for black, till click
754 $board->set (cursor => sub { 768 $board->set (cursor => sub {
755 my ($mark, $x, $y) = @_; 769 my ($mark, $x, $y) = @_;
756 770
757 $mark |= MARK_GRAYED | MARK_B 771 $mark |= MARK_GRAYED | MARK_B
764 $board->signal_connect (button_release => sub { 778 $board->signal_connect (button_release => sub {
765 my ($board, $button, $x, $y) = @_; 779 my ($board, $button, $x, $y) = @_;
766 780
767 $game->{board}[$x][$y] |= MARK_CIRCLE; 781 $game->{board}[$x][$y] |= MARK_CIRCLE;
768 $board->set_board ($game); # force update 782 $board->set_board ($game); # force update
783
784 Gtk2::GoBoard::play_sound "move"; # play click sound
769 785
770 $board->set (cursor => undef); # disable cursor 786 $board->set (cursor => undef); # disable cursor
771 }); 787 });
772 788
773 my $w = new Gtk2::Window "toplevel"; 789 my $w = new Gtk2::Window "toplevel";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines