| 23 | } |
| 24 | |
| 25 | bool ImportTexture::TryGetImportOptions(const StringView& path, Options& options) |
| 26 | { |
| 27 | #if IMPORT_TEXTURE_CACHE_OPTIONS |
| 28 | if (FileSystem::FileExists(path)) |
| 29 | { |
| 30 | auto tmpFile = ContentStorageManager::GetStorage(path); |
| 31 | AssetInitData data; |
| 32 | if (tmpFile |
| 33 | && tmpFile->GetEntriesCount() == 1 |
| 34 | && IsSpriteAtlasOrTexture(tmpFile->GetEntry(0).TypeName) |
| 35 | && !tmpFile->LoadAssetHeader(0, data) |
| 36 | && data.SerializedVersion >= 4) |
| 37 | { |
| 38 | // For sprite atlas try to get sprites from the last chunk |
| 39 | if (tmpFile->GetEntry(0).TypeName == SpriteAtlas::TypeName) |
| 40 | { |
| 41 | auto chunk15 = data.Header.Chunks[15]; |
| 42 | if (chunk15 != nullptr && !tmpFile->LoadAssetChunk(chunk15) && chunk15->Data.IsValid()) |
| 43 | { |
| 44 | MemoryReadStream stream(chunk15->Data.Get(), chunk15->Data.Length()); |
| 45 | int32 tilesVersion, tilesCount; |
| 46 | stream.Read(tilesVersion); |
| 47 | if (tilesVersion == 1) |
| 48 | { |
| 49 | options.Sprites.Clear(); |
| 50 | stream.Read(tilesCount); |
| 51 | for (int32 i = 0; i < tilesCount; i++) |
| 52 | { |
| 53 | // Load sprite |
| 54 | Sprite t; |
| 55 | stream.Read(t.Area); |
| 56 | stream.Read(t.Name, 49); |
| 57 | options.Sprites.Add(t); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // Check import meta |
| 64 | rapidjson_flax::Document metadata; |
| 65 | metadata.Parse((const char*)data.Metadata.Get(), data.Metadata.Length()); |
| 66 | if (metadata.HasParseError() == false) |
| 67 | { |
| 68 | options.Deserialize(metadata, nullptr); |
| 69 | return true; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | #endif |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | void ImportTexture::InitOptions(CreateAssetContext& context, Options& options) |
| 78 | { |
nothing calls this directly
no test coverage detected