]> www.fi.muni.cz Git - slotcarman.git/blobdiff - SCX/Track.pm
Time formatting moved to SCX::GUI
[slotcarman.git] / SCX / Track.pm
index bd6ceea620e9d3626cba484c34f5f9f8c094944d..c1f66a3e8890307f2b9316042db1427d7dcdde10 100644 (file)
@@ -25,9 +25,10 @@ sub new {
        for my $i (0..5) {
                $self->{cars}->[$i] = SCX::Car->new({
                        gui => $self->{gui},
-                       order => $i,
+                       id => $i,
                        track => $self,
                });
+               $self->car($i)->set_order($i);
        }
 
        return $self;
@@ -87,15 +88,14 @@ sub race_setup {
                $self->{gui}->rounds('0');
                $self->{race_rounds} = 0;
        }
-       $self->{race_time} = 0;
        $self->{best_lap} = undef;
 
        $self->{gui}->show_semaphore(undef);
        $self->{race_running} = 0;
        $self->{start_in_progress} = 0;
 
-       $self->{gui}->time('00:00');
-       $self->{gui}->best_lap('0.00');
+       $self->{gui}->time(undef);
+       $self->{gui}->best_lap(undef);
 
        for my $car (0..5) {
                $self->car($car)->set_order($car);
@@ -112,11 +112,26 @@ sub check_best_lap {
        if (!defined $self->{best_lap}
                || $time < $self->{best_lap}) {
                $self->{best_lap} = $time;
-               $self->{gui}->best_lap(sprintf("%.2f", $time), $who);
+               $self->{gui}->best_lap($time, $who);
                return 1;
        }
        return 0;
 }
 
+sub qualification_start {
+       my ($self) = @_;
+
+       return if $self->{qualification_running};
+       for my $car (0..5) {
+               $self->car($car)->set_lap(undef);
+               $self->car($car)->set_laptime(undef);
+       }
+
+       $self->{qualification_running} = 1;
+       $self->{gui}->lap('Qualification');
+       $self->{gui}->time(undef);
+       $self->{gui}->best_lap(undef);
+}
+
 1;