| 135 | #endif |
| 136 | |
| 137 | bool SpriteAtlas::LoadSprites(ReadStream& stream) |
| 138 | { |
| 139 | ScopeLock lock(Locker); |
| 140 | |
| 141 | // Sprites may be used on rendering thread so lock drawing for a while |
| 142 | #if USE_EDITOR |
| 143 | GPUDevice* gpuDevice = GPUDevice::Instance; |
| 144 | if (gpuDevice) |
| 145 | gpuDevice->Locker.Lock(); |
| 146 | #endif |
| 147 | |
| 148 | Sprites.Clear(); |
| 149 | |
| 150 | int32 tilesVersion, tilesCount; |
| 151 | stream.Read(tilesVersion); |
| 152 | if (tilesVersion != 1) |
| 153 | { |
| 154 | #if USE_EDITOR |
| 155 | if (gpuDevice) |
| 156 | gpuDevice->Locker.Unlock(); |
| 157 | #endif |
| 158 | LOG(Warning, "Invalid tiles version."); |
| 159 | return true; |
| 160 | } |
| 161 | stream.Read(tilesCount); |
| 162 | Sprites.Resize(tilesCount); |
| 163 | for (Sprite& t : Sprites) |
| 164 | { |
| 165 | stream.Read(t.Area); |
| 166 | stream.Read(t.Name, 49); |
| 167 | } |
| 168 | |
| 169 | #if USE_EDITOR |
| 170 | if (gpuDevice) |
| 171 | gpuDevice->Locker.Unlock(); |
| 172 | #endif |
| 173 | return false; |
| 174 | } |
| 175 | |
| 176 | Asset::LoadResult SpriteAtlas::load() |
| 177 | { |