require "Vehicles/ISUI/ISVehicleMechanics"

function ISVehicleMechanics:doDrawItem(y, item, alt)
	if not item.item.cat then
		if item.itemindex == self.selected then
			self:drawRect(0, y, self:getWidth(), item.height, 0.1, 1.0, 1.0, 1.0);
		elseif item.itemindex == self.mouseoverselected and ((self.parent.context and not self.parent.context:isVisible()) or not self.parent.context) then
			self:drawRect(0, y, self:getWidth(), item.height, 0.05, 1.0, 1.0, 1.0);
		end
	end
	
	if item.item.cat then
		self:drawText(item.item.name, 0, y, self.parent.partCatRGB.r, self.parent.partCatRGB.g, self.parent.partCatRGB.b, self.parent.partCatRGB.a, UIFont.Medium);
		y = y + 5;
	else
		local rgb = self.parent.partRGB;
		if not item.item.part:getInventoryItem() and item.item.part:getTable("install") then
			self:drawText(item.item.name, 20, y, getCore():getBadHighlitedColor():getR(), getCore():getBadHighlitedColor():getG(), getCore():getBadHighlitedColor():getB(), 1, UIFont.Small);
		else
			self:drawText(item.item.name, 20, y, self.parent.partRGB.r, self.parent.partRGB.g, self.parent.partRGB.b, self.parent.partRGB.a, UIFont.Small);
			local charge = ""
			if item.item.part:getId() == "Battery"  then
				local amount = (math.floor(item.item.part:getInventoryItem():getCurrentUsesFloat() * 100))
				charge = ": " .. amount .. "% " .. getText("IGUI_invpanel_Remaining")
				self:drawText(charge, getTextManager():MeasureStringX(UIFont.Small, item.item.name) + 20, y, self.parent.partRGB.r, self.parent.partRGB.g, self.parent.partRGB.b, self.parent.partRGB.a, UIFont.Small);
			elseif item.item.part:getId() == "Battery1"  then
					local amount = (math.floor(item.item.part:getInventoryItem():getCurrentUsesFloat() * 100))
					charge = ": " .. amount .. "% " .. getText("IGUI_invpanel_Remaining")
					self:drawText(charge, getTextManager():MeasureStringX(UIFont.Small, item.item.name) + 20, y, self.parent.partRGB.r, self.parent.partRGB.g, self.parent.partRGB.b, self.parent.partRGB.a, UIFont.Small);
				
				elseif item.item.part:getId() == "Battery2"  then
					local amount = (math.floor(item.item.part:getInventoryItem():getCurrentUsesFloat() * 100))
					charge = ": " .. amount .. "% " .. getText("IGUI_invpanel_Remaining")
					self:drawText(charge, getTextManager():MeasureStringX(UIFont.Small, item.item.name) + 20, y, self.parent.partRGB.r, self.parent.partRGB.g, self.parent.partRGB.b, self.parent.partRGB.a, UIFont.Small);
						
			
				elseif item.item.part:getId() == "Battery3"  then
					local amount = (math.floor(item.item.part:getInventoryItem():getCurrentUsesFloat() * 100))
					charge = ": " .. amount .. "% " .. getText("IGUI_invpanel_Remaining")
					self:drawText(charge, getTextManager():MeasureStringX(UIFont.Small, item.item.name) + 20, y, self.parent.partRGB.r, self.parent.partRGB.g, self.parent.partRGB.b, self.parent.partRGB.a, UIFont.Small);
					
				elseif item.item.part:getId() == "Battery4"  then
					local amount = (math.floor(item.item.part:getInventoryItem():getCurrentUsesFloat() * 100))
					charge = ": " .. amount .. "% " .. getText("IGUI_invpanel_Remaining")
					self:drawText(charge, getTextManager():MeasureStringX(UIFont.Small, item.item.name) + 20, y, self.parent.partRGB.r, self.parent.partRGB.g, self.parent.partRGB.b, self.parent.partRGB.a, UIFont.Small);
		
			
			elseif item.item.part:getId() == "GasTank" then
				local amount = (math.floor(item.item.part:getContainerContentAmount() / item.item.part:getContainerCapacity() * 100))
				charge = ": " .. amount .. "% " .. getText("IGUI_invpanel_Remaining")
				self:drawText(charge, getTextManager():MeasureStringX(UIFont.Small, item.item.name) + 20, y, self.parent.partRGB.r, self.parent.partRGB.g, self.parent.partRGB.b, self.parent.partRGB.a, UIFont.Small);
			end
			-- --print(("NAME..................  " .. tostring(item.item.name))
			local condition = item.item.part:getCondition();
			local invItm = item.item.part:getInventoryItem();
			local condRGB = self.parent:getConditionRGB(item.item.part:getCondition());
			-- self:drawText(" (" .. condition .. "%)", getTextManager():MeasureStringX(UIFont.Small, item.item.name) + 22, y, condRGB.r, condRGB.g, condRGB.b, self.parent.partRGB.a, UIFont.Small)
			self:drawText(" (" .. condition .. "%)", getTextManager():MeasureStringX(UIFont.Small, item.item.name) + getTextManager():MeasureStringX(UIFont.Small, charge) + 22, y, condRGB.r, condRGB.g, condRGB.b, self.parent.partRGB.a, UIFont.Small)
		end
	end
	
	return y + self.itemheight;
end
