| 1 | // This file is part of Dust Racing 2D. |
| 2 | // Copyright (C) 2011 Jussi Lind <[email protected]> |
| 3 | // |
| 4 | // Dust Racing 2D 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 | // Dust Racing 2D is distributed in the hope that it will be useful, |
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | // GNU General Public License for more details. |
| 12 | // |
| 13 | // You should have received a copy of the GNU General Public License |
| 14 | // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>. |
| 15 | |
| 16 | #include "tracktile.hpp" |
| 17 | |
| 18 | TrackTile::TrackTile( |
| 19 | QPointF location, |
| 20 | QPoint matrixLocation, |
| 21 | const QString & type, |
| 22 | TrackTile::TileType typeEnum) |
| 23 | : TrackTileBase(location, matrixLocation, type) |
| 24 | , m_rotation(0) |
| 25 | , m_typeEnum(typeEnum) |
| 26 | , m_hasAsphalt(false) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | void TrackTile::setRotation(int rotation) |
| 31 | { |
| 32 | m_rotation = rotation; |
| 33 | } |
| 34 | |
| 35 | int TrackTile::rotation() const |
| 36 | { |
| 37 | return m_rotation; |
| 38 | } |
| 39 | |
| 40 | void TrackTile::setSurface(MCSurfacePtr surface) |
| 41 | { |
| 42 | m_surface = surface; |
| 43 | } |
| 44 | |
| 45 | MCSurfacePtr TrackTile::surface() const |
| 46 | { |
| 47 | return m_surface; |
| 48 | } |
| 49 | |
| 50 | void TrackTile::setPreviewSurface(MCSurfacePtr surface) |
| 51 | { |
| 52 | m_previewSurface = surface; |
| 53 | } |
| 54 | |
| 55 | MCSurfacePtr TrackTile::previewSurface() const |
| 56 | { |
| 57 | return m_previewSurface; |
| 58 | } |
| 59 | |
| 60 | TrackTile::TileType TrackTile::tileTypeEnum() const |
| 61 | { |
| 62 | return m_typeEnum; |
| 63 | } |
| 64 | |
| 65 | void TrackTile::setTileTypeEnum(TrackTile::TileType type) |
| 66 | { |
| 67 | m_typeEnum = type; |
| 68 | |
| 69 | switch (type) |
| 70 | { |
| 71 | case TileType::Bridge: |
| 72 | case TileType::Corner90: |
| 73 | case TileType::Corner45Left: |
| 74 | case TileType::Corner45Right: |
| 75 | case TileType::Straight: |
| 76 | case TileType::Straight45Male: |
| 77 | case TileType::Straight45Female: |
| 78 | case TileType::Finish: |
| 79 | m_hasAsphalt = true; |
| 80 | break; |
| 81 | default: |
| 82 | m_hasAsphalt = false; |
| 83 | break; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | bool TrackTile::hasAsphalt() const |
| 88 | { |
| 89 | return m_hasAsphalt; |
| 90 | } |
| 91 | |
| 92 | TrackTile::~TrackTile() = default; |