#ifndef __OD2SRC_RESOURCES_H__ #define __OD2SRC_RESOURCES_H__ 1 /* OD2 - Dune II Clone * * Copyright (C) 2009 Robert Crossfield * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * * $Id$ * */ #include #include #include #include #include #include #include #include #include class cScriptEmc; class cResources : public cBase { private: string _DataPath; // Path to game data files dune2::Dune2File *_D2Exe; map< string, cScriptEmc*> _dataEmc; map< string, eastwood::WsaFile*> _dataWSA; map< string, eastwood::PakFile*> _Paks; // All game PAKs std::map _fonts; map< string, eastwood::IniFile::KeyListHandle> _IniHandles; map< word, eastwood::SDL::Surface* > _Tiles; // In-game tile images map< uint32_t, map< uint32_t, eastwood::SDL::Surface*> > _dataSHP; // In-game graphics map< uint16_t, vector*> _dataIconFrames; // Loaded frames byte _angleAdjust[256]; eastwood::IniFile *_ini; // Current loaded 'INI' scenario eastwood::MapFile *_map; eastwood::IcnFile *_icons; // Loaded map Icons eastwood::SDL::Palette *_paletteIBM; // IBM Palette SDL_Palette *_palIBM; word _tileFogWar, _tileBloom, _tileConcrete, _tileWall; // Tile Reference IDs word _tileLand; // void angleAdjustBuild(); string languageAdd( string pFilename ); cScriptEmc *emcGet( string pFilename ); cScriptEmc *emcUnitsLoad(); cScriptEmc *emcStructuresLoad(); cScriptEmc *emcHousesLoad(); void pakLoad(); // Load all PAKs into '_Paks' map void mapTileIDsLoad(); // Load the Map-Tiles IDs into '_tile' variables void shpLoad(); // Load the 4 SHP files into _dataSHP void shpLoad( string Filename );// Load the SHP file into _dataSHP public: cResources( cOD2 *pEngine, string pPath ); ~cResources(); eastwood::SDL::Surface *CpsGet( string fileName ) ; string *fileRead( string pFileName); byte *fileRead( string pFile, uint32_t &pFileSize ); // Read from a file on disk byte *fileRead( istream *pStream, uint32_t &pSize ); // Read from an istream istream *fileOpen( string pFilename ); const FntFile& getFont(std::string fileName); void IniLoad( string fileName ); // Load an ini in string IniStringGet( string pSection, string pVariable, string pDefault); uint32_t IniNumGet( string pSection, string pVariable, uint32_t pDefault ); void IniSectionOpen( string pSection ); string IniSectionNext( string pSection ); void IniSectionClose(string pSection ); uint16_t actionFind( std::string pName ); const dune2::Action actionGet( uint16_t pIndex ); uint32_t aiModeFind( string pName ) ; const std::vector& getAnims(uint16_t animIdx); const std::vector& getStructureAnims(uint16_t animIdx); const std::vector& getUnitAnims(uint16_t animIdx); const std::vector& angleTableGet(); cScriptEmc *emcStructuresGet(); cScriptEmc *emcUnitsGet(); cScriptEmc *emcTeamGet(); uint16_t houseFind( string pName ); const dune2::House houseGet( eHouse pHouse ); uint16_t structureFind(std::string pName); const dune2::Structure structureGet(uint16_t pIndex); const std::vector& structureGet() { return _D2Exe->getStructureData(); } uint16_t unitFind(std::string pName); const dune2::Unit unitGet(uint16_t pIndex); const std::vector& unitGet() { return _D2Exe->getUnitData(); } const UPoint& getLayoutTileDiff(uint8_t pIndex); const std::vector& getLayoutTiles(uint8_t pIndex); word foundationSizeGet( uint32_t pIndex ); const dune2::File fileTableGet( uint16_t pIndex ); // const std::vector& getMapOffsetIndexes(); const std::vector& getMapOffsets(); const std::vector& getMovementTiles(); const std::vector& getMapSinTable(); const std::vector& getMapCosTable(); const MapInfo& getMapScale(uint8_t pIndex); uint16_t mapIcnCount( word pIndex ); vector *mapIcnFrameSetGet( word pIndex ); eastwood::SDL::Surface *mapTileGet( word pTileIndex ); const vector& mapGet(uint16_t pIndex) { return (*_map)[pIndex]; } const std::vector& mapMoveModGet(); const std::vector& mapModGet(); word movementFind( string pName ); uint32_t movementNamesGet( string pName ); uint16_t getMovementUnk1(uint16_t pIndex); const std::vector >& placementPositionsGet(); inline const std::vector& getEmc15CDA() { return _D2Exe->getEmc15CDA(); } const UPoint& getUnitAngleFrameAdjust(uint8_t row, uint8_t frame); int8_t unitFrameAdjustGet(uint8_t pIndex); const SPoint& getUnitTurretFrame(uint8_t row, uint8_t frame); SDL_Palette *paletteGet() { return _palIBM; } eastwood::SDL::Surface *shpGet( word pIndex, word pMode ); // Don't free these surfaces eastwood::SDL::Surface *wsaGet( string pFileName, uint32_t pFrame ); void resourcePrepare(); inline SDL_Color *colorGet( word color ) { return &_palIBM->colors[color]; } inline word tileFogWar() { return _tileFogWar; } inline word tileBloom() { return _tileBloom; } inline word tileConcrete() { return _tileConcrete; } inline word tileWall() { return _tileWall; } inline word tileLand() { return _tileLand; } inline uint16_t getMapTileColor(uint16_t pTile) { return _D2Exe->getMapTileColors()[pTile]; } inline byte angleAdjustGet( uint32_t pIndex ) { return _angleAdjust[ pIndex & 0xFF ] & 0x07; } }; #endif // __OD2SRC_RESOURCES_H__