1 /* Copyright (C) 2013-2014 Michal Brzozowski (rusolis@poczta.fm) 2 3 This file is part of KeeperRL. 4 5 KeeperRL is free software; you can redistribute it and/or modify it under the terms of the 6 GNU General Public License as published by the Free Software Foundation; either version 2 7 of the License, or (at your option) any later version. 8 9 KeeperRL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 10 even the implied warranty of 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 along with this program. 14 If not, see http://www.gnu.org/licenses/ . */ 15 16 #pragma once 17 18 #include "renderer.h" 19 #include "util.h" 20 21 enum class ViewId; 22 class ViewObject; 23 24 class Tile { 25 public: 26 typedef Renderer::TileCoord TileCoord; 27 static const Tile& getTile(ViewId, bool sprite); 28 static const Tile& getTile(ViewId); 29 static Color getColor(const ViewObject& object); 30 31 static Tile empty(); 32 static Tile fromString(const string&, Color, bool symbol = false); 33 static Tile byCoord(TileCoord); 34 35 static void initialize(Renderer&, bool useTiles); 36 37 Color color; 38 string text; 39 bool symFont = false; 40 double translucent = 0; 41 bool roundShadow = false; 42 bool floorBorders = false; 43 bool wallShadow = false; 44 45 Tile addConnection(DirSet, TileCoord); 46 Tile addOption(Dir, TileCoord); 47 Tile setFloorBorders(); 48 49 Tile addBackground(TileCoord); 50 51 Tile addExtraBorder(DirSet, TileCoord); 52 Tile addExtraBorderId(ViewId); 53 Tile addCorner(DirSet cornerDef, DirSet borders, TileCoord); 54 Tile setTranslucent(double v); 55 Tile addHighlight(TileCoord); 56 Tile setColor(Color); 57 Tile setRoundShadow(); 58 Tile setWallShadow(); 59 optional<TileCoord> getHighlightCoord() const; 60 61 const vector<ViewId>& getExtraBorderIds() const; 62 bool hasExtraBorders() const; 63 bool hasAnyConnections() const; 64 optional<TileCoord> getExtraBorderCoord(DirSet) const; 65 66 bool hasSpriteCoord() const; 67 68 TileCoord getSpriteCoord() const; 69 TileCoord getSpriteCoord(DirSet) const; 70 optional<TileCoord> getBackgroundCoord() const; 71 72 bool hasAnyCorners() const; 73 const vector<TileCoord>& getCornerCoords(DirSet) const; 74 75 private: 76 static void loadTiles(); 77 static void loadUnicode(); 78 friend class TileCoordLookup; 79 Tile(); 80 Tile(TileCoord); 81 // Tile(const Tile&) = default; 82 optional<TileCoord> tileCoord; 83 optional<TileCoord> backgroundCoord; 84 optional<TileCoord> highlightCoord; 85 array<optional<TileCoord>, 256> connections; 86 optional<pair<Dir, TileCoord>> connectionOption; 87 array<vector<TileCoord>, 256> corners; 88 array<optional<TileCoord>, 256> extraBorders; 89 bool anyExtraBorders = false; 90 bool anyConnections = false; 91 bool anyCorners = false; 92 DirSet connectionsMask = DirSet{Dir::N, Dir::E, Dir::S, Dir::W}; 93 vector<ViewId> extraBorderIds; 94 static void addTile(ViewId, Tile); 95 static void addSymbol(ViewId, Tile); 96 }; 97 98 99