supertux
level_time.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_LEVEL_TIME_HPP
18 #define HEADER_SUPERTUX_OBJECT_LEVEL_TIME_HPP
19 
20 #include "squirrel/exposed_object.hpp"
21 #include "scripting/level_time.hpp"
22 #include "supertux/game_object.hpp"
23 #include "video/color.hpp"
24 #include "video/surface_ptr.hpp"
25 
26 class ReaderMapping;
27 
28 class LevelTime final : public GameObject,
29  public ExposedObject<LevelTime, scripting::LevelTime>
30 {
31  static Color text_color;
32 public:
33  LevelTime(const ReaderMapping& reader);
34 
35  virtual void update(float dt_sec) override;
36  virtual void draw(DrawingContext& context) override;
37 
42  void start();
43 
45  void stop();
46 
48  float get_time() const;
49 
51  void set_time(float time_left);
52 
54  virtual std::string get_class() const override { return "leveltime"; }
55  virtual std::string get_display_name() const override { return _("Level time"); }
56 
57  virtual ObjectSettings get_settings() override;
58 
59  virtual const std::string get_icon_path() const override { return "images/engine/editor/clock.png"; }
60 
61 private:
62  SurfacePtr time_surface;
63  bool running;
64  float time_left;
65 
66 private:
67  LevelTime(const LevelTime&) = delete;
68  LevelTime& operator=(const LevelTime&) = delete;
69 };
70 
71 #endif
72 
73 /* EOF */
float get_time() const
Returns the number of seconds left on the clock.
Definition: level_time.cpp:118
Definition: level_time.hpp:28
This class binds a certain GameObject class to a scripting class.
Definition: exposed_object.hpp:45
Definition: object_settings.hpp:35
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: level_time.cpp:78
void stop()
Pauses the countdown.
Definition: level_time.cpp:112
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
void set_time(float time_left)
Changes the number of seconds left on the clock.
Definition: level_time.cpp:124
Definition: color.hpp:25
void start()
Resumes the countdown.
Definition: level_time.cpp:106
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: level_time.cpp:58