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
26class ReaderMapping;
27
28class LevelTime final : public GameObject,
29 public ExposedObject<LevelTime, scripting::LevelTime>
30{
31 static Color text_color;
32public:
33 LevelTime(const ReaderMapping& reader);
34
35 virtual void update(float dt_sec) override;
36 virtual void draw(DrawingContext& context) override;
37
38 /** @name Scriptable Methods
39 @{ */
40
41 /** Resumes the countdown */
42 void start();
43
44 /** Pauses the countdown */
45 void stop();
46
47 /** Returns the number of seconds left on the clock */
48 float get_time() const;
49
50 /** Changes the number of seconds left on the clock */
51 void set_time(float time_left);
52
53 /** @} */
54 virtual std::string get_class() const override { return "leveltime"; }
55 virtual std::string get_display_name() const override { return _("Time Limit"); }
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
61private:
62 SurfacePtr time_surface;
63 bool running;
64 float time_left;
65
66private:
67 LevelTime(const LevelTime&) = delete;
68 LevelTime& operator=(const LevelTime&) = delete;
69};
70
71#endif
72
73/* EOF */
74