1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef SHERLOCK_SCALPEL_MAP_H 24 #define SHERLOCK_SCALPEL_MAP_H 25 26 #include "common/scummsys.h" 27 #include "common/array.h" 28 #include "common/rect.h" 29 #include "common/str-array.h" 30 #include "sherlock/surface.h" 31 #include "sherlock/map.h" 32 #include "sherlock/resources.h" 33 34 namespace Sherlock { 35 36 class SherlockEngine; 37 38 namespace Scalpel { 39 40 41 struct MapEntry : Common::Point { 42 int _translate; 43 MapEntryMapEntry44 MapEntry() : Common::Point(), _translate(-1) {} 45 MapEntryMapEntry46 MapEntry(int posX, int posY, int translate) : Common::Point(posX, posY), _translate(translate) {} 47 }; 48 49 class MapPaths { 50 private: 51 int _numLocations; 52 Common::Array< Common::Array<byte> > _paths; 53 54 public: 55 MapPaths(); 56 57 /** 58 * Load the data for the paths between locations on the map 59 */ 60 void load(int numLocations, Common::SeekableReadStream &s); 61 62 /** 63 * Get the path between two locations on the map 64 */ 65 const byte *getPath(int srcLocation, int destLocation); 66 }; 67 68 class ScalpelMap: public Map { 69 private: 70 Common::Array<MapEntry> _points; // Map locations for each scene 71 Common::StringArray _locationNames; 72 MapPaths _paths; 73 Common::Array<Common::Point> _pathPoints; 74 Common::Point _savedPos; 75 Common::Point _savedSize; 76 Surface _topLine; 77 ImageFile *_mapCursors; 78 ImageFile *_shapes; 79 ImageFile *_iconShapes; 80 WalkSequences _walkSequences; 81 Point32 _lDrawnPos; 82 int _point; 83 bool _placesShown; 84 int _cursorIndex; 85 bool _drawMap; 86 Surface _iconSave; 87 protected: 88 /** 89 * Load data needed for the map 90 */ 91 void loadData(); 92 93 /** 94 * Load and initialize all the sprites that are needed for the map display 95 */ 96 void setupSprites(); 97 98 /** 99 * Free the sprites and data used by the map 100 */ 101 void freeSprites(); 102 103 /** 104 * Draws an icon for every place that's currently known 105 */ 106 void showPlaces(); 107 108 /** 109 * Makes a copy of the top rows of the screen that are used to display location names 110 */ 111 void saveTopLine(); 112 113 /** 114 * Erases anything shown in the top line by restoring the previously saved original map background 115 */ 116 void eraseTopLine(); 117 118 /** 119 * Prints the name of the specified icon 120 */ 121 void showPlaceName(int idx, bool highlighted); 122 123 /** 124 * Update all on-screen sprites to account for any scrolling of the map 125 */ 126 void updateMap(bool flushScreen); 127 128 /** 129 * Handle moving icon for player from their previous location on the map to a destination location 130 */ 131 void walkTheStreets(); 132 133 /** 134 * Save the area under the player's icon 135 */ 136 void saveIcon(ImageFrame *src, const Common::Point &pt); 137 138 /** 139 * Restore the area under the player's icon 140 */ 141 void restoreIcon(); 142 143 /** 144 * Handles highlighting map icons, showing their names 145 */ 146 void highlightIcon(const Common::Point &pt); 147 public: 148 ScalpelMap(SherlockEngine *vm); ~ScalpelMap()149 ~ScalpelMap() override {} 150 151 const MapEntry &operator[](int idx) { return _points[idx]; } 152 153 /** 154 * Loads the list of points for locations on the map for each scene 155 */ 156 void loadPoints(int count, const int *xList, const int *yList, const int *transList); 157 158 /** 159 * Load the sequence data for player icon animations 160 */ 161 void loadSequences(int count, const byte *seq); 162 163 /** 164 * Show the map 165 */ 166 int show() override; 167 }; 168 169 } // End of namespace Scalpel 170 171 } // End of namespace Sherlock 172 173 #endif 174