UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
scene.h
Go to the documentation of this file.
1 #ifndef UGDK_ACTION_SCENE_H_
2 #define UGDK_ACTION_SCENE_H_
3 
5 #include <ugdk/structure/types.h>
8 
9 #include <ugdk/action.h>
10 #include <ugdk/audio.h>
11 #include <ugdk/graphic.h>
12 
13 #include <functional>
14 #include <list>
15 #include <queue>
16 #include <string>
17 
18 namespace ugdk {
19 namespace action {
20 
29 class Scene : public system::TaskPlayer {
30  public:
31  Scene();
32  virtual ~Scene();
33 
35  virtual void Focus();
36 
38  virtual void DeFocus();
39 
41  virtual void OnPushed(int index) {}
42 
44  void Finish();
45 
47  void StopsPreviousMusic(bool set) { stops_previous_music_ = set; }
48 
50 
53  void Update(double delta_t);
54 
56 
59  void Render(graphic::Canvas&) const;
60 
64  const std::string& identifier() const { return identifier_; }
65  void set_identifier(const std::string& new_identifier) { identifier_ = new_identifier; }
66 
67  bool finished() const { return finished_; }
68 
69  bool active() const { return active_; }
70  void set_active(bool is_active) { active_ = is_active; }
71 
72  bool visible() const { return visible_; }
73  void set_visible(bool is_visible) { visible_ = is_visible; }
74 
75  MediaManager& media_manager() { return media_manager_; }
76  const MediaManager& media_manager() const { return media_manager_; }
77 
78  system::EventHandler& event_handler() { return event_handler_; }
79  const system::EventHandler& event_handler() const { return event_handler_; }
80 
81  audio::Music* background_music() const { return background_music_; }
82  void set_background_music(audio::Music* music) { background_music_ = music; }
86  void set_render_function(const std::function<void (graphic::Canvas& canvas)>& render_function) {
87  render_function_ = render_function;
88  }
89 
90  protected:
92 
93  virtual void End();
94 
95  private:
97  std::string identifier_;
98 
100  bool active_;
101 
103  bool finished_;
104 
106  bool visible_;
107 
109  audio::Music* background_music_;
110 
112  bool stops_previous_music_;
113 
115  MediaManager media_manager_;
116 
118  system::EventHandler event_handler_;
119 
121  std::function<void (graphic::Canvas& canvas)> render_function_;
122 }; // class Scene.
123 
124 } /* namespace action */
125 } /* namespace ugdk */
126 
127 #endif /* UGDK_ACTION_SCENE_H_ */
Definition: canvas.h:28
A game scene, or screen.
Definition: scene.h:29
bool visible() const
Definition: scene.h:72
virtual void Focus()
Method called when this Scene arrives on the top of the Scene stack.
Definition: mediamanager.h:11
const std::string & identifier() const
Definition: scene.h:64
audio::Music * background_music() const
Definition: scene.h:81
virtual void DeFocus()
Method called when this Scene leaves the top of the Scene stack.
void set_identifier(const std::string &new_identifier)
Definition: scene.h:65
void set_active(bool is_active)
Definition: scene.h:70
system::EventHandler & event_handler()
Definition: scene.h:78
Definition: animation.h:11
Definition: music.h:18
bool finished() const
Definition: scene.h:67
void set_render_function(const std::function< void(graphic::Canvas &canvas)> &render_function)
Definition: scene.h:85
bool active() const
Definition: scene.h:69
Definition: eventhandler.h:40
void set_visible(bool is_visible)
Definition: scene.h:73
virtual void OnPushed(int index)
Method called when this scene is pushed to the Engine's Scene stack.
Definition: scene.h:41
const MediaManager & media_manager() const
Definition: scene.h:76
void Update(double delta_t)
Logical update of the scene.
void Finish()
Finishes the scene.
MediaManager & media_manager()
Definition: scene.h:75
void StopsPreviousMusic(bool set)
Whether this scene stops the previous music even if wont play any music.
Definition: scene.h:47
void Render(graphic::Canvas &) const
Renders the scene to the given canvas if the scene is visible.
const system::EventHandler & event_handler() const
Definition: scene.h:79
void set_background_music(audio::Music *music)
Definition: scene.h:82
virtual void End()
Ends the scene activity.
Definition: taskplayer.h:11