supertux
gradient.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_GRADIENT_HPP
18 #define HEADER_SUPERTUX_OBJECT_GRADIENT_HPP
19 
20 #include "squirrel/exposed_object.hpp"
21 #include "scripting/gradient.hpp"
22 #include "supertux/game_object.hpp"
23 #include "video/drawing_context.hpp"
24 
25 class ReaderMapping;
26 
27 class Gradient final :
28  public GameObject,
29  public ExposedObject<Gradient, scripting::Gradient>
30 {
31 public:
32  Gradient();
33  Gradient(const ReaderMapping& reader);
34  virtual ~Gradient();
35 
36  virtual void update(float dt_sec) override;
37  virtual void draw(DrawingContext& context) override;
38 
39  virtual bool is_saveable() const override;
40 
41  virtual std::string get_class() const override { return "gradient"; }
42  virtual std::string get_display_name() const override { return _("Gradient"); }
43 
44  virtual const std::string get_icon_path() const override {
45  return "images/engine/editor/gradient.png";
46  }
47 
48  virtual ObjectSettings get_settings() override;
49 
50  void set_gradient(Color top, Color bottom);
51  Color get_gradient_top() const { return m_gradient_top; }
52  Color get_gradient_bottom() const { return m_gradient_bottom; }
53 
54  GradientDirection get_direction() const { return m_gradient_direction; }
55  void set_direction(const GradientDirection& direction);
56 
57  int get_layer() const { return m_layer; }
58 
59 private:
60  int m_layer;
61  Color m_gradient_top;
62  Color m_gradient_bottom;
63  GradientDirection m_gradient_direction;
64  Blend m_blend;
65  DrawingTarget m_target;
66 
67 private:
68  Gradient(const Gradient&) = delete;
69  Gradient& operator=(const Gradient&) = delete;
70 };
71 
72 #endif
73 
74 /* EOF */
This class binds a certain GameObject class to a scripting class.
Definition: exposed_object.hpp:45
Definition: gradient.hpp:27
Definition: object_settings.hpp:35
virtual bool is_saveable() const override
Indicates if the object will be saved.
Definition: gradient.cpp:215
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: gradient.cpp:187
Definition: color.hpp:25
Definition: reader_mapping.hpp:31
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
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: gradient.cpp:153