]> www.fi.muni.cz Git - slotcarman.git/blobdiff - SCX/Track.pm
Highlight the best lap
[slotcarman.git] / SCX / Track.pm
index a86ba429f0fab626ffacb40958566f8a8b473944..097dde88cf565be597ed55bfda6b069f6b44956d 100644 (file)
@@ -115,27 +115,13 @@ sub race_setup {
        $self->{best_lap} = undef;
 
        $self->{gui}->show_semaphore(undef);
-       $self->{race_running} = 0;
-       $self->{qualification_running} = 0;
-       $self->{start_in_progress} = 0;
-
-       $self->{gui}->time(undef);
-       $self->{gui}->best_lap(undef);
-}
-
-sub reset {
-       my ($self) = @_;
-
        $self->{race_running} = 0;
        $self->{qualification_running} = 0;
        $self->{start_in_progress} = 0;
        $self->{race_finishing} = 0;
-       $self->{best_lap} = undef;
-       $self->{round} = 0;
 
-       $self->print_rounds;
-       $self->{gui}->best_lap(undef);
        $self->{gui}->time(undef);
+       $self->{gui}->best_lap(undef);
 
        for my $car (0..5) {
                $self->car($car)->reset;
@@ -159,8 +145,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;
 
@@ -171,6 +157,11 @@ 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;
+               }
                return 1;
        }
        return 0;