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 //============================================================================= 24 // 25 // Functions related to finding and opening game assets. 26 // 27 //============================================================================= 28 29 #ifndef AGS_ENGINE_AC_ASSET_HELPER_H 30 #define AGS_ENGINE_AC_ASSET_HELPER_H 31 32 #include "ags/lib/std/memory.h" 33 #include "ags/lib/std/utility.h" 34 #include "ags/shared/util/string.h" 35 36 namespace AGS3 { 37 38 namespace AGS { 39 namespace Shared { 40 class Stream; 41 } // namespace Shared 42 } // namespace AGS 43 44 using AGS::Shared::Stream; 45 using AGS::Shared::String; 46 47 // Looks for valid asset library everywhere and returns path, or empty string if failed 48 String find_assetlib(const String &filename); 49 50 extern "C" { 51 struct PACKFILE; // Allegro 4's own stream type 52 } 53 54 // AssetPath combines asset name and optional library filter, that serves to narrow down the search 55 struct AssetPath { 56 String Name; 57 String Filter; 58 NameAssetPath59 AssetPath(const String &name = "", const String &filter = "") : Name(name), Filter(filter) { 60 } 61 }; 62 63 // Returns the path to the audio asset, considering the given bundling type 64 AssetPath get_audio_clip_assetpath(int bundling_type, const String &filename); 65 // Returns the path to the voice-over asset 66 AssetPath get_voice_over_assetpath(const String &filename); 67 68 // Locates asset among known locations, on success returns open stream and asset's size. 69 Stream *LocateAsset(const AssetPath &path, size_t &asset_size); 70 // Custom AGS PACKFILE user object 71 // TODO: it is preferrable to let our Stream define custom readable window instead, 72 // keeping this as simple as possible for now (we may require a stream classes overhaul). 73 struct AGS_PACKFILE_OBJ { 74 std::unique_ptr<Stream> stream; 75 size_t asset_size = 0u; 76 size_t remains = 0u; 77 }; 78 // Creates PACKFILE stream from AGS asset. 79 // This function is supposed to be used only when you have to create Allegro 80 // object, passing PACKFILE stream to constructor. 81 PACKFILE *PackfileFromAsset(const AssetPath &path, size_t &asset_size); 82 bool DoesAssetExistInLib(const AssetPath &assetname); 83 84 } // namespace AGS3 85 86 #endif 87