1 /* 2 * Copyright 2010-2014 OpenXcom Developers. 3 * 4 * This file is part of OpenXcom. 5 * 6 * OpenXcom is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * OpenXcom is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #ifndef OPENXCOM_SURFACESET_H 20 #define OPENXCOM_SURFACESET_H 21 22 #include <vector> 23 #include <map> 24 #include <string> 25 #include <SDL.h> 26 27 namespace OpenXcom 28 { 29 30 class Surface; 31 32 /** 33 * Container of a set of surfaces. 34 * Used to manage single images that contain series of 35 * frames inside, like animated sprites, making them easier 36 * to access without constant cropping. 37 */ 38 class SurfaceSet 39 { 40 private: 41 int _width, _height; 42 std::map<int, Surface*> _frames; 43 public: 44 /// Crates a surface set with frames of the specified size. 45 SurfaceSet(int width, int height); 46 /// Creates a surface set from an existing one. 47 SurfaceSet(const SurfaceSet& other); 48 /// Cleans up the surface set. 49 ~SurfaceSet(); 50 /// Loads an X-Com set of PCK/TAB image files. 51 void loadPck(const std::string &pck, const std::string &tab = ""); 52 /// Loads an X-Com DAT image file. 53 void loadDat(const std::string &filename); 54 /// Gets a particular frame from the set. 55 Surface *getFrame(int i); 56 /// Creates a new surface and returns a pointer to it. 57 Surface *addFrame(int i); 58 /// Gets the width of all frames. 59 int getWidth() const; 60 /// Gets the height of all frames. 61 int getHeight() const; 62 /// Gets the total frames in the set. 63 size_t getTotalFrames() const; 64 /// Sets the surface set's palette. 65 void setPalette(SDL_Color *colors, int firstcolor = 0, int ncolors = 256); 66 std::map<int, Surface*> *getFrames(); 67 }; 68 69 } 70 71 #endif 72