mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 10:30:06 +00:00 
			
		
		
		
	Support placefile icon modulate with "scwx-ModulateIcon:" statement
This commit is contained in:
		
							parent
							
								
									1a9e87ba07
								
							
						
					
					
						commit
						2f41993d7b
					
				
					 3 changed files with 34 additions and 17 deletions
				
			
		|  | @ -488,11 +488,11 @@ void PlacefileIcons::Impl::UpdateBuffers() | ||||||
|       units::angle::degrees<float> angle = di->angle_; |       units::angle::degrees<float> angle = di->angle_; | ||||||
|       const float                  a     = angle.value(); |       const float                  a     = angle.value(); | ||||||
| 
 | 
 | ||||||
|       // Fixed modulate color
 |       // Modulate color
 | ||||||
|       const float mc0 = 1.0f; |       const float mc0 = di->modulate_[0] / 255.0f; | ||||||
|       const float mc1 = 1.0f; |       const float mc1 = di->modulate_[1] / 255.0f; | ||||||
|       const float mc2 = 1.0f; |       const float mc2 = di->modulate_[2] / 255.0f; | ||||||
|       const float mc3 = 1.0f; |       const float mc3 = di->modulate_[3] / 255.0f; | ||||||
| 
 | 
 | ||||||
|       newIconBuffer_.insert(newIconBuffer_.end(), |       newIconBuffer_.insert(newIconBuffer_.end(), | ||||||
|                             { |                             { | ||||||
|  |  | ||||||
|  | @ -81,6 +81,7 @@ public: | ||||||
|    { |    { | ||||||
|       IconDrawItem() { itemType_ = ItemType::Icon; } |       IconDrawItem() { itemType_ = ItemType::Icon; } | ||||||
| 
 | 
 | ||||||
|  |       boost::gil::rgba8_pixel_t modulate_ {}; | ||||||
|       double                    latitude_ {}; |       double                    latitude_ {}; | ||||||
|       double                    longitude_ {}; |       double                    longitude_ {}; | ||||||
|       double                    x_ {}; |       double                    x_ {}; | ||||||
|  |  | ||||||
|  | @ -70,6 +70,7 @@ public: | ||||||
|    // Parsing state
 |    // Parsing state
 | ||||||
|    units::length::nautical_miles<double> threshold_ {999.0_nmi}; |    units::length::nautical_miles<double> threshold_ {999.0_nmi}; | ||||||
|    boost::gil::rgba8_pixel_t             color_ {255, 255, 255, 255}; |    boost::gil::rgba8_pixel_t             color_ {255, 255, 255, 255}; | ||||||
|  |    boost::gil::rgba8_pixel_t             iconModulate_ {255, 255, 255, 255}; | ||||||
|    ColorMode                             colorMode_ {ColorMode::RGBA}; |    ColorMode                             colorMode_ {ColorMode::RGBA}; | ||||||
|    std::chrono::sys_time<std::chrono::seconds> startTime_ {}; |    std::chrono::sys_time<std::chrono::seconds> startTime_ {}; | ||||||
|    std::chrono::sys_time<std::chrono::seconds> endTime_ {}; |    std::chrono::sys_time<std::chrono::seconds> endTime_ {}; | ||||||
|  | @ -242,6 +243,8 @@ void Placefile::Impl::ProcessLine(const std::string& line) | ||||||
|    static const std::string imageKey_ {"Image:"}; |    static const std::string imageKey_ {"Image:"}; | ||||||
|    static const std::string polygonKey_ {"Polygon:"}; |    static const std::string polygonKey_ {"Polygon:"}; | ||||||
| 
 | 
 | ||||||
|  |    static const std::string scwxModulateIconKey_ {"scwx-ModulateIcon:"}; | ||||||
|  | 
 | ||||||
|    currentStatement_ = DrawingStatement::Standard; |    currentStatement_ = DrawingStatement::Standard; | ||||||
| 
 | 
 | ||||||
|    // When tokenizing, add one additional delimiter to discard unexpected
 |    // When tokenizing, add one additional delimiter to discard unexpected
 | ||||||
|  | @ -338,6 +341,18 @@ void Placefile::Impl::ProcessLine(const std::string& line) | ||||||
|          color_ = ParseColor(tokenList, 0, colorMode_); |          color_ = ParseColor(tokenList, 0, colorMode_); | ||||||
|       } |       } | ||||||
|    } |    } | ||||||
|  |    else if (boost::istarts_with(line, scwxModulateIconKey_)) | ||||||
|  |    { | ||||||
|  |       // Supercell Wx Extension
 | ||||||
|  |       // scwx-ModulateIcon: red green blue [alpha]
 | ||||||
|  |       std::vector<std::string> tokenList = util::ParseTokens( | ||||||
|  |          line, {" ", " ", " ", " "}, scwxModulateIconKey_.size()); | ||||||
|  | 
 | ||||||
|  |       if (tokenList.size() >= 3) | ||||||
|  |       { | ||||||
|  |          iconModulate_ = ParseColor(tokenList, 0, colorMode_); | ||||||
|  |       } | ||||||
|  |    } | ||||||
|    else if (boost::istarts_with(line, refreshKey_)) |    else if (boost::istarts_with(line, refreshKey_)) | ||||||
|    { |    { | ||||||
|       // Refresh: minutes
 |       // Refresh: minutes
 | ||||||
|  | @ -433,6 +448,7 @@ void Placefile::Impl::ProcessLine(const std::string& line) | ||||||
|          di->threshold_ = threshold_; |          di->threshold_ = threshold_; | ||||||
|          di->startTime_ = startTime_; |          di->startTime_ = startTime_; | ||||||
|          di->endTime_   = endTime_; |          di->endTime_   = endTime_; | ||||||
|  |          di->modulate_  = iconModulate_; | ||||||
| 
 | 
 | ||||||
|          ParseLocation(tokenList[0], |          ParseLocation(tokenList[0], | ||||||
|                        tokenList[1], |                        tokenList[1], | ||||||
|  | @ -686,7 +702,7 @@ void Placefile::Impl::ProcessLine(const std::string& line) | ||||||
|    } |    } | ||||||
|    else |    else | ||||||
|    { |    { | ||||||
|       logger_->warn("Unknown statement: {}", line); |       logger_->trace("Unknown statement: {}", line); | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat