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_RESOURCEPACK_H 20 #define OPENXCOM_RESOURCEPACK_H 21 22 #include <map> 23 #include <string> 24 #include <list> 25 #include <vector> 26 #include <SDL.h> 27 28 namespace OpenXcom 29 { 30 31 class Surface; 32 class SurfaceSet; 33 class Font; 34 class Palette; 35 class Polygon; 36 class Polyline; 37 class Music; 38 class SoundSet; 39 class Sound; 40 41 /** 42 * Packs of external game media. 43 * Resource packs contain all the game media that's 44 * loaded externally, like graphics, fonts, languages, 45 * audio and world map. 46 * @note The game is still hardcoded to X-Com resources, 47 * so for now this just serves to keep all the file loading 48 * in one place. 49 */ 50 class ResourcePack 51 { 52 private: 53 Music *_muteMusic; 54 Sound *_muteSound; 55 std::string _playingMusic; 56 protected: 57 std::map<std::string, Palette*> _palettes; 58 std::map<std::string, Font*> _fonts; 59 std::map<std::string, Surface*> _surfaces; 60 std::map<std::string, SurfaceSet*> _sets; 61 std::map<std::string, SoundSet*> _sounds; 62 std::list<Polygon*> _polygons; 63 std::list<Polyline*> _polylines; 64 std::map<std::string, Music*> _musics; 65 std::vector<Uint16> _voxelData; 66 public: 67 /// Create a new resource pack with a folder's contents. 68 ResourcePack(); 69 /// Cleans up the resource pack. 70 virtual ~ResourcePack(); 71 /// Gets a particular font. 72 Font *getFont(const std::string &name) const; 73 /// Gets a particular surface. 74 Surface *getSurface(const std::string &name) const; 75 /// Gets a particular surface set. 76 SurfaceSet *getSurfaceSet(const std::string &name) const; 77 /// Gets the list of world polygons. 78 std::list<Polygon*> *getPolygons(); 79 /// Gets the list of world polylines. 80 std::list<Polyline*> *getPolylines(); 81 /// Gets a particular music. 82 Music *getMusic(const std::string &name) const; 83 /// Gets a random music. 84 Music *getRandomMusic(const std::string &name) const; 85 /// Plays a particular music. 86 void playMusic(const std::string &name, bool random = false); 87 /// Gets a particular sound. 88 Sound *getSound(const std::string &set, unsigned int sound) const; 89 /// Gets a particular palette. 90 Palette *getPalette(const std::string &name) const; 91 /// Sets a new palette. 92 void setPalette(SDL_Color *colors, int firstcolor = 0, int ncolors = 256); 93 /// Gets list of voxel data. 94 std::vector<Uint16> *getVoxelData(); 95 }; 96 97 } 98 99 #endif 100