Add the hacks to fix disabling of buttons
[cs356-p1-elevator.git] / elevatorgui.cpp
index 8e7ae2a..f18a334 100644 (file)
@@ -94,6 +94,16 @@ ElevatorGUI::ElevatorGUI (int floors, int elevators)
 
 
 
+       /* Fill in all of the PositionLabels */
+       for (e=0; e<elevators; ++e)
+       {
+               PositionLabel *label = new PositionLabel (e);
+               position_labels_.push_back (label);
+               table_.attach (*label, e+1, e+2, floors, floors+1);
+       }
+
+
+
        /* Fill in all of the Elevator Request Panels */
        for (e=0; e<elevators; ++e)
        {
@@ -131,17 +141,7 @@ ElevatorGUI::ElevatorGUI (int floors, int elevators)
                }
 
                // Attach the Panel
-               table_.attach (*panel, e+1, e+2, floors, floors+1);
-       }
-
-
-
-       /* Fill in all of the PositionLabels */
-       for (e=0; e<elevators; ++e)
-       {
-               PositionLabel *label = new PositionLabel (e);
-               position_labels_.push_back (label);
-               table_.attach (*label, e+1, e+2, floors+1, floors+2);
+               table_.attach (*panel, e+1, e+2, floors+1, floors+2);
        }
 
 
@@ -247,6 +247,10 @@ void ElevatorGUI::gui_unpress_call_button (int floor, Direction direction)
 {
        CallButtonVector::iterator it;
 
+       /* If there is still an elevator coming, don't turn it off! */
+       if (ec_.oneElevatorWillStillStopAt (floor, direction))
+               return;
+
        for (it=call_buttons_.begin(); it!=call_buttons_.end(); it++)
                if ((*it)->getFloorNumber() == floor && (*it)->getDirection() == direction)
                        (*it)->set_active (false);