]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel_io.cxx
Prepare and implement reinit methods for instruments
[flightgear.git] / src / Cockpit / panel_io.cxx
index f59f93c8ffdae34d2c95a99886920b67a4715534..f05d057f1b508519c9e6450ca2f02d060675163e 100644 (file)
@@ -29,6 +29,7 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/props/props.hxx>
+#include <simgear/props/props_io.hxx>
 
 #include <istream>
 #include <fstream>
@@ -260,7 +261,7 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
   SGPropertyNode * target = 0;
 
   if (type.empty()) {
-    SG_LOG( SG_COCKPIT, SG_INFO,
+    SG_LOG( SG_COCKPIT, SG_BULK,
             "No type supplied for transformation " << name
             << " assuming \"rotation\"" );
     type = "rotation";
@@ -282,7 +283,7 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
                                // Check for an interpolation table
   const SGPropertyNode * trans_table = node->getNode("interpolation");
   if (trans_table != 0) {
-    SG_LOG( SG_COCKPIT, SG_INFO, "Found interpolation table with "
+    SG_LOG( SG_COCKPIT, SG_DEBUG, "Found interpolation table with "
             << trans_table->nChildren() << " children" );
     t->table = new SGInterpTable(trans_table);
   } else {
@@ -430,7 +431,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
 
 
   if (type.empty()) {
-    SG_LOG( SG_COCKPIT, SG_INFO,
+    SG_LOG( SG_COCKPIT, SG_BULK,
             "No type supplied for layer " << name
             << " assuming \"texture\"" );
     type = "texture";
@@ -641,7 +642,6 @@ readInstrument (const SGPropertyNode * node)
   }
 
   readConditions(instrument, node);
-  SG_LOG( SG_COCKPIT, SG_DEBUG, "Done reading instrument " << name );
   return instrument;
 }
 
@@ -662,8 +662,8 @@ readPanel (const SGPropertyNode * root)
   //
   // Grab the visible external viewing area, default to 
   //
-  panel->setViewHeight(root->getIntValue("view-height",
-                                        768 - panel->getHeight() + 2));
+//  panel->setViewHeight(root->getIntValue("view-height",
+//                                      768 - panel->getHeight() + 2));
 
   //
   // Grab the panel's initial offsets, default to 0, 0.
@@ -685,7 +685,6 @@ readPanel (const SGPropertyNode * root)
   if (bgTexture.empty())
     bgTexture = "FOO";
   panel->setBackground(FGTextureManager::createTexture(bgTexture.c_str()));
-  SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << bgTexture );
 
   //
   // Get multibackground if any...
@@ -693,49 +692,41 @@ readPanel (const SGPropertyNode * root)
   string mbgTexture = root->getStringValue("multibackground[0]");
   if (!mbgTexture.empty()) {
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 0);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[1]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 1);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[2]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 2);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[3]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 3);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[4]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 4);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[5]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 5);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[6]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 6);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[7]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 7);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
   }
   
@@ -744,7 +735,7 @@ readPanel (const SGPropertyNode * root)
   //
   // Create each instrument.
   //
-  SG_LOG( SG_COCKPIT, SG_INFO, "Reading panel instruments" );
+  SG_LOG( SG_COCKPIT, SG_DEBUG, "Reading panel instruments" );
   const SGPropertyNode * instrument_group = root->getChild("instruments");
   if (instrument_group != 0) {
     int nInstruments = instrument_group->nChildren();
@@ -764,8 +755,8 @@ readPanel (const SGPropertyNode * root)
           int y = node->getIntValue("y", -1);
           int real_w = node->getIntValue("w", -1);
           int real_h = node->getIntValue("h", -1);
-          int w = node->getIntValue("w-base", -1);
-          int h = node->getIntValue("h-base", -1);
+//          int w = node->getIntValue("w-base", -1);
+//          int h = node->getIntValue("h-base", -1);
           
           if (x == -1 || y == -1) {
             SG_LOG( SG_COCKPIT, SG_ALERT,
@@ -773,18 +764,18 @@ readPanel (const SGPropertyNode * root)
             return 0;
           }
           
-          float w_scale = 1.0;
-          float h_scale = 1.0;
+//          float w_scale = 1.0;
+//          float h_scale = 1.0;
           if (real_w != -1) {
-            w_scale = float(real_w) / float(w);
-            w = real_w;
+//            w_scale = float(real_w) / float(w);
+//            w = real_w;
           }
           if (real_h != -1) {
-            h_scale = float(real_h) / float(h);
-            h = real_h;
+//            h_scale = float(real_h) / float(h);
+//            h = real_h;
           }
           
-          SG_LOG( SG_COCKPIT, SG_DEBUG, "Reading instrument " << name );
+          SG_LOG( SG_COCKPIT, SG_BULK, "Reading instrument " << name );
           
           // Warning - hardwired size!!!
           RenderArea2D* instrument = new RenderArea2D(158, 40, 158, 40, x, y);
@@ -800,12 +791,12 @@ readPanel (const SGPropertyNode * root)
           SG_LOG( SG_COCKPIT, SG_WARN, "Unknown special instrument found" );
         }
       } else {
-        SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
+        SG_LOG( SG_COCKPIT, SG_WARN, "Skipping " << node->getName()
         << " in instruments section" );
       }
     }
   }
-  SG_LOG( SG_COCKPIT, SG_INFO, "Done reading panel instruments" );
+  SG_LOG( SG_COCKPIT, SG_BULK, "Done reading panel instruments" );
 
 
   //
@@ -849,10 +840,9 @@ fgReadPanel (istream &input)
 FGPanel *
 fgReadPanel (const string &relative_path)
 {
-  SGPath path(globals->get_fg_root());
-  path.append(relative_path);
+  SGPath path = globals->resolve_aircraft_path(relative_path);
   SGPropertyNode root;
-
+  
   try {
     readProperties(path.str(), &root);
   } catch (const sg_exception &e) {