mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 11:00:06 +00:00 
			
		
		
		
	Placefile image rendering
This commit is contained in:
		
							parent
							
								
									44030fdf87
								
							
						
					
					
						commit
						00c297094e
					
				
					 5 changed files with 545 additions and 1 deletions
				
			
		|  | @ -737,13 +737,15 @@ void PlacefileManager::Impl::LoadResources( | |||
|    const std::shared_ptr<gr::Placefile>& placefile) | ||||
| { | ||||
|    const auto iconFiles = placefile->icon_files(); | ||||
|    const auto drawItems = placefile->GetDrawItems(); | ||||
| 
 | ||||
|    const QUrl baseUrl = | ||||
|       QUrl::fromUserInput(QString::fromStdString(placefile->name())); | ||||
| 
 | ||||
|    std::vector<std::string> urlStrings; | ||||
|    std::vector<std::string> urlStrings {}; | ||||
|    urlStrings.reserve(iconFiles.size()); | ||||
| 
 | ||||
|    // Resolve Icon Files
 | ||||
|    std::transform(iconFiles.cbegin(), | ||||
|                   iconFiles.cend(), | ||||
|                   std::back_inserter(urlStrings), | ||||
|  | @ -757,6 +759,34 @@ void PlacefileManager::Impl::LoadResources( | |||
|                      return resolvedUrl.toString().toStdString(); | ||||
|                   }); | ||||
| 
 | ||||
|    // Resolve Image Files
 | ||||
|    for (auto& di : drawItems) | ||||
|    { | ||||
|       switch (di->itemType_) | ||||
|       { | ||||
|       case gr::Placefile::ItemType::Image: | ||||
|       { | ||||
|          const std::string& imageFile = | ||||
|             std::static_pointer_cast<gr::Placefile::ImageDrawItem>(di) | ||||
|                ->imageFile_; | ||||
| 
 | ||||
|          QUrl        fileUrl     = QUrl(QString::fromStdString(imageFile)); | ||||
|          QUrl        resolvedUrl = baseUrl.resolved(fileUrl); | ||||
|          std::string urlString   = resolvedUrl.toString().toStdString(); | ||||
| 
 | ||||
|          if (std::find(urlStrings.cbegin(), urlStrings.cend(), urlString) == | ||||
|              urlStrings.cend()) | ||||
|          { | ||||
|             urlStrings.push_back(urlString); | ||||
|          } | ||||
|          break; | ||||
|       } | ||||
| 
 | ||||
|       default: | ||||
|          break; | ||||
|       } | ||||
|    } | ||||
| 
 | ||||
|    ResourceManager::LoadImageResources(urlStrings); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat