]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/NasalSys.hxx
- fix two bugs
[flightgear.git] / src / Scripting / NasalSys.hxx
index ec9b8d3d00d4029573f31c3d49abb69b1d39b8df..ca7d9f2eaa23d57ae5511f42de3a8263c2303cd4 100644 (file)
@@ -4,6 +4,7 @@
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/nasal/nasal.h>
+#include <simgear/scene/model/model.hxx>
 
 #include <map>
 SG_USING_STD(map);
@@ -52,7 +53,9 @@ public:
     virtual bool handleCommand(const SGPropertyNode* arg);
 
     void createModule(const char* moduleName, const char* fileName,
-                    const char* src, int len);
+                    const char* src, int len, const SGPropertyNode* arg=0);
+
+    void deleteModule(const char* moduleName);
 
 private:
     friend class FGNasalScript;
@@ -93,7 +96,7 @@ private:
     naContext _context;
     naRef _globals;
 
-    SGPropertyNode* _cmdArg;
+    SGPropertyNode_ptr _cmdArg;
 
     int _nextGCKey;
     naRef _gcHash;
@@ -101,6 +104,7 @@ private:
     public: void handleTimer(NasalTimer* t);
 };
 
+
 class FGNasalScript {
 public:
     ~FGNasalScript() { _nas->gcRelease(_gcKey); }
@@ -118,26 +122,14 @@ private:
     FGNasalSys* _nas;
 };
 
+
 class FGNasalListener : public SGPropertyChangeListener {
 public:
     FGNasalListener(SGPropertyNode_ptr node, naRef handler,
-            FGNasalSys* nasal, int key)
-        : _node(node), _handler(handler), _gcKey(key), _nas(nasal) {}
+                    FGNasalSys* nasal, int key);
 
-    ~FGNasalListener() {
-        _nas->gcRelease(_gcKey);
-    }
-
-    void valueChanged(SGPropertyNode* node) {
-        _nas->_cmdArg = node;
-        naContext c = naNewContext();
-        naModUnlock();
-        naCall(c, _handler, 0, 0, naNil(), naNil());
-        naModLock();
-        if(naGetError(c))
-            _nas->logError(c);
-        naFreeContext(c);
-    }
+    ~FGNasalListener();
+    void valueChanged(SGPropertyNode* node);
 
 private:
     friend class FGNasalSys;
@@ -145,6 +137,19 @@ private:
     naRef _handler;
     int _gcKey;
     FGNasalSys* _nas;
+    unsigned int _active;
+};
+
+
+class FGNasalModelData : public SGModelData {
+public:
+    FGNasalModelData() : _unload(0) {}
+    ~FGNasalModelData();
+    void modelLoaded(const string& path, SGPropertyNode *prop, ssgBranch *);
+
+private:
+    string _module;
+    SGConstPropertyNode_ptr _unload;
 };
 
 #endif // __NASALSYS_HXX