mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-11-04 09:15:29 +01:00 
			
		
		
		
	Add explanation to touchscreen item tooltip code (#15607)
this explains some cryptic inventory code I wrote in #14029 / 771da80bbb
			
			
This commit is contained in:
		@@ -137,12 +137,26 @@ void GUIInventoryList::draw()
 | 
			
		||||
					client, rotation_kind);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Add hovering tooltip
 | 
			
		||||
		// Add hovering tooltip. The tooltip disappears if any item is selected,
 | 
			
		||||
		// including the currently hovered one.
 | 
			
		||||
		bool show_tooltip = !item.empty() && hovering && !selected_item;
 | 
			
		||||
		// Make it possible to see item tooltips on touchscreens
 | 
			
		||||
 | 
			
		||||
		if (RenderingEngine::getLastPointerType() == PointerType::Touch) {
 | 
			
		||||
			// Touchscreen users cannot hover over an item without selecting it.
 | 
			
		||||
			// To allow touchscreen users to see item tooltips, we also show the
 | 
			
		||||
			// tooltip if the item is selected and the finger is still on the
 | 
			
		||||
			// source slot.
 | 
			
		||||
			// The selected amount may be 0 in rare cases during "left-dragging"
 | 
			
		||||
			// (used to distribute items evenly).
 | 
			
		||||
			// In this case, the user doesn't see an item being dragged,
 | 
			
		||||
			// so we don't show the tooltip.
 | 
			
		||||
			// Note: `m_fs_menu->getSelectedAmount() != 0` below refers to the
 | 
			
		||||
			// part of the selected item the user is dragging.
 | 
			
		||||
			// `!item.empty()` would refer to the part of the selected item
 | 
			
		||||
			// remaining in the source slot.
 | 
			
		||||
			show_tooltip |= hovering && selected && m_fs_menu->getSelectedAmount() != 0;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (show_tooltip) {
 | 
			
		||||
			std::string tooltip = orig_item.getDescription(client->idef());
 | 
			
		||||
			if (m_fs_menu->doTooltipAppendItemname())
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user