8 my ($class, $args) = @_;
14 order => $args->{order},
15 track => $args->{track},
20 $self->set_throttle(undef);
21 $self->set_fuel(undef);
26 sub gui { return shift->{gui}; }
28 sub track { return shift->{track}; }
31 my ($self, $val) = @_;
33 return if (!defined $self->{throttle} && !defined $val)
34 || (defined $self->{throttle} && defined $val
35 && $self->{throttle} == $val);
37 $self->{throttle} = $val;
38 $self->gui->set_throttle($self->{order}, $val);
43 my ($self, $val) = @_;
45 return if (!defined $self->{fuel} && !defined $val)
46 || (defined $self->{fuel} && defined $val
47 && $self->{fuel} == $val);
50 $self->gui->set_fuel($self->{order}, $val);
62 my ($self, $name) = @_;
64 return if (!defined $self->{car_icon} && !defined $name)
65 || (defined $self->{car_icon} && defined $name
66 && $self->{car_icon} eq $name);
68 $self->{car_icon} = $name;
69 $self->gui->set_car_icon($self->{order}, $name);
73 my ($self, $lap_nr) = @_;
75 return if (!defined $self->{lap} && !defined $lap_nr)
76 || (defined $self->{lap} && defined $lap_nr
77 && $self->{lap} == $lap_nr);
79 $self->{lap} = $lap_nr;
80 $self->gui->set_lap($self->{order}, defined $lap_nr ? $lap_nr : '--');
84 my ($self, $lap_time) = @_;
86 if (defined $lap_time) {
87 $lap_time = sprintf("%.2f", $lap_time);
88 if ($lap_time > 1.0 && !$self->{in_pit_lane}
89 && (!defined $self->{best_lap}
90 || $self->{best_lap} > $lap_time
93 $self->{best_lap} = $lap_time;
94 my $global = $self->{track}->check_best_lap($lap_time,
97 $self->gui->set_best_lap($self->{order}, $lap_time,
101 $self->gui->set_best_lap($self->{order}, '--');
102 $self->{best_lap} = undef;
105 return if (!defined $self->{laptime} && !defined $lap_time)
106 || (defined $self->{laptime} && defined $lap_time
107 && $self->{laptime} == $lap_time);
109 $self->{laptime} = $lap_time;
111 $self->gui->set_laptime($self->{order}, defined $lap_time
116 my ($self, $driver_name) = @_;
118 return if (!defined $self->{driver} && !defined $driver_name)
119 || (defined $self->{driver} && defined $driver_name
120 && $self->{driver} == $driver_name);
122 $self->{driver} = $driver_name;
123 $self->gui->set_driver($self->{order}, $driver_name || '--');
129 return if $self->{in_pit_lane};
131 $self->{in_pit_lane} = 1;
132 $self->gui->enter_pit_lane;
138 return if !$self->{in_pit_lane};
140 $self->{in_pit_lane} = 0;
141 $self->gui->leave_pit_lane;
145 my ($self, $pos) = @_;
147 $self->{order} = $pos;
149 $self->gui->set_driver($self->{order}, $self->{driver}
151 $self->gui->set_car_icon($self->{order}, $self->{car_icon});
152 $self->gui->set_throttle($self->{order}, $self->{throttle});
153 $self->gui->set_lap($self->{order}, defined $self->{lap}
154 ? $self->{lap} : '--');
155 $self->gui->set_laptime($self->{order}, defined $self->{laptime}
156 ? $self->{laptime} : '--');
157 $self->gui->set_best_lap($self->{order}, defined $self->{best_lap}
158 ? $self->{best_lap} : '--');
159 $self->gui->set_fuel($self->{order}, $self->{fuel});