X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=SCX%2FTrack.pm;h=32f03f40555bcf95fd8d7586e5c4f7efe7fd54ed;hb=9aec101d497a8b3549b7150b0371e18c4c843f6a;hp=c75659282f57061f35e3002efb567482b213b732;hpb=3043b1b70f247549f10fa5e3ce713c2a80cd2200;p=slotcarman.git diff --git a/SCX/Track.pm b/SCX/Track.pm index c756592..32f03f4 100644 --- a/SCX/Track.pm +++ b/SCX/Track.pm @@ -45,7 +45,7 @@ sub race_start { sub semaphore_step { my ($self) = @_; - return if !$self->{start_in_progress} && !$self->{race_running}; + return FALSE if !$self->{start_in_progress} && !$self->{race_running}; $self->{semaphore}++; if ($self->{semaphore} <= 5) { @@ -56,6 +56,7 @@ sub semaphore_step { Glib::Timeout->add($timeout, \&semaphore_step, $self); } elsif ($self->{semaphore} == 6) { $self->{race_running} = 1; + $self->{race_running_since} = gettimeofday; $self->{start_in_progress} = undef; $self->{gui}->show_semaphore(0); Glib::Timeout->add(3*$SEMAPHORE_STEP, \&semaphore_step, $self); @@ -72,6 +73,30 @@ sub race_end { $self->{race_running} = 0; } +sub race_setup { + my ($self, $rounds) = @_; + + if ($rounds) { + $self->{gui}->rounds('0/' . $rounds); + $self->{race_rounds} = $rounds; + } else { + $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'); + + for my $car (0..5) { + $self->car($car)->set_order($car); + } +} 1;