]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel_io.cxx
allow to trigger widgets via accelerator key, which is defined via "keynum"
[flightgear.git] / src / Cockpit / panel_io.cxx
index 7bb8f27261712b0f99d1a7ff5348f6860d7073e3..978aac540057753635333c47548201c3ee54d019 100644 (file)
 #include <string.h>            // for strcmp()
 
 #include <simgear/compiler.h>
-#include <simgear/misc/exception.hxx>
-
-#include <simgear/misc/sg_path.hxx>
+#include <simgear/structure/exception.hxx>
 #include <simgear/debug/logstream.hxx>
-#include <simgear/misc/props.hxx>
+#include <simgear/misc/sg_path.hxx>
+#include <simgear/props/props.hxx>
 
 #include STL_IOSTREAM
 #include STL_FSTREAM
@@ -132,12 +131,13 @@ readTexture (const SGPropertyNode * node)
 ////////////////////////////////////////////////////////////////////////
 
 static void
-readConditions (FGConditional * component, const SGPropertyNode * node)
+readConditions (SGConditional *component, const SGPropertyNode *node)
 {
   const SGPropertyNode * conditionNode = node->getChild("condition");
   if (conditionNode != 0)
                                // The top level is implicitly AND
-    component->setCondition(fgReadCondition(conditionNode));
+    component->setCondition(sgReadCondition(globals->get_props(),
+                                            conditionNode) );
 }
 
 
@@ -182,19 +182,34 @@ readAction (const SGPropertyNode * node, float w_scale, float h_scale)
   FGPanelAction * action = new FGPanelAction(button, x, y, w, h, repeatable);
 
   vector<SGPropertyNode_ptr>bindings = node->getChildren("binding");
+  SGPropertyNode * dest = fgGetNode("/sim/bindings/panel", true);
 
-  unsigned int i;
+  SGPropertyNode *binding;
+  unsigned int i, j;
   for (i = 0; i < bindings.size(); i++) {
     SG_LOG(SG_INPUT, SG_INFO, "Reading binding "
-          << bindings[i]->getStringValue("command"));
-    action->addBinding(new FGBinding(bindings[i]), 0);
+      << bindings[i]->getStringValue("command"));
+
+    j = 0;
+    while (dest->getChild("binding", j))
+      j++;
+
+    binding = dest->getChild("binding", j, true);
+    copyProperties(bindings[i], binding);
+    action->addBinding(new FGBinding(binding), 0);
   }
 
   if (node->hasChild("mod-up")) {
-      bindings = node->getChild("mod-up")->getChildren("binding");
-      for (i = 0; i < bindings.size(); i++) {
-          action->addBinding(new FGBinding(bindings[i]), 1);
-      }
+    bindings = node->getChild("mod-up")->getChildren("binding");
+    for (i = 0; i < bindings.size(); i++) {
+      j = 0;
+      while (dest->getChild("binding", j))
+        j++;
+
+      binding = dest->getChild("binding", j, true);
+      copyProperties(bindings[i], binding);
+      action->addBinding(new FGBinding(binding), 1);
+    }
   }
 
   readConditions(action, node);
@@ -238,7 +253,7 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
   SGPropertyNode * target = 0;
 
   if (type.empty()) {
-    SG_LOG( SG_COCKPIT, SG_ALERT,
+    SG_LOG( SG_COCKPIT, SG_INFO,
             "No type supplied for transformation " << name
             << " assuming \"rotation\"" );
     type = "rotation";
@@ -365,9 +380,11 @@ 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);
+    bool truncation = node->getBoolValue("truncate", false);
     SGPropertyNode * target = fgGetNode(propName.c_str(), true);
     chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, target,
-                                  format, scale);
+                                  format, scale, offset, truncation);
   }
 
                                // Unknown type.
@@ -418,7 +435,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
 
 
   if (type.empty()) {
-    SG_LOG( SG_COCKPIT, SG_ALERT,
+    SG_LOG( SG_COCKPIT, SG_INFO,
             "No type supplied for layer " << name
             << " assuming \"texture\"" );
     type = "texture";