| 1 | // SuperTux |
| 2 | // Copyright (C) 2016 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/marker_object.hpp" |
| 18 | |
| 19 | #include "supertux/globals.hpp" |
| 20 | #include "supertux/resources.hpp" |
| 21 | #include "video/color.hpp" |
| 22 | #include "video/drawing_context.hpp" |
| 23 | #include "video/renderer.hpp" |
| 24 | #include "video/video_system.hpp" |
| 25 | |
| 26 | MarkerObject::MarkerObject (const Vector& pos) |
| 27 | { |
| 28 | m_col.m_bbox.set_p1(pos); |
| 29 | m_col.m_bbox.set_size(16, 16); |
| 30 | } |
| 31 | |
| 32 | MarkerObject::MarkerObject () |
| 33 | { |
| 34 | m_col.m_bbox.set_p1(Vector(0, 0)); |
| 35 | m_col.m_bbox.set_p2(Vector(16, 16)); |
| 36 | } |
| 37 | |
| 38 | void |
| 39 | MarkerObject::draw(DrawingContext& context) |
| 40 | { |
| 41 | Vector dir = get_point_vector(); |
| 42 | if (dir.x == 0 && dir.y == 0) { |
| 43 | context.color().draw_filled_rect(m_col.m_bbox, Color(1, 1, 1, 0.5), 7.5, LAYER_GUI-20); |
| 44 | } else { |
| 45 | // draw a triangle |
| 46 | dir = dir.unit() * 8; |
| 47 | Vector dir2 = Vector(-dir.y, dir.x); |
| 48 | Vector pos = m_col.m_bbox.get_middle(); |
| 49 | context.color().draw_triangle(pos + dir * 1.5, pos - dir + dir2, pos - dir - dir2, |
| 50 | Color(1, 1, 1, 0.5), LAYER_GUI-20); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /* EOF */ |
| 55 | |