my ($self, $lap_time) = @_;
if (!defined $lap_time) {
- $self->gui->set_best_lap($self->{order}, undef);
$self->{best_lap} = undef;
+ $self->{global_best_lap} = undef;
+ $self->print_best_lap;
}
return if $self->same('laptime', $lap_time);
return if defined $self->{best_lap} && $self->{best_lap} <= $lap_time;
$self->{best_lap} = $lap_time;
- my $global = $self->{track}->check_best_lap($lap_time,
+ $self->print_best_lap;
+ $self->{track}->notify_best_lap($self->{id}, $lap_time,
$self->{driver});
+}
+
+sub print_best_lap {
+ my ($self) = @_;
+ $self->gui->set_best_lap($self->{order}, $self->{best_lap},
+ $self->{global_best_lap});
+}
+
+sub set_global_best {
+ my ($self, $val) = @_;
- $self->gui->set_best_lap($self->{order}, $lap_time, $global);
+ $self->{global_best_lap} = $val ? 1 : undef;
}
sub set_driver {
$self->{button});
$self->gui->set_lap($self->{order}, $self->{lap});
$self->gui->set_laptime($self->{order}, $self->{laptime});
- $self->gui->set_best_lap($self->{order}, $self->{best_lap});
$self->gui->set_fuel($self->{order}, $self->{fuel});
$self->gui->set_car_id($self->{order}, $self->{id} + 1);
$self->gui->set_distance($self->{order},
$self->{time_diff}, $self->{lap_diff}, $self->{grey_diff});
$self->print_state;
+ $self->print_best_lap;
}
sub print_state {
}
sub set_best_lap {
- my ($self, $row, $text) = @_;
+ my ($self, $row, $text, $overall_best) = @_;
- $self->set_label('label_best_lap', $row, format_lap_time($text));
+ $text = format_lap_time($text);
+ if ($overall_best) {
+ $text = '<span fgcolor="red">' . $text . '</span>';
+ }
+ $self->set_label('label_best_lap', $row, $text);
}
sub set_name {
$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;
|| $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;