X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=SCX%2FTrack.pm;h=90724290bc5252bd2bb7b897486d7ec23d3ef72c;hb=8f29704c1e17195a4e195872ed518dd6d2f0dd62;hp=6ed3d822581242fb96e88dc86d7c9f3b626196e3;hpb=cdde130ace5a74cd817d4600033789343e72d317;p=slotcarman.git diff --git a/SCX/Track.pm b/SCX/Track.pm index 6ed3d82..9072429 100644 --- a/SCX/Track.pm +++ b/SCX/Track.pm @@ -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; } @@ -145,8 +149,8 @@ sub print_rounds { $self->{gui}->rounds($msg); } -sub check_best_lap { - my ($self, $time, $who) = @_; +sub notify_best_lap { + my ($self, $id, $time, $who) = @_; return if !defined $time || $time == 0; @@ -157,6 +161,16 @@ sub check_best_lap { || $time < $self->{best_lap}) { $self->{best_lap} = $time; $self->{gui}->best_lap($time, $who); + + for my $car (0..5) { + $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; @@ -221,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; }