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