1 | // SuperTux |
2 | // Copyright (C) 2015 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 | #include "scripting/sector.hpp" |
18 | |
19 | #include "object/ambient_light.hpp" |
20 | #include "object/music_object.hpp" |
21 | #include "supertux/sector.hpp" |
22 | #include "video/color.hpp" |
23 | |
24 | namespace scripting { |
25 | |
26 | Sector::Sector(::Sector* parent) : |
27 | m_parent(parent) |
28 | { |
29 | } |
30 | |
31 | void |
32 | Sector::fade_to_ambient_light(float red, float green, float blue, float fadetime) |
33 | { |
34 | auto& ambient_light = m_parent->get_singleton_by_type<AmbientLight>(); |
35 | ambient_light.fade_to_ambient_light(red, green, blue, fadetime); |
36 | } |
37 | |
38 | void |
39 | Sector::set_ambient_light(float red, float green, float blue) |
40 | { |
41 | auto& ambient_light = m_parent->get_singleton_by_type<AmbientLight>(); |
42 | ambient_light.set_ambient_light(Color(red, green, blue)); |
43 | } |
44 | |
45 | float |
46 | Sector::get_ambient_red() const |
47 | { |
48 | auto& ambient_light = m_parent->get_singleton_by_type<AmbientLight>(); |
49 | return ambient_light.get_ambient_light().red; |
50 | } |
51 | |
52 | float |
53 | Sector::get_ambient_green() const |
54 | { |
55 | auto& ambient_light = m_parent->get_singleton_by_type<AmbientLight>(); |
56 | return ambient_light.get_ambient_light().green; |
57 | } |
58 | |
59 | float |
60 | Sector::get_ambient_blue() const |
61 | { |
62 | auto& ambient_light = m_parent->get_singleton_by_type<AmbientLight>(); |
63 | return ambient_light.get_ambient_light().blue; |
64 | } |
65 | |
66 | void |
67 | Sector::set_gravity(float gravity) |
68 | { |
69 | m_parent->set_gravity(gravity); |
70 | } |
71 | |
72 | void |
73 | Sector::set_music(const std::string& filename) |
74 | { |
75 | auto& music = m_parent->get_singleton_by_type<MusicObject>(); |
76 | music.set_music(filename); |
77 | } |
78 | |
79 | } // namespace scripting |
80 | |
81 | /* EOF */ |
82 | |