]> git.mxchange.org Git - flightgear.git/commitdiff
Add support for an offset for number-value typed text chunks
authorehofman <ehofman>
Tue, 13 Jan 2004 18:28:46 +0000 (18:28 +0000)
committerehofman <ehofman>
Tue, 13 Jan 2004 18:28:46 +0000 (18:28 +0000)
src/Cockpit/panel.cxx
src/Cockpit/panel.hxx
src/Cockpit/panel_io.cxx

index 822c2ba26102f2795cf7a4a3bb24e544a6df6dd3..de9a7877866653942f97814f17346401ac0caf95 100644 (file)
@@ -1092,8 +1092,8 @@ FGTextLayer::Chunk::Chunk (const string &text, const string &fmt)
 }
 
 FGTextLayer::Chunk::Chunk (ChunkType type, const SGPropertyNode * node,
-                          const string &fmt, float mult)
-  : _type(type), _fmt(fmt), _mult(mult)
+                          const string &fmt, float mult, float offs)
+  : _type(type), _fmt(fmt), _mult(mult), _offs(offs)
 {
   if (_fmt.empty()) {
     if (type == TEXT_VALUE)
@@ -1117,7 +1117,7 @@ FGTextLayer::Chunk::getValue () const
       sprintf(_buf, _fmt.c_str(), _node->getStringValue());
       break;
     case DOUBLE_VALUE:
-      sprintf(_buf, _fmt.c_str(), _node->getFloatValue() * _mult);
+      sprintf(_buf, _fmt.c_str(), _offs + _node->getFloatValue() * _mult);
       break;
     }
     return _buf;
index 624ccfc16f1ec69416ab3510cdc824717434374a..01ccc469db7562c1e0e50d9d774f95acdd266d22 100644 (file)
@@ -492,7 +492,7 @@ public:
   public:
     Chunk (const string &text, const string &fmt = "%s");
     Chunk (ChunkType type, const SGPropertyNode * node,
-          const string &fmt = "", float mult = 1.0);
+          const string &fmt = "", float mult = 1.0, float offs = 0.0);
 
     const char * getValue () const;
   private:
@@ -501,6 +501,7 @@ public:
     const SGPropertyNode * _node;
     string _fmt;
     float _mult;
+    float _offs;
     mutable char _buf[1024];
   };
 
index e24aafc62b8744c987520ea750721735754e4615..55dcb52ac85ffb03596c7fa9b1783b6917f1cdd3 100644 (file)
@@ -365,9 +365,10 @@ readTextChunk (const SGPropertyNode * node)
   else if (type == "number-value") {
     string propName = node->getStringValue("property");
     float scale = node->getFloatValue("scale", 1.0);
+    float offset = node->getFloatValue("offset", 0.0);
     SGPropertyNode * target = fgGetNode(propName.c_str(), true);
     chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, target,
-                                  format, scale);
+                                  format, scale, offset);
   }
 
                                // Unknown type.