1 | // SuperTux |
2 | // Copyright (C) 2015 Hume2 <teratux.mail@gmail.com> |
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 "editor/tip.hpp" |
18 | |
19 | #include "supertux/colorscheme.hpp" |
20 | #include "supertux/game_object.hpp" |
21 | #include "supertux/resources.hpp" |
22 | #include "util/log.hpp" |
23 | #include "video/drawing_context.hpp" |
24 | |
25 | Tip::Tip(GameObject& object) : |
26 | m_strings(), |
27 | m_header() |
28 | { |
29 | auto os = object.get_settings(); |
30 | m_header = os.get_name(); |
31 | |
32 | for (const auto& oo_ptr : os.get_options()) |
33 | { |
34 | const auto& oo = *oo_ptr; |
35 | |
36 | if (!(oo.get_flags() & OPTION_HIDDEN)) { |
37 | auto value = oo.to_string(); |
38 | if (!value.empty()) { |
39 | m_strings.push_back(oo.get_text() + ": " + value); |
40 | } |
41 | } |
42 | } |
43 | } |
44 | |
45 | void |
46 | Tip::draw(DrawingContext& context, const Vector& pos) |
47 | { |
48 | auto position = pos; |
49 | position.y += 35; |
50 | context.color().draw_text(Resources::normal_font, m_header, position, |
51 | ALIGN_LEFT, LAYER_GUI-11, ColorScheme::Menu::label_color); |
52 | |
53 | for (const auto& str : m_strings) { |
54 | position.y += 22; |
55 | context.color().draw_text(Resources::normal_font, str, position, |
56 | ALIGN_LEFT, LAYER_GUI-11, ColorScheme::Menu::default_color); |
57 | } |
58 | } |
59 | |
60 | void |
61 | Tip::draw_up(DrawingContext& context, const Vector& pos) |
62 | { |
63 | auto position = Vector(pos.x, pos.y - (static_cast<float>(m_strings.size()) + 1.0f) * 22.0f - 35.0f); |
64 | draw(context, position); |
65 | } |
66 | |
67 | /* EOF */ |
68 | |