lua_sound_world.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. #include "lua_stack.h"
  6. #include "lua_environment.h"
  7. #include "sound_world.h"
  8. namespace crown
  9. {
  10. static int sound_world_stop_all(lua_State* L)
  11. {
  12. LuaStack stack(L);
  13. stack.get_sound_world(1)->stop_all();
  14. return 0;
  15. }
  16. static int sound_world_pause_all(lua_State* L)
  17. {
  18. LuaStack stack(L);
  19. stack.get_sound_world(1)->pause_all();
  20. return 0;
  21. }
  22. static int sound_world_resume_all(lua_State* L)
  23. {
  24. LuaStack stack(L);
  25. stack.get_sound_world(1)->resume_all();
  26. return 0;
  27. }
  28. static int sound_world_is_playing(lua_State* L)
  29. {
  30. LuaStack stack(L);
  31. stack.push_bool(stack.get_sound_world(1)->is_playing(stack.get_sound_instance_id(2)));
  32. return 1;
  33. }
  34. static int sound_world_tostring(lua_State* L)
  35. {
  36. LuaStack stack(L);
  37. SoundWorld* sw = stack.get_sound_world(1);
  38. stack.push_fstring("SoundWorld (%p)", sw);
  39. return 1;
  40. }
  41. void load_sound_world(LuaEnvironment& env)
  42. {
  43. env.load_module_function("SoundWorld", "stop_all", sound_world_stop_all);
  44. env.load_module_function("SoundWorld", "pause_all", sound_world_pause_all);
  45. env.load_module_function("SoundWorld", "resume_all", sound_world_resume_all);
  46. env.load_module_function("SoundWorld", "is_playing", sound_world_is_playing);
  47. env.load_module_function("SoundWorld", "__index", "SoundWorld");
  48. env.load_module_function("SoundWorld", "__tostring", sound_world_tostring);
  49. }
  50. } // namespace crown