mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 13:30:05 +00:00 
			
		
		
		
	Gracefully fallback when icon cannot be loaded
This commit is contained in:
		
							parent
							
								
									dc284974b3
								
							
						
					
					
						commit
						2fd94c6575
					
				
					 2 changed files with 20 additions and 3 deletions
				
			
		|  | @ -446,9 +446,18 @@ void MarkerManager::add_icon(const std::string& name, bool startup) | ||||||
|       const std::shared_ptr<boost::gil::rgba8_image_t> image = |       const std::shared_ptr<boost::gil::rgba8_image_t> image = | ||||||
|          ResourceManager::LoadImageResource(name); |          ResourceManager::LoadImageResource(name); | ||||||
| 
 | 
 | ||||||
|  |       if (image) | ||||||
|  |       { | ||||||
|          auto icon = types::MarkerIconInfo(name, -1, -1, image); |          auto icon = types::MarkerIconInfo(name, -1, -1, image); | ||||||
|          p->markerIcons_.emplace(name, icon); |          p->markerIcons_.emplace(name, icon); | ||||||
|       } |       } | ||||||
|  |       else | ||||||
|  |       { | ||||||
|  |          // defaultIconName should always be in markerIcons, so at is fine
 | ||||||
|  |          auto icon = p->markerIcons_.at(defaultIconName); | ||||||
|  |          p->markerIcons_.emplace(name, icon); | ||||||
|  |       } | ||||||
|  |    } | ||||||
| 
 | 
 | ||||||
|    if (!startup) |    if (!startup) | ||||||
|    { |    { | ||||||
|  |  | ||||||
|  | @ -88,8 +88,16 @@ void MarkerLayer::Impl::ReloadMarkers() | ||||||
|                   "{}\n{}, {}", marker.name, latitudeString, longitudeString) : |                   "{}\n{}, {}", marker.name, latitudeString, longitudeString) : | ||||||
|                fmt::format("{}, {}", latitudeString, longitudeString); |                fmt::format("{}, {}", latitudeString, longitudeString); | ||||||
| 
 | 
 | ||||||
| 
 |          auto iconInfo = markerManager_->get_icon(marker.iconName); | ||||||
|  |          if (iconInfo) | ||||||
|  |          { | ||||||
|  |             geoIcons_->SetIconTexture(icon, iconInfo->name, 0); | ||||||
|  |          } | ||||||
|  |          else | ||||||
|  |          { | ||||||
|             geoIcons_->SetIconTexture(icon, marker.iconName, 0); |             geoIcons_->SetIconTexture(icon, marker.iconName, 0); | ||||||
|  |          } | ||||||
|  | 
 | ||||||
|          geoIcons_->SetIconLocation(icon, marker.latitude, marker.longitude); |          geoIcons_->SetIconLocation(icon, marker.latitude, marker.longitude); | ||||||
|          geoIcons_->SetIconHoverText(icon, hoverText); |          geoIcons_->SetIconHoverText(icon, hoverText); | ||||||
|          geoIcons_->SetIconModulate(icon, marker.iconColor); |          geoIcons_->SetIconModulate(icon, marker.iconColor); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 AdenKoperczak
						AdenKoperczak