]> git.mxchange.org Git - flightgear.git/commitdiff
FlightPlan activation, delegate hook.
authorJames Turner <zakalawe@mac.com>
Sun, 25 Jan 2015 11:29:19 +0000 (11:29 +0000)
committerJames Turner <zakalawe@mac.com>
Mon, 23 Feb 2015 13:41:50 +0000 (13:41 +0000)
src/Autopilot/route_mgr.cxx
src/Navaids/FlightPlan.cxx
src/Navaids/FlightPlan.hxx
src/Scripting/NasalPositioned.cxx

index ca851881eb2d57f102ecbd8f16d951a381d79276..0ef6e72c207da6bfe5be57da8c21c95ed3329016 100644 (file)
@@ -746,7 +746,7 @@ bool FGRouteMgr::activate()
     return false;
   }
  
-  _plan->setCurrentIndex(0);
+  _plan->activate();
   active->setBoolValue(true);
   SG_LOG(SG_AUTOPILOT, SG_INFO, "route-manager, activate route ok");
   return true;
index ee1e908157baf31c2a4a3a9327a6d8214a24600f..339ae0a198b220eedeed9c3dfa596e4074ff8c36 100644 (file)
@@ -333,7 +333,21 @@ void FlightPlan::setCurrentIndex(int index)
   _currentWaypointChanged = true;
   unlockDelegate();
 }
-    
+
+void FlightPlan::activate()
+{
+    lockDelegate();
+
+    _currentIndex = 0;
+    _currentWaypointChanged = true;
+
+    if (_delegate) {
+        _delegate->runActivated();
+    }
+
+    unlockDelegate();
+}
+
 void FlightPlan::finish()
 {
     if (_currentIndex == -1) {
@@ -1362,6 +1376,12 @@ void FlightPlan::Delegate::runFinished()
     endOfFlightPlan();
 }
 
+void FlightPlan::Delegate::runActivated()
+{
+    if (_inner) _inner->runActivated();
+    activated();
+}
+
 void FlightPlan::setFollowLegTrackToFixes(bool tf)
 {
     _followLegTrackToFix = tf;
index 50747b6df192db91c2b0348d13def81bcb9297b3..34630e82941dff0815089b3ed70a34bcc13e1a23 100644 (file)
@@ -121,6 +121,7 @@ public:
     virtual void arrivalChanged() { }
     virtual void waypointsChanged() { }
     virtual void cleared() { }
+    virtual void activated() { }
     virtual void currentWaypointChanged() { }
     virtual void endOfFlightPlan() { }
   protected:
@@ -135,7 +136,8 @@ public:
     void runCurrentWaypointChanged();
     void runCleared();
     void runFinished();
-      
+    void runActivated();
+
     friend class FlightPlan;
     
     bool _deleteWithPlan;
@@ -153,7 +155,9 @@ public:
   { return _currentIndex; }
   
   void setCurrentIndex(int index);
-  
+
+  void activate();
+
   void finish();
     
   Leg* currentLeg() const;
index b642d3def55bd69e23841d17381abaf8c3cd4877..6a52a0847e8b40e8e3928839b6de39f290f336e7 100644 (file)
@@ -1807,6 +1807,11 @@ public:
   {
     callDelegateMethod("endOfFlightPlan");
   }
+
+  virtual void activated()
+  {
+    callDelegateMethod("activated");
+  }
 private:
   
   void callDelegateMethod(const char* method)