1// SuperTux
2// Copyright (C) 2018 Ingo Ruhnke <grumbel@gmail.com>
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_AMBIENT_LIGHT_HPP
18#define HEADER_SUPERTUX_OBJECT_AMBIENT_LIGHT_HPP
19
20#include "supertux/game_object.hpp"
21
22#include "video/color.hpp"
23
24class AmbientLight : public GameObject
25{
26public:
27 AmbientLight(const Color& color);
28 AmbientLight(const ReaderMapping& mapping);
29
30 virtual void update(float dt_sec) override;
31 virtual void draw(DrawingContext& context) override;
32
33 virtual bool is_singleton() const override { return true; }
34
35 virtual std::string get_class() const override { return "ambient-light"; }
36 virtual std::string get_display_name() const override { return _("Ambient Light"); }
37 virtual const std::string get_icon_path() const override { return "images/engine/editor/ambient_light.png"; }
38
39 virtual ObjectSettings get_settings() override;
40
41 void set_ambient_light(const Color& ambient_light);
42 Color get_ambient_light() const;
43
44 /** Fades to the target ambient light */
45 void fade_to_ambient_light(float red, float green, float blue, float seconds);
46
47private:
48 Color m_ambient_light;
49
50 /** Specifies whether we're fading the ambient light*/
51 bool m_ambient_light_fading;
52
53 /** Source color for fading */
54 Color m_source_ambient_light;
55
56 /** Target color for fading */
57 Color m_target_ambient_light;
58
59 /** Ambient light fade duration */
60 float m_ambient_light_fade_duration;
61
62 /** Accumulated time for fading */
63 float m_ambient_light_fade_accum;
64
65private:
66 AmbientLight(const AmbientLight&) = delete;
67 AmbientLight& operator=(const AmbientLight&) = delete;
68};
69
70#endif
71
72/* EOF */
73