]> www.fi.muni.cz Git - slotcarman.git/blobdiff - SCX/Track.pm
Sound support
[slotcarman.git] / SCX / Track.pm
index 097dde88cf565be597ed55bfda6b069f6b44956d..90724290bc5252bd2bb7b897486d7ec23d3ef72c 100644 (file)
@@ -7,6 +7,7 @@ use Carp;
 
 use Glib qw(TRUE FALSE);
 use SCX::Car;
+use SCX::Sound;
 
 our $SEMAPHORE_STEP = 1000;
 
@@ -37,6 +38,8 @@ sub new {
        $self->{gui}->time(undef);
        $self->{gui}->best_lap(undef, undef);
 
+       $self->{sound} = new SCX::Sound;
+
        return $self;
 }
 
@@ -87,6 +90,7 @@ sub semaphore_step {
        } else {
                $self->{gui}->show_semaphore(undef);
                $self->{semaphore} = undef;
+               $self->{sound}->start();
        }
        return FALSE;
 }
@@ -162,6 +166,11 @@ sub notify_best_lap {
                        $self->car($car)->set_global_best($car == $id);
                        $self->car($car)->print_best_lap;
                }
+
+               if (!$self->{race_running} || $self->{round} > 1) {
+                       # skip the first round in the race
+                       $self->{sound}->best_lap($id);
+               }
                return 1;
        }
        return 0;
@@ -226,6 +235,9 @@ sub recalc_order {
 
        if ($self->{round} && $self->{race_rounds}
                && $self->{round} > $self->{race_rounds}) {
+               if (!$self->{race_finishing}) {
+                       $self->{sound}->winner($new_order[0]);
+               }
                $self->{race_finishing} = 1;
        }