Renamed namespaces to all lowercase
[supertux.git] / src / scripting / floating_image.cpp
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 #include <stdexcept>
18
19 #include "object/floating_image.hpp"
20 #include "scripting/floating_image.hpp"
21 #include "supertux/sector.hpp"
22 #include "worldmap/worldmap.hpp"
23
24 namespace scripting {
25
26 FloatingImage::FloatingImage(const std::string& spritefile) :
27   floating_image()
28 {
29   using namespace worldmap;
30
31   floating_image = new _FloatingImage(spritefile);
32   if(Sector::current() != NULL) {
33     Sector::current()->add_object(floating_image.get());
34   } else if(WorldMap::current() != NULL) {
35     WorldMap::current()->add_object(floating_image.get());
36   } else {
37     throw new std::runtime_error("Neither sector nor worldmap active");
38   }
39 }
40
41 FloatingImage::~FloatingImage()
42 {
43   floating_image->remove_me();
44 }
45
46 void
47 FloatingImage::set_layer(int layer)
48 {
49   floating_image->set_layer(layer);
50 }
51
52 int
53 FloatingImage::get_layer()
54 {
55   return floating_image->get_layer();
56 }
57
58 void
59 FloatingImage::set_pos(float x, float y)
60 {
61   floating_image->set_pos(Vector(x, y));
62 }
63
64 float
65 FloatingImage::get_pos_x()
66 {
67   return floating_image->get_pos().x;
68 }
69
70 float
71 FloatingImage::get_pos_y()
72 {
73   return floating_image->get_pos().y;
74 }
75
76 void
77 FloatingImage::set_anchor_point(int anchor)
78 {
79   floating_image->set_anchor_point((AnchorPoint) anchor);
80 }
81
82 int
83 FloatingImage::get_anchor_point()
84 {
85   return (int) floating_image->get_anchor_point();
86 }
87
88 bool
89 FloatingImage::get_visible()
90 {
91   return floating_image->get_visible();
92 }
93
94 void
95 FloatingImage::set_visible(bool visible)
96 {
97   floating_image->set_visible(visible);
98 }
99
100 void
101 FloatingImage::set_action(const std::string& action)
102 {
103   floating_image->set_action(action);
104 }
105
106 std::string
107 FloatingImage::get_action()
108 {
109   return floating_image->get_action();
110 }
111
112 void
113 FloatingImage::fade_in(float fadetime)
114 {
115   floating_image->fade_in(fadetime);
116 }
117
118 void
119 FloatingImage::fade_out(float fadetime)
120 {
121   floating_image->fade_out(fadetime);
122 }
123
124 }
125
126 /* EOF */