]> www.fi.muni.cz Git - slotcarman.git/commitdiff
Race setup, car reordering.
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Mon, 6 Dec 2010 22:42:49 +0000 (23:42 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Mon, 6 Dec 2010 22:47:15 +0000 (23:47 +0100)
SCX/Car.pm
SCX/GUI.pm
SCX/Reader.pm
SCX/Track.pm
slotcarman.glade

index 8446592f90b68dfb400d2b050c67c74341ac5ac8..d48cbd37bb8f6b44616df4b1bda4bdeb9823bc79 100644 (file)
@@ -79,7 +79,7 @@ sub set_lap {
                        && $self->{lap} == $lap_nr);
 
        $self->{lap} = $lap_nr;
-       $self->gui->set_lap($self->{order}, defined $lap_nr ? $lap_nr : 'N/A');
+       $self->gui->set_lap($self->{order}, defined $lap_nr ? $lap_nr : '--');
 }
 
 sub set_laptime {
@@ -97,7 +97,7 @@ sub set_laptime {
                }
                
        } else {
-               $self->gui->set_best_lap($self->{order}, 'N/A');
+               $self->gui->set_best_lap($self->{order}, '--');
                $self->{best_lap} = undef;
        }
 
@@ -108,7 +108,7 @@ sub set_laptime {
        $self->{laptime} = $lap_time;
 
        $self->gui->set_laptime($self->{order}, defined $lap_time
-               ? $lap_time : 'N/A');
+               ? $lap_time : '--');
 }
 
 sub set_driver {
@@ -119,7 +119,7 @@ sub set_driver {
                        && $self->{driver} == $driver_name);
 
        $self->{driver} = $driver_name;
-       $self->gui->set_driver($self->{order}, $driver_name || 'N/A');
+       $self->gui->set_driver($self->{order}, $driver_name || '--');
 }
 
 sub enter_pit_lane {
@@ -129,5 +129,23 @@ sub enter_pit_lane {
        $self->gui->enter_pit_lane;
 }
 
+sub set_order {
+       my ($self, $pos) = @_;
+
+       $self->{order} = $pos;
+       
+       $self->gui->set_driver($self->{order}, $self->{driver}
+               || '--');
+       $self->gui->set_car_icon($self->{order}, $self->{car_icon});
+       $self->gui->set_throttle($self->{order}, $self->{throttle});
+       $self->gui->set_lap($self->{order}, defined $self->{lap}
+               ? $self->{lap} : '--');
+       $self->gui->set_laptime($self->{order}, defined $self->{laptime}
+               ? $self->{laptime} : '--');
+       $self->gui->set_best_lap($self->{order}, defined $self->{best_lap}
+               ? $self->{best_lap} : '--');
+       $self->gui->set_fuel($self->{order}, $self->{fuel});
+}
+       
 1;
 
index 573843172d28fff1825f0bcbae8a0f8e4f362ddc..e782ba768e54e1f44477163759c65c85154da818 100755 (executable)
@@ -195,5 +195,29 @@ sub show_semaphore {
        }
 }
 
+sub rounds {
+       my ($self, $text) = @_;
+
+       my $label = $self->get_object("label_lap_global")
+               or die "Can't get label_lap_global";
+       $label->set_markup('<span font_desc="18" weight="bold">Lap '.$text.'</span>');
+}
+
+sub time {
+       my ($self, $text) = @_;
+
+       my $label = $self->get_object("label_time_global")
+               or die "Can't get label_time_global";
+       $label->set_markup('<span font_desc="18" weight="bold">Time '.$text.'</span>');
+}
+
+sub best_lap {
+       my ($self, $text) = @_;
+
+       my $label = $self->get_object("label_best_lap_global")
+               or die "Can't get label_best_lap_global";
+       $label->set_markup('<span font_desc="18" weight="bold">Best lap '.$text.'</span>');
+}
+
 1;
 
index 8d9f42dcad72e6382d2f2e9e6880cc6605df809b..565af0fe13d94b25d1a9cfbfcd5b6dff511c70ac 100644 (file)
@@ -265,10 +265,16 @@ sub race_setup_packet {
                || $bytes[5] != 0xFF;
 
        for my $car (0..5) {
-               $self->track->car($car)->set_lap(undef);
+               $self->track->car($car)->set_lap(0);
                $self->track->car($car)->set_laptime(undef);
        }
 
+       $self->track->race_setup($bytes[0] == 0x00
+               ? 0
+               : $bytes[1] & 0x0F * 256
+                       + $bytes[2] & 0x0F * 16
+                       + $bytes[3] & 0x0F);
+
        return $msg; # FIXME - to be implemented
 }
 
@@ -408,7 +414,6 @@ sub finish_line_packet {
        return $msg; # FIXME - to be implemented
 }
 
-
 sub controller_status_packet {
        my ($self, @bytes) = @_;
 
index c75659282f57061f35e3002efb567482b213b732..32f03f40555bcf95fd8d7586e5c4f7efe7fd54ed 100644 (file)
@@ -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;
 
index aa67219dc5f835a7d0340cf466ed4f9d5190d6fa..ca13b1a97a6afe850fd2937e319c2fc9adc54774 100644 (file)
             <property name="position">0</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkHBox" id="hbox1">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkLabel" id="label_lap_global">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">label</property>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label_time_global">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">label</property>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label_best_lap_global">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">label</property>
+              </object>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
         <child>
           <object class="GtkTable" id="table1">
             <property name="visible">True</property>
               </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label_best_lap1">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">label</property>
+                <property name="justify">right</property>
+                <property name="width_chars">12</property>
+              </object>
+              <packing>
+                <property name="left_attach">5</property>
+                <property name="right_attach">6</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+              </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label_best_lap2">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">label</property>
+                <property name="justify">right</property>
+                <property name="width_chars">12</property>
+              </object>
+              <packing>
+                <property name="left_attach">5</property>
+                <property name="right_attach">6</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+              </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label_best_lap3">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">label</property>
+                <property name="justify">right</property>
+                <property name="width_chars">12</property>
+              </object>
+              <packing>
+                <property name="left_attach">5</property>
+                <property name="right_attach">6</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
+              </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label_best_lap4">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">label</property>
+                <property name="justify">right</property>
+                <property name="width_chars">12</property>
+              </object>
+              <packing>
+                <property name="left_attach">5</property>
+                <property name="right_attach">6</property>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
+              </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label_best_lap5">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">label</property>
+                <property name="justify">right</property>
+                <property name="width_chars">12</property>
+              </object>
+              <packing>
+                <property name="left_attach">5</property>
+                <property name="right_attach">6</property>
+                <property name="top_attach">5</property>
+                <property name="bottom_attach">6</property>
+              </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label_best_lap6">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">label</property>
+                <property name="justify">right</property>
+                <property name="width_chars">12</property>
+              </object>
+              <packing>
+                <property name="left_attach">5</property>
+                <property name="right_attach">6</property>
+                <property name="top_attach">6</property>
+                <property name="bottom_attach">7</property>
+              </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Name</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+              </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Lap</property>
+              </object>
+              <packing>
+                <property name="left_attach">3</property>
+                <property name="right_attach">4</property>
+              </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Last lap</property>
+              </object>
+              <packing>
+                <property name="left_attach">4</property>
+                <property name="right_attach">5</property>
+              </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label4">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Best lap</property>
+              </object>
+              <packing>
+                <property name="left_attach">5</property>
+                <property name="right_attach">6</property>
+              </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label5">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Throttle</property>
+              </object>
+              <packing>
+                <property name="left_attach">9</property>
+                <property name="right_attach">10</property>
+              </packing>
             </child>
             <child>
-              <placeholder/>
+              <object class="GtkLabel" id="label6">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Fuel</property>
+              </object>
+              <packing>
+                <property name="left_attach">10</property>
+                <property name="right_attach">11</property>
+              </packing>
             </child>
             <child>
               <placeholder/>
               <placeholder/>
             </child>
             <child>
-              <object class="GtkLabel" id="label_best_lap1">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">label</property>
-                <property name="justify">right</property>
-                <property name="width_chars">12</property>
-              </object>
-              <packing>
-                <property name="left_attach">5</property>
-                <property name="right_attach">6</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-              </packing>
+              <placeholder/>
             </child>
             <child>
-              <object class="GtkLabel" id="label_best_lap2">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">label</property>
-                <property name="justify">right</property>
-                <property name="width_chars">12</property>
-              </object>
-              <packing>
-                <property name="left_attach">5</property>
-                <property name="right_attach">6</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-              </packing>
+              <placeholder/>
             </child>
             <child>
-              <object class="GtkLabel" id="label_best_lap3">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">label</property>
-                <property name="justify">right</property>
-                <property name="width_chars">12</property>
-              </object>
-              <packing>
-                <property name="left_attach">5</property>
-                <property name="right_attach">6</property>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
-              </packing>
+              <placeholder/>
             </child>
             <child>
-              <object class="GtkLabel" id="label_best_lap4">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">label</property>
-                <property name="justify">right</property>
-                <property name="width_chars">12</property>
-              </object>
-              <packing>
-                <property name="left_attach">5</property>
-                <property name="right_attach">6</property>
-                <property name="top_attach">4</property>
-                <property name="bottom_attach">5</property>
-              </packing>
+              <placeholder/>
             </child>
             <child>
-              <object class="GtkLabel" id="label_best_lap5">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">label</property>
-                <property name="justify">right</property>
-                <property name="width_chars">12</property>
-              </object>
-              <packing>
-                <property name="left_attach">5</property>
-                <property name="right_attach">6</property>
-                <property name="top_attach">5</property>
-                <property name="bottom_attach">6</property>
-              </packing>
+              <placeholder/>
             </child>
             <child>
-              <object class="GtkLabel" id="label_best_lap6">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">label</property>
-                <property name="justify">right</property>
-                <property name="width_chars">12</property>
-              </object>
-              <packing>
-                <property name="left_attach">5</property>
-                <property name="right_attach">6</property>
-                <property name="top_attach">6</property>
-                <property name="bottom_attach">7</property>
-              </packing>
+              <placeholder/>
             </child>
           </object>
           <packing>
-            <property name="position">1</property>
+            <property name="position">2</property>
           </packing>
         </child>
         <child>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="position">2</property>
+            <property name="position">3</property>
           </packing>
         </child>
       </object>