music_object.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SuperTux
  2. // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
  3. // 2018 Ingo Ruhnke <grumbel@gmail.com>
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef HEADER_SUPERTUX_OBJECT_MUSIC_OBJECT_HPP
  18. #define HEADER_SUPERTUX_OBJECT_MUSIC_OBJECT_HPP
  19. #include "supertux/game_object.hpp"
  20. enum MusicType {
  21. LEVEL_MUSIC,
  22. HERRING_MUSIC,
  23. HERRING_WARNING_MUSIC
  24. };
  25. class MusicObject : public GameObject
  26. {
  27. public:
  28. MusicObject();
  29. MusicObject(const ReaderMapping& mapping);
  30. virtual void update(float dt_sec) override;
  31. virtual void draw(DrawingContext& context) override;
  32. virtual bool is_singleton() const override { return true; }
  33. static std::string class_name() { return "music"; }
  34. virtual std::string get_class_name() const override { return class_name(); }
  35. static std::string display_name() { return _("Music"); }
  36. virtual std::string get_display_name() const override { return display_name(); }
  37. virtual const std::string get_icon_path() const override { return "images/engine/editor/music.png"; }
  38. virtual ObjectSettings get_settings() override;
  39. void play_music(MusicType musictype);
  40. void resume_music(bool instantly = false);
  41. MusicType get_music_type() const;
  42. void set_music(const std::string& music);
  43. std::string get_music() const;
  44. private:
  45. MusicType m_currentmusic;
  46. std::string m_music;
  47. private:
  48. MusicObject(const MusicObject&) = delete;
  49. MusicObject& operator=(const MusicObject&) = delete;
  50. };
  51. #endif
  52. /* EOF */