| 124 | } |
| 125 | |
| 126 | void TextureAtlasLoader::loadFromStream( IOStream& IOS ) { |
| 127 | mRL.setThreaded( mThreaded ); |
| 128 | |
| 129 | if ( IOS.isOpen() ) { |
| 130 | IOS.read( (char*)&mTexGrHdr, sizeof( sTextureAtlasHdr ) ); |
| 131 | |
| 132 | if ( mTexGrHdr.Magic == EE_TEXTURE_ATLAS_MAGIC ) { |
| 133 | for ( Uint32 i = 0; i < mTexGrHdr.TextureCount; i++ ) { |
| 134 | sTextureHdr tTextureHdr; |
| 135 | sTempTexAtlas tTexAtlas; |
| 136 | |
| 137 | IOS.read( (char*)&tTextureHdr, sizeof( sTextureHdr ) ); |
| 138 | |
| 139 | tTexAtlas.Texture = tTextureHdr; |
| 140 | tTexAtlas.TextureRegions.resize( tTextureHdr.TextureRegionCount ); |
| 141 | |
| 142 | std::string name( &tTextureHdr.Name[0] ); |
| 143 | std::string path( FileSystem::fileRemoveFileName( mTextureAtlasPath ) + name ); |
| 144 | |
| 145 | //! Checks if the texture is already loaded |
| 146 | Texture* tTex = TextureFactory::instance()->getByName( path ); |
| 147 | |
| 148 | if ( !mSkipResourceLoad && NULL == tTex ) { |
| 149 | if ( NULL != mPack ) { |
| 150 | mRL.add( [this, path = std::move( path )] { |
| 151 | TextureFactory::instance()->loadFromPack( mPack, path ); |
| 152 | } ); |
| 153 | } else { |
| 154 | mRL.add( [path = std::move( path )] { |
| 155 | TextureFactory::instance()->loadFromFile( path ); |
| 156 | } ); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | IOS.read( (char*)&tTexAtlas.TextureRegions[0], |
| 161 | sizeof( sTextureRegionHdr ) * tTextureHdr.TextureRegionCount ); |
| 162 | |
| 163 | mTempAtlass.push_back( tTexAtlas ); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | if ( !mSkipResourceLoad ) { |
| 168 | mIsLoading = true; |
| 169 | mRL.load( [this]( ResourceLoader* ) { |
| 170 | if ( !mLoaded ) { |
| 171 | createTextureRegions(); |
| 172 | } |
| 173 | } ); |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | void TextureAtlasLoader::loadFromFile( const std::string& TextureAtlasPath ) { |
| 179 | if ( TextureAtlasPath.size() ) |
nothing calls this directly
no test coverage detected