supertux
music_object.hpp
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 
18 #ifndef HEADER_SUPERTUX_OBJECT_MUSIC_OBJECT_HPP
19 #define HEADER_SUPERTUX_OBJECT_MUSIC_OBJECT_HPP
20 
21 #include "supertux/game_object.hpp"
22 
23 enum MusicType {
24  LEVEL_MUSIC,
25  HERRING_MUSIC,
26  HERRING_WARNING_MUSIC
27 };
28 
29 class MusicObject : public GameObject
30 {
31 public:
32  MusicObject();
33  MusicObject(const ReaderMapping& mapping);
34 
35  virtual void update(float dt_sec) override;
36  virtual void draw(DrawingContext& context) override;
37 
38  virtual bool is_singleton() const override { return true; }
39 
40  static std::string class_name() { return "music"; }
41  virtual std::string get_class_name() const override { return class_name(); }
42  static std::string display_name() { return _("Music"); }
43  virtual std::string get_display_name() const override { return display_name(); }
44  virtual GameObjectClasses get_class_types() const override { return GameObject::get_class_types().add(typeid(MusicObject)); }
45  virtual const std::string get_icon_path() const override { return "images/engine/editor/music.png"; }
46 
47  virtual ObjectSettings get_settings() override;
48 
49  void play_music(MusicType musictype);
50  void resume_music(bool instantly = false);
51  MusicType get_music_type() const;
52 
53  void set_music(const std::string& music);
54  const std::string& get_music() const;
55 
56 private:
57  MusicType m_currentmusic;
58  std::string m_music;
59 
60 private:
61  MusicObject(const MusicObject&) = delete;
62  MusicObject& operator=(const MusicObject&) = delete;
63 };
64 
65 #endif
66 
67 /* EOF */
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: music_object.hpp:43
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: music_object.cpp:44
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: music_object.hpp:44
virtual bool is_singleton() const override
If true only a single object of this type is allowed in a given GameObjectManager.
Definition: music_object.hpp:38
Definition: object_settings.hpp:39
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
Definition: music_object.hpp:29
virtual GameObjectClasses get_class_types() const
List notable classes in inheritance hierarchy of class.
Definition: game_object.cpp:113
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
Definition: reader_mapping.hpp:32
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it&#39;s state.
Definition: music_object.cpp:39
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42