]> git.mxchange.org Git - flightgear.git/commitdiff
Make the v2 HUD support reinit(), so HUDs can be reloaded at runtime.
authorJames Turner <zakalawe@mac.com>
Fri, 22 Oct 2010 18:11:24 +0000 (19:11 +0100)
committerJames Turner <zakalawe@mac.com>
Fri, 22 Oct 2010 18:11:24 +0000 (19:11 +0100)
src/Instrumentation/HUD/HUD.cxx
src/Instrumentation/HUD/HUD.hxx

index 4ea539db366891e00ec1876833c698d3e176d608..4a7d6a5428e00b3e7e8dd573ea9456f4efd9533d 100644 (file)
@@ -115,14 +115,8 @@ HUD::~HUD()
     _scr_heightN->removeChangeListener(this);
     _unitsN->removeChangeListener(this);
     delete _font_renderer;
-    delete _clip_box;
-
-    deque<Item *>::const_iterator it, end = _items.end();
-    for (it = _items.begin(); it != end; ++it)
-        delete *it;
-    end = _ladders.end();
-    for (it = _ladders.begin(); it != end; ++it)
-        delete *it;
+    
+    deinit();
 }
 
 
@@ -146,6 +140,27 @@ void HUD::init()
     _path->fireValueChanged();
 }
 
+void HUD::deinit()
+{
+  deque<Item *>::const_iterator it, end = _items.end();
+    for (it = _items.begin(); it != end; ++it)
+        delete *it;
+    end = _ladders.end();
+    for (it = _ladders.begin(); it != end; ++it)
+        delete *it;
+        
+  _items.clear();
+  _ladders.clear();
+  
+  delete _clip_box;
+  _clip_box = NULL;
+}
+
+void HUD::reinit()
+{
+    deinit();
+    _path->fireValueChanged();
+}
 
 void HUD::update(double dt)
 {
@@ -328,8 +343,7 @@ int HUD::load(const char *file, float x, float y, int level, const string& inden
     const sgDebugPriority TREE = SG_INFO;
     const int MAXNEST = 10;
 
-    SGPath path(globals->get_fg_root());
-    path.append(file);
+    SGPath path(globals->resolve_maybe_aircraft_path(file));
 
     if (!level) {
         SG_LOG(SG_INPUT, TREE, endl << "load " << file);
index 6776495f26478547ca855dc592494a6d93578a01..3ef9d7ee7d8fbbafa59ed14657f54b04d2017b8f 100644 (file)
@@ -153,6 +153,8 @@ public:
     void init();
     void update(double);
 
+  void reinit();
+
     // called from Main/renderer.cxx to draw 2D and 3D HUD
     void draw(osg::State&);
 
@@ -195,6 +197,8 @@ protected:
             int level = 0, const std::string& indent = "");
 
 private:
+    void deinit();
+    
     void draw3D();
     void draw2D(GLfloat, GLfloat, GLfloat, GLfloat);