mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:20:05 +00:00 
			
		
		
		
	Only update icons on change
This commit is contained in:
		
							parent
							
								
									8262d8b034
								
							
						
					
					
						commit
						5beb16271a
					
				
					 1 changed files with 43 additions and 20 deletions
				
			
		|  | @ -179,7 +179,7 @@ void Icons::Initialize() | ||||||
|                             reinterpret_cast<void*>(8 * sizeof(float))); |                             reinterpret_cast<void*>(8 * sizeof(float))); | ||||||
|    gl.glEnableVertexAttribArray(4); |    gl.glEnableVertexAttribArray(4); | ||||||
| 
 | 
 | ||||||
|    // aAngle
 |    // aDisplayed
 | ||||||
|    gl.glVertexAttribPointer(5, |    gl.glVertexAttribPointer(5, | ||||||
|                             1, |                             1, | ||||||
|                             GL_FLOAT, |                             GL_FLOAT, | ||||||
|  | @ -315,59 +315,82 @@ std::shared_ptr<IconDrawItem> Icons::AddIcon() | ||||||
| 
 | 
 | ||||||
| void Icons::SetIconVisible(const std::shared_ptr<IconDrawItem>& di, | void Icons::SetIconVisible(const std::shared_ptr<IconDrawItem>& di, | ||||||
|                            bool                                 visible) |                            bool                                 visible) | ||||||
|  | { | ||||||
|  |    if (di->visible_ != visible) | ||||||
|    { |    { | ||||||
|       di->visible_ = visible; |       di->visible_ = visible; | ||||||
|       p->dirtyIcons_.insert(di); |       p->dirtyIcons_.insert(di); | ||||||
|    } |    } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| void Icons::SetIconTexture(const std::shared_ptr<IconDrawItem>& di, | void Icons::SetIconTexture(const std::shared_ptr<IconDrawItem>& di, | ||||||
|                            const std::string&                   iconSheet, |                            const std::string&                   iconSheet, | ||||||
|                            std::size_t                          iconIndex) |                            std::size_t                          iconIndex) | ||||||
|  | { | ||||||
|  |    if (di->iconSheet_ != iconSheet || di->iconIndex_ != iconIndex) | ||||||
|    { |    { | ||||||
|       di->iconSheet_ = iconSheet; |       di->iconSheet_ = iconSheet; | ||||||
|       di->iconIndex_ = iconIndex; |       di->iconIndex_ = iconIndex; | ||||||
|       p->dirtyIcons_.insert(di); |       p->dirtyIcons_.insert(di); | ||||||
|    } |    } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| void Icons::SetIconLocation(const std::shared_ptr<IconDrawItem>& di, | void Icons::SetIconLocation(const std::shared_ptr<IconDrawItem>& di, | ||||||
|                             double                               x, |                             double                               x, | ||||||
|                             double                               y) |                             double                               y) | ||||||
|  | { | ||||||
|  |    if (di->x_ != x || di->y_ != y) | ||||||
|    { |    { | ||||||
|       di->x_ = x; |       di->x_ = x; | ||||||
|       di->y_ = y; |       di->y_ = y; | ||||||
|       p->dirtyIcons_.insert(di); |       p->dirtyIcons_.insert(di); | ||||||
|    } |    } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| void Icons::SetIconAngle(const std::shared_ptr<IconDrawItem>& di, | void Icons::SetIconAngle(const std::shared_ptr<IconDrawItem>& di, | ||||||
|                          units::angle::degrees<double>        angle) |                          units::angle::degrees<double>        angle) | ||||||
|  | { | ||||||
|  |    if (di->angle_ != angle) | ||||||
|    { |    { | ||||||
|       di->angle_ = angle; |       di->angle_ = angle; | ||||||
|       p->dirtyIcons_.insert(di); |       p->dirtyIcons_.insert(di); | ||||||
|    } |    } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| void Icons::SetIconModulate(const std::shared_ptr<IconDrawItem>& di, | void Icons::SetIconModulate(const std::shared_ptr<IconDrawItem>& di, | ||||||
|                             boost::gil::rgba8_pixel_t            modulate) |                             boost::gil::rgba8_pixel_t            modulate) | ||||||
| { | { | ||||||
|    di->modulate_ = {modulate[0] / 255.0f, |    boost::gil::rgba32f_pixel_t newModulate = {modulate[0] / 255.0f, | ||||||
|                                               modulate[1] / 255.0f, |                                               modulate[1] / 255.0f, | ||||||
|                                               modulate[2] / 255.0f, |                                               modulate[2] / 255.0f, | ||||||
|                                               modulate[3] / 255.0f}; |                                               modulate[3] / 255.0f}; | ||||||
|  | 
 | ||||||
|  |    if (di->modulate_ != newModulate) | ||||||
|  |    { | ||||||
|  |       di->modulate_ = newModulate; | ||||||
|       p->dirtyIcons_.insert(di); |       p->dirtyIcons_.insert(di); | ||||||
|    } |    } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| void Icons::SetIconModulate(const std::shared_ptr<IconDrawItem>& di, | void Icons::SetIconModulate(const std::shared_ptr<IconDrawItem>& di, | ||||||
|                             boost::gil::rgba32f_pixel_t          modulate) |                             boost::gil::rgba32f_pixel_t          modulate) | ||||||
|  | { | ||||||
|  |    if (di->modulate_ != modulate) | ||||||
|    { |    { | ||||||
|       di->modulate_ = modulate; |       di->modulate_ = modulate; | ||||||
|       p->dirtyIcons_.insert(di); |       p->dirtyIcons_.insert(di); | ||||||
|    } |    } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| void Icons::SetIconHoverText(const std::shared_ptr<IconDrawItem>& di, | void Icons::SetIconHoverText(const std::shared_ptr<IconDrawItem>& di, | ||||||
|                              const std::string&                   text) |                              const std::string&                   text) | ||||||
|  | { | ||||||
|  |    if (di->hoverText_ != text) | ||||||
|    { |    { | ||||||
|       di->hoverText_ = text; |       di->hoverText_ = text; | ||||||
|       p->dirtyIcons_.insert(di); |       p->dirtyIcons_.insert(di); | ||||||
|    } |    } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| void Icons::FinishIcons() | void Icons::FinishIcons() | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat