]> git.mxchange.org Git - simgear.git/commitdiff
Allow multiple <button> elements for <action> elements in pick animations. Nice to...
authortorsten <torsten>
Tue, 28 Jul 2009 14:33:44 +0000 (14:33 +0000)
committerTim Moore <timoore@redhat.com>
Fri, 7 Aug 2009 22:49:40 +0000 (00:49 +0200)
simgear/scene/model/animation.cxx

index 7218fc06b3512c6ce93eaf191127985d7f9d91cb..28f89f5e303791529744c36c835fa550e822dffd 100644 (file)
@@ -1976,12 +1976,16 @@ class SGPickAnimation::PickCallback : public SGPickCallback {
 public:
   PickCallback(const SGPropertyNode* configNode,
                SGPropertyNode* modelRoot) :
-    _button(configNode->getIntValue("button", -1)),
     _repeatable(configNode->getBoolValue("repeatable", false)),
     _repeatInterval(configNode->getDoubleValue("interval-sec", 0.1))
   {
     SG_LOG(SG_INPUT, SG_DEBUG, "Reading all bindings");
     std::vector<SGPropertyNode_ptr> bindings;
+
+    bindings = configNode->getChildren("button");
+    for (unsigned int i = 0; i < bindings.size(); ++i) {
+      _buttons.push_back( bindings[i]->getIntValue() );
+    }
     bindings = configNode->getChildren("binding");
     for (unsigned int i = 0; i < bindings.size(); ++i) {
       _bindingsDown.push_back(new SGBinding(bindings[i], modelRoot));
@@ -1997,7 +2001,14 @@ public:
   }
   virtual bool buttonPressed(int button, const Info&)
   {
-    if (0 <= _button && button != _button)
+    bool found = false;
+    for( std::vector<int>::iterator it = _buttons.begin(); it != _buttons.end(); it++ ) {
+      if( *it == button ) {
+        found = true;
+        break;
+      }
+    }
+    if (!found )
       return false;
     SGBindingList::const_iterator i;
     for (i = _bindingsDown.begin(); i != _bindingsDown.end(); ++i)
@@ -2027,7 +2038,7 @@ public:
 private:
   SGBindingList _bindingsDown;
   SGBindingList _bindingsUp;
-  int _button;
+  std::vector<int> _buttons;
   bool _repeatable;
   double _repeatInterval;
   double _repeatTime;