-// $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
// 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
{
public:
ScriptManager();
+ ScriptManager(ScriptManager* parent);
~ScriptManager();
void update();
* 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 {
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
typedef std::list<SquirrelVM> SquirrelVMs;
SquirrelVMs squirrel_vms;
- HSQUIRRELVM v;
+ HSQUIRRELVM vm;
+ ScriptManager* parent;
+ std::vector<ScriptManager*> childs;
};
-extern ScriptManager* script_manager;
-
#endif