Removed a global variable
[supertux.git] / src / script_manager.hpp
index bbcbbf1..77d74d2 100644 (file)
@@ -1,7 +1,7 @@
-//  $Id: main.cpp 3275 2006-04-09 00:32:34Z sommer $
-// 
+//  $Id$
+//
 //  SuperTux
-//  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
+//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
@@ -12,7 +12,7 @@
 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 //  GNU General Public License for more details.
-// 
+//
 //  You should have received a copy of the GNU General Public License
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -37,6 +37,7 @@ class ScriptManager
 {
 public:
   ScriptManager();
+  ScriptManager(ScriptManager* parent);
   ~ScriptManager();
 
   void update();
@@ -45,11 +46,11 @@ public:
    * Creates a new thread and registers it with the script manager
    * (so it can suspend and register for wakeup events)
    */
-  HSQUIRRELVM create_thread();
+  HSQUIRRELVM create_thread(bool leave_thread_on_stack = false);
 
-  HSQUIRRELVM get_global_vm() const
+  HSQUIRRELVM get_vm() const
   {
-    return v;
+    return vm;
   }
 
   enum WakeupEvent {
@@ -75,6 +76,9 @@ public:
   void set_wakeup_event(HSQUIRRELVM vm, WakeupData  event, float timeout = -1);
   void fire_wakeup_event(WakeupEvent event);
   void fire_wakeup_event(WakeupData  event);
+
+  // global (root) instance of the ScriptManager
+  static ScriptManager* instance;
   
 private:
   class SquirrelVM
@@ -91,10 +95,10 @@ private:
   typedef std::list<SquirrelVM> SquirrelVMs;
   SquirrelVMs squirrel_vms;
 
-  HSQUIRRELVM v;
+  HSQUIRRELVM vm;
+  ScriptManager* parent;
+  std::vector<ScriptManager*> childs;
 };
 
-extern ScriptManager* script_manager;
-
 #endif