- Added a new script command to display text files
[supertux.git] / src / scripting / script_interpreter.h
1 #ifndef __SCRIPT_INTERPRETER_H__
2 #define __SCRIPT_INTERPRETER_H__
3
4 #include <squirrel.h>
5 #include <iostream>
6 #include "timer.h"
7 #include "game_object.h"
8 #include "scripting/sound.h"
9 #include "scripting/level.h"
10
11 class Sector;
12
13 class ScriptInterpreter : public GameObject
14 {
15 public:
16   ScriptInterpreter(const std::string& working_dir);
17   ~ScriptInterpreter();
18
19   void register_sector(Sector* sector);
20
21   void draw(DrawingContext& );
22   void update(float );
23
24   void load_script(std::istream& in, const std::string& sourcename = "");
25   void start_script();
26   
27   void expose_object(void* object, const std::string& name,
28                      const std::string& type);
29
30   void set_wakeup_time(float seconds);
31
32   static ScriptInterpreter* current()
33   {
34     return _current;
35   }
36
37   const std::string& get_working_directory() const
38   {
39       return working_directory;
40   }
41
42 private:
43   HSQUIRRELVM v;
44   static ScriptInterpreter* _current;
45   Timer wakeup_timer;
46
47   /// this directory is used as base for all filenames used in scripts
48   std::string working_directory;
49   Scripting::Sound* sound;
50   Scripting::Level* level;
51 };
52
53 #endif
54