| 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 "object/spawnpoint.hpp" | 
|---|
| 18 |  | 
|---|
| 19 | #include "editor/editor.hpp" | 
|---|
| 20 | #include "supertux/debug.hpp" | 
|---|
| 21 | #include "util/reader_mapping.hpp" | 
|---|
| 22 | #include "video/drawing_context.hpp" | 
|---|
| 23 | #include "video/surface.hpp" | 
|---|
| 24 |  | 
|---|
| 25 | SpawnPointMarker::SpawnPointMarker(const std::string& name, const Vector& pos) : | 
|---|
| 26 | m_surface(Surface::from_file( "images/engine/editor/spawnpoint.png")) | 
|---|
| 27 | { | 
|---|
| 28 | m_name = name; | 
|---|
| 29 | m_col.m_bbox.set_p1(pos); | 
|---|
| 30 | m_col.m_bbox.set_size(32, 32); | 
|---|
| 31 |  | 
|---|
| 32 | if (!Editor::is_active()) { | 
|---|
| 33 | set_group(COLGROUP_DISABLED); | 
|---|
| 34 | } | 
|---|
| 35 | } | 
|---|
| 36 |  | 
|---|
| 37 | SpawnPointMarker::SpawnPointMarker(const ReaderMapping& mapping) : | 
|---|
| 38 | m_surface(Surface::from_file( "images/engine/editor/spawnpoint.png")) | 
|---|
| 39 | { | 
|---|
| 40 | mapping.get( "name", m_name, ""); | 
|---|
| 41 | mapping.get( "x", m_col.m_bbox.get_left(), 0.0f); | 
|---|
| 42 | mapping.get( "y", m_col.m_bbox.get_top(), 0.0f); | 
|---|
| 43 |  | 
|---|
| 44 | m_col.m_bbox.set_size(32, 32); | 
|---|
| 45 | set_group(COLGROUP_DISABLED); | 
|---|
| 46 | } | 
|---|
| 47 |  | 
|---|
| 48 | void | 
|---|
| 49 | SpawnPointMarker::draw(DrawingContext& context) | 
|---|
| 50 | { | 
|---|
| 51 | if (Editor::is_active() || g_debug.show_collision_rects) | 
|---|
| 52 | { | 
|---|
| 53 | context.color().draw_surface(m_surface, m_col.m_bbox.p1(), LAYER_FOREGROUND1); | 
|---|
| 54 | } | 
|---|
| 55 | } | 
|---|
| 56 |  | 
|---|
| 57 | /* EOF */ | 
|---|
| 58 |  | 
|---|