Fixed ambient sound scripting
authorWolfgang Becker <uafr@gmx.de>
Wed, 5 Jul 2006 10:40:36 +0000 (10:40 +0000)
committerWolfgang Becker <uafr@gmx.de>
Wed, 5 Jul 2006 10:40:36 +0000 (10:40 +0000)
SVN-Revision: 3890

data/levels/world2/village.stl
src/object/ambient_sound.cpp
src/object/ambient_sound.hpp
src/scripting/ambient_sound.hpp [new file with mode: 0644]

index 9cc19fa..fd3de2d 100644 (file)
       (x 1076)
       (y 884)
     )
+    (scripttrigger
+      (script "//move saw to start
+tischsaege.goto_node( 0 )      ")
+      (button #f)
+      (width 32)
+      (height 124)
+      (x 1088)
+      (y 416)
+    )
     (secretarea
       (width 569.4012)
       (height 312.0143)
index 5ac3b0f..8fad2a9 100644 (file)
@@ -30,7 +30,6 @@
 #include "audio/sound_manager.hpp"
 #include "audio/sound_source.hpp"
 #include "log.hpp"
-#include "scripting/ambient_sound.hpp"
 #include "scripting/squirrel_util.hpp"
 
 AmbientSound::AmbientSound(const lisp::Lisp& lisp)
@@ -211,16 +210,30 @@ AmbientSound::draw(DrawingContext &)
 void
 AmbientSound::expose(HSQUIRRELVM vm, SQInteger table_idx)
 {
-  if (name == "") return;
-  Scripting::AmbientSound* interface = new Scripting::AmbientSound(this);
-  expose_object(vm, table_idx, interface, name, true);
+  Scripting::AmbientSound* interface = static_cast<Scripting::AmbientSound*> (this);
+  expose_object(vm, table_idx, interface, name, false);
 }
 
 void
 AmbientSound::unexpose(HSQUIRRELVM vm, SQInteger table_idx)
 {
-  if (name == "") return;
   Scripting::unexpose_object(vm, table_idx, name);
 }
 
+void
+AmbientSound::set_pos(float x, float y){
+  position.x = x;
+  position.y = y; 
+}
+
+float
+AmbientSound::get_pos_x(){;
+  return position.x;
+}
+
+float
+AmbientSound::get_pos_y(){
+  return position.y;
+}
+
 IMPLEMENT_FACTORY(AmbientSound, "ambient_sound");
index 74d9c9d..2a58788 100644 (file)
 #include "resources.hpp"
 #include "player.hpp"
 #include "script_interface.hpp"
+#include "scripting/ambient_sound.hpp"
 
 class SoundSource;
 
-class AmbientSound : public GameObject, public ScriptInterface
+class AmbientSound : public GameObject, public ScriptInterface, public Scripting::AmbientSound
 {
 public:
   AmbientSound(const lisp::Lisp& lisp);
   AmbientSound(Vector pos, float factor, float bias, float vol, std::string file);
   ~AmbientSound();
-
+  
   void set_pos(Vector newpos)
   {
     position=newpos;
@@ -65,6 +66,13 @@ public:
   {
     return position;
   }
+
+  // --- Scripting Interface ---
+
+  void set_pos(float x, float y);
+  float get_pos_x();
+  float get_pos_y();
+
 protected:
   virtual void hit(Player& player);
   virtual void update(float time);
diff --git a/src/scripting/ambient_sound.hpp b/src/scripting/ambient_sound.hpp
new file mode 100644 (file)
index 0000000..2cff32c
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef __SCRIPTING_AMBIENT_SOUND_H__
+#define __SCRIPTING_AMBIENT_SOUND_H__
+
+namespace Scripting
+{
+
+class AmbientSound
+{
+public:
+#ifndef SCRIPTING_API
+  virtual ~AmbientSound()
+  {}
+#endif
+
+  virtual void set_pos(float x, float y) = 0;
+  virtual float get_pos_x() = 0;
+  virtual float get_pos_y() = 0;
+};
+
+}
+
+#endif
+