supertux
display_effect.hpp
1 // SuperTux
2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_OBJECT_DISPLAY_EFFECT_HPP
18 #define HEADER_SUPERTUX_OBJECT_DISPLAY_EFFECT_HPP
19 
20 #include "supertux/game_object.hpp"
21 
29 class DisplayEffect final : public GameObject
30 {
31 public:
32  static void register_class(ssq::VM& vm);
33 
34 public:
35  DisplayEffect(const std::string& name = "");
36  ~DisplayEffect() override;
37  virtual GameObjectClasses get_class_types() const override { return GameObject::get_class_types().add(typeid(DisplayEffect)); }
38 
39  virtual void update(float dt_sec) override;
40  virtual void draw(DrawingContext& context) override;
41  virtual bool is_singleton() const override { return true; }
42  virtual bool is_saveable() const override { return false; }
43  virtual std::string get_exposed_class_name() const override { return "DisplayEffect"; }
44 
53  void fade_out(float time);
59  void fade_in(float time);
65  void set_black(bool black);
71  bool is_black() const;
78  void sixteen_to_nine(float time);
85  void four_to_three(float time);
86 
89 private:
90  enum class FadeType {
91  NO_FADE, FADE_IN, FADE_OUT
92  };
93 
94 private:
95  FadeType screen_fade;
96  float screen_fadetime;
97  float screen_fading;
98  FadeType border_fade;
99  float border_fadetime;
100  float border_fading;
101  float border_size;
102 
103  bool black;
104  bool borders;
105 
106 private:
107  DisplayEffect(const DisplayEffect&) = delete;
108  DisplayEffect& operator=(const DisplayEffect&) = delete;
109 };
110 
111 #endif
112 
113 /* EOF */
void fade_in(float time)
Gradually fades in the screen from black for the next ""time"" seconds.
Definition: display_effect.cpp:147
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: display_effect.hpp:37
void set_black(bool black)
Blackens or un-blackens the screen (depending on the value of ""black"").
Definition: display_effect.cpp:156
void four_to_three(float time)
Sets the display ratio to 4:3, removing the black bars added by ""sixteen_to_nine()"".
Definition: display_effect.cpp:183
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: display_effect.cpp:93
virtual bool is_singleton() const override
If true only a single object of this type is allowed in a given GameObjectManager.
Definition: display_effect.hpp:41
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: display_effect.cpp:46
""DisplayEffect"" is an interface for toying with the display.
Definition: display_effect.hpp:29
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
void sixteen_to_nine(float time)
Sets the display ratio to 16:9, effectively adding black bars at the top and bottom of the screen...
Definition: display_effect.cpp:168
bool is_black() const
Returns ""true"" if the screen has been blackened by ""set_black"".
Definition: display_effect.cpp:162
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
virtual bool is_saveable() const override
Indicates if the object will be saved.
Definition: display_effect.hpp:42
void fade_out(float time)
Gradually fades out the screen to black for the next ""time"" seconds.
Definition: display_effect.cpp:138
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42